PayServiceV3.php
1.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
namespace addons\groupon\library\payv3;
use think\Log;
use addons\groupon\exception\Exception;
class PayServiceV3
{
protected $payment;
protected $platform;
public function __construct($payment, $platform = null)
{
$this->payment = $payment;
$this->platform = $platform ?: request()->header('platform', null);
if (!$this->platform) {
throw new Exception('缺少用户端平台参数');
}
}
/**
* 支付提供器
*
* @param string $type
* @return Base
*/
public function provider($payment = null)
{
$payment = $payment ?: $this->payment;
$class = "\\addons\\groupon\\library\\payv3\\provider\\" . \think\helper\Str::studly($payment);
if (class_exists($class)) {
return new $class($this, $this->platform);
}
throw new Exception('支付类型不支持');
}
public function __call($funcname, $arguments)
{
return $this->provider()->{$funcname}(...$arguments);
}
}