Recently, I built a feature in a Rails web application to take payments for an annual subscription service. There are many options for accepting credit card payments available. I was encouraged by a colleague to consider using Stripe.
A day later, I was happy I did. Able to accept payments in a PCI compliant way, the feature was quite a pleasure to build.
I found these resources particularly helpful:
A rundown of how it works.
- Use a basic html form and add
data-stripe=attributesfor Credit Card, Expiration Month and Year, and CVC number
- Use jQuery to handle the form submission instead of the browser's default form handling
- In the browser, use
Stripe.jsto generate a one-time use token from the 4 credit card fields (the library provides methods for it)
- Send the one-time use token from the browser to your Server. I used jQuery's
- From your Server, send the token to Stripe using
stripe-ruby.gem, and create either a
Customerobject will have an ID that you can store and re-bill at a later date