Skip to content
thenbsp edited this page Sep 5, 2016 · 3 revisions

描码支付(临时模式)

use Thenbsp\Wechat\Payment\Unifiedorder;
use Thenbsp\Wechat\Payment\Qrcode\Temporary;

$unifiedorder = new Unifiedorder('appid', 'mch_id', 'key');
$unifiedorder->set('body',          '微信支付测试商品');
$unifiedorder->set('total_fee',     1);
$unifiedorder->set('openid',        'OPENID');
$unifiedorder->set('out_trade_no',  date('YmdHis').mt_rand(10000, 99999));
$unifiedorder->set('notify_url',    'http://example.com/your-notify.php');

$qrcode = new Temporary($unifiedorder);
$payurl = $qrcode->getPayurl();

HTML

示例中使用的在线二维码生成工具,实际应用中可使用第三方包生成二维码。

<img src="http://qr.liantu.com/api.php?&bg=ffffff&fg=000000&text=<?php echo $payurl; ?>" />