PayPal Integration

PayPal Integration

Teaches an agent to integrate PayPal checkout, subscriptions, IPN webhooks and refunds into a web app, with client and server code examples.

Skill files2 files

references/

SKILL.md157 lines
1
---
2
name: paypal-integration
3
description: Integrate PayPal payment processing with support for express checkout, subscriptions, and refund management. Use when implementing PayPal payments, processing online transactions, or building e-commerce checkout flows.
4
---
5
6
# PayPal Integration
7
8
Master PayPal payment integration including Express Checkout, IPN handling, recurring billing, and refund workflows.
9
10
## When to Use This Skill
11
12
- Integrating PayPal as a payment option
13
- Implementing express checkout flows
14
- Setting up recurring billing with PayPal
15
- Processing refunds and payment disputes
16
- Handling PayPal webhooks (IPN)
17
- Supporting international payments
18
- Implementing PayPal subscriptions
19
20
## Core Concepts
21
22
### 1. Payment Products
23
24
**PayPal Checkout**
25
26
- One-time payments
27
- Express checkout experience
28
- Guest and PayPal account payments
29
30
**PayPal Subscriptions**
31
32
- Recurring billing
33
- Subscription plans
34
- Automatic renewals
35
36
**PayPal Payouts**
37
38
- Send money to multiple recipients
39
- Marketplace and platform payments
40
41
### 2. Integration Methods
42
43
**Client-Side (JavaScript SDK)**
44
45
- Smart Payment Buttons
46
- Hosted payment flow
47
- Minimal backend code
48
49
**Server-Side (REST API)**
50
51
- Full control over payment flow
52
- Custom checkout UI
53
- Advanced features
54
55
### 3. IPN (Instant Payment Notification)
56
57
- Webhook-like payment notifications
58
- Asynchronous payment updates
59
- Verification required
60
61
## Quick Start
62
63
```javascript
64
// Frontend - PayPal Smart Buttons
65
<div id="paypal-button-container"></div>
66
67
<script src="https://www.paypal.com/sdk/js?client-id=YOUR_CLIENT_ID&currency=USD"></script>
68
<script>
69
paypal.Buttons({
70
createOrder: function(data, actions) {
71
return actions.order.create({
72
purchase_units: [{
73
amount: {
74
value: '25.00'
75
}
76
}]
77
});
78
},
79
onApprove: function(data, actions) {
80
return actions.order.capture().then(function(details) {
81
// Payment successful
82
console.log('Transaction completed by ' + details.payer.name.given_name);
83
84
// Send to backend for verification
85
fetch('/api/paypal/capture', {
86
method: 'POST',
87
headers: {'Content-Type': 'application/json'},
88
body: JSON.stringify({orderID: data.orderID})
89
});
90
});
91
}
92
}).render('#paypal-button-container');
93
</script>
94
```
95
96
```python
97
# Backend - Verify and capture order
98
from paypalrestsdk import Payment
99
import paypalrestsdk
100
101
paypalrestsdk.configure({
102
"mode": "sandbox", # or "live"
103
"client_id": "YOUR_CLIENT_ID",
104
"client_secret": "YOUR_CLIENT_SECRET"
105
})
106
107
def capture_paypal_order(order_id):
108
"""Capture a PayPal order."""
109
payment = Payment.find(order_id)
110
111
if payment.execute({"payer_id": payment.payer.payer_info.payer_id}):
112
# Payment successful
113
return {
114
'status': 'success',
115
'transaction_id': payment.id,
116
'amount': payment.transactions[0].amount.total
117
}
118
else:
119
# Payment failed
120
return {
121
'status': 'failed',
122
'error': payment.error
123
}
124
```
125
126
## Detailed patterns and worked examples
127
128
Detailed pattern documentation lives in `references/details.md`. Read that file when the navigation tier above is insufficient.
129
130
## Testing
131
132
```python
133
# Use sandbox credentials
134
SANDBOX_CLIENT_ID = "..."
135
SANDBOX_SECRET = "..."
136
137
# Test accounts
138
# Create test buyer and seller accounts at developer.paypal.com
139
140
def test_payment_flow():
141
"""Test complete payment flow."""
142
client = PayPalClient(SANDBOX_CLIENT_ID, SANDBOX_SECRET, mode='sandbox')
143
144
# Create order
145
order = client.create_order(10.00)
146
assert 'id' in order
147
148
# Get approval URL
149
approval_url = next((link['href'] for link in order['links'] if link['rel'] == 'approve'), None)
150
assert approval_url is not None
151
152
# After approval (manual step with test account)
153
# Capture order
154
# captured = client.capture_order(order['id'])
155
# assert captured['status'] == 'COMPLETED'
156
```
157

© Seth Hobson · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 10,803 prompts

More by @OpenSourceBuffGuy

See all
Novelist & Book Architect (Genre-Aware) prompt image

Novelist & Book Architect (Genre-Aware)

Builds a full novel blueprint from a pitch: premise, comp titles, world bible, four characters, a 20-beat outline and a sample opening.

novel-writing, creative-writing, worldbuilding, character-development, act-as, for-writers, outline, structured-output, writing, storytelling, sci-fi, fantasy-world, romance, thriller, horror, publishing, editing, template, guardrails, advanced, books, literature

Playwright Integration Testing prompt image

Playwright Integration Testing

Sets Cursor up as a QA engineer who writes focused Playwright integration tests in TypeScript, mocking API routes and covering key user flows.

rule-file, cursor, playwright, typescript, testing, end-to-end-testing, best-practices, test-generation, for-developers, code, few-shot, guardrails, javascript, test-cases, api, act-as

Candid Portrait of Young Woman in Rainy Night Car prompt image

Candid Portrait of Young Woman in Rainy Night Car

Draws a candid flash-style portrait of a young woman in a car seat at night, with rain on the window and blurred city lights behind her.

image-prompt, json-prompt, photorealistic, woman, portrait, rain, night-scene, candid, smartphone-photo, bokeh, vertical-format, negative-prompt, moody, cityscape, cars, soft-lighting, close-up

Reviews

Loading reviews…

Discussion

Loading comments…