Patch Order from Express button

Mittelwind
Contributor
Contributor

Hello,

 

I stuck with a problem I can not resolve by my own.

On address change I fetch a method server side which updates order items for the payment. This works, because I get the change on every second request (if i change back the address I get the result from the server side patch)

Because the popup window seems to not know, that the payment is already patched serverside, I trying to force a patch client side (intent)

 

onShippingChange: function(data, actions) {
                fetch('/paypal/recalculate', {
            		method: 'post',
            		headers: {
                		'content-type': 'application/json'
            		},
            		body:    JSON.stringify(data)
                }).then(response=>response.text()).then(
                        data=>{
                            return actions.order.patch([
                                    {'op': 'replace',
                                     'path': 'intent',
                                     'value': 'sale'}
                                     ]);
                            //console.log(data);
                    });
            },

This results in

​stack: "Payment could not be patched, error occured in API call.

with a traceback which says nothing

 

Any help welcome!

Login to Me Too
1 REPLY 1

Mittelwind
Contributor
Contributor

Simple Solution: you must return the fetch if you are not returning action.resolve() or action.reject()

 

return fetch(....
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.