mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
🚧 Adjust button-manager to new workflow
This commit is contained in:
parent
d5e406a563
commit
c2d5c8f3c5
1 changed files with 17 additions and 18 deletions
|
@ -11,7 +11,7 @@ class ApplePayManager {
|
|||
this.ApplePayConfig = null;
|
||||
this.buttons = [];
|
||||
|
||||
buttonModuleWatcher.watchContextBootstrap( ( bootstrap ) => {
|
||||
buttonModuleWatcher.watchContextBootstrap( async ( bootstrap ) => {
|
||||
this.contextHandler = ContextHandlerFactory.create(
|
||||
bootstrap.context,
|
||||
buttonConfig,
|
||||
|
@ -29,19 +29,26 @@ class ApplePayManager {
|
|||
|
||||
this.buttons.push( button );
|
||||
|
||||
if ( this.ApplePayConfig ) {
|
||||
button.init( this.ApplePayConfig );
|
||||
}
|
||||
// Ensure ApplePayConfig is loaded before proceeding.
|
||||
await this.init();
|
||||
|
||||
button.configure( this.ApplePayConfig );
|
||||
button.init();
|
||||
} );
|
||||
}
|
||||
|
||||
init() {
|
||||
( async () => {
|
||||
await this.config();
|
||||
for ( const button of this.buttons ) {
|
||||
button.init( this.ApplePayConfig );
|
||||
async init() {
|
||||
try {
|
||||
if ( ! this.ApplePayConfig ) {
|
||||
this.ApplePayConfig = await paypal.Applepay().config();
|
||||
|
||||
if ( ! this.ApplePayConfig ) {
|
||||
console.error( 'No ApplePayConfig received during init' );
|
||||
}
|
||||
}
|
||||
} )();
|
||||
} catch ( error ) {
|
||||
console.error( 'Error during initialization:', error );
|
||||
}
|
||||
}
|
||||
|
||||
reinit() {
|
||||
|
@ -49,14 +56,6 @@ class ApplePayManager {
|
|||
button.reinit();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Apple Pay configuration of the PayPal merchant.
|
||||
*/
|
||||
async config() {
|
||||
this.ApplePayConfig = await paypal.Applepay().config();
|
||||
return this.ApplePayConfig;
|
||||
}
|
||||
}
|
||||
|
||||
export default ApplePayManager;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue