dever 4 vuotta sitten
vanhempi
commit
9de8d2bd70
4 muutettua tiedostoa jossa 115 lisäystä ja 12 poistoa
  1. 9 3
      database/account.php
  2. 18 0
      lib/Alipay.php
  3. 71 0
      lib/Test.php
  4. 17 9
      src/Api.php

+ 9 - 3
database/account.php

@@ -13,6 +13,7 @@ $box = array
 (
 	1 => '正式环境',
 	2 => '沙箱模式',
+	3 => '测试环境',
 );
 
 return array
@@ -66,7 +67,7 @@ return array
 		'box'		=> array
 		(
 			'type' 		=> 'int-11',
-			'name' 		=> '支付环境',
+			'name' 		=> '支付环境-沙箱模式为支付时第三方平台不实际收费,测试环境为不拉取第三方支付',
 			'default' 	=> '1',
 			'desc' 		=> '支付环境',
 			'match' 	=> 'is_numeric',
@@ -291,10 +292,15 @@ return array
 	# 默认值
 	'default' => array
 	(
-		'col' => 'name,state,cdate',
+		'col' => 'name,system_source,type,state,cdate',
 		'value' => array
 		(
-			'"公众号支付",1,' . time(),
+			'"h5支付",1,"wechat",1,' . time(),
+			'"安卓支付",2,"wechat",1,' . time(),
+			'"苹果支付",3,"wechat",1,' . time(),
+			'"微信二维码支付",4,"wechat",1,' . time(),
+			'"微信小程序支付",5,"wechat",1,' . time(),
+			'"微信公众号支付",6,"wechat",1,' . time(),
 		),
 	),
 );

+ 18 - 0
lib/Alipay.php

@@ -163,4 +163,22 @@ class Alipay extends Core
 		$result = $this->aop()->rsaCheckV1($data, $this->config['public_key'], $this->signType);
 		return $result;
 	}
+
+	# 退款
+	public function refund($order_id, $cash)
+	{
+		$out_trade_no = $order_id;
+		$cash = $cash * 100;
+		$total_fee = $cash;
+		$refund_fee = $cash;
+		$input = new \WxPayRefund();
+		$input->SetOut_trade_no($out_trade_no);
+		$input->SetTotal_fee($total_fee);
+		$input->SetRefund_fee($refund_fee);
+
+	    $input->SetOut_refund_no($out_trade_no . '_' . time());
+	    $input->SetOp_user_id($this->config->GetMerchantId());
+		$result = \WxPayApi::refund($this->config, $input);
+		return $result;
+	}
 }

+ 71 - 0
lib/Test.php

@@ -0,0 +1,71 @@
+<?php namespace Pay\Lib;
+use Dever;
+
+class Test extends Core
+{
+	public function __construct($config)
+	{
+		$this->config = $config;
+	}
+
+	/**
+	 * 通知
+	 */
+	public function notify()
+	{
+		
+	}
+
+	/**
+	 * 获取统一下单的基本信息
+	 */
+	public function order($account_id, $project_id, $uid, $username, $product_id, $name, $cash, $openid = false, $type = 1, $order_id = false)
+	{
+		$order_id = $this->createOrder($uid, $username, $account_id, $project_id, $product_id, $name, $cash, $this->config['type'], $order_id);
+
+		return $order_id;
+	}
+
+	/**
+	 * 获取二维码支付
+	 */
+	public function qrcode($order, $refer)
+	{
+		return $order;
+	}
+
+	/**
+	 * 获取小程序支付
+	 */
+	public function applet($order)
+	{
+		return $order;
+	}
+
+
+	/**
+	 * 获取页面支付
+	 */
+	public function page($order, $refer)
+	{
+		return $order;
+	}
+
+	# 退款
+	public function refund($order_id, $cash)
+	{
+		$out_trade_no = $order_id;
+		$cash = $cash * 100;
+		$total_fee = $cash;
+		$refund_fee = $cash;
+		$input = new \WxPayRefund();
+		$input->SetOut_trade_no($out_trade_no);
+		$input->SetTotal_fee($total_fee);
+		$input->SetRefund_fee($refund_fee);
+
+	    $input->SetOut_refund_no($out_trade_no . '_' . time());
+	    $input->SetOp_user_id($this->config->GetMerchantId());
+		$result = \WxPayApi::refund($this->config, $input);
+		return $result;
+	}
+}

+ 17 - 9
src/Api.php

@@ -66,15 +66,16 @@ class Api
 	 */
 	public function pay($param = array())
 	{
-		$source = $this->getParam($param, 'source');
+		$system_source = $this->getParam($param, 'system_source');
 		$receipt = $this->getParam($param, 'receipt');
+		$account_id = $this->getParam($param, 'account_id');
 
-		$config = Dever::config('base', 'pay')->method;
+		$config = Dever::config('base', 'pay')->pay['method'];
 
-		if (isset($config[$source])) {
-			$param['account_id'] = $source;
-			$method = $config[$source];
-			if ($source == 3 && $receipt) {
+		if (isset($config[$system_source])) {
+			$param['account_id'] = $account_id ? $account_id : $system_source;
+			$method = $config[$system_source];
+			if ($system_source == 3 && $receipt) {
 				$method = $method[1];
 				$param['other'] = $receipt;
 			}
@@ -91,7 +92,7 @@ class Api
 	 */
 	public function applet($param = array())
 	{
-		$param['source'] = 4;
+		$param['system_source'] = 4;
 		$this->init($param);
 		return $this->method->applet($this->get(1));
 	}
@@ -103,7 +104,7 @@ class Api
 	 */
 	public function app($param = array())
 	{
-		$param['source'] = 1;
+		$param['system_source'] = 1;
 		$this->init($param);
 		$this->openid = -1;
 		return $this->method->app($this->get(3));
@@ -275,13 +276,20 @@ class Api
 		if (!$pay || ($pay && $pay['state'] != 1)) {
 			Dever::alert('没有账户信息');
 		}
+		
+		if (!$pay['type']) {
+			Dever::alert('账户类型错误');
+		}
 
 		$this->account_id = $pay['id'];
 		/*
 		$this->channel_id = $pay['channel_id'];
 		$this->system_source = $pay['system_source'];
 		*/
-		
+		if ($pay['box'] == 3) {
+			$pay['type'] = 'test';
+		}
+
 		$method = '\\Pay\\Lib\\' . ucwords($pay['type']);
 		if (isset($this->refer) && $this->refer) {
 			$pay['refer'] = $this->refer;