Contents

applePayCapabilities

Indicates whether the device supports Apple Pay and whether the person has an active card in Wallet that qualifies for web payments.

Declaration

static Promise < PaymentCredentialStatusResponse > applePayCapabilities(
	DOMString merchantIdentifier
);

Parameters

  • merchantIdentifier:

    The ID the merchant creates when they enroll in Apple Pay.

Mentioned in

Return Value

Returns the PaymentCredentialStatus object.

Discussion

This method asynchronously contacts the Apple Pay servers as part of the verification process. You can use this method to check for support on third-party browsers.

According to the Acceptable Use Guidelines for Apple Pay on the Web, if you invoke the applePayCapabilities method and determine that a person has an active card provisioned into Wallet, then Apple Pay should be the primary, but not necessarily sole, payment option on any webpage that accepts payments, like the checkout page or product detail page. In all other situations, use canMakePayments instead. For more information, see Checking for Apple Pay availability.

The following code demonstrates calling this method with each of the possible return values, to determine when to display an Apple Pay button.

// Check if the Apple Pay JS API is available.
  if (window.ApplePaySession) {
    var merchantIdentifier = 'YOUR MERCHANT IDENTIFIER';
    var promise = ApplePaySession.applePayCapabilities(merchantIdentifier);
    promise.then(function(capabilities) {
      // Check whether the person has an active payment credential provisioned in Wallet.
      switch (capabilities.paymentCredentialStatus) {
        case "paymentCredentialsAvailable":
          // Display an Apple Pay button and offer Apple Pay as the primary payment option. 
        case "paymentCredentialStatusUnknown":
          // Display an Apple Pay button and offer Apple Pay as a payment option.
        case "paymentCredentialsUnavailable":
          // Consider displaying an Apple Pay button.
        case "applePayUnsupported":
          // Don't show an Apple Pay button or offer Apple Pay.
      }
    })
  }

See Also

Apple Pay availability