capacitor-community / stripe

Stripe Mobile SDK wrapper for Capacitor
https://capacitor-community-stripe.netlify.app/
MIT License
197 stars 77 forks source link

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

Open polidario opened 1 year ago

polidario commented 1 year ago

Platform

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
ekniazi commented 1 year ago

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().

miraclemaker commented 1 year ago

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.

ciccilleju commented 1 year ago

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?

polidario commented 1 year ago

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)

matthewbecker1990 commented 9 months ago

@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!

rdlabo commented 7 months ago

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