runway

Runway

Stripe Payments Overview

An overview of the Stripe payment system in this boilerplate, covering one-time payments, subscriptions, tax handling, and webhook events.

This boilerplate comes with a full Stripe integration that’s designed to be optimal, modular, and production‑ready. Whether you need to accept one‑time payments or manage subscriptions, everything is pre-configured with tax handling, webhook event processing, and secure practices.

One-Time Payments

For single payments, a Checkout Session is created in “payment” mode. Your customers will be redirected to a secure, Stripe‑hosted payment page.

jsx

1// Creating a one-time Checkout Session:
2await createCheckoutSession({
3planType: "starter",
4mode: "payment",
5successUrl: "https://your-app.com/thank-you",
6cancelUrl: "https://your-app.com/",
7});

The Checkout Session automatically enables tax calculation, so you don’t need to worry about handling taxes manually.

Subscriptions

Subscriptions work similarly—simply set the mode to “subscription” and the same session logic applies.

jsx

1// Creating a subscription Checkout Session:
2await createCheckoutSession({
3planType: "pro",
4mode: "subscription",
5successUrl: "https://your-app.com/thank-you",
6cancelUrl: "https://your-app.com/",
7});

This setup allows you to handle recurring billing without additional complexity.

Tax Handling

Stripe Checkout includes automatic tax calculation when you enable it in the session. The boilerplate sets automatic_tax: { enabled: true } so tax is computed based on the customer’s location.

Tip: If you need advanced tax reporting, refer to Stripe Tax documentation and adjust your dashboard settings accordingly.

Webhook Event Handling

Webhooks are critical for processing asynchronous payment events. The webhook endpoint in this boilerplate listens for events such as:

  • checkout.session.completed: When a payment or subscription is successfully completed.
  • checkout.session.expired: When a session expires.
  • invoice.payment_failed and invoice.payment_succeeded: To track invoice outcomes.

jsx

1// Example webhook processing:
2await handleStripeWebhookEvent(event);

Customize event handlers in libs/stripe/webhookHandlers.js to fit your business logic.

Security & Best Practices

Store your Stripe API keys and webhook secret in environment variables. Never expose them in client-side code.

Always verify webhook signatures to ensure events are truly from Stripe.

Double-check your success and cancel URLs in production to avoid misdirected payments.

This complete payment system lets you focus on building your app while I’ve done the heavy lifting on Stripe integration.