-
Notifications
You must be signed in to change notification settings - Fork 137
Description
WebKit's Payment Request implementation recently switched from the non-standard applepaypaymentmethodchanged
event to using PaymentDetailsModifier
s for handling payment instrument changes in Apple Pay. This allows merchants to add additional display items based on the type of card selected by the user.
Right now, Apple Pay supports the following card types: credit
, debit
, prepaid
, and store
. For the first three types, the only information WebKit provided in applepaypaymentmethodchanged
was the card type itself, so it's an easy migration to PaymentDetailsModifier
for these types, e.g.:
{
total: {
label: 'Total',
amount: {
currency: 'USD',
value: '10.00',
},
},
displayItems: [{
label: 'Item',
amount: {
currency: 'USD',
value: '10.00',
},
}],
modifiers: [{
supportedMethods: 'https://apple.com/apple-pay',
total: {
label: 'Total',
amount: {
currency: 'USD',
value: '15.00',
},
},
additionalDisplayItems: [{
label: 'Credit surcharge',
amount: {
currency: 'USD',
value: '5.00',
},
}],
data: {
paymentMethodType: 'credit',
},
}],
}
However, for store
cards (private-label credit cards), Apple Pay provided the merchant associated with the card with additional account information in applepaypaymentmethodchanged
so that they can apply discounts based on factors like "points", premium account status, etc. In the PaymentDetailsModifier
model, there is no clear way to do this, since the additional display items will differ from customer to customer.
While PaymentDetailsModifier
will work fine for most use cases involving credit, debit, and prepaid cards, it would be nice to also have a solution in Payment Request for private-label cards.
One solution would be to add a standard paymentinstrumentchange
event where payment methods can include arbitrary additional information, and use that as a replacement for applepaypaymentmethodchanged
and in addition to PaymentDetailsModifier
. I'd be interested to hear if there are other ideas, though.