Skip to content

Updating visuals

If you see any images containing outdated UI, please bear with us.

We are updating all content as quickly as possible to mirror our new UI.

Stripe Checkout

Stripe Checkout is a hosted page where customers enter their payment details. You create a Checkout Session from your backend and redirect the user to it; Stripe handles the rest and sends them back to your site.

How it works

  1. Your backend creates a Checkout Session (with line items, success/cancel URLs, and mode).
  2. Your app gets the session url from the response and redirects the customer there (e.g. “Pay” button).
  3. Stripe shows the payment page, collects the payment, and redirects to your Success or Cancel URL.
  4. Optional: A webhook runs when the session is completed so you can update your database or send a receipt.

Step 1: Create products and prices in Stripe

Before you can add line items to Checkout, Stripe needs at least one Price (and usually a Product). You can:

  • Create them in the Stripe Dashboard, or
  • Use the Create Product and Create Price actions from a WeWeb workflow or API.

For a subscription, create a recurring price (e.g. monthly). Note the Price ID (e.g. price_123...).

Step 2: Create an API that creates a Checkout Session

  1. In WeWeb, go to Data & API → APIs and create a new API (e.g. POST /create-checkout).
  2. In the workflow for that API, add the Stripe action Create Checkout Session.
  3. Configure:
    • Modepayment (one-time) or subscription (recurring).
    • Line Items — e.g. [{ "price": "price_123...", "quantity": 1 }] (use your Stripe Price IDs).
    • Success URL — e.g. https://yoursite.com/success?session_id={CHECKOUT_SESSION_ID}. Stripe replaces {CHECKOUT_SESSION_ID} with the real ID.
    • Cancel URL — e.g. https://yoursite.com/cancel.
    • Customer or Customer Email (optional).
    • Metadata (optional) — e.g. order ID for your records.
  4. Return the session’s url (and optionally id) in the API response.

For subscriptions, you can add Subscription Data (e.g. { "trial_period_days": 14 }).

Step 3: Redirect the customer from your interface

On the page where the user clicks “Pay” (or “Subscribe”):

  1. Call the API you created (e.g. POST /create-checkout) with the right body (e.g. price ID, quantity).
  2. From the response, take the session url.
  3. Redirect: e.g. window.location.href = response.url.

The customer will land on Stripe’s page, pay, and then be sent to your Success or Cancel URL.

Step 4: (Optional) Use the success page or a webhook

  • Success page: You can call Retrieve Checkout Session with the session_id from the URL to show order details or confirmation.
  • Webhook: Create a backend workflow with trigger On checkout session event. When context.event.action is completed, update your orders table, send a receipt, or grant access. See Webhooks.

Main inputs at a glance

InputExampleDescription
Modepaymentpayment (one-time), subscription, or setup
Line Items[{"price":"price_123","quantity":1}]Required for payment/subscription. Use Stripe Price IDs.
Success URLhttps://yoursite.com/success?session_id={CHECKOUT_SESSION_ID}Where to send the customer after success.
Cancel URLhttps://yoursite.com/cancelWhere to send the customer if they cancel.
Customercus_xxxOptional. Existing Stripe customer ID.
Customer Emailuser@example.comOptional. Used when no Customer ID is provided.
Metadata{"order_id":"123"}Optional. Available in webhooks.

Full parameter list: Actions reference → Create Checkout Session.


Next: Payment Intents and subscriptions or Webhooks