I am trying to make a custom payment form for Stripe, and I want to make the AJAX call to Stripe manually. (instead of a submit event)
However, first off I am pretty sure I am posting it to the wrong place. But I can't figure out what URL I'm supposed to make this post request to.
If I am using the right url. I am getting a 405 not allowed
response. With no information on what is wrong with my request.
Here's what I got:
Stripe.setPublishableKey('pk_test_12345');
Stripe.card.createToken({
number: ccNum,
cvc: ccCVC,
exp_month: ccMonth,
exp_year: ccYear
}, stripeResponseHandler);
This part works fine, gives me a 200 OK status and I got a token back from the server.
function stripeResponseHandler(status, response) {
console.log('card status: ', status);
console.log('token: ', response.id);
$.ajax({
type: 'POST',
url: 'https://checkout.stripe.com/checkout.js',
headers: {
stripeToken: response.id
},
data: {
number: ccNum,
cvc: ccCVC,
exp_month: ccMonth,
exp_year: ccYear
},
success: (response) => {
console.log('successful payment: ', response);
},
error: (response) => {
console.log('error payment: ', response);
}
})
}
This however, gives me the 405 Not Allowed. It seems a bit weird to me that the endpoint would be a .js file. Which is why I am assuming I got the wrong URL.
Can anyone help me figure out how to make a manual post request for a Stripe payment?