Check the current method in block

This commit is contained in:
Alex P 2023-03-27 10:59:08 +03:00
parent 5261484f11
commit 21bba80f49
No known key found for this signature in database
GPG key ID: 54487A734A204D71

View file

@ -12,6 +12,7 @@ const PayPalComponent = ({
onError, onError,
eventRegistration, eventRegistration,
emitResponse, emitResponse,
activePaymentMethod,
}) => { }) => {
const {onPaymentSetup} = eventRegistration; const {onPaymentSetup} = eventRegistration;
const {responseTypes} = emitResponse; const {responseTypes} = emitResponse;
@ -110,6 +111,10 @@ const PayPalComponent = ({
}; };
useEffect(() => { useEffect(() => {
if (activePaymentMethod !== config.id) {
return;
}
const unsubscribeProcessing = onPaymentSetup(() => { const unsubscribeProcessing = onPaymentSetup(() => {
const shippingAddress = paypalOrderToWcShippingAddress(paypalOrder); const shippingAddress = paypalOrderToWcShippingAddress(paypalOrder);
let billingAddress = paypalPayerToWc(paypalOrder.payer); let billingAddress = paypalPayerToWc(paypalOrder.payer);
@ -132,7 +137,7 @@ const PayPalComponent = ({
return () => { return () => {
unsubscribeProcessing(); unsubscribeProcessing();
}; };
}, [onPaymentSetup, paypalOrder]); }, [onPaymentSetup, paypalOrder, activePaymentMethod]);
if (!loaded) { if (!loaded) {
return null; return null;