conekta / conekta-ruby

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

Error when calling Conekta::Charge.create: "Line items están vacíos." #65

Closed holamendi closed 7 years ago

holamendi commented 7 years ago

I'm getting the error "Line items están vacíos." when calling Conekta::Charge.create. The error happened in test and livemode, using version '0.5.7', which was working fine for several months, so I'm assuming it was due to some API changes. I'm using the default API version.

The object passed in test mode was:

{:amount=>150100, 
:currency=>"MXN",
 :description=>"Compra en mendi", 
:reference_id=>"139FD543", 
:details=>{:line_items=>[[{:name=>"Silla Madera", :description=>"Sin variante", :unit_price=>150000, :quantity=>1, :sku=>nil}]], 
:shipment=>{:carrier=>"Chile", :service=>"Chile", :price=>100, :address=>{:street1=>"23322332", :street2=>nil, :street3=>nil, :city=>"Cochrane", :state=>"Aisén del General Carlos Ibáñez del Campo", :zip=>nil, :country=>"Chile"}}, :name=>"Pablo Orellana", :email=>"xxx@xxx.com", :phone=>"123123123"}, 
:card=>"tok_2g5SjadcY7tjEYbxC"}

This totally broke our payments integration through Conekta. Hopefully you can give me a hand with this soon.

MauricioMurga commented 7 years ago

I'm sorry for the problems you may have. The only thing that seems strange is that line items has a nested array which can cause problems. Are you sure this worked before?

holamendi commented 7 years ago

@MauricioMurga removing that extra array did the trick! We haven't touched that code for a few months and it was working with that nested array, I found a few transactions in our logs from a few days ago.

I removed sensitive information from the logs, this is from production environment. February 23th.

Feb 23 06:51:35 spincommerce-store app/web.1:  conekta.payment | {:amount=>310000, :currency=>"MXN", :description=>"Compra en Monica Xerrano", :reference_id=>"0D125EFC", :details=>{:line_items=>[[{:name=>"xxx", :description=>"Sin variante", :unit_price=>310000, :quantity=>1, :sku=>nil}]], :shipment=>{:carrier=>"Compra  Recuperacion", :service=>"Compra  Recuperacion", :price=>0, :address=>{:street1=>"xxx", :street2=>nil, :street3=>nil, :city=>"Tijuana", :state=>"Baja California", :zip=>"xxx", :country=>"México"}}, :name=>"xxx ", :email=>"xxx", :phone=>"xxx"}, :card=>"xxx"} 
Feb 23 06:51:39 spincommerce-store heroku/router:  at=info method=POST path="/monicaxerrano/0D125EFC/payments/conekta" host=checkout.spincommerce.com request_id=adf5d0af-c0ac-4ba8-9e58-b5709cb6fd9a fwd="xxx" dyno=web.1 connect=1ms service=4389ms status=302 bytes=777 
Feb 23 06:51:39 spincommerce-store app/web.1:  conekta.payment | charge_response: {"id"=>"xxx", "livemode"=>true, "created_at"=>1487829095, "status"=>"paid", "currency"=>"MXN", "description"=>"xxx", "reference_id"=>"0D125EFC", "failure_code"=>nil, "failure_message"=>nil, "monthly_installments"=>nil, "device_fingerprint"=>"xxx", "refunds"=>[], "payment_method"=>{"name"=>"xxx ", "exp_month"=>"03", "exp_year"=>"17", "auth_code"=>"xxx", "object"=>"card_payment", "type"=>"credit", "normalized_device_fingerprint"=>nil, "last4"=>"xxx", "brand"=>"mc", "issuer"=>"SCOTIABANK INVERLAT", "account_type"=>"", "country"=>"MX", "fraud_score"=>19, "fraud_indicators"=>[]}, "details"=>{"name"=>"xxx", "phone"=>"xxx", "email"=>"xxx", "line_items"=>[nil], "coupons"=>[], "shipment"=>{"carrier"=>"Compra  Recuperacion", "service"=>"Compra  Recuperacion", "tracking_id"=>nil, "price"=>0, "address"=>{"street1"=>"xxx", "street2"=>nil, "street3"=>nil, "city"=>"Tijuana", "state"=>"Baja California", "zip"=>"xxx", "country"=>"mx", "object"=>"address"}, "object"=>"shipment"}, "object"=>"details"}, "object"=>"charge", "amount"=>310000, "paid_at"=>1487829099, "fee"=>10718, "customer_id"=>"", "subscription_id"=>"", "amount_refunded"=>nil} 

Thank you from your prompt response.

vrfox commented 7 years ago

I had this problem... check your api version... they changed the object structure