Hi, My name is Andy Leverenz and I work as a Product Designer at Dribbble. For fun I design, code, and write. Check out my blog called Web-Crunch https://web-crunch.com where I publish design and development tutorials with the occasional vlog.
▶️ You are watching: PART 3 of 6
Download the source code:
Welcome to my eleventh Let’s Build series featuring Ruby on Rails. This installment, once again, focuses on accepting payments using Ruby on Rails as a web application framework. We partner Ruby on Rails with Stripe to create a subscription based SaaS model for a book library application.
What’s new in this build?
* Rails 5.2 makes an appearance
* We use ActiveStorage which comes new with Rails 5.2. No longer do we require third-party gems like PaperClip or Carrierwave.
* New encrypted secrets which make managing any environment variables or keys way easier. You can commit these to version control without fear thanks to the encrypted quality
* Stripe Billing – Stripe recently released a new model around their subscription products. Within Stripe Billing you can define overlying products which have associated plans. It’s a nicer way to bundle whatever it is you sell but still be able to sell things in different manners i.e. Flat rates, Multiple Plans, Per seat, Usage-based, and Flat rate + overage.
The Book Library application
The application is a simple book application that allows a user to add and remove books from their library. These books can be downloaded for reading once a user is subscribed. Accessing a library is only possible if a user is subscribed. This app differs than previous apps where a user must pay before making an account.
A user is presented with buttons for adding a book to their library. As you can guess, to do this action a user first needs an account. Upon clicking the “add to library” button a public facing user (someone with no account) is redirected to a signup page of which we implement using the Devise gem.
A nice callback function from Devise allows us to redirect a user upon successfully signing up. In this case, we redirect a user to a pricing page which features three plans to choose from. Each plan has its own parameters associated with it. Upon clicking the “subscribe” button on any of the tiers, the user is redirected to a payment page carrying over the necessary parameters to hook into Stripe with.
What seems like a simple app carries some logic and weight to cover all our tracks. The application is far from complete but you can, however, extend this to be much more however you like.
I ran out of time but one obvious area to extend this app is to save what plan a user has subscribed to. This can be done at the time they create a subscription. From there you can query different places in your app to show and hide specific features based on their plan type.
??Help me keep going. Become a patreon or buy me a coffee:
? Previously published at:
? Check out the blog:
? ? Check out my agency:
? Check out my personal site:
Weekly Newsletter: https://web-crunch.com/subscribe
Twitter(Personal Account): https://twitter.com/justalever
?Check out my book on UX Design:
“LUXD: Learn User Experience Design”
? Check out my FREE book on Tumblr Theming:
“Pro Tumblr Theming”
? Need awesome web hosting? Check out cloudways. They allow me to use a variety of hosting providers and build apps with ease:
? Need more advanced hosting for Rails, PHP, Node, or other projects? Digital Ocean has you covered.