The official Mercado Pago SDK for Ruby applications.
Integrate Mercado Pago APIs into your Ruby application and start receiving payments.
Installation · Getting started · Documentation · Contributing
Ruby version 3.3 or greater.
Run gem install mercadopago-sdk
First time using Mercado Pago? Create your Mercado Pago account.
Copy your Access Token in the credentials panel and replace the text YOUR_ACCESS_TOKEN with it.
To generate a card token read the Checkout API documentation.
require 'mercadopago'
sdk = Mercadopago::SDK.new('YOUR_ACCESS_TOKEN')
custom_headers = {
'x-idempotency-key': '<SOME_UNIQUE_VALUE>'
}
custom_request_options = Mercadopago::RequestOptions.new(custom_headers: custom_headers)
order_data = {
type: 'online',
total_amount: '1000.00',
external_reference: 'ext_ref_1234',
capture_mode: 'automatic',
transactions: {
payments: [
{
amount: '1000.00',
payment_method: {
id: 'master',
type: 'credit_card',
token: '<CARD_TOKEN>',
installments: 1,
statement_descriptor: 'Store name'
}
}
]
},
processing_mode: 'automatic',
description: 'some description',
payer: {
email: '<PAYER_EMAIL>',
first_name: 'John',
last_name: 'Doe',
identification: {
type: 'CPF',
number: '00000000000'
}
}
}
result = sdk.order.create(order_data, custom_request_options)
order = result[:response]
puts orderAll methods that make API calls accept an optional RequestOptions object. This can be used to configure some special options of the request, such as changing credentials or custom headers.
require 'mercadopago'
request_options = Mercadopago::RequestOptions.new(access_token: 'YOUR_ACCESS_TOKEN')
# ...
result = sdk.payment.create(payment_data, request_options: request_options)
payment = result[:response]- SDK guides: request options, errors, webhooks, and production guidance.
- Examples: integration flows supported by this SDK.
- API reference: request fields and response schemas.
All contributions are welcome, ranging from people wanting to triage issues, others wanting to write documentation, to people wanting to contribute code.
Please read and follow our contribution guidelines. Contributions not following this guidelines will be disregarded. The guidelines are in place to make all of our lives easier and make contribution a consistent process for everyone.
If you require technical support, please contact our support team at developers.mercadopago.com.
MIT license. Copyright (c) 2021 - Mercado Pago / Mercado Libre
For more information, see the LICENSE file.