Structure

ApplePayModifier

A dictionary that defines a payment modifier for a specific payment type.

Overview

In the Payment Request API, modifiers contain transaction details that apply only when certain conditions are met. For example, a modifier could be a surcharge for paying with a credit card. The transaction includes the modifier's details, and the payment sheet displays the surcharge, only if the user pays with a credit card.

With Apple Pay, use ApplePayModifier to define display items based on a user's choice of payment method type: credit, debit, prepaid, or store. When the user selects their payment method, the transaction invokes the modifier corresponding to the payment method, and displays the information in the payment sheet.

The following example shows a modifier that applies a surcharge when the customer uses a credit card. The modifier's additionalDisplayItem applies only if the user's chooses to use a credit card and is using Apple Pay.

const modifiers = [
            {
                supportedMethods: "https://apple.com/apple-pay",
                total: {
                    label: "Total",
                    amount: {
                        currency: "USD",
                        value: "110.08",
                    },
                },
                additionalDisplayItems: [
                    {
                        label: "Credit surcharge",
                        amount: {
                            currency: "USD",
                            value: "2.00",
                        },
                    },
                ],
                data: {
                    paymentMethodType: "credit",
                },
            },
        ];

        const details = {
            total,
            displayItems,
            shippingOptions,
            modifiers,
        };

Notice that the modifier also contains a total, which overwrites the payment request's total when applying the modifier. The payment sheet itself does not perform any calculations. You are responsible for supplying all values, including calculating new totals within modifiers.The payment sheets displays the values you provide.

Topics

Payment Method Type

paymentMethodType

The type of card used by the customer for completing the transaction.

See Also

Payment Request

ApplePayRequest

A request for payment, including merchant-specific details and requirements.