gaolei / weilan-pay
微蓝支付:支持多种支付方式-支付宝、微信、QQ
v1.0.2
2021-07-12 12:44 UTC
Requires
- php: >=7.1
This package is not auto-updated.
Last update: 2025-04-02 01:14:24 UTC
README
微蓝支付 对接库
安装方式
composer require gaolei/weilan-pay
发起支付
use GaoLei\WeilanPay\WeiLan;
$payer = WeiLan::create([
'mchId' => '******',
'apiKey' => '**************************'
]);
$orderParams = [
'type' => $payer::TYPE_WX,
'out_trade_no' => date('YmdHis').rand(1000,9999),
'notify_url' => 'http://***.com/notify.php',
'return_url' => 'http://***.com.com/pay/success',
'name' => '***套餐',
'money' => sprintf('%.2f',0.01), // 这里填你自己的支付金额
'sitename' => '***',
];
$payUrl = $payer->generate($orderParams);
// $payUrl 是一个支付链接,直接跳转即可,此链接当前手机微信内无无法打开,建议在普通浏览器内打开
echo $payUrl."\n";
支付回调
notify.php
use GaoLei\WeilanPay\WeiLan;
$params = $_GET;
// 简单打印日志
$body = date('Y-m-d H:i:s') . "\n" . print_r($params, true) . "\n";
file_put_contents('./logs/weilan-notify.log', $body, FILE_APPEND);
if(empty($params['sign'])){
die("FAILED");
}
$payer = WeiLan::create(['mchId' => '******', 'apiKey' => '**************************']);
if($payer->validate($params)){
// 简单打印日志
file_put_contents('./logs/weilan-notify.log', "支付验证成功", FILE_APPEND);
// 这里做你的支付成功逻辑
die('SUCCESS');
}
// 简单打印日志
file_put_contents('./logs/weilan-notify.log', "支付验证失败", FILE_APPEND);
die("FAILED");