PayPalRecurringGateway for direct #357

Closed
glideranderson opened this Issue May 7, 2012 · 16 comments

Comments

Projects
None yet
6 participants
@glideranderson

I see paypal express has recurring payments support, why not for the paypal gateway? I have seen people build classes (https://gist.github.com/1058090) for the paypal gateway. I see you have the paypal_recurring_api.rb. Is there a way to access this module thru paypal gateway?

Any help would be much appreciated, need recurring payments thru paypal!!

Thanks for the awesome gem!

@ntalbott

This comment has been minimized.

Show comment Hide comment
@ntalbott

ntalbott May 7, 2012

Contributor

PaypalRecurringApi is included in PaypalGateway, so all those methods should be available to you through the latter.

Because of the sprawling nature of ActiveMerchant, none of us are really experts on the whole codebase. Your best bet with questions like this is to read the code (and check out the tests if they're there) to see how to use the API.

Hope this helps!

Contributor

ntalbott commented May 7, 2012

PaypalRecurringApi is included in PaypalGateway, so all those methods should be available to you through the latter.

Because of the sprawling nature of ActiveMerchant, none of us are really experts on the whole codebase. Your best bet with questions like this is to read the code (and check out the tests if they're there) to see how to use the API.

Hope this helps!

@glideranderson

This comment has been minimized.

Show comment Hide comment
@glideranderson

glideranderson May 7, 2012

I thought so too. However I tried accessing the recurring api methods like other methods (authorize, capture) with no success. (my authorize works so I know I have the gateway set up properly) However, I do not understand enough to know how to access the api. If anyone can help with some code examples I WOULD LOVE IT :)

Is the next best thing if I cannot access api: http://blog.matthodan.com/how-to-add-support-for-paypal-website-payment

I thought so too. However I tried accessing the recurring api methods like other methods (authorize, capture) with no success. (my authorize works so I know I have the gateway set up properly) However, I do not understand enough to know how to access the api. If anyone can help with some code examples I WOULD LOVE IT :)

Is the next best thing if I cannot access api: http://blog.matthodan.com/how-to-add-support-for-paypal-website-payment

@ntalbott

This comment has been minimized.

Show comment Hide comment
@ntalbott

ntalbott May 7, 2012

Contributor

Can you drop some sample code here that shows how you're trying to access those methods? You might also want to try asking on the ActiveMerchant mailing list.

Contributor

ntalbott commented May 7, 2012

Can you drop some sample code here that shows how you're trying to access those methods? You might also want to try asking on the ActiveMerchant mailing list.

@hjelmeir

This comment has been minimized.

Show comment Hide comment
@hjelmeir

hjelmeir May 8, 2012

This is what I want: https://gist.github.com/2631732

I am still new to Rails, so I apologize if this is a noob question :)

hjelmeir commented May 8, 2012

This is what I want: https://gist.github.com/2631732

I am still new to Rails, so I apologize if this is a noob question :)

@ntalbott

This comment has been minimized.

Show comment Hide comment
@ntalbott

ntalbott May 8, 2012

Contributor

What version of the ActiveMerchant gem are you using?

Contributor

ntalbott commented May 8, 2012

What version of the ActiveMerchant gem are you using?

@glideranderson

This comment has been minimized.

Show comment Hide comment
@glideranderson

glideranderson May 8, 2012

ActiveMerchant 1.21.0

I think it has something to do with namespacing, but I not sure yet

ActiveMerchant 1.21.0

I think it has something to do with namespacing, but I not sure yet

@ntalbott

This comment has been minimized.

Show comment Hide comment
@ntalbott

ntalbott May 8, 2012

Contributor

If I do exactly what your gist does, but cut out the Rails config stuff, the method seems to be there and just waiting for the right arguments.:

irb(main):014:0> payment_gateway = ActiveMerchant::Billing::PaypalGateway.new(
irb(main):015:1*           :login => 'rander_1307553309_biz_api1.glideint.com',
irb(main):016:1*           :password => '1307553332',
irb(main):017:1*           :signature => 'AiCozzWYgDEkMhTodrzOjnIvAbX.AQp38EXocUyf0PKAjIPmXhTGJHKv')
=> #<ActiveMerchant::Billing::PaypalGateway:0x007f888cb43ef0 @options={:pem=>nil, :signature=>"AiCozzWYgDEkMhTodrzOjnIvAbX.AQp38EXocUyf0PKAjIPmXhTGJHKv", :headers=>{}, :login=>"rander_1307553309_biz_api1.glideint.com", :password=>"1307553332"}>
irb(main):018:0> payment_gateway.recurring
ArgumentError: wrong number of arguments (0 for 2)
    from /Users/ntalbott/git/active_merchant/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb:27:in `recurring'
    from (irb):18
    from /Users/ntalbott/.rbenv/versions/1.9.3-p125/bin/irb:12:in `<main>'

