Stripe Integration
Accept credit cards, Apple Pay, Google Pay, and 40+ payment methods globally using Stripe as your payment provider.Prerequisites
Before you begin, make sure you have:- A Stripe account — sign up at stripe.com if you don’t have one
- Your Stripe API keys from the Stripe Dashboard
- A working Headless Commerce store with at least one product
Use test mode keys (
sk_test_... / pk_test_...) during development. Switch to live keys only when you’re ready to accept real payments.Environment Variables
Add the following environment variables to your API server:Checkout Flow
The complete Stripe checkout flow involves four steps: creating a cart, initiating checkout, confirming payment on the client, and handling the webhook confirmation.Webhook Setup
Headless Commerce listens for Stripe webhook events to keep order and payment statuses in sync. Configure webhooks in the Stripe Dashboard:- Go to Developers → Webhooks in the Stripe Dashboard
- Click Add endpoint
- Enter your webhook URL:
https://api.headlesscommerce.io/v1/webhooks/stripe - Select the following events:
payment_intent.succeededpayment_intent.payment_failedcharge.refundedcharge.dispute.created
- Copy the Signing secret and set it as
STRIPE_WEBHOOK_SECRET
Event handling
Refunds
Issue full or partial refunds through the Admin API:Testing
Test mode keys
Always use test mode API keys during development. These keys create test-only transactions that never hit real payment networks.Test card numbers
Use these card numbers in test mode:
Use any future expiration date, any 3-digit CVC, and any postal code.
Testing webhooks locally
Use the Stripe CLI to forward webhook events to your local development server:Error Handling
Handle payment errors gracefully in your frontend:confirmPayment():
Next Steps
Webhooks
Learn about all webhook events and payload formats.
TossPayments
Set up TossPayments for Korean payment methods.
API Reference
Explore all checkout and payment endpoints.
SDKs
Full SDK reference with every resource and method.