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