capacitor-community / stripe

Stripe Mobile SDK wrapper for Capacitor
MIT License
185 stars 74 forks source link

Allow a Stripe Connect account id to be passed during initialization for ApplePay #182

Closed yllaw closed 1 year ago

yllaw commented 2 years ago

Currently when creating initializing the plugin I pass the Stripe public key.

import {
  Stripe as StripeCapacitor,
} from '@capacitor-community/stripe';
await StripeCapacitor.setPublishableKey('pk_test_....');

The initialization succeeds. However requests to charge the payment intent on behalf of connected accounts will fail.

The stripe package is missing the 'Stripe-Account' header. The platform cannot charge payment intents with an application fee without the header.

The fix would be to add the 'Stripe-Account' header to requests as per the Stripe documentation

Essentially updating the initialization options interface to pass in the Stripe connect account id so that requests can be made on their behalf:

 this.stripe = Stripe(environment.stripeMyPublicKey, {
          stripeAccount: connectedStripeAccountId,
        });
rdlabo commented 2 years ago

@yllaw This is the first time I have heard of this function. It's easy to implement, so we'll be working on it in a few days.

yllaw commented 2 years ago

Thank you!

rdlabo commented 2 years ago

@yllaw I released v3.8.0-0. Please try this: npm install @capacitor-community/stripe@3.8.0-0 https://github.com/capacitor-community/stripe/releases/tag/v3.8.0-0

note: if you use on web, you should update @stripe-elements/stripe-elements to 2.0.1.

yllaw commented 2 years ago

@rdlabo Thank you for this!

Apple pay works as intended.

I have not been able to test Google pay yet.

rdlabo commented 1 year ago

@yllaw I'm glad you got it sorted out!

Did you use this plugin for production? If yes, please tell us what app. This help development this plugin.

👉 https://github.com/capacitor-community/stripe/issues/145

Thanks.