canMakePayments vs. ApplePaySession

Hello, guys! As far as I understood, there is no difference between ApplePaySession.canMakePayments and window.ApplePaySession checking, right? So we can just check window object on ApplePaySession storing without using of canMakePayments method. Is that true or I just missed something?

Answered by NorfolkMustard in 159568022

Should probably start with window.ApplePaySession, to avoid js errors for those not on apple, then follow with check for valid payment card


e.g.


if (window.ApplePaySession) {
    var merchantIdentifier = 'merchant.com.blah.shop';
    var promise = ApplePaySession.canMakePaymentsWithActiveCard(merchantIdentifier);
    promise.then(function (canMakePayments) {
   if (canMakePayments) {
      $("#applePay").show();
  console.log('hi, I can do ApplePay');
   } else { 
      $("#orderform").after('<p>ApplePay is possible on this browser, but not currently activated.</p>');
  console.log('ApplePay is possible on this browser, but not currently activated.');
   }
  });
  } else {
  console.log('ApplePay not available on this browser');
  $("#orderform").after('<p>ApplePay not available on this browser</p>');
  }
Accepted Answer

Should probably start with window.ApplePaySession, to avoid js errors for those not on apple, then follow with check for valid payment card


e.g.


if (window.ApplePaySession) {
    var merchantIdentifier = 'merchant.com.blah.shop';
    var promise = ApplePaySession.canMakePaymentsWithActiveCard(merchantIdentifier);
    promise.then(function (canMakePayments) {
   if (canMakePayments) {
      $("#applePay").show();
  console.log('hi, I can do ApplePay');
   } else { 
      $("#orderform").after('<p>ApplePay is possible on this browser, but not currently activated.</p>');
  console.log('ApplePay is possible on this browser, but not currently activated.');
   }
  });
  } else {
  console.log('ApplePay not available on this browser');
  $("#orderform").after('<p>ApplePay not available on this browser</p>');
  }
canMakePayments vs. ApplePaySession
 
 
Q