Completed
Push — master ( 04e442...a80522 )
by wannanbigpig
02:37 queued 10s
created

Client::wap()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 2
dl 0
loc 12
ccs 9
cts 9
cp 1
crap 1
rs 10
c 0
b 0
f 0
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['timeout_express'] = $params['timeout_express'] ?? '1c';
36 2
        $this->app->setEndpointConfig($method, [
37 2
            'return_url' => $this->app['config']->get('return_url'),
38 2
            'notify_url' => $this->app['config']->get('notify_url'),
39
        ]);
40
41 2
        return $this->sdkExecute($method, [
42 2
            'biz_content' => $params,
43
        ]);
44
    }
45
46
    /**
47
     * alipay.trade.wap.pay(手机网站支付接口2.0).
48
     *
49
     * @param array  $params
50
     * @param string $httpMethod
51
     *
52
     * @return string
53
     *
54
     * @throws \WannanBigPig\Supports\Exceptions\InvalidArgumentException
55
     */
56 2
    public function wap(array $params, string $httpMethod = 'POST')
57
    {
58 2
        $method = 'alipay.trade.wap.pay';
59 2
        $params['timeout_express'] = $params['timeout_express'] ?? '1c';
60 2
        $this->app->setEndpointConfig($method, [
61 2
            'return_url' => $this->app['config']->get('return_url'),
62 2
            'notify_url' => $this->app['config']->get('notify_url'),
63
        ]);
64
65 2
        return $this->pageExecute($method, [
66 2
            'biz_content' => $params,
67 2
        ], $httpMethod);
68
    }
69
70
    /**
71
     * alipay.trade.page.pay(统一收单下单并支付页面接口).
72
     *
73
     * @param array  $params
74
     * @param string $httpMethod
75
     *
76
     * @return string
77
     *
78
     * @throws \WannanBigPig\Supports\Exceptions\InvalidArgumentException
79
     */
80 2
    public function pc(array $params, string $httpMethod = 'POST')
81
    {
82 2
        $method = 'alipay.trade.page.pay';
83 2
        $params = array_merge([
84 2
            'timeout_express' => $params['timeout_express'] ?? '1c',
85 2
            'product_code' => 'FAST_INSTANT_TRADE_PAY',
86 2
        ], $params);
87 2
        $this->app->setEndpointConfig($method, [
88 2
            'return_url' => $this->app['config']->get('return_url'),
89 2
            'notify_url' => $this->app['config']->get('notify_url'),
90
        ]);
91
92 2
        return $this->pageExecute($method, [
93 2
            'biz_content' => $params,
94 2
        ], $httpMethod);
95
    }
96
97
    /**
98
     * zoloz.authentication.customer.smilepay.initialize(人脸初始化唤起zim).
99
     *
100
     * @param string $zimmetainfo
101
     *
102
     * @return array|object|\Psr\Http\Message\ResponseInterface|\WannanBigPig\Supports\Collection|\WannanBigPig\Supports\Http\Response
103
     *
104
     * @throws \EasyAlipay\Kernel\Exceptions\InvalidSignException
105
     * @throws \GuzzleHttp\Exception\GuzzleException
106
     * @throws \WannanBigPig\Supports\Exceptions\InvalidArgumentException
107
     */
108
    public function face(string $zimmetainfo)
109
    {
110
        $method = 'zoloz.authentication.customer.smilepay.initialize';
111
        $params = [
112
            'zimmetainfo' => $zimmetainfo,
113
        ];
114
115
        return $this->request($method, [
116
            'biz_content' => $params,
117
        ]);
118
    }
119
}
120