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

I am creating a back end for scanning qr code to payment, but the problem the qr code is not showing. But i have installed this library using a composer. The error i am getting is this "
Error: Call to undefined method Endroid\QrCode\QrCode::writeDataUri() in C:\wamp64\www\eCommerce\eshopper\eshopper-1.0.0\payments.php on line 19
"

What I have tried:

<?php
require 'C:\wamp64\www\vendor\autoload.php';

use Endroid\QrCode\QrCode;

// Process the payment and get the necessary data
$amount = $_POST['amount'];
$description = $_POST['description'];

// Generate the payment QR code
$paymentData = [
    'amount' => $amount,
    'description' => $description
];

$qrCode = new QrCode(json_encode($paymentData));
$qrCode->setSize(300);

$qrCodeDataUri = $qrCode->writeDataUri();

// Prepare the response
$response = [
    'qr_code_url' => $qrCodeDataUri
];

// Send the response as JSON
header('Content-Type: application/json');
echo json_encode($response);
?>
PHP

Posted
Comments
Richard MacCutchan 9-Jun-23 8:26am    
The message is clear, QrCode does not include a method named writeDataUri. Check the documentation to see if that is a simple typo, or if the method definitely does not exist.
Andre Oosthuizen 10-Jun-23 5:21am    
Richard's comment should be the answer to close post.

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