Indicates whether the device supports Apple Pay and whether the user has an active card in Wallet.
SDKs
- Safari Desktop 10.0+
- Safari Mobile 10.0+
Framework
- Apple Pay JS
Declaration
static Promise <boolean> canMakePaymentsWithActiveCard(DOMString merchantIdentifier);
Parameters
merchantIdentifier
The merchant ID created when the merchant enrolled in Apple Pay.
Return Value
true
if the device supports Apple Pay and there is at least one active card in Wallet that is qualified for payments on the web; otherwise, false
.
Discussion
This method asynchronously contacts the Apple Pay servers as part of the verification process.
Per the Apple Pay on the Web Acceptable Use Guidelines, if you invoke the can
API and determine that a user has an active card provisioned into Wallet, then Apple Pay must automatically be set as the default or sole payment option on any webpage where payments are accepted, such as the checkout page or product detail page. In all other situations, use can
instead.
Note that some cards, such as transit cards, are only enabled for POS payments and therefore will not qualify for payments on the web.
Listing 1 is an example of calling this method before displaying an Apple Pay button.
Determining whether to display an Apple Pay button
if (window.ApplePaySession) {
var merchantIdentifier = 'example.com.store';
var promise = ApplePaySession.canMakePaymentsWithActiveCard(merchantIdentifier);
promise.then(function (canMakePayments) {
if (canMakePayments)
// Display Apple Pay Buttons here…
}); }