I am integrating Apple Pay using PKPaymentAuthorizationViewController and its delegate methods. When user changes the Address the below delegate method gets triggered:
- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didSelectShippingContact:(PKContact *)contact completion:(void (^)(PKPaymentAuthorizationStatus status, NSArray<PKShippingMethod *> *shippingMethods, NSArray<PKPaymentSummaryItem *> *summaryItems))completion
When I try to access the Phone number from 'contact' it is always empty also the name (given name, family name, etc.) are also empty. But the selected shipping contact has all the information like name, phone number, postal address.
PKPaymentRequest *pkPaymentRequest = [[PKPaymentRequest alloc] init];
pkPaymentRequest.merchantIdentifier = merchantId;
pkPaymentRequest.supportedNetworks = @[PKPaymentNetworkAmex, PKPaymentNetworkMasterCard, PKPaymentNetworkVisa, PKPaymentNetworkDiscover];
pkPaymentRequest.merchantCapabilities = PKMerchantCapability3DS;
pkPaymentRequest.countryCode = @"US";
pkPaymentRequest.currencyCode = @"USD";
pkPaymentRequest.requiredShippingContactFields = [NSSet setWithArray:@[PKContactFieldPostalAddress, PKContactFieldName, PKContactFieldPhoneNumber]];
This is address I have been using for now:
Find the debugging info in below screenshots which shows the PKContact object 'contact' is missing the required information.
I have found solution, hope this may help out someone like me.
https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypayment/1916097-shippingcontact
Above link gave me hints that I can't get the complete address info in the delegate method 'didSelectShippingContact' instead it will be provided only after the payment is authorized by user using Touch ID, Face ID, or Passcode in the delegate method 'didAuthorizePayment'. Here we have an object of PKPayment (payment), this object consists all the Address/Contact Fields that I require to process further to complete the Payment Transaction.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With