Anthenticating against PayFlowPro for Rails with ActiveMerchant
By: Johnathon Wright on: July 29, 2010
Rails is fortunate to have ActiveMerchant, a gem that provides a standard interface for billing. Unfortunately, there are a wide variety of gateways out there and each has their own "uniqueness." I experienced PayFlowPro's "uniqueness" today and thought I would share my now-working spike code.
THE PARTNER FIELD
The partner field below is optional. If you leave it blank, the default will be PayPal. The other option, apparently, is VeriSign. I have included it here because magical, undocumented parameters confuse people.
MERCHANT LOGIN
in my case, this was the company name without any spaces. It's the same as the merchant login required to log in to the PayflowPro website.
---ruby
gateway = ActiveMerchant::Billing::PayflowGateway.new( :login => 'mycompanyname', # 'Merchant Login from the login page :user => 'my_username', :password => 'ComPliCatedP4sSw0rd', :partner => 'PayPal' )
creditcard = ActiveMerchant::Billing::CreditCard.new( :number => '5105105105105100', :month => '9', :year => '2011', :firstname => 'Longbob', :lastname => 'Longsen', :verificationvalue => '123', :type => 'master' )
Make a $1 purchase (100 cents)
response = gateway.purchase(100, credit_card) puts response.success?
puts response.message
MOVING FROM A SPIKE TO REAL CODE
Copy the above code, replace your company name, and get that to say "Accepted"... once that's done, check back for my blog entry on the easiest way to set up ActiveMerchant in a Rails app.
ISSUES I EXPERIENCED
PayFlowPro response 26 - Invalid Vendor Account
I was using my username where my merchant login should have been.
PayflowPro response 1 - User authentication failed
Here I was submitting the company name as my :login but was not including my username under :user
REFERENCES
"com.googlegroups.activemerchant - Payflow Pro Integration":http://markmail.org/message/sjc3nbw2vttredlj
"Payflow Gateway - User authentication failed":http://groups.google.com/group/activemerchant/browse_thread/thread/e15c44b27a654c9f