Skip to content

Commit

Permalink
fix: 微信关闭订单报解包错误的问题 (#1000)
Browse files Browse the repository at this point in the history
  • Loading branch information
yansongda authored Jun 16, 2024
1 parent 3d79403 commit 1cbe8d8
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 11 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v3.7.6

### fixed

- fix: 微信关闭订单报解包错误的问题(#1000)

## v3.7.5

### fixed
Expand Down
18 changes: 10 additions & 8 deletions src/Plugin/Wechat/V3/Pay/Jsapi/ClosePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Closure;
use Yansongda\Artful\Contract\PluginInterface;
use Yansongda\Artful\Direction\OriginResponseDirection;
use Yansongda\Artful\Exception\ContainerException;
use Yansongda\Artful\Exception\InvalidParamsException;
use Yansongda\Artful\Exception\ServiceNotFoundException;
Expand Down Expand Up @@ -45,14 +46,15 @@ public function assembly(Rocket $rocket, Closure $next): Rocket
$data = $this->service($payload, $config);
}

$rocket->setPayload(array_merge(
[
'_method' => 'POST',
'_url' => 'v3/pay/transactions/out-trade-no/'.$outTradeNo.'/close',
'_service_url' => 'v3/pay/partner/transactions/out-trade-no/'.$outTradeNo.'/close',
],
$data ?? $this->normal($config)
));
$rocket->setDirection(OriginResponseDirection::class)
->setPayload(array_merge(
[
'_method' => 'POST',
'_url' => 'v3/pay/transactions/out-trade-no/'.$outTradeNo.'/close',
'_service_url' => 'v3/pay/partner/transactions/out-trade-no/'.$outTradeNo.'/close',
],
$data ?? $this->normal($config)
));

Logger::info('[Wechat][Pay][Jsapi][ClosePlugin] 插件装载完毕', ['rocket' => $rocket]);

Expand Down
2 changes: 1 addition & 1 deletion src/Provider/Alipay.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Alipay implements ProviderInterface
*/
public function __call(string $shortcut, array $params): null|Collection|MessageInterface|Rocket
{
$plugin = '\\Yansongda\\Pay\\Shortcut\\Alipay\\'.Str::studly($shortcut).'Shortcut';
$plugin = '\Yansongda\Pay\Shortcut\Alipay\\'.Str::studly($shortcut).'Shortcut';

return Artful::shortcut($plugin, ...$params);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Provider/Unipay.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Unipay implements ProviderInterface
*/
public function __call(string $shortcut, array $params): null|Collection|MessageInterface|Rocket
{
$plugin = '\\Yansongda\\Pay\\Shortcut\\Unipay\\'.Str::studly($shortcut).'Shortcut';
$plugin = '\Yansongda\Pay\Shortcut\Unipay\\'.Str::studly($shortcut).'Shortcut';

return Artful::shortcut($plugin, ...$params);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Provider/Wechat.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Wechat implements ProviderInterface
*/
public function __call(string $shortcut, array $params): null|Collection|MessageInterface
{
$plugin = '\\Yansongda\\Pay\\Shortcut\\Wechat\\'.Str::studly($shortcut).'Shortcut';
$plugin = '\Yansongda\Pay\Shortcut\Wechat\\'.Str::studly($shortcut).'Shortcut';

return Artful::shortcut($plugin, ...$params);
}
Expand Down
4 changes: 4 additions & 0 deletions tests/Plugin/Wechat/V3/Pay/Jsapi/ClosePluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Yansongda\Pay\Tests\Plugin\Wechat\V3\Pay\Jsapi;

use Yansongda\Artful\Direction\OriginResponseDirection;
use Yansongda\Pay\Exception\Exception;
use Yansongda\Artful\Exception\InvalidParamsException;
use Yansongda\Pay\Plugin\Wechat\V3\Pay\Jsapi\ClosePlugin;
Expand Down Expand Up @@ -46,6 +47,7 @@ public function testNormal()
'_service_url' => 'v3/pay/partner/transactions/out-trade-no/111/close',
'mchid' => '1600314069',
], $result->getPayload()->all());
self::assertEquals(OriginResponseDirection::class, $result->getDirection());
}

public function testServiceParams()
Expand All @@ -65,6 +67,7 @@ public function testServiceParams()
'sp_mchid' => '1600314069',
'sub_mchid' => '333',
], $result->getPayload()->all());
self::assertEquals(OriginResponseDirection::class, $result->getDirection());
}

public function testService()
Expand All @@ -83,5 +86,6 @@ public function testService()
'sp_mchid' => '1600314069',
'sub_mchid' => '1600314070',
], $result->getPayload()->all());
self::assertEquals(OriginResponseDirection::class, $result->getDirection());
}
}

0 comments on commit 1cbe8d8

Please sign in to comment.