PKPaymentAuthorizationViewController在iOS 8.4上意外崩溃 [英] PKPaymentAuthorizationViewController is crashing unexpectedly on iOS 8.4
问题描述
后台:我在iOS 8.2,8.3上使用了相同的代码,但它运行正常。
Background: I used same code for iOS 8.2,8.3 it was working fine.
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上尝试展示我的payPane价值是以某种方式为零。
Question: Now on iOS 8.4 when I try to present my paymentPane its value is nil somehow.
致命异常:NSInvalidArgumentException应用程序尝试
在目标上显示一个nil模态视图控制器。
Fatal Exception: NSInvalidArgumentException Application tried to present a nil modal view controller on target .
我已经尝试使用Google搜索和使用stackoverflow的答案。
-
二手支票
Used Checks like
[PKPaymentAuthorizationViewController canMakePaymentsUsingNetworks:@[PKPaymentNetworkAmex, PKPaymentNetworkMasterCard, PKPaymentNetworkVisa]]
和
[PKPaymentAuthorizationViewController canMakePayments]
检查我的商家ID是否有效。
Checking my merchant id is valid or not.
推荐答案
-
检查磨她已经在您的设备中添加了
信用卡
信息Passbook
。
检查您是否可以使用自己的设备付款。
目标C:
Check whether you can make payment using your device.
Objective C :
if ([PKPaymentAuthorizationViewController canMakePayments]) {
NSLog(@"Can Make Payments");
}
else {
NSLog(@"Can't Make payments");
}
Swift:
Swift :
if PKPaymentAuthorizationViewController.canMakePayments() {
NSLog(@"Can Make Payments");
}
else {
NSLog(@"Can't Make Payments");
}
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");
}
Swift:
Swift :
let paymentNetworks = [PKPaymentNetworkAmex, PKPaymentNetworkMasterCard, PKPaymentNetworkVisa]
if PKPaymentAuthorizationViewController.canMakePaymentsUsingNetworks(paymentNetworks) {
NSLog(@"Can Make payment with your card");
}
else {
NSLog(@"Card is not supporting");
}
这篇关于PKPaymentAuthorizationViewController在iOS 8.4上意外崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!