Stripe Sinatra Example
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.
What you'll need
- A Stripe account. You can signup at http://stripe.com
- 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:
Run your app with
shotgun app.rbif using shotgun), click
Submit Payment, and you should see your charge registered on the stripe dashboard.
By default this form will bill the stripe test credit card
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