No idea what's up with using the Rails config, but I don't think this is an ActiveMerchant issue.

Contributor

ntalbott commented May 8, 2012

If I do exactly what your gist does, but cut out the Rails config stuff, the method seems to be there and just waiting for the right arguments.:

irb(main):014:0> payment_gateway = ActiveMerchant::Billing::PaypalGateway.new(
irb(main):015:1*           :login => 'rander_1307553309_biz_api1.glideint.com',
irb(main):016:1*           :password => '1307553332',
irb(main):017:1*           :signature => 'AiCozzWYgDEkMhTodrzOjnIvAbX.AQp38EXocUyf0PKAjIPmXhTGJHKv')
=> #<ActiveMerchant::Billing::PaypalGateway:0x007f888cb43ef0 @options={:pem=>nil, :signature=>"AiCozzWYgDEkMhTodrzOjnIvAbX.AQp38EXocUyf0PKAjIPmXhTGJHKv", :headers=>{}, :login=>"rander_1307553309_biz_api1.glideint.com", :password=>"1307553332"}>
irb(main):018:0> payment_gateway.recurring
ArgumentError: wrong number of arguments (0 for 2)
    from /Users/ntalbott/git/active_merchant/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb:27:in `recurring'
    from (irb):18
    from /Users/ntalbott/.rbenv/versions/1.9.3-p125/bin/irb:12:in `<main>'

No idea what's up with using the Rails config, but I don't think this is an ActiveMerchant issue.

@ntalbott ntalbott closed this May 8, 2012

@glideranderson

This comment has been minimized.

Show comment Hide comment
@glideranderson

glideranderson May 9, 2012

my issue might be that I set activemerchant into test mode or that my environment is in development, I even tried on a fresh install of rails, with just active merchant. went in rails console, set payment_gateway to the above, tried to call method recurring with response no such method.

ActiveMerchant::Billing::Base.mode = :test

In the below output, I did not set active merchant to test mode, and I tried in both development and production mode with no success

Loading development environment (Rails 3.2.2)
1.9.3-p0 :001 > payment_gateway = ActiveMerchant::Billing::PaypalGateway.new(
1.9.3-p0 :002 >           :login => 'rander_1307553309_biz_api1.glideint.com',
1.9.3-p0 :003 >           :password => '1307553332',
1.9.3-p0 :004 >           :signature => 'AiCozzWYgDEkMhTodrzOjnIvAbX.AQp38EXocUyf0PKAjIPmXhTGJHKv')
 => #<ActiveMerchant::Billing::PaypalGateway:0x007fb07570f288 @options={:pem=>nil, :signature=>"AiCozzWYgDEkMhTodrzOjnIvAbX.AQp38EXocUyf0PKAjIPmXhTGJHKv", :headers=>{}, :login=>"rander_1307553309_biz_api1.glideint.com", :password=>"1307553332"}> 
1.9.3-p0 :005 > payment_gateway.recurring
NoMethodError: undefined method `recurring' for #<ActiveMerchant::Billing::PaypalGateway:0x007fb07570f288>
    from (irb):5
    from /Users/robin/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.2/lib/rails/commands/console.rb:47:in `start'
    from /Users/robin/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.2/lib/rails/commands/console.rb:8:in `start'
    from /Users/robin/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.2/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

my issue might be that I set activemerchant into test mode or that my environment is in development, I even tried on a fresh install of rails, with just active merchant. went in rails console, set payment_gateway to the above, tried to call method recurring with response no such method.

ActiveMerchant::Billing::Base.mode = :test

In the below output, I did not set active merchant to test mode, and I tried in both development and production mode with no success

Loading development environment (Rails 3.2.2)
1.9.3-p0 :001 > payment_gateway = ActiveMerchant::Billing::PaypalGateway.new(
1.9.3-p0 :002 >           :login => 'rander_1307553309_biz_api1.glideint.com',
1.9.3-p0 :003 >           :password => '1307553332',
1.9.3-p0 :004 >           :signature => 'AiCozzWYgDEkMhTodrzOjnIvAbX.AQp38EXocUyf0PKAjIPmXhTGJHKv')
 => #<ActiveMerchant::Billing::PaypalGateway:0x007fb07570f288 @options={:pem=>nil, :signature=>"AiCozzWYgDEkMhTodrzOjnIvAbX.AQp38EXocUyf0PKAjIPmXhTGJHKv", :headers=>{}, :login=>"rander_1307553309_biz_api1.glideint.com", :password=>"1307553332"}> 
1.9.3-p0 :005 > payment_gateway.recurring
NoMethodError: undefined method `recurring' for #<ActiveMerchant::Billing::PaypalGateway:0x007fb07570f288>
    from (irb):5
    from /Users/robin/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.2/lib/rails/commands/console.rb:47:in `start'
    from /Users/robin/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.2/lib/rails/commands/console.rb:8:in `start'
    from /Users/robin/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.2/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'
@ntalbott

This comment has been minimized.

Show comment Hide comment
@ntalbott

ntalbott May 9, 2012

Contributor

Doesn't look like it:

irb(main):009:0> require 'activemerchant'
=> true
irb(main):010:0> payment_gateway = ActiveMerchant::Billing::PaypalGateway.new(
irb(main):011:1*                :login => 'rander_1307553309_biz_api1.glideint.com',
irb(main):012:1*                :password => '1307553332',
irb(main):013:1*                :signature => 'AiCozzWYgDEkMhTodrzOjnIvAbX.AQp38EXocUyf0PKAjIPmXhTGJHKv')
=> #<ActiveMerchant::Billing::PaypalGateway:0x007ff8cb23d1f8 @options={:pem=>nil, :signature=>"AiCozzWYgDEkMhTodrzOjnIvAbX.AQp38EXocUyf0PKAjIPmXhTGJHKv", :headers=>{}, :login=>"rander_1307553309_biz_api1.glideint.com", :password=>"1307553332"}>
irb(main):014:0> ActiveMerchant::Billing::Base.mode = :test
=> :test
irb(main):015:0> payment_gateway.recurring
ArgumentError: wrong number of arguments (0 for 2)
    from /Users/ntalbott/git/active_merchant/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb:27:in `recurring'
    from (irb):15
    from /Users/ntalbott/.rbenv/versions/1.9.3-p125/bin/irb:12:in `<main>'
Contributor

ntalbott commented May 9, 2012

Doesn't look like it:

irb(main):009:0> require 'activemerchant'
=> true
irb(main):010:0> payment_gateway = ActiveMerchant::Billing::PaypalGateway.new(
irb(main):011:1*                :login => 'rander_1307553309_biz_api1.glideint.com',
irb(main):012:1*                :password => '1307553332',
irb(main):013:1*                :signature => 'AiCozzWYgDEkMhTodrzOjnIvAbX.AQp38EXocUyf0PKAjIPmXhTGJHKv')
=> #<ActiveMerchant::Billing::PaypalGateway:0x007ff8cb23d1f8 @options={:pem=>nil, :signature=>"AiCozzWYgDEkMhTodrzOjnIvAbX.AQp38EXocUyf0PKAjIPmXhTGJHKv", :headers=>{}, :login=>"rander_1307553309_biz_api1.glideint.com", :password=>"1307553332"}>
irb(main):014:0> ActiveMerchant::Billing::Base.mode = :test
=> :test
irb(main):015:0> payment_gateway.recurring
ArgumentError: wrong number of arguments (0 for 2)
    from /Users/ntalbott/git/active_merchant/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb:27:in `recurring'
    from (irb):15
    from /Users/ntalbott/.rbenv/versions/1.9.3-p125/bin/irb:12:in `<main>'
@glideranderson

This comment has been minimized.

Show comment Hide comment
@glideranderson

glideranderson May 10, 2012

I tried on brand new rails app with only active merchant. Went to rails console did the above code, with result of undefined method 'recurring'.

This is very puzzling to me: on Rails 3.2.2, activemerchant 1.21.0, with ruby 1.9.3-p0

this is my gemfile.lock

