Documentation
Affiliate program

Stripe Checkout from your server

Pass a captured referral into the Stripe Checkout Session your application creates.

View as Markdown

Install referral capture

Connect the Stripe account in Monok, choose Stripe Checkout from your server in the offer setup, and install the workspace snippet on your landing site and app.

HTML
<script defer src="https://cdn.monok.com/monok.js"
  data-workspace-id="WORKSPACE_ID"></script>

Pass the referral into Checkout

Before making the checkout request, await the browser helper and include the referral with your usual request data. Keep your existing server-side authentication and price validation.

JavaScript
const checkoutData = window.Monok
  ? await window.Monok.getCheckoutData({ priceId: selectedPriceId })
  : { priceId: selectedPriceId };

// Send checkoutData to your existing checkout endpoint.
JavaScript
import { withMonokStripeCheckout } from "@monok/server/payments/stripe";

const session = await stripe.checkout.sessions.create(
  withMonokStripeCheckout(checkoutOptions, body.monok_referral),
);

The helper adds referral metadata to your existing session options and ensures attributed one-time payments can be linked to a Stripe customer. If customers sign up before paying, register the referral at signup while it is still valid.

Verify capture and payment

Run Test browser script on your offer, then check a referred Checkout flow. Confirm the payment is credited to the correct affiliate. Stripe test-mode events do not earn commissions.

Related guides