Home arrow Ruby-on-Rails arrow Page 4 - Order and Payment Handling for an Ecommerce Website
RUBY-ON-RAILS

Order and Payment Handling for an Ecommerce Website


In this second part of a five-part series on building the checkout and order processing parts of an ecommerce application in Ruby on Rails, you'll learn how to save order information, integrate with payment gateways, and more. This article is excerpted from chapter nine of the book Practical Rails Projects, written by Eldon Alameda (Apress; ISBN: 1590597818).

Author Info:
By: Apress Publishing
Rating: 5 stars5 stars5 stars5 stars5 stars / 9
July 09, 2010
TABLE OF CONTENTS:
  1. · Order and Payment Handling for an Ecommerce Website
  2. · Creating the View
  3. · Saving the Order Information
  4. · Integrating with Payment Gateways

print this article
SEARCH DEVARTICLES

Order and Payment Handling for an Ecommerce Website - Integrating with Payment Gateways
(Page 4 of 4 )

You can think of a payment gateway as a kind of proxy that handles the tricky details of credit card transactions for merchants. You send the payment details to the gateway, and the gateway forwards the details to the financial institution. The payment is then processed (with a possible delay) by the financial institution, after which the result is communicated back to the gateway, and then to you or your application.

We’ll first show you how to use Active Merchant, a payment abstraction library, to integrate with PayPal, the leading online payment solution that enables merchants to manage credit card transactions online. Later, we’ll also demonstrate how to integrate with Authorize.Net, another leading payment gateway, including how to do this with the Payment gem as an alternative to Active Merchant.


Note  Only US-based businesses are allowed to use PayPal’s Website Payments Pro and Authorize.Net. For alternative payment gateways, see the Active Merchant homepage athttp://home.leetsoft.com/am. And remember, using payment gateways is not the only option. Some banks allow you to add a simple form to your site, which the customer can use for transferring money directly to your bank account.


Installing the Active Merchant Plugin

Active Merchant (http://home.leetsoft.com/am) is a Rails plugin, written by Tobias Lütke and various contributors, that allows you to integrate with various payment gateways, including: Moneris, Authorize.Net, TrustCommerce, PsiGate, and PayPal’s Website Payments Pro. It’s currently used by Shopify (http://shopify.com) in production.  

You first need to install the Money gem (http://rubyforge.org/projects/money/), which Active Merchant uses to handle money:

$ sudo gem install money

Next, install Active Merchant itself with the following command:

$ script/plugin install svn://home.leetsoft.com/active_merchant/trunk/➥
active_merchant

The command checks out the latest version of the plugin and places it in thevendor/ plugins/active_merchantdirectory.

Active Merchant uses the SOAP protocol to communicate with PayPal. This means you’ll need to installsoap4r, an implementation of SOAP 1.1. Download the latest version fromhttp://dev.ctor.org/soap4r, extract the package to a folder of your choice, and then execute the following command:

$ sudo ruby install.rb


Note  At the time of writing, Active Merchant requiredsoap4rversion 1.5.5 or greater to work. To retrieve the latest version, executesvn checkout http://dev.ctor.org/svn/soap4r/trunk soap4r.


soap4ruses thehttp-access2library to communicate with the PayPal servers, so download the latest stable release of this library fromhttp://dev.ctor.org/http-access2/, extract the package, and install it with the following command:

$ sudo ruby install.rb

That’s it. If you have the server running, restart it for the changes to take effect.

Please check back next week for the third part of this series.


DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

blog comments powered by Disqus
RUBY-ON-RAILS ARTICLES

- Ruby-on-Rails Faces Second Security Flaw in ...
- Ruby 2.0 Prepped for February 2013 Release
- Why LinkedIn Switched from Ruby on Rails
- Adding Style with Action Pack
- Handling HTML in Templates with Action Pack
- Filters, Controllers and Helpers in Action P...
- Action Pack and Controller Filters
- Action Pack Categories and Events
- Logging Out, Events and Templates with Actio...
- Action Pack Sessions and Architecture
- More on Action Pack Partial Templates
- Action Pack Partial Templates
- Displaying Error Messages with the Action Pa...
- Action Pack Request Parameters
- Creating an Action Pack Registration Form

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials