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