<?php
namespace App\Facades;
use EasyWeChat\Payment\Order;
use SimpleSoftwareIO\QrCode\Facades\QrCode;
class WeChat
{
//这个函数是产生二维码
public static function getImg($tradeNo, $title, $money)
{
$attributes = [
'body' => $title,
'detail' => $title,
'total_fee' => $money * 100,
'out_trade_no' => $tradeNo,
'notify_url' => url('/api/weixin/notify'),
'trade_type' => 'NATIVE',
];
$order = new Order($attributes);
$weChat = app('wechat');
$payment = $weChat->payment;
$result = $payment->prepare($order);
if ($result->return_code == 'SUCCESS' && $result->result_code == 'SUCCESS') {
$codeUrl = $result->code_url;
$img = QrCode::size(300)->generate($codeUrl);
return $img;
}
return false;
}
}
然后我扫完支付回,我的地址/api/weixin/notify..收到微信5次的回调,一模一样的