tipsi / tipsi-stripe

React Native Stripe binding for iOS/Android platforms
MIT License
1.14k stars 526 forks source link

Apple Pay "Canceled by User" on Real Device #315

Closed psimk closed 3 years ago

psimk commented 6 years ago

As the title suggests, I am receiving a really weird issue, when running my app on a Real Device. Everything works as expected on the iOS emulator, but once I get the app on the App Store this "Error: Canceled by user" keeps comming up immediately after initiating "paymentRequestWithApplePay".

isnifer commented 6 years ago

@PaulySim Hi! I got this issue too. Trying to figure out what's wrong

isnifer commented 6 years ago

@PaulySim what version of iOS and Simulator Model do you use?

psimk commented 6 years ago

@isnifer Tried it with iOS 8 and 9 with the 6, 6plus, 8 and X Models. I think, that the models are just for the different screen sizes and they don't actually change the behavior. Also, I attempted to update Stripe from 11.2.0 to 13.0.3, but still got the same result. There's definitely nothing wrong with my app as I attempted create a completely new project with the UI from the example and it still wouldn't work. Right now I will try lower RN versions as I am always testing on the 0.55.

isnifer commented 6 years ago

@PaulySim can you build your app with Xcode on device and look into logs?

psimk commented 6 years ago

@isnifer Nope, sorry. My friend is testing the app, because in my country Apple Pay is not supported so I cannot test it out on a Real Device. Also, we just tried out it on RN 0.52.3 and we get the same error.

isnifer commented 6 years ago

@PaulySim did your friend follow these requirements https://developer.apple.com/documentation/passkit/apple_pay/setting_up_apple_pay_requirements?

isnifer commented 6 years ago

tldr; you need to activate apple pay, create merchant id for your app in the developer portal

psimk commented 6 years ago

@isnifer All of that is done and Apple Pay is activated, without it the emulator version of Apple Pay wouldn't work.

psimk commented 6 years ago

@isnifer On the emulator, sometimes I get this error:

2018-06-20 18:24:11.941197+0200 [APPNAME][48659:865470] Failed to present in-app payment interface: Error Domain=PKPassKitErrorDomain Code=-1 "Payment interface not available" UserInfo={NSLocalizedDescription=Payment interface not available}

When it shows up, I get the "Canceled by User" error, but that's just for the emulator.

isnifer commented 6 years ago

@PaulySim there is an error on iOS 11.2 Simulator. We have temporarily fixed it with a downgrade of Xcode to 9.1. Later we will update an RN version of our example app and upgrade a version of the Xcode to 9.3 (or 9.4.1 who knows)

isnifer commented 6 years ago

@PaulySim it would be nice to connect a real device to Xcode and see the log

nineto4 commented 6 years ago

I had the same problem just forgot about MERCHANT_ID stripe.init({ merchantId: '', publishableKey: '', });

isnifer commented 6 years ago

@NextVictim stripe.setOptions in current release

nineto4 commented 6 years ago

@isnifer yes before 5.0.0: stripe.init after 5.0.0: stripe.setOptions

IzaacBarratt commented 6 years ago

I'm having this problem also. My apple merchant details are set up, and it works on my simulator, but when testing on my phone it says cancelled by user.

The error output I'm getting on the xcode console just says: 'Error: Canceled by User'

AshtonKem commented 6 years ago

I'm in the exact same boat.

AshtonKem commented 6 years ago

After running it on my device in Debug mode, it turns out my error is "deviceNotSupportsNativePay".

I got this after configuring my merchantId and setting all settings you mentioned here. Do you think this is the same error, or should I open a new ticket?

pborbas commented 5 years ago

Hi, Same issue here. All set up (merchant id, certificate), xcode configured, stripe.setOptions called. Simulator also works for me. Btw simulator also worked when I forgot to set up the Payment Processing Certificate for our merchant id, so this step may help someone. stripe.deviceSupportsNativePay() and stripe.canMakeNativePayPayments() both returns true.

Sadly I cannot access the device to connect it and create debug logs cause its in another country where applepay is supported.

Stripe pod version: 13.2.0, "tipsi-stripe": "^6.1.2", "react-native": "0.55.4"

pborbas commented 5 years ago

Turned out it was our merchant id. I made lots of changes and we used the old id in our app code, so with the versions in my previous comment it works. here are some thing you can check

rahulverma0508 commented 5 years ago

@isnifer, we are also facing exactly the same issue as you. Were you able to get it running on iOS 11.2 and higher versions?

It's set up correctly with merchant id or certificates and works great on iOS 11.1. Any help here will be highly appreciated. Thank you!

isnifer commented 5 years ago

@rahulverma0508 as I wrote before – no. Actually, I do not work on this component any more.

ShikharQuovantis commented 5 years ago

@isnifer So, Is Tipsi/Stripe not supporting Apple Pay anymore? Or is this issue assigned to some other contributor? As the problem is, we cannot get Apple pay working without it. I hope you do understand. Thanks.

cybergrind commented 5 years ago

@ShikharQuovantis tipsi-stripe is working with apple pay.

@rahulverma0508 it works on IOS 12+ on ipad mini 4. Cannot say version by version but if you have 11.1 working and 11.2 not working. That is strange and we have real payments via apple pay so there are no reasons to suspect that the library doesn't work itself.

grahamyesfit commented 5 years ago

Has anyone been successful getting past this error? I'm getting the same. The code works in the simulator, but on a real device, I get the "Canceled by user" alert. I have performed all the steps outlined here twice, with no success.

Here are my versions:

xCode 10
Stripe pod version 14.0.0
tipsi-stripe 7.0.0
react-native 0.57.8
samcorcos commented 5 years ago

For what it's worth, I ran into this error as well and I solved it.

My problem was that the name of the MerchantId in Xcode did not match the MerchantId when I initialized stripe in stripe.setOptions. It took a while to diagnose since the error says "Cancelled by user", but that solved it.

grahamyesfit commented 5 years ago

@samcorcos , thanks so much for the hint. Unfortunately, I've checked this thrice, and still no luck. I even completely changed it something else, to rule out a caching issue.

I do realize, however, that the "Cancelled by user" message is likely masking the real error. I just need to find out what that is?

Let me ask you something, if you don't mind. On your Apple certificates page, is the merchant certificate type "Apple Pay Payment Processing"? In addition, is the merchantId value in the "Name" field on this page?

samcorcos commented 5 years ago

@grahamyesfit Yes, it's "Apple Pay Payment Processing" and the "Name" matches the merchantId that I put in Xcode :)

fardeen-panjwani commented 5 years ago

Has anyone resolved it yet. I'm facing the same issue.

grahamyesfit commented 5 years ago

@fardeen-panjwani, I haven't fixed it, but I found a workaround.

In my case, it was obviously code not configuration, because it occasionally worked on one device, and not others.

I included many NSLog calls in TPSStripeManager.m, and I was able to establish that as soon as paymentAuthorizationVC is queued for viewing, the paymentAuthorizationViewControllerDidFinish method runs immediately. The way the code is written, Cancelled by User is the default error, so that's the one that's shown.

My conclusion is there's some kind of timing or memory issue.

My workaround, though not ideal, seems to make the code work - I put a 5 second delay in TPSStripeManager.m, it's around line 446, in the paymentRequestWithApplePay method:

        double delayInSeconds = 5.0;
        dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
        dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
            dispatch_async(dispatch_get_main_queue(), ^{
                [RCTPresentedViewController() presentViewController:paymentAuthorizationVC animated:YES completion:nil];
            });
        });

You're welcome to pull our repository to see if it fixes your issue: github:yesfit/tipsi-stripe.

This has been a frustrating experience. This ticket was originally opened Jun 19, 2018, and people are clearly still having issues, but the tipsi team seem not to care about this particular module. This library is by far the best Stripe/React Native implementation; Google Pay and Credit card payments work flawlessly. I was able to engage a developer at Stripe, and he was the person that suggested it was a timing or memory issue. I wish Stripe would provide their own official React Native implementation.

fardeen-panjwani commented 5 years ago

@fardeen-panjwani, I haven't fixed it, but I found a workaround.

In my case, it was obviously code not configuration, because it occasionally worked on one device, and not others.

I included many NSLog calls in TPSStripeManager.m, and I was able to establish that as soon as paymentAuthorizationVC is queued for viewing, the paymentAuthorizationViewControllerDidFinish method runs immediately. The way the code is written, Cancelled by User is the default error, so that's the one that's shown.

My conclusion is there's some kind of timing or memory issue.

My workaround, though not ideal, seems to make the code work - I put a 5 second delay in TPSStripeManager.m, it's around line 446, in the paymentRequestWithApplePay method:

        double delayInSeconds = 5.0;
        dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
        dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
            dispatch_async(dispatch_get_main_queue(), ^{
                [RCTPresentedViewController() presentViewController:paymentAuthorizationVC animated:YES completion:nil];
            });
        });

You're welcome to pull our repository to see if it fixes your issue: github:yesfit/tipsi-stripe.

This has been a frustrating experience. This ticket was originally opened Jun 19, 2018, and people are clearly still having issues, but the tipsi team seem not to care about this particular module. This library is by far the best Stripe/React Native implementation; Google Pay and Credit card payments work flawlessly. I was able to engage a developer at Stripe, and he was the person that suggested it was a timing or memory issue. I wish Stripe would provide their own official React Native implementation.

Thanks @grahamyesfit! Worked really well for me.

kelmendtairi commented 5 years ago

It is necessary to have connected account on stripe in order to use test Apple Pay? I get the same error and im stuck for 3 days..

quachsimon commented 5 years ago

Have there been any updates on this? I am experiencing a similar issue but, on the simulator. On a real device Apple Pay is working as normal.

I am not sure how to debug this issue and I've tried deleting the cached simulator data with no luck.

kyytiPetteri commented 5 years ago

Getting the same error when making request on iOS 13

MrKriegler commented 5 years ago

Have there been any updates on this? I am experiencing a similar issue but, on the simulator. On a real device Apple Pay is working as normal.

I am not sure how to debug this issue and I've tried deleting the cached simulator data with no luck.

@quachsimon were you able to solve this? I'm having the same issue on the emulator and not an actual device.

quachsimon commented 5 years ago

@MrKriegler, no. I have resorted to testing only on my physical device for the time being.

ghost commented 5 years ago

I'm getting the error on emulators and physical devices running iOS 13.

Podfile:

# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'

target 'FlyWithBreeze' do
  pod 'Stripe', '~> 14.0.0'
  pod 'Firebase/Core'
  pod 'Firebase/Auth'
  pod 'GoogleIDFASupport'
  pod 'Firebase/Database'
  pod 'Firebase/Functions'
  pod 'Firebase/DynamicLinks'
  pod 'Firebase/Firestore'
  pod 'Firebase/Messaging'
  pod 'Firebase/RemoteConfig'
  pod 'Firebase/Storage'
  pod 'Firebase/Performance'
  pod 'Fabric'
  pod 'Crashlytics'
  pod 'GoogleSignIn'
  pod 'RNGoogleSignin', :path => '../node_modules/react-native-google-signin'
  pod 'React', path: '../node_modules/react-native'
  pod 'yoga', path: '../node_modules/react-native/ReactCommon/yoga'
  inherit! :search_paths
  pod 'ReactNativeExceptionHandler', :path => '../node_modules/react-native-exception-handler'
  pod 'react-native-splash-screen', :path => '../node_modules/react-native-splash-screen'
  pod 'react-native-webview', :path => '../node_modules/react-native-webview'
  pod 'Mixpanel'

  pod 'RNCAsyncStorage', :path => '../node_modules/@react-native-community/async-storage'

  pod 'react-native-netinfo', :path => '../node_modules/@react-native-community/netinfo'

end
post_install do |installer|
  installer.pods_project.targets.each do |target|
    targets_to_ignore = %w(React yoga)
    if targets_to_ignore.include? target.name
      target.remove_from_project
    end
  end
end

package.json:

    "@react-native-community/netinfo": "^4.4.0",
    "axios": "^0.19.0",
    "moment-timezone": "^0.5.23",
    "native-base": "^2.13.8",
    "prop-types": "^15.6.2",
    "react": "16.6.1",
    "react-native": "^0.59.9",
    "react-native-cached-image": "^1.4.3",
    "react-native-clean-project": "^3.2.4",
    "react-native-config": "^0.11.7",
    "react-native-exception-handler": "^2.10.8",
    "react-native-fetch-blob": "^0.10.8",
    "react-native-firebase": "^5.5.6",
    "react-native-google-signin": "^1.2.2",
    "react-native-gridview": "^0.1.2",
    "react-native-image-picker": "^0.28.0",
    "react-native-image-progress": "^1.1.1",
    "react-native-linear-gradient": "^2.5.3",
    "react-native-mixpanel": "^1.1.4",
    "react-native-open-settings": "^1.0.1",
    "react-native-size-matters": "^0.1.6",
    "react-native-splash-screen": "^3.2.0",
    "react-native-status-bar-height": "^2.2.0",
    "react-native-super-grid": "^3.0.4",
    "react-native-swipe-gestures": "^1.0.3",
    "react-native-swiper": "^1.5.14",
    "react-native-vector-icons": "^6.2.0",
    "react-native-webview": "^7.4.1",
    "react-navigation": "^2.18.2",
    "react-redux": "^6.0.0",
    "redux": "^4.0.1",
    "redux-logger": "^3.0.6",
    "redux-thunk": "^2.3.0",
    "spacetime": "^5.9.0",
    "tipsi-stripe": "^7.2.0",
    "url-parse": "^1.4.4"
multiplegeorges commented 4 years ago

Same issue here @grahamyesfit , I also thought it was a timing issue so I tried your branch but it didn't make a difference.

My code works perfectly on sandboxed device and real device, but never opens the Apple Pay modal in Simulator. The weird thing is that it used to work in Simulator, then one day stopped working.

It fails with the same User cancelled error message and the source is the device calling paymentAuthorizationViewControllerDidFinish before anything is shown on screen.

I've tried debugging for hours to no avail. It's really not clear what's happening.

@cybergrind Is there anyone at tipsi that can look at this? I'll help out by going through any debug steps you need to figure this out.

Thanks!

macnibblet commented 4 years ago

We are experiencing the same issue that @multiplegeorges Is having and would also love to see this issue resolved.

wayzate commented 4 years ago

Had the same problem and got it working on real iOS device, RN0.61.2, tipsi-stripe 7.5.1.

Step for installation:

Added on top of ApplePayScreen.js (from tipsi-stripe example available on github): stripe.setOptions({ publishableKey: myStripePublicKey, merchantId: myMerchantId, // Optional androidPayMode: 'test', // Android only })

multiplegeorges commented 4 years ago

Some research with multiple simulators running different iOS versions:

iPhone 8 - iOS 11 ✅ Apple Pay works in Simulator as expected.

iPhone 8 - iOS 12 ⚠️ Apple Pay confirmation modal appears, click "Pay with Passcode", errors out with "Cancelled by User".

iPhone 8 - iOS 13 🔴 Apple Pay confirmation modal never appears. "Cancelled by User" error is thrown after 1-2 seconds.

mlguys commented 4 years ago

I can confirm that I'm having the same issue as @multiplegeorges, Apple Pay modal is no longer work on my ios 13 Simulator anymore.

cybergrind commented 4 years ago

@multiplegeorges from what I can say this library support isn't a priority for the tipsi as a business. probably it isn't going to be fixed

JollyGolf commented 4 years ago

I tried fix same issue with other plugins Apple Pay throughout 2 days and I found the solution. I didn't enter the properly merchantID. Before that on Emulator (iOS 12, 13) it worked perfectly, but on real device - "Canceled by User" or "AbortError". I tried any solution, no luck.

And when I entered properly merchantID (in my case I used chain Apple Pay + Gateway [SberBank]) apple pay was called on real device. And same error was disappeared.

Conclusion: Please check your merchantID is active and ready to work. Try to send it to other developers, who published own application on App Store and ask them to temporary replace their merchantID with your (in dev config of course). I'm absolutely right that error due to invalid, inactive or improperly prepared merchantID. I hope this information helps you. Let me know if so.

marcelpl commented 4 years ago

We had the same issue and managed to fix it. Building on @JollyGolf you need to add the MerchantID to signing capabilities on your XCode

VinitBhavsar commented 4 years ago

Check that your region / country supported for apple pay or not? Also for test environment. In emulator for ios 13.6 it work, but for my device 13.6 it's not working.

https://developer.apple.com/apple-pay/sandbox-testing/ https://support.apple.com/en-us/HT207957

jack828 commented 4 years ago

To all those still looking for a solution:

This worked for me for the 8.0.0beta-10.

zesk8 commented 3 years ago

Is someone still facing these issue?

I have the same problem in 8.0.0beta-11 and I try all the solutions here but still see the canceled by user error

jSkrills commented 3 years ago

For me what was wrong was that in xCode I could see Apple Pay in the signing and capabilities section and I saw my Merchant ID listed correctly beneath it but did not notice that the grey square next to it is actually a checkbox that needs to be checked. Once I did that things worked fine. A simple oversight but perhaps it will help another lost soul

RayKay91 commented 2 years ago

For me the issue was that I was using a deprecated method. Use paymentAuthorizationViewController:didAuthorizePayment:handler: not paymentAuthorizationViewController:didAuthorizePayment:completion: