fix: 支付宝 system.oauth.token 请求参数错误 (#528)

* fix: #527

* changelog
This commit is contained in:
yansongda 2021-12-02 21:14:22 +08:00 committed by GitHub
parent 1560fc989a
commit f48ec8850a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 0 deletions

View File

@ -1,3 +1,9 @@
## v3.0.19
### fixed
- fix: 支付宝 system.oauth.token 请求参数错误 (#528)
## v3.0.18
### added

View File

@ -5,9 +5,15 @@ declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Alipay\Tools;
use Yansongda\Pay\Plugin\Alipay\GeneralPlugin;
use Yansongda\Pay\Rocket;
class SystemOauthTokenPlugin extends GeneralPlugin
{
protected function doSomethingBefore(Rocket $rocket): void
{
$rocket->mergePayload($rocket->getParams());
}
protected function getMethod(): string
{
return 'alipay.system.oauth.token';

View File

@ -0,0 +1,24 @@
<?php
namespace Yansongda\Pay\Tests\Plugin\Alipay\Tools;
use Yansongda\Pay\Parser\ResponseParser;
use Yansongda\Pay\Plugin\Alipay\Tools\SystemOauthTokenPlugin;
use Yansongda\Pay\Rocket;
use Yansongda\Pay\Tests\TestCase;
class SystemOauthTokenPluginTest extends TestCase
{
public function testNormal()
{
$rocket = new Rocket();
$rocket->setParams(['name' => 'yansongda', 'age' => 28]);
$plugin = new SystemOauthTokenPlugin();
$result = $plugin->assembly($rocket, function ($rocket) { return $rocket; });
self::assertEquals('yansongda', $result->getPayload()->get('name'));
self::assertEquals(28, $result->getPayload()->get('age'));
}
}