Skip to main content

Stripe Checkout and Payment Links

Implement Stripe attribution using client_reference_id from AffiliateBase referral state

Table of Contents

Stripe Checkout and Payment Links

Attribution for Stripe depends on client_reference_id.

Stripe Checkout

Pass the current referral when creating the checkout session.

const referralId = window.AffiliateBase?.referral || '';

const session = await stripe.checkout.sessions.create({
  mode: 'subscription',
  line_items: [{ price: 'price_xxx', quantity: 1 }],
  success_url: 'https://example.com/success',
  cancel_url: 'https://example.com/cancel',
  customer_creation: 'always',
  ...(referralId && { client_reference_id: referralId })
});

Tracking script supports automatic wiring when elements include data-affiliatebase.

Examples:

  • stripe-buy-button[data-affiliatebase]
  • stripe-pricing-table[data-affiliatebase]
  • Stripe payment links marked with data-affiliatebase

Next steps