Static QR Code

Payrexx enables you to create Static QR Codes with TWINT payment provider for your own webshop.

Create a Static QR Code - Gastro Case

You can create a Static QR Code with our Merchant API. For simplicity, we will explain it with the example of the QR Code creation.

Step 1: Create a QR Code

Create a QR Code with the mandatory parameters:

The webshopUrl is a mandatory field.

Your QR Code can be scanned using any QR Code scanner.

Step 2: Display the QR Code

After Step 1, you will get a QR Code string in the response of your request. Use this string as src attribute in HTML image tag. Now your QR Code can be displayed as image.

Step 3: Scan the QR Code

If the buyer scans the QR Code using TWINT app, they will be redirected to your webshop URL with the following parameters.

  • qr_code_session_id

  • returnAppScheme (iOS)

  • returnAppPackage (Android)

Example Redirects

Scanned using a TWINT app

  • iOS: https://{{webshopUrl}}?qr_code_session_id={{session}}&returnAppScheme={{appName}}

  • Android: https://{{webshopUrl}}?qr_code_session_id={{session}}&returnAppPackage={{appName}}

Scanned using a regular QR code scanner app

  • https://{{webshopUrl}}

Step 4: Gateway

Once the buyer has selected their products on your webshop and is ready to pay, you have to Create a Gateway with the corresponding amount and currency (optional: basket).

In Gateway creation you need to pass the QR Code session ID and the "return app" parameter:

$gateway->setQrCodeSessionId($_GET['qr_code_session_id']);
if ($_GET['returnAppScheme']) {
    $returnApp = 'returnAppScheme=' . $_GET['returnAppScheme']; // iOS
} else if ($_GET['returnAppPackage']) {
    $returnApp = 'returnAppPackage=' . $_GET['returnAppPackage']; // Android
}
$gateway->setReturnApp($returnApp);

In the Gateway response you will get the TWINT app link:

{
  "status": "success",
  "data": [
    {
      "transactionId": "100",
      "appLink": "intent://payment#Intent;action=ch.twint.action.TWINT_PAYMENT;scheme=twint;S.code=12345;S.startingOrigin=EXTERNAL_WEB_BROWSER;S.browser_fallback_url=;end", // Android
      // "appLink": 'twint-issuer1://applinks/?al_applink_data={"app_action_type": "TWINT_PAYMENT","extras": {"code": "12345",},"referer_app_link": {"target_url": "", "url": "", "app_name": "EXTERNAL_WEB_BROWSER"}, "version": "6.0" }' // iOS
    }
  ]
}

Once you received the appLink in the response, you need to open it. So the TWINT app will be automatically opened for the buyer.

Parallel to this you have to start a transaction polling using the transactionId in the response and the Retrieve a transaction endpoint. You can perform the GET request every second until the transaction status changes from initiated to confirmed or cancelled. Once the status has changed, you can show the corresponding result page on your webshop.

Scan the QR Code (Other App / Camera)

If the customer scans the QR Code other than TWINT app, they will also be redirected to your webshop url. But without special parameters. When the buyer is ready to pay in your webshop, you have to Create a Gateway.

Other as in the TWINT app case you have to create the Gateway with the following redirect URLs.

$gateway->setSuccessRedirectUrl('https://www.merchant-website.com/success');
$gateway->setFailedRedirectUrl('https://www.merchant-website.com/failed');
$gateway->setCancelRedirectUrl('https://www.merchant-website.com/cancel');

You will receive a link in the Gateway response as mentioned here. You just need to open the link. The buyer will be redirected to Payrexx Gateway page. There the buyer can choose their preferred payment method and do the payment. Once the payment is done, they will be redirected to the URL which is set in the Gateway creation.

Delete a QR Code

You can delete the QR Code using Delete a QR Code endpoint.

When cancelling the order process in your webshop you also have to destroy the session to prevent possible payments after cancellation. You can delete the QR Code Scan using Delete a QR Code Scan endpoint by setting the session ID (see Step 3: Scan the QR Code).

Last updated