My experiences setting up Potion Store

24 views
Skip to first unread message

John McLaughlin

unread,
Nov 21, 2007, 11:53:11 PM11/21/07
to Potion Store Discussions

(A google doc version of this with some marginal formatting is
available here http://docs.google.com/Doc?id=ah4jzqpk89pj_30g849wn)

I started my little software business about two years ago -- Even
though I wasn't a novice to the world of business having to 'do it
all' was a bit overwhelming to me -- Coding, artwork, website,
customer support, documentation and payment processing. It was too
much to worry about ... Especially at a time when I was just glad when
the software didn't Crash!

So I was more than happy to find a third party solution in Esellerate
-- They had no setup costs and could handle payment processing with a
variety of payments -- I set up a account, put a 'now open' on my web
site and started learning how to run my own software business.

Fast Forward 2 years -- By all measure Esellerate has been a good
partner, the number of complaints from my customers about them I could
count on both hands (mostly due to problems with processing German
paypal transactions) I'm not fundamentally unhappy with them, I'm
just looking at the 15% they take off the top on every transaction and
started thinking there has to be a better way.

I had heard about the potion store but I was a little 'scared' of it
-- It was based on Ruby and I have no Ruby skills and I just didn't
believe it would meet my needs. But I decided to spend a little time
investigating and a week later I rolled out my 'new' store based on
potion store.

First my requirements. In two years this is the functionality I used
in Esellerate that I would need to duplicate
Ability to process orders from CC or papal
Ability to issue serial numbers from a pre-calculated list
Ability to offer coupons -- I use mostly % off coupons (as opposed to
save $10)
Coupons would need some level of restrictions (e.g. you must buy at
least 3 things, or only applies to a certain product)
Ability to offer my customers a 'lost serial number' feature
Ability to review orders & reports

After a little sleuthing I realized the potion store was almost 100%
there. The 'things' I would need to do myself were pretty small
I would need to write my own 'pull serial number off a precalculated
list' function in ruby
I would need to enhance the coupon system a bit -- Right now there is
no interface to % off (although if you edit the database directly the
field is there) but what's missing is the ability to have a % off
coupon with a minimum order quantity

Everything else was there -- I had some additional complications
because while my web host (Dreamhost) does support ruby on rails they
do not support postgres which is the default (and preferred) database
for potion store. Jeremy Knope on the #macsb channel was kind enough
to whip up a patch to work with mysql (you also need to changed the
adapter in config/database.yml to be 'mysql') You can get the patches
at http://www.loghound.com/download/mysql_fix-1.zip

Finally I had to deal with the inevitable customization of look & feel
and fix a few defects. But after a week I had my own store online --
in reality it was probably closer to 3 evenings of work and then a
morning to actually launch it but I didn't work non stop. I mention
this only to point out that it is really almost ready to go out of the
box -- Most of that time was in my learning -- the actual number of
changes were very, very small.

So it's been online 3 days now -- I'm happy to report that it's all
running very smoothly, my sales have not slowed down at all.
Customers are placing orders, confirmation emails are being send and
I've lowered my transaction cost from 15% to 5% -- A 10% increase in
revenue for about 4 days of work -- Not bad.

I've only had two 'suprises' -- The first one is nice, During testing
I asked a friend to place some orders just to confirm it was all
working. When I refunded their money I discovered that Paypal also
refunds the transaction fee -- Esellerate used to keep the 15% even
with refunds! The other surprise is more of a mystery to me. I
decided to keep Esellerate as a payment option, I really just kept it
there as a backdoor in case something bad happened I had a way to
process through Esellerate -- All I do is take the order information
(products, quantities & coupons) and redirect them to the Esellerate
store with the form prepopulated for payment. I expected my sales
through Esellerate to be close to 0 but I've found about 25% to 30% of
the people are choosing Esellerate -- Not sure why...

I've got my notes below for getting it up and running on the Potion
store -- I'd like to disclaim that I'm new to ruby so there are likely
more elegant solutions than what I presented and perhaps I'm stating
the obvious in some cases but I hope they help people.

My final two thoughts are first to the Potion factory guys -- Thanks
for putting this fantastic resource out there! The second thought it
to all of those developers using Kagi/Esellerate -- get off those lazy
asses and put some of them mad coding skills to work on your own
store.

-John





Potion Store setup.

These are some more-or-less raw notes from setting up potion store in
Potionstore on Dreamhost. Although it may look like a walk through or
step-by step it's not -- It's just the significant points I came
across.

First prerequisite -- You will need to learn Ruby. I did most of my
learning by looking at this web page : http://rubylearning.com/satishtalim/tutorial.html
It takes about one hour to go through the tutorials but at the end you
should be able to fuddle your way through. Some other URL's that might
come in handy are 6 tips for deploying Ruby on Rails with Dreamhost <<
Gizmoojo! and Ruby on Rails Hosting - Reviews - Rails Tutorials,
Demos, Price Comparisons...

The potion store uses postgresql -- not my sql -- You can get a set of
patches for the mysql that Dreamhost uses here:
http://www.loghound.com/download/mysql_fix-1.zip

create a new domain with fastcgi in Dreamhost from the control panel
-- I used store.loghound.com
download & install the potion store to a location in your account --
It can be anywhere
Symbolic link your new domain to the 'public' directory of the potion
store

ln -s ~/loghound.com/potionstore-0.3.1/public store.loghound.com

edit the .htaccess in the public dir to modify the rewrite rules. The
important one is the dispatch.cgi needs to point to dispatch.cfgi


RewriteRule ^$ index.html [QSA] to RewriteRule ^$ store/index.html
[QSA]
RewriteRule ^(.*)$ dispatch.cgi [QSA,L] to RewriteRule ^(.*)$
dispatch.fcgi [QSA,L]

You need to comment out the ruby debug -- for some reason I can't get
it working with Dreamhost Edit app/controllers/application.rb and
comment out the require -- Skip the step about running " gem install
ruby-debug" from the included readme -- you can't install it on
Dreamhost.

# require 'ruby-debug' if not is_live()

edit the config/store.yml to your liking. Mostly self explanatory

you will need to create a paypal sandbox and account to test buying.
This is a royal pain and is time conusming but in short you go to
developer.paypal.com and create an account. Then you create one users
(seller). Then you log into the seller and setup a merchant account.
Then you need to create api credentials and download them into
sandbox_api.key and sandbox_api.crt (it downloads as a single file but
you can split it up). Then you need to get your paypal_username and
paypal_password from your sandboxed paypal account and set up
paypal.yml (whew!)

Create a mysql database from the Ddreamhost control panel. Enter the
credentials into database.yml with the username, password, & host set
up properly with the adapter set to mysql

The store should be live now. Log in and see it working. Play
around
During testing you will not (usually) receive emails -- they are
logged to the window however. When you go live emails should function
from the store.

Setting up paypal pro


Under Dreamhost you need to manually select between production &
development by editing the config/environment.rb. To force
development mode do this

ENV['RAILS_ENV'] ||= 'development'

To force production mode do this

ENV['RAILS_ENV'] ||= 'production'

Note that you may need to do a 'killall ruby' to get the store into
the new mode -- Also note that that it's not enough to comment out the
'development' line in dreamhost -- You actually have to force
production mode to get it working properly.

I had problems with coupons -- I tend to use a lot of % off coupons
(Bundle discounts) and there were rounding errors that caused
transactions to fail I fixed it by rounding the total in order.rb

def total
return ((total_before_applying_coupons() - coupon_amount()
+0.0005)*100.0).round/100.0;
end

I also wanted to keep an esellerate as an option for payment -- sort
of a safety ne I did this by creating a custom redirect back to
esellerate with the shopping cart pre-filled.. Let me know if you
would like an example of this.

Andy Kim

unread,
Nov 22, 2007, 2:41:06 AM11/22/07
to potion...@googlegroups.com
John,

Thanks for the write-up. I'm sure it'll be useful to other people, even ones not on DreamHost.

I just committed the code to round the order total and a few other monetary amounts.

- Andy Kim

Potion Factory LLC

RedRuby

unread,
Dec 4, 2007, 5:26:18 PM12/4/07
to Potion Store Discussions
Using mysql, did you create the database tables by hand? Or were you
able to use the "rake db:migrate?" How would you use "rake
db:migrate" assuming the hosting is shared and no access to the
command line.

John McLaughlin

unread,
Dec 4, 2007, 6:21:15 PM12/4/07
to Potion Store Discussions
I followed the normal directions including 'rake db:migrate' but
changed my adapter to mysql and it all worked perfectly. If you don't
have access to the command line I'm guessing (?) you could set up the
tables & by hand but my database kung-fu is pretty weak so I'm
probably not the best to comment on it.

Honestly though if you are considering using the Potion store I'd
suggest you find a web host that does give you command line access --
I know dreamhost does and their rates are pretty reasonable (almost
free the first year if you use one of the many coupons floating
around)

-John

RedRuby

unread,
Dec 7, 2007, 3:45:41 AM12/7/07
to Potion Store Discussions
Using DH, how do you get the images, stylesheets, and javascripts to
link up correctly?

From what I understand ./script/server runs the Webrick server which
allows absolute paths like src="/images/store/amex.gif"

However, when starting the app through the "public" folder the images,
stylesheets, and javascripts are all missing because the file paths
are wrong. How did you fix this?

Peter Boling

unread,
Dec 7, 2007, 9:17:24 AM12/7/07
to potion...@googlegroups.com
There are guides to setting up a Ruby on Rails site on Dreamhost. You
should have access to the command line. I do on my Dreamhost account.
And you need to setup a database to use using the MySQL tab of your
dreamhost account, and then setup your database.yml to connect to it.
Then you can ssh into your Dreamhost account, and cd to the project
directory, and run rake db:migrate to add all the required tables to
the database. I have several Rails sites on Dreamhost. They run a
bit slow, and there are outages a bit more than I would like, but it
is not too hard to get it setup.

Dreamhost has some info on setting up rails on their wiki.
Helpful hionts on setting up Rails on DH:
http://gizmoojo.wordpress.com/2006/02/28/6-tips-for-deploying-ruby-on-rails-with-dreamhost/

--
(**********************************************************
* |7eter H. l3oling
* Fooby-Ru Wizard - Sagebit, LLC
* skype: peter.boling
* AIM: djpeteplzdance
* gmail: peter....@gmail.com
* blog: http://galtzo.blogspot.com/
* languages: English, Spanish, Portuguese
***********************************************************)

Reply all
Reply to author
Forward
0 new messages