Process payments
With Wallet Connect, payments are processed through the Orders API, an API designed to simplify the integration with Mercado Pago. The order represents the purchase intent and concentrates the payment transactions associated with it, allowing the amount to be debited directly from the buyer's wallet using the payment token obtained in the agreement.
Before processing payments, you must have completed the agreement flow and obtained the payer_token. If you have not done so yet, see the Configure agreements section.
capture_mode parameter, and determines whether the payment will be debited immediately upon the creation of the order (automatic) or only authorized for later capture (manual). If you define that the capture will be performed later, after the order creation you must capture it through the endpoint /v1/orders/{order_id}/capturePOST.Creating the order is the operation that performs the charge on the buyer's wallet. It is only possible to associate one payment transaction per order in Wallet Connect integrations.
To do this, send a request to the endpoint /v1/ordersPOST, including your test Access TokenPrivate key used in the backend to authenticate the requests. In the Wallet Connect integration, your Access Token will initially be provided by the team responsible for creating your application in Mercado Pago, but once you have access to that application you will be able to view it in Your integrations > Integration data > Tests > Test credentials. The test Access Token starts with the prefix `APP_USR`. and the payer_token obtained in the agreement.
additional_info.sub_merchant node when creating the order, as in the example below. For more information, see the Payment facilitators documentation.curlcurl -X POST \ 'https://api.mercadopago.com/v1/orders' \ -H 'Content-Type: application/json' \ -H 'X-Idempotency-Key: {{SOME_UNIQUE_VALUE}}' \ -H 'Authorization: Bearer {{YOUR_ACCESS_TOKEN}}' \ -d '{ "type": "online", "external_reference": "ext_ref_1234", "total_amount": "24.90", "description": "Smartphone", "capture_mode": "automatic", "integration_data": { "platform_id": "123abc" }, "additional_info": { "sub_merchant": { "id": "123123", "legal_name": "LOJINHA DO ZE", "mcc": "5462", "document_type": "CNPJ", "document_number": "222222222222222", "phone": "5551999999999", "url": "www.nomedofacilitador.com.br", "address_street": "RUA A", "address_door_number": 123, "zip": "01310100", "city": "Sao Paulo", "region_code_iso": "BR-SP", "region_code": "BR", "country": "BRA" } }, "transactions": { "payments": [ { "amount": "24.90", "payment_method": { "type": "wallet", "id": "wallet", "token": "PAYER_TOKEN", "statement_descriptor": "My Store" } } ] } }'
See the table below for descriptions of the parameters that are mandatory in the request and those that, although optional, have some important particularity that should be highlighted.
| Parameter | Type | Description | Requirement |
X-Idempotency-Key | Header | Idempotency key. This key ensures that each request is processed only once, avoiding duplicate charges if the request is resent. Use a unique value per payment attempt, such as a UUID V4 or a random string, with a length between 1 and 64 characters. | Required |
Authorization | Header | Refers to your test Access TokenPrivate key used in the backend to authenticate the requests. In the Wallet Connect integration, your Access Token will initially be provided by the team responsible for creating your application in Mercado Pago, but once you have access to that application you will be able to view it in Your integrations > Integration data > Tests > Test credentials. The test Access Token starts with the prefix `APP_USR`.. | Required |
type | Body. String | Type of order, associated with the Mercado Pago solution for which it was created. For payments with Wallet Connect, the only possible value is online. | Required |
external_reference | Body. String | External reference of the order, assigned at creation time. It must be a unique value for each order and must not contain PII data. The maximum limit is 64 characters and the allowed ones are: uppercase and lowercase letters, numbers and hyphen (-) and underscore (_) symbols. | Required |
total_amount | Body. String | Total amount to be paid. The field must contain 2 decimal places, even when it is a whole number (for example, "10.00"). | Required |
description | Body. String | Description of the purchased product or service, that is, the reason for the payment order. | Optional |
capture_mode | Body. String | Defines when the payment is captured. The possible values are: - automatic: debits the amount from the buyer's wallet immediately upon order creation. This is the default value if the field is not sent. - manual: only authorizes the payment upon order creation, requiring it to be captured later through the capture endpoint. | Optional |
integration_data.platform_id | Body. String | Platform identifier assigned by Mercado Pago. | Optional |
transactions.payments.amount | Body. String | Amount of the payment transaction. It must match the value informed in total_amount and follow the same decimal places rule. | Required |
transactions.payments.payment_method.type | Body. String | Type of payment method. For transactions with Wallet Connect, the only possible value is wallet. | Required |
transactions.payments.payment_method.id | Body. String | Identifier of the payment method. For transactions with Wallet Connect, the only possible value is wallet. | Required |
transactions.payments.payment_method.token | Body. String | Payment token (payer_token) obtained upon completing the wallet agreement flow. It must contain exactly 32 alphanumeric characters, with no special characters. | Required |
transactions.payments.payment_method.statement_descriptor | Body. String | Description with which the payment will appear on the buyer's statement. Accepts up to 50 characters. | Optional |
transactions.payments.stored_credential | Body. Object | Payment credential previously authorized by the buyer, used to process recurring payments initiated by the seller (MIT — Merchant Initiated Transaction). Send the reason field with the value recurring and payment_initiator with the value merchant only for recurring payments, omitting the parameter for one-time payments. | Optional |
additional_info.sub_merchant | Body. Object | Information about the sub-merchant involved in the transaction. Required only for Payment facilitators integrations — entities required by Circular BCB No. 3978/2020 to identify sub-merchants at the time of the transaction. | Optional |
additional_info.sub_merchant.id | Body. String | Sub-merchant code. | Required |
additional_info.sub_merchant.legal_name | Body. String | Legal name of the sub-merchant. | Required |
additional_info.sub_merchant.mcc | Body. String | Sub-merchant MCC (Merchant Category Code), according to Abecs classification and/or primary CNAE. | Required |
additional_info.sub_merchant.document_type | Body. String | Document type of the sub-merchant, either CPF or CNPJ. | Required |
additional_info.sub_merchant.document_number | Body. String | CPF or CNPJ number of the sub-merchant. | Required |
additional_info.sub_merchant.phone | Body. String | Phone number of the sub-merchant. | Required |
additional_info.sub_merchant.url | Body. String | URL of the payment facilitator. | Required |
additional_info.sub_merchant.address_street | Body. String | Street where the sub-merchant is located. | Required |
additional_info.sub_merchant.address_door_number | Body. Integer | Street number where the sub-merchant is located. | Required |
additional_info.sub_merchant.zip | Body. String | Postal code of the sub-merchant. | Required |
additional_info.sub_merchant.city | Body. String | City where the sub-merchant is located. | Required |
additional_info.sub_merchant.region_code_iso | Body. String | ISO code of the state where the sub-merchant is located. | Required |
additional_info.sub_merchant.region_code | Body. String | Country code of the sub-merchant. | Required |
additional_info.sub_merchant.country | Body. String | Country where the sub-merchant is located. | Required |
If the request is successful, the response will return status 201 with the created order. For orders with capture_mode=automatic, the payment will return status=processed and status_detail=accredited, indicating that the amount has already been debited from the buyer's wallet.
json{ "id": "ORDBTA01KJZ06DEJX3DMY26FAB44BXNN", "type": "online", "processing_mode": "automatic", "external_reference": "ext_ref_1234", "description": "Smartphone", "total_amount": "24.90", "total_paid_amount": "24.90", "status": "processed", "status_detail": "accredited", "capture_mode": "automatic", "transactions": { "payments": [ { "id": "PAY01KJZ06DEJX3DMXXXXXXXXXXXX", "amount": "24.90", "paid_amount": "24.90", "status": "processed", "status_detail": "accredited", "payment_method": { "id": "wallet", "type": "wallet", "statement_descriptor": "My Store", "installments": 1 } } ] } }
Among the returned parameters, we have those indicated in the table below.
| Parameter | Type | Description |
id | String | Identifier of the created order, automatically generated by Mercado Pago. Use it to query, capture, cancel or refund the order. |
status | String | Returns the order status. The possible values are processed, action_required, failed and canceled. |
status_detail | String | Details the reason for the order status. For approved payments, it returns accredited. For orders created with capture_mode set to manual, it returns waiting_capture until the capture is performed. |
total_paid_amount | String | Amount effectively paid for the order, including any discounts applied. |
transactions.payments.id | String | Identifier of the payment transaction, automatically generated by Mercado Pago. It is required to perform partial refunds. |
transactions.payments.status | String | Returns the status of the payment transaction. |
transactions.payments.attempts | Array | Ordered list of the processing attempts made for this payment, with the status and the payment method of each one. |
If you created the order in manual mode, that is, with the capture_mode=manual field, remember that processing the payment requires an additional step. In this scenario, the amount is only authorized upon order creation and the response will return status=action_required with status_detail=waiting_capture, indicating that the transaction is awaiting capture. To complete the charge and debit the amount from the buyer's wallet, you must send a request to the endpoint /v1/orders/{order_id}/capturePOST. After the capture, the order will return status=processed with status_detail=accredited.
The query allows you to obtain the updated data of an order, including the payment status and the processing attempts made. We recommend using it as an alternative to notifications when you need to confirm the result of a transaction.
To perform the query, send a request to the endpoint /v1/orders/{order_id}GET, including your test Access TokenPrivate key used in the backend to authenticate the requests. In the Wallet Connect integration, your Access Token will initially be provided by the team responsible for creating your application in Mercado Pago, but once you have access to that application you will be able to view it in Your integrations > Integration data > Tests > Test credentials. The test Access Token starts with the prefix `APP_USR`. and the order ID (order_id) obtained in the response to its creation.
curlcurl -X GET \ 'https://api.mercadopago.com/v1/orders/{{ORDER_ID}}' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer {{YOUR_ACCESS_TOKEN}}'
| Parameter | Type | Description | Requirement |
order_id | Path. String | Identifier of the order you want to query, obtained in the response to its creation. | Required |
Authorization | Header | Refers to your test Access TokenPrivate key used in the backend to authenticate the requests. In the Wallet Connect integration, your Access Token will initially be provided by the team responsible for creating your application in Mercado Pago, but once you have access to that application you will be able to view it in Your integrations > Integration data > Tests > Test credentials. The test Access Token starts with the prefix `APP_USR`.. | Required |
If the request is successful, the response will return status 200 with the updated order data.
json{ "id": "ORDBTA01KJZ06DEJX3DMY26FAB44BXNN", "type": "online", "processing_mode": "automatic", "external_reference": "ext_ref_1234", "description": "Smartphone", "total_amount": "24.90", "total_paid_amount": "24.90", "status": "processed", "status_detail": "accredited", "transactions": { "payments": [ { "id": "PAY01KJZ06DEJX3DMXXXXXXXXXXXX", "amount": "24.90", "paid_amount": "24.90", "status": "processed", "status_detail": "accredited" } ] } }
Cancelling releases the authorization of a payment that has not yet been captured, without transferring any amount from the buyer's wallet. It applies only to orders with the action_required status, that is, created with capture_mode=manual and still pending capture.
To cancel an order, send a request to the endpoint /v1/orders/{order_id}/cancelPOST without sending the body in the request. Make sure to include your test Access TokenPrivate key used in the backend to authenticate the requests. In the Wallet Connect integration, your Access Token will initially be provided by the team responsible for creating your application in Mercado Pago, but once you have access to that application you will be able to view it in Your integrations > Integration data > Tests > Test credentials. The test Access Token starts with the prefix `APP_USR`. and the order ID (order_id) you want to cancel.
curlcurl -X POST \ 'https://api.mercadopago.com/v1/orders/{{ORDER_ID}}/cancel' \ -H 'Content-Type: application/json' \ -H 'X-Idempotency-Key: {{SOME_UNIQUE_VALUE}}' \ -H 'Authorization: Bearer {{YOUR_ACCESS_TOKEN}}'
| Parameter | Type | Description | Requirement |
order_id | Path. String | Identifier of the order you want to cancel, obtained in the response to its creation. | Required |
X-Idempotency-Key | Header | Idempotency key. Use a unique value per request to prevent the cancellation from being reprocessed. | Required |
Authorization | Header | Refers to your test Access TokenPrivate key used in the backend to authenticate the requests. In the Wallet Connect integration, your Access Token will initially be provided by the team responsible for creating your application in Mercado Pago, but once you have access to that application you will be able to view it in Your integrations > Integration data > Tests > Test credentials. The test Access Token starts with the prefix `APP_USR`.. | Required |
If the request is successful, the response will return the order with status=canceled and status_detail=canceled_transaction, indicating that the authorization has been released.
order_already_canceled error on new attempts.Refunds are transactions performed when a given charge is reversed and the paid amounts are returned to the buyer. With Wallet Connect, it is possible to perform the total or partial refund of an order that has already been processed.
Choose the option that best suits your needs and follow the corresponding instructions.
To perform the total refund of an order, send a request to the endpoint /v1/orders/{order_id}/refundPOST without sending the body in the request. Make sure to include your test Access TokenPrivate key used in the backend to authenticate the requests. In the Wallet Connect integration, your Access Token will initially be provided by the team responsible for creating your application in Mercado Pago, but once you have access to that application you will be able to view it in Your integrations > Integration data > Tests > Test credentials. The test Access Token starts with the prefix `APP_USR`. and the order ID (order_id) you want to refund.
curlcurl -X POST \ 'https://api.mercadopago.com/v1/orders/{{ORDER_ID}}/refund' \ -H 'Content-Type: application/json' \ -H 'X-Idempotency-Key: {{SOME_UNIQUE_VALUE}}' \ -H 'Authorization: Bearer {{YOUR_ACCESS_TOKEN}}'
| Parameter | Type | Description | Requirement |
order_id | Path. String | Identifier of the order you want to refund, obtained in the response to its creation. | Required |
X-Idempotency-Key | Header | Idempotency key. Use a unique value per request to prevent the refund from being reprocessed. | Required |
Authorization | Header | Refers to your test Access TokenPrivate key used in the backend to authenticate the requests. In the Wallet Connect integration, your Access Token will initially be provided by the team responsible for creating your application in Mercado Pago, but once you have access to that application you will be able to view it in Your integrations > Integration data > Tests > Test credentials. The test Access Token starts with the prefix `APP_USR`.. | Required |
If the request is successful, the response will return status=refunded and a new transactions.refunds node, which will contain the refund details, in addition to the id of the original payment transaction and the id of the refund transaction.
json{ "id": "ORDBTA01KJZ0AYZPD3SXDYCQ109Q69EA", "status": "refunded", "status_detail": "refunded", "transactions": { "refunds": [ { "id": "REF01KJZ0BPKX0BQ0KG1VPBMJDX9G", "transaction_id": "PAY01KJZ0AYZPD3SXDYCQ10RYPF8E", "amount": "24.90", "status": "processed" } ] } }