Monday 15 March 2021

PayPal Express shipping cost does not update on patch

When I patch the order Total is right, but Shipping is still holding old shipping price (4.50)

For example i've try to patch it with 24.60

enter image description here

This is my code for onShippingChange

onShippingChange: function (data, actions) {                    
    data.action = "changeShippingCost";
    return new Promise((resolve) => {
        $.ajax({
            url: window.location.protocol + "//" + window.location.hostname + '/paypalExpress/request',
            type: "POST",
            data: JSON.stringify(data),
            dataType: "json",
            headers: {
                'content-type': 'application/json'
            },
            success: function (data) {
                resolve(data);
            }
        });
    }).then(function (res) {
        if (res.accept) {
            shippingAmount = (res.shipping);
            baseOrderAmount = (res.value);
            itemsTotal = (res.itemsTotal);
            return actions.order.patch([
                {
                    op: 'replace',
                    path: '/purchase_units/@reference_id==\'default\'/amount',
                    value: {
                        currency_code: 'EUR',
                        value: (parseFloat(baseOrderAmount)).toFixed(2),
                        breakdown: {
                            item_total: {
                                currency_code: 'EUR',
                                value: (parseFloat(itemsTotal)).toFixed(2)
                            },
                            shipping: {
                                currency_code: 'EUR',
                                value: (parseFloat(shippingAmount)).toFixed(2)
                            }
                        }
                    }
                }
            ]);
        }
        return actions.reject();
    });
},

I've managed to create a minimal reproducible example without the server side here

UPDATE: After contacting PayPal Suport they send me

Thank you for contacting Merchant Technical Support.

Based on the information provided in the ticket, it is my understanding that you are inquiring about patching the shipping costs into your smart payment buttons. I worked with some of my peers on this and I have included the suggested code for what you are looking to accomplish here

and this attachment

So I need to change the tax_total to change a shipping or what ?



from PayPal Express shipping cost does not update on patch

No comments:

Post a Comment