mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
♻️ Further streamline button-manager classes
This commit is contained in:
parent
060dedaae9
commit
0a212edb89
2 changed files with 46 additions and 41 deletions
|
@ -11,30 +11,33 @@ class ApplePayManager {
|
|||
this.ApplePayConfig = null;
|
||||
this.buttons = [];
|
||||
|
||||
buttonModuleWatcher.watchContextBootstrap( async ( bootstrap ) => {
|
||||
this.contextHandler = ContextHandlerFactory.create(
|
||||
bootstrap.context,
|
||||
buttonConfig,
|
||||
ppcpConfig,
|
||||
bootstrap.handler
|
||||
);
|
||||
this.onContextBootstrap = this.onContextBootstrap.bind( this );
|
||||
buttonModuleWatcher.watchContextBootstrap( this.onContextBootstrap );
|
||||
}
|
||||
|
||||
const button = ApplePayButton.createButton(
|
||||
bootstrap.context,
|
||||
bootstrap.handler,
|
||||
buttonConfig,
|
||||
ppcpConfig,
|
||||
this.contextHandler
|
||||
);
|
||||
async onContextBootstrap( bootstrap ) {
|
||||
this.contextHandler = ContextHandlerFactory.create(
|
||||
bootstrap.context,
|
||||
this.buttonConfig,
|
||||
this.ppcpConfig,
|
||||
bootstrap.handler
|
||||
);
|
||||
|
||||
this.buttons.push( button );
|
||||
const button = ApplePayButton.createButton(
|
||||
bootstrap.context,
|
||||
bootstrap.handler,
|
||||
this.buttonConfig,
|
||||
this.ppcpConfig,
|
||||
this.contextHandler
|
||||
);
|
||||
|
||||
// Ensure ApplePayConfig is loaded before proceeding.
|
||||
await this.init();
|
||||
this.buttons.push( button );
|
||||
|
||||
button.configure( this.ApplePayConfig );
|
||||
button.init();
|
||||
} );
|
||||
// Ensure ApplePayConfig is loaded before proceeding.
|
||||
await this.init();
|
||||
|
||||
button.configure( this.ApplePayConfig );
|
||||
button.init();
|
||||
}
|
||||
|
||||
async init() {
|
||||
|
|
|
@ -11,33 +11,35 @@ class GooglepayManager {
|
|||
this.googlePayConfig = null;
|
||||
this.transactionInfo = null;
|
||||
this.contextHandler = null;
|
||||
|
||||
this.buttons = [];
|
||||
|
||||
buttonModuleWatcher.watchContextBootstrap( async ( bootstrap ) => {
|
||||
this.contextHandler = ContextHandlerFactory.create(
|
||||
bootstrap.context,
|
||||
buttonConfig,
|
||||
ppcpConfig,
|
||||
bootstrap.handler
|
||||
);
|
||||
this.onContextBootstrap = this.onContextBootstrap.bind( this );
|
||||
buttonModuleWatcher.watchContextBootstrap( this.onContextBootstrap );
|
||||
}
|
||||
|
||||
const button = GooglepayButton.createButton(
|
||||
bootstrap.context,
|
||||
bootstrap.handler,
|
||||
buttonConfig,
|
||||
ppcpConfig,
|
||||
this.contextHandler
|
||||
);
|
||||
async onContextBootstrap( bootstrap ) {
|
||||
this.contextHandler = ContextHandlerFactory.create(
|
||||
bootstrap.context,
|
||||
this.buttonConfig,
|
||||
this.ppcpConfig,
|
||||
bootstrap.handler
|
||||
);
|
||||
|
||||
this.buttons.push( button );
|
||||
const button = GooglepayButton.createButton(
|
||||
bootstrap.context,
|
||||
bootstrap.handler,
|
||||
this.buttonConfig,
|
||||
this.ppcpConfig,
|
||||
this.contextHandler
|
||||
);
|
||||
|
||||
// Ensure googlePayConfig and transactionInfo are loaded.
|
||||
await this.init();
|
||||
this.buttons.push( button );
|
||||
|
||||
button.configure( this.googlePayConfig, this.transactionInfo );
|
||||
button.init();
|
||||
} );
|
||||
// Ensure googlePayConfig and transactionInfo are loaded.
|
||||
await this.init();
|
||||
|
||||
button.configure( this.googlePayConfig, this.transactionInfo );
|
||||
button.init();
|
||||
}
|
||||
|
||||
async init() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue