Munim Technologies

Checkout

Create a checkout on your server and open it on the web, in React Native or Expo, or as a link. Brand how it looks.

Create a checkout

Make one per purchase on your server, then send the customer to its url. It takes cards, Apple Pay, Google Pay, Link, PayPal and Venmo, and works out sales tax once the customer picks a country.

curl https://billing-sandbox-api.munimtech.com/v1/checkouts \
  -H "Authorization: Bearer $MUNIM_BILLING_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "price_id": "pri_…",
    "app_user_id": "user_123",
    "customer_email": "[email protected]",
    "success_url": "myapp://billing/done",
    "cancel_url": "myapp://billing/canceled",
    "metadata": {"team_id": "team_9"}
  }'
price_idstring
pri_…. Required unless you pass pricing_quote_id.
pricing_quote_idstring
pq_… from Munim Autopilot Pricing: sells at the price it picked.
quantityinteger
Default 1.
customer_emailstring
Prefills the email.
customer_idstring
ctm_… of an existing customer.
app_user_idstring
Your own user id. Links the purchase to that user's entitlements.
success_urlstring
https:// or your app’s scheme (myapp://…). checkout_id is appended. Without it, the checkout shows its own “Payment complete” screen.
cancel_urlstring
Where the back / cancel link goes.
templatestring
sheet, split or compact. Default: your account’s.
metadataobject
Up to 20 keys. Copied to the transaction and subscription.

The response is a checkout with status open, its url, amount_total, mode (payment or subscription) and expires_at. Once paid it becomes completed with transaction_id and, for recurring prices, subscription_id.

Open it on the web

The overlay shows the checkout over your page in an iframe that allows payments, so Apple Pay and Google Pay work. Escape, the close button, or a click outside closes it.

Overlay
import { openCheckout } from 'munim-billing/web'

const { url } = await fetch('/api/checkout', {
  method: 'POST',
  body: JSON.stringify({ priceId }),
}).then((r) => r.json())

const overlay = openCheckout(url, {
  onComplete: ({ checkoutId }) => refreshAccess(checkoutId),
  onClose: () => console.log('closed'),
})
// overlay.close() closes it yourself

Or send the whole page there:

Redirect
import { redirectToCheckout } from 'munim-billing/web'

redirectToCheckout(url) // comes back to success_url after paying

If you embed the page yourself, it posts { source: 'munim-billing', type: 'checkout.completed' | 'checkout.closed', checkout_id } to the parent window. isCheckoutMessage(data) tells you whether a message is one of these; only trust ones from the checkout’s own origin.

Open it in React Native and Expo

The helper opens an in-app sheet (ASWebAuthenticationSession on iOS, Custom Tabs on Android) through expo-web-browser. It works in Expo Go, development builds and bare apps. Without expo-web-browser it opens the browser instead.

Terminal
npx expo install munim-billing expo-web-browser
BuyButton.tsx
import { openCheckout } from 'munim-billing/react-native'

// Your server made the checkout with success_url 'myapp://billing/done'
// and cancel_url 'myapp://billing/canceled'.
const { url } = await api.createCheckout()
const result = await openCheckout(url, { returnUrl: 'myapp://billing' })

if (result.status === 'completed') {
  await refreshEntitlements() // your server already heard by webhook
}
ResultWhen
{ status: 'completed', checkoutId, url }The checkout came back to your success_url.
{ status: 'canceled', checkoutId?, url? }The customer closed the sheet or canceled.
{ status: 'opened' }No expo-web-browser: it opened in the browser, and the result comes back later as a deep link.

success_url and cancel_url must start with the returnUrl you pass, and your app must own that scheme (scheme in app.json). Read a deep link yourself with parseCheckoutReturnUrl(url). On iOS, preferEphemeralSession: true keeps Safari’s cookies out of the sheet.

The same flow with Convex as the backend:

convex/billing.ts
// convex/billing.ts
import { action } from './_generated/server'
import { v } from 'convex/values'
import { MunimBilling } from 'munim-billing'

export const createCheckout = action({
  args: { priceId: v.string() },
  handler: async (ctx, { priceId }) => {
    const user = await ctx.auth.getUserIdentity()
    if (!user) throw new Error('Not signed in')
    const munim = new MunimBilling(process.env.MUNIM_BILLING_SECRET_KEY!)
    const checkout = await munim.checkouts.create({
      price_id: priceId,
      app_user_id: user.subject,
      customer_email: user.email,
      success_url: 'myapp://billing/done',
      cancel_url: 'myapp://billing/canceled',
    })
    return checkout.url
  },
})
Don't grant access from the return URL
It only says the customer came back. Grant access from the transaction.completed webhook, an entitlement check, or checkouts.retrieve(checkoutId) on your server.

Brand the checkout

Set the default look in the dashboard under Checkout, or with the API. A checkout can still pick its own template.

curl https://billing-sandbox-api.munimtech.com/v1/checkout_settings \
  -H "Authorization: Bearer $MUNIM_BILLING_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{"template": "split", "brand_color": "#111827", "theme": "auto", "corners": "sharp"}'
templatestring
sheet (a mobile sheet), split (desktop, two columns) or compact (embeds and small sheets).
brand_colorstring
#RRGGBB for buttons.
logo_urlstring
https:// logo, shown when a product has no image. null clears it.
themestring
auto, light or dark.
cornersstring
rounded, sharp or pill.

Preview any combination at https://billing-sandbox-api.munimtech.com/checkout/preview?template=split&brand_color=%23111827. The business name, support email and card statement name come from your account settings.