Desktop/Mobile Website Browser - PIX
Accept PIX payment by displaying the QR code and/or PIX code to the shopper.
Step 1. Initialize a Payment Intent
Create a Payment Intent with the Create a Payment Intent API API.
POST /api/v1/pa/payment_intents/create
Step 2. Generate and render the QR code and/or PIX code to the shopper
2.1. Obtain the string representation of the QR code and the PIX code
When a shopper selects to pay with PIX on their desktop/mobile browser, call the Confirm a Payment Intent API API to get a redirect URL.
POST /api/v1/pa/payment_intents/{id}/confirm
If you send shopperName
and identificationNumber
, the transaction can only be completed by the designated payer.
identificationNumber
refers to the payer’s CPF or CNPJ number. The CNPJ number consists of 14 digits, and the CPF number consists of 11 digits. The identificationNumber
only accepts numerical digits.
You will get a response similar to the following.
2.2. Present the QR code and/or PIX code to the shopper
On desktop, you can render the QR code image with the next_action.data.qrcode
returned in the confirm Payment Intent response and present it to the shopper. Shoppers will complete payment after scanning the QR code with their PIX-supported banking app.
There are publicly available libraries for different programming languages to render a QR code image from its string representation. For example, if you use JavaScript, you may use qrcode to facilitate the conversion. Firstly, get a Base64-encoded image string with the qrcode library:
Then place the image string into the src field of the img element.
On mobile, you should also display the PIX code returned next_action.data.qrcode
returned in the confirm Payment Intent response. Shoppers should be able to copy and paste the PIX code to their PIX-supported banking app and complete the payment.
Step 3. Query the payment result status
To get the payment result, we suggest you poll the status of the Payment Intent via the Retrieve a Payment Intent API API. You may start polling the Payment Intent status after the shopper is redirected back to your website or mobile app, i.e., the return_url
passed when creating the Payment Intent.
GET /api/v1/pa/payment_intents/{id}
In addition, Airwallex will notify you of the payment result asynchronously via the webhooks. Please refer to the webhook documentation to set up your webhook accordingly. Although subscribing to webhook events is optional, it is recommended to subscribe to the payment_intent.succeeded
webhook which indicates that the shopper has paid the order.