payjs
Version 1.5.0
This project is a Composer 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 Laravel Development Kit
Install via Composer
$ composer require xhat/payjs
First introduced in the business
<?php
require_once __DIR__ . ' /vendor/autoload.php ' ;
use Xhat Payjs Payjs ;
// 配置通信参数
$ config = [
' mchid ' => ' 12323412323 ' , // 配置商户号
' key ' => ' sadfsaddsaf ' , // 配置通信密钥
];
// 初始化
$ payjs = new Payjs ( $ config );
Next start using
// 构造订单基础信息
$ data = [
' body ' => '订单测试' , // 订单标题
' total_fee ' => 2 , // 订单金额
' out_trade_no ' => time (), // 订单号
' attach ' => ' test_order_attach ' , // 订单附加信息(可选参数)
' notify_url ' => ' https://www.baidu.com ' , // 异步通知地址(可选参数)
];
$ result = $ payjs -> native ( $ data );
print_r ( $ result );
// 构造订单基础信息
$ data = [
' body ' => '订单测试' , // 订单标题
' total_fee ' => 2 , // 订单金额
' out_trade_no ' => time (), // 订单号
' attach ' => ' test_order_attach ' , // 订单附加信息(可选参数)
' notify_url ' => ' https://www.baidu.com ' , // 异步通知地址(可选参数)
' callback_url ' => ' https://www.baidu.com ' , // 支付后前端跳转地址(可选参数)
];
$ url = $ payjs -> cashier ( $ data );
header ( ' Location: ' . $ url );
exit ;
// 构造订单基础信息
$ data = [
' body ' => '订单测试' , // 订单标题
' total_fee ' => 2 , // 订单金额
' out_trade_no ' => time (), // 订单号
' attach ' => ' test_order_attach ' , // 订单附加信息(可选参数)
' notify_url ' => ' https://www.baidu.com ' , // 异步通知地址(可选参数)
' openid ' => ' xxxxxxxxxxxxx ' , // OPENID (必选参数)
];
$ result = $ payjs -> jsapi ( $ data );
print_r ( $ result );
// 构造订单基础信息
$ data = [
' body ' => '订单测试' , // 订单标题
' total_fee ' => 2 , // 订单金额
' out_trade_no ' => time (), // 订单号
' attach ' => ' test_order_attach ' , // 订单附加信息(可选参数)
' notify_url ' => ' https://www.baidu.com ' , // 异步通知地址(可选参数)
' callback_url ' => ' https://www.qq.com ' , // 前端跳转url(可选参数)
];
$ result = $ payjs -> mweb ( $ data );
print_r ( $ result );
// 根据订单号查询订单状态
$ payjs_order_id = ' ******************** ' ;
$ result = $ payjs -> check ( $ payjs_order_id );
print_r ( $ result );
// 根据订单号关闭订单
$ payjs_order_id = ' ******************** ' ;
$ result = $ payjs -> close ( $ payjs_order_id );
print_r ( $ result );
// 根据订单号退款
$ payjs_order_id = ' ********************* ' ;
$ result = $ payjs -> refund ( $ payjs_order_id );
print_r ( $ result );
// 构造订单基础信息
$ data = [
' mchid ' => ' 123123 ' , // 商户号
];
$ result = $ payjs -> complaint ( $ data );
print_r ( $ result );
// 返回商户基础信息
$ result = $ payjs -> info ();
print_r ( $ result );
// 根据订单信息中的 OPENID 查询用户资料
$ openid = ' ******************* ' ;
$ result = $ payjs -> user ( $ openid );
print_r ( $ result );
// 根据订单信息中的银行编码查询银行中文名称
$ bank = ' ******************* ' ;
$ result = $ payjs -> bank ( $ bank );
print_r ( $ result );
// 接收异步通知,无需关注验签动作,已自动处理
$ notify_info = $ payjs -> notify ();
// 接收信息后自行处理
Version 1.5.0 adds complaint API and adds H5 payment API
Version 1.4.3 mainly removes the dependence on the GuzzleHttp package, removes the Curl 60 error prompt, and fixes a bug in jsapi.
If you find any bugs during use, please give positive feedback and I will fix it as soon as possible.