PayPal Express Gateway

228 views
Skip to first unread message

soichi

unread,
Apr 13, 2012, 12:28:16 AM4/13/12
to activem...@googlegroups.com
Rails 3.1.3

I would like to use PayPal Express Gateway, and I got information from Rails Casts,


First of all, in development.rb, I put, 

  config.after_initialize do
    ActiveMerchant::Billing::Base.mode = :test

    paypal_options = { 
    :login => "xxxx_biz_api1.gmail.com",
    :password => "xxxx"
    :signature => "xxxx"
    }
    ::STANDARD_GATEWAY = ActiveMerchant::Billing::PaypalGateway.new(paypal_options)
    ::EXPRESS_GATEWAY = ActiveMerchant::Billing::PaypalExpressGateway.new(paypal_options)
  end

in payments_controller.rb,

  def checkout
    setup_response = EXPRESS_GATEWAY.setup_purchase(5000,
    :ip                => request.remote_ip,
    :return_url        => url_for(:action => 'confirm', :only_path => false),
    :cancel_return_url => url_for(:action => 'index', :only_path => false)
    )
    redirect_to gateway.redirect_url_for(setup_response.token)
  end

well, this gives now an error, 

uninitialized constant PaymentsController::EXPRESS_GATEWAY
Is there anything wrong?
soichi

Nathaniel Talbott

unread,
Apr 13, 2012, 10:40:08 AM4/13/12
to activem...@googlegroups.com
For starters, I'd put the configuration in a standard initializer
rather than an after_initialize block:

config/initializers/activemerchant.rb:

ActiveMerchant::Billing::Base.mode = :test
paypal_options = {
:login => "xxxx_biz_api1.gmail.com",
:password => "xxxx"
:signature => "xxxx"
}
STANDARD_GATEWAY = ActiveMerchant::Billing::PaypalGateway.new(paypal_options)
EXPRESS_GATEWAY =
ActiveMerchant::Billing::PaypalExpressGateway.new(paypal_options)

If you do that does it work?


--
Nathaniel

> --
> You received this message because you are subscribed to the Google Groups
> "Active Merchant" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/activemerchant/-/9aYzvnl9LBcJ.
> To post to this group, send email to activem...@googlegroups.com.
> To unsubscribe from this group, send email to
> activemerchan...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/activemerchant?hl=en.

soichi

unread,
Apr 13, 2012, 9:59:38 PM4/13/12
to Active Merchant
It did work! Thanks!

soichi

Reply all
Reply to author
Forward
0 new messages