Merge branch 'trunk' into PCP-2158-apple-pay-use-checkout-form-data-to-update-shipping-and-billing

# Conflicts:
#	modules/ppcp-applepay/resources/js/ApplepayButton.js
This commit is contained in:
Pedro Silva 2023-11-08 15:01:21 +00:00
commit 0e59051815
No known key found for this signature in database
GPG key ID: E2EE20C0669D24B3
20 changed files with 532 additions and 31 deletions

View file

@ -4,6 +4,7 @@ import CheckoutHandler from "./CheckoutHandler";
import CartBlockHandler from "./CartBlockHandler";
import CheckoutBlockHandler from "./CheckoutBlockHandler";
import MiniCartHandler from "./MiniCartHandler";
import PreviewHandler from "./PreviewHandler";
import PayNowHandler from "./PayNowHandler";
class ContextHandlerFactory {
@ -24,6 +25,8 @@ class ContextHandlerFactory {
return new CartBlockHandler(buttonConfig, ppcpConfig);
case 'checkout-block':
return new CheckoutBlockHandler(buttonConfig, ppcpConfig);
case 'preview':
return new PreviewHandler(buttonConfig, ppcpConfig);
}
}
}

View file

@ -0,0 +1,37 @@
import BaseHandler from "./BaseHandler";
class PreviewHandler extends BaseHandler {
constructor(buttonConfig, ppcpConfig, externalHandler) {
super(buttonConfig, ppcpConfig, externalHandler);
}
transactionInfo() {
// We need to return something as ApplePay button initialization expects valid data.
return {
countryCode: "US",
currencyCode: "USD",
totalPrice: "10.00",
totalPriceStatus: "FINAL"
}
}
createOrder() {
throw new Error('Create order fail. This is just a preview.');
}
approveOrder(data, actions) {
throw new Error('Approve order fail. This is just a preview.');
}
actionHandler() {
throw new Error('Action handler fail. This is just a preview.');
}
errorHandler() {
throw new Error('Error handler fail. This is just a preview.');
}
}
export default PreviewHandler;