OGeek|极客世界-中国程序员成长平台

标题: ios - PKPaymentAuthorizationViewController 不为零但不显示 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 18:26
标题: ios - PKPaymentAuthorizationViewController 不为零但不显示

我正在尝试显示一个 PKPaymentAuthorizationViewController,它不是 nil 但没有显示。 我以前工作过,但现在没有了。 权利和商家 ID 似乎不错。 这是我的初始化代码(没有无用的代码)

PKPaymentRequest *request = [PKPaymentRequest new];

request.merchantIdentifier = kApplePayMerchantId;
request.merchantCapabilities = PKMerchantCapability3DS;
request.supportedNetworks = self.class.supportedNetworks;
request.countryCode = _countryCode;
request.currencyCode = _currencyCode;
request.requiredShippingAddressFields = PKAddressFieldAll;
request.requiredBillingAddressFields = PKAddressFieldName | PKAddressFieldPostalAddress;
request.paymentSummaryItems = summaryItems;

PKPaymentAuthorizationViewController *paymentVC = [[PKPaymentAuthorizationViewController alloc] initWithPaymentRequest:request];
paymentVC.delegate = self;
return paymentVC;

然后我使用显示它

- (void)presentViewControllerUIViewController *)viewControllerToPresent animated: (BOOL)flag completionvoid (^ __nullable)(void))completion;

但是什么也没发生。没有日志...

我尝试在 return paymentVC; 之前设置断点,打印这个对象(看起来没问题),然后按下 Play,我得到了以下日志

Payment request is invalid: check your entitlements

Apple 付费 View Controller 出现并因 BAD ACCESS 错误而崩溃。

我真的不明白会发生什么。 你能帮我解决这个错误吗?



Best Answer-推荐答案


哇,经过一天的研究,我找到了。 如果您的默认 Apple Pay 送货地址(在钱包条目中,设置中)带有无效字段(我不知道它的规则),Apple Pay 表将不会弹出... 所以要注意这一点!

关于ios - PKPaymentAuthorizationViewController 不为零但不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35228985/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4