GEM
remote: https://rubygems.org/
specs:
actionmailer (3.2.2)
actionpack (= 3.2.2)
mail (> 2.4.0)
actionpack (3.2.2)
activemodel (= 3.2.2)
activesupport (= 3.2.2)
builder (
> 3.0.0)
erubis (> 2.7.0)
journey (
> 1.0.1)
rack (> 1.4.0)
rack-cache (
> 1.1)
rack-test (> 0.6.1)
sprockets (
> 2.1.2)
active_utils (1.0.3)
activesupport (>= 2.3.11)
i18n
activemerchant (1.21.0)
active_utils (>= 1.0.2)
activesupport (>= 2.3.11)
builder (>= 2.0.0)
i18n
json (>= 1.5.1)
money (<= 3.7.1)
activemodel (3.2.2)
activesupport (= 3.2.2)
builder (> 3.0.0)
activerecord (3.2.2)
activemodel (= 3.2.2)
activesupport (= 3.2.2)
arel (
> 3.0.2)
tzinfo (> 0.3.29)
activeresource (3.2.2)
activemodel (= 3.2.2)
activesupport (= 3.2.2)
activesupport (3.2.2)
i18n (
> 0.6)
multi_json (> 1.0)
arel (3.0.2)
builder (3.0.0)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
railties (
> 3.2.0)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.3.1)
erubis (2.7.0)
execjs (1.3.2)
multi_json (> 1.0)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.3)
jquery-rails (2.0.2)
railties (>= 3.2.0, < 5.0)
thor (
> 0.14)
json (1.7.1)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (> 1.16)
treetop (
> 1.4.8)
mime-types (1.18)
money (3.7.1)
i18n (> 0.4)
multi_json (1.3.4)
mysql2 (0.3.11)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
rack (>= 0.4)
rack-ssl (1.3.2)
rack
rack-test (0.6.1)
rack (>= 1.0)
rails (3.2.2)
actionmailer (= 3.2.2)
actionpack (= 3.2.2)
activerecord (= 3.2.2)
activeresource (= 3.2.2)
activesupport (= 3.2.2)
bundler (
> 1.0)
railties (= 3.2.2)
railties (3.2.2)
actionpack (= 3.2.2)
activesupport (= 3.2.2)
rack-ssl (> 1.3.2)
rake (>= 0.8.7)
rdoc (
> 3.4)
thor (> 0.14.6)
rake (0.9.2.2)
rdoc (3.12)
json (
> 1.4)
sass (3.1.17)
sass-rails (3.2.5)
railties (> 3.2.0)
sass (>= 3.1.10)
tilt (
> 1.3)
sprockets (2.1.3)
hike (> 1.2)
rack (
> 1.0)
tilt (~> 1.1, != 1.3.0)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.33)
uglifier (1.2.4)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)

PLATFORMS
ruby

DEPENDENCIES
activemerchant
coffee-rails (> 3.2.1)
jquery-rails
mime-types
mysql2
rails (= 3.2.2)
sass-rails (
> 3.2.3)
uglifier (>= 1.0.3)

I tried on brand new rails app with only active merchant. Went to rails console did the above code, with result of undefined method 'recurring'.

This is very puzzling to me: on Rails 3.2.2, activemerchant 1.21.0, with ruby 1.9.3-p0

this is my gemfile.lock

GEM
remote: https://rubygems.org/
specs:
actionmailer (3.2.2)
actionpack (= 3.2.2)
mail (> 2.4.0)
actionpack (3.2.2)
activemodel (= 3.2.2)
activesupport (= 3.2.2)
builder (
> 3.0.0)
erubis (> 2.7.0)
journey (
> 1.0.1)
rack (> 1.4.0)
rack-cache (
> 1.1)
rack-test (> 0.6.1)
sprockets (
> 2.1.2)
active_utils (1.0.3)
activesupport (>= 2.3.11)
i18n
activemerchant (1.21.0)
active_utils (>= 1.0.2)
activesupport (>= 2.3.11)
builder (>= 2.0.0)
i18n
json (>= 1.5.1)
money (<= 3.7.1)
activemodel (3.2.2)
activesupport (= 3.2.2)
builder (> 3.0.0)
activerecord (3.2.2)
activemodel (= 3.2.2)
activesupport (= 3.2.2)
arel (
> 3.0.2)
tzinfo (> 0.3.29)
activeresource (3.2.2)
activemodel (= 3.2.2)
activesupport (= 3.2.2)
activesupport (3.2.2)
i18n (
> 0.6)
multi_json (> 1.0)
arel (3.0.2)
builder (3.0.0)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
railties (
> 3.2.0)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.3.1)
erubis (2.7.0)
execjs (1.3.2)
multi_json (> 1.0)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.3)
jquery-rails (2.0.2)
railties (>= 3.2.0, < 5.0)
thor (
> 0.14)
json (1.7.1)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (> 1.16)
treetop (
> 1.4.8)
mime-types (1.18)
money (3.7.1)
i18n (> 0.4)
multi_json (1.3.4)
mysql2 (0.3.11)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
rack (>= 0.4)
rack-ssl (1.3.2)
rack
rack-test (0.6.1)
rack (>= 1.0)
rails (3.2.2)
actionmailer (= 3.2.2)
actionpack (= 3.2.2)
activerecord (= 3.2.2)
activeresource (= 3.2.2)
activesupport (= 3.2.2)
bundler (
> 1.0)
railties (= 3.2.2)
railties (3.2.2)
actionpack (= 3.2.2)
activesupport (= 3.2.2)
rack-ssl (> 1.3.2)
rake (>= 0.8.7)
rdoc (
> 3.4)
thor (> 0.14.6)
rake (0.9.2.2)
rdoc (3.12)
json (
> 1.4)
sass (3.1.17)
sass-rails (3.2.5)
railties (> 3.2.0)
sass (>= 3.1.10)
tilt (
> 1.3)
sprockets (2.1.3)
hike (> 1.2)
rack (
> 1.0)
tilt (~> 1.1, != 1.3.0)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.33)
uglifier (1.2.4)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)

PLATFORMS
ruby

DEPENDENCIES
activemerchant
coffee-rails (> 3.2.1)
jquery-rails
mime-types
mysql2
rails (= 3.2.2)
sass-rails (
> 3.2.3)
uglifier (>= 1.0.3)

@glideranderson

This comment has been minimized.

Show comment Hide comment
@glideranderson

glideranderson May 10, 2012

SOLVED: activemerchant 1.21.0 doesn't have the paypal recurring api, added :git option in gemfile and works on coworkers machine but not mine (something is wrong with my machine)

SOLVED: activemerchant 1.21.0 doesn't have the paypal recurring api, added :git option in gemfile and works on coworkers machine but not mine (something is wrong with my machine)

@ntalbott

This comment has been minimized.

Show comment Hide comment
@ntalbott

ntalbott May 10, 2012

Contributor

Oh, didn't realize it was that new. We should be cutting a new gem version pretty soon.

Contributor

ntalbott commented May 10, 2012

Oh, didn't realize it was that new. We should be cutting a new gem version pretty soon.

@brian5150

This comment has been minimized.

Show comment Hide comment
@brian5150

brian5150 Aug 6, 2012

Does this allow the use of Paypal recurring features using Paypal Website Pro or do you have to purchase Paypal Payflow Pro? If the former, it eliminates the need to move from Paypal to Authorize.net or some other merchant account, true?

Thanks!

Does this allow the use of Paypal recurring features using Paypal Website Pro or do you have to purchase Paypal Payflow Pro? If the former, it eliminates the need to move from Paypal to Authorize.net or some other merchant account, true?

Thanks!

@ntalbott

This comment has been minimized.

Show comment Hide comment
@ntalbott

ntalbott Aug 23, 2012

Contributor

@brian5150 not sure - you'd have to peruse the code and see.

Contributor

ntalbott commented Aug 23, 2012

@brian5150 not sure - you'd have to peruse the code and see.

@robconery

This comment has been minimized.

Show comment Hide comment
@robconery

robconery Sep 29, 2012

I have this issue as well - with the PaypalExpressGateway. The recurring bits aren't included, it seems:
https://github.com/Shopify/active_merchant/blob/master/lib/active_merchant/billing/gateways/paypal_express.rb

Note that PaypalCommon and PaypalExpressCommon are included, however PaypalRecurringApi is not.

I have this issue as well - with the PaypalExpressGateway. The recurring bits aren't included, it seems:
https://github.com/Shopify/active_merchant/blob/master/lib/active_merchant/billing/gateways/paypal_express.rb

Note that PaypalCommon and PaypalExpressCommon are included, however PaypalRecurringApi is not.

@aklein-dex

This comment has been minimized.

Show comment Hide comment
@aklein-dex

aklein-dex Nov 1, 2012

+1 robconery
In the doc it says

Overview
This module is included in both PaypalGateway and PaypalExpressGateway

But it's not included in PaypalExpressGateway:

require File.dirname(__FILE__) + '/paypal/paypal_common_api'
require File.dirname(__FILE__) + '/paypal/paypal_express_response'
require File.dirname(__FILE__) + '/paypal_express_common'

module ActiveMerchant #:nodoc:
....

+1 robconery
In the doc it says

Overview
This module is included in both PaypalGateway and PaypalExpressGateway

But it's not included in PaypalExpressGateway:

require File.dirname(__FILE__) + '/paypal/paypal_common_api'
require File.dirname(__FILE__) + '/paypal/paypal_express_response'
require File.dirname(__FILE__) + '/paypal_express_common'

module ActiveMerchant #:nodoc:
....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment