Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Team

I am testing qr code using php library with master qr code, but some strange reason the banking app is not recognized master card qr code. What do i need to improve my logic for the banking app when scanning to pay recognizes?

What I have tried:

PHP
<pre><?php
require "vendor/autoload.php";

use Endroid\QrCode\QrCode;
use Endroid\QrCode\ErrorCorrectionLevel;
use Endroid\MastercardQR\MastercardQRCode;

// Define the payment data
$paymentData = [
    "merchant" => "****",
    "amount" => 100.00, // Payment amount
    "currency" => "USD", // Payment currency
    "reference" => "123456789" // Payment reference
];

// Generate the Mastercard QR code payload
$payload = "MC" . json_encode($paymentData);

// Create the QR code
$qrCode = new QrCode($payload);

// Set QR code options
$qrCode->setSize(300); // Set the size of the QR code
$qrCode->setErrorCorrectionLevel(ErrorCorrectionLevel::LOW); // Set error correction level
//$qrCode->setEncoding(new Encoding('UTF-8')); // Set encoding

// Save the QR code as a PNG image
$qrCode->writeFile('C:/wamp64/www/eCommerce/eshopper/eshopper-1.0.0/img/qrcode.png');

// Output the QR code image
header("Content-Type: image/png");
echo $qrCode->writeString();
exit();

echo "QR code generated successfully!";
?>
Posted
Comments
Richard Deeming 12-Jun-23 5:56am    
$qrCode->writeFile('C:/wamp64/www/eCommerce/eshopper/eshopper-1.0.0/img/qrcode.png');

That overwrites a single file for every request. If two users hit your page at the same time, the image for one will overwrite the image for the other.

But since you don't seem to be using that file anyway, it's probably best to remove that line.
Andre Oosthuizen 12-Jun-23 6:55am    
Add
error_reporting(E_ALL);
ini_set('display_errors', 1);
at the top of your page to see where the code error occur. The '->writeString' might be the cause as well but then we cannot see what happens in this class function.
Gcobani Mkontwana 12-Jun-23 10:28am    
@Richard Deeming thanks for updating me, will do so.@Andre Oosthuizen noted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900