Selected Shipping Method amount not updating to cart for card payment

Abhaysingh15022
New Community Member

Hi,

I am implementing the PayPal Checkout using the JavaScript SDK and have encountered an issue related to shipping method selection. Here are the details:

Code to Create Order:
actions.order.create({
payer: get_payer_data(values),
purchase_units: [{
amount: {
value: values.amount,
currency_code: values.currency_code,
item_total: {
currency_code: values.currency_code,
value: values.amount
}
},
description: values.so_reference,
reference_id: values.reference,
shipping: shipping_data,
}],
});
This code successfully creates an order and displays the shipping methods in the PayPal payment popup.

Observed Behavior:
Case 1: Paying with PayPal Account
When paying with a PayPal account, if I change the shipping method during the payment process, the total order amount updates correctly.

The new total reflects the sum of the item amount and the selected shipping amount.

Case 2: Paying with Card
When selecting the card payment option, the popup also shows the shipping methods passed during order creation.

However, if I change the shipping method in the popup, the total amount remains unchanged.

I verified that the onShippingChange callback function is triggered when changing the shipping method, but the total amount does not update.

Request for Assistance:
Why does the total amount update correctly when paying with a PayPal account but not when using the card payment option?

Is there a specific configuration or additional step required to ensure the total amount updates correctly when the shipping method is changed for card payments?

Any guidance or suggestions would be greatly appreciated. Thank you for your help!

Login to Me Too
1 REPLY 1

Abhaysingh15022
New Community Member

Also checked the approach of order patching on callback funtion onShippingChange 

here is code 

 let path = `/purchase_units/@reference_id='${self.reference}'/amount`; //checked the self.reference it is correct and same as order reference_id provided on order creation 
// Also Checked with path /purchase_units/0/amount
 
try {
let res = await actions.order.patch([{
op: "replace",
path: path,
value: {
currency_code: data.amount.currency_code,
value: (parseFloat(data.amount.value) + parseFloat(newShippingAmount)).toFixed(2),
}
}]);
Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.