可以用PHP创建扫描支付二维码吗?

问题描述 投票:0回答:1

我正在开发自己的插件来处理 PDF 生成(发票、形式等)。我想包含 QR 码,如果用户在银行应用程序中扫描,它将为其设置付款数据(姓名、iban、变量符号、付款金额等)。

我使用 TCPDF 生成二维码,但二维码的内容需要设置为特定字符串(可能是带有支付信息的哈希数据)。

所以这让我想到了我的问题,有没有办法生成这个代码,该代码将以二维码的形式输出,以便客户可以打开他们的银行应用程序并扫描它以自动设置支付数据? 在WordPress 网站。

我对这个主题很陌生,所以我想知道这个东西是否可能。

    // Create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

// Set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Your Name');
$pdf->SetTitle('Scan and Pay QR Code Example');

// Add a page
$pdf->AddPage();

// Set QR code style
$style = array(
    'border' => 2,
    'vpadding' => 'auto',
    'hpadding' => 'auto',
    'fgcolor' => array(0,0,0),
    'bgcolor' => false, // No background color
    'module_width' => 1, // Width of a single module in points
    'module_height' => 1 // Height of a single module in points
);

// Define the content of the QR code that includes a variable symbol and an amount
$variableSymbol = "1111";
$amount = "1 EUR";
$merchantCode = "123456789012";
$transactionCurrency = "978"; // EUR's numeric code

// This is the string that should be formatted in a way that bank apps can read it. HERE IS THE PROBLEM
$codeContents = "TXN:".$variableSymbol."-AMT:".$amount."-MCC:".$merchantCode."-CUR:".$transactionCurrency;

// Print a QR code
$pdf->write2DBarcode($codeContents, 'QRCODE,H', 20, 20, 50, 50, $style, 'N');

// Close and output PDF document
$pdf->Output('scan_and_pay_qr.pdf', 'D');
?>

我尝试根据一些在线文档(SEPA、EMVCo)包含数据,但未能成功。它在我的银行应用程序中显示无效的二维码数据。

php wordpress qr-code payment tcpdf
1个回答
-1
投票

是的,这很有可能

© www.soinside.com 2019 - 2024. All rights reserved.