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

Fund::transfer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Fund.php
4
 *
5
 * Created by PhpStorm.
6
 *
7
 * author: liuml  <[email protected]>
8
 * DateTime: 2019-04-20  10:28
9
 */
10
11
namespace WannanBigPig\Alipay\Payment\Trade;
12
13
use Symfony\Component\HttpFoundation\Response;
14
use WannanBigPig\Alipay\Kernel\Support\Support;
15
use WannanBigPig\Supports\AccessData;
16
17
class Fund
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.fund.trans.toaccount.transfer (单笔转账到支付宝账户接口)
34
     * 单笔转账到支付宝账户接口是基于支付宝的资金处理能力,为了满足支付宝商家向其他支付宝账户转账的需求,针对有部分开发能力的商家,
35
     * 提供通过 API 接口完成支付宝账户间的转账的功能。 该接口适用行业较广,比如商家间的货款结算,商家给个人用户发放佣金等。
36
     *
37
     * @param $params
38
     *
39
     * @return \WannanBigPig\Supports\AccessData
40
     *
41
     * @throws \WannanBigPig\Alipay\Kernel\Exceptions\SignException
42
     * @throws \WannanBigPig\Supports\Exceptions\BusinessException
43
     * @throws \WannanBigPig\Supports\Exceptions\InvalidArgumentException
44
     */
45 1
    public function transfer($params): AccessData
46
    {
47 1
        Support::$config->set('event.method', $this->method.'->transfer');
48 1
        return Support::executeApi($params, 'alipay.fund.trans.toaccount.transfer');
49
    }
50
51
    /**
52
     * alipay.fund.auth.order.voucher.create (资金授权发码接口) 在线调试(沙箱环境)
53
     * 收银员通过收银台或商户后台调用支付宝接口,生成二维码后,展示给用户,由用户扫描二维码完成资金冻结。
54
     *
55
     * @param $params
56
     *
57
     * @return \WannanBigPig\Supports\AccessData
58
     *
59
     * @throws \WannanBigPig\Alipay\Kernel\Exceptions\SignException
60
     * @throws \WannanBigPig\Supports\Exceptions\BusinessException
61
     * @throws \WannanBigPig\Supports\Exceptions\InvalidArgumentException
62
     */
63 1
    public function fundAuthOrderVoucherCreate($params): AccessData
64
    {
65 1
        Support::$config->set('event.method', $this->method.'->fundAuthOrderVoucherCreate');
66 1
        return Support::executeApi($params, 'alipay.fund.auth.order.voucher.create');
67
    }
68
69
    /**
70
     * alipay.fund.auth.operation.cancel (资金授权撤销接口)
71
     * 只有商户由于业务系统处理超时需要终止后续业务处理或者授权结果未知时可调用撤销,其他正常授权冻结的操作如需实现相同功能请调用资金授权解冻服务。提交资金授权后调用【资金授权操作查询】,没有明确的授权结果再调用【资金授权撤销】
72
     *
73
     * @param $params
74
     *
75
     * @return \WannanBigPig\Supports\AccessData
76
     *
77
     * @throws \WannanBigPig\Alipay\Kernel\Exceptions\SignException
78
     * @throws \WannanBigPig\Supports\Exceptions\BusinessException
79
     * @throws \WannanBigPig\Supports\Exceptions\InvalidArgumentException
80
     */
81 1
    public function fundAuthOperationCancel($params)
82
    {
83 1
        Support::$config->set('event.method', $this->method.'->fundAuthOperationCancel');
84 1
        return Support::executeApi($params, 'alipay.fund.auth.order.voucher.create');
85
    }
86
87
    /**
88
     * alipay.fund.auth.order.unfreeze (资金授权解冻接口) 在线调试(沙箱环境)
89
     * 当资金授权发生之后一段时间内,由于买家或者商家等其他原因需要要解冻资金,商家可通过资金授权解冻接口将授权资金进行解冻,支付宝将在收到解冻请求并验证成功后,按解冻规则将冻结资金按原路进行解冻
90
     *
91
     * @param $params
92
     *
93
     * @return \WannanBigPig\Supports\AccessData
94
     *
95
     * @throws \WannanBigPig\Alipay\Kernel\Exceptions\SignException
96
     * @throws \WannanBigPig\Supports\Exceptions\BusinessException
97
     * @throws \WannanBigPig\Supports\Exceptions\InvalidArgumentException
98
     */
99 1
    public function fundAuthUnfreeze($params)
100
    {
101 1
        Support::$config->set('event.method', $this->method.'->fundAuthUnfreeze');
102 1
        return Support::executeApi($params, 'alipay.fund.auth.order.unfreeze');
103
    }
104
105
    /**
106
     * alipay.fund.auth.order.freeze (资金授权冻结接口) 在线调试(沙箱环境)
107
     * 收银员使用扫码设备读取用户支付宝钱包 “付款码” 后,将条码信息和订单信息通过本接口上送至支付宝发起资金冻结。
108
     *
109
     * @param $params
110
     *
111
     * @return \WannanBigPig\Supports\AccessData
112
     *
113
     * @throws \WannanBigPig\Alipay\Kernel\Exceptions\SignException
114
     * @throws \WannanBigPig\Supports\Exceptions\BusinessException
115
     * @throws \WannanBigPig\Supports\Exceptions\InvalidArgumentException
116
     */
117 1
    public function fundAuthFreeze($params)
118
    {
119 1
        Support::$config->set('event.method', $this->method.'->fundAuthFreeze');
120 1
        return Support::executeApi($params, 'alipay.fund.auth.order.freeze');
121
    }
122
123
    /**
124
     * alipay.fund.auth.order.app.freeze (线上资金授权冻结接口) 在线调试(沙箱环境)
125
     * 创建支付宝授权订单并完成资金冻结。适用于线上场景完成资金授权,例如从商户 APP 端拉起支付宝收银台完成冻结。
126
     *
127
     * @param $params
128
     *
129
     * @return \Symfony\Component\HttpFoundation\Response
130
     * @throws \WannanBigPig\Supports\Exceptions\InvalidArgumentException
131
     *
132
     */
133 1
    public function fundAuthAppFreeze($params):Response
134
    {
135 1
        Support::$config->set('event.method', $this->method.'->fundAuthAppFreeze');
136 1
        return Support::executeSdk($params, 'alipay.fund.auth.order.app.freeze');
137
    }
138
}
139