Pix QrCode - Pay-In

With the use of this API, it is possible to implement Pix QR code in your business, thus facilitating the receipt of funds from your customers.

About Pix

Pix, the instant payment system of the Central Bank of Brazil, has become increasingly popular due to its convenience and speed, being a convenient option for companies in different sectors.

By using the Pix QR code, your customers can perform financial transactions quickly and securely, without the need to enter bank data or make transfers through other platforms. By offering this payment option in your business, you can increase customer satisfaction and, consequently, improve your financial results.

AgilSpot Pay's API offers an extremely useful functionality for its users: the token key, also known as the Pix key. This key allows the customer to copy and paste the information into their banking app, making it easier to complete the payment. In addition, it is possible to convert this key into a Pix QR Code image, making the financial transaction process even more agile and practical.

To perform this conversion in PHP, for example, it is possible to use the Mpdf\QrCode library, which is quite popular among developers. With this tool, it is possible to generate the Pix QR Code from the token key in a simple and fast way, allowing the customer to scan the image and make the payment without complications. This solution offered by AgilSpot Pay's API brings numerous advantages for both users and businesses, making the payment process more secure, fast, and efficient.

Example

A practical example of how the Pix Key can be handled, offering the user two payment options through a single return. This is possible because the Pix Key is a unique information that can be associated with different types of transactions, such as payments through QR code or direct transfer.

By using an API that handles the Pix Key, it is possible to provide the user with the choice between the two payment options, without needing to generate different keys for each one. Thus, the customer can choose the payment method that they consider most convenient at the moment, without having to worry about obtaining new payment information.

Generate the Pix QR Code from the Pix key

If you need to convert a Pix Key to a QR Code, one option is to use the PHP language along with the Mpdf\QrCode library. This library is one of the most widely used by developers for generating QR Codes in PHP and offers a range of features for customizing the generated image.

NOTE:: You can obtain the Pix Key (pix_copy_past) through the "paymentInit" endpoint, as depicted in the image below.

The process of converting a Pix Key to a QR Code using this library is relatively simple. First, you need to define the Pix Key that will be used as the basis for generating the code. Then, using the QRcode function of the Mpdf\QrCode library, it is possible to generate the corresponding QR Code for the Pix Key.

<?php
        use Mpdf\QrCode\QrCode;
        use Mpdf\QrCode\Output;
        $objNewQrCode = new QrCode($pix_copia_cola); // Converting to QR Code
        $imageNew = (new Output\Png)->output($objNewQrCode, 500);
?>
// 
<img src="data:image/png;base64,<?= base64_encode($imageNew)?>" style="display: block; margin-left: auto; margin-right: auto; width: 10%">

<h1><?php echo $pix_copia_cola;?></h1> // Only Pix Key

It is important to remember that this is just an example of how to perform this conversion using the PHP language and the Mpdf\QrCode library. If you prefer, you can use other programming languages and similar libraries to achieve the same goal.

Regardless of the programming language used, converting the Pix Key to a QR Code is a very useful feature for businesses that want to offer payment through this technology to their customers. In addition to being a practical and secure option, the Pix QR Code can be easily read by banking apps, making the payment process faster and more efficient.

Last updated