canMakePaymentsWithActiveCard
Indicates whether the device supports Apple Pay and whether the user has an active card in Wallet.
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 canMakePaymentsWithActiveCard 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 canMakePayments instead.
Note that some cards, such as transit cards, are only enabled for POS payments and therefore won’t qualify for payments on the web.
The following code 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…
}); }