Skip to content

Instantly share code, notes, and snippets.

@davidystephenson
Created August 18, 2026 23:56
Show Gist options
  • Select an option

  • Save davidystephenson/7a26a98698b716feea6f9ee96fb483ea to your computer and use it in GitHub Desktop.

Select an option

Save davidystephenson/7a26a98698b716feea6f9ee96fb483ea to your computer and use it in GitHub Desktop.

Stripe learning plan

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.

1. Account, keys, and API client

  • 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

Topics

  • Sandbox
  • Test mode
  • Live mode
  • Secret key (sk_test_...)
  • Publishable key (pk_test_...)
  • Stripe SDK / API client
  • API version

2. Products and prices

  • 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

Topics

  • Product
  • Price
  • One-time price
  • Recurring price
  • currency
  • unit_amount
  • unit_amount_decimal

3. Customers

  • 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)

Topics

  • Customer
  • metadata
  • Customer list / search
  • customer id

4. One-time payment with Checkout

  • Create a Checkout Session in payment mode
  • Redirect the browser to session.url
  • Land on success and cancel URLs
  • Inspect the Session in the Dashboard

Topics

  • Checkout Session
  • mode: "payment"
  • line_items
  • success_url
  • cancel_url
  • client_reference_id
  • session.url

5. PaymentIntent lifecycle

  • Create a PaymentIntent server-side for a fixed amount
  • Retrieve the PaymentIntent after Checkout completes
  • Walk the status values on test payments

Topics

  • PaymentIntent
  • amount
  • currency
  • status
  • requires_payment_method
  • requires_action
  • processing
  • succeeded
  • canceled
  • automatic_payment_methods
  • capture_method

6. Webhooks

  • Install Stripe CLI and forward events to localhost
  • Verify webhook signatures
  • Handle checkout.session.completed
  • Handle payment_intent.succeeded
  • Handle payment_intent.payment_failed

Topics

  • Webhook endpoint
  • Signing secret
  • constructEvent
  • Event
  • type
  • data.object
  • Stripe CLI listen
  • Stripe CLI trigger
  • event.id

7. Saved payment methods

  • 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

Topics

  • SetupIntent
  • PaymentMethod
  • payment_method
  • Off-session payment
  • Customer default payment method

8. Subscriptions

  • Create a Checkout Session in subscription mode
  • Create a Subscription for an existing Customer with a Price
  • Cancel at period end
  • Cancel immediately

Topics

  • Subscription
  • mode: "subscription"
  • Subscription item
  • status
  • incomplete
  • active
  • past_due
  • canceled
  • current_period_end
  • cancel_at_period_end
  • subscription.created
  • customer.subscription.updated
  • customer.subscription.deleted

9. Coupons and promotion codes

  • Create a Coupon (percent or amount off)
  • Create a Promotion Code
  • Apply it on a Checkout Session
  • Confirm the discount on the resulting object

Topics

  • Coupon
  • PromotionCode
  • percent_off
  • amount_off
  • Duration (once, repeating, forever)
  • Checkout discounts
  • allow_promotion_codes
  • Max redemptions
  • Expiry

10. Refunds

  • Refund a succeeded PaymentIntent in full
  • Refund partially

Topics

  • Refund
  • Partial refund
  • Full refund
  • Refund reason
  • charge.refunded

11. Payment Element

  • Add one small page that loads Stripe.js with pk_test_...
  • Create a PaymentIntent on the server
  • Pass client_secret to the page
  • Confirm payment with Payment Element

Topics

  • Stripe.js
  • Payment Element
  • client_secret
  • stripe.confirmPayment

12. Connect

  • Create a connected account in test / sandbox
  • Create a destination charge or transfer-style payment in test mode

Topics

  • Stripe Connect
  • Connected account
  • Standard / Express / Custom
  • Application fee
  • Destination charge
  • Separate charges and transfers
  • Connect account events

13. Hardening

  • Keep secret keys server-side only
  • Validate Price ids and amounts on the server
  • Attach metadata that links Stripe objects to app records

Topics

  • Server-side Price validation
  • metadata
  • Webhook signature verification in production
  • Stripe request id
  • Live mode keys
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment