|
@@ -16,6 +16,13 @@ class Api
|
|
|
Dever::location($url);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public function channel()
|
|
|
+ {
|
|
|
+ $data = Dever::db('pay/channel')->getData();
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
* 发起支付 下单 获取预支付信息
|
|
|
*
|
|
@@ -48,10 +55,34 @@ class Api
|
|
|
if (!$this->account_id) {
|
|
|
Dever::alert('没有账户信息');
|
|
|
}
|
|
|
- $this->pay();
|
|
|
+ $this->handle();
|
|
|
return $this->method->notify();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 发起支付 通用的发起支付方法
|
|
|
+ *
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
+ public function pay($param = array())
|
|
|
+ {
|
|
|
+ $source = $this->getParam($param, 'source');
|
|
|
+ $receipt = $this->getParam($param, 'receipt');
|
|
|
+
|
|
|
+ $config = Dever::config('base', 'pay')->method;
|
|
|
+
|
|
|
+ if (isset($config[$source])) {
|
|
|
+ $param['account_id'] = $source;
|
|
|
+ $method = $config[$source];
|
|
|
+ if ($source == 3 && $receipt) {
|
|
|
+ $method = $method[1];
|
|
|
+ }
|
|
|
+ return $this->$method($param);
|
|
|
+ } else {
|
|
|
+ Dever::alert('错误的source');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
* 发起支付 用于小程序支付
|
|
|
*
|
|
@@ -59,6 +90,7 @@ class Api
|
|
|
*/
|
|
|
public function applet($param = array())
|
|
|
{
|
|
|
+ $param['source'] = 4;
|
|
|
$this->init($param);
|
|
|
return $this->method->applet($this->get(1));
|
|
|
}
|
|
@@ -70,6 +102,7 @@ class Api
|
|
|
*/
|
|
|
public function app($param = array())
|
|
|
{
|
|
|
+ $param['source'] = 1;
|
|
|
$this->init($param);
|
|
|
$this->openid = -1;
|
|
|
return $this->method->app($this->get(3));
|
|
@@ -129,7 +162,7 @@ class Api
|
|
|
if (!$this->account_id) {
|
|
|
Dever::alert('没有账户信息');
|
|
|
}
|
|
|
- $this->pay();
|
|
|
+ $this->handle();
|
|
|
$this->order_id = $this->getParam($param, 'order_id');
|
|
|
return $this->method->search($this->order_id);
|
|
|
}
|
|
@@ -145,7 +178,7 @@ class Api
|
|
|
if (!$this->account_id) {
|
|
|
Dever::alert('没有账户信息');
|
|
|
}
|
|
|
- $this->pay();
|
|
|
+ $this->handle();
|
|
|
$this->order_id = $this->getParam($param, 'order_id');
|
|
|
return $this->method->refundByOrder($this->order_id);
|
|
|
}
|
|
@@ -160,16 +193,18 @@ class Api
|
|
|
if (isset($this->account_id)) {
|
|
|
return;
|
|
|
}
|
|
|
+ $this->channel_id = $this->getParam($param, 'channel_id');
|
|
|
+ $this->system_source = $this->getParam($param, 'system_source');
|
|
|
$this->account_id = $this->getParam($param, 'account_id');
|
|
|
$this->project_id = $this->getParam($param, 'project_id');
|
|
|
$this->uid = $this->getParam($param, 'uid');
|
|
|
+ $this->openid = $this->getParam($param, 'openid');
|
|
|
$this->username = $this->getParam($param, 'username');
|
|
|
$this->product_id = $this->getParam($param, 'product_id');
|
|
|
$this->name = $this->getParam($param, 'name');
|
|
|
$this->cash = $this->getParam($param, 'cash');
|
|
|
$this->refer = $this->getParam($param, 'refer');
|
|
|
$this->order_id = $this->getParam($param, 'order_id');
|
|
|
- $this->openid = $this->getParam($param, 'openid');
|
|
|
$this->other = $this->getParam($param, 'other');
|
|
|
$this->h5 = $this->getParam($param, 'h5');
|
|
|
$this->ip = $this->getParam($param, 'ip');
|
|
@@ -182,7 +217,7 @@ class Api
|
|
|
$this->order_id = false;
|
|
|
}
|
|
|
|
|
|
- if (!$this->account_id) {
|
|
|
+ if (!$this->account_id && !$this->channel_id && !$this->system_source) {
|
|
|
Dever::alert('没有账户信息');
|
|
|
}
|
|
|
|
|
@@ -206,7 +241,7 @@ class Api
|
|
|
$this->ip = Dever::ip();
|
|
|
}
|
|
|
|
|
|
- return $this->pay();
|
|
|
+ return $this->handle();
|
|
|
}
|
|
|
|
|
|
|
|
@@ -227,9 +262,25 @@ class Api
|
|
|
*
|
|
|
* @return mixed
|
|
|
*/
|
|
|
- private function pay()
|
|
|
+ private function handle()
|
|
|
{
|
|
|
- $pay = Dever::db('pay/account')->one($this->account_id);
|
|
|
+ $pay = false;
|
|
|
+ if ($this->account_id > 0) {
|
|
|
+ $pay = Dever::db('pay/account')->one($this->account_id);
|
|
|
+ } elseif ($this->channel_id && $this->system_source) {
|
|
|
+ $pay = Dever::db('pay/account')->one(array('channel_id' => $channel_id, 'system_source' => $this->system_source));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!$pay || ($pay && $pay['state'] != 1)) {
|
|
|
+ Dever::alert('没有账户信息');
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->account_id = $pay['id'];
|
|
|
+
|
|
|
+ $this->channel_id = $pay['channel_id'];
|
|
|
+ $this->system_source = $pay['system_source'];
|
|
|
+ */
|
|
|
+
|
|
|
$method = '\\Pay\\Lib\\' . ucwords($pay['type']);
|
|
|
if (isset($this->refer) && $this->refer) {
|
|
|
$pay['refer'] = $this->refer;
|