0.07
A long-lived project that still receives updates
Mercado Pago Ruby SDK
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 0.14
~> 13.0

Runtime

~> 2.5
~> 2.0
 Project Readme
Mercado Pago

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.

CI status RubyGems package version Ruby 3.3 or later MIT license

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 order

Per-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.