Pesquisar

Are you looking for test card numbers?

Would you like to contact support?

Atenção, esta página não se encontra disponível em Português
Payment-method icon

Pix Drop-in integration

Add Pix to an existing Drop-in integration.

Our Web Drop-in renders Pix in your payment form. Web Drop-in shows a QR code and button for copying QR code data. Shoppers can scan the QR code or paste the QR code data in their banking or wallet app participating in Pix.

Before you begin

This page explains how to add Pix to your existing Web Drop-in integration. The Web Drop-in integration works the same way for all payment methods. If you haven't done this integration yet, refer to our Drop-in integration guide.
Before starting your Pix integration:

  1. Make sure that you have set up your back end implementation, and added Drop-in to your payments form.
  2. Add Pix in your Customer Area.

Show Pix in your payment form

Drop-in uses countryCode and amount.currency from your /paymentMethods request to show the available payment methods to your shopper.

If you're using the /paymentMethods endpoint to show which payment methods are available to the shopper, specify in your request:

When the shopper selects the payment method, Drop-in calls the onSubmit event, which contains a state.data object including the shopper's selected payment method. Pass the state.data object to your server.

Collect additional parameters in your payment form

Collect the following details from the shopper:

Pass the collected data to your server because you will need to submit both Name and CPF/CNPJ in the /payments request. This information will be shown to the shopper to help identify the payment.

Make a payment

To make a Pix payment, follow these steps:

  1. From your server, make a /payments request, specifying the following parameters:

    Parameter Required Description
    paymentMethod.type -white_check_mark- Payment method from the onSubmit event.
    amount -white_check_mark- The final price of the purchase.
    shopperName -white_check_mark- The shopper's firstName and lastName. Keep the length of each field under 200 characters, otherwise it will be truncated. This will be shown to the shopper in the payments form.
    socialSecurityNumber -white_check_mark- The shopper's CPF or CNPJ number. This will be shown to the shopper in the payments form.
    shopperStatement -x- Free-text field that will be shown to the shopper. By default this contains the message: $merchantName - Este pagamento PIX para $merchantName é processado por Adyen. If you provide any value, keep the length under 60 characters because this will be appended to the default message.
    sessionValidity -x- The expiration date of the Pix payment. The default value is 24 hours, the maximum value is 5 days, in ISO 8601 format.
    For example: 2020-07-18T15:42:40.428+01:00
    lineItems -x- Information about purchased items.
    lineItems.id -x- The name of the purchased item. Maximum 50 characters.
    lineItems.amountIncludingTax -x- The price of the purchased item including tax. Maximum 200 characters.

    The following code sample is a /payments request for a Pix payment.

    curl https://checkout-test.adyen.com/v67/payments \
    -H "x-API-key: YOUR_X-API-KEY" \
    -H "content-type: application/json" \
    -d '{
        "merchantAccount": "YOUR_MERCHANT_ACCOUNT",
        "amount": {
            "currency": "BRL",
            "value": 100000
        },
        "paymentMethod": {
            "type": "pix"
        },
        "sessionValidity":"2021-12-21T13:00:00-03:00",
        "shopperStatement": "Your message to the shopper.",
        "shopperName": {
            "firstName": "Jose",
            "infix": "da",
            "lastName": "Silva"
        },
        "socialSecurityNumber": "01234567890",
        "lineItems": [
            {
                "id": "Item 1",
                "amountIncludingTax": "40000"
            },
            {
                "id": "Item 2",
                "amountIncludingTax": "60000"
            }
        ],
        "reference": "YOUR_ORDER_NUMBER"
    }'
    # Set your X-API-KEY with the API key from the Customer Area.
    adyen = Adyen::Client.new
    adyen.api_key = "YOUR_X-API-KEY"
     
    response = adyen.checkout.payments({
      :merchantAccount => "YOUR_MERCHANT_ACCOUNT",
      :amount => {
        :currency => "BRL",
        :value => 100000
      },
      :paymentMethod => {
        :type => "pix"
      },
      :sessionValidity => "2021-12-21T13:00:00-03:00",
      :shopperStatement => "Your message to the shopper.",
      :shopperName => {
          :firstName => "Jose",
          :infix => "da",
          :lastName => "Silva"
      },
      :socialSecurityNumber => "01234567890",
      :lineItems => [
          {
              :id => "Item 1",
              :amountIncludingTax => "40000"
          },
          {
              :id => "Item 2",
              :amountIncludingTax => "60000"
          }
      ]
      :reference => "YOUR_ORDER_NUMBER"
    })
    // Set YOUR_X-API-KEY with the API key from the Customer Area.
    // Change to Environment.LIVE and add the Live URL prefix when you're ready to accept live payments.
    Client client = new Client("YOUR_X-API-KEY", Environment.TEST);
    Checkout checkout = new Checkout(client);
    
    PaymentsRequest paymentsRequest = new PaymentsRequest();
    
    String merchantAccount = "YOUR_MERCHANT_ACCOUNT";
    paymentsRequest.setMerchantAccount(merchantAccount);
    
    Amount amount = new Amount();
    amount.setCurrency("BRL");
    amount.setValue(100000L);
    paymentsRequest.setAmount(amount);
    
    DefaultPaymentMethodDetails paymentMethodDetails = new DefaultPaymentMethodDetails();
    paymentMethodDetails.setType("pix");
    paymentsRequest.setPaymentMethod(paymentMethodDetails);
    
    String sessionValidity = "2021-12-21T13:00:00-03:00";
    String shopperStatement = "Your message to the shopper.";
    
    ShopperName shopperName = new ShopperName();
    shopperName.setFirstName("Jose");
    shopperName.setInfix("da");
    shopperName.setLastName("Silva");
    paymentsRequest.setShopperName(shopperName);
    
    String socialSecurityNumber = "01234567890";
    
    List<LineItem> lineItems = new ArrayList<>();
    lineItems.add(
            new LineItem()
                    .id("Item 1")
                    .amountIncludingTax(40000L)
    );
    lineItems.add(
            new LineItem()
                    .id("Item 2")
                    .amountIncludingTax(60000L)
    );
    
    paymentsRequest.setReference("YOUR_ORDER_NUMBER");
    
    PaymentsResponse paymentsResponse = checkout.payments(paymentsRequest);
    // Set your X-API-KEY with the API key from the Customer Area.
    $client = new \Adyen\Client();
    $client->setXApiKey("YOUR_X-API-KEY");
    $service = new \Adyen\Service\Checkout($client);
    
    $params = [
      "merchantAccount" => "YOUR_MERCHANT_ACCOUNT",
      "amount" => [
        "currency" => "BRL",
        "value" => 100000
      ],
      "paymentMethod" => [
        "type" => "pix"
      ],
      "sessionValidity" => "2021-12-21T13:00:00-03:00",
      "shopperStatement" => "Your message to the shopper.",
      "shopperName" => [
          "firstName" => "Jose",
          "infix" => "da",
          "lastName" => "Silva"
      ],
      "socialSecurityNumber" => "01234567890",
      "lineItems": [
        [
            "id" => "Item 1",
            "amountIncludingTax" => "40000"
        ],
        [
            "id" => "Item 2",
            "amountIncludingTax" => "60000"
        ]
      ],
      "reference" => "YOUR_ORDER_NUMBER"
    ];
    $result = $service->payments($params);
    # Set your X-API-KEY with the API key from the Customer Area.
    adyen = Adyen.Adyen()
    adyen.client.xapikey = 'YOUR_X-API-KEY'
    
    result = adyen.checkout.payments({
      "merchantAccount": "YOUR_MERCHANT_ACCOUNT",
      "reference": "YOUR_ORDER_NUMBER",
      "paymentMethod": {
        "type": "pix"
      },
      "amount": {
        "currency": "BRL",
        "value": 100000
      },
      "sessionValidity":"2021-12-21T13:00:00-03:00",
      "shopperStatement": "Your message to the shopper.",
      "shopperName": {
        "firstName": "Jose",
        "infix": "da",
        "lastName": "Silva"
      },
      "socialSecurityNumber": "01234567890",
      "lineItems": [
        {
          "id": "Item 1",
          "amountIncludingTax": "40000"
        },
        {
          "id": "Item 2",
          "amountIncludingTax": "60000"
        }
      ]
    })
    // Set your X-API-KEY with the API key from the Customer Area.
    var client = new Client ("YOUR_X-API-KEY", Environment.Test);
    var checkout = new Checkout(client);
    
    var paymentRequest = new Adyen.Model.Checkout.PaymentRequest
    {
       MerchantAccount = "YOUR_MERCHANT_ACCOUNT",
       Reference = "YOUR_ORDER_NUMBER",
       PaymentMethod = new DefaultPaymentMethodDetails { Type = "pix" },
       Amount = new Model.Checkout.Amount(Currency: "BRL", Value: 100000),
       SessionValidity = "2021-12-21T13:00:00-03:00",
       ShopperStatement = "Your message to the shopper.",
       ShopperName = new Model.Checkout.Name
       {
           FirstName = "Jose",
           Infix = "da"
           LastName = "Silva"
       },
       SocialSecurityNumber = "01234567890",
       LineItems = new List<LineItem>
    {
       new LineItem(Id:"Item 1", AmountIncludingTax:40000),
       new LineItem(Id:"Item 2", AmountIncludingTax:60000)
    }
    return paymentRequest;
    }
    // Set your X-API-KEY with the API key from the Customer Area.
    const {Client, Config, CheckoutAPI} = require('@adyen/api-library');
    const config = new Config();
    // Set your X-API-KEY with the API key from the Customer Area.
    config.apiKey = '[API_KEY]';
    config.merchantAccount = '[MERCHANT_ACCOUNT]';
    const client = new Client({ config });
    client.setEnvironment("TEST");
    const checkout = new CheckoutAPI(client);
    checkout.payments({
      merchantAccount: "YOUR_MERCHANT_ACCOUNT",
      reference: "YOUR_ORDER_NUMBER",
      paymentMethod: {
         type: "pix"
      },
      amount: {
         currency: "BRL",
         value: "100000"
      },
      sessionValidity: "2021-12-21T13:00:00-03:00",
      shopperStatement: "Your message to the shopper.",
      shopperName: {
         firstName": "Jose",
         infix": "da",
         lastName": "Silva"
      },
      socialSecurityNumber: "01234567890",
      lineItems: [
         {
            id: "item1",
            amountIncludingTax: "5000"
         },
         {
            id: "item2",
            amountIncludingTax: "10000"
         }
      ]
    }).then(res => res);

    The /payments response contains:

    • resultCode: Pending
    • action: The object needed to present the QR code and a button to copy QR code data.
    /payments response
    {
        "additionalData": {
            "pix.expirationDate": "2021-12-21T13:00:00-03:00",
            "acquirerReference": "00000000008216311768599610",
            "acquirerAccountCode": "PixBTGAcquirerAccount"
        },
        "pspReference": "8216311768599610",
        "resultCode": "Pending",
        "action": {
            "paymentData": "Ab02b4c0!BQABAgA...",
            "paymentMethodType": "pix",
            "type": "qrCode",
            "url": "https://test.adyen.com/hpp/generateQRCodeImage.shtml?url=DMhpN90TFR2e7TzwHYRFkhw4brxm2wHBg",
            "qrCodeData": "DMhpN90TFR2e7TzwHYRFkhw4brxm2wHBg"
        }
    }
  2. Pass the action object to your front end.

Present the QR code

Drop-in uses dropin.handleAction(action) function to present the QR code and a button to copy QR code data. The shopper can either scan the QR code or copy the QR code data to paste to their banking or wallet app.

After the shopper completes the payment or if the shopper fails to complete the payment within the QR code validity period, Drop-in calls the onAdditionalDetails event.

From your front end, pass state.data from the onAdditionalDetails event and pass it your server.

state.data from onAdditionalDetails
{
      data: {
        details: {
            payload: "X6XtfGC3!Y..."
        },
       paymentData: "Ab02b4c0!BQABAgC.."
     }
  }

Check the payment result

To check the payment result, make a /payments/details request containing state.data from Drop-in.

curl https://checkout-test.adyen.com/v67/payments/details \
-H "x-API-key: YOUR_X-API-KEY" \
-H "content-type: application/json" \
-d '{
     "paymentData":"Ab02b4c0!BQABAgC..",
     "details":{
       "payload":"X6XtfGC3!Y..."
     }
}'
require 'adyen-ruby-api-library'

# Set your X-API-KEY with the API key from the Customer Area.
adyen = Adyen::Client.new
adyen.env = :test
adyen.api_key = "YOUR_X-API-KEY"

response = adyen.checkout.payments.details({
  :paymentData => 'Ab02b4c0!BQABAgC..',
  :details => {
    :payload => 'X6XtfGC3!Y...'
  }
})
// Set your X-API-KEY with the API key from the Customer Area.
String xApiKey = "YOUR_X-API-KEY";
Client client = new Client(xApiKey,Environment.TEST);
Checkout checkout = new Checkout(client);
paymentsDetailsRequest paymentsDetailsRequest = new paymentsDetailsRequest();
HashMap<String, String> details = new HashMap<>();
details.put("payload", "X6XtfGC3!Y...");
paymentsDetailsRequest.setDetails(details);
paymentsDetailsRequest.setPaymentData("Ab02b4c0!BQABAgC..");
PaymentsResponse paymentsDetailsResponse = checkout.paymentsDetails(paymentsDetailsRequest);
// Set your X-API-KEY with the API key from the Customer Area.
$client = new \Adyen\Client();
$client->setEnvironment(\Adyen\Environment::TEST);
$client->setXApiKey("YOUR_X-API-KEY");
$service = new \Adyen\Service\Checkout($client);

