mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-07 19:54:15 +08:00
🚧 Migrate eligibility check
This commit is contained in:
parent
74e806535e
commit
a4b3f2a079
1 changed files with 22 additions and 0 deletions
|
@ -232,6 +232,7 @@ class ApplePayButton extends PaymentButton {
|
||||||
}
|
}
|
||||||
|
|
||||||
super.init();
|
super.init();
|
||||||
|
this.checkEligibility();
|
||||||
|
|
||||||
const button = this.addButton();
|
const button = this.addButton();
|
||||||
|
|
||||||
|
@ -256,6 +257,27 @@ class ApplePayButton extends PaymentButton {
|
||||||
this.init();
|
this.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Re-check if the current session is eligible for Apple Pay.
|
||||||
|
*/
|
||||||
|
checkEligibility() {
|
||||||
|
if ( this.isPreview ) {
|
||||||
|
this.isEligible = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if ( ! window.ApplePaySession?.canMakePayments() ) {
|
||||||
|
this.isEligible = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.isEligible = !! this.#applePayConfig.isEligible;
|
||||||
|
} catch ( error ) {
|
||||||
|
this.isEligible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts an Apple Pay session, which means that the user interacted with the Apple Pay button.
|
* Starts an Apple Pay session, which means that the user interacted with the Apple Pay button.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue