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