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

Update deviceSupportsApplePay #3350

Open
acatalina opened this issue Feb 29, 2024 · 4 comments
Open

Update deviceSupportsApplePay #3350

acatalina opened this issue Feb 29, 2024 · 4 comments
Labels
kind:improvement triaged Issue has been reviewed by Stripe and is being tracked internally

Comments

@acatalina
Copy link

Is your feature request related to a problem? Please describe.

I use the react native library. I am having an issue where our apps gets randomly rejected by the app store review process because they cannot see Apple Pay at checkout. It seems that deviceSupportsApplePay is returning false on their device.

My only guess is that whatever they are doing in the review process, they don't have a compatible card with apple pay on the device so I was looking into firing the setup apple pay when no cards available. It seems that from iOS 15+ this is not even necessary as customers can add cards directly on the payment sheet.

I don't have much clue when looking at swift and please correct me if I am wrong but as far as I can tell from the react native bridge I call isPlatformPaySupported that through the bridge it calls deviceSupportsApplePay.

Looking at the latest, it seems that it calls canMakePayments with the supported networks.

    @objc public class func deviceSupportsApplePay() -> Bool {
        if let deviceSupportsApplePay = _deviceSupportsApplePay {
            return deviceSupportsApplePay
        }
        let deviceSupportsApplePay = PKPaymentAuthorizationController.canMakePayments(
            usingNetworks: self.supportedPKPaymentNetworks()
        )
        _deviceSupportsApplePay = deviceSupportsApplePay
        return deviceSupportsApplePay
    }

Checking around, there's also another method here https://github.com/stripe/stripe-ios/blob/d3362b0cd52f0892f4f1fe1e9b0bce5172a82de6/StripeApplePay/StripeApplePay/Source/ApplePayContext/STPApplePayContext.swift that it does this:

      let canMakePayments: Bool = {
            if #available(iOS 15.0, *) {
                // On iOS 15+, Apple Pay can be displayed even though there are no cards because Apple added the ability for customers to add cards in the payment sheet (see WWDC '21 "What's new in Wallet and Apple Pay")
                return PKPaymentAuthorizationController.canMakePayments()
            } else {
                return PKPaymentAuthorizationController.canMakePayments(usingNetworks: StripeAPI.supportedPKPaymentNetworks())
            }
        }()

Describe the solution you'd like

If I am correct on what I am saying, I wonder if it's possible to implement a similar approach for deviceSupportsApplePay.

Describe alternatives you've considered

I was considering firing setup apple pay PKPassLibrary.init().openPaymentSetup() but I should check first if Apple Pay is available on the device which there are no methods to do this. As I understand the flow, first it needs to check canMakePayments and then canMakePaymentsUsingNetworks to determine if apple pay is supported first and then if there are cards available to pay.

I hope it makes sense. Thanks

@yuki-stripe
Copy link
Collaborator

Thanks for writing in @acatalina!

It'd be surprising if the app store is rejecting apps because of this - can you share the rejection reason?

Describe alternatives you've considered
I was considering firing setup apple pay PKPassLibrary.init().openPaymentSetup() but I should check first if Apple Pay is available on the device which there are no methods to do this. As I understand the flow, first it needs to check canMakePayments and then canMakePaymentsUsingNetworks to determine if apple pay is supported first and then if there are cards available to pay.

No need to call PKPassLibrary.init().openPaymentSetup() - you can call the RN method that opens Apple Pay like normal even if the customer doesn't have a card on iOS 15+ and it will automatically show the "Add card" flow.

@yuki-stripe yuki-stripe added the triaged Issue has been reviewed by Stripe and is being tracked internally label Feb 29, 2024
@acatalina
Copy link
Author

hey @yuki-stripe, thanks for the quick response.

I am surprised we are the only ones hehe We've deployed at least a hundred apps through the app store and we've seen this a very common issue on the approval process.

Guideline 2.1 - Information Needed

We're looking forward to completing our review of your app, but we still need more information to continue. Specifically, we noticed that your binary includes the PassKit framework for implementing Apple Pay, but we were unable to verify any integration of Apple Pay within your app.

Apple Pay is a mobile payment technology that provides an easy and secure way for users to pay for physical goods and real-world services in apps and on the web.

One of the latests examples.

No need to call PKPassLibrary.init().openPaymentSetup() - you can call the RN method that opens Apple Pay like normal even if the customer doesn't have a card on iOS 15+ and it will automatically show the "Add card" flow.

I think I've not written the issue very well. The alternative that I've considered is not possible neither. The problem here is that I'm trying to check if Apple Pay is supported on the device before showing and/or calling the create payment method but I don't have any methods to do so.

@yuki-stripe
Copy link
Collaborator

Ah I see. Your issue was written clearly, I just didn't read carefully!

I'd recommend using the native PKPaymentAuthorizationController.canMakePayments() instead of using isPlatformPaySupported. That should do what you want - it ignores whether or not the customer has saved cards.

For some more context, I don't think it's an option for us to change deviceSupportsApplePay to start returning true in the case where users can add cards. It'd be a material change in its documented behavior (it'd stop respecting the list of supported card networks).

@acatalina
Copy link
Author

Fair enough. The thing is I use the react native library that's why I was suggesting changing the behaviour of deviceSupportsApplePay

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:improvement triaged Issue has been reviewed by Stripe and is being tracked internally
Projects
None yet
Development

No branches or pull requests

2 participants