Reputation: 1300
Integrated Apple Pay with my react-native app. It works in a simulator. When running on the device, things are a bit odd.
ApplePay.canMakePayments() returns true while ApplePay.canMakePaymentsUsingNetworks() returns false. While I am using a RN module and not Apple Pay directly, it appears that the code is right:
RCT_EXPORT_METHOD(canMakePaymentsUsingNetworks: (RCTResponseSenderBlock)callback)
{
NSArray *paymentNetworks = @[PKPaymentNetworkAmex, PKPaymentNetworkMasterCard, PKPaymentNetworkVisa];
if ([PKPaymentAuthorizationViewController canMakePaymentsUsingNetworks:paymentNetworks]) {
callback(@[@true]);
} else {
callback(@[@false]);
}
}
If I ignore canMakePaymentsUsingNetworks
, it returns a nil controller. That part makes sense.
The phone has a valid and verified card, which has been used with Apple Pay. We are still using a test stripe key. Can that be the problem? Please advise.
Please do not edit the text until you learn English.
Upvotes: 1
Views: 1413
Reputation: 6950
Ran into the same issue, and just finished troubleshooting.
Have you 1. created an Apple Pay merchant ID, and 2. added the Apple Pay entitlement to the app? These steps are outlined on the Stripe site. Once I did this, it started working. I did NOT have to create the Apple Pay certificate and upload it to Stripe to get Apple Pay to work, although sending the token to Stripe failed until I did this.
Note that you'll have to ensure that in Xcode the Project settings > General > Team setting, and Build Settings > Code Signing settings match the credentials linked to the Apple Pay entitlement.
I can confirm that this issue is NOT caused by:
PKPaymentNetworkAmex, PKPaymentNetworkMasterCard, PKPaymentNetworkVisa
)Note that, even after I got it working, I still saw sporadic failures and I don't know what caused these. Sometimes the app seemed to get into a weird state where canMakePaymentsUsingNetworks
would return false continually; after restarting the app, it magically started working again.
Upvotes: 1