diff --git a/README.md b/README.md index a10c475..a8a7775 100644 --- a/README.md +++ b/README.md @@ -145,101 +145,7 @@ return Pay::alipay($config)->gateway('web')->pay($order); ### 5. 查询订单 -### 13、微信 - 发放裂变红包 -#### 最小配置参数 -```php - [ - 'app_id'=>'wxaxxxxxxxx', - 'mch_id' => '1442222202', - 'key' => 'ddddddddddddddd', - 'cert_client' => 'D:\php\xxx\application\wxpay\cert\apiclient_cert.pem', - 'cert_key' => 'D:\php\xxx\application\wxpay\cert\apiclient_key.pem', - ], - ]; - - $config_biz = [ - 'wxappid'=>'wxaxxxxxxxx', - 'mch_billno' => 'hb'.time(), - 'send_name'=>'萌点云科技',//商户名称 - 're_openid'=>'ogg5JwsssssssssssCdXeD_S54',//用户openid - 'total_amount' =>333, // 付款金额,单位分 - 'wishing'=>'提前祝你狗年大吉',//红包祝福语 - 'client_ip'=>'192.168.0.1',//调用接口的机器Ip地址 - 'total_num'=>'3',//红包发放总人数 - 'act_name'=>'提前拜年',//活动名称 - 'remark'=>'提前祝你狗年大吉,苟富贵勿相忘!', //备注 - 'amt_type'=>'ALL_RAND',//ALL_RAND—全部随机,商户指定总金额和红包发放总人数,由微信支付随机计算出各红包金额 - ]; - - $pay = new Pay($config); - try - { - $res= $pay->driver('wechat')->gateway('groupredpack')->pay($config_biz); - - }catch (Exception $e){ - - } - -``` - -#### 所有配置参数 -具体请看 [官方文档](https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_5&index=4)。 - -#### 返回值 -- pay() -类型:array -说明:返回用于 支付结果 的数组。具体请 [参考这里](https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_5&index=4)。 - - -### 14、微信 - 发放普通红包 - -#### 最小配置参数 -```php - [ - 'app_id'=>'wxaxxxxxxxx', - 'mch_id' => '1442222202', - 'key' => 'ddddddddddddddd', - 'cert_client' => 'D:\php\xxx\application\wxpay\cert\apiclient_cert.pem', - 'cert_key' => 'D:\php\xxx\application\wxpay\cert\apiclient_key.pem', - ], - ]; - - $config_biz = [ - 'wxappid'=>'wxaxxxxxxxx', - 'mch_billno' => 'hb'.time(), - 'send_name'=>'萌点云科技',//商户名称 - 're_openid'=>'ogg5JwsssssssssssCdXeD_S54',//用户openid - 'total_amount' =>100, // 付款金额,单位分 - 'wishing'=>'提前祝你狗年大吉',//红包祝福语 - 'client_ip'=>'192.168.0.1',//调用接口的机器Ip地址 - 'total_num'=>'1',//红包发放总人数 - 'act_name'=>'提前拜年',//活动名称 - 'remark'=>'提前祝你狗年大吉,苟富贵勿相忘!', //备注 - ]; - - $pay = new Pay($config); - try - { - $res= $pay->driver('wechat')->gateway('redpack')->pay($config_biz); - - }catch (Exception $e){ - - } - -``` - -#### 所有配置参数 -具体请看 [官方文档](https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_4&index=3)。 - -#### 返回值 -- pay() -类型:array -说明:返回用于 支付结果 的数组。具体请 [参考这里](https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_4&index=3)。 ## 代码贡献 由于测试及使用环境的限制,本项目中只开发了「支付宝」和「微信支付」的相关支付网关。 diff --git a/src/Gateways/Wechat/GroupredpackGateway.php b/src/Gateways/Wechat/GroupredpackGateway.php deleted file mode 100644 index 2e76f10..0000000 --- a/src/Gateways/Wechat/GroupredpackGateway.php +++ /dev/null @@ -1,82 +0,0 @@ - - * - * @param array $config_biz - * - * @return mixed - */ - public function pay(array $config_biz = []) - { - if (is_null($this->user_config->get('app_id'))) { - throw new InvalidArgumentException('Missing Config -- [app_id]'); - } - unset($this->config['sign_type']); - unset($this->config['trade_type']); - unset($this->config['notify_url']); - unset($this->config['app_id']); - unset($this->config['appid']); - $this->config = array_merge($this->config, $config_biz); - $this->config['sign'] = $this->getSign($this->config); - $data = $this->fromXml($this->post( - $this->endpoint.$this->gateway_transfer, - $this->toXml($this->config), - [ - 'cert' => $this->user_config->get('cert_client', ''), - 'ssl_key' => $this->user_config->get('cert_key', ''), - ] - )); - if (!isset($data['return_code']) || $data['return_code'] !== 'SUCCESS' || $data['result_code'] !== 'SUCCESS') { - $error = 'getResult error:'.$data['return_msg']; - $error .= isset($data['err_code_des']) ? ' - '.$data['err_code_des'] : ''; - } - - if (isset($error)) { - throw new GatewayException( - $error, - 20000, - $data); - } - - return $data; - } - - /** - * get trade type config. - * - * @author yansongda - * - * @return string - */ - protected function getTradeType() - { - return ''; - } -} diff --git a/src/Gateways/Wechat/RedpackGateway.php b/src/Gateways/Wechat/RedpackGateway.php deleted file mode 100644 index 557a92e..0000000 --- a/src/Gateways/Wechat/RedpackGateway.php +++ /dev/null @@ -1,86 +0,0 @@ - - * - * @param array $config_biz - * - * @return mixed - */ - public function pay(array $config_biz = []) - { - if (is_null($this->user_config->get('app_id'))) { - throw new InvalidArgumentException('Missing Config -- [app_id]'); - } - unset($this->config['sign_type']); - unset($this->config['trade_type']); - unset($this->config['notify_url']); - unset($this->config['app_id']); - unset($this->config['appid']); - - $this->config = array_merge($this->config, $config_biz); - - $this->config['sign'] = $this->getSign($this->config); - - $data = $this->fromXml($this->post( - $this->endpoint.$this->gateway_transfer, - $this->toXml($this->config), - [ - 'cert' => $this->user_config->get('cert_client', ''), - 'ssl_key' => $this->user_config->get('cert_key', ''), - ] - )); - - if (!isset($data['return_code']) || $data['return_code'] !== 'SUCCESS' || $data['result_code'] !== 'SUCCESS') { - $error = 'getResult error:'.$data['return_msg']; - $error .= isset($data['err_code_des']) ? ' - '.$data['err_code_des'] : ''; - } - - if (isset($error)) { - throw new GatewayException( - $error, - 20000, - $data); - } - - return $data; - } - - /** - * get trade type config. - * - * @author yansongda - * - * @return string - */ - protected function getTradeType() - { - return ''; - } -}