TypeError: Failed to fetch
let paynow = new Paynow("xxx", "xxxxxxxxxxxxxx");
// Set return and result urls
paynow.resultUrl = "http://example.com/gateways/paynow/update";
paynow.returnUrl = "http://example.com/return?gateway=paynow";
// Create a new payment
let payment = paynow.createPayment("Invoice 35",'test@gmail.com');
// Add items to the payment list passing in the name of the item and it's price
payment.add("Bananas", 2.5);
payment.add("Apples", 3.4);
// Send off the payment to Paynow
paynow.sendMobile(
// The payment to send to Paynow
payment,
// The phone number making payment
'0775658123',
// The mobile money method to use.
'ecocash',
).then(function(response) {
if(response.success) {
// These are the instructions to show the user.
// Instruction for how the user can make payment
let instructions = response.instructions // Get Payment instructions for the selected mobile money method
// Get poll url for the transaction. This is the url used to check the status of the transaction.
// You might want to save this, we recommend you do it
let pollUrl = response.pollUrl;
console.log(instructions)
} else {
console.log(response.error)
}
}).catch(ex => {
// Ahhhhhhhhhhhhhhh
// *freak out*
console.log('Your application has broken an axle', ex.message)
});
}