2Checkout / 2checkout-ruby

2Checkout Ruby Library
MIT License
21 stars 17 forks source link

Rails 5 issue #6

Open k2m30 opened 8 years ago

k2m30 commented 8 years ago

RAILS 5 model:

def stop_recurring!
    Twocheckout::API.credentials = {
        username: ENV['CHECKOUT_USER'],
        password: ENV['CHECKOUT_PASSWORD'],
    }
    begin
      sale = Twocheckout::Sale.find(sale_id: order_number)
      sale.stop_recurring!
    rescue Exception => e
      logger.error e.message
      logger.error e.backtrace
    end
  end

undefined method response for #<NoMethodError:0x007f81470f2dd0> Did you mean? respond_to?

/usr/local/lib/ruby/gems/2.3.0/gems/twocheckout-0.4.0/lib/twocheckout/api.rb:24:in rescue in request' /usr/local/lib/ruby/gems/2.3.0/gems/twocheckout-0.4.0/lib/twocheckout/api.rb:20:in request' /usr/local/lib/ruby/gems/2.3.0/gems/twocheckout-0.4.0/lib/twocheckout/sale.rb:5:in find' /Users/mikhail/projects/trendom/backend/app/models/user.rb:95:in stop_recurring!' /Users/mikhail/projects/trendom/backend/app/controllers/users_controller.rb:27:in cancel_subscription'


The same in plain irb works perfectly fine

calebh05 commented 8 years ago

By chance are you using the responders gem? Others on rails 5 were able to resolve similar errors by adding the responders gem (https://github.com/richpeck/exception_handler/issues/34)

k2m30 commented 8 years ago

@calebh05 No, I don't use it directly. However it is in my Gemfil.lock

    redis-namespace (1.5.2)
      redis (~> 3.0, >= 3.0.4)
    responders (2.2.0)
      railties (>= 4.2.0, < 5.1)
    resque (1.26.0)
      mono_logger (~> 1.0)
      multi_json (~> 1.0)
      redis-namespace (~> 1.3)
      sinatra (>= 0.9.2)
      vegas (~> 0.1.2)
daareiza commented 8 years ago

@k2m30, please check your rest-client version, I was able to make a request using rest-client 1.8.0 (was 1.6.7)

calebh05 commented 8 years ago

@k2m30 any luck? I'm also able to make this request using rest-client 1.8.0.

k2m30 commented 8 years ago

@daareiza @calebh05 Guys, will check tomorrow. At the moment I have rest-client (1.6.7)

frizbee commented 8 years ago

Same here, gem update rest-client helped I confirm, It works with 1.8.0

EnziinSystem commented 6 years ago

I fixed it, in the Gemfile

...
gem 'netrc', '0.11.0'
gem 'http-cookie', '1.0.3'
gem 'rest-client', '1.8.0'
gem 'twocheckout', '0.4.0'
...

Or install from github.

gem 'twocheckout', git: 'https://github.com/EnziinSystem/2checkout-ruby.git'

https://github.com/EnziinSystem/2checkout-ruby