Guides
GuidePayment Providers

Payment Providers

Get paid the way that works where you and your members are. Every payment method is an optional, independent switch — turn on only what you need. Use just bank transfer if that’s all you want; add cards later; mix and match freely.

How it works: open your app’s Payments tab, flip on a method, and connect it: for Stripe, press Connect with Stripe, sign in to Stripe (or create an account) and approve, with no keys to copy; for Pesapal, type your Pesapal keys on the same tab. However a member pays, a successful payment unlocks the same paid access — so the rest of your app doesn’t care which provider they used.

Built-in methods

Stripe — cards & subscriptions

Visa, Mastercard and recurring subscriptions worldwide. Press Connect with Stripe, sign in to your Stripe account (or create one) and approve, then confirm it’s you back on the Payments tab. Payments go straight to your own Stripe account and unlock access automatically.

Pesapal — M-Pesa & cards in East Africa

Open the Pesapal row, type your test keys under Test keys and your live keys under Live keys (each set is kept apart), press Save keys, then switch it on. Going live asks for your live keys first. Each payment is checked with Pesapal, in the mode it was made in, before access unlocks.

Bank transfer / cash — manual

No processor at all. Show your bank details or a QR, the member pays you directly, and you approve it — access unlocks on approval. Perfect when card processors aren’t available or you just want to keep it simple.

Test vs Live

Stripe and Pesapal each have their own Test / Live button. Test mode takes fake payments so you can try the whole checkout-to-access flow safely; Live takes real money. Switching one to Live doesn’t touch anything else.

Bank transfer / cash has no processor to sandbox — it’s simply on or off, and you’re the one confirming each payment is real before you approve it.

While every payment provider of a site is in test mode (or there is none yet), you or your AI can also simulate the money flow without paying: a paid test payment (with a coupon or an order bump), a member’s manual claim to approve or reject, and a refund. They run like real test payments: nothing is charged, but a journey, flow, agent or function set on payment_succeeded runs and may email the member (that event carries test: true), and the access they give ends when the site goes live. Ask the AI chat to “simulate a payment”, or use site_simulatePayment, site_simulateManualClaim and site_simulateRefund over MCP.

Need a provider that isn’t listed?

You are not limited to the built-in methods. Want Razorpay, Khalti, PayPal, Paytm, or a local processor? Serenities can connect any gateway through a small backend function that grants access through the same entitlement ledger Stripe and manual payments use. You don’t have to wait for us to add it as a built-in.

Not sure which provider fits your country? Which payment provider for which country lists where Stripe works and which local gateway to look at where it does not.

The easiest path: just ask the AI assistant in your app to set it up, for example —

"Add Razorpay as a payment option and unlock the ‘pro’ plan when a payment succeeds."

It stores your gateway key securely as a project environment variable (never in page code), opens that gateway’s own checkout, verifies each payment with the gateway’s API, and unlocks paid access — exactly like Stripe.

One provider function for all your sites. A function in your workspace can be the payment provider for any of your sites: save it with a provider spec and publish it, someone with the permission to offer functions as payment providers offers it to each site, then switch it on in that site’s Payments. A payment that waits on your provider function is checked again by itself. On Payments → Payment history whoever may take payments can press Check now on a pending one, or ask the AI. Once a day, if the function could not check some payments, you get one notice in the app and one email from your own sending account.

Bottom line: the built-in methods are the fast path, not a fence. If a gateway exists, your app can take money through it.

Prefer to wire it yourself? (for builders)

The AI does exactly what a builder would do by hand. If you’d rather build it, here’s the whole pattern. It rests on one idea: access is entitlement-based, so nothing cares how a payment was collected — a verified payment grants an entitlement, and your access rules check the entitlement, exactly as they would for Stripe or manual payments.

  1. Save the gateway’s keys as secrets in your site’s Environment Variables (e.g. RAZORPAY_TEST_KEY_SECRET), plus a plain RAZORPAY_MODE = test/live setting. Then open the function’s Access tab and add each secret to Secrets this function can use: the API secret with api.razorpay.com, the signing secret with “Only to check signatures”. A function never holds a key: it uses ctx.secrets.ref('NAME') in a request and ctx.secrets.verifyHmac to check a signature, and the platform does the rest.
  2. On your checkout page, call a backend function to create the order (the secret stays server-side), then open the gateway’s own checkout widget (their JS SDK).
  3. The gateway’s success callback (or webhook) hits your project’s backend function endpoint — give the function a public access rule so it’s reachable with no login. Treat its input as untrusted — verify the payment (check the signature, or refetch from the gateway’s API).
  4. On a verified payment, grant one billing period of access. A replay guard makes sure the same payment can’t unlock twice.
Runtime note: backend functions run on Deno, so use Web APIs —crypto.subtle (Web Crypto),btoa, crypto.getRandomValues — not Node’s crypto module.

The verification backend function — the security-critical part (real Razorpay pattern, Deno):

// Backend function "verifyRazorpayPayment" — params is UNTRUSTED input
const { razorpay_order_id, razorpay_payment_id, razorpay_signature, appUserId } = params;
if (!razorpay_order_id || !razorpay_payment_id || !razorpay_signature || !appUserId)
  throw new Error('Missing required fields');

// The key secret is on this function's list as "Only to check signatures": verifyHmac answers true or false and
// the key never enters this code. RAZORPAY_MODE is a plain setting, so ctx.env.get reads it.
// A person also switches on the Entitlements power on the function's Access tab (Powers & secrets); a new function has no powers.
const mode = await ctx.env.get('RAZORPAY_MODE') || 'test';

// 1) Verify the signature: HMAC-SHA256(order|payment), hex.
const ok = await ctx.secrets.verifyHmac(
  mode === 'live' ? 'RAZORPAY_LIVE_KEY_SECRET' : 'RAZORPAY_TEST_KEY_SECRET',
  razorpay_order_id + '|' + razorpay_payment_id,
  razorpay_signature,
);
if (!ok) throw new Error('Payment verification failed');

// 2) Replay guard — one grant per gateway payment id.
const key = 'pro';
const got = await ctx.entitlements.get(appUserId, key);
const existing = got && got.entitlement;
if (existing?.source?.paymentId === razorpay_payment_id) return { granted: false, reason: 'already processed' };

// 3) One period per verified charge; a renewal extends from the current expiry.
const PERIOD_MS = 30 * 86400000;
const base = existing?.expiresAt && new Date(existing.expiresAt) > new Date()
  ? new Date(existing.expiresAt).getTime() : Date.now();
const expiresAt = new Date(base + PERIOD_MS).toISOString();
existing
  ? await ctx.entitlements.extend(appUserId, key, expiresAt, { source: { provider: 'razorpay', paymentId: razorpay_payment_id } })
  : await ctx.entitlements.grant(appUserId, key, { expiresAt, source: { provider: 'razorpay', paymentId: razorpay_payment_id } });
return { granted: true, expiresAt };

Why this is safe: access closes automatically when the entitlement lapses, so a missed renewal fails closed even if a callback never arrives. Gate any content with the same rule you’d use for Stripe: { "type": "has_entitlement", "key": "pro" }.

Recurring subscriptions map the same way: each renewal charge → verify → extend one period; a failed payment → suspend with a grace period; a cancellation → revoke. The full, annotated version lives in the in-app AI code guide (payments topic).