From 3e5c87b2de2b6871cf50ceb05a6d0dc5e467865b Mon Sep 17 00:00:00 2001 From: Andy Date: Fri, 11 Sep 2020 14:16:44 +0800 Subject: [PATCH] add h5 api --- readme.md | 28 ++++++++++++++++++++++++++++ src/Payjs.php | 40 ++++++++++++++++++++++++++++++---------- 2 files changed, 58 insertions(+), 10 deletions(-) diff --git a/readme.md b/readme.md index efcc500..8b1f86a 100644 --- a/readme.md +++ b/readme.md @@ -104,6 +104,31 @@ $data = [ return Payjs::jsapi($data); ``` +- H5支付 + +```php +// 构造订单基础信息 +$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); +``` + +- 投诉查询 + +```php +// 构造订单基础信息 +$data = [ + 'mchid' => '123123', // 商户号 +]; +return Payjs::complaint($data); +``` + - 查询订单 ```php @@ -161,6 +186,9 @@ Log::info($notify_info); ``` ## 更新日志 +Version 1.5.0 +增加投诉API、H5支付API + Version 1.4 修正空值参数的过滤问题 diff --git a/src/Payjs.php b/src/Payjs.php index 05b0e6a..8c3ad97 100644 --- a/src/Payjs.php +++ b/src/Payjs.php @@ -14,6 +14,10 @@ class Payjs private $api_url_user; private $api_url_info; private $api_url_bank; + private $api_url_jsapi; + private $api_url_facepay; + private $api_url_complaint; + private $api_url_mweb; public function __construct() { @@ -21,16 +25,18 @@ public function __construct() $this->key = config('payjs.key'); $api_url = config('payjs.api_url'); - $this->api_url_native = $api_url . 'native'; - $this->api_url_cashier = $api_url . 'cashier'; - $this->api_url_refund = $api_url . 'refund'; - $this->api_url_close = $api_url . 'close'; - $this->api_url_check = $api_url . 'check'; - $this->api_url_user = $api_url . 'user'; - $this->api_url_info = $api_url . 'info'; - $this->api_url_bank = $api_url . 'bank'; - $this->api_url_jsapi = $api_url . 'jsapi'; - $this->api_url_facepay = $api_url . 'facepay'; + $this->api_url_native = $api_url . 'native'; + $this->api_url_cashier = $api_url . 'cashier'; + $this->api_url_refund = $api_url . 'refund'; + $this->api_url_close = $api_url . 'close'; + $this->api_url_check = $api_url . 'check'; + $this->api_url_user = $api_url . 'user'; + $this->api_url_info = $api_url . 'info'; + $this->api_url_bank = $api_url . 'bank'; + $this->api_url_jsapi = $api_url . 'jsapi'; + $this->api_url_facepay = $api_url . 'facepay'; + $this->api_url_complaint = $api_url . 'complaint'; + $this->api_url_mweb = $api_url . 'mweb'; } // 扫码支付 @@ -71,6 +77,20 @@ public function facepay(array $data) return $this->post($data); } + // 投诉订单 + public function complaint(array $data) + { + $this->url = $this->api_url_complaint; + return $this->post($data); + } + + // MWEB(H5) 支付 + public function mweb(array $data) + { + $this->url = $this->api_url_mweb; + return $this->post($data); + } + // 关闭订单 public function close($payjs_order_id) {