mirror of
https://gitee.com/yansongda/pay.git
synced 2024-12-12 12:25:32 +08:00
9412db512f
* deprecated: 支付宝/微信 `RadarPlugin`, `SignPlugin` 已废弃,使用 `RadarSignPlugin` 代替
92 lines
3.7 KiB
PHP
92 lines
3.7 KiB
PHP
<?php
|
|
|
|
namespace Yansongda\Pay\Tests\Plugin\Alipay;
|
|
|
|
use Yansongda\Pay\Plugin\Alipay\RadarSignPlugin;
|
|
use Yansongda\Pay\Rocket;
|
|
use Yansongda\Pay\Tests\TestCase;
|
|
use Yansongda\Supports\Collection;
|
|
|
|
class RadarSignPluginTest extends TestCase
|
|
{
|
|
protected $plugin;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->plugin = new RadarSignPlugin();
|
|
}
|
|
|
|
public function testSignNormal()
|
|
{
|
|
$payload = [
|
|
"app_id" => "2016082000295641",
|
|
"method" => "alipay.trade.query",
|
|
"format" => "JSON",
|
|
"return_url" => "http://127.0.0.1:8000/alipay/verify",
|
|
"charset" => "utf-8",
|
|
"sign_type" => "RSA2",
|
|
"timestamp" => "2021-06-07 21:54:50",
|
|
"version" => "1.0",
|
|
"app_cert_sn" => "fb5e86cfb784de936dd3594e32381cf8",
|
|
"alipay_root_cert_sn" => "687b59193f3f462dd5336e5abf83c5d8_02941eef3187dddf3d3b83462e1dfcf6",
|
|
"biz_content" => ['out_trade_no' => "yansongda-1622986519"],
|
|
];
|
|
$sign = "QMh6CzKWIt5yIYCrYrMdC2/Mt+4lTNEaPN0biIZPuiWzgTS7pyIYFOmb+dEi70X5q9UaCBlejwwwTEzRtfIjudPu/mIrlpnwsN8mEhDjyZihmgb/wCZy+kR0OIwvZjTd/3AuALIcwDbhZqDwssZAOTlco4eE7WosEdsob52OfCBAn0ZEf/9zZk5+FSbL8xbwO9hTlspl5ArgFBf9RryBxAviC09Nr5eSNdwYBIyOUdLtEVHBuHHvwa4UfiCFe0SyDFVQODgoz3Mjcs5d4RmJqKNLorkN8dHzjzlAnCR07EHsMzV4ivNG703hReHMyazPDuaWBg11/spMJUNUF/tEBQ==";
|
|
|
|
$rocket = new Rocket();
|
|
$rocket->setParams([])->setPayload(new Collection($payload));
|
|
|
|
$result = $this->plugin->assembly($rocket, function ($rocket) { return $rocket; });
|
|
|
|
self::assertSame($sign, $result->getPayload()->get('sign'));
|
|
}
|
|
|
|
public function testSignUnderlineParams()
|
|
{
|
|
$payload = [
|
|
"app_id" => "2016082000295641",
|
|
"method" => "alipay.trade.query",
|
|
"format" => "JSON",
|
|
"return_url" => "http://127.0.0.1:8000/alipay/verify",
|
|
"charset" => "utf-8",
|
|
"sign_type" => "RSA2",
|
|
"timestamp" => "2021-06-07 21:54:50",
|
|
"version" => "1.0",
|
|
"app_cert_sn" => "fb5e86cfb784de936dd3594e32381cf8",
|
|
"alipay_root_cert_sn" => "687b59193f3f462dd5336e5abf83c5d8_02941eef3187dddf3d3b83462e1dfcf6",
|
|
"biz_content" => ['out_trade_no' => "yansongda-1622986519", '_method' => 'get', '_ignore' => true],
|
|
];
|
|
$sign = "QMh6CzKWIt5yIYCrYrMdC2/Mt+4lTNEaPN0biIZPuiWzgTS7pyIYFOmb+dEi70X5q9UaCBlejwwwTEzRtfIjudPu/mIrlpnwsN8mEhDjyZihmgb/wCZy+kR0OIwvZjTd/3AuALIcwDbhZqDwssZAOTlco4eE7WosEdsob52OfCBAn0ZEf/9zZk5+FSbL8xbwO9hTlspl5ArgFBf9RryBxAviC09Nr5eSNdwYBIyOUdLtEVHBuHHvwa4UfiCFe0SyDFVQODgoz3Mjcs5d4RmJqKNLorkN8dHzjzlAnCR07EHsMzV4ivNG703hReHMyazPDuaWBg11/spMJUNUF/tEBQ==";
|
|
|
|
$rocket = new Rocket();
|
|
$rocket->setParams([])->setPayload(new Collection($payload));
|
|
|
|
$result = $this->plugin->assembly($rocket, function ($rocket) { return $rocket; });
|
|
|
|
self::assertSame($sign, $result->getPayload()->get('sign'));
|
|
}
|
|
|
|
public function testRadarPostNormal()
|
|
{
|
|
$rocket = new Rocket();
|
|
$rocket->setParams([])->setPayload(new Collection(['name' => 'yansongda']));
|
|
|
|
$result = $this->plugin->assembly($rocket, function ($rocket) { return $rocket; });
|
|
|
|
self::stringContains('name=yansongda', (string) $result->getRadar()->getBody());
|
|
self::assertEquals('POST', $result->getRadar()->getMethod());
|
|
}
|
|
|
|
public function testRadarGetNormal()
|
|
{
|
|
$rocket = new Rocket();
|
|
$rocket->setParams(['_method' => 'get'])->setPayload(new Collection(['name' => 'yansongda']));
|
|
|
|
$result = $this->plugin->assembly($rocket, function ($rocket) { return $rocket; });
|
|
|
|
self::assertEquals('GET', $result->getRadar()->getMethod());
|
|
}
|
|
}
|