Stripe Integration
When to Use
Trigger phrases:
"stripe integration"
"Integrate Stripe for payments, subscriptions, invoicing, and billing"
When adding payment processing to an application
When implementing subscription billing or recurring payments
When building checkout flows or payment forms
When handling Stripe webhooks for payment events
When NOT to Use
- For non-Stripe payment gateways (use their specific skills)
- For simple donation pages (use simpler payment widgets)
Overview
Full Stripe integration covering payments, subscriptions, invoicing, and billing. Handles checkout sessions, customer portal, webhooks, and error handling.
Workflow
- Install SDK -
npm install stripe or pip install stripe
- Configure - Set API keys (test + live), webhook endpoints
- Build checkout - Create checkout sessions or payment elements
- Handle webhooks - Process payment events (succeeded, failed, refunded)
- Manage customers - Create, update, attach payment methods
- Handle errors - Declined cards, expired tokens, rate limits
Anti-Rationalization Table
| Rationalization |
Reality |
| "I will handle payments myself" |
PCI compliance is complex - Stripe handles it for you |
| "Webhooks are optional" |
Without webhooks, you miss failed payments, refunds, and disputes |
| "Test mode is enough" |
Always test with real card numbers in live mode before launch |
Code Example (Node.js)
const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY);
const session = await stripe.checkout.sessions.create({
mode: 'subscription',
payment_method_types: ['card'],
line_items: [{ price: 'price_xxx', quantity: 1 }],
success_url: 'https://example.com/success',
cancel_url: 'https://example.com/cancel',
});
app.post('/webhook', express.raw({type: 'application/json'}), (req, res) => {
const sig = req.headers['stripe-signature'];
const event = stripe.webhooks.constructEvent(req.body, sig, endpointSecret);
switch (event.type) {
case 'invoice.payment_succeeded': break;
case 'invoice.payment_failed': break;
}
res.json({received: true});
});
Process
- Prepare — Gather requirements, verify prerequisites, set up environment
- Execute — Run stripe integration workflow with configured parameters
- Verify — Validate output meets requirements, document results
Verification
1---2name: stripe-integration3description: Use when integrate Stripe for payments, subscriptions, invoicing, and billing. Handle checkout sessions, webhooks, customer management, and payment method handling. Use when integrateing stripe for payments, subscriptions, invoicing, and billing. handle checkout.4license: Apache-2.05---678# Stripe Integration910## When to Use11**Trigger phrases:**12- "stripe integration"13- "Integrate Stripe for payments, subscriptions, invoicing, and billing"141516- When adding payment processing to an application17- When implementing subscription billing or recurring payments18- When building checkout flows or payment forms19- When handling Stripe webhooks for payment events2021## When NOT to Use2223- For non-Stripe payment gateways (use their specific skills)24- For simple donation pages (use simpler payment widgets)2526## Overview2728Full Stripe integration covering payments, subscriptions, invoicing, and billing. Handles checkout sessions, customer portal, webhooks, and error handling.2930## Workflow31321. **Install SDK** - `npm install stripe` or `pip install stripe`332. **Configure** - Set API keys (test + live), webhook endpoints343. **Build checkout** - Create checkout sessions or payment elements354. **Handle webhooks** - Process payment events (succeeded, failed, refunded)365. **Manage customers** - Create, update, attach payment methods376. **Handle errors** - Declined cards, expired tokens, rate limits3839## Anti-Rationalization Table4041| Rationalization | Reality |42|---|---|43| "I will handle payments myself" | PCI compliance is complex - Stripe handles it for you |44| "Webhooks are optional" | Without webhooks, you miss failed payments, refunds, and disputes |45| "Test mode is enough" | Always test with real card numbers in live mode before launch |4647## Code Example (Node.js)4849```javascript50const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY);5152const session = await stripe.checkout.sessions.create({53 mode: 'subscription',54 payment_method_types: ['card'],55 line_items: [{ price: 'price_xxx', quantity: 1 }],56 success_url: 'https://example.com/success',57 cancel_url: 'https://example.com/cancel',58});5960app.post('/webhook', express.raw({type: 'application/json'}), (req, res) => {61 const sig = req.headers['stripe-signature'];62 const event = stripe.webhooks.constructEvent(req.body, sig, endpointSecret);63 switch (event.type) {64 case 'invoice.payment_succeeded': break;65 case 'invoice.payment_failed': break;66 }67 res.json({received: true});68});69```707172## Process73741. **Prepare** — Gather requirements, verify prerequisites, set up environment751. **Execute** — Run stripe integration workflow with configured parameters761. **Verify** — Validate output meets requirements, document results7778## Verification7980- [ ] Checkout session creates successfully81- [ ] Payment processes in test mode82- [ ] Webhooks verify signature correctly83- [ ] Failed payments handled gracefully84