Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to access Phone no, First-Last Name, Street from PKContact inside PKPaymentAuthorizationViewController delegate method didSelectShippingContact

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: enter image description here

Find the debugging info in below screenshots which shows the PKContact object 'contact' is missing the required information.

enter image description here

enter image description here

enter image description here

like image 264
Suraj Mirajkar Avatar asked Jan 29 '20 13:01

Suraj Mirajkar


1 Answers

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.

enter image description here

like image 195
Suraj Mirajkar Avatar answered Oct 17 '22 12:10

Suraj Mirajkar