2

I'm using the mercadopago-sdk gem, to create customers by API sending email addresses but I'm getting an error code that's not even on the documentation page

response = Mercadopago::SDK.new('access-token').customer.create(email: 'test_123@gmail.com')

Response

{:status=>400, :response=>{"message"=>"invalid parameters ", "error"=>"bad_request", "status"=>400, "cause"=>[{"code"=>"130", "description"=>"Invalid customer data"}]}}

Documentation https://www.mercadopago.com.ar/developers/es/reference/customers/_customers/post

  • Ruby: 2.6.6

  • mercadopago-sdk (2.0.1)

Community
  • 1
  • 1
Javier Menéndez Rizo
  • 2,138
  • 3
  • 12
  • 22

1 Answers1

0

Try passing the hash explicitly:

Mercadopago::SDK.new('access-token').customer.create({ email: 'test_123@gmail.com' })

If it doesn't help, check that you are using the latest version of mercadopago-sdk gem (right now it seems to be 2.1.0). Why I am mentioning this is because on the latest gem when I try to run the line you wrote in your question (using the access token from their test code) it gives me a different error

gems/mercadopago-sdk-2.1.0/lib/mercadopago/resources/customer.rb:20:in `create': wrong number of arguments (given 0, expected 1) (ArgumentError)

which makes me suspect you are using the old gem version if you get a different error.

If that doesn't work also check the code of their tests. Maybe they expect more parameters from your access token, not just an email of a customer but also their name, address, etc.

If that doesn't help either your best bet might be contacting them directly.

  • Since I'm using ruby 2.6 that doesn't matter, either way, I tested both ways and it happens the same. I don't think this is a problem with the SDK, probably is something internal to mercadopago itself. The same code works ok with others mercadopago accounts – Javier Menéndez Rizo Oct 04 '22 at 13:10
  • Oh, if it's working with other accounts then you definitely should contact them directly, maybe you have some limitations set on this particular account (access token) which require you to send more data when you create customers. – Dmytro Savochkin Oct 04 '22 at 13:38