Skip to main content

Request/Response: Generate QR (generate_qr)

Be Aware Of

This parameter ONLY working with those integration types (Hosted Payment Page, Invoices(Payment Endpoint)).

be aware of
The hosted After the Payment Page expiration time elapsed, which is 20 minutes, if no action had been taken from the user side, the page would be expired, and the transaction would be considered deleted from the PayTabs system.

In the evolving landscape of online payments, accurate identification and management of merchant accounts are crucial. PayTabs introduces the generate_qr parameter, One of the optional parameters provides you with a QR code to share with your customers to speed up the payment process. This parameter will return a encoded Base64 string, that you can encoded to image and print or share with your customers.


How this parameter could benefit you?​

The generate_qr parameter offers significant advantages for payment experience. Here’s how it can benefit you:

  • Enhanced Customer Convenience:
    • Frictionless Payment Process: Customers can simply scan the QR code with their smartphones, avoiding manual entry of payment details or URLs.
    • Universal Accessibility: QR codes are supported across various mobile devices and apps, making them accessible to a wide audience.

  • Increased Payment Speed:
    • Instant Redirection: Scanning the QR code redirects customers directly to the payment page, speeding up the checkout process.
    • Reduced Abandonment Rates: A faster checkout reduces the likelihood of customers abandoning their purchases due to complex payment processes.

  • Improved User Experience:
    • Ease of Use: A single scan simplifies the payment process, enhancing the overall shopping experience.
    • Seamless Transition: Customers are guided smoothly from the point of sale to the payment gateway.

  • Support for Contactless Payments:
    • Hygienic and Safe Transactions: Particularly important in post-pandemic times, QR codes support touch-free payments, boosting customer trust.
    • In-Person Sales Integration: Perfect for physical stores or events where customers can scan the QR code displayed on invoices, receipts, or signage.

  • Enhanced Branding Opportunities
    • Custom QR Codes: Merchants can design QR codes with their brand colors and logos to strengthen brand identity.
    • Marketing Integration: QR codes can double as marketing tools by embedding additional URLs for promotions or loyalty programs.

  • Cross-Platform Compatibility
    • No App Dependency: Customers can use any QR scanning app or the built-in scanner in their mobile cameras, ensuring compatibility across operating systems.
    • Diverse Use Cases: Works for both desktop (via screenshots) and mobile users.

Name but a few different Businesses/Industries that can benefit from this API parameter:

  • Retail & E-commerce
    • Online Stores: QR codes in digital invoices or order confirmation emails simplify customer payments.
    • Brick-and-Mortar Stores: Use QR codes at checkout counters for customers to pay directly using their smartphones.
    • Pop-Up Shops & Market Stalls: Portable QR codes are ideal for temporary retail setups

  • Food & Beverage
    • Restaurants & CafΓ©s: Allow customers to scan a QR code at their table to pay their bills without waiting for a server.
    • Food Trucks: Perfect for mobile food vendors needing quick, contactless payment options.
    • Online Food Delivery Services: Include QR codes in digital receipts or email confirmations.

  • Hospitality & Travel
    • Hotels & Resorts: Simplify payments for room bookings, amenities, or services by integrating QR codes in booking confirmations.
    • Travel Agencies: QR codes can facilitate quick payments for tours, packages, or airline tickets.
    • Transportation Services: Taxi services or ride-sharing platforms can use QR codes for fare payments.

  • Education
    • Schools & Universities: Enable students or parents to pay tuition fees by scanning a QR code in payment notifications.
    • Online Learning Platforms: Simplify subscription or course fee payments with embedded QR codes.

  • Entertainment & Events
    • Event Organizers: Include QR codes on tickets or invitations for attendees to pay for additional services or donations.
    • Cinemas & Theaters: Allow customers to pay for tickets or concessions using QR codes.
    • Gaming Platforms: Gamers can scan QR codes for in-app purchases or subscription renewals.

  • Nonprofits & Charities
    • Donation Campaigns: QR codes make it easy for donors to contribute directly to fundraising efforts.
    • Fundraising Events: Display QR codes at events for instant donations.

  • Freelancers & Small Businesses
    • Freelancers: Include QR codes in invoices for easy client payments.
    • Home-Based Businesses: Use QR codes to accept payments for handmade products or services.

  • Government & Public Services
    • Tax Payments: Provide QR codes on tax forms or notifications for easy payment submission.
    • Public Utilities: Use QR codes for payments of municipal services or fines.

  • Automotive
    • Car Dealerships: QR codes for booking test drives, paying deposits, or purchasing vehicles.
    • Repair Shops: Simplify invoice payments with QR codes.

