Stripe Integration

Connect Geddle tracking with Stripe Checkout for commission attribution

Integrations1 min read

Stripe Integration

Pass the SDK's track ID to Stripe Checkout metadata for commission attribution.

Step 1: Get Track ID

On your checkout page, retrieve the track ID:

const trackId = window.Geddle?.getReferral()

Step 2: Send to Server

Pass the track ID when creating the checkout session:

async function handleCheckout() { const trackId = window.Geddle?.getReferral() const response = await fetch('/create-checkout-session', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ priceId: 'price_xxx', trackId: trackId }) }) const session = await response.json() window.location.href = session.url }

Step 3: Add to Stripe Metadata

The metadata key MUST be geddle_referral.

const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY) app.post('/create-checkout-session', async (req, res) => { const { priceId, trackId } = req.body const session = await stripe.checkout.sessions.create({ mode: 'subscription', line_items: [{ price: priceId, quantity: 1 }], success_url: 'https://yoursite.com/success', cancel_url: 'https://yoursite.com/checkout', metadata: { geddle_referral: trackId || '' } }) res.json({ url: session.url }) }) ## Using Stripe Payment Links If using Payment Links instead of Checkout Sessions, add a custom field named `geddle_referral` and pre-fill it: ```javascript const trackId = window.Geddle?.getReferral() const link = `https://buy.stripe.com/xxx?prefilled_geddle_referral=${trackId}` window.location.href = link

Checkout Sessions provide better control and are recommended.