Skip to content

Apple Pay

The Apple:ApplePay provider renders an Apple Pay button using the W3C Payment Request API with an Apple Pay payment method.

Requirement: Apple Pay only works on pages served over HTTPS with a validated Apple Pay merchant domain. See Known Constraints — Apple Pay Requires HTTPS.

Options — ApplePayOptions

FieldTypeRequiredDefaultDescription
totalAmountnumberYesAmount in minor units (e.g. 19300 = €193.00)
currencyCodestringYesISO 4217 currency code
countryCodestringYesISO 3166-1 alpha-2 merchant country code
merchantIdentifierstringYesApple Pay merchant identifier from Apple Developer account
merchantDisplayNamestringYesDisplayed as the payment line item label in the sheet
validateMerchantUrlstringYesYour backend URL for Apple Pay merchant session validation
supportedNetworksstring[]No['amex','discover','masterCard','visa']Accepted card networks
billingAddressRequiredbooleanNofalseRequest billing address
shippingAddressRequiredbooleanNofalseRequest shipping address
requestPayerNamebooleanNotrueRequest payer's name
requestPayerEmailbooleanNotrueRequest payer's email
requestPayerPhonebooleanNotrueRequest payer's phone number

Merchant Validation

Your validateMerchantUrl endpoint receives a POST with { validationUrl: string } and must respond with an Apple Pay merchant session object. The SDK passes this to event.complete() on the Payment Request.

Style — ApplePayStyle

FieldTypeDescription
buttonstyle'black' | 'white' | 'white-outline'Button color theme
type'buy' | 'plain' | 'checkout'Label variant
localestringBCP 47 locale tag for button text (e.g. 'en-US', 'de-DE')

Example

html
<div id="applepay-container"></div>
js
import { ExpressButtons } from 'collana-pay-js';

const buttons = ExpressButtons({
  providers: [
    {
      providerProtocolType: 'Apple',
      paymentMethodType: 'ApplePay',
      container: '#applepay-container',
      style: {
        buttonstyle: 'black',
        type: 'buy',
        locale: 'en-US',
      },
      options: {
        totalAmount: 19300,       // €193.00
        currencyCode: 'EUR',
        countryCode: 'DE',
        merchantIdentifier: 'merchant.com.myshop',
        merchantDisplayName: 'My Shop',
        validateMerchantUrl: 'https://api.myshop.com/applepay/validate-merchant',
        supportedNetworks: ['masterCard', 'visa'],
        billingAddressRequired: true,
        requestPayerEmail: true,
      },
    },
  ],

  onClick: async (identity, paymentMethodData) => {
    const res = await fetch('/api/orders', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ provider: identity, paymentMethodData }),
    });
    const order = await res.json();
    return { orderId: order.id };
  },

  onApprove: (data) => {
    window.location.href = `/order/success?id=${data.orderId}`;
  },

  onCancel: (identity) => {
    console.log('Apple Pay cancelled', identity);
  },

  onError: (error) => {
    console.error('Apple Pay error', error);
  },
});

buttons.render();

CollanaPay SDK Documentation