A very simple but working example with the Stripe APIs. This app lets you charge any credit card any amount you want and have the funds deposited in your Stripe account. Not bad for less than 100 lines of code.
- A Stripe account. You can signup at http://stripe.com
- Sinatra
- The Stripe gem
-
Fork or download.
-
Get your API keys from the API Keys page on stripe.com.
-
Change the API key on line 5 of in app.rb:
Stripe.api_key = "STRIPE_API_PRIVATE_KEY"
-
Change the API key on line 7 of views/form.erb:
Stripe.setPublishableKey('PUBLISHABLE_KEY');
-
Run your app with
ruby app.rb
(orshotgun app.rb
if using shotgun), clickSubmit Payment
, and you should see your charge registered on the stripe dashboard.
By default this form will bill the stripe test credit card 4242424242424242
.
You can do all kind of cool stuff with these APIs. Check out the official docs.
- Check for the response code and report that to the user