Website Checkout
Hosted checkout + customer portal for web apps. Server creates checkout session; browser redirects to SolvaPay; return URL refreshes access from server truth.
Guardrails
- Never build custom card forms when hosted checkout is acceptable.
- Never expose
SOLVAPAY_SECRET_KEYin client code. - Always keep checkout session creation on the server.
- Always verify access state from server truth after returning from checkout.
- Always use SolvaPay naming in user-facing text.
Gotchas
- Checkout succeeds but access unchanged → missing webhooks or stale client cache; refresh from server truth on return URL.
- React-only apps need a backend for checkout sessions — partial guidance here; full wiring →
solvapay/sdk-integration. - Lovable / Vite + Supabase Edge →
solvapay/lovable-checkout, not this skill. - Customer must exist in SolvaPay before checkout session — sync/ensure step first (details: references/nextjs.md).
- JWT/session must reach server routes that create sessions (details: references/nextjs.md).
- Durable access after redirect often needs webhooks, not return URL alone (details: references/nextjs.md).
Prerequisites
Before stack-specific implementation, run npx -y solvapay@latest init to configure SOLVAPAY_SECRET_KEY and install base SDK packages.
For advanced use cases (usage metering, Express/MCP paths, webhook-heavy flows), use solvapay/sdk-integration.
Mandatory read order
- Next.js detected → read references/nextjs.md end-to-end before generating routes.
- React-only → read references/react.md; if no backend exists, stop and hand off to
solvapay/sdk-integration. - Out-of-scope flows → references/out-of-scope.md.
Checkout procedure
- Run
npx -y solvapay@latest init. - Detect framework → load stack guide.
- Implement server checkout-session route.
- Implement return-URL handler + access refresh.
- Gate premium views from server truth.
- Run verification loop.
Verification loop
- Run stack-specific dev flow.
- Happy-path hosted checkout (redirect → return URL → access granted).
- Failure path (declined payment or unauthorized access check).
- Verify server-side access matches UI after return.
- Emit a runnable verification artifact — copy-pasteable
curlcommands or a test script inoutputs/(not a prose summary). Include:- Happy path: return from sandbox checkout → access check returns granted state.
- Failure path: unauthenticated or declined → access remains blocked.
- Fix and re-test until pass.
Handoff template
## Website checkout handoff
- **Framework:** [Next.js / React + backend]
- **Auth model:** [session / JWT / …]
- **Routes:** [checkout session / portal / access check]
- **Return URL behavior:** [post-checkout refresh path]
- **Sandbox:** [success + failure case outcomes]
- **Verification commands:**
# Happy path — after sandbox checkout, access refresh returns granted
curl -i -X POST http://localhost:3000/api/check-access \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d '{"productRef":"prd_..."}'
# Failure path — unauthenticated checkout blocked
curl -i -X POST http://localhost:3000/api/create-checkout-session \
-H "Content-Type: application/json" -d '{"productRef":"prd_..."}'
Docs discovery hints
- Topics:
checkout sessions,customer sessions,nextjs guide,react guide,webhooks,test in sandbox. - Retrieval hint: resolve topics via MCP search first, then
llms.txt.
Task progress
- Run
npx -y solvapay@latest init - Detect framework and read stack guide
- Implement server checkout session route
- Implement customer portal session route
- Implement return-URL handler + access refresh
- Gate premium views from server truth
- Run verification loop until pass and emit runnable curl/test artifact
Stack support
- Next.js: references/nextjs.md
- React (no Next.js): references/react.md