Giter Club home page Giter Club logo

Comments (4)

rafaelivan avatar rafaelivan commented on August 23, 2024

julio336,

Do you already have your client_id and client_secret on MercadoPago?

from mercadopago.

julio336 avatar julio336 commented on August 23, 2024

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.

from mercadopago.

julio336 avatar julio336 commented on August 23, 2024

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"=> "[email protected]"
},
"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?

from mercadopago.

rafaelivan avatar rafaelivan commented on August 23, 2024

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.

from mercadopago.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.