Pay with a QR Code
Use cases
Using the Charge/CreateQRCode Web Service, the merchant creates a QR code.
Once created and displayed, the buyer scans the QR Code to pay.
List of payment methods
![]() |
Test
Test the Charge/CreateQRCode Web Service via our playground.
Fields
mandatory
name | Description |
---|---|
Amount to be paid, expressed in its smallest currency unit (cent for euro). | |
Currency of payment. ISO 4217 alpha-3 code. Ex: "EUR" for euro. | |
Choice of payment method: "PAYCONIQ" | |
Buyer's e-mail address. |
recommended
name | Description |
---|---|
Order reference. | |
Validity period in seconds. Another possibility to configure it via the application. | |
size | Possible values: S, M (default), L. |
Payment source. Possible values: 'EC' (default), 'INSTORE', 'APP'. | |
Serial number of the device. Required fieldiftransactionOptions.paymentMethodOptions.paymentSourcehas the valueINSTORE. | |
transactionOptions.paymentMethodOptions.mid | Acquirer contract number. |
Request
Sample query
{ "amount": 10000, "currency": "EUR", "paymentMethodType": "[SELECTED PAYMENT METHOD]", "orderId": "myOrderId-1234", "customer": { "email": "sample@example.com" } }
<!-- <pre data-language="json" data-market="es-PE">
{
 "amount": 200050,
 "currency": "PEN",
 "orderId": "myOrderId-999999", 
 "channelOptions": {
 "channelType": "MAIL",
 "mailOptions": {
 "recipient": "sample@example.com"
 }
 },
 "paymentReceiptEmail": "sample@example.com",
 "expirationDate": "2020-04-20T20:13:26+02:00",
 "locale": "es_PE",
 "dataCollectionForm": "false"
}
</pre>
{ "amount": 200050, "currency": "ARS", "orderId": "myOrderId-999999", "channelOptions": { "channelType": "MAIL", "mailOptions": { "recipient": "sample@example.com" } }, "paymentReceiptEmail": "sample@example.com", "expirationDate": "2020-04-20T20:13:26+02:00", "locale": "es_AR", "dataCollectionForm": "false" }
{ "amount": 200050, "currency": "COP", "orderId": "myOrderId-999999", "channelOptions": { "channelType": "MAIL", "mailOptions": { "recipient": "sample@example.com" } }, "paymentReceiptEmail": "sample@example.com", "expirationDate": "2020-04-20T20:13:26+02:00", "locale": "es_CO", "dataCollectionForm": "false" }
{ "amount": 200050, "currency": "BRL", "orderId": "myOrderId-999999", "channelOptions": { "channelType": "MAIL", "mailOptions": { "recipient": "sample@example.com" } }, "paymentReceiptEmail": "sample@example.com", "expirationDate": "2020-04-20T20:13:26+02:00", "locale": "pt_BR", "dataCollectionForm": "false" }-->
/** * I initialize the PHP SDK */ require_once __DIR__ . '/vendor/autoload.php'; require_once __DIR__ . '/keys.php'; require_once __DIR__ . '/helpers.php'; /** * Initialize the SDK * see keys.php */ $client = new Lyra\Client(); /** * I create a formToken */ $store = array("amount" => 250, "currency" => "EUR", "orderId" => uniqid("MyOrderId"), "customer" => array( "email" => "sample@example.com" )); $response = $client->post("V4/Charge/CreatePayment", $store); /* I check if there are some errors */ if ($response['status'] != 'SUCCESS') { /* an error occurs, I throw an exception */ display_error($response); $error = $response['answer']; throw new Exception("error " . $error['errorCode'] . ": " . $error['errorMessage'] ); } /* everything is fine, I extract the formToken */ $formToken = $response["answer"]["formToken"]; ?>
/** * I initialize the PHP SDK */ require_once __DIR__ . '/vendor/autoload.php'; require_once __DIR__ . '/keys.php'; require_once __DIR__ . '/helpers.php'; /** * Initialize the SDK * see keys.php */ $client = new Lyra\Client(); /** * I create a formToken */ $store = array("amount" => 250, "currency" => "EUR", "orderId" => uniqid("MyOrderId"), "customer" => array( "email" => "sample@example.com" )); $response = $client->post("V4/Charge/CreatePayment", $store); /* I check if there are some errors */ if ($response['status'] != 'SUCCESS') { /* an error occurs, I throw an exception */ display_error($response); $error = $response['answer']; throw new Exception("error " . $error['errorCode'] . ": " . $error['errorMessage'] ); } /* everything is fine, I extract the formToken */ $formToken = $response["answer"]["formToken"]; ?>
Response
There are three response types in the qrCode.qrType
field:
- URL
- DATA
- IMAGE(encoded in
base64
)
Example of a response
URL
{ "webService": "Charge/CreateQRCode", "version": "V4", "applicationVersion": "6.10.0", "status": "SUCCESS", "answer": { "uuid": "3e14c758e0464a1f85f6de287689306d", "amount": 10000, "currency": "EUR", "orderId": "myOrderId-1234", "qrCode": { "expirationDate": "2024-02-22T09:55:44+00:00", "qrType": "URL", "value": "https://secure.lyra.com/checkout(...)entID=253965149&s=M", "copyPasteValue": null, "_type": "URL" }, "_type": "V4/Charge/CreateQRCodeResponse" }, (...) "_type": "V4/WebService/Response" }
The qrCode.value
field contains a URL. The buyer clicks the URL to display the QR Code.
The merchant can also create a QR Code with the generated URL. Example implementation in PHP :
<?php
include('phpqrcode/qrlib.php'); // Load the PHP QR Code librairy
$url='qrCode.value'; // Retrieve the answer.qrCode.value
QRcode::png($url, 'image-qrcode.png'); // Create the QR Code
?>
DATA
{ "webService": "Charge/CreateQRCode", "version": "V4", "applicationVersion": "6.10.0", "status": "SUCCESS", "answer": { "uuid": "3e14c758e0464a1f85f6de287689306d", "amount": 10000, "currency": "EUR", "orderId": "myOrderId-1234", "qrCode": { "expirationDate": "2024-01-04T09:50:27+00:00", "qrType": "DATA", "value": "00020101021226(...)f3f8-44fa-805d-3552f3ae759c5204000053039865802BR5925LYRA NETWORK TEL M PAGAME6009SAO PAULO62070503***630426BD", "_type": "DATA" }, "_type": "V4/Charge/CreateQRCodeResponse" }, (...) "_type": "V4/WebService/Response" }
Use the field valueqrCode.value
to create the QR Code.
Example of implementation in
<?php
include('phpqrcode/qrlib.php'); // Load the PHP QR Code librairy
$value='qrCode.value'; // Retrieve the answer.qrCode.value
QRcode::png($value, 'image-qrcode.png'); // Create the QR Code
?>
IMAGE ( base64 encoded)
{ "webService": "Charge/CreateQRCode", "version": "V4", "applicationVersion": "6.10.0", "status": "SUCCESS", "answer": { "uuid": "3e14c758e0464a1f85f6de287689306d", "amount": 10000, "currency": "EUR", "orderId": "myOrderId-1234", "qrCode": { "expirationDate": "2024-01-04T09:50:27+00:00", "qrType": "IMAGE", "value": "iVBORw07(...)wewJpltJrLXvdENKGtEvQpazhQYeMy3B4up5XyA64lTSD+Apcr0Opbr760ZEKiSLRj8r/F3AH5oAdICpAVIC5A8gD9G7EWe3QLtLAAAAABJRU5ErkJggg==", "_type": "IMAGE" }, "_type": "V4/Charge/CreateQRCodeResponse" }, (...) "_type": "V4/WebService/Response" }
Retrieve the value of the qrCode.value
field encoded in base64
and insert it into a tag img
.
<div> <img src="data:image/png;base64,iVBORw07(...)wewJpltJrLXvdENKGtEvQpazhQYeMy3B4up5XyA64lTSD+Apcr0Opbr760ZEKiSLRj8r/F3AH5oAdICpAVIC5A8gD9G7EWe3QLtLAAAAABJRU5ErkJggg==" alt="QR Code"> </div>
Find the description and all the fields in our playground: QRCodeTransaction
Error handling
Error table
Code | Description |
---|---|
The format of the amount field is invalid or the field is not transmitted. | |
The format of the currency field is invalid or the field is not transmitted. | |
The strongAuthentication parameter is invalid. | |
The description parameter is too long.The maximum length is 65 characters. | |
The locale parameter is invalid. | |
The taxRate parameter is invalid. | |
The taxAmount parameter is invalid. | |
Unknown currency. | |
Currency not supported by the MID. | |
QR Code creation has failed in the application. | |
Error during QR Code creation. | |
The serial number of the device (fieldtransactionOptions.paymentMethodOptions.deviceSerialNumber ) isMandatoryif thetransactionOptions.paymentMethodOptions.paymentSource field has the 'INSTORE’ value. |
Analysis of payment results
To know the payment result, implement the instant payment notification (also known as IPN).