mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Check the current method in block
This commit is contained in:
parent
5261484f11
commit
21bba80f49
1 changed files with 6 additions and 1 deletions
|
@ -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;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue