mirror of
https://gitee.com/yansongda/pay.git
synced 2024-12-02 04:08:21 +08:00
fix: app 支付调起签名中时间戳参数大小写问题 (#510)
* fix: app 支付调起签名中时间戳参数大小写问题 * changelog
This commit is contained in:
parent
796ce44dbc
commit
223732dbcc
@ -1,3 +1,9 @@
|
||||
## v3.0.13
|
||||
|
||||
### fixed
|
||||
|
||||
- fixed: app 支付调起签名中时间戳参数大小写问题 (#510)
|
||||
|
||||
## v3.0.12
|
||||
|
||||
### fixed
|
||||
|
@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace Yansongda\Pay\Plugin\Wechat\Pay\App;
|
||||
|
||||
use Yansongda\Pay\Rocket;
|
||||
use Yansongda\Supports\Collection;
|
||||
use Yansongda\Supports\Config;
|
||||
use Yansongda\Supports\Str;
|
||||
|
||||
@ -32,6 +33,22 @@ class InvokePrepayPlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\InvokeP
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Yansongda\Pay\Exception\ContainerDependencyException
|
||||
* @throws \Yansongda\Pay\Exception\ContainerException
|
||||
* @throws \Yansongda\Pay\Exception\InvalidConfigException
|
||||
* @throws \Yansongda\Pay\Exception\ServiceNotFoundException
|
||||
*/
|
||||
protected function getSign(Collection $invokeConfig, array $params): string
|
||||
{
|
||||
$contents = $invokeConfig->get('appid', '')."\n".
|
||||
$invokeConfig->get('timestamp', '')."\n".
|
||||
$invokeConfig->get('nonceStr', '')."\n".
|
||||
$invokeConfig->get('package', '')."\n";
|
||||
|
||||
return get_wechat_sign($params, $contents);
|
||||
}
|
||||
|
||||
protected function getAppid(Rocket $rocket): string
|
||||
{
|
||||
$config = get_wechat_config($rocket->getParams());
|
||||
|
@ -33,7 +33,7 @@ class InvokePrepayPlugin implements PluginInterface
|
||||
$prepayId = $rocket->getDestination()->get('prepay_id');
|
||||
|
||||
if (is_null($prepayId)) {
|
||||
Logger::error('[wechat][InvokePrepayPlugin] 预下单失败:响应缺少 prepay_id 参数', $rocket->getDestination()->all());
|
||||
Logger::error('[wechat][InvokePrepayPlugin] 预下单失败:响应缺少 prepay_id 参数,请自行检查参数是否符合微信要求', $rocket->getDestination()->all());
|
||||
|
||||
throw new InvalidResponseException(Exception::RESPONSE_MISSING_NECESSARY_PARAMS, 'Prepay Response Error: Missing PrepayId', $rocket->getDestination()->all());
|
||||
}
|
||||
@ -55,7 +55,7 @@ class InvokePrepayPlugin implements PluginInterface
|
||||
*/
|
||||
protected function getSign(Collection $invokeConfig, array $params): string
|
||||
{
|
||||
$contents = $invokeConfig->get('appid', $invokeConfig->get('appId'))."\n".
|
||||
$contents = $invokeConfig->get('appId', '')."\n".
|
||||
$invokeConfig->get('timeStamp', '')."\n".
|
||||
$invokeConfig->get('nonceStr', '')."\n".
|
||||
$invokeConfig->get('package', '')."\n";
|
||||
|
@ -22,5 +22,6 @@ class InvokePrepayPluginTest extends TestCase
|
||||
self::assertArrayHasKey('package', $contents->all());
|
||||
self::assertEquals('Sign=WXPay', $contents->get('package'));
|
||||
self::assertArrayHasKey('sign', $contents->all());
|
||||
self::assertArrayHasKey('timestamp', $contents->all());
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace Yansongda\Pay\Tests\Plugin\Wechat\Pay\Common;
|
||||
|
||||
use Yansongda\Pay\Exception\Exception;
|
||||
use Yansongda\Pay\Exception\InvalidResponseException;
|
||||
use Yansongda\Pay\Plugin\Wechat\Pay\Common\InvokePrepayPlugin;
|
||||
use Yansongda\Pay\Rocket;
|
||||
@ -21,6 +22,7 @@ class InvokePrepayPluginTest extends TestCase
|
||||
self::assertArrayHasKey('appId', $contents->all());
|
||||
self::assertArrayHasKey('package', $contents->all());
|
||||
self::assertArrayHasKey('paySign', $contents->all());
|
||||
self::assertArrayHasKey('timeStamp', $contents->all());
|
||||
}
|
||||
|
||||
public function testWrongPrepayId()
|
||||
@ -28,7 +30,7 @@ class InvokePrepayPluginTest extends TestCase
|
||||
$rocket = (new Rocket())->setDestination(new Collection([]));
|
||||
|
||||
self::expectException(InvalidResponseException::class);
|
||||
self::expectExceptionCode(InvalidResponseException::RESPONSE_MISSING_NECESSARY_PARAMS);
|
||||
self::expectExceptionCode(Exception::RESPONSE_MISSING_NECESSARY_PARAMS);
|
||||
|
||||
(new InvokePrepayPlugin())->assembly($rocket, function ($rocket) { return $rocket; });
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user