# Active Merchant Example

**URL:** <https://www.ruby-forum.com/t/active-merchant-example/152663>\
**Category:** Rails\
**Created:** [November 6, 2008, 5:33am UTC](https://www.ruby-forum.com/t/active-merchant-example/152663 "2008-11-06T05:33:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sshefer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d9b06d/32.png) [@sshefer](https://www.ruby-forum.com/u/sshefer)\
**Post date:** [November 6, 2008, 5:33am UTC](https://www.ruby-forum.com/t/active-merchant-example/152663/1 "2008-11-06T05:33:05Z")

</div>

Hi,

I’ve searched the web and found some old examples of Active Merchant  
but was wondering if anyone had, or could point me to, a definitive  
guide showing a simple checkout where the logic is in the model rather  
than including the process in the controller.

I’d like to keep everything separate and would just like a super  
simple example.

Thanks!

---

<div class="post-metadata">

**Author:** ![sshefer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d9b06d/32.png) [@sshefer](https://www.ruby-forum.com/u/sshefer)\
**Post date:** [November 6, 2008, 8:39am UTC](https://www.ruby-forum.com/t/active-merchant-example/152663/2 "2008-11-06T08:39:46Z")

</div>

You can look at this code

[http://code.google.com/p/substruct/](http://code.google.com/p/substruct/)

---

<div class="post-metadata">

**Author:** ![sshefer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d9b06d/32.png) [@sshefer](https://www.ruby-forum.com/u/sshefer)\
**Post date:** [November 6, 2008, 9:08am UTC](https://www.ruby-forum.com/t/active-merchant-example/152663/3 "2008-11-06T09:08:30Z")

</div>

Thanks Freddy.

I found substruct to be the only example I could find but am having a  
hard time pulling out the excess. I was wondering if there was  
anything out there that was even more basic. No cart, just a simple  
buy this and pay now example that is clean and model based.

For now, substruct is the closest and I’ll keep looking at it, but if  
anyone knows of a better example please share. 🙂

---

<div class="post-metadata">

**Author:** ![sshefer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d9b06d/32.png) [@sshefer](https://www.ruby-forum.com/u/sshefer)\
**Post date:** [November 6, 2008, 2:02pm UTC](https://www.ruby-forum.com/t/active-merchant-example/152663/4 "2008-11-06T14:02:05Z")

</div>

Not sure if this is what you are after:  
[https://peepcode.com/products/activemerchant-pdf](https://peepcode.com/products/activemerchant-pdf)

hth,  
Rick

---

<div class="post-metadata">

**Author:** ![sshefer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d9b06d/32.png) [@sshefer](https://www.ruby-forum.com/u/sshefer)\
**Post date:** [November 6, 2008, 6:37pm UTC](https://www.ruby-forum.com/t/active-merchant-example/152663/5 "2008-11-06T18:37:47Z")

</div>

Hi Rick - Thanks for the suggestion. I purchased the peepcode a few  
months back and found it was lacking some information.

I guess I should rephrase the question by asking, do most of you  
process the payment (checkout) as a controller action, or does the  
actual processing piece take place in the model?

It seems like integration in the controller is very straight forward,  
but I am not sure it is the best method for an application. Any  
thoughts?

---

<div class="post-metadata">

**Author:** ![sshefer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d9b06d/32.png) [@sshefer](https://www.ruby-forum.com/u/sshefer)\
**Post date:** [November 6, 2008, 10:14pm UTC](https://www.ruby-forum.com/t/active-merchant-example/152663/6 "2008-11-06T22:14:23Z")

</div>

When I did this I used a checkout controller that uses an external  
order helper module… The order helper does all the checking and  
validation before my checkout controller does @order.save then if that  
works I do @order.process which then does all the “payment” stuff in  
the order model…

So the process class does the cc card and gateway setup then if that  
works and is valid it charges the card…
