Reputation: 2322
We are creating a PKPaymentRequest
and setting the requiredBillingAddressFields
property to PKAddressFieldPostalAddress | PKAddressFieldPhone
. The system enforces the address requirement but ignores the phone requirement. (Enforce in this case means, disallow the Apple Pay transaction from proceeding until the user has filled in the fields.)
Our app does not require a shipping address, but while debugging we set the requiredShippingAddressFields
property to PKAddressFieldPostalAddress | PKAddressFieldPhone
and found the phone number requirement is now enforced.
Nothing in the PKPaymentRequest
or PKAddressField
documentation suggests that this is expected behavior. Any ideas on how to work around this?
Edit - here's the full method:
+ (PKPaymentRequest *)newPayRequestFromBasket:(WFBasket *)basket
{
PKPaymentRequest *request = [PKPaymentRequest new];
request.supportedNetworks = [WFApplePayManager supportedPaymentNetworks];
request.countryCode = [WFAppTargetDispatcher currentAppTarget].storeConfig.countryCode;
request.currencyCode = [WFAppTargetDispatcher currentAppTarget].storeConfig.currencyCode;
request.merchantIdentifier = [WFAppTargetDispatcher currentAppTarget].storeConfig.merchantIdentifier;
request.merchantCapabilities = PKMerchantCapability3DS; // Support of 3DS is mandatory
int64_t orderId = basket.orderId;
request.applicationData = [NSData dataWithBytes:&orderId length:sizeof(orderId)];
request.paymentSummaryItems = [WFApplePayManager allSummaryItemsFromBasket:basket];
request.requiredBillingAddressFields = [WFApplePayManager requiredBillingFields]; // = PKAddressFieldPostalAddress | PKAddressFieldPhone
return request;
}
Upvotes: 3
Views: 1052
Reputation: 175
There's not much documentation for Swift if you need to require multiple shipping fields. Here's the code to do it.
Swift 3
var pkAddress = PKAddressField()
pkAddress.insert(.name)
pkAddress.insert(.email)
request.requiredShippingAddressFields = pkAddress
Upvotes: 0
Reputation: 31304
The API is a little confusing, but the billing address is just that - the billing address. It doesn't have a phone field. If you want to obtain a user's phone number you should use requiredShippingAddressFields
instead.
Upvotes: 4