Support place order button mode in block

This commit is contained in:
Alex P 2023-11-15 09:45:15 +02:00
parent c71e312f18
commit 33ed474ae1
No known key found for this signature in database
GPG key ID: 54487A734A204D71
3 changed files with 45 additions and 18 deletions

View file

@ -316,20 +316,35 @@ const PayPalComponent = ({
}
const features = ['products'];
let registerMethod = registerExpressPaymentMethod;
if (config.scriptData.continuation) {
features.push('ppcp_continuation');
registerMethod = registerPaymentMethod;
}
registerMethod({
name: config.id,
label: <div dangerouslySetInnerHTML={{__html: config.title}}/>,
content: <PayPalComponent isEditing={false}/>,
edit: <PayPalComponent isEditing={true}/>,
ariaLabel: config.title,
canMakePayment: () => config.enabled,
supports: {
features: features,
},
});
if (config.usePlaceOrder && !config.scriptData.continuation) {
registerPaymentMethod({
name: config.id,
label: <div dangerouslySetInnerHTML={{__html: config.title}}/>,
content: <div dangerouslySetInnerHTML={{__html: config.description}}/>,
edit: <div dangerouslySetInnerHTML={{__html: config.description}}/>,
ariaLabel: config.title,
canMakePayment: () => config.enabled,
supports: {
features: features,
},
});
} else {
let registerMethod = registerExpressPaymentMethod;
if (config.scriptData.continuation) {
features.push('ppcp_continuation');
registerMethod = registerPaymentMethod;
}
registerMethod({
name: config.id,
label: <div dangerouslySetInnerHTML={{__html: config.title}}/>,
content: <PayPalComponent isEditing={false}/>,
edit: <PayPalComponent isEditing={true}/>,
ariaLabel: config.title,
canMakePayment: () => config.enabled,
supports: {
features: features,
},
});
}