# MD for: https://www.mercadopago.com.br/developers/pt/docs/checkout-api-orders/payment-integration/pix.md \# Pix With Mercado Pago's Checkout Transparente, it's also possible to offer instant payments with Pix through a \*\*QR code\*\* or a \*\*payment link\*\*. > WARNING > > If you want to offer payments via Pix, you must have your keys registered. If you haven't already, \[click here\](https://www.youtube.com/watch?v=60tApKYVnkA) for more information on how to register them. \*\*Pix\*\* is an instant electronic payment method offered by the Central Bank of Brazil to individuals and businesses. If you already \[set up your environment\](https://www.mercadopago.com.br/developers/en/docs/checkout-api-orders/development-environment) and want to offer payments with Pix, follow the steps below. > NOTE > > Remember: before setting up the payment methods, choose the way you will process your transactions. The processing mode, whether \*\*manual or automatic\*\*, will be defined at the time of order creation, using the \`processing\_mode\` parameter. For more information, visit the section \[Integration model\](https://www.mercadopago.com.br/developers/en/docs/checkout-api-orders/integration-model). :::AccordionComponent{title="Add payment form" pill="client-side"} To be able to receive payments, you need to add a form in the frontend that securely captures the payer's information. If you already have a development that includes your own payment form, make sure to include \*\*Pix\*\* among the payment options you want to offer, as indicated below, and continue to the next step. If you do not have a payment form, add the form below to your project, including the identifier for boleto bancário among the payment methods to be offered. | Payment method | \`payment\_method\_id\`| |:---:|:---:| | Pix | \`pix\` | \`\`\`html Nome Sobrenome E-mail Tipo de documento Número do documento Pagar \`\`\` ::: :::AccordionComponent{title="Get document types" pill="client-side"} To facilitate the correct entry of data in the payment form, it is necessary to obtain the possible document types to be accepted. The function below will allow you to automatically populate the available options, thanks to the inclusion of the \`select\` element with the \`id: form-checkout\_\_identificationType\` found in the form used as an example in the previous step. If you already have a development that includes the retrieval of document types, as indicated below, proceed to \[Submit payment\](https://www.mercadopago.com.br/developers/en/docs/checkout-api-orders/payment-integration/pix#:\~:text=server%2Dside-,Submit,-payment). If you do not have this function, add the following to your project. \`\`\`javascript (async function getIdentificationTypes() { try { const identificationTypes = await mp.getIdentificationTypes(); const identificationTypeElement = document.getElementById('form-checkout\_\_identificationType'); createSelectOptions(identificationTypeElement, identificationTypes); } catch (e) { return console.error('Error getting identificationTypes: ', e); } })(); function createSelectOptions(elem, options, labelsAndKeys = { label: "name", value: "id" }) { const { label, value } = labelsAndKeys; elem.options.length = 0; const tempOptions = document.createDocumentFragment(); options.forEach(option => { const optValue = option\[value\]; const optLabel = option\[label\]; const opt = document.createElement('option'); opt.value = optValue; opt.textContent = optLabel; tempOptions.appendChild(opt); }); elem.appendChild(tempOptions); } \`\`\` ::: :::AccordionComponent{title="Submit payment" pill="server-side"} The payment submission must be made by creating an order that contains associated payment transactions. > NOTE > > The creation of a payment can occur asynchronously in an order. In this scenario, the order remains in a processing state and without information. We recommend setting up \[Order topic notifications\](https://www.mercadopago.com.br/developers/en/docs/checkout-api-orders/notifications) to receive updates on the status change, including the updated order data. Alternatively, you can choose to send a \*\*GET\*\* request to the \[/v1/orders/{id}\](https://www.mercadopago.com.br/developers/en/reference/online-payments/checkout-api/get-order/get) endpoint to retrieve that updated information. To do this, send a \*\*POST\*\* with your :toolTipComponent\[test Access Token\]{content="Private key of the application created in Mercado Pago, that must be used in the backend. You can access it through \*Your integrations > Integration data > Tests > Test credentials\*."} and the required parameters listed below to the endpoint :TagComponent{tag="API" text="/v1/orders" href="/developers/en/reference/online-payments/checkout-api/create-order/post"} and execute the request. \`\`\`curl curl -X POST \\ -H 'accept: application/json' \\ -H 'Content-Type: application/json' \\ -H 'Authorization: Bearer ' \\ -H 'X-Idempotency-Key: ' \\ 'https://api.mercadopago.com/v1/orders' \\ -d '{ "type": "online", "total\_amount": "1000.00", "external\_reference": "ext\_ref\_1234", "processing\_mode": "automatic", "transactions": { "payments": \[ { "amount": "1000.00", "payment\_method": { "id": "pix", "type": "bank\_transfer" }, "expiration\_time": "P3Y6M4DT12H30M5S" } \] }, "payer": { "email": "test\_user\_br@testuser.com" } }' \`\`\` 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. | Atribute | Type | Description | Requirement | |---------------------------------------------------|-----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------| | \`Authorization\` | \_Header\_ | Refers to your private key, the :toolTipComponent\[test Access Token\]{content="Private key of the application created in Mercado Pago, that must be used in the backend. You can access it through \*Your integrations > Integration data > Tests > Test credentials\*."}. | Required | | \`X-Idempotency-Key\` | \_Header\_ | Idempotency key. It is used to ensure that each request is processed only once, avoiding duplications. Use a unique value in the header of your request, such as a UUID V4 or random strings. | Required | | \`total\_amount\` | \_Body. String\_ | Total amount for the transaction. | Required | | \`external\_reference\` | \_Body. String\_ | External reference of the order, which can be, for example, a hashcode from the Central Bank, serving as the transaction's source identifier. | Required | | \`processing\_mode\` | \_Body. String\_ | Processing mode of the order. The possible values are: \- \`automatic\`: to create and process the order in automatic mode. \- \`manual\`: to create the order and process it later. For more information, visit the section \[Integration model\](https://www.mercadopago.com.br/developers/en/docs/checkout-api-orders/integration-model). | Required | | \`transaction.payments.payment\_method.id\` | \_Body. String\_ | Identifier of the payment method. In this case, the value should be \`pix\`. | Required | | \`transaction.payments.payment\_method.type\` | \_Body. String\_ | Type of the payment method. In the case of payments with a slip, the value should be \`bank\_transfer\`. | Required | | \`transaction.payment.expiration\_time\` | \_Body. String\_ | Allows you to set the \*\*due date\*\* using the ISO 8601 duration format. By default, \*\*the due date of a Pix payment is 24 hours\*\*, but it can be changed through this parameter. It must be set to a minimum of 30 minutes from the creation of the payment, and a maximum of 30 days. | Optional | | \`payer.email\` | \_Body. String\_ | Buyer’s e-mail. | Required | > SUCCESS\_MESSAGE > > To learn in detail about all the parameters sent and returned in this request, please refer to our \[API Reference\](https://www.mercadopago.com.br/developers/en/reference/online-payments/checkout-api/create-order/post). Additionally, if you receive an error when submitting the payment, you can consult our \[list of errors\](https://www.mercadopago.com.br/developers/en/docs/checkout-api-orders/payment-management/integration-errors). The response will return the parameters \`ticket\_url\`, \`qr\_code\` and \`qr\_code\_base64\`, containing, respectively, the URL with instructions for the buyer to complete the payment, an alphanumeric code to be used in the configuration to display the option that will allow copying and pasting the payment code, and the QR code that can be rendered directly on the payment screen. You must make one or all of these options available following the guidelines in the \[Make the payment available\](https://www.mercadopago.com.br/developers/en/docs/checkout-api-orders/payment-integration/pix#bookmark\_make\_the\_payment\_available) step. Additionally, it will also display the \_status\_ \`action\_required\` with \`status\_detail=waiting\_transfer\` until the payment is made. \`\`\`json { "id": "ORD01HRYFWNYRE1MR1E60MW3X0T2P", "type": "online", "total\_amount": "1000.00", "external\_reference": "ext\_ref\_1234", "country\_code": "BRA", "status": "action\_required", "status\_detail": "waiting\_transfer", "capture\_mode": "automatic", "transactions": { "payments": \[ { "id": "PAY01HRYFXQ53Q3JPEC48MYWMR0TE", "reference\_id": "123456789", "status": "action\_required", "status\_detail": "waiting\_transfer", "amount": "1000.00", "payment\_method": { "id": "pix", "type": "bank\_transfer", "ticket\_url": "https://www.mercadopago.com.br/sandbox/payments/00000000000/ticket?caller\_id=77777777777&hash=34cb0d7c-81d9-478c-92a5-767d0kakjja", "qr\_code": "00020126580014br.gov.bcb.pix0136b76aa9c2-2ec4-4110-954e-ebfe34f05b61520400005303986540510.005802BR5912TESTPVBWOSBE6009Sao Paulo62240520mpqrinter715936942186304C3C0", "qr\_code\_base64": "iVBORw0KGgoAAAANSUhEUgAABWQAAAVkAQAAAAB79i" } } \] }, "processing\_mode": "automatic", "marketplace": "NONE" } \`\`\` Among the returned parameters, we have those indicated in the table below. | Atribute | Type | Description | |---------------------------------------------------|---------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | \`transaction.payments.status\` | \_String\_ | Returns the status of the transaction. In this case, it will return \`action\_required\` to indicate the need for action to complete processing, that is, until the payment of the Pix is made. | | \`transaction.payments.status\_detail\` | \_String\_ | In this case, the obtained \`status\_detail\` is waiting (\`waiting\_payment\`) for the user to complete the payment process of the Pix with their bank. | | \`transaction.payments.payment\_method.ticket\_url\` | \_String\_ | URL for the rendered Pix with QR code, Pix Copia e Cola, and payment instructions. See more information in \[Make the payment available\](https://www.mercadopago.com.br/developers/en/docs/checkout-api-orders/payment-integration/pix#bookmark\_add\_link\_or\_bottom). | | \`transaction.payments.payment\_method.qr\_code\` | \_String\_ | Presents an alphanumeric code to be used in the configuration to display the option that will allow copying and pasting the payment code for Pix payment. See more information in \[Make the payment available\](https://www.mercadopago.com.br/developers/en/docs/checkout-api-orders/payment-integration/pix#bookmark\_add\_link\_or\_bottom). | | \`transaction.payments.payment\_method.qr\_code\_base64\` | \_String\_ | Base64 representation of the QR code image to be scanned to complete the payment. Provides the value to be used in the request to display the QR code for Pix payment. See more information in \[Make the payment available\](https://www.mercadopago.com.br/developers/en/docs/checkout-api-orders/payment-integration/pix#bookmark\_add\_link\_or\_bottom). | > WARNING > > If you have created the order in manual mode, remember that processing the payment requires an additional step, which is calling the :TagComponent{tag="API" text="Process order" href="/developers/en/reference/online-payments/checkout-api/process-order/post"}. ::: :::AccordionComponent{title="Make the payment available" pill="client-side"} After creating the payment request with Pix, choose how the user will be able to make the payment on the frontend, either through a \*\*payment link or button\*\* or a \*\*rendered QR code\*\*. Select the option that best fits your business model and follow the steps described below. ### Add link or bottom When choosing to \*\*add a link or button for payment with Pix\*\*, the buyer will be directed to a new window containing all the information to complete the payment, such as \*\*QR code\*\* or \*\*Pix Copia e Cola\*\*, along with the respective payment instructions. To offer this option, use the \`ticket\_url\` attribute returned in the response of the request, as shown below: \`\`\`html [Pagar com Pix](https://www.mercadopago.com.br/payments/123456789/ticket?caller%5Fid=123456&hash=123e4567-e89b-12d3-a456-426655440000)\`\`\` ### Render QR code It is possible to render the current QR code returned in the response of the request, which should be used only once, on the payment screen itself. Additionally, you can also add an option to copy and paste the payment code, allowing the transaction to be carried out via Internet Banking. To do this, follow the steps below. 1\. Add the \`qr\_code\_base64\`, returned in the response of the request, to display the QR code. \`\`\`html ![](https://www.mercadopago.com.br/{`data:image/jpeg;base64,${qr_code_base64}`})\`\`\` 2\. Next, add the \`qr\_code\`, returned in the response of the request, to present the option that allows copying and pasting the code. \`\`\`html Copiar Hash: \`\`\` Once these steps are completed, the buyer will see the rendered QR code along with the option to copy and paste their payment code at the time of payment. ::: :::AccordionComponent{title="Cancel payment" pill="server-side"} If you wish, you can cancel a payment created, as long as it is pending or in process; that is, with \`status=action\_required\`. Additionally, we recommend canceling payments that were not made by the established due date to avoid billing and reconciliation issues. > WARNING > > If 30 days pass after the established due date for a payment and it has not been made, Mercado Pago will consider it expired. In these cases, it is not possible to perform a manual cancellation, and the payment status will change to canceled or expired. For more information, please consult the \[Refunds and cancellations\](https://www.mercadopago.com.br/developers/en/docs/checkout-api-payments/payment-management/refunds-cancellations) section. :::