Build a tiny NextJS app that sells one digital product and one subscription. Keep auth, database, and UI as thin as possible. Prefer Stripe Checkout and the Stripe CLI for most sections.
- Create or open a sandbox (or toggle test mode)
- Load
sk_test_...on the server only - Make one authenticated API call and log the response
- Sandbox
- Test mode
- Live mode
- Secret key (
sk_test_...) - Publishable key (
pk_test_...) - Stripe SDK / API client
- API version
- Create a Product for a one-time item
- Create a Product for a recurring item
- Attach Price objects (one-time and recurring)
- List products and prices from the API
ProductPrice- One-time price
- Recurring price
currencyunit_amountunit_amount_decimal
- Create a Customer with email and name
- Retrieve and update that Customer
- Attach metadata
- Keep the Stripe Customer id in app state (in-memory is fine)
Customermetadata- Customer list / search
customerid
- Create a Checkout Session in
paymentmode - Redirect the browser to
session.url - Land on success and cancel URLs
- Inspect the Session in the Dashboard
- Checkout Session
mode: "payment"line_itemssuccess_urlcancel_urlclient_reference_idsession.url
- Create a PaymentIntent server-side for a fixed amount
- Retrieve the PaymentIntent after Checkout completes
- Walk the status values on test payments
PaymentIntentamountcurrencystatusrequires_payment_methodrequires_actionprocessingsucceededcanceledautomatic_payment_methodscapture_method
- Install Stripe CLI and forward events to localhost
- Verify webhook signatures
- Handle
checkout.session.completed - Handle
payment_intent.succeeded - Handle
payment_intent.payment_failed
- Webhook endpoint
- Signing secret
constructEventEventtypedata.object- Stripe CLI
listen - Stripe CLI
trigger event.id
- Create a SetupIntent (or Checkout setup flow) to save a card
- Attach a PaymentMethod to a Customer
- List a Customer's payment methods
- Charge a saved PaymentMethod off-session in test mode
SetupIntentPaymentMethodpayment_method- Off-session payment
- Customer default payment method
- Create a Checkout Session in
subscriptionmode - Create a Subscription for an existing Customer with a Price
- Cancel at period end
- Cancel immediately
Subscriptionmode: "subscription"- Subscription item
statusincompleteactivepast_duecanceledcurrent_period_endcancel_at_period_endsubscription.createdcustomer.subscription.updatedcustomer.subscription.deleted
- Create a Coupon (percent or amount off)
- Create a Promotion Code
- Apply it on a Checkout Session
- Confirm the discount on the resulting object
CouponPromotionCodepercent_offamount_off- Duration (
once,repeating,forever) - Checkout
discounts allow_promotion_codes- Max redemptions
- Expiry
- Refund a succeeded PaymentIntent in full
- Refund partially
Refund- Partial refund
- Full refund
- Refund reason
charge.refunded
- Add one small page that loads Stripe.js with
pk_test_... - Create a PaymentIntent on the server
- Pass
client_secretto the page - Confirm payment with Payment Element
- Stripe.js
- Payment Element
client_secretstripe.confirmPayment
- Create a connected account in test / sandbox
- Create a destination charge or transfer-style payment in test mode
- Stripe Connect
- Connected account
- Standard / Express / Custom
- Application fee
- Destination charge
- Separate charges and transfers
- Connect account events
- Keep secret keys server-side only
- Validate Price ids and amounts on the server
- Attach metadata that links Stripe objects to app records
- Server-side Price validation
metadata- Webhook signature verification in production
- Stripe request id
- Live mode keys