mirror of
https://gitee.com/yansongda/pay.git
synced 2024-12-09 15:48:00 +08:00
find/close/refund 等操作接口服务商模式的完善
This commit is contained in:
parent
4d1db92198
commit
fd3272c309
@ -27,6 +27,11 @@ use Yansongda\Supports\Str;
|
||||
*/
|
||||
class Wechat implements GatewayApplicationInterface
|
||||
{
|
||||
const MODE_NORMAL = 'normal'; // 普通模式
|
||||
const MODE_DEV = 'dev'; // 沙箱模式
|
||||
const MODE_HK = 'hk'; // 香港钱包
|
||||
const MODE_SERVICE = 'service'; // 服务商
|
||||
|
||||
/**
|
||||
* Config.
|
||||
*
|
||||
@ -34,6 +39,13 @@ class Wechat implements GatewayApplicationInterface
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* Mode.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $mode;
|
||||
|
||||
/**
|
||||
* Wechat payload.
|
||||
*
|
||||
@ -58,7 +70,8 @@ class Wechat implements GatewayApplicationInterface
|
||||
public function __construct(Config $config)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->gateway = Support::baseUri($this->config->get('mode', 'normal'));
|
||||
$this->mode = $this->config->get('mode', Wechat::MODE_NORMAL);
|
||||
$this->gateway = Support::baseUri($this->mode);
|
||||
$this->payload = [
|
||||
'appid' => $this->config->get('app_id', ''),
|
||||
'mch_id' => $this->config->get('mch_id', ''),
|
||||
@ -68,6 +81,13 @@ class Wechat implements GatewayApplicationInterface
|
||||
'trade_type' => '',
|
||||
'spbill_create_ip' => Request::createFromGlobals()->getClientIp(),
|
||||
];
|
||||
|
||||
if ($this->mode === static::MODE_SERVICE) {
|
||||
$this->payload = array_merge($this->payload, [
|
||||
'sub_mch_id' => $this->config->get('sub_mch_id'),
|
||||
'sub_appid' => $this->config->get('sub_app_id', ''),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -23,7 +23,7 @@ class RedpackGateway extends Gateway
|
||||
{
|
||||
$payload['wxappid'] = $payload['appid'];
|
||||
if ($this->mode === Wechat::MODE_SERVICE) {
|
||||
$payload['msgappid'] = $payload['appid'];
|
||||
$payload['msgappid'] = $payload['appid'];
|
||||
}
|
||||
$payload['client_ip'] = Request::createFromGlobals()->server->get('SERVER_ADDR');
|
||||
|
||||
|
@ -103,6 +103,10 @@ class Support
|
||||
$type = isset($order['type']) ? ($order['type'].($order['type'] == 'app' ?: '_').'id') : 'app_id';
|
||||
|
||||
$payload['appid'] = $config->get($type, '');
|
||||
$mode = $config->get('mode', Wechat::MODE_NORMAL);
|
||||
if ($mode === Wechat::MODE_SERVICE) {
|
||||
$payload['sub_appid'] = $config->get('sub_' . $type, '');
|
||||
}
|
||||
|
||||
unset($payload['notify_url'], $payload['trade_type'], $payload['type']);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user