Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
R

rails-stripe-checkout

> 编程语言
Open source

Rails 5.0 starter app for selling a product using Stripe Checkout

99 stars0 likes3 views
WebsiteGitHub

About

Rails 5.0 starter app for selling a product using Stripe Checkout

h1. !http://railsapps.github.io/images/rails-36x36.jpg(Rails Stripe Checkout)! Rails Stripe Checkout

Rails 5.0 example application demonstrates how to sell a product using "Stripe Checkout":https://stripe.com/checkout. Use this example application as a starter app for your own web applications.

See the tutorial for a complete explanation of the code:

  • "Stripe Checkout Tutorial":https://tutorials.railsapps.org/rails-stripe-checkout

The application uses:

  • "Stripe":https://stripe.com/ for credit card payment processing
  • "Devise":https://github.com/plataformatec/devise for user management and authentication
  • "Role-Based Authorization":http://railsapps.github.io/rails-devise-roles for administrator access
  • "Bootstrap":http://getbootstrap.com/ front-end framework

Other tutorials may be helpful:

  • "Signup and Download":https://tutorials.railsapps.org/rails-signup-download
  • "Role-Based Authorization":http://railsapps.github.io/rails-devise-roles
  • "Devise Tutorial":http://railsapps.github.io/rails-devise/
  • "RSpec Tutorial":http://railsapps.github.io/rspec.html

You can build this application in only a few minutes using the "Rails Composer":http://railsapps.github.io/rails-composer/ tool.

h4. !http://railsapps.github.io/images/join/join-railsapps.png(Join RailsApps)!:http://railsapps.github.io/

h4. From the RailsApps Project

The "RailsApps":http://railsapps.github.io/ open source project offers starter applications and tutorials for Rails developers. Generate the applications with the Rails Composer tool.

All the code is explained in the Capstone Rails Tutorials. You can purchase the "Capstone Rails Tutorials":https://tutorials.railsapps.org/ to support the project.

h4. If You Are New to Rails

If you're new to Rails, see "What is Ruby on Rails?":http://railsapps.github.io/what-is-ruby-rails.html, the book "Learn Ruby on Rails":http://learn-rails.com/learn-ruby-on-rails.html, and recommendations for a "Rails tutorial":https://tutorials.railsapps.org/rails-tutorial.

h2. What Is Implemented -- and What Is Not

This application is based on the "rails-devise-roles":https://github.com/RailsApps/rails-devise-roles and "rails-signup-download":https://github.com/RailsApps/rails-signup-download example applications. The rails-devise-roles application shows how to implement "sign up" and "sign in" features (authentication) combined with authorization for roles such as an administrator. The rails-signup-download example application shows how a visitor can download a PDF file after registering for an account.

The rails-stripe-checkout application implements a payment feature using Stripe Checkout so a visitor makes a payment to obtain an example PDF file. Devise provides account registration, so that a visitor creates an account when he or she makes a purchase. This means the visitor can return to the site, and after signing in with an email address and password, can download the PDF file again to get an update or replace a deleted file. This functionality is similar to sites such as "Gumroad":https://gumroad.com/ or "Leanpub":https://leanpub.com/ where authors sell digital books.

"Stripe Checkout":https://stripe.com/checkout provides compliance with "Payment Card Industry Data Security Standards":https://www.pcisecuritystandards.org/ (PCI-DSS). Stripe Checkout is a JavaScript script that generates a "Pay with Card" button and form. The script submits the visitor's credit card data to Stripe and obtains an authorization token. Your application uses the authorization token to initiate a payment so the visitor's credit card data is never stored or exposed by your application.

Most examples of Stripe Checkout show how to make one-time purchases with no account registration feature. In contrast, the rails-stripe-checkout application shows how to integrate Stripe Checkout with Devise for account registration. The application provides a two-step "sign up and purchase" process that initiates a payment and creates a user account.

For a one-step process, you can use the "Stripe.js":https://stripe.com/docs/stripe.js script instead of Stripe Checkout, creating a custom form. Stripe Checkout is simpler. Stripe.js provides more flexibility. This application does not show how to use Stripe.js.

The rails-stripe-checkout example application does not show how to offer multiple products for sale (though you can customize the application if you wish). It also does not support subscription sales or recurring billing (again, you can customize the application if you wish).

The rails-stripe-checkout application has all the functionality of the rails-signup-download example application, including the ability to subscribe a user to a MailChimp mailing list at the time an account is created. The mailing list subscription feature runs as a background process using "Active Job":https://github.com/rails/rails/tree/master/activejob. You can learn more about the subscription feature by reading the "Mailing List with Active Job":https://tutorials.railsapps.org/rails-mailinglist-activejob tutorial.

h4. Database

The application requires a database. The example application uses SQLite with Rails ActiveRecord. You can easily substitute PostgreSQL, MySQL, or other databases.

h4. Front-end Framework

The example application integrates Bootstrap for a navigation bar and flash messages. The forms are set up to use Bootstrap. You can customize the application to use other front-end frameworks such as Zurb Foundation.

h2. Similar Examples and Tutorials

