Rails - Stripe::InvalidRequestError (Must provide source or customer.)
As mentioned in the docs, stripe expects either customer or source to be mentioned while creating a charge. So, you either need to
Create a customer on stripe(if you want to charge that customer in future too) from the token you received, and mention that customer while creating a charge,
customer = Stripe::Customer.create(source: params[:stripeToken]) charge = Stripe::Charge.create({ :amount => 400, :currency => "usd", :customer => customer.id, :description => "Charge for [email protected]" })
Or, if you don't want to create a customer, then directly mention received token as a source,
Stripe::Charge.create({ :amount => 400, :currency => "usd", :source => params[:stripeToken], :description => "Charge for [email protected]" })