1
votes

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.

1
How do I prevent someone with poor command of English from messing up my text?Moshe Shmukler
Have you tried specifying just the network of the card(s) stored in the phone? The use of "any" in the Apple docs is ambiguous. I would expect the Stripe environment to not be relevant at that point.jcaron
@jcaron don't understand your suggestion... you advise that I build an app with say only visa? our customers with MC and AmEx will probably be thrilled. don't you think?Moshe Shmukler
I'm just talking about testing it to see if that returns something different. Also, I suppose you have added the relevant capabilities, merchant IDs and certificates to your app?jcaron
@jcaron Simulator successfully receives a payment token from stripe. Hence, I am pretty sure that my settings are good. I also added capabilities/entitlements to the project and profile. Do you know how to check what is happening? Do you have hands-on experience integrating Apple Pay via Stripe?Moshe Shmukler

1 Answers

1
votes

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:

  1. Stripe test mode
  2. App not being built for release
  3. Choice of payment networks (mine is set to 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.