Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Providers urlScheme ignored when using paymentMethodId in confirmPayment (iOS) #378

Closed
ghitier opened this issue Jun 29, 2021 · 2 comments · Fixed by #389
Closed

Providers urlScheme ignored when using paymentMethodId in confirmPayment (iOS) #378

ghitier opened this issue Jun 29, 2021 · 2 comments · Fixed by #389
Labels
bug Something isn't working P0 Address these issues first

Comments

@ghitier
Copy link
Collaborator

ghitier commented Jun 29, 2021

Describe the bug
When calling confirmPayment (of the useStripe hook) with the paymentMethodId option. The urlScheme of the StripeProvider is ignored. This issue is iOS only.

To Reproduce
Steps to reproduce the behavior:

Call confirmPayment with an existing paymentMethodId, and have your app scheme in the provider:

const MyPaymentComponent = () => {
  const { confirmPayment } = useStripe();

  const pay = async () => {
    const { paymentIntent, error } = await confirmPayment(
      stripe_client_secret,
      //
      // Note: the paymentMethod used needs to trigger a 3DS WebView flow.
      { type: 'Card', paymentMethodId: 'pm_somepmid' },
    );
  }

  return <Button onPress={pay} title="pay" />
}

const MyParentComponent = () => (
  <StripeProvider publishableKey="mypublishablekey" urlScheme="my-app">
    <MyPaymentComponent />
  </StripeProvider>
);

Expected behavior
The "return_url" should visible in the POST /v1/payment_intents/..../confirm request on the stripe dashboard, consequently once the 3DS WebView challenge was completed, it should be closed and return to the app.

Screenshots
If applicable, add screenshots to help explain your problem.

Smartphone (please complete the following information):

  • Device: iPhone 12 (simulator)
  • OS: iOS
  • Version: 14.5

Additional context
I have applied this patch to fix the issue, for stripe-react-native version 0.1.4:

diff --git a/node_modules/@stripe/stripe-react-native/ios/StripeSdk.swift b/node_modules/@stripe/stripe-react-native/ios/StripeSdk.swift
index 379e1f1..4e9deba 100644
--- a/node_modules/@stripe/stripe-react-native/ios/StripeSdk.swift
+++ b/node_modules/@stripe/stripe-react-native/ios/StripeSdk.swift
@@ -603,10 +603,10 @@ class StripeSdk: RCTEventEmitter, STPApplePayContextDelegate, STPBankSelectionVi
             paymentIntentParams.paymentMethodParams = paymentMethodParams
             paymentIntentParams.paymentMethodOptions = paymentMethodOptions
             paymentIntentParams.shipping = Mappers.mapToShippingDetails(shippingDetails: params["shippingDetails"] as? NSDictionary)
+        }
         
-            if let urlScheme = urlScheme {
-                paymentIntentParams.returnURL = Mappers.mapToReturnURL(urlScheme: urlScheme)
-            }
+        if let urlScheme = urlScheme {
+            paymentIntentParams.returnURL = Mappers.mapToReturnURL(urlScheme: urlScheme)
         }
         
         let paymentHandler = STPPaymentHandler.shared()
@thorsten-stripe
Copy link
Contributor

Thanks for flagging it, indeed missing it here https://github.com/stripe/stripe-react-native/blob/master/ios/StripeSdk.swift#L587

@4gmayank
Copy link

Try adding
Stripe.publishableKey,
Stripe.merchantIdentifier = "acct_1IL78e48329489014f";
Stripe.stripeAccountId = "acct_1IL78e48329489014f";
Stripe.urlScheme
before initializing Stripe instance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P0 Address these issues first
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants