Mercado Pago SDK for Ruby
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
๐ก Requirements
Ruby version 3.3 or greater.
๐ฒ Installation
Run gem install mercadopago-sdk
๐ Getting Started
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.
Simple usage
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 orderPer-request configuration
All 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]๐ Documentation
- SDK guides: request options, errors, webhooks, and production guidance.
- Examples: integration flows supported by this SDK.
- API reference: request fields and response schemas.
๐ค Contributing
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.
โค๏ธ Support
If you require technical support, please contact our support team at developers.mercadopago.com.
๐ป License
MIT license. Copyright (c) 2021 - Mercado Pago / Mercado Libre
For more information, see the LICENSE file.