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; |
12
|
|
|
|
13
|
|
|
use Closure; |
14
|
|
|
use EasyAlipay\Kernel\ServiceContainer; |
15
|
|
|
use EasyAlipay\Payment\Notify\Handle; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Class Application |
19
|
|
|
* |
20
|
|
|
* @author liuml <[email protected]> |
21
|
|
|
* @DateTime 2019-07-18 16:13 |
22
|
|
|
* |
23
|
|
|
* @property Pay\Client $pay |
24
|
|
|
* @property Refund\Client $refund |
25
|
|
|
* @property Bill\Client $bill |
26
|
|
|
* |
27
|
|
|
* @method mixed pay(array $params) |
28
|
|
|
* @method mixed create(array $params) |
29
|
|
|
* @method mixed preCreate(array $params) |
30
|
|
|
* @method mixed close(string $tradeNo, string $outTradeNo = null, string $operatorId = null) |
31
|
|
|
* @method mixed refund(string $tradeNo, $amount, string $outTradeNo = null, array $params = []) |
32
|
|
|
* @method mixed query(string $tradeNo, string $outTradeNo = null, string $orgPid = null) |
33
|
|
|
* @method mixed cancel(string $tradeNo, string $outTradeNo = null) |
34
|
|
|
* @method mixed orderSettle(string $outRequestNo, string $tradeNo, array $royaltyParameters, string $operatorId = null) |
35
|
|
|
* @method mixed orderInfoSync(string $tradeNo, string $outRequestNo, string $bizType, string $origRequestNo = null, string $orderBizInfo = null) |
36
|
|
|
*/ |
37
|
|
|
class Application extends ServiceContainer |
38
|
|
|
{ |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var array |
42
|
|
|
*/ |
43
|
|
|
protected $providers = [ |
44
|
|
|
'base' => Base\Client::class, |
45
|
|
|
'pay' => Pay\Client::class, |
46
|
|
|
'refund' => Refund\Client::class, |
47
|
|
|
'bill' => Bill\Client::class, |
48
|
|
|
]; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @param string $name |
52
|
|
|
* @param array $arguments |
53
|
|
|
* |
54
|
|
|
* @return mixed |
55
|
|
|
*/ |
56
|
|
|
public function __call($name, $arguments) |
57
|
|
|
{ |
58
|
|
|
return call_user_func_array([$this['base'], $name], $arguments); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* setNotifyUrl. |
63
|
|
|
* |
64
|
|
|
* @param string $notifyUrl |
65
|
|
|
* |
66
|
|
|
* @return $this |
67
|
|
|
*/ |
68
|
|
|
public function setNotifyUrl(string $notifyUrl) |
69
|
|
|
{ |
70
|
|
|
$this->config->set('notify_url', $notifyUrl); |
71
|
|
|
|
72
|
|
|
return $this; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* setReturnUrl. |
77
|
|
|
* |
78
|
|
|
* @param string $returnUrl |
79
|
|
|
* |
80
|
|
|
* @return $this |
81
|
|
|
*/ |
82
|
|
|
public function setReturnUrl(string $returnUrl) |
83
|
|
|
{ |
84
|
|
|
$this->config->set('return_url', $returnUrl); |
85
|
|
|
|
86
|
|
|
return $this; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* handleNotify. |
91
|
|
|
* |
92
|
|
|
* @param \Closure $closure |
93
|
|
|
* |
94
|
|
|
* @return \Symfony\Component\HttpFoundation\Response |
95
|
|
|
*/ |
96
|
|
|
public function handleNotify(Closure $closure) |
97
|
|
|
{ |
98
|
|
|
return (new Handle($this))->run($closure); |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|