Closed julio336 closed 11 years ago
julio336,
Do you already have your client_id and client_secret on MercadoPago?
Yes, I would like an example of how to make a checkout with MercadoPago, I hope you can help me!
By the way I have my client_id and my client_secret.
Kind regards.
I have defined a method at my products model like this:
client_id = 'xxxxx' client_secret = 'xxxxxxxxxxxxx' mp_client = MercadoPago::Client.new(client_id, client_secret)
Then I send some data, like your example:
data = { "external_reference" => "OPERATION-ID-14288", "items" => [ { "id" => "123", "title" => "Example T-Shirt", "description" => "Red XL T-Shirt", "quantity" => 1, "unit_price" => 10.50, "currency_id" => "BRL", "picture_url" => "http://www.site.com/image/123.png" } ], "payer" => { "name"=> "John", "surname"=> "Mikel", "email"=> "buyer@email.com" }, "back_urls"=> { "pending"=> "https://www.site.com/pending", "success"=> "http://www.site.com/success", "failure"=> "http://www.site.com/failure" } }
payment = mp_client.create_preference(data)
I got the Json as you said, but how can I redirect to the init_point url where is the data of the product?
I would like to know how to initialize my mercadopago count, I have code at the folder config/initializers/mercadopago.rb something like this:
client_id = 'xxxxx' client_secret = 'xxxxxxxxxxxxx' mp_client = MercadoPago::Client.new(client_id, client_secret)
But It doesn't answer, It brings some error like "mp client doesn't exists"
How can I make it work?
I'm sorry for taking so long to answer this question.
So, you were able to create the preference, right? In the response hash, MercadoPago sends the init_point UR, which you should use to redirect the buyer to the checkout page on MercadoPago.
I have no idea how to use the gem :s, where must I have to put this code???
Use your credentials
client_id = '1234' client_secret = 'abcdefghijklmnopqrstuvwxyz'
mp_client = MercadoPago::Client.new(client_id, client_secret)
And how can I send the Post request?