💰 Stripe Integration Demo

Test AffyJS Stripe helper methods

Step 1: Initialize AffyJS

Method 1: getReferralId()

Get the click ID directly

Method 2: getStripeMetadata()

Get ready-to-use metadata object

Method 3: enrichStripeCheckout()

Auto-enrich checkout config

📋 Integration Code Examples

Option 1: Simple - Get Metadata

// Frontend - Get click ID
const clickID = AffyJS.getReferralId();

// Backend - Create Stripe checkout
const session = await stripe.checkout.sessions.create({
  line_items: [{ price: 'price_xxx', quantity: 1 }],
  mode: 'subscription',
  metadata: {
    clickID: clickID  // ← Add this!
  }
});

Option 2: Auto-Enrich (Recommended)

// Frontend - Before sending to backend
let config = {
  line_items: [{ price: 'price_xxx', quantity: 1 }],
  mode: 'subscription'
};

// Automatically add clickID to metadata
config = AffyJS.enrichStripeCheckout(config);

// Send to backend
fetch('/create-checkout', {
  method: 'POST',
  body: JSON.stringify(config)
});

Option 3: Customer Creation

// Frontend
let customerConfig = {
  email: 'customer@example.com',
  name: 'John Doe'
};

// Auto-add referral tracking
customerConfig = AffyJS.enrichStripeCustomer(customerConfig);

// Backend
const customer = await stripe.customers.create(customerConfig);
// customer.metadata.clickID will be set automatically!

🔧 Debug & Testing Helpers

📟 Console Output