Test AffyJS Stripe helper methods
Get the click ID directly
Get ready-to-use metadata object
Auto-enrich checkout config
// 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!
}
});
// 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)
});
// 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!