Ios8 PKPaymentAuthorizationViewController显示为零视图控制器

Ios8 PKPaymentAuthorizationViewController显示为零视图控制器,ios8,applepay,Ios8,Applepay,我正试图在我的演示应用程序中集成Apple Pay,链接如下&我面临着一个问题。我已将我的iphone 6+操作系统更新为8.1.1版本,但仍然无法正确显示PKPaymentAuthorizationViewController&我收到错误“应用程序试图在目标上显示无模式视图控制器”。请提供一些建议,因为我对此束手无策。以下是我编写的代码:- PKPaymentRequest *request = [[PKPaymentRequest alloc] init]; request.currenc

我正试图在我的演示应用程序中集成Apple Pay,链接如下&我面临着一个问题。我已将我的iphone 6+操作系统更新为8.1.1版本,但仍然无法正确显示PKPaymentAuthorizationViewController&我收到错误“应用程序试图在目标上显示无模式视图控制器”。请提供一些建议,因为我对此束手无策。以下是我编写的代码:-

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];


}

感谢和问候

在尝试演示viewcontroller之前,您是否实施了这些检查方法

// Determine whether this device can process payment requests.
// YES if the device is generally capable of making in-app payments.
// NO if the device cannot make in-app payments or if the user is restricted from authorizing payments.
+ (BOOL)canMakePayments;

// Determine whether this device can process payment requests using specific payment network brands.
// Your application should confirm that the user can make payments before attempting to authorize a payment.
// Your application may also want to alter its appearance or behavior when the user is not allowed
// to make payments.
// YES if the user can authorize payments on this device using one of the payment networks supported
// by the merchant.
// NO if the user cannot authorize payments on these networks or if the user is restricted from
// authorizing payments.
+ (BOOL)canMakePaymentsUsingNetworks:(NSArray *)supportedNetworks;

nil view controller表示您的
PKPaymentRequest
对象的格式不正确且缺少信息。你能在这里发布你的代码吗?我也有同样的问题…请有人帮助。我是否必须重写这两个方法并返回YES?否,当你执行这些方法时,它们将以YES或No响应,这将有助于解决apple pay无法在该设备上工作的问题。PKPaymentAuthorization ViewController可以使用网络进行支付:@[PKPaymentNetworkAmex、PKPaymentNetworkMasterCard、PKPaymentNetworkVisa]始终返回否…知道为什么吗???Iphone 6+iOS 8.1.1…是否可以使支付返回是?