fix: 支付宝 wap/web 支付 get 方法时url拼接问题 (#488)

* fix: 支付宝 wap/web 支付 get 方法时url拼接问题

* style: code style optimized
This commit is contained in:
yansongda 2021-09-10 16:28:51 +08:00 committed by GitHub
parent 660fa5ef12
commit c88f0c2d5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View File

@ -9,7 +9,6 @@ use GuzzleHttp\Psr7\Response;
use Yansongda\Pay\Contract\PluginInterface;
use Yansongda\Pay\Logger;
use Yansongda\Pay\Rocket;
use Yansongda\Supports\Arr;
use Yansongda\Supports\Collection;
class HtmlResponsePlugin implements PluginInterface
@ -36,7 +35,7 @@ class HtmlResponsePlugin implements PluginInterface
protected function buildRedirect(string $endpoint, Collection $payload): Response
{
$url = $endpoint.'?'.Arr::query($payload->all());
$url = $endpoint.(false === strpos($endpoint, '?') ? '?' : '&').$payload->query();
$content = sprintf('<!DOCTYPE html>
<html lang="en">

View File

@ -25,6 +25,20 @@ class HtmlResponsePluginTest extends TestCase
self::assertEquals('https://yansongda.cn?name=yansongda', $result->getDestination()->getHeaderLine('Location'));
}
public function testRedirectIncludeMark()
{
$rocket = new Rocket();
$rocket->setRadar(new Request('GET', 'https://yansongda.cn?charset=utf8'))
->setPayload(new Collection(['name' => 'yansongda']));
$plugin = new HtmlResponsePlugin();
$result = $plugin->assembly($rocket, function ($rocket) { return $rocket; });
self::assertInstanceOf(ResponseInterface::class, $result->getDestination());
self::assertArrayHasKey('Location', $result->getDestination()->getHeaders());
self::assertEquals('https://yansongda.cn?charset=utf8&name=yansongda', $result->getDestination()->getHeaderLine('Location'));
}
public function testHtml()
{
$rocket = new Rocket();