Search code examples
swiftstripe-paymentstestflightapplepaypasskit

apple pay button won't show even though device supports apple pay


so my goal is to have the apple pay button show up on devices that support apple pay and be hidden on devices that do not support it.

Currently I have a vc with two buttons, one is an Apple Pay button and one is a button that segues to a normal checkout. I use logic to determine the right buttons to show, if the device supports Apple Pay it'll show both, if not, it'll show the normal checkout button.

Here is an example of the simulator, a device that supports Apple Pay:

enter image description here

This is what it should look like for a device that supports Apple Pay. Here is the logic I use to determine what buttons to show:

func checkIfApplePaySupported() {
    if StripeAPI.deviceSupportsApplePay() == false {
        applePayButton.isHidden = true
    } else {
        applePayButton.isHidden = false
        applePayButton.addTarget(self, action: #selector(applePayTapped), for: .touchUpInside)
    }
}

Pretty straightforward, works perfectly fine on simulator. I hide the Apple Pay button originally in the storyboard so it doesn't have any choppy UI movement when the view loads. I call that method in the viewDidLoad() of the vc.

Now the issue is when I uploaded the build to TestFlight with that exact logic, the Apple Pay button does not show in the vc when testing on my iPhone. I have Apple Pay setup, there is a card in my Wallet, matter a fact, I paid for my groceries yesterday with Apple Pay so there is no doubt the device supports Apple Pay.

This is the outcome I get every time I get to that vc :

no apple pay button

The Apple Pay button never shows up despite the fact my device whole heartedly supports Apple Pay, this is like the weirdest bug and I can't figure out what I'm doing wrong for the life of me. This was happening with my friends as well, their device supported Apple Pay but they couldn't see the Apple Pay button as well and make payments with it. Any suggestions on how I can fix this bug?


Solution

  • You are using Apple Pay through Stripe. StripeAPI.deviceSupportsApplePay() function is not checking only "is device support Apple Pay or not?". It also checks is user has at least one saved credit card that supported by Stripe or other requirements. In the description of deviceSupportsApplePay() clearly describes that.

    Whether or not this can make Apple Pay payments via a card network supported by Stripe. The Stripe supported Apple Pay card networks are: American Express, Visa, Mastercard, Discover, Maestro. Japanese users can enable JCB by setting JCBPaymentNetworkSupported to YES, after they have been approved by JCB. - Returns: YES if the device is currently able to make Apple Pay payments via one of the supported networks. NO if the user does not have a saved card of a supported type, or other restrictions prevent payment (such as parental controls).

    For checking that you can run your app on simulator. StripeAPI.deviceSupportsApplePay() returns true in simulators.