Payfast ITN integration with Express.js

Viewed 517

So I am utilising PayFast as my payment gateway for an Angular Project, I got everything to work up till the ITN callback, I am using my express Api to catch the callback and send to the DB but there is nothing being caught and PayFast is stating an invalid header error message.

1 Answers

So for anyone utilising Payfast I finally found a solution:

router.post('/payfast', function(req,res,err) {
  res.sendStatus(200);

  var payment = {
    payment_id: req.body.pf_payment_id,
    status: req.body.payment_status,
    orderName: req.body.item_name,
    gross: req.body.amount_gross,
    fee: req.body.amount_fee,
    net: req.body.amount_net,
    name: req.body.name_first,
    last_name: req.body.name_last,
    signature: req.body.signature
  };
...
});

Payfast won't send data until you send a 200 OK status first, only then will they send the appropriate details.

Related