PKContact and Zip code for non US contries

403 Views Asked by At

I am implementing apple pay for Canada, to know the location of user i should have his/her postal code to estimate shipping price. I input

H4A2R4

as my postal code as shipping address for ApplePay. when I am trying to get info from PKContact it just return me

H4A

. how can i have it completely ? my sample code :

- (NSString *)postCodeForContact:(PKContact *)contact {
  return contact.postalAdress.postalCode;
}

I also tried ABPersonRef and i got same result.

2

There are 2 best solutions below

0
Ali On

I found that this change has been made by Apple. you only get the full postcode when users applies their thumbprint.

https://forums.developer.apple.com/thread/15217

0
The Windwaker On

Ali's answer is correct. You have all needed info in

- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller
                   didAuthorizePayment:(PKPayment *)payment
                            completion:(void (^)(PKPaymentAuthorizationStatus status))completion;

Just access it via payment.shippingContact.postalAdress.postalCode and if you want the user to know his shipping address is incorrect, then call completion(PKPaymentAuthorizationStatusInvalidShippingPostalAddress) in the same method.