Skip to main content

Table of Contents

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.
Create supabase/functions/deno.json:
The "@solvapay/server/" trailing-slash entry is what unlocks the /fetch subpath import in Deno.

Basic Setup

Set secrets

The SOLVAPAY_SECRET_KEY is required for all handlers. The webhook secret is only needed if you deploy the webhook function.

Prerequisites

Creating Edge Functions

Each handler is a two-line file. Create one function per endpoint:
The adapter handles CORS preflight, JSON serialization, error formatting, and auth extraction internally.

Available Handlers

All handlers are pure (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:
Or deploy individually:

Webhook Handling

For receiving webhook events, use the solvapayWebhook factory instead of a direct handler. It verifies HMAC signatures automatically:
The factory reads SOLVAPAY_WEBHOOK_SECRET from the environment automatically. You can also pass it explicitly:

When to use solvapayWebhook vs verifyWebhook

  • solvapayWebhook from @solvapay/server/fetch: fetch-runtime convenience wrapper. Handles the full request lifecycle (read body, verify, parse, respond).
  • verifyWebhook from @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 with Access-Control-Allow-Origin: *. For production, restrict to your app’s origin:
Call 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’s SolvaPayProvider at the Edge Function URLs:
The 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 at examples/supabase-edge in the SDK repository.
Total backend code: ~50 lines across 17 files.

Best Practices

  1. Set secrets via Supabase CLI, not in source code or .env files. Use supabase secrets set for both SOLVAPAY_SECRET_KEY and SOLVAPAY_WEBHOOK_SECRET.
  2. Restrict CORS origins in production. The default * is fine for development.
  3. Process webhooks idempotently. The same event may be delivered more than once.
  4. Test locally first with supabase start && supabase functions serve before deploying.
  5. Deploy all functions at once with supabase functions deploy to avoid version skew between handlers.

Next Steps