conekta / conekta-ruby

Ruby Bindings for Conekta
https://www.conekta.com
MIT License
31 stars 28 forks source link

undefined method `[]=' for nil:NilClass #79

Closed obelich closed 6 years ago

obelich commented 7 years ago

Hi i have install conekta 2.0.0 from https://github.com/conekta/conekta-ruby.git (at v.2.1.0@caadd58) not give the 2.1.0 and it give that error using the example and get undefined method `[]=' for nil:NilClass or Conekta::ErrorList

Conekta::Order.create({
  :currency => "MXN",
  :customer_info => {
    :customer_id => "cus_zzmjKsnM9oacyCwV3"
  },
  :line_items => [{
    :name => "Box of Cohiba S1s",
    :unit_price => 35000,
    :quantity => 1
  }],
  :charges => [{
    :payment_method => {
      :type => "default"
    }
  }]
})
edenriquez commented 6 years ago

Hi @obelich I just did a clean installation and a test creating an Order and everything its ok, all your specs run fine? this is my output

 Conekta::Order.create({
2.3.0 :069 >         :currency => "MXN",
2.3.0 :070 >         :customer_info => {
2.3.0 :071 >             :customer_id => "cus_2hkYSut6QctwH8Pqv"
2.3.0 :072?>         },
2.3.0 :073 >         :line_items => [{
2.3.0 :074 >               :name => "Box of Cohiba S1s",
2.3.0 :075 >               :unit_price => 35000,
2.3.0 :076 >               :quantity => 1
2.3.0 :077?>           }],
2.3.0 :078 >         :charges => [{
2.3.0 :079 >               :payment_method => {
2.3.0 :080 >                   :type => "default"
2.3.0 :081?>               }
2.3.0 :082?>           }]
2.3.0 :083?>     })
 => {"livemode"=>false, "amount"=>35000, "currency"=>"MXN", "payment_status"=>"paid", "amount_refunded"=>0, "customer_info"=>{"email"=>"usuario@example.com", "phone"=>"+5215555555555", "name"=>"Mario Perez", "corporate"=>false, "customer_id"=>"cus_2hkYSut6QctwH8Pqv", "object"=>"customer_info"}, "shipping_contact"=>{"receiver"=>"Marvin Fuller", "phone"=>"+5215555555555", "address"=>{"street1"=>"Nuevo Leon 4", "country"=>"mx", "residential"=>true, "object"=>"shipping_address", "postal_code"=>"06100"}, "id"=>"ship_cont_2hkYTUN9KPfV2MTyM", "object"=>"shipping_contact", "created_at"=>0}, "object"=>"order", "id"=>"ord_2hkYTUN9KPfV2MTyN", "metadata"=>{}, "created_at"=>1513702389, "updated_at"=>1513702398, "line_items"=>{0=>{"name"=>"Box of Cohiba S1s", "unit_price"=>35000, "quantity"=>1, "object"=>"line_item", "id"=>"line_item_2hkYTUN9KPfV2MTyK", "parent_id"=>"ord_2hkYTUN9KPfV2MTyN", "metadata"=>{}, "antifraud_info"=>{}}}, "charges"=>{0=>{"id"=>"5a3943f5edbb6e56d87c5aa5", "livemode"=>false, "created_at"=>1513702389, "currency"=>"MXN", "device_fingerprint"=>"123456789abcdefghijkmnopqrstuv", "payment_method"=>{"name"=>"Jorge Lopez", "exp_month"=>"12", "exp_year"=>"19", "auth_code"=>"537123", "object"=>"card_payment", "type"=>"credit", "last4"=>"4242", "brand"=>"visa", "issuer"=>"", "account_type"=>"", "country"=>"US", "fraud_score"=>34, "fraud_indicators"=>[]}, "object"=>"charge", "description"=>"Payment from order", "status"=>"paid", "amount"=>35000, "paid_at"=>1513702398, "fee"=>1467, "customer_id"=>"cus_2hkYSut6QctwH8Pqv", "order_id"=>"ord_2hkYTUN9KPfV2MTyN"}}}

My current version also is v2.1.0

ulices commented 6 years ago

Hi @eduardoconekta

I have the same error when trying to create a new customer, I think the problem is when conketa is trying to generate the error list not in creating or not the resource (Order or Customer), so if we are not able to get the errors list we don't know what we are doing wrong in our request.

edenriquez commented 6 years ago

Hi @ulices can you create a gist recreating your steps using conekta-ruby ? I think i will reproduce the error if you give me some info, what are the calls you are trying to make, params send, etc

ulices commented 6 years ago

Hi @eduardoconekta

I created a gist with the methods we are using to create our request:

https://gist.github.com/ulices/469247a0764b82dd2efdc3af5533ded2

Thanks

edenriquez commented 6 years ago

thanks @ulices we will fix this as son as posible 👍

obelich commented 6 years ago

hiyas @ulices go to https://admin.conekta.com/logs?page=1 and you can see what is the attribute is missing

edenriquez commented 6 years ago

@obelich , @ulices have you tried our latest release ?

https://github.com/conekta/conekta-ruby/releases/tag/v2.3.0

I can see whats the error with this release

https://gist.github.com/eduardoconekta/3d8b016ac1a1406553e6800f3133de48

edenriquez commented 6 years ago

@ulices you can check at conekta-ruby/spec/conekta/2.0.0/order_spec.rb:42

  let(:line_items) do
    [{
      name: "Box of Cohiba S1s",
      description: "Imported From Mex.",
      unit_price: 35000,
      quantity: 1,
      tags: ["food", "mexican food"]
    }]
  end

how to send line_items

also your Conekta api_version should be '2.0.0'

ulices commented 6 years ago

Thanks @eduardoconekta and @obelich I'm going to made the changes and try again :)