mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-08 21:52:55 +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.ApplePayConfig = null;
|
||||||
this.buttons = [];
|
this.buttons = [];
|
||||||
|
|
||||||
buttonModuleWatcher.watchContextBootstrap( async ( bootstrap ) => {
|
this.onContextBootstrap = this.onContextBootstrap.bind( this );
|
||||||
this.contextHandler = ContextHandlerFactory.create(
|
buttonModuleWatcher.watchContextBootstrap( this.onContextBootstrap );
|
||||||
bootstrap.context,
|
}
|
||||||
buttonConfig,
|
|
||||||
ppcpConfig,
|
|
||||||
bootstrap.handler
|
|
||||||
);
|
|
||||||
|
|
||||||
const button = ApplePayButton.createButton(
|
async onContextBootstrap( bootstrap ) {
|
||||||
bootstrap.context,
|
this.contextHandler = ContextHandlerFactory.create(
|
||||||
bootstrap.handler,
|
bootstrap.context,
|
||||||
buttonConfig,
|
this.buttonConfig,
|
||||||
ppcpConfig,
|
this.ppcpConfig,
|
||||||
this.contextHandler
|
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.
|
this.buttons.push( button );
|
||||||
await this.init();
|
|
||||||
|
|
||||||
button.configure( this.ApplePayConfig );
|
// Ensure ApplePayConfig is loaded before proceeding.
|
||||||
button.init();
|
await this.init();
|
||||||
} );
|
|
||||||
|
button.configure( this.ApplePayConfig );
|
||||||
|
button.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
|
|
|
@ -11,33 +11,35 @@ class GooglepayManager {
|
||||||
this.googlePayConfig = null;
|
this.googlePayConfig = null;
|
||||||
this.transactionInfo = null;
|
this.transactionInfo = null;
|
||||||
this.contextHandler = null;
|
this.contextHandler = null;
|
||||||
|
|
||||||
this.buttons = [];
|
this.buttons = [];
|
||||||
|
|
||||||
buttonModuleWatcher.watchContextBootstrap( async ( bootstrap ) => {
|
this.onContextBootstrap = this.onContextBootstrap.bind( this );
|
||||||
this.contextHandler = ContextHandlerFactory.create(
|
buttonModuleWatcher.watchContextBootstrap( this.onContextBootstrap );
|
||||||
bootstrap.context,
|
}
|
||||||
buttonConfig,
|
|
||||||
ppcpConfig,
|
|
||||||
bootstrap.handler
|
|
||||||
);
|
|
||||||
|
|
||||||
const button = GooglepayButton.createButton(
|
async onContextBootstrap( bootstrap ) {
|
||||||
bootstrap.context,
|
this.contextHandler = ContextHandlerFactory.create(
|
||||||
bootstrap.handler,
|
bootstrap.context,
|
||||||
buttonConfig,
|
this.buttonConfig,
|
||||||
ppcpConfig,
|
this.ppcpConfig,
|
||||||
this.contextHandler
|
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.
|
this.buttons.push( button );
|
||||||
await this.init();
|
|
||||||
|
|
||||||
button.configure( this.googlePayConfig, this.transactionInfo );
|
// Ensure googlePayConfig and transactionInfo are loaded.
|
||||||
button.init();
|
await this.init();
|
||||||
} );
|
|
||||||
|
button.configure( this.googlePayConfig, this.transactionInfo );
|
||||||
|
button.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue