ablevarghese/ios-claude-toolkit/stripe-best-practices

Claude Code and agent skill by ablevarghese/ios-claude-toolkit

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Accept payments, Stripe integration, subscription billing, payment flow design. Stripe integration design patterns and official best practices — CheckoutSessions, PaymentIntents, PaymentSheet, Connect marketplace, webhook security, deprecated API migration. Trigger on: 'add payments', 'set up Stripe', 'which Stripe API to use', 'build a checkout flow', 'implement subscriptions', 'Connect marketplace', 'handle refunds', or any payment architecture decision. For Stripe CLI testing and test cards, use hermes-stripe. For StoreKit/IAP, use cupertino-apple.

Install

npx vskill@latest install ablevarghese/ios-claude-toolkit/stripe-best-practices

SKILL.md

The same SKILL.md was published earlier as ablevarghese/ios-claude-toolkit/stripe-best-practices.

Stripe Best Practices

Iron Law: "Never store raw card data. Never use deprecated Stripe APIs. Never skip webhook signature verification."

Official Stripe integration best practices. Reference these guidelines when building, reviewing, or debugging Stripe integrations.

Source: github.com/stripe/ai


Rationalizations (Do Not Skip)

RationalizationWhy It's WrongRequired Action
"The Charges API still works"The Charges API lacks 3D Secure support, SCA compliance, dynamic payment methods, and modern error handling. It will eventually be removed. Every new integration using Charges is technical debt from day one.Use CheckoutSessions (preferred) or PaymentIntents. Migrate existing Charges integrations using Stripe's migration guide.
"We don't need webhook verification in development"If you don't verify signatures in dev, you won't catch verification bugs until production. You're also training developers to skip a critical security step. The webhook signing secret takes 30 seconds to configure.Always verify webhook signatures. Use stripe listen --forward-to for local development, which provides a signing secret.
"We'll migrate to the new API later"Every month on deprecated APIs increases migration cost. New features only ship on modern APIs. You're falling further behind while accumulating more code to migrate.Start migration now. Stripe provides incremental migration paths -- you don't need to rewrite everything at once.
"Manual testing is sufficient"Payment integrations have 20+ distinct scenarios (success, decline codes, 3DS flows, webhook races, refunds, disputes). Manual testing catches 3-5 of them. The other 15+ fail in production.Use systematic test card coverage. Write automated tests for every webhook handler. Test every decline scenario. See references/payment-flows.md.
"We can log the full Stripe response for debugging"Stripe responses can contain PII and partial card data. Logging raw responses may violate PCI requirements and privacy regulations.Log only: Stripe event ID, event type, payment intent ID, error code. Never log full response bodies in production.
"Idempotency keys are optional"Without idempotency keys, network retries or user double-clicks create duplicate charges. This is the #1 source of payment disputes from integration bugs.Add idempotency keys to every POST request. Use a deterministic key (e.g., {user_id}_{action}_{timestamp} or UUID stored before the request).

Red Flags -- STOP

  • Using deprecated APIs: Charges API, Sources API, Tokens API, legacy Card Element. These are missing SCA support, modern payment methods, and will be deprecated. Migrate immediately.
  • Missing webhook signature verification: stripe.webhooks.constructEvent() must use the endpoint signing secret. Without verification, anyone can send fake events to your webhook endpoint.
  • Logging card numbers: Even partial PANs in logs violate PCI. Use Stripe Dashboard or request IDs for debugging.
  • Missing idempotency keys: All POST requests to Stripe must include Idempotency-Key headers. Without them, retries create duplicates.
  • Service role / secret key in client code: Stripe secret keys must NEVER appear in iOS app bundles, JavaScript, or any client-side code. Only publishable keys on the client.
  • Hardcoded payment_method_types: Use dynamic payment methods (enabled in Dashboard). Hardcoding types prevents Stripe from optimizing for the customer's location and preferences.

When NOT to Use This Skill

  • Apple In-App Purchase flows: Digital goods and subscriptions sold within iOS apps must use StoreKit, not Stripe. See cupertino-apple for IAP rules.
  • Stripe CLI testing operations: For test card numbers, webhook forwarding, and CLI commands, see hermes-stripe.
  • Database schema for payment records: For designing the database tables that store payment records, see supabase-postgres-best-practices.
  • Security review of payment code: For a security-focused review of payment handling, see cipher-security or trailofbits-differential-review.

Decision Framework

What kind of payment am I implementing?
ONE-TIME PAYMENT
|-- Is this for a web integration?
| YES --> Use Checkout (Stripe-hosted or embedded)
| NO --> Is this for iOS?
| YES --> Use PaymentSheet with PaymentIntent
| NO --> Use Payment Element with PaymentIntent
|
|-- Do I need to save the card for later?
YES --> Use SetupIntent first, then PaymentIntent off-session
NO --> Single PaymentIntent flow
SUBSCRIPTION / RECURRING
|-- Use Stripe Billing APIs (Subscription + Price objects)
|-- Frontend: Checkout (preferred) or PaymentSheet
|-- Handle: invoice.payment_succeeded, invoice.payment_failed,
| customer.subscription.updated, customer.subscription.deleted
|-- Implement: grace periods, billing retry, upgrade/downgrade
MARKETPLACE / PLATFORM
|-- Use Stripe Connect
|-- Which charge type?
| |-- Platform accepts liability --> Destination charges
| |-- Stripe takes risk --> Direct charges
| |-- Never mix charge types
|
|-- Connected account onboarding: use Account Links
|-- Payout management: configure payout schedule per account

Primary APIs

CheckoutSessions (Preferred)

Stripe's primary API for modeling on-session payments is CheckoutSessions. It supports one-time payments and subscriptions and allows you to model taxes and discounts.

swift
// Server-side: Create CheckoutSession
let session = try await stripe.checkoutSessions.create(
mode: .payment,
lineItems: [
.init(priceData: .init(
currency: "usd",
productData: .init(name: "Transfer fee"),
unitAmount: 299
), quantity: 1)
],
successURL: "yourapp://payment-success",
cancelURL: "yourapp://payment-cancel"
)
// Return session.clientSecret to iOS app
PaymentIntents (For Custom Flows)

Use when you need to model checkout state yourself:

swift
// Server-side: Create PaymentIntent
let paymentIntent = try await stripe.paymentIntents.create(
amount: 5000,
currency: "usd",
automaticPaymentMethods: .init(enabled: true)
)
// iOS: Present PaymentSheet
var configuration = PaymentSheet.Configuration()
configuration.merchantDisplayName = "Your App"
configuration.customer = .init(id: customerId, ephemeralKeySecret: ephemeralKey)
let paymentSheet = PaymentSheet(
paymentIntentClientSecret: paymentIntent.clientSecret,
configuration: configuration
)
Deprecated APIs (Never Recommend)

Confirmation Tokens

If a user wants to render the Payment Element before creating a PaymentIntent or SetupIntent (e.g., to inspect card details for surcharging), advise them to use Stripe Confirmation Tokens. Do not recommend createPaymentMethod or createToken Stripe.js functions.

PCI Compliance

If a PCI compliant user asks about sending server-side raw PAN data, suggest they might be required to prove PCI compliance to gain access to such an option (e.g., payment_method_data). Point users migrating PAN data from another processor to the migration process.


Mobile / iOS Integration (PaymentSheet)

For iOS apps using the Stripe iOS SDK:

swift
import StripePaymentSheet
// 1. Configure at app launch
STPAPIClient.shared.publishableKey = publishableKey
// 2. Create PaymentSheet
var configuration = PaymentSheet.Configuration()
configuration.merchantDisplayName = "Your App"
configuration.defaultBillingDetails.address.country = "US"
configuration.returnURL = "yourapp://stripe-redirect"
configuration.allowsDelayedPaymentMethods = true
// For returning customers
configuration.customer = .init(
id: customerId,
ephemeralKeySecret: ephemeralKeySecret
)
// Use CustomerSession for enhanced returning customer flows
configuration.customerSessionClientSecret = customerSessionClientSecret
// 3. Present PaymentSheet
let paymentSheet = PaymentSheet(
paymentIntentClientSecret: clientSecret,
configuration: configuration
)
// In SwiftUI:
.paymentSheet(isPresented: $showPaymentSheet, paymentSheet: paymentSheet) { result in
switch result {
case .completed:
// Payment completed -- wait for webhook confirmation before fulfilling
break
case .canceled:
// User dismissed
break
case .failed(let error):
// Handle error
break
}
}
PaymentSheet.FlowController

Separate payment method selection from confirmation:

swift
PaymentSheet.FlowController.create(
paymentIntentClientSecret: clientSecret,
configuration: configuration
) { result in
switch result {
case .success(let flowController):
// Show payment option button
// flowController.paymentOption gives selected method info
// Call flowController.presentPaymentOptions() to change
// Call flowController.confirm() to complete
break
case .failure(let error):
break
}
}

Webhook Best Practices

Signature Verification (Non-Negotiable)
typescript
// CORRECT: Always verify webhook signatures
import Stripe from 'stripe';
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);
async function handleWebhook(req: Request): Promise<Response> {
const signature = req.headers.get('stripe-signature');
const body = await req.text();
let event: Stripe.Event;
try {
event = await stripe.webhooks.constructEventAsync(
body,
signature!,
process.env.STRIPE_WEBHOOK_SECRET!
);
} catch (err) {
// Invalid signature -- reject immediately
return new Response('Invalid signature', { status: 400 });
}
// Process event idempotently
await processEvent(event);
// Respond quickly (within 5 seconds)
return new Response('OK', { status: 200 });
}
Idempotent Event Processing
typescript
async function processEvent(event: Stripe.Event): Promise<void> {
// Check if already processed
const { data: existing } = await supabase
.from('stripe_events')
.select('id')
.eq('event_id', event.id)
.single();
if (existing) {
// Already processed -- return success (not error)
return;
}
// Process the event
switch (event.type) {
case 'payment_intent.succeeded':
await handlePaymentSuccess(event.data.object);
break;
case 'payment_intent.payment_failed':
await handlePaymentFailure(event.data.object);
break;
case 'invoice.payment_failed':
await handleSubscriptionPaymentFailure(event.data.object);
break;
}
// Mark as processed
await supabase.from('stripe_events').insert({
event_id: event.id,
type: event.type,
processed_at: new Date().toISOString()
});
}
Critical Events to Handle

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/ablevarghese/ios-claude-toolkit/stripe-best-practices/badge)](https://verified-skill.com/skills/ablevarghese/ios-claude-toolkit/stripe-best-practices)

Something wrong with this skill or its page? Tell us.