Documentation Index
Fetch the complete documentation index at: https://docs.solvapay.com/llms.txt
Use this file to discover all available pages before exploring further.
Table of Contents
- Installation
- Basic Setup
- Creating Edge Functions
- Webhook Handling
- CORS Configuration
- Frontend Integration
- Complete Example
- Best Practices
- Next Steps
Installation
The fetch handlers live at the@solvapay/server/fetch subpath, consumed through Deno’s npm resolution. No npm install is needed — instead, create an import map.
@solvapay/server/fetch replaces the older standalone @solvapay/supabase / @solvapay/fetch packages. Same handlers, same signatures — now co-located with the *Core primitives they wrap.supabase/functions/deno.json:
"@solvapay/server/" trailing-slash entry is what unlocks the /fetch subpath import in Deno.
Basic Setup
Set secrets
SOLVAPAY_SECRET_KEY is required for all handlers. The webhook secret is only needed if you deploy the webhook function.
Prerequisites
- Supabase CLI installed
- A SolvaPay account with a product and at least one plan configured in the SolvaPay Console
Creating Edge Functions
Each handler is a two-line file. Create one function per endpoint:Available Handlers
| Function | Method | Handler | Description |
|---|---|---|---|
check-purchase | GET | checkPurchase | Check user’s purchase status |
sync-customer | POST | syncCustomer | Sync/create customer in SolvaPay |
create-payment-intent | POST | createPaymentIntent | Create payment intent for a plan |
process-payment | POST | processPayment | Process confirmed payment |
create-topup-payment-intent | POST | createTopupPaymentIntent | Create credit top-up intent |
customer-balance | GET | customerBalance | Get customer credit balance |
cancel-renewal | POST | cancelRenewal | Cancel subscription renewal |
reactivate-renewal | POST | reactivateRenewal | Reactivate cancelled subscription |
activate-plan | POST | activatePlan | Activate a free/usage plan |
list-plans | GET | listPlans | List available plans |
track-usage | POST | trackUsage | Track usage for metered billing |
create-checkout-session | POST | createCheckoutSession | Create hosted checkout session |
create-customer-session | POST | createCustomerSession | Create customer portal session |
get-merchant | GET | getMerchant | Fetch merchant branding (name, iconUrl, logoUrl, terms, privacy) |
get-payment-method | GET | getPaymentMethod | Preview mirrored card brand / last4 for a customer |
get-product | GET | getProduct | Fetch product + public plans (used by checkout UI) |
(req: Request) => Promise<Response> and run on any web-standards runtime (Supabase Edge, Deno, Cloudflare Workers, Bun, Next.js Edge, Vercel Edge Functions).
Deploy
Deploy all functions at once:Webhook Handling
For receiving webhook events, use thesolvapayWebhook factory instead of a direct handler. It verifies HMAC signatures automatically:
SOLVAPAY_WEBHOOK_SECRET from the environment automatically. You can also pass it explicitly:
When to use solvapayWebhook vs verifyWebhook
solvapayWebhookfrom@solvapay/server/fetch: fetch-runtime convenience wrapper. Handles the full request lifecycle (read body, verify, parse, respond).verifyWebhookfrom@solvapay/server: low-level primitive for any runtime. You handle body reading, signature extraction, and response formatting yourself.
CORS Configuration
By default, all handlers respond withAccess-Control-Allow-Origin: *. For production, restrict to your app’s origin:
configureCors() before Deno.serve() in each function that needs restricted origins. CORS state is per-isolate, so each function file must configure it independently.
Frontend Integration
Point your React app’sSolvaPayProvider at the Edge Function URLs:
sync-customer, create-checkout-session, create-customer-session, and solvapay-webhook functions are server-side only and are called directly from application code, not through the React provider.
Complete Example
The full reference project is available atexamples/supabase-edge in the SDK repository.
Best Practices
- Set secrets via Supabase CLI, not in source code or
.envfiles. Usesupabase secrets setfor bothSOLVAPAY_SECRET_KEYandSOLVAPAY_WEBHOOK_SECRET. - Restrict CORS origins in production. The default
*is fine for development. - Process webhooks idempotently. The same event may be delivered more than once.
- Test locally first with
supabase start && supabase functions servebefore deploying. - Deploy all functions at once with
supabase functions deployto avoid version skew between handlers.
Next Steps
- React Components Guide — build checkout UI with
PaymentFormandusePurchase - Webhooks Guide — detailed webhook event handling patterns
- Usage Events Guide — implement metered billing with
trackUsage - Purchase Management Guide — cancel, reactivate, and switch plans
- Examples Gallery — see all SDK examples