Passed
Pull Request — master (#894)
by Songda
01:58
created

AppPayPlugin::assembly()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 19
rs 9.9332
cc 1
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yansongda\Pay\Plugin\Alipay\Marketing\Redpack;
6
7
use Closure;
8
use Yansongda\Pay\Contract\PluginInterface;
9
use Yansongda\Pay\Direction\ResponseDirection;
10
use Yansongda\Pay\Logger;
11
use Yansongda\Pay\Rocket;
12
13
/**
14
 * @see https://opendocs.alipay.com/open/03rbyf?pathHash=76643847&ref=api&scene=common
15
 */
16
class AppPayPlugin implements PluginInterface
17
{
18
    public function assembly(Rocket $rocket, Closure $next): Rocket
19
    {
20
        Logger::debug('[Alipay][Marketing][Redpack][AppPayPlugin] 插件开始装载', ['rocket' => $rocket]);
21
22
        $rocket->setDirection(ResponseDirection::class)
23
            ->mergePayload([
24
                'method' => 'alipay.fund.trans.app.pay',
25
                'biz_content' => array_merge(
26
                    [
27
                        'product_code' => 'STD_RED_PACKET',
28
                        'biz_scene' => 'PERSONAL_PAY',
29
                    ],
30
                    $rocket->getParams(),
31
                ),
32
            ]);
33
34
        Logger::info('[Alipay][Marketing][Redpack][AppPayPlugin] 插件装载完毕', ['rocket' => $rocket]);
35
36
        return $next($rocket);
37
    }
38
}
39