♻️ More reliable eligibility-check

Eligibility better aligns with the ApplePay SDK logic and will not insert a hidden button anymore.
This commit is contained in:
Philipp Stracker 2024-07-26 17:28:30 +02:00
parent 09308f15b6
commit c15715a02f
No known key found for this signature in database

View file

@ -163,11 +163,26 @@ class ApplePayButton {
return true;
}
if ( this.buttonConfig.is_admin ) {
if ( CONTEXT.Preview === this.context ) {
return true;
}
return !! ( this.applePayConfig.isEligible && window.ApplePaySession );
/**
* Ensure the ApplePaySession is available and accepts payments
* This check is required when using Apple Pay SDK v1; canMakePayments() returns false
* if the current device is not liked to iCloud or the Apple Wallet is not available
* for a different reason.
*/
try {
if ( ! window.ApplePaySession?.canMakePayments() ) {
return false;
}
} catch ( error ) {
console.warn( error );
return false;
}
return !! this.applePayConfig.isEligible;
}
/**