My Octopress Blog

A blogging framework for hackers.

Using Paypal Website Payments Pro With Ruby on Rails

Using Paypal Website Payments Pro with Ruby On Rails

There have been a few tutorials written on using PayPal’s API with RubyOnRails. There have been plugins made and patches to ActiveMerchant developed. Still, I could not for the life of me get it working for the longest time. This is my walkthrough.. it’s the idiot’s walkthrough. I assume nothing about your knowledge, and I will explain it in a detailed step by step process.

Here are the steps required to using PayPal’s Website Payments Pro. Also note that at this time Website Payments Pro is ONLY available to US merchants.

  1. Get a PayPal business or premier account.
  2. Apply for Website Payments Pro and get approved.
  3. Setup a Paypal developer account and sandbox accounts
  4. Get the necessary API access and certificates
  5. Download the ELC RoR::Paypal Plugin
  6. Download soap4r and http-access2
  7. Install the plugin
  8. Setup the plugin and certificates
  9. Run the tests

If you’ve already done most of this and you’re just looking for answers to the hard questions, here they are for reference:

  1. You need to use the Nov 2005 version of soap4r to generate the wsdl and to send the request to paypal
  2. Your Username and Password for using the API is NOT your Paypal login info. It is the username and password provided for you when you generate the API Certificate.
  3. Paypal’s Country Codes are the TWO character international standards. CA, US, DE, JP etc

Here are some common issues we hit and what they mean:

  1. “OrderTotal is required” - You are using an old version of the default.rb and defaultDriver.rb files. You need to regenerate them with the Nov 2005 version of soap4r (or newer).
  2. Authentication Error - Not using the right username / password from the API Credentials
  3. SSL Not Supported - You need to install http-access2

Kidzworld

Kidzworld In 2006 I designed and developed a kids social networking site to replace their 500,000 member online magazine. I did all of the development and planning by myself. It was huge. Looking back on it, doing it by myself was stupid.

Interview With Geoffrey Grosenbach

Geoff stopped into the Raincity office today and I got the chance to ask him a few random questions. We were able to catch it all on film using out high tech video recorder.. and a stapler.

MexRetire and Livtopia

# MexRetire and Livtopia In a 2006 partnership with Raincity Studios, I developed the Livtopia network of sites. MexRetire, an informational resource for people interested in retiring to Mexico; MexLiving, a Mexican property listing site; and Livtopia, a full blown real estate information site for latin america. Again, I did all of the development, planning and architecture for all three websites.

Conquering Fear - the End of Good Enough

Conquering Fear: The end of ‘Good Enough’

We all have fears. Our lives are dictated by them. The fears that we express such as spiders and small spaces are easy to pin point. We let them out and, although they control us, we understand that and work around them. If we are unable to fly because of our fear of flying, we schedule trips that involve cars, trains and boats instead. We learn to tolerate this, as do those around us, and it becomes a part of our life.

The worst cause of fear is that people settle. They decide that what they have is ‘good enough’ because they do not want to put themselves through the pain of taking action. They choose fat over fit because of how hard it would be to get some exercise and to eat well. They stay in jobs they don’t like because of the fear that there is nothing else out there. They stay in relationships that they know aren’t right, just because fear of losing someone close doesn’t seem worth it.

The path to being honest with yourself is a dangerous one. To be truly honest with yourself, and do something about it, takes a tremendous amount of strength. You have to stand up, look at what you want, look at what you’re afraid of and face it head on.

Power (n.)

  The ability or capacity to perform or act effectively.

The fear of the unknown and the fear of pain can NOT dictate your life. You have to get past it. You have to ask yourself honest questions and deal with the answers. How many of you know people who are unhappy in their jobs, yet do nothing about it. Would you say that only their job is affected by this? NO! Everything is affected by not being true to yourself.

If you are unable to take action on something in your life, it has effects on everything. If you KNOW what is right but refuse to do it, you can not be truly happy. Not taking action makes us less powerful. Being less powerful affects our self esteem. Having lowered self esteem affects the way we interact with people. Everything you do is connected to your ability to be honest with yourself. It is a very fragile system, but it is there for a reason.

The long term pain of not being honest with yourself will have a devastating effect on your life. One thing leads to another. You settle for a job you don’t like. Because of that job’s salary, you tolerate living in an area that you’re not happy with. You meet a woman who is “good enough” and get married. Your life seems to be trucking along just fine. That’s when it hits. The inner nagging that has been with you all along. The painful feeling in your gut that you have learned to live with starts acting up. You take a good look at your life, and realize that it’s not what you wanted. What do you do now? You’ve got a family, friends, a lifestyle that you’re deeply intrenched in - and getting out of it is going to be incredibly painful.

Take action now, before it is too hard not to. The pain you feel for a week, month or year is worth every minute compared to the pain that eats away at you when everything is “good enough.”

Digifonica

In late 2005, Digifonica was getting ready to launch their white-labeled VOIP system. I developed a white labeled reseller website system that let other companies have their own VOIP website. The core of the app was developed over the course of a single weekend.

Installing FastCGi and RubyOnRails on FreeBSD

Assumptions

We are going to assume that Apache2 is already installed with mod_fastcgi. We are also going to assume that Ruby has already been installed from Ports. Please see Appendix 1 for a list of installed packages in my environment.

Step 1

Download the latest version of FastCGI from http://www.fastcgi.com/dist/

Step 2

Install the Rails bindings from Ports

cd /usr/ports/www/rubygem-rails
    make install clean

Step 3

Install FastCGI from Source

tar -xzf fcgi-2.4.0.tar.gz
    cd fcgi-2.4.0
    ./configure
    make install clean

Step 4

Install the Ruby FastCGI Bindings using Gem

gem install fcgi --
      --with-fcgi-include=/usr/local/include
      --with-fcgi-lib=/usr/local/lib

Step 5

To setup the default website, edit your Apache2 configuration file and add the following lines:

<Directory /var/www/>
        AllowOverride all
    </Directory>

    LoadModule fastcgi_module modules/mod_fastcgi.so

    AddHandler fastcgi-script .fcgi

    <VirtualHost *:80>
        ServerAdmin webmaster@example.com
        DocumentRoot /var/www/rails/testapp/public
        ServerName www.example.com
        ErrorLog /var/log/httpd/testapp-error_log
        CustomLog /var/log/httpd/testapp-access_log common
        Options Indexes ExecCGI FollowSymLinks
        RewriteEngine On
    </VirtualHost>

Step 6

You’re done. You can now setup your web app. :) For more information on configuring your application to use fastcgi, please see the RailsWiki entry: HowtoSetupApacheWithFastCGIAndRubyBindings

Appendix 1

This is a pkg_info dump from the server before the install process was started. You can use this as a reference on your system.

apache-2.0.54 - Version 2 of Apache web server with prefork MPM.
apr-nothr-db4-1.0.1_1 - The Apache Group's Portability Library
bash-2.05b.007_2 - The GNU Bourne Again Shell
bsdiff-4.2 - Generates and applies patches to binary files
db42-4.2.52_4 - The Berkeley DB package, revision 4.2
expat-1.95.8 - XML 1.0 parser written in C
freebsd-update-1.6_1 - Fetches and installs binary updates to FreeBSD
gettext-0.14.1 - GNU gettext package
libiconv-1.9.2_1 - A character set conversion library
mod_fastcgi-2.4.2 - A fast-cgi module for Apache
mysql-client-4.1.11_1 - Multithreaded SQL database (client)
mysql-server-4.1.11_1 - Multithreaded SQL database (server)
neon-0.24.7 - An HTTP and WebDAV client library for Unix systems
ngrep-1.43 - Network grep
perl-5.8.6_2 - Practical Extraction and Report Language
ruby-1.8.2_4 - An object-oriented interpreted scripting language
ruby18-gems-0.8.11 - Package management framework for the Ruby language
rubygem-actionmailer-1.0.1 - Easy email delivery and testing for Ruby
rubygem-actionpack-1.9.1 - Action Controller and Action View of Rails MVC Framework
rubygem-actionwebservice-0.8.1_1 - Simple support for publishing Web Service APIs for Rails ap
rubygem-activerecord-1.11.1 - Object-relational mapping layer for Rails MVC Framework
rubygem-activesupport-1.1.1 - Utility classes and extension that are required by Rails MV
rubygem-rails-0.13.1 - MVC web application framework
rubygem-rake-0.5.4 - Ruby Make
subversion-1.1.4 - Version control system
sudo-1.6.8.8 - Allow others to run commands as root
vim-lite-6.3.62 - Vi 'workalike', with many additional features (Lite package)

Spammer Gets a Beat Down

I just had this article passed over to me by my friend Markus Frind.

Russian Spammer Beaten to Death

MOSCOW — The director of an English language center and one of the country’s most notorious spammers was found beaten to death in his apartment in central Moscow, police said Monday.

Happy? Sad? Neither? Poetic Justice? What do you think?

A Good Place for the Kitchen Sink

Improving negative activities

I was up visiting my parents recently, and my mother said something that stuck with me.

“Doing the dishes wouldn’t be so bad if the sink wasn’t up against a wall.”

I looked at the kitchen of her place and realized that she was right. The sink in this house was in the corner of the kitchen. If she was to stand at the sink to do the dishes, it would be akin to sending a kid into the corner with a dunce hat.

Somewhere along the line, some architect was trying to fit all the necessary items into the kitchen and, although he succeeded, he forgot to think about the people. This is a mistake I’m sure a lot of us web developers, programmers, and techies do on a regular basis.

Just think of how limiting it is to have a double sink in the corner of the room. If my parents have guests over, my mom can’t interact with them at the same time as she does the dishes. If my parents want to talk, they can’t do so over the dishes. In fact, a person could do nothing more while doing the dishes than focus on how crappy it is to do the dishes.

Simple ways to improve this?

  • Build the sink on an island in the middle of the kitchen
  • Build the sink overlooking a window with a view
  • Hire a maid. ;)

How can these simple ideas be translated to the web? Are there things that are usable, but that don’t help take the pain away? Have you ever had to use a signup form and just loathed all the filling out you had to do?

When you’re building your next app, or even your next house, just think about what it would be like to do a 15 person dinner’s worth of dishes while staring at the corner of a room.

MatchTag

As an experiment in mapping and social networking, I created an activity based site that could tell where you are and help you connect with other people in the area who were interested in doing the same thing. Time constraints prevented me from turning it into a completed project, but within the first 4 days we had over 1500 members and ended up getting mentioned on TechCrunch.