Skip to content

Instantly share code, notes, and snippets.

@dannysofftie
Created August 20, 2021 15:47
Show Gist options
  • Save dannysofftie/fecb498fa199bbff606a4ff90917a8df to your computer and use it in GitHub Desktop.
Save dannysofftie/fecb498fa199bbff606a4ff90917a8df to your computer and use it in GitHub Desktop.
let unirest = require('unirest');
let req = unirest('POST', 'https://sandbox.safaricom.co.ke/mpesa/b2c/v1/paymentrequest')
.headers({
'Content-Type': 'application/json',
'Authorization': 'Bearer ojS0BpE4PVvOIQeqftIaCJg6sRrp'
})
.send(JSON.stringify({
"InitiatorName": "testapi",
"SecurityCredential": "hXqyG2If6W9+IU4/stlOT97+9MI8cNbl8VY1Fj1RlSr+tPvUMtCUnWkuQUAgISE02n+7HlDJiYLs1GzAcN7erax/RTqrjA5PThSGP7OY0TzN4zB1cwd+eQ4gf/Y1SPK4ekfsl7Ox7MXYQw1h/ULiIMEZNRKCAIklj3YhcgnzKX9FsKL0XWZ00MZSChP8a4w2ARwZN5L8nz7vSP5yD4ZWt2/RCSIPVAdlEFOYHUVC5fkU8+I+8KCOfqw+PCHsLLag/evP/Ptqpjicbp5q2sj9tdCIqyy9ZwovTLb/BEqP2MWP9iBUg1FpfRPlOrB5sGrZJGmEPpRUw8HT6PhB8husRw==",
"CommandID": "BusinessPayment",
"Amount": 5,
"PartyA": 600978,
"PartyB": 254708374149,
"Remarks": "Test remarks",
"QueueTimeOutURL": "https://mydomain.com/b2c/queue",
"ResultURL": "https://mydomain.com/b2c/result",
"Occassion": "",
}))
.end(res => {
if (res.error) throw new Error(res.error);
console.log(res.raw_body);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment