capacitor-community / stripe

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

Can't use stripe on ios #85

Closed danielalbrecht closed 2 years ago

danielalbrecht commented 2 years ago

I tried to integrate the stripe plugin in our ionic app.

Im getting a "paymentSheetFailed" error on iOS But its works on android. I added a print statement to the PaymentSheetExecutor.swift file to get more informations about the error.

The error message is: Error Domain=com.stripe.lib Code=50 "Unerwarteter Fehler – versuchen Sie es in ein paar Sekunden noch einmal." UserInfo={NSLocalizedDescription=Unerwarteter Fehler – versuchen Sie es in ein paar Sekunden noch einmal., com.stripe.lib:ErrorMessageKey=No valid API key provided. Set STPAPIClient.shared().publishableKey to your publishable key, which you can find here: https://stripe.com/docs/keys, com.stripe.lib:StripeErrorCodeKey=,com.stripe.lib:StripeErrorTypeKey=invalid_request_error} #

To Reproduce Our integration:

image

Expected behavior Open the payment sheet

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

Desktop (please complete the following information):

Smartphone (please complete the following information):

rdlabo commented 2 years ago

@danielalbrecht Did you run initialize? https://github.com/capacitor-community/stripe#initialize-stripe

danielalbrecht commented 2 years ago

Yes, the Stripe.initialize is called

image

I also added debug outputs to the SwiftPlugin.swift, to check if the publishableKey is there.

rdlabo commented 2 years ago

@danielalbrecht Thanks for reply.

We confirmed this plugin working at https://github.com/capacitor-community/stripe/tree/master/demo Doesn't this demo work in your environment, too? or Test environment at stripe key can work, but Production environment at stripe key can't work??

If possible, I would be grateful if you could share a repository that doesn't work.

rdlabo commented 2 years ago

memo: What is the difference between StripeAPI.defaultPublishableKey and STPAPIClient.shared.publishableKey? https://stackoverflow.com/questions/67879699/what-is-the-difference-between-stripeapi-defaultpublishablekey-and-stpapiclient

danielalbrecht commented 2 years ago

@rdlabo we invited you to our repository (called "sammlr"). Until now we only have the stripe test environment. I will try the demo

rdlabo commented 2 years ago

@danielalbrecht checked, but I can't find capacitor-community/stripe code at master and development branch. First, please check demo. Thanks.

danielalbrecht commented 2 years ago

Sry, I didn't commit, pls do a pull

PaintedShepherd commented 2 years ago

What ionic and Capacitor Version do we Need to run the Demo? Maybe the global version is a problem?

danielalbrecht commented 2 years ago

I tried the demo, but only get a blank screen. It seems like that the ready state is never called. I don't get a log from the PaymentSheetEventsEnum.Loaded

image

2021-07-25 23:17:02.929895+0200 App[47711:816154] KeyboardPlugin: resize mode - native ⚡️ Loading app at capacitor://localhost... 2021-07-25 23:17:03.955069+0200 App[47711:816154] WF: === Starting WebFilter logging for process App 2021-07-25 23:17:03.955385+0200 App[47711:816154] WF: _userSettingsForUser : (null) 2021-07-25 23:17:03.955643+0200 App[47711:816154] WF: _WebFilterIsActive returning: NO ⚡️ JS Eval error A JavaScript exception occurred ⚡️ [log] - Angular is running in development mode. Call enableProdMode() to enable production mode. ⚡️ To Native -> Stripe initialize 19423468 ⚡️ TO JS undefined ⚡️ To Native -> Stripe addListener 19423469 ⚡️ To Native -> Stripe addListener 19423470 ⚡️ To Native -> Stripe addListener 19423471 ⚡️ To Native -> Stripe addListener 19423472 ⚡️ To Native -> Stripe addListener 19423473 ⚡️ To Native -> App addListener 19423474

rdlabo commented 2 years ago

@PaintedShepherd @danielalbrecht Did you run current version? current version is updated @stripe-elements/stripe-elements: https://github.com/capacitor-community/stripe/commit/00f15ba2bd17036c654f29738cadc94a59dc922a#diff-ec8d138d9f45c8082220b3c83e0ad27d074b65b9301038a259556e55a42b8f08

Please confirm version is 0.0.2. Thanks.

PaintedShepherd commented 2 years ago

We are not using the stripe-elements, just the stripe plug-in. We don’t need web support, just iOS and Android.

PaintedShepherd commented 2 years ago

Anything else we should try to initialize the plug-in on iOS?

rdlabo commented 2 years ago

in demo code, @stripe-elements/stripe-elements is read at https://github.com/capacitor-community/stripe/blob/master/demo/angular/src/main.ts#L14. This read at every platform.

Please clone demo code the current version anyway. Now this repository, I confirm work right.

PaintedShepherd commented 2 years ago

こんにちはみなさん

we managed to make it work. It was kind of our fault because the ephemeralKey was wrong. It’s still interesting that it works on android. Is the ephemeral key only for iOS?

どうもありがとう. さよなら

rdlabo commented 2 years ago

Good news! the ephemeral key use android, too. This may stripe specification. https://github.com/capacitor-community/stripe/blob/master/android/src/main/java/com/getcapacitor/community/stripe/paymentsheet/PaymentSheetExecutor.java#L58

rdlabo commented 2 years ago

@danielalbrecht @PaintedShepherd Did you adapt this plugin for production? If yes, please tell us what app. Please help us to develop this plugin in 2022. https://github.com/capacitor-community/stripe/issues/145 Thanks.

roblog commented 8 months ago

I had the same problem. It turned out to be because I was trying to use the ephemeral key ID instead of the ephemeral key secret. The interesting thing is that the payment sheet loaded on Android, but not on IOS. (Which completely threw me off the scent!) Just thought I’d mention it in case it is of interest / help to anyone.