Skip to content

feat: add an example Stripe Checkout payment page - #140

Draft
iloveitaly wants to merge 7 commits into
masterfrom
cursor/example-stripe-payment-7574
Draft

iloveitaly wants to merge 7 commits into
masterfrom
cursor/example-stripe-payment-7574

Conversation

@iloveitaly

@iloveitaly iloveitaly commented Oct 15, 2026 •

Copy link
Copy Markdown
Owner

Motivation

The Stripe helpers needed a real checkout flow. commands.md already specifies that flow: create a session, save a pending order, complete it on the Stripe return, then read the order from the confirmation page.

Description

/pay follows those four steps:

  • POST /unauthenticated/example-payment/session creates a Checkout Session. return_url is the backend complete route, with Stripe's unescaped {CHECKOUT_SESSION_ID} placeholder.
  • POST /unauthenticated/example-payment/pending saves an ExamplePaymentOrder (email plus checkout session id) immediately before confirm. A retry updates the same order.
  • GET /unauthenticated/example-payment/complete marks the order paid when Stripe redirects back, then sends the browser to /pay/confirmation.
  • GET /unauthenticated/example-payment/status reads that order and fills country, postal code, and dispute state from the stripe helpers.

ui_mode is elements. That is the current name of the template's custom mode, and it matches initCheckoutElementsSdk.

just db_generate_migration add_example_payment_order added revision 801c44619be3. It creates the examplepaymentorderstatus enum and the example_payment_order table, including the unique checkout session id.

Screenshots / Test

tests/integration/example_payment_test.py pays with Stripe test card 4242 and asserts the order is paid. Visual snapshots:

  • 01-payment-form.png is the stable page intro. Stripe iframes change height between loads, so they are not part of this shot.
  • 02-payment-complete.png masks the email and Stripe ids.

The checkout test passed on GitHub Actions. Snapshot comparison failed because the payment images were captured with different font metrics than ubuntu-latest, and the home snapshots now include the Example payment link. Those images were replaced with the actuals from that run.

The revision was applied on the dev and test databases. uv run alembic check reported no new operations, and just db_lint found 0 squawk issues.

Payment page intro
Payment confirmation
Home page with payment link

Links

To show artifacts inline, enable in settings.

Open in Web Open in Cursor 

Wire an unauthenticated /pay flow through the stripe helpers so checkout
session secrets, retrieval, country/zip, and dispute checks are exercised.
Live charges still need STRIPE_SECRET_KEY and VITE_STRIPE_PUBLIC_KEY.

Co-authored-by: Michael Bianco <mike@mikebian.co>
@cursor
cursor Bot force-pushed the cursor/example-stripe-payment-7574 branch from 50d3ecd to 9ed371e Compare November 2, 2026 19:27
cursoragent and others added 6 commits November 2, 2026 19:36
Save a pending example order before confirm, mark it paid when Stripe
redirects to the complete route, and read that order on the confirmation page.

Co-authored-by: Michael Bianco <mike@mikebian.co>
Walk through /pay with a test card, assert the order is paid, and store
visual snapshots of the payment intro and confirmation page.

Co-authored-by: Michael Bianco <mike@mikebian.co>
Sort the Python imports, format the payment pages, and keep the Stripe
checkout instance in state so the submit handler does not read a ref during render.

Co-authored-by: Michael Bianco <mike@mikebian.co>
The loading check still referenced checkoutReady after the Stripe instance moved into state.

Co-authored-by: Michael Bianco <mike@mikebian.co>
Autogenerate the example_payment_order table and status enum so db_lint matches the model.

Co-authored-by: Michael Bianco <mike@mikebian.co>
The payment images were captured with different font metrics than GitHub Actions, and the home snapshots now include the example payment link.

Co-authored-by: Michael Bianco <mike@mikebian.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants