后台:我在iOS 8.2,8.3上使用了相同的代码,但它运行正常。
PKPaymentAuthorizationViewController *paymentPane = [[PKPaymentAuthorizationViewController alloc] initWithPaymentRequest:request];
paymentPane.delegate = self;
[self presentViewController:paymentPane animated:TRUE completion:nil];
PaymentRequest代码:
PKPaymentRequest *request = [[PKPaymentRequest alloc] init];
NSString *chargeApplePay=[NSString stringWithFormat:@"%.02f",pay];
PKPaymentSummaryItem *total = [PKPaymentSummaryItem summaryItemWithLabel:@"Grand Total"
amount:[NSDecimalNumber decimalNumberWithString:chargeApplePay]];
request.paymentSummaryItems = @[total];
request.countryCode = @"US";
request.currencyCode = @"USD";
request.supportedNetworks = @[PKPaymentNetworkAmex, PKPaymentNetworkMasterCard, PKPaymentNetworkVisa];
request.merchantIdentifier = @"valid.com.myIdentifier";
request.merchantCapabilities = PKMerchantCapability3DS;
问题:现在在iOS 8.4上,当我尝试提供我的paymentPane时,其价值是以某种方式为零。
致命异常:NSInvalidArgumentException应用程序尝试过 在目标上显示一个零模态视图控制器。
我已经尝试使用Google搜索并使用stackoverflow中的答案。
二手检查
[PKPaymentAuthorizationViewController canMakePaymentsUsingNetworks:@[PKPaymentNetworkAmex, PKPaymentNetworkMasterCard, PKPaymentNetworkVisa]]
和
[PKPaymentAuthorizationViewController canMakePayments]
检查我的商家ID是否有效。
答案 0 :(得分:2)
检查您是否在设备Credit card
中添加了Passbook
信息。
检查您是否可以使用自己的设备付款。
目标C:
if ([PKPaymentAuthorizationViewController canMakePayments]) {
NSLog(@"Can Make Payments");
}
else {
NSLog(@"Can't Make payments");
}
斯威夫特:
if PKPaymentAuthorizationViewController.canMakePayments() {
NSLog(@"Can Make Payments");
}
else {
NSLog(@"Can't Make Payments");
}
payment networks
付款。
NSArray *paymentNetworks = [NSArray arrayWithObjects:PKPaymentNetworkMasterCard, PKPaymentNetworkVisa, PKPaymentNetworkAmex, nil];
if ([PKPaymentAuthorizationViewController canMakePaymentsUsingNetworks:paymentNetworks]) {
NSLog(@"Can Make payment with your card");
}
else {
NSLog(@"Card is not supporting");
}
斯威夫特:
let paymentNetworks = [PKPaymentNetworkAmex, PKPaymentNetworkMasterCard, PKPaymentNetworkVisa]
if PKPaymentAuthorizationViewController.canMakePaymentsUsingNetworks(paymentNetworks) {
NSLog(@"Can Make payment with your card");
}
else {
NSLog(@"Card is not supporting");
}
答案 1 :(得分:0)
在Xcode调试器中运行时,我也有类似的问题。作为解决方法,我在Xcode中停止应用程序,然后在iPhone或iPad上手动启动应用程序。
显然,您无法调试任何问题。我不得不求助于NSLog并阅读控制台日志。