payjs laravel
Version 1.6.0
This project is a Laravel Package developed based on the API of PAYJS and can be directly used in the production environment.
PAYJS provides WeChat payment access capabilities for individual subjects. It is a formal, safe and reliable WeChat payment personal development interface that has been tested.
Other versions: PAYJS Universal Development Kit
Support Laravel 5.x, Laravel 6.x, Laravel 7.x, Laravel 8.x
Install via Composer
$ composer require xhat/payjs-laravel
php artisan vendor:publish --provider= " XhatPayjsPayjsServiceProvider "
config/payjs.php
to configure the merchant number and communication key return [
' mchid ' => '' , // 填写商户号
' key ' => '' , // 填写通信KEY
];
First introduce the facade in the business module
use Xhat Payjs Facades Payjs ;
// 构造订单基础信息
$ data = [
' body ' => '订单测试' , // 订单标题
' total_fee ' => 2 , // 订单标题
' out_trade_no ' => time (), // 订单号
' attach ' => ' test_order_attach ' , // 订单附加信息(可选参数)
' notify_url ' => ' https://www.baidu.com/notify ' , // 异步通知地址(可选参数)
];
return Payjs:: native ( $ data );
// 构造订单基础信息
$ data = [
' body ' => '订单测试' , // 订单标题
' total_fee ' => 2 , // 订单金额
' out_trade_no ' => time (), // 订单号
' attach ' => ' test_order_attach ' , // 订单附加信息(可选参数)
' notify_url ' => ' https://www.baidu.com/notify ' , // 异步通知地址(可选参数)
' callback_url ' => ' https://www.baidu.com/callback ' , // 支付后前端跳转地址(可选参数)
];
$ url = Payjs:: cashier ( $ data );
return redirect ( $ url );
// 构造订单基础信息
$ data = [
' body ' => '订单测试' , // 订单标题
' total_fee ' => 2 , // 订单金额
' out_trade_no ' => time (), // 订单号
' attach ' => ' test_order_attach ' , // 订单附加信息(可选参数)
' openid ' => ' xxxxxxxxxxxxxxxxx ' , // 订单附加信息(可选参数)
' notify_url ' => ' https://www.baidu.com/notify ' , // 异步通知地址(可选参数)
];
return Payjs:: jsapi ( $ data );
// 构造订单基础信息
$ data = [
' body ' => '订单测试' , // 订单标题
' total_fee ' => 2 , // 订单金额
' out_trade_no ' => time (), // 订单号
' attach ' => ' test_order_attach ' , // 订单附加信息(可选参数)
' notify_url ' => ' https://www.baidu.com/notify ' , // 异步通知地址(可选参数)
' callback_url ' => ' https://www.baidu.com ' , // 前端跳转地址(可选参数)
];
return Payjs:: mweb ( $ data );
// 构造订单基础信息
$ data = [
' mchid ' => ' 123123 ' , // 商户号
];
return Payjs:: complaint ( $ data );
// 根据订单号查询订单状态
$ payjs_order_id = ' **************** ' ;
return Payjs:: check ( $ payjs_order_id );
// 根据订单号关闭订单
$ payjs_order_id = ' **************** ' ;
return Payjs:: close ( $ payjs_order_id );
// 根据订单号退款
$ payjs_order_id = ' **************** ' ;
return Payjs:: refund ( $ payjs_order_id );
// 返回商户基础信息
return Payjs:: info ();
// 根据订单信息中的 OPENID 查询用户资料
$ openid = ' *************** ' ;
return Payjs:: user ( $ openid );
// 根据订单信息中的银行编码查询银行中文名称
$ bank = ' *************** ' ;
return Payjs:: bank ( $ bank );
// 接收异步通知,无需关注验签动作,已自动处理
$ notify_info = Payjs:: notify ();
Log:: info ( $ notify_info );
Version 1.5.0 adds complaint API and H5 payment API
Version 1.4 fixes the filtering problem of null parameters
If you find any bugs during use, please give positive feedback and I will fix it as soon as possible.