Development

    Implementing Dual Payment Gateways: Lemon Squeezy + Dodo Payments

    Dec 10, 2024
    15 min read
    PaymentsSaaSIntegrationTypeScript

    Why Multiple Payment Gateways?

    Selling globally means accepting payments locally. While Lemon Squeezy handles international payments beautifully, Indian customers prefer UPI and local cards. Enter Dodo Payments.

    Architecture Overview

    I built an abstraction layer that routes payments based on user location:

    interface PaymentProvider {
    

    createCheckout(options: CheckoutOptions): Promise;

    handleWebhook(payload: WebhookPayload): Promise;

    cancelSubscription(subscriptionId: string): Promise;

    }

    class LemonSqueezyProvider implements PaymentProvider {

    // Implementation

    }

    class DodoPaymentsProvider implements PaymentProvider {

    // Implementation

    }

    Lemon Squeezy Integration

    Perfect for international customers. Handles tax calculations, invoicing, and chargebacks automatically.

    Dodo Payments Setup

    For the Indian market - supports UPI, Indian credit/debit cards, and net banking with lower fees.

    Key Lessons

  1. Abstract payment logic behind interfaces
  2. Always handle webhook idempotency
  3. Test with real transactions early
  4. Keep subscription status synced across providers
  5. Related Articles