mirror of
https://gitee.com/yansongda/pay.git
synced 2024-12-04 21:29:29 +08:00
Revert " 新增微信普通红包、裂变红包"
This commit is contained in:
parent
ce4e49713e
commit
7f4b23b7f6
94
README.md
94
README.md
@ -145,101 +145,7 @@ return Pay::alipay($config)->gateway('web')->pay($order);
|
||||
|
||||
### 5. 查询订单
|
||||
|
||||
### 13、微信 - 发放裂变红包
|
||||
|
||||
#### 最小配置参数
|
||||
```php
|
||||
<?php
|
||||
$config = [
|
||||
'wechat' => [
|
||||
'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
|
||||
<?php
|
||||
$config = [
|
||||
'wechat' => [
|
||||
'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)。
|
||||
## 代码贡献
|
||||
由于测试及使用环境的限制,本项目中只开发了「支付宝」和「微信支付」的相关支付网关。
|
||||
|
||||
|
@ -1,82 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 发放裂变红包
|
||||
* Class GroupredpackGateway
|
||||
* Date: 2017/12/21
|
||||
* Time: 19:23
|
||||
* Com:萌点云科技(深圳)有限公司.
|
||||
*
|
||||
* Author:陈老司机
|
||||
*
|
||||
* Email:690712575@qq.com
|
||||
*/
|
||||
|
||||
namespace Yansongda\Pay\Gateways\Wechat;
|
||||
|
||||
use Yansongda\Pay\Exceptions\GatewayException;
|
||||
use Yansongda\Pay\Exceptions\InvalidArgumentException;
|
||||
|
||||
class GroupredpackGateway extends Wechat
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $gateway_transfer = 'mmpaymkttransfers/sendgroupredpack';
|
||||
|
||||
/**
|
||||
* pay a order.
|
||||
*
|
||||
* @author yansongda <me@yansongda.cn>
|
||||
*
|
||||
* @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 <me@yansongda.cn>
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getTradeType()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 发放普通红包
|
||||
* Class RedPackGateway
|
||||
* Date: 2017/12/21
|
||||
* Time: 19:23
|
||||
* Com:萌点云科技(深圳)有限公司.
|
||||
*
|
||||
* Author:陈老司机
|
||||
*
|
||||
* Email:690712575@qq.com
|
||||
*/
|
||||
|
||||
namespace Yansongda\Pay\Gateways\Wechat;
|
||||
|
||||
use Yansongda\Pay\Exceptions\GatewayException;
|
||||
use Yansongda\Pay\Exceptions\InvalidArgumentException;
|
||||
|
||||
class RedpackGateway extends Wechat
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $gateway_transfer = 'mmpaymkttransfers/sendredpack';
|
||||
|
||||
/**
|
||||
* pay a order.
|
||||
*
|
||||
* @author yansongda <me@yansongda.cn>
|
||||
*
|
||||
* @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 <me@yansongda.cn>
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getTradeType()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user