Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PKPaymentRequest not enforcing phone requirement for billing address

Tags:

ios

applepay

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;
}
like image 755
aednichols Avatar asked Dec 10 '25 01:12

aednichols


1 Answers

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.

like image 62
lxt Avatar answered Dec 12 '25 14:12

lxt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!