A simple sales app built on Heroku, Stripe, and Mailgun
CSS Ruby JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Mazuma - a sales app built on Heroku, Stripe, and Mailgun

Mazuma is a simple sales application written in Ruby. It uses Sinatra and ERB templates to produce an attractive two-column web application suitable for selling a product, service, or subscription online. The application is capable of delivering a file download link on a successful transaction and/or sending the file as an email attachment.

Mazuma is designed for easy deployment to Heroku's. Stripe is used to charge the user's credit card, and Mailgun is used to send the user a receipt for successful transactions, as well as send all purchasers update emails via a simple command line interface. Mailcheck.js automatically catches common email typos.

All pages in the application default to SSL via rack-ssl-enforcer. Using an SSL connection allows you to securely transmit user credit card information to Stripe without storing it in your application, ensuring full PCI compliance. Piggyback SSL is available by default for apps on subdomain.herokuapp.com, or inexpensively via Heroku's wildcard SSL add-on.

("Mazuma" is the Yiddish word for money.)

Getting Started

$ git clone git://github.com/worldlywisdom/mazuma.git

$ gem install bundler

$ bundle install

$ git init .

$ git commit -m "Initial commit"

$ heroku create yourappname

$ git push heroku master

Setting Global and Environment Variables

Global variables are set in the /config/globals.rb file. This file is read by both the Sinatra application and the Rakefile, ensuring these items are consistent and available across the application.

Once you've set up accounts at Stripe and Mailgun, you'll need to add your API keys to Heroku as environment variables. This help you keep your private keys secure if you contribute to open source or in the event your machine is compromised. (Be sure to replace "t0psecretkey" with your personal key.)

Set Stripe.com Keys

$ heroku config:add STRIPE_SECRET_KEY=t0psecretkey

$ heroku config:add STRIPE_PUBLISHABLE_KEY=publickey

Set Mailgun.net Keys

$ heroku config:add MAILGUN_PRIVATE_KEY=t0psecretkey

Changing Page Copy & Design

All pages in this application are ERB templates, which can be found in the /views directory.

The general page layout is set in /views/layout.erb. The site uses Bootstrap as a design framework, modified by a custom stylesheet in /public/css/stylesheet.css. Fancy fonts are provided by Google Web Fonts, which are included in the header of /views/layout.erb and set in /public/css/stylesheet.css.

Notably, it's easy to change the default layout to a single-column format by removing the sidebar div in /views/layout.erb and changing the container div to "span8 offset1"

Sending Email Broadcasts

The included Rakefile contains two Rake tasks that make it easy to send broadcast emails to your paid users. For security, broadcast emails to your users are sent via the command line vs. a web-based interface, since Heroku command line logins require both your SSH key file and password.

Step 1: Upload Files

Add your email message to /email/messages, and upload the fie to Heroku by running $ git push heroku master after adding and committing the file to your repo. Text or HTML files are supported. I recommend using a YEAR-MONTH-DAY-filename.extention naming scheme to make your messages easy to find later.

Add file attachments to /email/attachments.

Step 2: Preview Your Email

Use this command to send a preview email to the administrator email set in the /config/globals.rb file.

$ heroku rake 'email:preview["Subject Line","2012-01-01-message.extention"]'

If you'd like to include an attachment, use this command:

$ heroku rake 'email:preview["Subject Line","2012-01-01-message.extention","attachment.extention"]'

Step 3: Send the Broadcast

Use this command to send a broadcast email to the Mailgun list set in the /config/globals.rb file.

$ heroku rake 'email:broadcast["Subject Line","2012-01-01-message.extention"]'

If you'd like to include an attachment, use this command:

$ heroku rake 'email:broadcast["Subject Line","2012-01-01-message.extention","attachment.extention"]'

These commands change to $ heroku run rake if you deploy to Heroku's Cedar stack.

Extending Mazuma

You can extend the features of Mazuma however you desire. Want to add your customers to a database? Integrate with other APIs? Change mailing or credit card services? Mazuma is simple enough to change: everything you need is in application.rb and /modules/mailer.rb.