mirror of
https://gitee.com/yansongda/pay.git
synced 2024-12-06 06:07:59 +08:00
fix some bugs
This commit is contained in:
parent
6106ff15c0
commit
0bc9e721ad
@ -117,15 +117,7 @@ class Wechat implements GatewayApplicationInterface
|
||||
*/
|
||||
public function find($order): Collection
|
||||
{
|
||||
if (is_array($order)) {
|
||||
$this->payload = array_merge($this->payload, $order);
|
||||
} else {
|
||||
$this->payload['out_trade_no'] = $order;
|
||||
}
|
||||
|
||||
unset($this->payload['notify_url'], $this->payload['trade_type']);
|
||||
|
||||
$this->payload['sign'] = Support::generateSign($this->payload, $this->config->get('key'));
|
||||
$this->payload = Support::filterPayload($this->payload, $order, $this->config);
|
||||
|
||||
return Support::requestApi('pay/orderquery', $this->payload, $this->config->get('key'));
|
||||
}
|
||||
@ -141,16 +133,7 @@ class Wechat implements GatewayApplicationInterface
|
||||
*/
|
||||
public function refund($order): Collection
|
||||
{
|
||||
if (isset($order['miniapp'])) {
|
||||
$this->payload['appid'] = $this->config->get('miniapp_id');
|
||||
unset($order['miniapp']);
|
||||
}
|
||||
|
||||
$this->payload = array_merge($this->payload, $order);
|
||||
|
||||
unset($this->payload['notify_url'], $this->payload['trade_type']);
|
||||
|
||||
$this->payload['sign'] = Support::generateSign($this->payload, $this->config->get('key'));
|
||||
$this->payload = Support::filterPayload($this->payload, $order, $this->config);
|
||||
|
||||
return Support::requestApi(
|
||||
'secapi/pay/refund',
|
||||
@ -186,15 +169,7 @@ class Wechat implements GatewayApplicationInterface
|
||||
*/
|
||||
public function close($order)
|
||||
{
|
||||
if (is_array($order)) {
|
||||
$this->payload = array_merge($this->payload, $order);
|
||||
} else {
|
||||
$this->payload['out_trade_no'] = $order;
|
||||
}
|
||||
|
||||
unset($this->payload['notify_url'], $this->payload['trade_type']);
|
||||
|
||||
$this->payload['sign'] = Support::generateSign($this->payload, $this->config->get('key'));
|
||||
$this->payload = Support::filterPayload($this->payload, $order, $this->config);
|
||||
|
||||
return Support::requestApi('pay/closeorder', $this->payload, $this->config->get('key'));
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ class MiniappGateway extends MpGateway
|
||||
public function pay($endpoint, array $payload): Collection
|
||||
{
|
||||
$payload['appid'] = $this->config->get('miniapp_id');
|
||||
$payload['trade_type'] = $this->getTradeType();
|
||||
|
||||
return parent::pay($endpoint, $payload);
|
||||
}
|
||||
|
@ -85,6 +85,34 @@ class Support
|
||||
throw new InvalidSignException('Wechat Sign Verify FAILED', 3, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter payload.
|
||||
*
|
||||
* @author yansongda <me@yansongda.cn>
|
||||
*
|
||||
* @param array $payload
|
||||
* @param array|string $order
|
||||
* @param Yansongda\Supports\Config $config
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function filterPayload($payload, $order, $config)
|
||||
{
|
||||
$payload['out_trade_no'] = is_array($order) ? '' : $order;
|
||||
|
||||
$payload = array_merge($payload, $order);
|
||||
|
||||
$type = isset($order['type']) ? ($order['type'] . ($order['type'] != 'app' ?: '_') . 'id') : 'app_id';
|
||||
|
||||
$payload['appid'] = $config->get($type, '');
|
||||
|
||||
unset($payload['notify_url'], $payload['trade_type'], $payload['type']);
|
||||
|
||||
$payload['sign'] = self::generateSign($payload, $config->get('key'));
|
||||
|
||||
return $payload;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate wechat sign.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user