Mercadopago SDK module for Payments integration
Actively maintained. Last release 6 days ago, commits in 13 of the last 26 weeks. A safe choice.
pip install mercadopagoMercado Pago SDK for Python
The official Mercado Pago SDK for Python applications.
Integrate Mercado Pago APIs into your Python application and start receiving payments.
Installation · Getting started · Documentation · Contributing
💡 Requirements
Python 3.10 or higher.
📲 Installation
Run pip3 install mercadopago
🌟 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 — Orders API
The Orders API (/v1/orders) is the recommended way to accept payments. sdk.order().create() accepts either a plain dict or the optional typed request dataclasses (OrderCreateRequest and friends). Both routes produce the exact same JSON body.
import mercadopago
sdk = mercadopago.SDK("YOUR_ACCESS_TOKEN")
request_options = mercadopago.config.RequestOptions()
request_options.custom_headers = {
'x-idempotency-key': '<SOME_UNIQUE_VALUE>'
}
order_data = {
"type": "online",
"total_amount": "100.00",
"external_reference": "ext_ref_1234",
"transactions": {
"payments": [
{
"amount": "100.00",
"payment_method": {
"id": "master",
"type": "credit_card",
"token": "CARD_TOKEN",
"installments": 1,
},
}
]
},
"payer": {
"email": "test_user_123456@testuser.com"
},
}
result = sdk.order().create(order_data, request_options)
order = result["response"]
print(order)