Ensure shipping callback is removed from venmo button

This commit is contained in:
Emili Castells Guasch 2024-06-28 11:27:34 +02:00
parent 167c2c6883
commit a08ce87839

View file

@ -505,6 +505,30 @@ const PayPalComponent = ({
const PayPalButton = paypal.Buttons.driver("react", { React, ReactDOM }); const PayPalButton = paypal.Buttons.driver("react", { React, ReactDOM });
const getOnShippingOptionsChange = (fundingSource) => {
if(fundingSource === 'venmo') {
return null;
}
return (data, actions) => {
shouldHandleShippingInPayPal()
? handleShippingOptionsChange(data, actions)
: null;
};
}
const getOnShippingAddressChange = (fundingSource) => {
if(fundingSource === 'venmo') {
return null;
}
return (data, actions) => {
shouldHandleShippingInPayPal()
? handleShippingAddressChange(data, actions)
: null;
};
}
if(isPayPalSubscription(config.scriptData)) { if(isPayPalSubscription(config.scriptData)) {
return ( return (
<PayPalButton <PayPalButton
@ -515,16 +539,8 @@ const PayPalComponent = ({
onError={onClose} onError={onClose}
createSubscription={createSubscription} createSubscription={createSubscription}
onApprove={handleApproveSubscription} onApprove={handleApproveSubscription}
onShippingOptionsChange={(data, actions) => { onShippingOptionsChange={getOnShippingOptionsChange(fundingSource)}
shouldHandleShippingInPayPal() onShippingAddressChange={getOnShippingAddressChange(fundingSource)}
? handleSubscriptionShippingOptionsChange(data, actions)
: null;
}}
onShippingAddressChange={(data, actions) => {
shouldHandleShippingInPayPal()
? handleSubscriptionShippingAddressChange(data, actions)
: null;
}}
/> />
); );
} }
@ -538,16 +554,8 @@ const PayPalComponent = ({
onError={onClose} onError={onClose}
createOrder={createOrder} createOrder={createOrder}
onApprove={handleApprove} onApprove={handleApprove}
onShippingOptionsChange={(data, actions) => { onShippingOptionsChange={getOnShippingOptionsChange(fundingSource)}
shouldHandleShippingInPayPal() onShippingAddressChange={getOnShippingAddressChange(fundingSource)}
? handleShippingOptionsChange(data, actions)
: null;
}}
onShippingAddressChange={(data, actions) => {
shouldHandleShippingInPayPal()
? handleShippingAddressChange(data, actions)
: null;
}}
/> />
); );
} }