Reputation: 480
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 Code:
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;
Question: Now on iOS 8.4 when I try to present my paymentPane its value is nil somehow.
Fatal Exception: NSInvalidArgumentException Application tried to present a nil modal view controller on target .
What I have already tried by googling and using answers from stackoverflow.
Used Checks like
[PKPaymentAuthorizationViewController canMakePaymentsUsingNetworks:@[PKPaymentNetworkAmex, PKPaymentNetworkMasterCard, PKPaymentNetworkVisa]]
and
[PKPaymentAuthorizationViewController canMakePayments]
Checking my merchant id is valid or not.
Upvotes: 0
Views: 1612
Reputation: 6413
Check whether you've added Credit card
information in your device Passbook
or not.
Check whether you can make payment using your device.
Objective C :
Swift :
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");
}
Swift :
let paymentNetworks = [PKPaymentNetworkAmex, PKPaymentNetworkMasterCard, PKPaymentNetworkVisa]
if PKPaymentAuthorizationViewController.canMakePaymentsUsingNetworks(paymentNetworks) {
NSLog(@"Can Make payment with your card");
}
else {
NSLog(@"Card is not supporting");
}
Upvotes: 2
Reputation: 4990
I have also had similar problems when running inside the Xcode debugger. As a workaround I stop the app in Xcode and then manually start the app on the iPhone or iPad.
One drawback with this is obviously that you can't debug any issues. I've had to resort to NSLog and reading the console log.
Upvotes: 0