Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"NoMethodError: undefined method `[]' for nil:NilClass" when using Stripe/Webpay gateway to store customer #1864

Closed
tapalilov opened this issue Sep 4, 2015 · 5 comments

Comments

@tapalilov
Copy link

When i updated active merchant start to get this errors:
NoMethodError: undefined method []' for nil:NilClass`

Ive tried to add :email and :description options but result are above error.
It is something changed or need to add extra parameters?

Best regards,
Georgi.

with activemerchant 1.53

[1] pry(main)> credit_card = ActiveMerchant::Billing::CreditCard.new(
[1] pry(main)*   :first_name         => 'Bob',                
[1] pry(main)*   :last_name          => 'Bobsen',                
[1] pry(main)*   :number             => '4242424242424242',                
[1] pry(main)*   :month              => '8',                
[1] pry(main)*   :year               => Time.now.year+1,                
[1] pry(main)* :verification_value => '000')                  
=> #<ActiveMerchant::Billing::CreditCard:0x000000040c61c0 @first_name="Bob", @last_name="Bobsen", @month=8, @number="4242424242424242", @verification_value="000", @year=2016>
[2] pry(main)> GATEWAY.store(credit_card)
NoMethodError: undefined method `[]' for nil:NilClass
from /home/georgi/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activemerchant-1.53.0/lib/active_merchant/billing/gateways/stripe.rb:464:in `authorization_from'

with activemerchant 1.46

[1] pry(main)> credit_card = ActiveMerchant::Billing::CreditCard.new(
[1] pry(main)*   :first_name         => 'Bob',                
[1] pry(main)*   :last_name          => 'Bobsen',                
[1] pry(main)*   :number             => '4242424242424242',                
[1] pry(main)*   :month              => '8',                
[1] pry(main)*   :year               => Time.now.year+1,                
[1] pry(main)* :verification_value => '000')                  
=> #<ActiveMerchant::Billing::CreditCard:0x000000062dbaf8 @first_name="Bob", @last_name="Bobsen", @month=8, @number="4242424242424242", @verification_value="000", @year=2016>

[2] pry(main)> GATEWAY.store(credit_card)
=> #<ActiveMerchant::Billing::Response:0x0000000607e300
 @authorization="cus_fxraaJedZ01Z6b7",
 @avs_result={"code"=>nil, "message"=>nil, "street_match"=>nil, "postal_match"=>nil},
 @cvv_result={"code"=>"M", "message"=>"CVV matches"},
 @error_code=nil,
 @fraud_review=nil,
 @message="Transaction approved",
 @params=
  {"id"=>"cus_xxxxxxx",
   "object"=>"customer",
   "livemode"=>false,
   "created"=>1441382808,
   "email"=>nil,
   "description"=>nil,
   "active_card"=>{"object"=>"card", "exp_year"=>2016, "exp_month"=>8, "fingerprint"=>"215b5b2fe460809b8bb90bae6eeac0e0e0987bd7", "name"=>"Bob Bobsen", "country"=>"JP", "type"=>"Visa", "cvc_check"=>"pass", "last4"=>"4242"},
   "recursions"=>[]},
 @success=true,
 @test=true>

@ntalbott
Copy link
Contributor

ntalbott commented Sep 4, 2015

@tapalilov the challenge is that the remote tests for this are passing - just checked. Can you get a dump of the data being returned from Stripe that's causing the code to blow up?

@tapalilov
Copy link
Author

@ntalbott i`m using webpay gateway which inherit from stripe. I didnt get any data from gateway. How to dump data from gateway?

edit:
i`m getting this from gateway:

RuntimeError: {"id"=>"cus_fBz1JK8Wra5H8uT", "object"=>"customer", "livemode"=>false, "created"=>1441404954, "email"=>nil, "description"=>nil, "active_card"=>{"object"=>"card", "exp_year"=>2016, "exp_month"=>8, "fingerprint"=>"215b5b2fe460809b8bb90bae6eeac0e0e0987bd7", "name"=>"Bob Bobsen", "country"=>"JP", "type"=>"Visa", "cvc_check"=>"pass", "last4"=>"4242"}, "recursions"=>[]}

edit 2:
i checked commits and i`m almost sure that problem come from here:
808a142#diff-8299be227de5ba32c34c30c42a828c9cL441

@ntalbott
Copy link
Contributor

ntalbott commented Sep 5, 2015

Does the issue show up in the remote tests for Webpay?

I'm actually not surprised this is breaking; extending the Stripe gateway, which changes rapidly, probably wasn't the best idea. Fixing this will definitely need to happen in Webpay, likely by copying big chunks of Stripe into it so they can change independently.

I'd love to see a PR that fixes this by moving the offending code into Webpay and making the necessary tweaks - thanks!

@tapalilov
Copy link
Author

Okey. Will make PR and will try to make tests to not have issues like this in future.

Best regards,
Georgi.

@bpollack
Copy link
Contributor

Seems like this has been resolved; closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants