small medium large xlarge

Take My Money: Accepting Payments on the Web


Cover image for Take My Money

Take My Money

Accepting Payments on the Web


Getting paid using Stripe or PayPal is only the beginning of creating a fully functional e-commerce application. You also need to handle failure cases, inventory management, administration, security, reporting, and be compliant with legal issues. Manage one-time transactions and recurring subscriptions, handle inventory management, issue discounts and refunds, mitigate administration and compliance issues, and test your code to ensure your customers have a smooth, hassle-free experience.

Customer Reviews

The ability to easily and securely accept payments on the web is critical to any
business. Accepting Payments on the Web acts as a shining beacon, guiding intermediate
and advanced developers through the complexities of setting up a payment
system, interacting with third-party processors, and staying within compliance
regulations. This book is a must-have for any application developer.

- Nell Shamrell

Software development engineer, Chef

Do you need to accept money on the web? No problem! Just follow the steps in
Noel Rappin’s book and you will be taking money in a blink of an eye.

- Brian Schau

Lead developer, Rosving Applications

I’ve maintained two large payment systems at two different e-commerce companies,
and the hard lessons I learned are all captured succinctly in this book. I wish I’d
had it years ago.

- Dave Copeland

Author of "Rails, Angular, Postgres, and Bootstrap, Second Edition

Reading this book has increased my confidence in the daunting task of handling
electronic payments. All the topics I’d hoped would be covered are here, along
with useful introductions to handy gems and third-party tools.

- Nigel Lowry

Company director and principal consultant, Lemmata Ltd.

I would not hesitate to recommend this book to anyone looking to accept payments
online. I only wish I’d had this detailed a guide when building some of the systems
I’ve written in the past; it would have saved me a great deal of stress and pain.

- Stephen Orr

Senior developer, Siftware

See All Reviews

About this Title

Pages: 338
Published: 2017-01-31
Release: P1.0 (2017-01-24)
ISBN: 978-1-68050-199-5

An e-commerce payment application is literally rewarding to build—you can see the return on investment as genuine money is added to your account. But it can be stressful to manage, with security and compliance concerns and administration issues. And your entire business may depend on these features working smoothly.

Let Noel Rappin guide you through the setup and complications of dealing with online financial transactions.

Go beyond just the interaction with the gateway service and build an application using Ruby and Rails that will be robust and useful over time. Set up a Stripe and PayPal payment gateway and accept credit card payments. Use the Stripe API to improve security by validating credit card data without sending it through your own server. Design your application for maximum flexibility against the inevitable complexities of business logic, including handling discounts. Manage the multiple failure points of dealing with payment gateways and test for failure cases. Use background jobs to simplify third-party interactions. Handle administrative tasks such as issuing refunds and discounts while maintaining data integrity and security. Create subscription plans and manage recurring payments, and stay on top of legal issues regarding taxes, reporting, and compliance. Pay affiliates or contributors from your application.

By the end, you will know how to create a fully functional web payment-taking machine.

What You Need

The code in this book works with Ruby 2.3.1 and Rails 5, though nearly all of the code will run with earlier versions of Ruby and Rails.

Contents & Extracts


  • About This Book
  • About the Project
  • A Note About the Code
  • Not Taking Payments on the Web (Yet)
    • Understanding the Data Model
    • Building the Shopping Cart Feature
    • Unit Testing Our Logic
    • Next Up
  • Take the Money excerpt
    • What’s a Payment Gateway and Why Do I Need One?
    • Setting Up Our First Payment Gateway
    • Charging Cards with Server Authentication
    • Testing with the VCR Gem
    • Next Up
  • Client-Side Payment Authentication
    • Setting Up Client-Side Stripe
    • Using the Token on the Server
    • Testing the JavaScript via Capybara
    • Next Up
  • PayPal excerpt
    • Setting Up a PayPal Account
    • Accepting PayPal Transactions
    • Handling the PayPal Callback
    • Developing PayPal Charges
    • Next Up
  • Failure Is Totally an Option
    • Client-Side Validation
    • Server-Side Failure
    • Testing for Failure
    • Running a Background Job
    • Notification
    • Next Up
  • Subscriptions excerpt
    • Creating Subscription Plans
    • Creating Subscription Customers
    • Purchasing a Subscription
    • Setting Up Webhooks
    • Supporting the Stripe Subscription Life Cycle
    • Next Up
  • The Administration Experience
    • Using Stripe’s Administration Dashboard
    • Setting Up Your Own Administrative Dashboard
    • Setting Up a Point of Purchase
    • Next Up
  • Administration Roles
    • Authentication and Roles
    • Issuing Refunds
    • Applying Discounts
    • Next Up
  • Administration and Data Security
    • Breaking the Rules
    • Keeping Data Secure
    • Two-Factor Authorization
    • Simulating Users
    • Blocking Email
    • Next Up
  • Reporting
    • Using ActiveAdmin Reporting
    • Rolling Your Own Data
    • Speeding Up Performance and Data Preparation
    • Next Up
  • Adding Fees and Calculating Taxes
    • Adding Nontax Fees
    • Calculating Taxes
    • Next Up
  • Third-Party Sales with Stripe Connect
    • Creating Affiliate Accounts
    • Transferring Payments to Affiliate Accounts
    • Validating Affiliates
    • Next Up
  • Going to Production
    • Going Live
    • Setting Up SSL/TLS Encryption
    • Running Automated Security Audits
    • Database Backups
    • Running Periodic Tasks
    • Compliance
    • The End
  • Author

    Noel Rappin is the director of development at Table XI and the author of multiple technical books, including Rails 4 Test Prescriptions and Professional Ruby on Rails. He is a frequent speaker and trainer in the web development community.