Encountering an error with the code below while attempting to create a Stripe charge using Stripe.js.
Below is my web.rb file:
require 'json'
require 'sinatra'
require 'sinatra/reloader'
require 'stripe'
get '/' do
erb :index
end
Stripe.api_key = "sk_test_EkZm6rgWtt3gndztGnlfm4Yy"
token = params[:stripeToken]
post '/your-charge-code' do
charge = Stripe::Charge.create(
:amount => 1000,
:currency => "eur",
:description => "Example charge",
:customer => token,
)
end
Additionally, here is the index.erb file containing the payment form and client-side Javascript:
<script type="text/javascript" src="https://js.stripe.com/v2/"></script>
<script type="text/javascript">
Stripe.setPublishableKey("pk_test_xnI3R1Zl3CbybIM3J83SNMr2");
</script>
<form action="/your-charge-code" method="POST" id="payment-form">
<span class="payment-errors"></span>
<div class="form-row">
<label>
<span>Card Number</span>
<input type="text" size="20" data-stripe="number">
</label>
</div>
(...)
<input type="submit" class="submit" value="Submit Payment">
</form>
(...)
Any suggestions on what might be causing this issue?