This is one in a series of Rails example apps and tutorials from the "RailsApps Project":http://railsapps.github.io/. See a list of additional "Rails examples, tutorials, and starter apps":http://railsapps.github.io/rails-examples-tutorials.html. Related example applications may be useful:

  • "Learn Rails":https://github.com/RailsApps/learn-rails companion to the book "Learn Ruby on Rails":http://learn-rails.com/learn-ruby-on-rails.html
  • "Foundation and Rails":http://railsapps.github.io/rails-foundation/ shows how to integrate Foundation
  • "Bootstrap and Rails":http://railsapps.github.io/rails-bootstrap/ shows to integrate Bootstrap
  • "Mailing Lists with Active Job":https://tutorials.railsapps.org/rails-mailinglist-activejob for MailChimp subscriptions
  • "OmniAuth and Rails":https://github.com/RailsApps/rails-omniauth uses OmniAuth for authentication
  • "Devise and Rails":https://github.com/RailsApps/rails-devise uses Devise for authentication
  • "Role-Based Authorization":http://railsapps.github.io/rails-devise-roles using simple roles
  • "Pundit and Rails":https://github.com/RailsApps/rails-devise-pundit uses Pundit for authorization
  • "Signup and Download":https://tutorials.railsapps.org/rails-signup-download combines authentication with authorization and a PDF download

h2. Accounts You Will Need

Get the accounts you will need before deploying the application.

h3. Email

Devise provides a "Forgot Password?" feature that resets a password and sends instructions to the user. You'll need an email service provider to send email from the application. You can use "Gmail":https://accounts.google.com/SignUp?service=mail during development. You can get a free "Gmail":https://accounts.google.com/SignUp?service=mail account if you don't already have one. For production, Gmail is not robust. Use transactional email services, such as "Mandrill":http://mandrill.com/, to send email in production. See the article "Send Email with Rails":http://railsapps.github.io/rails-send-email.html for more information.

h3. Stripe

A "Stripe":https://stripe.com/ account is required. Before you start, go to the "Stripe website":https://stripe.com/ and set up an account. You don’t need a credit card merchant account or payment gateway. There’s no approval process to delay getting started.

h3. Merchant Account

Your business will need a merchant account in order to accept credit card payments. If you already have a merchant account, you can use it with Stripe. Stripe provides a merchant account as part of its service, so you don't need to obtain one.

h3. MailChimp

A "MailChimp":http://mailchimp.com account is optional. The application User model includes a method to subscribe a new user to a MailChimp mailing list when an account is created. If you choose to use this feature, you'll need a MailChimp account.

When visitors submit an email address, the application will add them to a MailChimp list. To access MailChimp, we’ll need a MailChimp API key. "Log in to MailChimp"https://admin.mailchimp.com/ to get your API key. Click your name at the top of the navigation menu, then click "Account". Click "Extras," then "API keys." You have to generate an API key; MailChimp doesn’t create one automatically.

You’ll also need to create a MailChimp mailing list. The MailChimp "Lists" page has a button for "Create List." The list name and other details are up to you. We’ll need the MAILCHIMP_LIST_ID for the mailing list you’ve created. To find the list ID, on the MailChimp "Lists" page, click the "down arrow" for a menu and click "Settings." At the bottom of the "List Settings" page, you’ll find the unique ID for the mailing list.

With MailChimp, you can send a welcome message automatically when the visitor signs up for the mailing list. Use the welcome message to inform the visitor that they've successfully subscribed to the mailing list. It’s a bit difficult to find the MailChimp option to create a welcome message. Strangely, MailChimp considers a welcome message a "form." Here's how to find it. On the MailChimp "Lists" page, click the "down arrow" for a list and click "Signup forms." Then click "General forms." On the "Create Forms" page, there is a drop-down list of "Forms & Response Emails." The gray box shows "Signup form." Click the down arrow. Select the menu item named "Final 'Welcome' Email" and you'll be able to create a welcome message.

h3. Hosting

We provide instructions to deploy the application to "Heroku":https://www.heroku.com/ which provides Rails application hosting. It costs nothing to set up a Heroku account and deploy as many applications as you want. To deploy an app to Heroku, you must have a Heroku account. Visit Heroku "to set up an account":https://id.heroku.com/signup/devcenter.

h3. SSL

Visitors to your website will be sending credit card information from their browser to Stripe’s servers when they sign up for a subscription. The Stripe JavaScript library will open an SSL connection to Stripe’s servers when the form is submitted. You can host your site without SSL and your users’ credit card numbers will be protected on the way to Stripe’s servers. However, your security-conscious visitors will be uneasy if they see that the web URL for your registration page begins with @http://@ and not @https://@ (indicating an SSL connection). For their peace of mind (and the higher conversion rate that comes with trust), you should host your website with an SSL connection. Additionally, as a general practice, it is wise to host any webapp that requires login over an SSL connection.

If you’re deploying with Heroku, you can access any Heroku app over SSL at https://myapp.herokuapp.com/. Setting up an SSL certificate for a custom domain on Heroku can be a hassle but there’s a convenient alternative that is a better value. You can purchase "CloudFlare":http://cloudflare.com/ for $20/month and get SSL without purchasing or installing an SSL certificate. CloudFlare is a content delivery network (CDN) and website optimizer; the $20/month "CloudFlare Pro plan includes SSL":http://blog.cloudflare.com/easiest-ssl-ever-now-included-automatically-w. See the article "Configuring CloudFlare DNS for a Heroku App":http://www.higherorderheroku.com/articles/cloudflare-dns-heroku/. If you’re deploying on Heroku, you can wait until you’ve deployed to sign up for a Cloudflare account.

h2. Dependencies

Before generating your application, you will need:

  • The Ruby language - version 2

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Ruby

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言