mirror of
https://gitee.com/yansongda/pay.git
synced 2024-11-30 03:07:38 +08:00
parent
9e29c732d0
commit
fd921a2b5d
@ -1,3 +1,9 @@
|
||||
## v3.0.24
|
||||
|
||||
### added
|
||||
|
||||
- feat: 支持使用小程序等其他类型转账 (#552)
|
||||
|
||||
## v3.0.23
|
||||
|
||||
### fixed
|
||||
|
@ -8,7 +8,7 @@ use Yansongda\Pay\Pay;
|
||||
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
|
||||
use Yansongda\Pay\Rocket;
|
||||
use Yansongda\Pay\Traits\HasWechatEncryption;
|
||||
use Yansongda\Supports\Config;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
class CreatePlugin extends GeneralPlugin
|
||||
{
|
||||
@ -25,9 +25,7 @@ class CreatePlugin extends GeneralPlugin
|
||||
protected function doSomething(Rocket $rocket): void
|
||||
{
|
||||
$params = $rocket->getParams();
|
||||
$config = get_wechat_config($params);
|
||||
|
||||
$extra = $this->getWechatId($config);
|
||||
$extra = $this->getWechatId($params, $rocket->getPayload());
|
||||
|
||||
if (!empty($params['transfer_detail_list'][0]['user_name'] ?? '')) {
|
||||
$params = $this->loadSerialNo($params);
|
||||
@ -50,15 +48,27 @@ class CreatePlugin extends GeneralPlugin
|
||||
return 'v3/partner-transfer/batches';
|
||||
}
|
||||
|
||||
protected function getWechatId(Config $config): array
|
||||
/**
|
||||
* @throws \Yansongda\Pay\Exception\ContainerDependencyException
|
||||
* @throws \Yansongda\Pay\Exception\ContainerException
|
||||
* @throws \Yansongda\Pay\Exception\ServiceNotFoundException
|
||||
*/
|
||||
protected function getWechatId(array $params, Collection $payload): array
|
||||
{
|
||||
$config = get_wechat_config($params);
|
||||
$key = ($params['_type'] ?? 'mp').'_app_id';
|
||||
|
||||
if ('app_app_id' === $key) {
|
||||
$key = 'app_id';
|
||||
}
|
||||
|
||||
$appId = [
|
||||
'appid' => $config->get('mp_app_id'),
|
||||
'appid' => $payload->get('appid', $config->get($key, '')),
|
||||
];
|
||||
|
||||
if (Pay::MODE_SERVICE == $config->get('mode')) {
|
||||
$appId = [
|
||||
'sub_mchid' => $config->get('sub_mch_id', ''),
|
||||
'sub_mchid' => $payload->get('sub_mchid', $config->get('sub_mch_id', '')),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -101,4 +101,18 @@ class CreatePluginTest extends TestCase
|
||||
self::assertEquals('yansongda', $result->getParams()['_serial_no']);
|
||||
self::assertStringContainsString('==', $userName);
|
||||
}
|
||||
|
||||
public function testNormalOtherType()
|
||||
{
|
||||
$rocket = new Rocket();
|
||||
$rocket->setParams(['_type' => 'mini'])->setPayload(new Collection());
|
||||
|
||||
$result = $this->plugin->assembly($rocket, function ($rocket) { return $rocket; });
|
||||
|
||||
$radar = $result->getRadar();
|
||||
$payload = $result->getPayload();
|
||||
|
||||
self::assertEquals(new Uri(Wechat::URL[Pay::MODE_NORMAL].'v3/transfer/batches'), $radar->getUri());
|
||||
self::assertEquals('wx55955316af4ef14', $payload->get('appid'));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user