mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
Add final review for blocks
This commit is contained in:
parent
b444c1ef55
commit
211c57b938
4 changed files with 35 additions and 29 deletions
|
@ -92,9 +92,23 @@ const PayPalComponent = ({
|
|||
throw new Error(config.scriptData.labels.error.generic)
|
||||
}
|
||||
|
||||
setPaypalOrder(json.data);
|
||||
const order = json.data;
|
||||
|
||||
onSubmit();
|
||||
setPaypalOrder(order);
|
||||
|
||||
const shippingAddress = paypalOrderToWcShippingAddress(order);
|
||||
let billingAddress = paypalPayerToWc(order.payer);
|
||||
// no billing address, such as if billing address retrieval is not allowed in the merchant account
|
||||
if (!billingAddress.address_line_1) {
|
||||
billingAddress = {...shippingAddress, ...paypalPayerToWc(order.payer)};
|
||||
}
|
||||
|
||||
await wp.data.dispatch('wc/store/cart').updateCustomerData({
|
||||
billing_address: billingAddress,
|
||||
shipping_address: shippingAddress,
|
||||
});
|
||||
|
||||
location.href = config.scriptData.redirect;
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
|
||||
|
@ -126,24 +140,6 @@ const PayPalComponent = ({
|
|||
},
|
||||
};
|
||||
}
|
||||
|
||||
const shippingAddress = paypalOrderToWcShippingAddress(paypalOrder);
|
||||
let billingAddress = paypalPayerToWc(paypalOrder.payer);
|
||||
// no billing address, such as if billing address retrieval is not allowed in the merchant account
|
||||
if (!billingAddress.address_line_1) {
|
||||
billingAddress = {...shippingAddress, ...paypalPayerToWc(paypalOrder.payer)};
|
||||
}
|
||||
|
||||
return {
|
||||
type: responseTypes.SUCCESS,
|
||||
meta: {
|
||||
paymentMethodData: {
|
||||
'paypal_order_id': paypalOrder.id,
|
||||
},
|
||||
shippingAddress,
|
||||
billingAddress,
|
||||
},
|
||||
};
|
||||
});
|
||||
return () => {
|
||||
unsubscribeProcessing();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue