Passed
Push — master ( 535bd5...f77f61 )
by wannanbigpig
03:11
created

Client   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 104
Duplicated Lines 0 %

Test Coverage

Coverage 86.49%

Importance

Changes 0
Metric Value
eloc 38
c 0
b 0
f 0
dl 0
loc 104
ccs 32
cts 37
cp 0.8649
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A app() 0 15 1
A wap() 0 16 1
A pc() 0 15 1
A face() 0 9 1
1
<?php
2
/*
3
 * This file is part of the wannanbigpig/alipay-sdk-php.
4
 *
5
 * (c) wannanbigpig <[email protected]>
6
 *
7
 * This source file is subject to the MIT license that is bundled
8
 * with this source code in the file LICENSE.
9
 */
10
11
namespace EasyAlipay\Payment\Pay;
12
13
use EasyAlipay\Payment\Kernel\BaseClient;
14
15
/**
16
 * Class Client
17
 *
18
 * @author   liuml  <[email protected]>
19
 * @DateTime 2019-07-22  14:36
20
 */
21
class Client extends BaseClient
22
{
23
    /**
24
     * alipay.trade.app.pay(app支付接口2.0).
25
     *
26
     * @param array $params
27
     *
28
     * @return string
29
     *
30
     * @throws \WannanBigPig\Supports\Exceptions\InvalidArgumentException
31
     */
32 2
    public function app(array $params)
33
    {
34 2
        $method = 'alipay.trade.app.pay';
35 2
        $params = array_merge([
36 2
            'timeout_express' => '1c',
37
            'product_code' => 'QUICK_MSECURITY_PAY',
38 2
        ], $params);
39
40 2
        $this->app->setEndpointConfig($method, [
41 2
            'return_url' => $this->app['config']->get('return_url'),
42 2
            'notify_url' => $this->app['config']->get('notify_url'),
43
        ]);
44
45 2
        return $this->sdkExecute($method, [
46 2
            'biz_content' => $params,
47
        ]);
48
    }
49
50
    /**
51
     * alipay.trade.wap.pay(手机网站支付接口2.0).
52
     *
53
     * @param array  $params
54
     * @param string $httpMethod
55
     *
56
     * @return string
57
     *
58
     * @throws \WannanBigPig\Supports\Exceptions\InvalidArgumentException
59
     */
60 2
    public function wap(array $params, string $httpMethod = 'POST')
61
    {
62 2
        $method = 'alipay.trade.wap.pay';
63 2
        $params = array_merge([
64 2
            'timeout_express' => '1c',
65
            'product_code' => 'QUICK_WAP_WAY',
66 2
        ], $params);
67
68 2
        $this->app->setEndpointConfig($method, [
69 2
            'return_url' => $this->app['config']->get('return_url'),
70 2
            'notify_url' => $this->app['config']->get('notify_url'),
71
        ]);
72
73 2
        return $this->pageExecute($method, [
74 2
            'biz_content' => $params,
75 2
        ], $httpMethod);
76
    }
77
78
    /**
79
     * alipay.trade.page.pay(统一收单下单并支付页面接口).
80
     *
81
     * @param array  $params
82
     * @param string $httpMethod
83
     *
84
     * @return string
85
     *
86
     * @throws \WannanBigPig\Supports\Exceptions\InvalidArgumentException
87
     */
88 2
    public function pc(array $params, string $httpMethod = 'POST')
89
    {
90 2
        $method = 'alipay.trade.page.pay';
91 2
        $params = array_merge([
92 2
            'timeout_express' => '1c',
93
            'product_code' => 'FAST_INSTANT_TRADE_PAY',
94 2
        ], $params);
95 2
        $this->app->setEndpointConfig($method, [
96 2
            'return_url' => $this->app['config']->get('return_url'),
97 2
            'notify_url' => $this->app['config']->get('notify_url'),
98
        ]);
99
100 2
        return $this->pageExecute($method, [
101 2
            'biz_content' => $params,
102 2
        ], $httpMethod);
103
    }
104
105
    /**
106
     * zoloz.authentication.customer.smilepay.initialize(人脸初始化唤起zim).
107
     *
108
     * @param string $zimmetainfo
109
     *
110
     * @return array|object|\Psr\Http\Message\ResponseInterface|\WannanBigPig\Supports\Collection|\WannanBigPig\Supports\Http\Response
111
     *
112
     * @throws \EasyAlipay\Kernel\Exceptions\InvalidSignException
113
     * @throws \GuzzleHttp\Exception\GuzzleException
114
     * @throws \WannanBigPig\Supports\Exceptions\InvalidArgumentException
115
     */
116
    public function face(string $zimmetainfo)
117
    {
118
        $method = 'zoloz.authentication.customer.smilepay.initialize';
119
        $params = [
120
            'zimmetainfo' => $zimmetainfo,
121
        ];
122
123
        return $this->request($method, [
124
            'biz_content' => $params,
125
        ]);
126
    }
127
}
128