Order capture not working

samebenezer
Contributor
Contributor

I've tried to follow the paypal documentation closely.

But for some reason my server integration isn't working 😢....

 

Could you help identify what i'm doing wrong?

Client side

 

 

onApprove: function(data) {
return fetch('/server-side-file-name', {
  headers: {
    'content-type': 'application/json'
  },
  body: JSON.stringify({
    orderID: data.orderID
  })
}).then(function(res) {
  return res.json();
}).then(function(details) {
  alert('Transaction funds captured from ' + details.payer_given_name);
})
}

 

 

 ON the SERVER SIDE

 

 

if (!count(debug_backtrace()))
{
  $json = file_get_contents('php://input');
$data = json_decode($json);
$orderid = $data->orderID;
  CaptureOrder::captureOrder($orderid, true);
}

 

 

Login to Me Too
0 REPLIES 0

Haven't Found your Answer?

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