ProductRead MeSections
Read Me
Payment is the platform service that takes a one-time payment for something an app sells. In DocFlow it is the step where a person pays before downloading the results.
An app's server asks for an order with a price; Payment returns the address of Stripe's own checkout page, where the person pays. Card details never touch 01scale.
Stripe's signed message, not the person's browser, is what marks an order paid. Payment then tells the app, and the app unlocks what was bought. Version 1 runs in Stripe's test mode only.
Why it exists
One trusted record of who paid for what
Apps check the order's status before unlocking anything, instead of each talking to Stripe.
Prices are never set by a browser
Only an app's server can create an order, so nobody can change a price in their browser.
Charged once, even when things repeat
Clicking twice, a repeated Stripe message or a retried request never creates a second order or charge.
No card data to protect
Stripe's hosted page takes the card, which keeps 01scale out of most of the card-security rules.
In this version
- One-time payment for one item, in USD, through Stripe Checkout in test mode
- Reuse the open checkout page when Pay is clicked again
- Mark orders paid, expired or failed from Stripe's signed events, once each
- Tell the app when an order changes
- List a person's orders; keep them, anonymized, if the account is deleted
Not in this version
- Saved cards and one-tap payment:
PAYMENT-V2-E13 - Paying for a batch of documents:
PAYMENT-V2-E13-04 - Refunds: not designed
- Live (real-money) payments: not planned for the portfolio
- Currencies other than USD
How a payment works
- App's server. Calls
POST /orderswith the user, a reference, a description and the price. In DocFlow, when the person taps Pay. - Payment. Records a
pendingorder and creates a Stripe Checkout session; returns its address. A second call for the same reference returns the same order. - Browser. Goes to Stripe's page; the person pays there.
- Stripe. Sends the person back to the app, and separately sends Payment a signed
checkout.session.completedevent. - Payment. Verifies the signature, records the event once, marks the order
paid, and announcespayment.order.paid. - App. Receives the event (or sees the order paid when polling) and unlocks what was bought.
Words used here
- Order
- One request for payment, with its price and status. The record an app trusts.
- Checkout session
- Stripe's hosted payment page for one order, open for 1 hour.
- Webhook
- A message Stripe sends to Payment's server when something happens, signed so it can be verified.
- Minor units
- The amount in the currency's smallest unit: 500 means $5.00.
- Reference
- What is being paid for, in the app's own terms; one open or paid order per reference.
Quick start
These examples work once the service is built and deployed.
1. Ask for payment (app server)
Set the price on the server and send the person to the returned address.
const { order, checkout_url } = await callService("/api/payment/v1/orders", { onBehalfOf: userId }, {
reference: `myapp:${itemId}`, description: "Report export",
amount: 500, currency: "USD",
success_url: `https://01scale.com/items/${itemId}/paid?order={ORDER_ID}`,
cancel_url: `https://01scale.com/items/${itemId}`,
});
return redirect(checkout_url);2. Confirm before unlocking
Trust the order's status, never the browser arriving at the success page.
const { order } = await api.get(`/api/payment/v1/orders/${orderId}`);
if (order.status !== "paid") return status(402);3. Show progress on a success page
The component polls until the order settles.
import { OrderStatus } from "@01scale/ui-payment";
<OrderStatus orderId={orderId} onSettled={(o) => o.status === "paid" && unlock()} />Configuration
Environment variables on the service's own deployment. Secrets are never committed.
PAYMENT_DATABASE_URLsecret- Neon connection string for the
payment_servicerole STRIPE_SECRET_KEYsecret- A Stripe test-mode secret key (
sk_test_…). Live keys are refused at start-up. STRIPE_WEBHOOK_SECRETsecret- The signing secret of the webhook endpoint (
whsec_…) IDENTITY_JWKS_URLhttps://01scale.com/api/identity/v1/jwksEVENTS_SIGNING_KEYsecret- 32 random bytes, base64: signs and verifies platform events
EVENT_ROUTES- From the service template: reference prefix → the app's event address (decision on #13)
Open questions
- Decided by Nikhil on 20 Nov 2026 (#67): a Stripe Checkout page stays open for 1 hour (Stripe allows 30 minutes to 24 hours).
- Refunds are pending: story
PAYMENT-V1-E6-04(decided on #67). This version has no refund endpoint; a refund made in Stripe's dashboard is not reflected on the order. - Rate limits are starting values.