简体   繁体   English

通过Stripe的Apple Pay canMakePaymentsUsingNetworks

[英]Apple Pay via Stripe canMakePaymentsUsingNetworks

Integrated Apple Pay with my react-native app. 将Apple Pay与我的本地应用程序集成。 It works in a simulator. 它可以在模拟器中工作。 When running on the device, things are a bit odd. 在设备上运行时,情况有些奇怪。

ApplePay.canMakePayments() returns true while ApplePay.canMakePaymentsUsingNetworks() returns false. ApplePay.canMakePayments()返回true,而ApplePay.canMakePaymentsUsingNetworks()返回false。 While I am using a RN module and not Apple Pay directly, it appears that the code is right: 当我使用RN模块而不是直接使用Apple Pay时,代码似乎正确:

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. 如果我忽略canMakePaymentsUsingNetworks ,它将返回一个nil控制器。 That part makes sense. 那部分是有道理的。

The phone has a valid and verified card, which has been used with Apple Pay. 手机具有经过验证的有效卡,该卡已与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. 在您学习英语之前,请不要编辑文本。

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? 您是否1.创建了Apple Pay商户ID,并且2.已将Apple Pay权利添加到应用程序? These steps are outlined on the Stripe site . 这些步骤在Stripe网站上概述。 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. 我不必创建Apple Pay证书并将其上传到Stripe即可使用Apple Pay,尽管直到执行此操作才将令牌发送到Stripe失败。

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. 请注意,您必须确保在Xcode中,项目设置>常规>团队设置,以及构建设置>代码签名设置与链接到Apple Pay授权的凭证匹配。

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 ) 选择支付网络(将我的设置为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; 有时,该应用似乎进入了一种奇怪的状态, canMakePaymentsUsingNetworks会不断返回false; after restarting the app, it magically started working again. 重新启动应用程序后,它神奇地重新开始工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM