Auto-Apply Discounts
Apply PPP discounts automatically at checkout without coupon codes.
Auto-apply discounts remove friction from the checkout process by applying the PPP discount automatically — the visitor never needs to copy or enter a coupon code.
Auto-Apply vs. Coupon Codes
Section titled “Auto-Apply vs. Coupon Codes”| Coupon Codes | Auto-Apply | |
|---|---|---|
| Visitor experience | Copy code, paste at checkout | Discount applied automatically |
| Conversion rate | Lower (some visitors don’t apply) | Higher (zero friction) |
| Setup | Works with all providers | Provider-specific implementation |
| Flexibility | Visitor decides when to use | Always applied for eligible visitors |
| Sharing risk | Codes can be shared online | Less risk (tied to checkout session) |
How It Works
Section titled “How It Works”- Visitor loads your pricing page
- GoPayLocal detects their country and discount
- Your checkout flow passes the discount to the payment provider
- The checkout page shows the discounted price automatically
Provider Implementation
Section titled “Provider Implementation”Each payment provider implements auto-apply differently:
Stripe
Section titled “Stripe”Checkout Sessions:
// Server-side: create a Checkout Session with discountconst session = await stripe.checkout.sessions.create({ line_items: [{ price: 'price_xxx', quantity: 1 }], mode: 'subscription', discounts: [{ promotion_code: 'promo_xxx' }], success_url: 'https://yoursite.com/success', cancel_url: 'https://yoursite.com/cancel',});Payment Links:
https://buy.stripe.com/xxx?prefilled_promo_code=PPP-INDIA-30Paddle
Section titled “Paddle”Checkout Overlay:
Paddle.Checkout.open({ items: [{ priceId: 'pri_xxx', quantity: 1 }], discountCode: 'PPP-INDIA-30',});Price Overrides (native PPP):
Paddle can set per-country prices directly on Price objects via unitPriceOverrides, making auto-apply truly seamless — no discount code needed.
Dodo Payments
Section titled “Dodo Payments”const session = await dodo.checkoutSessions.create({ product_id: 'prod_xxx', discount_code: 'PPP-INDIA-30', success_url: 'https://yoursite.com/success',});Lemon Squeezy
Section titled “Lemon Squeezy”https://yourstore.lemonsqueezy.com/checkout/buy/xxx?checkout[discount_code]=PPP-INDIA-30https://whop.com/yourproduct/?promoCode=PPP-INDIA-30Implementation Pattern
Section titled “Implementation Pattern”The general implementation pattern for auto-apply:
Step 1: Get the Discount Code from GoPayLocal
Section titled “Step 1: Get the Discount Code from GoPayLocal”// Client-sideimport { GoPayLocal } from '@gopaylocal/js';
const gpl = new GoPayLocal({ apiKey: 'gpl_pk_live_abc123' });const data = await gpl.init();
const discountCode = data?.code; // "PPP-INDIA-30" or nullStep 2: Pass to Your Checkout
Section titled “Step 2: Pass to Your Checkout”// When user clicks "Buy Now"async function handleCheckout() { const res = await fetch('/api/checkout', { method: 'POST', body: JSON.stringify({ planId: 'pro_monthly', discountCode: gpl.getCode(), // Pass the GoPayLocal code }), }); const { checkoutUrl } = await res.json(); window.location.href = checkoutUrl;}Step 3: Apply in Checkout Session (Server-Side)
Section titled “Step 3: Apply in Checkout Session (Server-Side)”// Server-side route handlerapp.post('/api/checkout', async (req, res) => { const { planId, discountCode } = req.body;
const session = await stripe.checkout.sessions.create({ line_items: [{ price: getPriceId(planId), quantity: 1 }], mode: 'subscription', ...(discountCode && { discounts: [{ promotion_code: await getPromoCodeId(discountCode) }], }), success_url: 'https://yoursite.com/success', cancel_url: 'https://yoursite.com/cancel', });
res.json({ checkoutUrl: session.url });});Providers Without Auto-Apply
Section titled “Providers Without Auto-Apply”| Provider | Auto-Apply Support |
|---|---|
| Gumroad | No native auto-apply |
| Chargebee | No URL-based auto-apply (possible via Chargebee.js) |
| Polar | No auto-apply |
For these providers, use the banner + coupon code approach. The visitor copies the code from the banner and enters it manually at checkout.
Best Practices
Section titled “Best Practices”- Always pass the discount code server-side — Don’t construct checkout URLs on the client with discount codes; a user could modify them
- Validate the discount — On your server, verify the discount code is valid before creating the checkout session
- Graceful fallback — If auto-apply fails, show the coupon code as a fallback
- Show the discount — Even with auto-apply, show the visitor that they’re getting a PPP discount (e.g., “Prices adjusted for India”)