MiniappGateway   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 28
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A pay() 0 11 2
1
<?php
2
3
namespace Yansongda\Pay\Gateways\Wechat;
4
5
use Yansongda\Pay\Exceptions\GatewayException;
6
use Yansongda\Pay\Exceptions\InvalidArgumentException;
7
use Yansongda\Pay\Exceptions\InvalidSignException;
8
use Yansongda\Pay\Gateways\Wechat;
9
use Yansongda\Supports\Collection;
10
11
class MiniappGateway extends MpGateway
12
{
13
    /**
14
     * Pay an order.
15
     *
16
     * @author yansongda <[email protected]>
17
     *
18
     * @param string $endpoint
19
     * @param array  $payload
20
     *
21
     * @throws GatewayException
22
     * @throws InvalidArgumentException
23
     * @throws InvalidSignException
24
     *
25
     * @return Collection
26
     */
27
    public function pay($endpoint, array $payload): Collection
28
    {
29
        $payload['appid'] = Support::getInstance()->miniapp_id;
30
31
        if ($this->mode === Wechat::MODE_SERVICE) {
32
            $payload['sub_appid'] = Support::getInstance()->sub_miniapp_id;
33
            $this->payRequestUseSubAppId = true;
34
        }
35
36
        return parent::pay($endpoint, $payload);
37
    }
38
}
39