问题
I'm trying to display a PKPaymentAuthorizationViewController which is not nil but isn't showing. I worked before but it doesn't anymore. The entitlement and merchant id seems good. Here is my init code (without useless code)
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;
Then I display it using
- (void)presentViewController:(UIViewController *)viewControllerToPresent animated: (BOOL)flag completion:(void (^ __nullable)(void))completion;
But nothing happens. No log ...
I tried to set a breakpoint before return paymentVC;
, printed this object (seemed ok) and then pressed Play and I had the following log
Payment request is invalid: check your entitlements
the apple pay view controller showed up and crashed in a BAD ACCESS error.
I really don't understand what happens. Can you help me with this bug ?
回答1:
Wow I found it, after a day of research. If you have a default Apple Pay shipping address (in Wallet entry, settings) with a non valid field (I don't know the rules for it), Apple Pay sheet won't pop up ... So be aware of that !
来源:https://stackoverflow.com/questions/35228985/pkpaymentauthorizationviewcontroller-not-nil-but-not-showing