I am trying to generate order id using order's api in razorpay.
My code:-
This code is in script of head:-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
The below code is in the script of the body
var jsonData = {
"currency": "INR",
"amount": "10000",
};
$.ajax({
type: 'POST',
dataType: 'jsonp',
url: url,
data: { json: JSON.stringify(jsonData) },
xhrFields: {
withCredentials: true
},
beforeSend: function (xhr) {
xhr.setRequestHeader("Authorization", "Basic " + btoa(username + ":" + password));
},
contentType: "application/json; charset=utf-8",
success: function (response) {
alert("done");
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
jsonValue = jQuery.parseJSON(xhr.responseText);
console.log(xhr.Message);
},
});
The above code continuously shows me alert box with status code as 0.