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:
- Make sure that you have set up your back end implementation, and added Drop-in to your payments form.
- 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:
- countryCode: BR
- amount.currency: BRL
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:
- Name: The first and last name of the shopper.
- CPF/CNPJ: CPF/CNPJ is a unique identifier similar to a social security number. The shopper can provide their Cadastro de Pessoas Físicas (CPF) number or their Cadastro Nacional da Pessoa Jurídica (CNPJ) number.
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:
-
From your server, make a /payments request, specifying the following parameters:
Parameter Required Description paymentMethod.type
Payment method from the onSubmit
event.amount
The final price of the purchase. shopperName
The shopper's firstName
andlastName
. 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
The shopper's CPF or CNPJ number. This will be shown to the shopper in the payments form. shopperStatement
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
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:00lineItems
Information about purchased items. lineItems.id
The name of the purchased item. Maximum 50 characters. lineItems.amountIncludingTax
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/v66/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
: Pendingaction
: The object needed to present the QR code and a button to copy QR code data.
{ "resultCode": "Pending", "action": { "paymentData": "Ab02b4c0!BQABAgA...", "paymentMethodType": "pix", "type": "qrCode", "url": "https://test.adyen.com/hpp/generateQRCodeImage.shtml?url=DMhpN90TFR2e7TzwHYRFkhw4brxm2wHBg", "qrCodeData": "DMhpN90TFR2e7TzwHYRFkhw4brxm2wHBg" }, "paymentData": "Ab02b4c0!BQABAgAQ...", "redirect": { "data": { "qrCodeData": "DMhpN90TFR2e7TzwHYRFkhw4brxm2wHBg" }, "url": "https://test.adyen.com/hpp/generateQRCodeImage.shtml?url=DMhpN90TFR2e7TzwHYRFkhw4brxm2wHBg" } }
- 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.
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/v66/payments/details \
-H "x-API-key: YOUR_X-API-KEY" \
-H "content-type: application/json" \
-d '{
"details": {
"redirectResult": "X6XtfGC3!Y..."
},
"paymentData":"Ab02b4c0!BQABAgAKspbjN8+5..."
}'
# 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"
request = DROPIN_DATA
# Data object passed from onAdditionalDetails event of the front end, parsed from JSON to a Hash.
response = adyen.checkout.payments.details(request)
# Check if further action is needed.
if response.body.has_key(:action)
# Pass the action object to your frontend
puts response.body[:action]
else
# No further action needed, pass the resultCode to your frontend
puts response.body[:resultCode]
end
// Set your X-API-KEY with the API key from the Customer Area.
Client client = new Client(xApiKey,Environment.TEST);
Checkout checkout = new Checkout(client);
PaymentsDetailsRequest paymentsDetailsRequest = new PaymentsDetailsRequest();
HashMap<String, String> details = new HashMap<>();
details.put("redirectResult", "X6XtfGC3!Y...");
paymentsDetailsRequest.setDetails(details);
paymentsDetailsRequest.setPaymentData("Ab02b4c0!BQABAgAKspbjN8+5...");
PaymentsResponse paymentsResponse = checkout.paymentsDetails(paymentsDetailsRequest);
// 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 = DROPIN_DATA;
// Data object passed from onAdditionalDetails event of the front end parsed from JSON to an array
$result = $service->paymentsDetails($params);
// Check if further action is needed
if (array_key_exists("action", $result){
// Pass the action object to your frontend.
// $result["action"]
}
else {
// No further action needed, pass the resultCode to your front end
// $result['resultCode']
}
#Set your X-API-KEY with the API key from the Customer Area.
adyen = Adyen.Adyen()
adyen.client.xapikey = 'YOUR_X-API-KEY'
request = DROPIN_DATA
# Data object passed from onAdditionalDetails event of the front end, parsed from JSON to a dictionary
result = adyen.checkout.payments_details(request)
# Check if further action is needed.
if 'action' in result.message:
# Pass the action object to your front end
# result.message['action']
else:
# No further action needed, pass the resultCode to your front end
# result.message['resultCode']
// 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);
string paymentData = "Ab02b4c0!BQABAgAKspbjN8+5...";
var details = new Dictionary<string, string>
{
{ "redirectResult", "X6XtfGC3!Y..." }
};
var paymentsDetailsRequest = new Model.Checkout.PaymentsDetailsRequest(Details: details);
var paymentResponse = checkout.PaymentDetails(paymentsDetailsRequest);
// 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 = '[YOUR_MERCHANT_ACCOUNT]';
const client = new Client({ config });
client.setEnvironment("TEST");
const checkout = new CheckoutAPI(client);
checkout.paymentsDetails({
details: {DROPIN_DATA} // Data object passed from onAdditionalDetails event of the front end
}).then(res => res);
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.
Compare original and paid amount
With Pix, shoppers can manually modify the amount they pay in their banking or wallet app after scanning the QR code or pasting the QR code data. Make sure to implement some business logic that matches additionalData.pix.originalAmountValue
and amount.value
.
If the actual paid amount doesn't match the original amount, we recommend that you cancel the payment and make a refund.
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 Transactions > Offers.
- 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.