Я пытаюсь интегрировать Apple Pay в свое демо-приложение после this link & Я столкнулся this issue вопрос. Я обновил свою версию iphone 6+ os до версии 8.1.1, но все еще не смог правильно представить PKPaymentAuthorizationViewController & Я получаю эту ошибку «Приложение попыталось представить nil modal view controller на цель». Пожалуйста, предложите что-нибудь, поскольку я застрял на этом .Здесь есть код, который я написал: -PKPaymentAuthorizationViewController присутствует как контроллер представления nil
PKPaymentRequest *request = [[PKPaymentRequest alloc] init];
request.currencyCode = @"USD";
request.countryCode = @"US";
// This is a test merchant id to demo the capability, this would work with Visa cards only.
request.merchantIdentifier = @"merchant.com.procharge"; // replace with YOUR_APPLE_MERCHANT_ID
request.applicationData = [@"" dataUsingEncoding:NSUTF8StringEncoding];
request.merchantCapabilities = PKMerchantCapability3DS;
request.supportedNetworks = @[PKPaymentNetworkMasterCard, PKPaymentNetworkVisa, PKPaymentNetworkAmex];
request.requiredBillingAddressFields = PKAddressFieldPostalAddress|PKAddressFieldPhone|PKAddressFieldEmail;
request.requiredShippingAddressFields = PKAddressFieldPostalAddress|PKAddressFieldPhone|PKAddressFieldEmail;
///Set amount here
NSString *amountText = @"0.01"; // Get the payment amount
NSDecimalNumber *amountValue = [NSDecimalNumber decimalNumberWithString:amountText];
PKPaymentSummaryItem *item = [[PKPaymentSummaryItem alloc] init];
item.amount = amountValue;
//item.amount = [[NSDecimalNumber alloc] initWithInt:20];
item.label = @"Test Payment Total";
request.paymentSummaryItems = @[item];
PKPaymentAuthorizationViewController *vc = nil;
// need to setup correct entitlement to make the view to show
@try
{
vc = [[PKPaymentAuthorizationViewController alloc] initWithPaymentRequest:request];
}
@catch (NSException *e)
{
NSLog(@"Exception %@", e);
}
if (vc != nil)
{
vc.delegate = self;
[self presentViewController:vc animated:YES completion:CompletionBlock];
}
else
{
//The device cannot make payments. Please make sure Passbook has valid Credit Card added.
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"PassKit Payment Error"
message:NSLocalizedString(@"The device cannot make payment at this time. Please check Passbook has Valid Credit Card and Payment Request has Valid Currency & Apple MerchantID.", @"")
delegate:nil
cancelButtonTitle:NSLocalizedString(@"OK", @"")
otherButtonTitles:nil];
[alert show];
}
спасибо & с уважением
Контроллер просмотра nil означает, что объект 'PKPaymentRequest' был плохо сформирован и отсутствовала информация. Можете ли вы разместить свой код здесь? – lxt
У меня такая же проблема .... пожалуйста, кто-то поможет. – iAnurag