#Configure multiple Stripe accounts

3 messages · Page 1 of 1 (latest)

latent tulip
#

My store would like to support US and Canadian accounts connected accounts, and for me to do this I need to configure US and Canadian Stripe accounts. How can I use the Stripe plugin so it can be configured with two sets of Stripe keys (one for US account and one for Canadian).

My plan was to extend BaseStripe to create another payment provider with its own static identifer and then pick the right one on the client side. My issue is that BaseStripe is "tied" to the medusa-payment-stripe configuration in medusa-config.js and there we can only specify one set of keys.

faint hull
#

Only thing that comes to my mind is to copy the stripe plugin to a service. And change the stripe-base to use your own env variables.
https://github.com/medusajs/medusa/blob/master/packages/medusa-payment-stripe/src/helpers/stripe-base.js

  static identifier = 'canadian-stripe'

  constructor(_, options) {
    super(_, options)

    /**
     * Required Stripe options:
     *  {
     *    api_key: "stripe_secret_key", REQUIRED
     *    webhook_secret: "stripe_webhook_secret", REQUIRED
     *    // Use this flag to capture payment immediately (default is false)
     *    capture: true
     *  }
     */
    this.options_ = {
                      api_key: process.env.CANADIAN_STRIPE_KEY
                      webhook_secret: process.env.CANADIAN_WEBHOOK_SECRET
                     }

You probably need to also create a webhook for Canadian under some other route.
And on the storefront, when this payment is chosen, you'll need to load stripe Elements with other public key, i.e process.env.NEXT_PUBLIC_STRIPE_CANADIAN_PUBLIC_KEY
But that's just my idea. And you might be locked out from future updates to plugin. Maybe there's a better way, I'm not sure

latent tulip
#

Thanks @faint hull. Appreciate the insight.