Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apple Pay will not display prefilled information

Tags:

ios

applepay

While trying to setup Apple Pay in an iOS app we've run into an issue with the API and pre-filling information. Our user flow allows the user to manually set their address, email and phone prior to paying with Apple Pay, so we want to be sure to fill the Apple Pay prompt with their inputs if they decide to do so.

According to the development guide, this should be as simple as setting these values in the request.shippingContact. However, when we do this, the values are ignored.

Is there something the documentation is not telling us?

PKContact *contact = [[PKContact alloc] init];  
contact.emailAddress = @"[email protected]";
contact.phoneNumber = [[CNPhoneNumber alloc] initWithStringValue:@"5555555"];

NSPersonNameComponents *name = [[NSPersonNameComponents alloc] init];
name.givenName = @"John";
name.familyName = @"Appleseed";
contact.name = name;

request.billingContact = contact;
request.shippingContact = contact;
request.requiredBillingAddressFields = PKAddressFieldAll;
request.requiredShippingAddressFields = PKAddressFieldEmail | PKAddressFieldPhone;

Apple Pay Sample

like image 228
Nathan Taylor Avatar asked Nov 25 '15 05:11

Nathan Taylor


People also ask

Why isn't my Apple Pay not showing up?

Contact your card issuer to see if they support Apple Pay. Update to the latest version of iOS or iPadOS, watchOS, or macOS. Make sure that you are in a supported country or region. Check that your device is compatible with Apple Pay.

Why is my Apple Pay suddenly not working?

Low Battery Mode can throw all your apps out of whack, including Apple Pay. If your battery is below 20 percent, and Apple Pay suddenly isn't working, the low battery could be the culprit. Charge your battery and try again.

How do I get Apple Pay to show up?

Apple Pay is simple to set up. Just add your credit or debit card to the Wallet app on your iPhone and you're ready to go. You still get all your card's rewards and benefits — so you won't miss out on any hard-earned points or miles. Apple Pay is already on your device.

Why is Apple Pay not working in Safari?

Go to your Safari menu bar, click Safari > Preferences then select the Privacy tab. Then make sure: Allow websites to check if Apple Pay is set up is selected. I confirm that the option is checked, both on my Mac and on my iPhone.


1 Answers

As mentioned in the documentation we need to validate the address values properly. We should pass valid address with valid postal code, see code below.

PKContact *contact = [[PKContact alloc] init];

NSPersonNameComponents *name = [[NSPersonNameComponents alloc] init];
name.givenName = @"John";
name.familyName = @"Appleseed";

contact.name = name;

CNMutablePostalAddress *address = [[CNMutablePostalAddress alloc] init];
address.street = @"1234 Laurel Street";
address.city = @"Atlanta";
address.state = @"GA";
address.postalCode = @"30303";

Also check:


NOTE

Address information can come from a wide range of sources in iOS. Always validate the information before you use it.

like image 191
Arun Ammannaya Avatar answered Oct 14 '22 07:10

Arun Ammannaya