Appearance
Workflow examples
These examples show how to wire up common payment flows using Stripe actions and webhooks in WeWeb.
One-time payment with Stripe Checkout
- API:
POST /create-checkout— Create Customer (if new), then Create Checkout Session with modepayment, line items (price IDs and quantities), success/cancel URLs, and metadata (e.g. order ID). - Interface: A “Pay” button calls that API and redirects to
response.url. - Success page (optional): Call Retrieve Checkout Session with the
session_idfrom the URL to show order details. - Webhook (optional): Backend workflow On checkout session event → filter for
action === 'completed'→ update your orders table, send receipt email, or grant access.
Subscription with Stripe Checkout
- API:
POST /create-subscription-checkout— Create Checkout Session with modesubscription, line items with a recurring price ID, success/cancel URLs. Optionally Subscription Data (e.g.trial_period_days: 14). - Interface: Same as above — call API, redirect to session URL.
- Webhook: On subscription event → when
createdorupdated, storesubscription.idand status in your database; usecontext.event.status(e.g.active,canceled) to control access.
One-time payment with Payment Intent (custom form)
- API:
POST /payments/intent— Create Payment Intent with amount, currency, optional customer and metadata. Returnclient_secret(and optionallyid) to the front end. - Interface: Use the Stripe plugin payment element bound to that
client_secret. On submit, Stripe confirms the payment. - Success: Redirect or show confirmation; optionally call Retrieve Payment Intent to show status.
- Webhook (recommended): On payment intent event → when
succeeded→ update order, grant access, or send email.
Refund after payment
- Use Refund Payment with either Payment Intent ID or Charge ID (from the payment or from a webhook payload).
- Optionally set Amount (in cents) for a partial refund; leave empty for full refund.
- Set Reason (e.g.
requested_by_customer) for your records.
Grant access when payment succeeds (webhook)
- Backend workflow: trigger On payment intent event (or On checkout session event).
- First action: Switch on
context.event.action→ branch onsucceeded(orcompleted). - In that branch: update your users or orders table (e.g. set
plan = 'premium',paid_at = now) using the customer ID or metadata fromcontext.event.
Reference: Actions reference · Errors and FAQs