How to Use?​

In order for you to start use the generate_qr parameter, you kindly need to follow the below simple steps:

  • Within the initiation of the request payload of the payment page as mentioned in Step 3, you will use the optional parameter generate_qr within the main request payload itself as shown below:

    {
    ...
    "generate_qr": true,
    ....
    }

  • Once you post your request, you will receive a response that includes the redirect_qr contain the encoded Base64 code of the image.

    Warning

    Only in "Invoices" integration type (via the invoice endpoint), you will NOT receive the redirect_qr in the response, as mentioned in theInvoices - Step 3 | Initiate the payment manual.

    {
    ...
    "redirect_qr": "iVBORw0KGgoAAAANSUg23F2LyCJF7GEBtwaSCEl0J4B+MkwkBA4lWMDbIAyS9s6f..........",
    ....
    }


Parameter Specifications​

  • generate_qr

    Parameter
    generate_qr
    DescriptionIf you set this parameter to true you will get a QR code image as encoded Base64 code within the response payload.
    Data TypeBOOLEAN
    Required✘
    Sample
    {
    "generate_qr": true
    }

Request & Response Payloads Samples​

The below sample request payload will show you how you can pass the above-mentioned required parameter, which are needed to be passed with valid values to perform a request. Along with the response payload received after using this request payload.

{
"profile_id": "79010",
"tran_type": "sale",
"tran_class": "ecom",
"cart_id": "cart_1",
"cart_currency": "SAR",
"cart_amount": 12.3,
"cart_description": "Description of the items/services",
"generate_qr": true
}


Expected Payment Flow Behavior​

  1. As mentioned above in the How to use? section, As a merchant you would initiate a payment request per the above Specifications, same as the sample codes mentioned in the samples section above.

  2. Then, you will receive a response that includes the redirect_qr as a result of set the generate_qr to true, along with the redirect URL. This means you have initiated a correct payment request/page successfully.

    {
    .
    .
    "redirect_url": "https://secure.paytabs.sa/payment/wr/5DBXXX4F5BB9C2EXXXX8249E75E3D4D8C84",
    "redirect_qr": "iVBORw0KGgoAAAANSUhEUgAAAggAAAIICAI..........",
    .
    .
    }

  3. Next, you should redirect your customer to this URL so the payment process can be finalized, or use the QR code, you can use the QR code image through HTML, make it downloadable, or decode it via your backend/frontend language and sent it as an image to your customer/s, as following:

    To use Data URLs through the src attribute you must start the code with the format data:[<media-type>][;base64],<data> which in our case will be data:image/png;base64,. After that, you need to insert the QR Code data.

    Some browsers might fail to display your image if you use an unexpected text encoding. To be safe, always specify your MIME Content-Type and Content-Encoding:
    //Image
    <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...." />

    //Link
    <a download="QR.png" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA....">download image</a>

  4. After this, your customer will scan the QR code:

    QR Code

    Scanning the QR code will generate the payment page that the customer would proceed normally with payment by redirected to the payment link.

    Payment Page

  5. Then, he will be redirected to his issuer bank 3DS/OTP page to authenticate the used card

  6. Finally, he would be redirect to a success/error page accordingly. By this time, you will be able to see his transaction on your merchant dashboard, whether it's accepted/authorized or not.transaction view

    transaction view

We are glad to be always in help. We aim to serve you better each time. As such, please spare a minute to share feedback about your recent experience with PayTabs Developers , on Trustpilot, or Google Reviews.