mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-03 08:37:53 +08:00
Refactor GooglePay contect handlers to reuse action handlers.
This commit is contained in:
parent
318217acb9
commit
c6379ca980
8 changed files with 78 additions and 64 deletions
|
@ -1,14 +1,13 @@
|
|||
import ErrorHandler from "../../../../ppcp-button/resources/js/modules/ErrorHandler";
|
||||
import CartActionHandler
|
||||
from "../../../../ppcp-button/resources/js/modules/ActionHandler/CartActionHandler";
|
||||
import onApprove
|
||||
from "../../../../ppcp-button/resources/js/modules/OnApproveHandler/onApproveForContinue";
|
||||
|
||||
class BaseHandler {
|
||||
|
||||
constructor(buttonConfig, ppcpConfig) {
|
||||
constructor(buttonConfig, ppcpConfig, externalHandler) {
|
||||
this.buttonConfig = buttonConfig;
|
||||
this.ppcpConfig = ppcpConfig;
|
||||
this.externalHandler = externalHandler;
|
||||
}
|
||||
|
||||
transactionInfo() {
|
||||
|
@ -42,30 +41,25 @@ class BaseHandler {
|
|||
}
|
||||
|
||||
createOrder() {
|
||||
const errorHandler = new ErrorHandler(
|
||||
this.ppcpConfig.labels.error.generic,
|
||||
document.querySelector('.woocommerce-notices-wrapper')
|
||||
);
|
||||
|
||||
const actionHandler = new CartActionHandler(
|
||||
this.ppcpConfig,
|
||||
errorHandler,
|
||||
);
|
||||
|
||||
return actionHandler.configuration().createOrder(null, null);
|
||||
return this.actionHandler().configuration().createOrder(null, null);
|
||||
}
|
||||
|
||||
approveOrderForContinue(data, actions) {
|
||||
const errorHandler = new ErrorHandler(
|
||||
approveOrder(data, actions) {
|
||||
return this.actionHandler().configuration().onApprove(data, actions);
|
||||
}
|
||||
|
||||
actionHandler() {
|
||||
return new CartActionHandler(
|
||||
this.ppcpConfig,
|
||||
this.errorHandler(),
|
||||
);
|
||||
}
|
||||
|
||||
errorHandler() {
|
||||
return new ErrorHandler(
|
||||
this.ppcpConfig.labels.error.generic,
|
||||
document.querySelector('.woocommerce-notices-wrapper')
|
||||
);
|
||||
|
||||
let onApproveHandler = onApprove({
|
||||
config: this.ppcpConfig
|
||||
}, errorHandler);
|
||||
|
||||
return onApproveHandler(data, actions);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue