stripe icon indicating copy to clipboard operation
stripe copied to clipboard

Apple Pay is not working on iOS (Apple Pay from the Demo not working either)

Open polidario opened this issue 1 year ago • 6 comments

Platform

  • [ ] Web
  • [x] iOS
  • [ ] Android

Describe the bug I'm currently working on application that needed Apple Pay. I've followed all the instructions including the ones from Stripe themselves (Certificates, Adding Domains, etc). And still the Apple Pay is not working. I've also tested the Demo website on our iPhone and no, it's also not working. So, my theory is there's something wrong with the plugin? Can someone else confirm that the demo for Apple Pay is working?

Expected behavior The app should allow users to click the create and present button for the ApplePay

Screenshots

Here's from Apple (To confirm that apple pay is enabled) Here's from the demo
image image

polidario avatar Oct 24 '23 15:10 polidario

Having the same issue with native iOS, works fine on iOS 16 simulator but Apple review team keeps rejecting the app stating:

We discovered one or more bugs in your app. Specifically, no action occurred when we tapped Apple Pay button.

Review device details:
- Device type: iPhone 
- OS version: iOS 17.0.3

I've added catch() with alerts to all isAvailable(), create() and present() methods but none of them get triggered suggesting a success flow with unsuccessful operation.

P.S: Followed all steps including merchant ID for Apple Pay along with including it in create().

ekniazi avatar Oct 26 '23 05:10 ekniazi

Also having the same issue. Am using createpayment Sheet. Apple Pay is set up and configured, so is PayPal. But the sheet appears only with card payment details.

miraclemaker avatar Oct 26 '23 17:10 miraclemaker

I tried it the last time in september and it was working, now it doesn't work anymore and i dont know if it's a problem of ios 17 or if something changed in the meanwhile and i didnt update my code i'm gettin this error: in xcode image

or this in my app image

can you show me what kind of error are you getting?

ciccilleju avatar Nov 15 '23 23:11 ciccilleju

I tried it the last time in september and it was working, now it doesn't work anymore and i dont know if it's a problem of ios 17 or if something changed in the meanwhile and i didnt update my code i'm gettin this error: in xcode image

or this in my app image

can you show me what kind of error are you getting?

Funnily enough, we don't even get to see the create button of this library's demo. As you can see in the Apple's demo screenshot, my sandbox apple pay is working (not just that, we tried using other online stores that accepts apple pay and it works), but not the demo. So my guess is there's an issue in the library (Though I'm always open for corrections)

polidario avatar Nov 17 '23 08:11 polidario

@polidario @ciccilleju @miraclemaker @rdlabo

I was having the same issues. I dived into the Swift code in the plugin and it looks like iOS may have changed how it handles the window rootView. I made the following changes to ApplePayExecutor.swift (found in @capacitor-community/stripe/ios/Plugin/ApplePay)and it has resolved the issue. Will try make a PR when I can, however I'm not super familiar with Swift, so not sure if my changes will break something elsewhere, but it seems to be working fine.

Added to the top of the file below the imports.

extension UIApplication {
    public var firstKeyWindow: UIWindow? {
        return UIApplication.shared.connectedScenes
            .compactMap { $0 as? UIWindowScene }
            .filter { $0.activationState == .foregroundActive }
            .first?.windows
            .first(where: \.isKeyWindow)
    }
}

Changed the following line of code in the presentApplePay function.

if let rootViewController = self.plugin?.getRootVC() { to if let rootViewController = UIApplication.shared.firstKeyWindow?.rootViewController {

Hope this helps!

matthewbecker1990 avatar Feb 14 '24 23:02 matthewbecker1990

Sorry to keep you waiting. Soon I will address this issue.

rdlabo avatar Apr 06 '24 00:04 rdlabo