Rails with Paypal Payments Pro error


I am trying to get up and running using active merchant and have been
following the article here

I have set up all of my sandbox accounts, downloaded the certificates
and pulled in all of the login info supplied by the sandbox account but
for some reason I keep getting “StandardError in
OrderController#checkout - Username/Password is incorrect” … although
I am pretty sure that is not the case.

My controller looks like this

class OrderController < ApplicationController

def checkout
creditcard = ActiveMerchant::Billing::CreditCard.new(
:type => ‘visa’,
:number => ‘the number supplied by paypal’,
:month => 1,
:year => 2010,
:first_name => ‘Test’,
:last_name => ‘User’
params = {
:address => {
:name => ‘Test User’,
:address1 => ‘1 Main St’,
:city => ‘San Jose’,
:state => ‘CA’,
:zip => ‘95131’,
:country => ‘US’,
:phone => ‘415-222-2222’
:ip => ‘’
if creditcard.valid?
# Create a gateway object to the Paypal service
gateway =
ActiveMerchant::Billing::PaypalGateway.new(:login =>
‘mysandboxAPIusername’, :password => ‘mysandboxAPIpassword’)

      # Authorize for 10 dollars (1000 cents)
      response = gateway.authorize(1000, creditcard, params)

      if response.success?
        # Capture the money right away
        gateway.capture(1000, response.authorization)
        render :text => 'Hazaa!'
        raise StandardError, response.message



I also have this in my enviroment.rb

Ensure the gateway is in test mode

ActiveMerchant::Billing::Base.gateway_mode = :test

Install the key

ActiveMerchant::Billing::PaypalGateway.pem_file =
File.read(File.join(RAILS_ROOT, ‘config’, ‘paypal’, ‘test.pem’))

does anyone have any idea why this is happening? any help would be
really appreciated.

you can see the page that is throwing the error here


cheers guys,


Graham D. wrote:

I am trying to get up and running using active merchant

It looks to me like you’re trying to test against the regular Paypal

Paypal Pro is a completely different system, with a completely different
test server!

–Al Evans