我正在为来自美国以外的美国客户开发使用Apple Pay的应用程序.我正在使用Braintree Apple Pay.我们支持真实的信用卡到Passbook,但我们无法验证它们.
我成功地生成了一个客户端令牌,self.braintree,并尝试了BT的两种集成方式.
> BTPaymentProvider – 我们对付款方式创建的抽象.
if(self.braintree && ![self.braintree isKindOfClass:[NSNull class]]) { self.provider = [braintree paymentProviderWithDelegate:self]; if ([self.provider canCreatePaymentMethodWithProviderType:BTPaymentProviderTypeApplePay]) { self.provider.paymentSummaryItems = @[[PKPaymentSummaryItem summaryItemWithLabel:@"XXXX" amount:[NSDecimalNumber decimalNumberWithString:@"1"]]]; } [self.provider createPaymentMethod:BTPaymentProviderTypeApplePay]; }
但它没有推“PKPaymentAuthorizationViewController”.跟踪它也不例外.
> PassKit – Apple的ApplePay API.
if([PKPaymentAuthorizationViewController canMakePayments]) // It returns TRUE { PKPaymentRequest *paymentRequest = [[PKPaymentRequest alloc] init]; paymentRequest.countryCode = @"US"; paymentRequest.currencyCode = @"USD"; paymentRequest.merchantCapabilities = PKMerchantCapabilityEMV | PKMerchantCapability3DS; paymentRequest.merchantIdentifier = MERCHANTID; paymentRequest.supportedNetworks = @[PKPaymentNetworkAmex,PKPaymentNetworkMasterCard,PKPaymentNetworkVisa]; paymentRequest.paymentSummaryItems = @[ [PKPaymentSummaryItem summaryItemWithLabel:@"TEST" amount:[NSDecimalNumber decimalNumberWithString:@"1"]] ]; if([PKPaymentAuthorizationViewController canMakePaymentsUsingNetworks:@[PKPaymentNetworkAmex,PKPaymentNetworkVisa]]) // Returns FALSE { PKPaymentAuthorizationViewController *vc = [[PKPaymentAuthorizationViewController alloc] initWithPaymentRequest:paymentRequest]; vc.delegate = self; [self presentViewController:vc animated:YES completion:nil]; } }
这使得“vc”为零.
纠正我,如果这是错的.如何在真实设备上测试?
解决方法
您的应用的Apple Pay权利可能未正确设置.
我注意到canMakePayments返回YES并且canMakePaymentsUsingNetworks:在未设置权利时返回NO.
(我还注意到,当你在PKPaymentRequest上设置的商家ID与你的Apple Pay权利的商家ID不匹配时,他们都可以返回YES.在这种情况下,你的PKPaymentAuthorizationViewController将是非零的,但是它会记录一个控制台中的神秘错误).
因此,要确认为您的应用配置了Apple Pay,请确保目标设置的“功能”部分中的“Apple Pay”处于“开启”状态,并且它具有商家标识符(如果您还没有,则需要set up)已经).
然后:
>如果使用BTPaymentProvider集成方法,请确保在Braintree控制面板中正确设置证书和商家标识符.>如果使用直接PassKit集成方法,请确保将merchantIdentifier属性设置为权利中的匹配商家标识符.