I'm trying to create a one time, single charge in Stripe with Rails. I am getting the following error:
Stripe::InvalidRequestError (No such token: tok_18nnwSJ6tVEvTdcVs3dNIhGs)
However, as can clearly be seen in the photo, the token is in the parameters. That token is from Stripe.js.
Here is my code in my controller:
Stripe.api_key = "xxxxxxxxxxx"
customer = Stripe::Customer.create(source: params[:stripeToken])
charge = Stripe::Charge.create({
:amount => 10000,
:currency => "usd",
:customer => customer.id,
:description => "Example charge"
})
I have also tried:
Stripe.api_key = "xxxxxxxxxxx"
charge = Stripe::Charge.create({
:amount => 10000,
:currency => "usd",
:source => params[:stripeToken],
:description => "Example charge"
})
And that does not work either. All of this is simple, boilerplate code straight from the Stripe site, any idea what I could be doing wrong? I'm not having any trouble with the Stripe embedded form.