From ee98528ba984b2ac5090997a50b388bd4cec957a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Perdig=C3=A3o?= Date: Thu, 5 Sep 2019 14:03:44 +0100 Subject: [PATCH] Expose setStripeAccount to JS (Enable Stripe Connect accounts) --- android/src/main/java/com/gettipsi/stripe/StripeModule.java | 5 +++++ ios/TPSStripe/TPSStripeManager.m | 4 ++++ src/Stripe.js | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/android/src/main/java/com/gettipsi/stripe/StripeModule.java b/android/src/main/java/com/gettipsi/stripe/StripeModule.java index 386d72902..9605b7d64 100644 --- a/android/src/main/java/com/gettipsi/stripe/StripeModule.java +++ b/android/src/main/java/com/gettipsi/stripe/StripeModule.java @@ -143,6 +143,11 @@ public void canMakeAndroidPayPayments(final Promise promise) { getPayFlow().deviceSupportsAndroidPay(true, promise); } + @ReactMethod + public void setStripeAccount(final String stripeAccount) { + getPayFlow().setStripeAccount(stripeAccount); + } + @ReactMethod public void createTokenWithCard(final ReadableMap cardData, final Promise promise) { try { diff --git a/ios/TPSStripe/TPSStripeManager.m b/ios/TPSStripe/TPSStripeManager.m index 8fb0db8b7..393ceb807 100644 --- a/ios/TPSStripe/TPSStripeManager.m +++ b/ios/TPSStripe/TPSStripeManager.m @@ -143,6 +143,10 @@ - (NSDictionary *)constantsToExport [Stripe setDefaultPublishableKey:publishableKey]; } +RCT_EXPORT_METHOD(setStripeAccount:(NSString *)stripeAccount) { + [[STPAPIClient sharedClient] setStripeAccount:stripeAccount]; +} + RCT_EXPORT_METHOD(deviceSupportsApplePay:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { resolve(@([PKPaymentAuthorizationViewController canMakePayments])); diff --git a/src/Stripe.js b/src/Stripe.js index abcf5c0f7..7ce19d10d 100644 --- a/src/Stripe.js +++ b/src/Stripe.js @@ -21,6 +21,10 @@ class Stripe { return StripeModule.init(options, errorCodes) } + setStripeAccount = (stripeAccount) => ( + StripeModule.setStripeAccount(stripeAccount) + ) + // @deprecated use deviceSupportsNativePay deviceSupportsAndroidPay = () => ( StripeModule.deviceSupportsAndroidPay()