Passed
Push — master ( 7807ae...01b45a )
by wannanbigpig
02:40
created

Query::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Query.php
4
 *
5
 * Created by PhpStorm.
6
 *
7
 * author: liuml  <[email protected]>
8
 * DateTime: 2019-04-10  16:45
9
 */
10
11
namespace WannanBigPig\Alipay\Payment\Trade;
12
13
use WannanBigPig\Alipay\Kernel\Support\Support;
14
use WannanBigPig\Alipay\Payment\DoctorInterface;
15
use WannanBigPig\Supports\AccessData;
16
17
class Query
18
{
19
    /**
20
     * @var string
21
     */
22
    protected $method = '';
23
24
    /**
25
     * Query constructor.
26
     */
27 1
    public function __construct()
28
    {
29 1
        $this->method = Support::$config->get('event.method');
0 ignored issues
show
Documentation Bug introduced by
It seems like WannanBigPig\Alipay\Kern...ig->get('event.method') can also be of type array. However, the property $method is declared as type string. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
30 1
    }
31
32
    /**
33
     * alipay.trade.query (统一收单线下交易查询)
34
     * 该接口提供所有支付宝支付订单的查询,商户可以通过该接口主动查询订单状态,完成下一步的业务逻辑。
35
     * 需要调用查询接口的情况: 当商户后台、网络、服务器等出现异常,商户系统最终未接收到支付通知;
36
     * 调用支付接口后,返回系统错误或未知交易状态情况; 调用 alipay.trade.pay,返回 INPROCESS 的状态;
37
     * 调用 alipay.trade.cancel 之前,需确认支付状态;
38
     *
39
     * @param $params
40
     *
41
     * @return \WannanBigPig\Supports\AccessData
42
     *
43
     * @throws \WannanBigPig\Alipay\Kernel\Exceptions\SignException
44
     * @throws \WannanBigPig\Supports\Exceptions\BusinessException
45
     * @throws \WannanBigPig\Supports\Exceptions\InvalidArgumentException
46
     */
47 1
    public function trade($params): AccessData
48
    {
49 1
        Support::$config->set('event.method', $this->method.'->trade');
50 1
        return Support::executeApi($params, 'alipay.trade.query');
51
    }
52
53
    /**
54
     * alipay.trade.fastpay.refund.query (统一收单交易退款查询)
55
     * 商户可使用该接口查询自已通过 alipay.trade.refund 提交的退款请求是否执行成功。
56
     * 该接口的返回码 10000,仅代表本次查询操作成功,不代表退款成功。
57
     * 如果该接口返回了查询数据,则代表退款成功,如果没有查询到则代表未退款成功,可以调用退款接口进行重试。重试时请务必保证退款请求号一致。
58
     *
59
     * @param $params
60
     *
61
     * @return \WannanBigPig\Supports\AccessData
62
     *
63
     * @throws \WannanBigPig\Alipay\Kernel\Exceptions\SignException
64
     * @throws \WannanBigPig\Supports\Exceptions\BusinessException
65
     * @throws \WannanBigPig\Supports\Exceptions\InvalidArgumentException
66
     */
67
    public function refund($params): AccessData
68
    {
69
        Support::$config->set('event.method', $this->method.'->refund');
70
        return Support::executeApi($params, 'alipay.trade.fastpay.refund.query');
71
    }
72
73
    /**
74
     * zoloz.authentication.customer.ftoken.query (人脸 ftoken 查询消费接口)
75
     * 人脸 ftoken 查询消费接口
76
     *
77
     * @param $params
78
     *
79
     * @return \WannanBigPig\Supports\AccessData
80
     *
81
     * @throws \WannanBigPig\Alipay\Kernel\Exceptions\SignException
82
     * @throws \WannanBigPig\Supports\Exceptions\BusinessException
83
     * @throws \WannanBigPig\Supports\Exceptions\InvalidArgumentException
84
     */
85
    public function faceFtoken($params): AccessData
86
    {
87
        Support::$config->set('event.method', $this->method.'->faceFtoken');
88
        return Support::executeApi($params, 'zoloz.authentication.customer.ftoken.query');
89
    }
90
91
    /**
92
     * alipay.fund.trans.order.query (查询转账订单接口)
93
     * 商户可通过该接口查询转账订单的状态、支付时间等相关信息,主要应用于 B2C 转账订单查询的场景
94
     *
95
     * @param $params
96
     *
97
     * @return \WannanBigPig\Supports\AccessData
98
     *
99
     * @throws \WannanBigPig\Alipay\Kernel\Exceptions\SignException
100
     * @throws \WannanBigPig\Supports\Exceptions\BusinessException
101
     * @throws \WannanBigPig\Supports\Exceptions\InvalidArgumentException
102
     */
103
    public function transOrder($params): AccessData
104
    {
105
        Support::$config->set('event.method', $this->method.'->transOrder');
106
        return Support::executeApi($params, 'alipay.fund.trans.order.query');
107
    }
108
109
    /**
110
     * alipay.fund.auth.operation.detail.query (资金授权操作查询接口)
111
     * 通过该接口可以查询单笔明细的详细信息
112
     *
113
     * @param $params
114
     *
115
     * @return \WannanBigPig\Supports\AccessData
116
     *
117
     * @throws \WannanBigPig\Alipay\Kernel\Exceptions\SignException
118
     * @throws \WannanBigPig\Supports\Exceptions\BusinessException
119
     * @throws \WannanBigPig\Supports\Exceptions\InvalidArgumentException
120
     */
121
    public function fundAuthOperationQuery($params): AccessData
122
    {
123
        Support::$config->set('event.method', $this->method.'->fundAuthOperationQuery');
124
        return Support::executeApi($params, 'alipay.fund.auth.operation.detail.query');
125
    }
126
}
127