$params = array(
  "paymentData" => "Ab02b4c0!BQABAgC..",
  "details" => array(
    "payload" => "X6XtfGC3!Y..."
  )
);
$result = $service->paymentsDetails($params);
# Set your X-API-KEY with the API key from the Customer Area.
adyen = Adyen.Adyen()
adyen.payment.client.platform = "test"
adyen.client.xapikey = 'YOUR_X-API-KEY'

result = adyen.checkout.payments_details({
   'paymentData' : 'Ab02b4c0!BQABAgC..',
   'details': {
      'payload': 'X6XtfGC3!Y...'
   }
})
// Set your X-API-KEY with the API key from the Customer Area.
string apiKey = "YOUR_X-API-KEY";
var client = new Client (apiKey, Environment.Test);
var checkout = new Checkout(client);
var details = new Dictionary<string, string>
{
  { "payload", "X6XtfGC3!Y..." }
};
var paymentsDetailsRequest = new Adyen.Model.Checkout.PaymentsDetailsRequest(Details: details);
var paymentsDetailsResponse = checkout.PaymentsDetails(paymentsDetailsRequest);
const {Client, Config, CheckoutAPI} = require('@adyen/api-library');
const config = new Config();
// Set your X-API-KEY with the API key from the Customer Area.
config.apiKey = '[YOUR_X-API-KEY]';
const client = new Client({ config });
client.setEnvironment("TEST");
const checkout = new CheckoutAPI(client);
checkout.paymentsDetails({
    details: { payload: "X6XtfGC3!Y..." },
    paymentData: "Ab02b4c0!BQABAgC..",
}).then(res => res);
import (
    "github.com/adyen/adyen-go-api-library/v5/src/checkout"
    "github.com/adyen/adyen-go-api-library/v5/src/common"
    "github.com/adyen/adyen-go-api-library/v5/src/adyen"
)
// Set your X-API-KEY with the API key from the Customer Area.
client := adyen.NewClient(&common.Config{
    Environment: common.TestEnv,
    ApiKey:      "[YOUR_X-API-KEY]",
})
req := checkout.DetailsRequest{
PaymentData: "Ab02b4c0!BQABAgC..",
    Details: map[string]interface{}{
        "payload":    "X6XtfGC3!Y...",
    },
res, httpRes, err := client.Checkout.PaymentsDetails(&req)

Present the payment result

Use resultCode that you received in the /payments/details response to present the payment result to your shopper.
The resultCode values you can receive for Pix are the following:

resultCode Description Action to take
Authorised The payment was successful. Inform the shopper that the payment has been successful.
You will receive the funds in 2-3 days.
Cancelled The shopper cancelled the payment while in the banking app. Ask the shopper whether they want to continue with the order, or ask them to select a different payment method.
Error There was an error when the payment was being processed. Inform the shopper that there was an error processing their payment. The response contains a refusalReason, indicating the cause of the error.
Pending or
Received
The payment order was successfully received. Inform the shopper that you've received their order, and are waiting for the payment to clear.
You will receive the final result of the payment in an AUTHORISATION notification. If successful, you will receive the funds in 2 days.
Refused The payment was refused by the shopper's bank. Ask the shopper to try the payment again using a different payment method.

You will also receive the outcome of the payment asynchronously in a notification webhook.

Here's an example of a standard notification you may receive.

{
    "live":"false",
    "notificationItems": [
        {
            "NotificationRequestItem": {
                "additionalData": {
                    ...
                    "pix.originalAmountValue":"1001",
                    "pix.originalAmountCurrency":"BRL"
                },
                "amount": {
                    "currency":"BRL",
                    "value":1001
                },
                "eventCode":"AUTHORISATION",
                "eventDate":"2021-12-21T20:49:23-03:00",
                "merchantAccountCode":"YOUR_MERCHANT_ACCOUNT",
                "merchantReference":"YOUR_REFERENCE",
                "paymentMethod":"pix",
                "pspReference":"991607125682053H",
                "success":"true",
                ...
            }
        }
    ]
}
<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"  xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soap:Body>
    <ns1:sendNotification xmlns:ns1="http://notification.services.adyen.com">
      <ns1:Notification>
        <live xmlns="http://notification.services.adyen.com">false</live>
        <notificationItems xmlns="http://notification.services.adyen.com">
          <NotificationRequestItem>
            <additionalData>
              <pix.originalAmountCurrency>BRL</pix.originalAmountCurrency>
              <pix.originalAmountValue>1001</pix.originalAmountValue>
            </additionalData>
            <amount>
              <currency xmlns="http://common.services.adyen.com">BRL</currency>
              <value xmlns="http://common.services.adyen.com">1001</value>
            </amount>
            <eventCode>AUTHORISATION</eventCode>
            <eventDate>2021-12-21T20:49:23-03:00</eventDate>
            <merchantAccountCode>YOUR_MERCHANT_ACCOUNT</merchantAccountCode>
            <merchantReference>YOUR_TRANSACTION_REFERENCE</merchantReference>
            <paymentMethod>pix</paymentMethod>
            <pspReference>991607125682053H</pspReference>
            <success>true</success>
          </NotificationRequestItem>
        </notificationItems>
      </ns1:Notification>
    </ns1:sendNotification>
  </soap:Body>
</soap:Envelope>

For more information about notifications, refer to Understanding notifications.

Refunds

You can refund a payment within 90 days after the payment in the Customer Area or via an API.

Test and go live

Pix is an asynchronous payment method. To be able to test this, make sure you have the following user roles in your test Customer Area:

  • Merchant view offers: This allows you to see Pix offers that are in the Pending state.
  • Promote offers to sale (test): This allows you to promote a Pix offer from Pending to Authorised. This way you can test what happens when we process the payment. This permission is only available in TEST.

Check the status of Pix test payments in your Customer Area:

  • Pix payments that are pending or that have expired are under TransactionsOffers.
  • Pix payments that have been paid (including test offers that you manually promoted to sale) are under Transactions > Payments.

Test the reconciliation process by promoting test payments from offer to sale in your test Customer Area.
Before you can accept live Pix payments, you need to submit a request for Pix in your live Customer Area.

See also