Technical reference
Stripe Cheatsheet
Payments, subscriptions, and safe integrations
Must Know
javascript
PaymentIntent
Amounts use the currency's smallest unit.
const intent = await stripe.paymentIntents.create({
amount: 2500,
currency: 'usd',
automatic_payment_methods: { enabled: true },
}, { idempotencyKey });javascript
Webhook Verification
Use the unmodified raw body.
const event = stripe.webhooks.constructEvent(rawBody, signature, endpointSecret);Important Patterns
javascript
Trust Server State
Fulfill from verified webhooks, not client redirects.
switch (event.type) {
case 'payment_intent.succeeded':
await fulfillOrderOnce(event.data.object.id);
}javascript
Metadata
Store internal references, but never secrets or sensitive health data.
metadata: {
orderId: order.id,
tenantId: tenant.id,
}Useful Recipes
javascript
Checkout Session
await stripe.checkout.sessions.create({
mode: 'payment',
line_items: [{ price: priceId, quantity: 1 }],
success_url,
cancel_url,
});javascript
Refund
Track refund state from webhook events.
await stripe.refunds.create({
payment_intent: paymentIntentId,
amount: partialAmount,
}, { idempotencyKey });Pitfalls & Production
Money Rules
integer minor units
do not use floating point
store currency with amount
handle zero-decimal currencies
calculate totals server-sideOperational Safety
Payments need recovery and reconciliation, not only a happy path.
test clocks
restricted API keys
request IDs
webhook replay
fraud controls
reconciliation jobs