Show
Destroy
An entry
Get it down. Make it good. Share it.
Title
Text
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: * https://stripe.com/docs/tutorials/charges * https://github.com/stripe/stripe-ruby * https://www.masteringmodernpayments.com/blog/life-of-a-stripe-charge ### A rundown of how it works. * Use a basic html form and add `data-stripe=attributes` for 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.js` to 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 `$.ajax` function * From your Server, send the token to Stripe using `stripe-ruby` .gem, and create either a `Customer` or a `Charge` * A `Customer` object will have an ID that you can store and re-bill at a later date
Status
idea
draft
release
personal
Series
Part of a Series?
Bitcoin
On Work
Phoenix Trello Tutorial
Civics
Re Email Address
Tags
api
×
payments
×
ruby
×
javascript
×
+
Slug
Url
Image 1
Image 2
Image 3
Visible
Date