Stripe Development & Integration
Stripe is a payment infrastructure platform providing APIs and tools for internet commerce. This skill covers the core development workflows: API authentication, payment processing, webhook handling, error management, testing strategies, and building multi-party platforms with Stripe Connect.
When to Use This Skill
This skill should be triggered when:
- Integrating Stripe payments (checkout, subscriptions, invoices)
- Setting up API keys and authentication
- Implementing webhook endpoints and signature verification
- Handling Stripe errors and decline codes
- Testing with sandbox/test cards
- Building platforms or marketplaces with Stripe Connect
- Managing connected accounts, charges, transfers, and payouts
- Using Stripe SDKs (Node.js, Python, Ruby, Go, Java, PHP, .NET)
- Debugging Stripe API issues
Quick Reference
API Base URL
https://api.stripe.com
Authentication
# Secret key (server-side only)
curl https://api.stripe.com/v1/charges \
-u sk_test_xxxx:
# Or via Authorization header
curl https://api.stripe.com/v1/charges \
-H "Authorization: Bearer sk_test_xxxx"
Key Prefixes
| Mode |
Secret Key |
Publishable Key |
Restricted Key |
| Sandbox |
sk_test_ |
pk_test_ |
rk_test_ |
| Live |
sk_live_ |
pk_live_ |
rk_live_ |
Available SDKs
| Platform |
Package |
| Node.js |
stripe |
| Python |
stripe |
| Ruby |
stripe |
| Go |
github.com/stripe/stripe-go |
| Java |
com.stripe:stripe-java |
| PHP |
stripe/stripe-php |
| .NET |
Stripe.net |
| React (web) |
@stripe/react-stripe-js |
| iOS |
StripePaymentSheet |
| Android |
com.stripe:stripe-android |
| React Native |
@stripe/stripe-react-native |
Common Test Cards
| Card |
Number |
PaymentMethod |
| Visa |
4242424242424242 |
pm_card_visa |
| Visa (debit) |
4000056655665556 |
pm_card_visa_debit |
| Mastercard |
5555555555554444 |
pm_card_mastercard |
| Amex |
378282246310005 |
pm_card_amex |
| Declined |
4000000000000002 |
pm_card_chargeDeclined |
| Fraud block |
- |
pm_card_radarBlock |
| Expired |
- |
pm_card_chargeDeclinedExpiredCard |
Use any future expiry date, any 3-digit CVC (4 for Amex), any other values.
Create a Payment Intent (curl)
curl https://api.stripe.com/v1/payment_intents \
-u sk_test_xxx: \
-d amount=2000 \
-d currency=usd \
-d "payment_method_types[]"=card
Connect Charge Types
| Type |
Use Case |
Fund Flow |
| Direct charges |
SaaS platforms |
Customer → Connected Account → Platform fee |
| Destination charges |
Marketplaces |
Customer → Platform → Connected Account |
| Separate charges & transfers |
Complex splits |
Customer → Platform → Multiple accounts |
Webhook Signature Verification (Node.js)
const stripe = require('stripe')('sk_test_xxx');
const endpointSecret = 'whsec_xxx';
app.post('/webhook', (req, res) => {
const sig = req.headers['stripe-signature'];
let event;
try {
event = stripe.webhooks.constructEvent(req.body, sig, endpointSecret);
} catch (err) {
return res.status(400).send(`Webhook Error: ${err.message}`);
}
// Handle event
res.status(200).json({received: true});
});
Error Types
| Exception Class |
HTTP |
Cause |
CardError |
402 |
Payment declined / card issue |
InvalidRequestError |
400 |
Wrong parameters or invalid state |
AuthenticationError |
401 |
Bad API key |
RateLimitError |
429 |
Too many requests |
APIConnectionError |
- |
Network failure |
APIError |
500 |
Stripe server error |
IdempotencyError |
400 |
Mismatched idempotency key |
PermissionError |
403 |
Restricted key lacks permissions |
SignatureVerificationError |
- |
Invalid webhook signature |
References
api-keys-auth.md - API keys, authentication, security best practices, key management
error-handling.md - Error types, exception handling patterns, test cards for errors
webhooks.md - Webhook setup, signature verification, event handling, testing, best practices
testing.md - Sandbox environment, test card numbers by brand/country, PaymentMethods, going live
connect-overview.md - Connect platform design, account types, charge types, onboarding, payouts
connect-charges.md - Direct/destination/separate charges, platform fees, fund flow
development-essentials.md - SDKs, expanding objects, pagination, idempotency, versioning, metadata
1---2name: stripe3description: Stripe payment platform integration guide covering API authentication, webhooks, error handling, testing, Connect platforms/marketplaces, SDKs, and development best practices. This skill should be used when building payment integrations with Stripe, implementing checkout flows, managing subscriptions, handling webhooks, creating Connect platforms, processing payouts, or debugging Stripe API errors.4---5
6# Stripe Development & Integration
7
8Stripe is a payment infrastructure platform providing APIs and tools for internet commerce. This skill covers the core development workflows: API authentication, payment processing, webhook handling, error management, testing strategies, and building multi-party platforms with Stripe Connect.
9
10## When to Use This Skill
11
12This skill should be triggered when:
13- Integrating Stripe payments (checkout, subscriptions, invoices)
14- Setting up API keys and authentication
15- Implementing webhook endpoints and signature verification
16- Handling Stripe errors and decline codes
17- Testing with sandbox/test cards
18- Building platforms or marketplaces with Stripe Connect
19- Managing connected accounts, charges, transfers, and payouts
20- Using Stripe SDKs (Node.js, Python, Ruby, Go, Java, PHP, .NET)
21- Debugging Stripe API issues
22
23## Quick Reference
24
25### API Base URL
26
27```
28https://api.stripe.com
29```
30
31### Authentication
32
33```bash
34# Secret key (server-side only)
35curl https://api.stripe.com/v1/charges \
36 -u sk_test_xxxx:
37
38# Or via Authorization header
39curl https://api.stripe.com/v1/charges \
40 -H "Authorization: Bearer sk_test_xxxx"
41```
42
43### Key Prefixes
44
45| Mode | Secret Key | Publishable Key | Restricted Key |
46|------|-----------|-----------------|----------------|
47| Sandbox | `sk_test_` | `pk_test_` | `rk_test_` |
48| Live | `sk_live_` | `pk_live_` | `rk_live_` |
49
50### Available SDKs
51
52| Platform | Package |
53|----------|---------|
54| Node.js | `stripe` |
55| Python | `stripe` |
56| Ruby | `stripe` |
57| Go | `github.com/stripe/stripe-go` |
58| Java | `com.stripe:stripe-java` |
59| PHP | `stripe/stripe-php` |
60| .NET | `Stripe.net` |
61| React (web) | `@stripe/react-stripe-js` |
62| iOS | `StripePaymentSheet` |
63| Android | `com.stripe:stripe-android` |
64| React Native | `@stripe/stripe-react-native` |
65
66### Common Test Cards
67
68| Card | Number | PaymentMethod |
69|------|--------|---------------|
70| Visa | `4242424242424242` | `pm_card_visa` |
71| Visa (debit) | `4000056655665556` | `pm_card_visa_debit` |
72| Mastercard | `5555555555554444` | `pm_card_mastercard` |
73| Amex | `378282246310005` | `pm_card_amex` |
74| Declined | `4000000000000002` | `pm_card_chargeDeclined` |
75| Fraud block | - | `pm_card_radarBlock` |
76| Expired | - | `pm_card_chargeDeclinedExpiredCard` |
77
78Use any future expiry date, any 3-digit CVC (4 for Amex), any other values.
79
80### Create a Payment Intent (curl)
81
82```bash
83curl https://api.stripe.com/v1/payment_intents \
84 -u sk_test_xxx: \
85 -d amount=2000 \
86 -d currency=usd \
87 -d "payment_method_types[]"=card
88```
89
90### Connect Charge Types
91
92| Type | Use Case | Fund Flow |
93|------|----------|-----------|
94| Direct charges | SaaS platforms | Customer → Connected Account → Platform fee |
95| Destination charges | Marketplaces | Customer → Platform → Connected Account |
96| Separate charges & transfers | Complex splits | Customer → Platform → Multiple accounts |
97
98### Webhook Signature Verification (Node.js)
99
100```javascript
101const stripe = require('stripe')('sk_test_xxx');
102const endpointSecret = 'whsec_xxx';
103
104app.post('/webhook', (req, res) => {
105 const sig = req.headers['stripe-signature'];
106 let event;
107 try {
108 event = stripe.webhooks.constructEvent(req.body, sig, endpointSecret);
109 } catch (err) {
110 return res.status(400).send(`Webhook Error: ${err.message}`);
111 }
112 // Handle event
113 res.status(200).json({received: true});
114});
115```
116
117### Error Types
118
119| Exception Class | HTTP | Cause |
120|----------------|------|-------|
121| `CardError` | 402 | Payment declined / card issue |
122| `InvalidRequestError` | 400 | Wrong parameters or invalid state |
123| `AuthenticationError` | 401 | Bad API key |
124| `RateLimitError` | 429 | Too many requests |
125| `APIConnectionError` | - | Network failure |
126| `APIError` | 500 | Stripe server error |
127| `IdempotencyError` | 400 | Mismatched idempotency key |
128| `PermissionError` | 403 | Restricted key lacks permissions |
129| `SignatureVerificationError` | - | Invalid webhook signature |
130
131## References
132
133- `api-keys-auth.md` - API keys, authentication, security best practices, key management
134- `error-handling.md` - Error types, exception handling patterns, test cards for errors
135- `webhooks.md` - Webhook setup, signature verification, event handling, testing, best practices
136- `testing.md` - Sandbox environment, test card numbers by brand/country, PaymentMethods, going live
137- `connect-overview.md` - Connect platform design, account types, charge types, onboarding, payouts
138- `connect-charges.md` - Direct/destination/separate charges, platform fees, fund flow
139- `development-essentials.md` - SDKs, expanding objects, pagination, idempotency, versioning, metadata