I am trying to post a JSON object to the payment gateway using Fetch API but it is giving server error. Can anyone tell me what is wrong with the code.
Payment Gateway docs - https://razorpay.com/docs/payment-gateway/web-integration/hosted/
topay is the JSON object
fetch( "https://api.razorpay.com/v1/checkout/embedded", {
"method": "post",
"headers": {
"Content-Type": "application/x-www-form-urlencoded"
},
"body": JSON.stringify(topay)
})
.then( (httpResponse) => {
if (httpResponse.ok) {
return httpResponse.json();
} else {
return Promise.reject("Fetch did not succeed");
}
})
.catch(err => console.log(err));
}