Everything was working fine but suddenly without changing any code, I noticed that approved orders do not get captured automatically and I have to capture the payment manually using curl.
After some investigations...
I found out while using sandbox everything works as intended, I compared the response of live and sandbox modes and I found out that onApprove() actions parameter response in live mode is
{
order: {},
payment: null
}
While in sandbox mode is
{
order: {capture: ƒ, authorize: ƒ, patch: ƒ, get: ƒ}
payment: null
redirect: ƒ r()
restart: ƒ r()
}
So, actions.order.capture() does not exist in live mode, hence does not capture automatically and no onError exceptions were thrown.
My onApprove code
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
alert('Transaction approved by ' + details.payer.name.given_name);
});
},
How can I resolve this problem?