Commit 92425b2b by yeran

update 3.1.0

1 parent 5d36bb51
Showing with 2898 additions and 319 deletions
# payment # payment
> 支付工具包 v1.0 from riverslei/payment > 支付工具包 v1.0 from riverslei/payment
\ No newline at end of file
> v 2.0
* 新增通联支付
> v3.0
* 新增Mi付通道
> v3.1
* 新增扫呗支付通道
* 优化业务逻辑、修复已知bug
\ No newline at end of file
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-08-01 11:37 * @createTime: 2016-08-01 11:37
* @description: 微信配置文件 * @description: 微信配置文件
*/ */
......
<?php <?php
/**
* 手机app支付demo
* Created by PhpStorm.
* User: helei
* Date: 2017/4/30
* Time: 下午5:38
*/
require_once __DIR__ . '/../../autoload.php'; require_once __DIR__ . '/../../autoload.php';
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* 条码支付 * 条码支付
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/30 * Date: 2017/4/30
* Time: 下午4:32 * Time: 下午4:32
*/ */
......
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/30 * Date: 2017/4/30
* Time: 下午4:29 * Time: 下午4:29
*/ */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* 查询订单 * 查询订单
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/30 * Date: 2017/4/30
* Time: 下午5:35 * Time: 下午5:35
*/ */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* 查询订单退款状态 * 查询订单退款状态
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/30 * Date: 2017/4/30
* Time: 下午5:55 * Time: 下午5:55
*/ */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* 转账查询 * 转账查询
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/30 * Date: 2017/4/30
* Time: 下午6:00 * Time: 下午6:00
*/ */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* 退款操作 * 退款操作
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/30 * Date: 2017/4/30
* Time: 下午5:43 * Time: 下午5:43
*/ */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* 支付转账操作 * 支付转账操作
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/30 * Date: 2017/4/30
* Time: 下午5:57 * Time: 下午5:57
*/ */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* wap网站支付 * wap网站支付
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/30 * Date: 2017/4/30
* Time: 上午11:31 * Time: 上午11:31
*/ */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* 电脑支付 即时到账接口 * 电脑支付 即时到账接口
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/30 * Date: 2017/4/30
* Time: 下午4:34 * Time: 下午4:34
*/ */
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-15 17:19 * @createTime: 2016-07-15 17:19
* @description: * @description:
*/ */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* 招商绑卡操作 签约 * 招商绑卡操作 签约
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/30 * Date: 2017/4/30
* Time: 下午1:39 * Time: 下午1:39
*/ */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* 招商一网通支付 * 招商一网通支付
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/30 * Date: 2017/4/30
* Time: 上午11:55 * Time: 上午11:55
*/ */
......
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/30 * Date: 2017/4/30
* Time: 下午2:18 * Time: 下午2:18
*/ */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* 招商一网通支付 * 招商一网通支付
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/30 * Date: 2017/4/30
* Time: 上午11:55 * Time: 上午11:55
*/ */
......
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/30 * Date: 2017/4/30
* Time: 下午2:29 * Time: 下午2:29
*/ */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* 招商退款操作 * 招商退款操作
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/30 * Date: 2017/4/30
* Time: 下午6:03 * Time: 下午6:03
*/ */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* 招商一网通配置文件 * 招商一网通配置文件
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/27 * Date: 2017/4/27
* Time: 上午11:29 * Time: 上午11:29
*/ */
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-08-01 11:37 * @createTime: 2016-08-01 11:37
* @description: 微信配置文件 * @description: 微信配置文件
*/ */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* 退款处理 金额必须是 3.01 * 退款处理 金额必须是 3.01
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/30 * Date: 2017/4/30
* Time: 下午3:51 * Time: 下午3:51
*/ */
......
<?php <?php
/** /**
* 第三方支付回调处理 * 第三方支付回调处理
* @author: helei *
* @createTime: 2016-07-25 15:57 * @createTime: 2016-07-25 15:57
* @description: 支付通知回调 * @description: 支付通知回调
*/ */
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
use Payment\Notify\PayNotifyInterface; use Payment\Notify\PayNotifyInterface;
use Payment\Config; use Payment\Config;
/** /**
* @author: helei *
* @createTime: 2016-07-20 18:31 * @createTime: 2016-07-20 18:31
* @description: * @description:
*/ */
...@@ -11,7 +11,7 @@ use Payment\Config; ...@@ -11,7 +11,7 @@ use Payment\Config;
/** /**
* 客户端需要继承该接口,并实现这个方法,在其中实现对应的业务逻辑 * 客户端需要继承该接口,并实现这个方法,在其中实现对应的业务逻辑
* Class TestNotify * Class TestNotify
* anthor helei *
*/ */
class TestNotify implements PayNotifyInterface class TestNotify implements PayNotifyInterface
{ {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* 公众号支付 * 公众号支付
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/30 * Date: 2017/4/30
* Time: 下午3:33 * Time: 下午3:33
*/ */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* 公众号支付 * 公众号支付
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/30 * Date: 2017/4/30
* Time: 下午3:33 * Time: 下午3:33
*/ */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* 查询支付的订单 * 查询支付的订单
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/30 * Date: 2017/4/30
* Time: 下午3:43 * Time: 下午3:43
*/ */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* 退款处理 金额必须是 3.01 * 退款处理 金额必须是 3.01
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/30 * Date: 2017/4/30
* Time: 下午3:51 * Time: 下午3:51
*/ */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* app支付 * app支付
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/30 * Date: 2017/4/30
* Time: 上午11:50 * Time: 上午11:50
*/ */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* 刷卡支付 * 刷卡支付
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/30 * Date: 2017/4/30
* Time: 下午3:12 * Time: 下午3:12
*/ */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* 公众号支付 * 公众号支付
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/30 * Date: 2017/4/30
* Time: 下午3:33 * Time: 下午3:33
*/ */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* 公众号支付 * 公众号支付
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/30 * Date: 2017/4/30
* Time: 下午3:33 * Time: 下午3:33
*/ */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* 微信扫码支付 * 微信扫码支付
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/30 * Date: 2017/4/30
* Time: 下午2:46 * Time: 下午2:46
*/ */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* 查询支付的订单 * 查询支付的订单
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/30 * Date: 2017/4/30
* Time: 下午3:43 * Time: 下午3:43
*/ */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* 查询退款订单 * 查询退款订单
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/30 * Date: 2017/4/30
* Time: 下午3:43 * Time: 下午3:43
*/ */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* 转账查询 没有沙箱模式 * 转账查询 没有沙箱模式
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/30 * Date: 2017/4/30
* Time: 下午3:48 * Time: 下午3:48
*/ */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* 退款处理 金额必须是 3.01 * 退款处理 金额必须是 3.01
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/30 * Date: 2017/4/30
* Time: 下午3:51 * Time: 下午3:51
*/ */
......
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/30 * Date: 2017/4/30
* Time: 下午4:13 * Time: 下午4:13
*/ */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* 微信wap支付 * 微信wap支付
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/30 * Date: 2017/4/30
* Time: 下午3:40 * Time: 下午3:40
*/ */
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-08-01 11:37 * @createTime: 2016-08-01 11:37
* @description: 微信配置文件 * @description: 微信配置文件
*/ */
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
namespace Payment; namespace Payment;
use Payment\Charge\MiPay\MiCancel; use Payment\Charge\MiPay\MiCancel;
use Payment\Charge\Sw\SwCancel;
use Payment\Charge\TLpay\TLCancel; use Payment\Charge\TLpay\TLCancel;
use Payment\Common\BaseStrategy; use Payment\Common\BaseStrategy;
use Payment\Common\PayException; use Payment\Common\PayException;
...@@ -46,6 +47,9 @@ class CancelContext ...@@ -46,6 +47,9 @@ class CancelContext
case Config::MI_CHANNEL_LITE: case Config::MI_CHANNEL_LITE:
$this->cancelHandler = new MiCancel($config); $this->cancelHandler = new MiCancel($config);
break; break;
case Config::SW_CHARGE:
$this->cancelHandler = new SwCancel($config);
break;
default: default:
throw new PayException('当前仅支持:通联支付平台'); throw new PayException('当前仅支持:通联支付平台');
} }
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-14 18:20 * @createTime: 2016-07-14 18:20
* @description: 支付宝移动支付接口 * @description: 支付宝移动支付接口
* @link https://github.com/helei112g/payment/tree/paymentv2 * @link https://github.com/helei112g/payment/tree/paymentv2
...@@ -20,7 +20,7 @@ class AliAppCharge extends AliBaseStrategy ...@@ -20,7 +20,7 @@ class AliAppCharge extends AliBaseStrategy
/** /**
* 获取支付对应的数据完成类 * 获取支付对应的数据完成类
* @return string * @return string
* @author helei *
*/ */
public function getBuildDataClass() public function getBuildDataClass()
{ {
......
...@@ -47,7 +47,7 @@ class AliBarCharge extends AliBaseStrategy ...@@ -47,7 +47,7 @@ class AliBarCharge extends AliBaseStrategy
* *
* @throws PayException * @throws PayException
* @return string 可生产二维码的uri * @return string 可生产二维码的uri
* @author helei *
*/ */
protected function retData(array $ret) protected function retData(array $ret)
{ {
......
...@@ -30,7 +30,7 @@ class AliQrCharge extends AliBaseStrategy ...@@ -30,7 +30,7 @@ class AliQrCharge extends AliBaseStrategy
* *
* @throws PayException * @throws PayException
* @return string 可生产二维码的uri * @return string 可生产二维码的uri
* @author helei *
*/ */
protected function retData(array $ret) protected function retData(array $ret)
{ {
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-14 18:19 * @createTime: 2016-07-14 18:19
* @description: 支付宝 手机网站支付 接口 * @description: 支付宝 手机网站支付 接口
* @link https://github.com/helei112g/payment/tree/paymentv2 * @link https://github.com/helei112g/payment/tree/paymentv2
...@@ -19,7 +19,7 @@ class AliWapCharge extends AliBaseStrategy ...@@ -19,7 +19,7 @@ class AliWapCharge extends AliBaseStrategy
/** /**
* 获取支付对应的数据完成类 * 获取支付对应的数据完成类
* @return string * @return string
* @author helei *
*/ */
public function getBuildDataClass() public function getBuildDataClass()
{ {
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-14 17:56 * @createTime: 2016-07-14 17:56
* @description: 支付宝 即时到账 接口 * @description: 支付宝 即时到账 接口
* @link https://github.com/helei112g/payment/tree/paymentv2 * @link https://github.com/helei112g/payment/tree/paymentv2
...@@ -18,7 +18,7 @@ class AliWebCharge extends AliBaseStrategy ...@@ -18,7 +18,7 @@ class AliWebCharge extends AliBaseStrategy
/** /**
* 获取支付对应的数据完成类 * 获取支付对应的数据完成类
* @return string * @return string
* @author helei *
*/ */
public function getBuildDataClass() public function getBuildDataClass()
{ {
......
...@@ -8,7 +8,7 @@ use Payment\Common\Cmb\Data\Charge\ChargeData; ...@@ -8,7 +8,7 @@ use Payment\Common\Cmb\Data\Charge\ChargeData;
/** /**
* 一网通支付API 接口 * 一网通支付API 接口
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/27 * Date: 2017/4/27
* Time: 下午12:36 * Time: 下午12:36
*/ */
......
...@@ -21,7 +21,7 @@ class MiCancel extends MiBaseStrategy{ ...@@ -21,7 +21,7 @@ class MiCancel extends MiBaseStrategy{
/** /**
* 交易撤销 的url * 交易撤销 的url
* @return null|string * @return null|string
* @author helei *
*/ */
protected function getReqUrl() protected function getReqUrl()
{ {
...@@ -31,7 +31,7 @@ class MiCancel extends MiBaseStrategy{ ...@@ -31,7 +31,7 @@ class MiCancel extends MiBaseStrategy{
/** /**
* 获取交易退款对应的数据完成类 * 获取交易退款对应的数据完成类
* @return MiCancelData * @return MiCancelData
* @author helei *
*/ */
public function getBuildDataClass() public function getBuildDataClass()
{ {
......
...@@ -41,7 +41,7 @@ class MiLiteCharge extends MiBaseStrategy ...@@ -41,7 +41,7 @@ class MiLiteCharge extends MiBaseStrategy
* 'paySign' => '', // 签名 * 'paySign' => '', // 签名
* ]; * ];
* ``` * ```
* @author helei *
*/ */
protected function retData(array $ret) protected function retData(array $ret)
{ {
......
<?php
namespace Payment\Charge\Sw;
use Payment\Common\Sw\Data\BackBarChargeData;
use Payment\Common\Sw\Data\BackScanChargeData;
use Payment\Common\Sw\Data\Charge\BarChargeData;
use Payment\Common\Sw\SwBaseStrategy;
use Payment\Common\SwConfig;
/**
* Class SwBarCharge
*
* 扫呗刷卡(条码)支付
*
* @package Payment\Charge\Sw
*
*/
class SwBarCharge extends SwBaseStrategy
{
public function getBuildDataClass()
{
return BarChargeData::class;
}
protected function getReqUrl(){
return SwConfig::BARCODE_URL;
}
/**
* 处理扫码支付的返回值
* @param array $ret
*
* @return array $backData
*
*
*/
protected function retData(array $ret)
{
$back = new BackBarChargeData($this->config, $ret);
$backData = $back->getData();
// 移除sign
unset($backData['sign']);
return $backData;
}
}
<?php
namespace Payment\Charge\Sw;
use Payment\Common\Sw\Data\BackCancelData;
use Payment\Common\Sw\Data\Charge\CancelData;
use Payment\Common\Sw\SwBaseStrategy;
use Payment\Common\SwConfig;
/**
* Class SwCancel
*
* 扫呗取消订单 (只针对刷卡支付!!!!!!)
*
* @package Payment\Charge\Sw
*
*/
class SwCancel extends SwBaseStrategy
{
public function getBuildDataClass()
{
return CancelData::class;
}
protected function getReqUrl(){
return SwConfig::CANCEL_URL;
}
/**
* 处理小程序支付的返回值
* @param array $ret
*
* @return array $backData
*
*
*/
protected function retData(array $ret)
{
$back = new BackCancelData($this->config, $ret);
$backData = $back->getData();
// 移除sign
unset($backData['sign']);
return $backData;
}
}
<?php
namespace Payment\Charge\Sw;
use Payment\Common\Sw\Data\BackCancelData;
use Payment\Common\Sw\Data\BackCloseData;
use Payment\Common\Sw\Data\Charge\CancelData;
use Payment\Common\Sw\Data\Charge\CloseData;
use Payment\Common\Sw\SwBaseStrategy;
use Payment\Common\SwConfig;
/**
* Class SwClose
*
* 扫呗关闭订单 ((仅限服务商模式商户且为微信支付时可用)!!!!!!)
*
* 此接口也支持支付宝,但仅限扫了二维码但没有输密码的情况下
* 刷卡支付不能进行关单操作
*
* @package Payment\Charge\Sw
*
*/
class SwClose extends SwBaseStrategy
{
public function getBuildDataClass()
{
return CloseData::class;
}
protected function getReqUrl(){
return SwConfig::CLOSE_URL;
}
/**
* 处理小程序支付的返回值
* @param array $ret
*
* @return array $backData
*
*
*/
protected function retData(array $ret)
{
$back = new BackCloseData($this->config, $ret);
$backData = $back->getData();
// 移除sign
unset($backData['sign']);
return $backData;
}
}
<?php
namespace Payment\Charge\Sw;
use Payment\Common\Sw\Data\BackFaceChargeData;
use Payment\Common\Sw\Data\Charge\FaceChargeData;
use Payment\Common\Sw\SwBaseStrategy;
use Payment\Common\SwConfig;
/**
* Class SwFaceCharge
*
* 扫呗自主收银(人脸支付)
*
* @package Payment\Charge\Sw
*
*/
class SwFaceCharge extends SwBaseStrategy
{
public function getBuildDataClass()
{
return FaceChargeData::class;
}
protected function getReqUrl(){
return SwConfig::FACEPAY_URL;
}
/**
* 处理小程序支付的返回值
* @param array $ret
*
* @return array $backData
*
*
*/
protected function retData(array $ret)
{
$back = new BackFaceChargeData($this->config, $ret);
$backData = $back->getData();
// 移除sign
unset($backData['sign']);
return $backData;
}
}
<?php
namespace Payment\Charge\Sw;
use Payment\Common\Sw\Data\BackFaceInfoData;
use Payment\Common\Sw\Data\Charge\FaceInfoData;
use Payment\Common\Sw\SwBaseStrategy;
use Payment\Common\SwConfig;
/**
* Class SwFaceInfo
*
* 自助收银SDK调用凭证获取接口
*
* @package Payment\Charge\Sw
*
*/
class SwFaceInfo extends SwBaseStrategy
{
public function getBuildDataClass()
{
return FaceInfoData::class;
}
protected function getReqUrl(){
return SwConfig::FACEPAY_ACCESSTOKEN_URL;
}
/**
* 处理小程序支付的返回值
* @param array $ret
*
* @return array $backData
*
*
*/
protected function retData(array $ret)
{
$back = new BackFaceInfoData($this->config, $ret);
$backData = $back->getData();
// 移除sign
unset($backData['sign']);
return $backData;
}
}
<?php
namespace Payment\Charge\Sw;
use Payment\Common\Sw\Data\BackLiteChargeData;
use Payment\Common\Sw\Data\Charge\LiteChargeData;
use Payment\Common\Sw\SwBaseStrategy;
use Payment\Common\SwConfig;
/**
* Class SwLiteCharge
*
* 扫呗小程序支付
*
* @package Payment\Charge\Sw
*
*/
class SwLiteCharge extends SwBaseStrategy
{
public function getBuildDataClass()
{
return LiteChargeData::class;
}
protected function getReqUrl(){
return SwConfig::LITEPAY_URL;
}
/**
* 处理小程序支付的返回值
* @param array $ret
*
* @return array $backData
*
*
*/
protected function retData(array $ret)
{
$back = new BackLiteChargeData($this->config, $ret);
$backData = $back->getData();
// 移除sign
unset($backData['sign']);
return $backData;
}
}
<?php
namespace Payment\Charge\Sw;
use Payment\Common\Sw\Data\BackPubChargeData;
use Payment\Common\Sw\Data\Charge\PubChargeData;
use Payment\Common\Sw\SwBaseStrategy;
/**
* Class SwPubCharge
*
* 扫呗微信公众号支付
*
* @package Payment\Charge\Sw
*
*/
class SwPubCharge extends SwBaseStrategy
{
public function getBuildDataClass()
{
// $this->config->tradeType = 'JSAPI';
return PubChargeData::class;
}
/**
* 处理公众号支付的返回值。直接返回与微信文档对应的字段
* @param array $ret
*
* @return array $data 包含以下键
*
* ```php
* $data = [
* 'appId' => '', // 公众号id
* 'package' => '', // 订单详情扩展字符串 统一下单接口返回的prepay_id参数值,提交格式如:prepay_id=***
* 'nonceStr' => '', // 随机字符串
* 'timeStamp' => '', // 时间戳
* 'signType' => '', // 签名算法,暂支持MD5
* 'paySign' => '', // 签名
* ];
* ```
*
*/
protected function retData(array $ret)
{
$back = new BackPubChargeData($this->config, $ret);
// $back->setSign();
$backData = $back->getData();
// $backData['paySign'] = $backData['sign'];
// 移除sign
unset($backData['sign']);
// 公众号支付返回数组结构
return $backData;
}
}
<?php
namespace Payment\Charge\Sw;
use Payment\Common\Sw\Data\BackScanChargeData;
use Payment\Common\Sw\Data\Charge\ScanChargeData;
use Payment\Common\Sw\SwBaseStrategy;
use Payment\Common\SwConfig;
/**
* Class SwScanCharge
*
* 扫呗扫码支付
*
* @package Payment\Charge\Sw
*
*/
class SwScanCharge extends SwBaseStrategy
{
public function getBuildDataClass()
{
return ScanChargeData::class;
}
protected function getReqUrl(){
return SwConfig::SCANPAY_URL;
}
/**
* 处理扫码支付的返回值
* @param array $ret
*
* @return array $backData
*
*
*/
protected function retData(array $ret)
{
$back = new BackScanChargeData($this->config, $ret);
$backData = $back->getData();
// 移除sign
unset($backData['sign']);
return $backData;
}
}
...@@ -21,7 +21,7 @@ class TLCancel extends TLBaseStrategy{ ...@@ -21,7 +21,7 @@ class TLCancel extends TLBaseStrategy{
/** /**
* 交易撤销 的url * 交易撤销 的url
* @return null|string * @return null|string
* @author helei *
*/ */
protected function getReqUrl() protected function getReqUrl()
{ {
...@@ -31,7 +31,7 @@ class TLCancel extends TLBaseStrategy{ ...@@ -31,7 +31,7 @@ class TLCancel extends TLBaseStrategy{
/** /**
* 获取交易退款对应的数据完成类 * 获取交易退款对应的数据完成类
* @return TLCancelData * @return TLCancelData
* @author helei *
*/ */
public function getBuildDataClass() public function getBuildDataClass()
{ {
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-14 18:28 * @createTime: 2016-07-14 18:28
* @description: 微信 公众号 支付接口 * @description: 微信 公众号 支付接口
* @link https://github.com/helei112g/payment/tree/paymentv2 * @link https://github.com/helei112g/payment/tree/paymentv2
...@@ -19,7 +19,7 @@ use Payment\Common\TLpay\TLBaseStrategy; ...@@ -19,7 +19,7 @@ use Payment\Common\TLpay\TLBaseStrategy;
* 通联支付-微信小程序支付 * 通联支付-微信小程序支付
* *
* @package Payment\Charge\TLpay * @package Payment\Charge\TLpay
* anthor helei *
*/ */
class TLLiteCharge extends TLBaseStrategy class TLLiteCharge extends TLBaseStrategy
{ {
...@@ -45,7 +45,7 @@ class TLLiteCharge extends TLBaseStrategy ...@@ -45,7 +45,7 @@ class TLLiteCharge extends TLBaseStrategy
* 'paySign' => '', // 签名 * 'paySign' => '', // 签名
* ]; * ];
* ``` * ```
* @author helei *
*/ */
protected function retData(array $ret) protected function retData(array $ret)
{ {
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-14 17:56 * @createTime: 2016-07-14 17:56
* @description: 微信 app 支付接口 * @description: 微信 app 支付接口
* @link https://github.com/helei112g/payment/tree/paymentv2 * @link https://github.com/helei112g/payment/tree/paymentv2
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
namespace Payment\Charge\Wx; namespace Payment\Charge\Wx;
use Payment\Common\Weixin\Data\BackAppChargeData; use Payment\Common\Weixin\Data\BackLiteChargeData;
use Payment\Common\Weixin\Data\Charge\AppChargeData; use Payment\Common\Weixin\Data\Charge\AppChargeData;
use Payment\Common\Weixin\WxBaseStrategy; use Payment\Common\Weixin\WxBaseStrategy;
...@@ -38,11 +38,11 @@ class WxAppCharge extends WxBaseStrategy ...@@ -38,11 +38,11 @@ class WxAppCharge extends WxBaseStrategy
* 'sign' => '', // 签名 * 'sign' => '', // 签名
* ]; * ];
* ``` * ```
* @author helei *
*/ */
protected function retData(array $ret) protected function retData(array $ret)
{ {
$back = new BackAppChargeData($this->config, $ret); $back = new BackLiteChargeData($this->config, $ret);
$back->setSign(); $back->setSign();
$backData = $back->getData(); $backData = $back->getData();
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2017-03-06 18:29 * @createTime: 2017-03-06 18:29
* @description: 微信 刷卡支付 对应支付宝的条码支付 * @description: 微信 刷卡支付 对应支付宝的条码支付
* @link https://github.com/helei112g/payment/tree/paymentv2 * @link https://github.com/helei112g/payment/tree/paymentv2
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
namespace Payment\Charge\Wx; namespace Payment\Charge\Wx;
use Payment\Common\Weixin\Data\Charge\BarChargeData; use Payment\Common\Weixin\Data\Charge\ScanChargeData;
use Payment\Common\Weixin\WxBaseStrategy; use Payment\Common\Weixin\WxBaseStrategy;
use Payment\Common\WxConfig; use Payment\Common\WxConfig;
...@@ -17,7 +17,7 @@ class WxBarCharge extends WxBaseStrategy ...@@ -17,7 +17,7 @@ class WxBarCharge extends WxBaseStrategy
{ {
public function getBuildDataClass() public function getBuildDataClass()
{ {
return BarChargeData::class; return ScanChargeData::class;
} }
/** /**
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-14 18:28 * @createTime: 2016-07-14 18:28
* @description: 微信 公众号 支付接口 * @description: 微信 公众号 支付接口
* @link https://github.com/helei112g/payment/tree/paymentv2
* @link https://helei112g.github.io/
*/ */
namespace Payment\Charge\Wx; namespace Payment\Charge\Wx;
...@@ -19,7 +17,7 @@ use Payment\Common\Weixin\WxBaseStrategy; ...@@ -19,7 +17,7 @@ use Payment\Common\Weixin\WxBaseStrategy;
* 微信公众号支付 * 微信公众号支付
* *
* @package Payment\Charge\Weixin * @package Payment\Charge\Weixin
* anthor helei *
*/ */
class WxPubCharge extends WxBaseStrategy class WxPubCharge extends WxBaseStrategy
{ {
...@@ -45,7 +43,7 @@ class WxPubCharge extends WxBaseStrategy ...@@ -45,7 +43,7 @@ class WxPubCharge extends WxBaseStrategy
* 'paySign' => '', // 签名 * 'paySign' => '', // 签名
* ]; * ];
* ``` * ```
* @author helei *
*/ */
protected function retData(array $ret) protected function retData(array $ret)
{ {
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-14 18:29 * @createTime: 2016-07-14 18:29
* @description: 微信 扫码支付 主要用于网站上 * @description: 微信 扫码支付 主要用于网站上
* @link https://github.com/helei112g/payment/tree/paymentv2 * @link https://github.com/helei112g/payment/tree/paymentv2
...@@ -24,7 +24,7 @@ class WxQrCharge extends WxBaseStrategy ...@@ -24,7 +24,7 @@ class WxQrCharge extends WxBaseStrategy
* 处理扫码支付的返回值 * 处理扫码支付的返回值
* @param array $ret * @param array $ret
* @return string 可生产二维码的uri * @return string 可生产二维码的uri
* @author helei *
*/ */
protected function retData(array $ret) protected function retData(array $ret)
{ {
......
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/3/6 * Date: 2017/3/6
* Time: 下午5:44 * Time: 下午5:44
*/ */
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-14 17:42 * @createTime: 2016-07-14 17:42
* @description: 暴露给客户端调用的接口 * @description: 暴露给客户端调用的接口
* @link https://github.com/helei112g/payment/tree/paymentv2 * @link https://github.com/helei112g/payment/tree/paymentv2
...@@ -17,6 +17,12 @@ use Payment\Charge\Ali\AliQrCharge; ...@@ -17,6 +17,12 @@ use Payment\Charge\Ali\AliQrCharge;
use Payment\Charge\Cmb\CmbCharge; use Payment\Charge\Cmb\CmbCharge;
use Payment\Charge\MiPay\MiLiteCharge; use Payment\Charge\MiPay\MiLiteCharge;
use Payment\Charge\Sw\SwBarCharge;
use Payment\Charge\Sw\SwFaceCharge;
use Payment\Charge\Sw\SwFaceInfo;
use Payment\Charge\Sw\SwLiteCharge;
use Payment\Charge\Sw\SwPubCharge;
use Payment\Charge\Sw\SwScanCharge;
use Payment\Charge\TLpay\TLLiteCharge; use Payment\Charge\TLpay\TLLiteCharge;
use Payment\Charge\Wx\WxAppCharge; use Payment\Charge\Wx\WxAppCharge;
use Payment\Charge\Wx\WxBarCharge; use Payment\Charge\Wx\WxBarCharge;
...@@ -32,7 +38,7 @@ use Payment\Common\PayException; ...@@ -32,7 +38,7 @@ use Payment\Common\PayException;
* 支付的上下文类 * 支付的上下文类
* *
* @package Payment * @package Payment
* anthor helei *
*/ */
class ChargeContext class ChargeContext
{ {
...@@ -49,7 +55,6 @@ class ChargeContext ...@@ -49,7 +55,6 @@ class ChargeContext
* - @see Config * - @see Config
* @param array $config 配置文件 * @param array $config 配置文件
* @throws PayException * @throws PayException
* @author helei
*/ */
public function initCharge($channel, array $config) public function initCharge($channel, array $config)
{ {
...@@ -92,14 +97,35 @@ class ChargeContext ...@@ -92,14 +97,35 @@ class ChargeContext
case Config::CMB_CHANNEL_APP: case Config::CMB_CHANNEL_APP:
$this->channel = new CmbCharge($config); $this->channel = new CmbCharge($config);
break; break;
case Config::TL_CHANNEL_LITE: //通联支付 case Config::TL_CHANNEL_LITE: //通联支付
$this->channel = new TLLiteCharge($config); $this->channel = new TLLiteCharge($config);
break; break;
case Config::MI_CHANNEL_LITE: //米付小程序通道 case Config::MI_CHANNEL_LITE: //米付小程序通道
$this->channel = new MiLiteCharge($config); $this->channel = new MiLiteCharge($config);
break; break;
//扫呗
case Config::SW_CHANNEL_PUB:
$this->channel = new SwPubCharge($config);
break;
case Config::SW_CHANNEL_LITE:
$this->channel = new SwLiteCharge($config);
break;
case Config::SW_CHANNEL_SCAN: //目前主扫模式已经逐步被被扫模式替换
$this->channel = new SwScanCharge($config);
break;
case Config::SW_CHANNEL_BAR: //用户被扫模式
$this->channel = new SwBarCharge($config);
break;
case Config::SW_CHANNEL_FACEPAY:
$this->channel = new SwFaceCharge($config);
break;
case Config::SW_CHANNEL_FACEPAY_TOKEN:
$this->channel = new SwFaceInfo($config);
break;
default: default:
throw new PayException('当前支持:支付宝 微信 招商一网通 通联支付 米付'); throw new PayException('当前支持:支付宝 微信 招商一网通 通联支付 米付');
} }
...@@ -125,7 +151,7 @@ class ChargeContext ...@@ -125,7 +151,7 @@ class ChargeContext
* *
* @return array * @return array
* @throws PayException * @throws PayException
* @author helei *
*/ */
public function charge(array $data) public function charge(array $data)
{ {
......
...@@ -36,6 +36,8 @@ class Cancel ...@@ -36,6 +36,8 @@ class Cancel
Config::TL_CHANNEL_LITE,//通联支付 Config::TL_CHANNEL_LITE,//通联支付
Config::MI_CHANNEL_LITE, //米付 Config::MI_CHANNEL_LITE, //米付
Config::SW_CHARGE,//扫呗支付退款
]; ];
/** /**
......
...@@ -25,12 +25,20 @@ class Charge ...@@ -25,12 +25,20 @@ class Charge
Config::WX_CHANNEL_LITE,// 微信小程序支付 Config::WX_CHANNEL_LITE,// 微信小程序支付
Config::CMB_CHANNEL_APP,// 招行一网通 Config::CMB_CHANNEL_APP,// 招行一网通
'applepay_upacp',// Apple Pay Config::APPLE_PAY,// Apple Pay
Config::TL_CHANNEL_LITE, // 通联支付 Config::TL_CHANNEL_LITE, // 通联支付
Config::MI_CHANNEL_LITE,//米付小程序通道
//立楚扫呗:公众号、小程序、扫码、自助收款
Config::SW_CHANNEL_PUB,
Config::SW_CHANNEL_LITE,
Config::SW_CHANNEL_SCAN,
Config::SW_CHANNEL_FACEPAY,
Config::SW_CHANNEL_BAR,
Config::MI_CHANNEL_LITE,//米付小程序通道
]; ];
/** /**
......
...@@ -9,30 +9,36 @@ ...@@ -9,30 +9,36 @@
namespace Payment\Client; namespace Payment\Client;
use Payment\CancelContext; use Payment\CloseContext;
use Payment\Common\PayException; use Payment\Common\PayException;
use Payment\Config; use Payment\Config;
class OrderCancel { /**
* 关闭订单
*
* Class Close
* @package Payment\Client
*/
class Close {
private static $supportChannel = [ private static $supportChannel = [
Config::TL_CHANNEL_LITE, Config::SW_CHARGE,//扫呗支付关闭订单
]; ];
/** /**
* @var CancelContext * @var CloseContext
*/ */
protected static $instance; protected static $instance;
protected static function getInstance($channel, $config) protected static function getInstance($channel, $config){
{
if (is_null(self::$instance)) { if (is_null(self::$instance)) {
static::$instance = new CancelContext(); static::$instance = new CloseContext();
try { try {
static::$instance->initCancelHandler($channel, $config); static::$instance->initCloseHandler($channel, $config);
} catch (PayException $e) { } catch (PayException $e) {
throw $e; throw $e;
} }
...@@ -58,7 +64,7 @@ class OrderCancel { ...@@ -58,7 +64,7 @@ class OrderCancel {
try { try {
$instance = self::getInstance($channel, $config); $instance = self::getInstance($channel, $config);
$ret = $instance->cancel($metadata); $ret = $instance->close($metadata);
} catch (PayException $e) { } catch (PayException $e) {
throw $e; throw $e;
} }
......
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/28 * Date: 2017/4/28
* Time: 上午10:44 * Time: 上午10:44
*/ */
......
...@@ -22,6 +22,8 @@ class Notify ...@@ -22,6 +22,8 @@ class Notify
Config::TL_CHARGE,//通联支付 Config::TL_CHARGE,//通联支付
Config::MI_CHARGE,//米付 Config::MI_CHARGE,//米付
Config::SW_CHARGE,//扫呗
]; ];
/** /**
......
...@@ -36,6 +36,8 @@ class Query ...@@ -36,6 +36,8 @@ class Query
Config::TL_QUERY,//通联支付 Config::TL_QUERY,//通联支付
Config::MI_QUERY,//米付 Config::MI_QUERY,//米付
Config::SW_QUERY,//扫呗
]; ];
/** /**
......
...@@ -31,6 +31,8 @@ class Refund ...@@ -31,6 +31,8 @@ class Refund
Config::TL_REFUND,//通联支付 Config::TL_REFUND,//通联支付
Config::MI_REFUND,//米付 Config::MI_REFUND,//米付
Config::SW_REFUND,//扫呗
]; ];
/** /**
......
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/3/7 * Date: 2017/3/7
* Time: 下午3:16 * Time: 下午3:16
*/ */
......
<?php
/**
* @author: yeran
* @createTime: 2019-03-25 00:15
* @description: 交易关闭接口
*/
namespace Payment;
use Payment\Charge\Sw\SwClose;
use Payment\Common\BaseStrategy;
use Payment\Common\PayException;
/**
* Class CloseContext
* @package Payment
*/
class CloseContext
{
/**
* 退款的渠道
* @var BaseStrategy
*/
protected $closeHandler;
/**
* 设置对应的退款渠道
* @param string $channel 退款渠道
* - @see Config
*
* @param array $config 配置文件
* @throws PayException
* @author yeran
*/
public function initCloseHandler($channel, array $config)
{
try {
switch ($channel) {
case Config::SW_CHARGE:
$this->closeHandler = new SwClose($config);
break;
default:
throw new PayException('当前仅支持:通联支付平台');
}
} catch (PayException $e) {
throw $e;
}
}
/**
* 通过环境类调用交易关闭操作
*
* @param array $data
*
* @return array
* @throws PayException
* @author yeran
*/
public function close(array $data)
{
if (! $this->closeHandler instanceof BaseStrategy) {
throw new PayException('请检查初始化是否正确');
}
try {
return $this->closeHandler->handle($data);
} catch (PayException $e) {
throw $e;
}
}
}
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-15 17:10 * @createTime: 2016-07-15 17:10
* @description: 支付宝支付接口的基类。 * @description: 支付宝支付接口的基类。
* @link https://github.com/helei112g/payment/tree/paymentv2 * @link https://github.com/helei112g/payment/tree/paymentv2
...@@ -111,7 +111,7 @@ abstract class AliBaseStrategy implements BaseStrategy ...@@ -111,7 +111,7 @@ abstract class AliBaseStrategy implements BaseStrategy
* 处理支付宝的返回值并返回给客户端 * 处理支付宝的返回值并返回给客户端
* @param array $data * @param array $data
* @return string|array * @return string|array
* @author helei *
*/ */
protected function retData(array $data) protected function retData(array $data)
{ {
...@@ -134,7 +134,7 @@ abstract class AliBaseStrategy implements BaseStrategy ...@@ -134,7 +134,7 @@ abstract class AliBaseStrategy implements BaseStrategy
* 返回统一的交易状态 做一些转化,方便处理 * 返回统一的交易状态 做一些转化,方便处理
* @param $status * @param $status
* @return string * @return string
* @author helei *
*/ */
protected function getTradeStatus($status) protected function getTradeStatus($status)
{ {
...@@ -156,7 +156,7 @@ abstract class AliBaseStrategy implements BaseStrategy ...@@ -156,7 +156,7 @@ abstract class AliBaseStrategy implements BaseStrategy
* @param array $data * @param array $data
* @param string $sign 支付宝返回的签名结果 * @param string $sign 支付宝返回的签名结果
* @return bool * @return bool
* @author helei *
*/ */
protected function verifySign(array $data, $sign) protected function verifySign(array $data, $sign)
{ {
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-15 17:28 * @createTime: 2016-07-15 17:28
* @description: 支付宝相关数据的基类 * @description: 支付宝相关数据的基类
* @link https://github.com/helei112g/payment/tree/paymentv2 * @link https://github.com/helei112g/payment/tree/paymentv2
...@@ -33,7 +33,7 @@ use Payment\Utils\RsaEncrypt; ...@@ -33,7 +33,7 @@ use Payment\Utils\RsaEncrypt;
* @property string $partner 合作id * @property string $partner 合作id
* *
* @package Payment\Charge\Ali\Data * @package Payment\Charge\Ali\Data
* anthor helei *
*/ */
abstract class AliBaseData extends BaseData abstract class AliBaseData extends BaseData
{ {
...@@ -51,7 +51,7 @@ abstract class AliBaseData extends BaseData ...@@ -51,7 +51,7 @@ abstract class AliBaseData extends BaseData
* 签名算法实现 * 签名算法实现
* @param string $signStr * @param string $signStr
* @return string * @return string
* @author helei *
*/ */
protected function makeSign($signStr) protected function makeSign($signStr)
{ {
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-25 14:49 * @createTime: 2016-07-25 14:49
* @description: * @description:
*/ */
......
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei <dayugog@gmail.com> * <dayugog@gmail.com>
* Date: 2016/12/28 * Date: 2016/12/28
* Time: 20:24 * Time: 20:24
*/ */
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-20 14:33 * @createTime: 2016-07-20 14:33
* @description: * @description:
*/ */
...@@ -27,14 +27,14 @@ use Payment\Utils\ArrayUtil; ...@@ -27,14 +27,14 @@ use Payment\Utils\ArrayUtil;
* @property string $store_id 商户门店编号 * @property string $store_id 商户门店编号
* *
* @package Payment\Common\Ali\Data\Charge * @package Payment\Common\Ali\Data\Charge
* anthor helei *
*/ */
abstract class ChargeBaseData extends AliBaseData abstract class ChargeBaseData extends AliBaseData
{ {
/** /**
* 构建 APP支付 加密数据 * 构建 APP支付 加密数据
* @author helei *
*/ */
protected function buildData() protected function buildData()
{ {
...@@ -70,7 +70,7 @@ abstract class ChargeBaseData extends AliBaseData ...@@ -70,7 +70,7 @@ abstract class ChargeBaseData extends AliBaseData
* *
* 如果输入参数不符合规范,直接抛出异常 * 如果输入参数不符合规范,直接抛出异常
* *
* @author helei *
*/ */
protected function checkDataParam() protected function checkDataParam()
{ {
......
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei <dayugog@gmail.com> * <dayugog@gmail.com>
* Date: 2016/12/28 * Date: 2016/12/28
* Time: 20:24 * Time: 20:24
*/ */
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-22 17:02 * @createTime: 2016-07-22 17:02
* @description: * @description:
*/ */
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-15 17:28 * @createTime: 2016-07-15 17:28
* @description: 即时到帐 接口的数据处理类 * @description: 即时到帐 接口的数据处理类
* @link https://github.com/helei112g/payment/tree/paymentv2 * @link https://github.com/helei112g/payment/tree/paymentv2
...@@ -19,7 +19,7 @@ use Payment\Utils\ArrayUtil; ...@@ -19,7 +19,7 @@ use Payment\Utils\ArrayUtil;
* @property integer $qr_mod * @property integer $qr_mod
* *
* @package Payment\Charge\Ali\Data * @package Payment\Charge\Ali\Data
* anthor helei *
*/ */
class WebChargeData extends ChargeBaseData class WebChargeData extends ChargeBaseData
{ {
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2017-03-06 22:32 * @createTime: 2017-03-06 22:32
* @description: * @description:
*/ */
...@@ -17,13 +17,13 @@ use Payment\Utils\ArrayUtil; ...@@ -17,13 +17,13 @@ use Payment\Utils\ArrayUtil;
* @property string $out_trade_no 商户系统内部的订单号 * @property string $out_trade_no 商户系统内部的订单号
* *
* @package Payment\Common\Ali\Data\Query * @package Payment\Common\Ali\Data\Query
* anthor helei *
*/ */
class ChargeQueryData extends QueryBaseData class ChargeQueryData extends QueryBaseData
{ {
/** /**
* 检查参数 * 检查参数
* @author helei *
*/ */
protected function checkDataParam() protected function checkDataParam()
{ {
......
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/3/6 * Date: 2017/3/6
* Time: 下午10:37 * Time: 下午10:37
*/ */
...@@ -16,7 +16,7 @@ abstract class QueryBaseData extends AliBaseData ...@@ -16,7 +16,7 @@ abstract class QueryBaseData extends AliBaseData
{ {
/** /**
* 构建 APP支付 加密数据 * 构建 APP支付 加密数据
* @author helei *
*/ */
protected function buildData() protected function buildData()
{ {
......
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/3/7 * Date: 2017/3/7
* Time: 下午1:45 * Time: 下午1:45
*/ */
......
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/3/7 * Date: 2017/3/7
* Time: 下午3:59 * Time: 下午3:59
*/ */
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-26 18:18 * @createTime: 2016-07-26 18:18
* @description: * @description:
*/ */
...@@ -23,14 +23,14 @@ use Payment\Utils\ArrayUtil; ...@@ -23,14 +23,14 @@ use Payment\Utils\ArrayUtil;
* @property string $store_id 商户门店编号 * @property string $store_id 商户门店编号
* *
* @package Payment\Common\Ali\Data * @package Payment\Common\Ali\Data
* anthor helei *
*/ */
class RefundData extends AliBaseData class RefundData extends AliBaseData
{ {
/** /**
* 检查退款数据是否正常 * 检查退款数据是否正常
* @author helei *
*/ */
protected function checkDataParam() protected function checkDataParam()
{ {
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-27 13:05 * @createTime: 2016-07-27 13:05
* @description: * @description:
*/ */
...@@ -27,13 +27,13 @@ use Payment\Utils\ArrayUtil; ...@@ -27,13 +27,13 @@ use Payment\Utils\ArrayUtil;
* @property string $remark 转账备注 当付款方为企业账户,且转账金额达到(大于等于)50000元,remark不能为空 * @property string $remark 转账备注 当付款方为企业账户,且转账金额达到(大于等于)50000元,remark不能为空
* *
* @package Payment\Common\Ali\Data * @package Payment\Common\Ali\Data
* anthor helei *
*/ */
class TransData extends AliBaseData class TransData extends AliBaseData
{ {
/** /**
* 检查参数是否合法 * 检查参数是否合法
* @author helei *
*/ */
protected function checkDataParam() protected function checkDataParam()
{ {
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-15 14:56 * @createTime: 2016-07-15 14:56
* @description: 支付宝配置文件 所有支付的配置文件,均需要继承 ConfigInterface 这个接口 * @description: 支付宝配置文件 所有支付的配置文件,均需要继承 ConfigInterface 这个接口
* @link https://github.com/helei112g/payment/tree/paymentv2 * @link https://github.com/helei112g/payment/tree/paymentv2
...@@ -94,7 +94,7 @@ final class AliConfig extends ConfigInterface ...@@ -94,7 +94,7 @@ final class AliConfig extends ConfigInterface
* 检查传入的配置文件信息是否正确 * 检查传入的配置文件信息是否正确
* @param array $config * @param array $config
* @throws PayException * @throws PayException
* @author helei *
*/ */
private function initConfig(array $config) private function initConfig(array $config)
{ {
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-28 18:05
* @description: 支付相关接口的数据基类 * @description: 支付相关接口的数据基类
*/ */
...@@ -13,12 +13,7 @@ use Payment\Utils\ArrayUtil; ...@@ -13,12 +13,7 @@ use Payment\Utils\ArrayUtil;
/** /**
* Class BaseData * Class BaseData
* 支付相关接口的数据基类 * 支付相关接口的数据基类
* @package Payment\Common\Weixin\Dataa * @package Payment\Common\Sw\Data
*
* @property string $limitPay 用户不可用指定渠道支付
* @property boolean $returnRaw 是否返回原始数据,只进行签名检查
* @property string $useSandbox 是否使用的测试模式
* @property string $signType 签名算法
* *
*/ */
abstract class BaseData abstract class BaseData
...@@ -60,6 +55,8 @@ abstract class BaseData ...@@ -60,6 +55,8 @@ abstract class BaseData
$this->channel = Config::TL_PAY; $this->channel = Config::TL_PAY;
} elseif ($config instanceof MiConfig) { } elseif ($config instanceof MiConfig) {
$this->channel = Config::MI_PAY; $this->channel = Config::MI_PAY;
}elseif ($config instanceof SwConfig) {
$this->channel = Config::SW_PAY;
} }
$this->data = array_merge($config->toArray(), $reqData);//配置信息合并 $this->data = array_merge($config->toArray(), $reqData);//配置信息合并
...@@ -76,7 +73,7 @@ abstract class BaseData ...@@ -76,7 +73,7 @@ abstract class BaseData
* 获取变量,通过魔术方法 * 获取变量,通过魔术方法
* @param string $name * @param string $name
* @return null|string * @return null|string
* @author helei *
*/ */
public function __get($name) public function __get($name)
{ {
...@@ -91,7 +88,7 @@ abstract class BaseData ...@@ -91,7 +88,7 @@ abstract class BaseData
* 设置变量 * 设置变量
* @param $name * @param $name
* @param $value * @param $value
* @author helei *
*/ */
public function __set($name, $value) public function __set($name, $value)
{ {
...@@ -100,7 +97,7 @@ abstract class BaseData ...@@ -100,7 +97,7 @@ abstract class BaseData
/** /**
* 设置签名 * 设置签名
* @author helei *
*/ */
public function setSign() public function setSign()
{ {
...@@ -128,7 +125,15 @@ abstract class BaseData ...@@ -128,7 +125,15 @@ abstract class BaseData
$this->cacertPath = "{$basePath}mipay".DIRECTORY_SEPARATOR."ldy_private_key.pem"; $this->cacertPath = "{$basePath}mipay".DIRECTORY_SEPARATOR."ldy_private_key.pem";
$this->retData['sign'] = ArrayUtil::SignRSA($data,$this->cacertPath);//签名 $this->retData['sign'] = ArrayUtil::SignRSA($data,$this->cacertPath);//签名
} else{ } else if($this->channel === Config::SW_PAY){
//添加令牌,参数由makesign函数自由控制
$values = ArrayUtil::removeKeys($data, ['key_sign']);
$values = ArrayUtil::arraySort($values);
$signStr = ArrayUtil::createLinkstring($values);
$this->makeSign($signStr);
}else{
$values = ArrayUtil::removeKeys($data, ['sign']); $values = ArrayUtil::removeKeys($data, ['sign']);
$values = ArrayUtil::arraySort($values); $values = ArrayUtil::arraySort($values);
$signStr = ArrayUtil::createLinkstring($values); $signStr = ArrayUtil::createLinkstring($values);
...@@ -139,7 +144,7 @@ abstract class BaseData ...@@ -139,7 +144,7 @@ abstract class BaseData
/** /**
* 返回处理之后的数据 * 返回处理之后的数据
* @return array * @return array
* @author helei *
*/ */
public function getData() public function getData()
{ {
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-28 16:45 * @createTime: 2016-07-28 16:45
* @description: 所有的策略类接口 * @description: 所有的策略类接口
*/ */
...@@ -13,14 +13,14 @@ interface BaseStrategy ...@@ -13,14 +13,14 @@ interface BaseStrategy
* 处理具体的业务 * 处理具体的业务
* @param array $data * @param array $data
* @return mixed * @return mixed
* @author helei *
*/ */
public function handle(array $data); public function handle(array $data);
/** /**
* 获取支付对应的数据完成类 * 获取支付对应的数据完成类
* @return BaseData * @return BaseData
* @author helei *
*/ */
public function getBuildDataClass(); public function getBuildDataClass();
} }
...@@ -11,7 +11,7 @@ use Payment\Utils\Curl; ...@@ -11,7 +11,7 @@ use Payment\Utils\Curl;
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/27 * Date: 2017/4/27
* Time: 下午12:36 * Time: 下午12:36
*/ */
...@@ -73,7 +73,7 @@ abstract class CmbBaseStrategy implements BaseStrategy ...@@ -73,7 +73,7 @@ abstract class CmbBaseStrategy implements BaseStrategy
* 处理微信的返回值并返回给客户端 * 处理微信的返回值并返回给客户端
* @param array $ret * @param array $ret
* @return mixed * @return mixed
* @author helei *
*/ */
protected function retData(array $ret) protected function retData(array $ret)
{ {
...@@ -92,7 +92,7 @@ abstract class CmbBaseStrategy implements BaseStrategy ...@@ -92,7 +92,7 @@ abstract class CmbBaseStrategy implements BaseStrategy
* @param string $json * @param string $json
* @return mixed * @return mixed
* @throws PayException * @throws PayException
* @author helei *
*/ */
protected function sendReq($json) protected function sendReq($json)
{ {
...@@ -116,7 +116,7 @@ abstract class CmbBaseStrategy implements BaseStrategy ...@@ -116,7 +116,7 @@ abstract class CmbBaseStrategy implements BaseStrategy
* @param string $json * @param string $json
* @param string $url * @param string $url
* @return array * @return array
* @author helei *
*/ */
protected function curlPost($json, $url) protected function curlPost($json, $url)
{ {
...@@ -130,7 +130,7 @@ abstract class CmbBaseStrategy implements BaseStrategy ...@@ -130,7 +130,7 @@ abstract class CmbBaseStrategy implements BaseStrategy
* 返回统一的交易状态 做一些转化,方便处理 * 返回统一的交易状态 做一些转化,方便处理
* @param $status * @param $status
* @return string * @return string
* @author helei *
*/ */
protected function getTradeStatus($status) protected function getTradeStatus($status)
{ {
......
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/28 * Date: 2017/4/28
* Time: 上午10:48 * Time: 上午10:48
*/ */
......
...@@ -9,7 +9,7 @@ use Payment\Config; ...@@ -9,7 +9,7 @@ use Payment\Config;
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/27 * Date: 2017/4/27
* Time: 下午1:01 * Time: 下午1:01
* *
......
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/27 * Date: 2017/4/27
* Time: 下午1:00 * Time: 下午1:00
*/ */
......
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/29 * Date: 2017/4/29
* Time: 上午9:52 * Time: 上午9:52
*/ */
......
...@@ -6,7 +6,7 @@ use Payment\Common\PayException; ...@@ -6,7 +6,7 @@ use Payment\Common\PayException;
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/28 * Date: 2017/4/28
* Time: 下午12:52 * Time: 下午12:52
* *
......
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/28 * Date: 2017/4/28
* Time: 下午5:23 * Time: 下午5:23
*/ */
......
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/28 * Date: 2017/4/28
* Time: 下午3:16 * Time: 下午3:16
*/ */
......
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/27 * Date: 2017/4/27
* Time: 上午11:28 * Time: 上午11:28
*/ */
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-15 17:42 * @createTime: 2016-07-15 17:42
* @description: 配置文件接口,主要提供返回属性数组的功能 * @description: 配置文件接口,主要提供返回属性数组的功能
* @link https://github.com/helei112g/payment/tree/paymentv2 * @link https://github.com/helei112g/payment/tree/paymentv2
......
...@@ -53,7 +53,7 @@ abstract class MiBaseStrategy implements BaseStrategy{ ...@@ -53,7 +53,7 @@ abstract class MiBaseStrategy implements BaseStrategy{
* @param array $body * @param array $body
* @return mixed * @return mixed
* @throws PayException * @throws PayException
* @author helei *
*/ */
protected function sendReq($body) protected function sendReq($body)
{ {
...@@ -90,7 +90,7 @@ abstract class MiBaseStrategy implements BaseStrategy{ ...@@ -90,7 +90,7 @@ abstract class MiBaseStrategy implements BaseStrategy{
* @param array $body * @param array $body
* @param string $url * @param string $url
* @return mixed * @return mixed
* @author helei *
*/ */
protected function curlPost($body, $url) protected function curlPost($body, $url)
{ {
...@@ -106,7 +106,7 @@ abstract class MiBaseStrategy implements BaseStrategy{ ...@@ -106,7 +106,7 @@ abstract class MiBaseStrategy implements BaseStrategy{
/** /**
* 获取需要的url 默认返回下单的url * 获取需要的url 默认返回下单的url
* @author helei *
* @return string|null * @return string|null
*/ */
protected function getReqUrl() protected function getReqUrl()
...@@ -116,7 +116,7 @@ abstract class MiBaseStrategy implements BaseStrategy{ ...@@ -116,7 +116,7 @@ abstract class MiBaseStrategy implements BaseStrategy{
/** /**
* @param array $data * @param array $data
* @author helei *
* @throws PayException * @throws PayException
* @return array|string * @return array|string
*/ */
...@@ -150,7 +150,7 @@ abstract class MiBaseStrategy implements BaseStrategy{ ...@@ -150,7 +150,7 @@ abstract class MiBaseStrategy implements BaseStrategy{
* 处理支付平台的返回值并返回给客户端 * 处理支付平台的返回值并返回给客户端
* @param array $ret * @param array $ret
* @return mixed * @return mixed
* @author helei *
*/ */
protected function retData(array $ret) protected function retData(array $ret)
{ {
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-14 18:02 * @createTime: 2016-07-14 18:02
* @description: 统一的异常处理类 * @description: 统一的异常处理类
* @link https://github.com/helei112g/payment/tree/paymentv2 * @link https://github.com/helei112g/payment/tree/paymentv2
...@@ -14,7 +14,7 @@ class PayException extends \Exception ...@@ -14,7 +14,7 @@ class PayException extends \Exception
/** /**
* 获取异常错误信息 * 获取异常错误信息
* @return string * @return string
* @author helei *
*/ */
public function errorMessage() public function errorMessage()
{ {
......
<?php
namespace Payment\Common\Sw\Data;
/**
* Class BackBarChargeData
*
* 刷卡(条码)支付,数据回调处理
*
* @package Payment\Common\Sw\Data
*
*/
class BackBarChargeData extends SwBaseData
{
protected function buildData(){
$this->retData['package'] = [
'channel_trade_no' => $this->channel_trade_no??'',//通道订单号,微信订单号、支付宝订单号等,返回时不参与签名
'channel_order_no' => $this->channel_order_no??'',//银行渠道订单号,微信支付时显示在支付成功页面的条码,可用作扫码查询和扫码退款时匹配
'user_id' => $this->user_id,//付款方用户id,“微信openid”、“支付宝账户”、“qq号”等,返回时不参与签名
];
$this->retData['other'] = [
'pay_type' => $this->pay_type,//010微信,020 支付宝,060qq钱包,080京东钱包,090口碑,100翼支付,110银联二维码
'merchant_name' => $this->merchant_name,
'merchant_no' => $this->merchant_no,
'terminal_id' => $this->terminal_id,
'terminal_trace'=> $this->terminal_trace,
'terminal_time' => $this->terminal_time,
'total_fee' => $this->total_fee,
'end_time' => $this->end_time??'',//支付完成时间,yyyyMMddHHmmss,全局统一时间格式
'out_trade_no' => $this->out_trade_no,
'attach' => $this->attach??'',//附加数据,原样返回
];
if($this->pay_type == '090'){//口碑实收金额,pay_type为090时必填
$this->retData['package']['receipt_fee'] = $this->receipt_fee;
}
}
protected function checkDataParam()
{
// 对于返回数据不做检查检查
}
}
<?php
namespace Payment\Common\Sw\Data;
/**
* Class BackFaceChargeData
*
*
* @package Payment\Common\Sw\Data
*
*/
class BackFaceChargeData extends SwBaseData
{
protected function buildData()
{
$this->retData['package'] = [
'channel_trade_no' => $this->channel_trade_no??'',//通道订单号,微信订单号、支付宝订单号等,返回时不参与签名
'channel_order_no' => $this->channel_order_no??'',//银行渠道订单号,微信支付时显示在支付成功页面的条码,可用作扫
];
$this->retData['other'] = [
'pay_type' => $this->pay_type,
'merchant_name' => $this->merchant_name,
'merchant_no' => $this->merchant_no,
'terminal_id' => $this->terminal_id,
'terminal_trace'=> $this->terminal_trace,
'terminal_time' => $this->terminal_time,
'total_fee' => $this->total_fee,
'out_trade_no' => $this->out_trade_no??'',//订单号
'end_time' => $this->end_time??'',
'order_body' => $this->order_body??'',
'attach' => $this->attach??'',
];
}
protected function checkDataParam()
{
// 对于返回数据不做检查检查
}
}
<?php
namespace Payment\Common\Sw\Data;
/**
* Class BackFaceInfoData
*
*
* @package Payment\Common\Sw\Data
*
*/
class BackFaceInfoData extends SwBaseData
{
protected function buildData()
{
$this->retData['package'] = [
'authinfo' => $this->authinfo??'',//微信、支付宝人脸识别SDK调用凭证
'channel_order_no' => $this->channel_order_no??'',//银行渠道订单号,微信支付时显示在支付成功页面的条码,可用作扫
];
$this->retData['other'] = [
'pay_type' => $this->pay_type,
'merchant_no' => $this->merchant_no,
'terminal_id' => $this->terminal_no,
'terminal_trace'=> $this->trace_no,
'terminal_time' => $this->terminal_time,
];
if($this->pay_type == '010'){ //微信人脸识别返回有效时间,单位:秒
$this->retData['package']['expires_in'] = $this->expires_in;
}
if($this->pay_type == '020'){ //支付宝ZimInitClientData
$this->retData['package']['zim_init'] = $this->zim_init;
}
}
protected function checkDataParam()
{
// 对于返回数据不做检查检查
}
}
<?php
namespace Payment\Common\Sw\Data;
use Payment\Common\PayException;
/**
* Class BackLiteChargeData
*
*
* @package Payment\Common\Sw\Data
*
*/
class BackLiteChargeData extends SwBaseData
{
protected function buildData()
{
$data = [];
switch ($this->pay_type){
case '010':{ //微信
$data = [
'appId' => $this->appId,
'timeStamp' => $this->timeStamp,//time() . '',
'nonceStr' => $this->nonceStr,
'package' => $this->package_str,
'signType' => $this->signType,// 签名算法,暂支持MD5
];
break;
}
case '020':{ //支付宝
$data = [
'ali_trade_no' => $this->ali_trade_no,
];
break;
}
default:{
throw new PayException('未知的官方支付方式');
break;
}
}
$this->retData['jspackage'] = $data;
$this->retData['other'] = [
'pay_type' => $this->pay_type,
'merchant_name' => $this->merchant_name,
'merchant_no' => $this->merchant_no,
'terminal_id' => $this->terminal_id,
'terminal_trace'=> $this->terminal_trace,
'terminal_time' => $this->terminal_time,
'total_fee' => $this->total_fee,
'out_trade_no' => $this->out_trade_no
];
}
protected function checkDataParam()
{
// 对于返回数据不做检查检查
}
}
<?php
namespace Payment\Common\Sw\Data;
/**
* Class BackPubChargeData
* 小程序数据也在这里处理
* @property string $device_info 设备号
* @property string $trade_type 交易类型
* @property string $prepay_id 预支付交易会话标识
*
* @package Payment\Common\Sw\Data
*
*/
class BackPubChargeData extends SwBaseData
{
protected function buildData()
{
$data = [];
switch ($this->pay_type){
case '010':{ //微信
$data = [
'appId' => $this->appId,
'timeStamp' => time() . '',
'nonceStr' => $this->nonceStr,
'package' => $this->package_str,
'signType' => $this->signType,// 签名算法,暂支持MD5
];
break;
}
case '020':{ //支付宝
$data = [
'ali_trade_no' => $this->ali_trade_no,
];
break;
}
case '060':{
$data = [
'token_id' => $this->token_id,
];
break;
}
}
$this->retData['jspackage'] = $data;
$this->retData['other'] = [
'out_trade_no' => $this->out_trade_no
];
}
protected function checkDataParam()
{
// 不进行检查
}
}
<?php
namespace Payment\Common\Sw\Data;
/**
* Class BackRefundData
*
*
* @package Payment\Common\Sw\Data
*
*/
class BackRefundData extends SwBaseData
{
protected function buildData()
{
$this->retData['package'] =[
'refund_fee' => $this->refund_fee,//退款金额,单位分
'end_time' => $this->end_time,//退款完成时间,yyyyMMddHHmmss,全局统一时间格式
'out_refund_no' => $this->out_refund_no,//利楚唯一退款单号
];
$this->retData['other'] = [
'pay_type' => $this->pay_type,
'merchant_name' => $this->merchant_name,
'merchant_no' => $this->merchant_no,
'terminal_id' => $this->terminal_id,
'terminal_trace'=> $this->terminal_trace,
'terminal_time' => $this->terminal_time,
'out_trade_no' => $this->out_trade_no,
// 'refund_fee' => $this->refund_fee,//退款金额,单位分
];
}
protected function checkDataParam()
{
// 对于返回数据不做检查检查
}
}
<?php
namespace Payment\Common\Sw\Data;
use Payment\Common\PayException;
/**
* Class BackScanChargeData
*
*
* @package Payment\Common\Sw\Data
*
*/
class BackScanChargeData extends SwBaseData
{
protected function buildData()
{
$this->retData['qr_code'] = $this->qr_code;//二维码码串
$this->retData['other'] = [
'pay_type' => $this->pay_type,
'merchant_name' => $this->merchant_name,
'merchant_no' => $this->merchant_no,
'terminal_id' => $this->terminal_id,
'terminal_trace'=> $this->terminal_trace,
'terminal_time' => $this->terminal_time,
'total_fee' => $this->total_fee,
'out_trade_no' => $this->out_trade_no
];
}
protected function checkDataParam()
{
// 对于返回数据不做检查检查
}
}
<?php
namespace Payment\Common\Sw\Data;
use Payment\Common\PayException;
/**
* Class BackCancelData
*
*
* @package Payment\Common\Sw\Data
*
*/
class BackCancelData extends SwBaseData
{
protected function buildData()
{
$this->retData['package'] = [
'recall' => $this->recall,//是否重新发起撤销
];
$this->retData['other'] = [
'pay_type' => $this->pay_type,
'merchant_name' => $this->merchant_name??'',
'merchant_no' => $this->merchant_no??'',
'terminal_id' => $this->terminal_id??'',
'terminal_trace'=> $this->terminal_trace??'',
'terminal_time' => $this->terminal_time??'',
'total_fee' => $this->total_fee,
'out_trade_no' => $this->out_trade_no
];
}
protected function checkDataParam()
{
// 对于返回数据不做检查检查
}
}
<?php
namespace Payment\Common\Sw\Data;
/**
* Class BackCloseData
*
*
* @package Payment\Common\Sw\Data
*
*/
class BackCloseData extends SwBaseData
{
protected function buildData()
{
$this->retData['package'] = [
'result_code' => $this->result_code,//"业务结果,01成功,表示关单成功,此笔订单不能再发起支付;
];
$this->retData['other'] = [
'pay_type' => $this->pay_type,//010
'merchant_no' => $this->merchant_no??'',
'terminal_id' => $this->terminal_id??'',
'terminal_trace'=> $this->terminal_trace??'',
'terminal_time' => $this->terminal_time??'',
];
}
protected function checkDataParam()
{
// 对于返回数据不做检查检查
}
}
<?php
namespace Payment\Common\Sw\Data\Charge;
use Payment\Common\PayException;
use Payment\Utils\ArrayUtil;
/**
* Class CancelData
* 扫呗取消订单
*
*
* @package Payment\Common\Sw\Data\Charge
*
*/
class CancelData extends ChargeBaseData
{
protected function checkDataParam()
{
parent::checkDataParam();
$this->pay_ver = '100';
$this->service_id = '040';
}
protected function buildData(){
$signData = [
// 基本数据
'pay_ver' => trim($this->pay_ver),
'pay_type' => trim($this->pay_type),
'service_id' => $this->service_id,
'merchant_no' => $this->merchant_no,
'terminal_id' => $this->terminal_id,
'terminal_trace' => $this->terminal_trace,
'terminal_time' => $this->terminal_time,
'total_fee' => $this->total_fee, // 金额,单位分
];
if(isset($this->out_trade_no)){
$signData['out_trade_no'] = $this->out_trade_no;
}
if(isset($this->pay_trace)){
$signData['pay_trace'] = $this->pay_trace;
}
if(isset($this->pay_time)){
$signData['pay_time'] = $this->pay_time;
}
// 移除数组中的空值
$this->retData = ArrayUtil::paraFilter($signData);
}
}
<?php
namespace Payment\Common\Sw\Data\Charge;
use Payment\Utils\ArrayUtil;
/**
* Class CloseData
* 扫呗关闭订单
*
*
* @package Payment\Common\Sw\Data\Charge
*
*/
class CloseData extends ChargeBaseData
{
protected function checkDataParam()
{
parent::checkDataParam();
$this->pay_ver = '100';
$this->service_id = '041';
}
protected function buildData(){
$signData = [
// 基本数据
'pay_ver' => trim($this->pay_ver),
'pay_type' => trim($this->pay_type),//010微信,020支付宝,000自动识别类型
'service_id' => $this->service_id,
'merchant_no' => $this->merchant_no,
'terminal_id' => $this->terminal_id,
'terminal_trace' => $this->terminal_trace,//终端流水号(socket协议:长度为6位,Http协议:长度为32位)
'terminal_time' => $this->terminal_time,
];
if(isset($this->out_trade_no) && !empty($this->out_trade_no)){
//利楚唯一订单号,优先使用订单号out_trade_no发起撤销,
//在out_trade_no获取异常的情况,可使用当前支付请求的终端交易流水号pay_trace和终端交易时间pay_time发起撤销
$signData['out_trade_no'] = $this->out_trade_no;
}
if(isset($this->pay_trace)){//当前支付终端流水号
$signData['pay_trace'] = $this->pay_trace;
}
if(isset($this->pay_time)){//当前支付终端交易时间
$signData['pay_time'] = $this->pay_time;
}
// 移除数组中的空值
$this->retData = ArrayUtil::paraFilter($signData);
}
}
<?php
namespace Payment\Common\Sw\Data\Charge;
use Payment\Common\PayException;
use Payment\Utils\ArrayUtil;
/**
* Class BarChargeData
*
* @inheritdoc
* @property string $auth_code 扫码支付授权码,设备读取用户微信/支付宝等中的条码或者二维码信息
*
* @package Payment\Common\Sw\Data\Charge
*/
class BarChargeData extends ChargeBaseData
{
protected function checkDataParam()
{
parent::checkDataParam();
if(!isset($this->auth_no) || empty($this->auth_no)){
throw new PayException('授权码,客户的付款码不能为空');
}
$payType = $this->pay_type;//010微信,020 支付宝,060qq钱包,080京东钱包,090口碑,100翼支付,110银联二维码,000自动识别类型
if ($payType == '010') {
if(empty($this->sub_appid))
throw new PayException('公众号appid,支付时使用的appid');
}
$this->service_id = '010';
}
/**
* 生成下单的数据
*/
protected function buildData()
{
$signData = [
// 基本数据
'pay_ver' => trim($this->pay_ver),
'pay_type' => trim($this->pay_type),
'service_id' => $this->service_id,
'merchant_no' => $this->merchant_no,
'terminal_id' => $this->terminal_id,
'terminal_trace' => $this->terminal_trace,
'terminal_time' => $this->terminal_time,
'total_fee' => $this->total_fee, // 金额,单位分
'auth_no' =>$this->auth_no,//授权码,客户的付款码
];
if(isset($this->sub_appid)){
$signData['sub_appid'] = $this->sub_appid;
}
if(isset($this->open_id)){
$signData['open_id'] = $this->open_id;
}
if(isset($this->order_body)){
$signData['order_body'] = $this->order_body;
}
if(isset($this->notify_url)){
$signData['notify_url'] = $this->notify_url;
}
if(isset($this->attach)){
$signData['attach'] = $this->attach;
}
if(isset($this->goods_detail)){
$signData['goods_detail'] = $this->goods_detail;
//goods_Id String N 商品编号
//goods_name String N 商品名称
//quantity String N 商品数量
//price String N 商品单价,单位为分
}
if(isset($this->goods_tag)){ //订单优惠标记,代金券或立减优惠功能的参数(字段值:cs和bld)
$signData['goods_tag'] = $this->goods_tag;
}
// 移除数组中的空值
$this->retData = ArrayUtil::paraFilter($signData);
}
}
<?php
namespace Payment\Common\Sw\Data\Charge;
use Payment\Common\PayException;
use Payment\Common\Sw\Data\SwBaseData;
use Payment\Config;
/**
* Class ChargeBaseData
*
*
* @package Payment\Common\Sw\Data\Charge
*/
abstract class ChargeBaseData extends SwBaseData
{
/**
* 检查传入的支付信息是否正确
*/
protected function checkDataParam()
{
// 检查订单号是否合法
if (empty($this->terminal_trace) || mb_strlen($this->terminal_trace) > 32) {
throw new PayException('商户系统的订单号不能为空,并且长度不能超过32位');
}
// 检查金额不能低于0.01
if ($this->total_fee < 1) {
throw new PayException('支付金额不能低于 ' . Config::PAY_MIN_FEE . ' 元');
}
// 检查 商品名称 与 商品描述
if (empty($this->terminal_id) || empty($this->merchant_no)) {
throw new PayException('必须提供终端号与商户号');
}
}
}
<?php
namespace Payment\Common\Sw\Data\Charge;
use Payment\Common\PayException;
use Payment\Utils\ArrayUtil;
/**
* Class FaceChargeData
* 扫呗自主收银(人脸)
*
*
* @package Payment\Common\Sw\Data\Charge
*
*/
class FaceChargeData extends ChargeBaseData
{
protected function checkDataParam()
{
parent::checkDataParam(); // TODO: Change the autogenerated stub
$payType = $this->pay_type; //010微信,020支付宝
if (($payType == '010' || $payType == '020')) {
if(empty($this->auth_no))
throw new PayException('人脸识别SDK调用凭证auth_no,必须参数');
if($payType == '010' && empty($this->open_id)){
throw new PayException('用户标识(微信openid),需要传入');
}
}
$this->pay_ver = '110';
$this->service_id = '015';
}
protected function buildData()
{
$signData = [
// 基本数据
'pay_ver' => trim($this->pay_ver),
'pay_type' => trim($this->pay_type),
'service_id' => $this->service_id,
'merchant_no' => $this->merchant_no,
'terminal_id' => $this->terminal_id,
'terminal_trace'=> $this->terminal_trace,
'terminal_time' => $this->terminal_time,
'total_fee' => $this->total_fee, // 金额,单位分
'auth_no' =>$this->auth_no,
];
if(isset($this->out_trade_no)){//利楚订单号,来自自助收银SDK调用凭证获取接口,仅微信刷脸支付必传。
$signData['out_trade_no'] = $this->out_trade_no;
}
if(isset($this->open_id)){//用户标识(微信openid),用于调起微信刷脸SDK
$signData['open_id'] = $this->open_id;
}
if(isset($this->order_body)){
$signData['order_body'] = $this->order_body;
}
if(isset($this->attach)){
$signData['attach'] = $this->attach;
}
// 移除数组中的空值
$this->retData = ArrayUtil::paraFilter($signData);
}
}
<?php
namespace Payment\Common\Sw\Data\Charge;
use Payment\Common\PayException;
use Payment\Utils\ArrayUtil;
/**
* Class FaceInfoData
* 自助收银SDK调用凭证获取接口
*
*
* @package Payment\Common\Sw\Data\Charge
*
*/
class FaceInfoData extends ChargeBaseData
{
protected function checkDataParam()
{
parent::checkDataParam();
$payType = $this->pay_type; //010微信,020支付宝
if($payType!='010' || $payType!='020'){
throw new PayException('暂不支持微信、支付宝以外的人脸识别SDK初始化');
}
if(!isset($this->rawdata) || empty($this->rawdata))
throw new PayException('微信、支付宝人脸识别SDK初始化数据不能为空');
$this->pay_ver = '110';
}
protected function buildData()
{
$signData = [
// 基本数据
'pay_ver' => trim($this->pay_ver),
'pay_type' => trim($this->pay_type),
'merchant_no' => $this->merchant_no,
'terminal_no' => $this->terminal_id,
'trace_no' => $this->terminal_trace,//终端流水号,填写商户系统的订单号
'terminal_time' => $this->terminal_time,
'rawdata' => $this->rawdata, //微信、支付宝人脸识别SDK初始化数据
];
// 移除数组中的空值
$this->retData = ArrayUtil::paraFilter($signData);
}
}
<?php
namespace Payment\Common\Sw\Data\Charge;
use Payment\Common\PayException;
use Payment\Utils\ArrayUtil;
/**
* Class LiteChargeData
* 扫呗微信小程序支付
*
*
* @package Payment\Common\Sw\Data\Charge
*
*/
class LiteChargeData extends ChargeBaseData
{
protected function checkDataParam()
{
parent::checkDataParam(); // TODO: Change the autogenerated stub
// 公众号支付,必须设置openid
$payType = $this->pay_type;//010微信,020支付宝,060qq钱包,090口碑,100翼支付
if (($payType == '010' || $payType == '020')) {
if(empty($this->sub_appid))
throw new PayException('小程序appid,小程序支付时使用的appid(若传入,则open_id需要保持一致)');
if($payType == '010' && empty($this->open_id)){
throw new PayException('用户标识(微信openid),需要传入,通过微信官方接口获得');
}
}
$this->service_id = '015';
}
protected function buildData()
{
$signData = [
// 基本数据
'pay_ver' => trim($this->pay_ver),
'pay_type' => trim($this->pay_type),
'service_id' => $this->service_id,
'merchant_no' => $this->merchant_no,
'terminal_id' => $this->terminal_id,
'terminal_trace' => $this->terminal_trace,
'terminal_time' => $this->terminal_time,
'total_fee' => $this->total_fee, // 金额,单位分
// 'time_expire' => $this->timeout_express,
];
if(isset($this->sub_appid)){
$signData['sub_appid'] = $this->sub_appid;
}
if(isset($this->open_id)){
$signData['open_id'] = $this->open_id;
}
if(isset($this->order_body)){
$signData['order_body'] = $this->order_body;
}
if(isset($this->notify_url)){
$signData['notify_url'] = $this->notify_url;
}
if(isset($this->attach)){
$signData['attach'] = $this->attach;
}
// 移除数组中的空值
$this->retData = ArrayUtil::paraFilter($signData);
}
}
<?php
/**
* Created by PhpStorm.
*
* Date: 16/7/31
* Time: 上午9:20
*/
namespace Payment\Common\Sw\Data\Charge;
use Payment\Common\PayException;
use Payment\Utils\ArrayUtil;
/**
* Class PubChargeData
* 扫呗微信公众号支付
*
*
* @package Payment\Common\Sw\Data\Charge
*
*/
class PubChargeData extends ChargeBaseData
{
protected function checkDataParam()
{
parent::checkDataParam(); // TODO: Change the autogenerated stub
// 公众号支付,必须设置openid
$payType = $this->pay_type;//010微信,020支付宝,060qq钱包,090口碑,100翼支付
if (($payType == '010' || $payType == '020')) {
if(empty($this->openid))
throw new PayException('用户在商户appid下的唯一标识,用户标识(微信openid,支付宝userid),pay_type为010及020时需要传入.');
}
$this->service_id = '012';
}
protected function buildData()
{
$signData = [
// 基本数据
'pay_ver' => trim($this->pay_ver),
'pay_type' => trim($this->pay_type),
'service_id' => $this->service_id,
'merchant_no' => $this->merchant_no,
'terminal_id' => $this->terminal_id,
'terminal_trace' => $this->terminal_trace,
'terminal_time' => $this->terminal_time,
'total_fee' => $this->total_fee, // 金额,单位分
// 'time_expire' => $this->timeout_express,
];
if(isset($this->sub_appid)){
$signData['sub_appid'] = $this->sub_appid;
}
if(isset($this->open_id)){
$signData['open_id'] = $this->open_id;
}
if(isset($this->order_body)){
$signData['order_body'] = $this->order_body;
}
if(isset($this->notify_url)){
$signData['notify_url'] = $this->notify_url;
}
if(isset($this->attach)){
$signData['attach'] = $this->attach;
}
if(isset($this->goods_detail)){
$signData['goods_detail'] = $this->goods_detail;
//goods_Id String N 商品编号
//goods_name String N 商品名称
//quantity String N 商品数量
//price String N 商品单价,单位为分
}
// 移除数组中的空值
$this->retData = ArrayUtil::paraFilter($signData);
}
}
<?php
namespace Payment\Common\Sw\Data\Charge;
use Payment\Common\PayException;
use Payment\Utils\ArrayUtil;
/**
* Class ScanChargeData
*
* @inheritdoc
* @property string $auth_code 扫码支付授权码,设备读取用户微信中的条码或者二维码信息
*
* @package Payment\Common\Sw\Data\Charge
*/
class ScanChargeData extends ChargeBaseData
{
protected function checkDataParam()
{
parent::checkDataParam(); // TODO: Change the autogenerated stub
// 公众号支付,必须设置openid
$payType = $this->pay_type;//010微信,020支付宝,060qq钱包,090口碑,100翼支付
if ($payType == '010') {
if(empty($this->sub_appid))
throw new PayException('公众号appid,支付时使用的appid');
}
$this->service_id = '011';
}
/**
* 生成下单的数据
*/
protected function buildData()
{
$signData = [
// 基本数据
'pay_ver' => trim($this->pay_ver),
'pay_type' => trim($this->pay_type),
'service_id' => $this->service_id,
'merchant_no' => $this->merchant_no,
'terminal_id' => $this->terminal_id,
'terminal_trace' => $this->terminal_trace,
'terminal_time' => $this->terminal_time,
'total_fee' => $this->total_fee, // 金额,单位分
// 'time_expire' => $this->timeout_express,
];
if(isset($this->sub_appid)){
$signData['sub_appid'] = $this->sub_appid;
}
if(isset($this->open_id)){
$signData['open_id'] = $this->open_id;
}
if(isset($this->order_body)){
$signData['order_body'] = $this->order_body;
}
if(isset($this->notify_url)){
$signData['notify_url'] = $this->notify_url;
}
if(isset($this->attach)){
$signData['attach'] = $this->attach;
}
if(isset($this->goods_detail)){
$signData['goods_detail'] = $this->goods_detail;
//goods_Id String N 商品编号
//goods_name String N 商品名称
//quantity String N 商品数量
//price String N 商品单价,单位为分
}
// 移除数组中的空值
$this->retData = ArrayUtil::paraFilter($signData);
}
}
<?php
/**
* Created by PhpStorm.
*
* Date: 2017/3/6
* Time: 下午5:45
*/
namespace Payment\Common\Weixin\Data\Charge;
use Payment\Common\PayException;
use Payment\Utils\ArrayUtil;
/**
* 构建wap支付的下单数据
* Class WapChargeData
*
* @property array $scene_info 该字段用于上报支付的场景信息
*
* @package Payment\Common\Weixin\Data\Charge
*/
class WapChargeData extends ChargeBaseData
{
protected function checkDataParam()
{
parent::checkDataParam(); // TODO: Change the autogenerated stub
$info = $this->scene_info;
if (! is_array($info) || empty($info)) {
throw new PayException('微信 H5 支付,必须提供该参数');
}
}
protected function buildData()
{
$info = $this->scene_info;
$sceneInfo['h5_info'] = $info;
$signData = [
// 基本数据
'appid' => trim($this->appId),
'mch_id' => trim($this->mchId),
'nonce_str' => $this->nonceStr,
'sign_type' => $this->signType,
'fee_type' => $this->feeType,
'notify_url' => $this->notifyUrl,
'trade_type' => $this->tradeType, //设置APP支付
'limit_pay' => $this->limitPay, // 指定不使用信用卡
// 业务数据
'device_info' => $this->terminal_id,
'body' => trim($this->subject),
//'detail' => json_encode($this->body, JSON_UNESCAPED_UNICODE);
'attach' => trim($this->return_param),
'out_trade_no' => trim($this->order_no),
'total_fee' => $this->amount,
'spbill_create_ip' => trim($this->client_ip),
'time_start' => $this->timeStart,
'time_expire' => $this->timeout_express,
'scene_info' => json_encode($sceneInfo),
];
// 移除数组中的空值
$this->retData = ArrayUtil::paraFilter($signData);
}
}
\ No newline at end of file
<?php
namespace Payment\Common\Sw\Data\Query;
use Payment\Common\Sw\Data\SwBaseData;
/**
* 查询交易的数据结构
* Class BackChargeQueryData
*
*
* @package Payment\Common\Sw\Data\Query
*/
class BackChargeQueryData extends SwBaseData
{
protected function buildData()
{
$this->retData['package'] = [
'trade_state' => $this->trade_state??'',//交易订单状态,SUCCESS支付成功,REFUND转入退款,NOTPAY未支付,CLOSED已关闭,USERPAYING用户支付中,REVOKED已撤销,NOPAY未支付支付超时,PAYERROR支付失败
'channel_order_no' => $this->channel_order_no??'',//银行渠道订单号,微信支付时显示在支付成功页面的条码,可用作扫码查询和扫码退款时匹配
'channel_trade_no' => $this->channel_trade_no??'',//通道订单号,微信订单号、支付宝订单号等,返回时不参与签名
'user_id' => $this->user_id,//付款方用户id,“微信openid”、“支付宝账户”、“qq号”等,返回时不参与签名
'pay_trace' => $this->pay_trace,//当前支付终端流水号
'pay_time' => $this->pay_time,//当前支付终端交易时间
'total_fee' => $this->total_fee,
'end_time' => $this->end_time??'',
];
$this->retData['other'] = [
'pay_type' => $this->pay_type,
'merchant_name' => $this->merchant_name,
'merchant_no' => $this->merchant_no,
'terminal_id' => $this->terminal_id,
'terminal_trace'=> $this->terminal_trace,
'terminal_time' => $this->terminal_time,
'total_fee' => $this->total_fee,
'end_time' => $this->end_time??'',
'out_trade_no' => $this->out_trade_no??'',//订单号
'order_body' => $this->order_body??'',
'attach' => $this->attach??'',
];
if($this->pay_type == '090'){//口碑实收金额,pay_type为090时必填
$this->retData['package']['receipt_fee'] = $this->receipt_fee;
}
}
protected function checkDataParam()
{
// 对于返回数据不做检查检查
}
}
\ No newline at end of file
<?php
namespace Payment\Common\Sw\Data\Query;
use Payment\Common\PayException;
use Payment\Common\Sw\Data\SwBaseData;
use Payment\Utils\ArrayUtil;
/**
* 查询交易的数据结构
* Class ChargeQueryData
*
*
* @package Payment\Common\Sw\Data\Query
*/
class ChargeQueryData extends SwBaseData
{
protected function checkDataParam()
{
parent::checkDataParam();
$this->pay_ver = '100';
$this->service_id = '020';
// 二者不能同时为空
if (empty($this->merchant_no) && empty($this->terminal_id)) {
throw new PayException('商户号、终端号都不能为空');
}
if (empty($this->terminal_trace) && empty($this->terminal_time)) {
throw new PayException('终端查询流水号、终端查询时间都不能为空');
}
if (empty($this->out_trade_no)) {//订单号,查询凭据,可填利楚订单号、微信订单号、支付宝订单号、银行卡订单号任意一个
throw new PayException('查询订单号不能为空(可填利楚订单号、微信订单号、支付宝订单号、银行卡订单号任意一个)');
}
}
protected function buildData(){
$signData = [
// 基本数据
'pay_ver' => trim($this->pay_ver),
'pay_type' => trim($this->pay_type),
'service_id' => $this->service_id,
'merchant_no' => $this->merchant_no,
'terminal_id' => $this->terminal_id,
'terminal_trace'=> $this->terminal_trace,//终端查询流水号,填写商户系统的查询流水号
'terminal_time' => $this->terminal_time,
'out_trade_no' => $this->out_trade_no, // 金额,单位分
];
if(isset($this->pay_trace)){//用户标识(微信openid),用于调起微信刷脸SDK
$signData['pay_trace'] = $this->pay_trace;
}
if(isset($this->pay_time)){
$signData['pay_time'] = $this->pay_time;
}
$this->retData = ArrayUtil::paraFilter($this->retData);
}
}
\ No newline at end of file
<?php
namespace Payment\Common\Sw\Data\Query;
use Payment\Common\PayException;
use Payment\Common\Sw\Data\SwBaseData;
use Payment\Utils\ArrayUtil;
/**
* 退款交易的数据结构
* Class RefundData
*
*
* @package Payment\Common\Sw\Data\Query
*/
class RefundData extends SwBaseData
{
protected function checkDataParam()
{
parent::checkDataParam();
$this->pay_ver = '100';
$this->service_id = '030';
// 二者不能同时为空
if (empty($this->merchant_no) && empty($this->terminal_id)) {
throw new PayException('商户号、终端号都不能为空');
}
if (empty($this->terminal_trace) && empty($this->terminal_time)) {
throw new PayException('终端退款流水号、终端退款时间都不能为空');
}
if (empty($this->out_trade_no)) {//订单号,查询凭据,订单号,查询凭据,利楚订单号、微信订单号、支付宝订单号任意一个
throw new PayException('订单号不能为空(订单号,查询凭据,利楚订单号、微信订单号、支付宝订单号任意一个)');
}
if (empty($this->refund_fee)) {//退款金额,单位分
throw new PayException('退款金额,不能为空');
}
}
protected function buildData(){
$signData = [
// 基本数据
'pay_ver' => trim($this->pay_ver),
'pay_type' => trim($this->pay_type),
'service_id' => $this->service_id,
'merchant_no' => $this->merchant_no,
'terminal_id' => $this->terminal_id,
'terminal_trace'=> $this->terminal_trace,//终端查询流水号,填写商户系统的查询流水号
'terminal_time' => $this->terminal_time,
'refund_fee' => $this->refund_fee,// 金额,单位分
'out_trade_no' => $this->out_trade_no,//订单号,查询凭据,利楚订单号、微信订单号、支付宝订单号任意一个
];
if(isset($this->pay_trace)){//当前支付终端流水号,与pay_time同时传递
$signData['pay_trace'] = $this->pay_trace;
}
if(isset($this->pay_time)){//当前支付终端交易时间,yyyyMMddHHmmss,全局统一时间格式,与pay_trace同时传递
$signData['pay_time'] = $this->pay_time;
}
if(isset($this->auth_code)){//短信或邮箱验证码
$signData['auth_code'] = $this->auth_code;
}
$this->retData = ArrayUtil::paraFilter($this->retData);
}
}
\ No newline at end of file
<?php
namespace Payment\Common\Sw\Data;
use Payment\Common\BaseData;
/**
* Class BaseData
*
* @property null|string signType
* @package Payment\Common\Sw\Data
*/
abstract class SwBaseData extends BaseData
{
/**
* 签名算法实现
* @param string $signStr
* @return string
*/
protected function makeSign($signStr)
{
switch ($this->signType) {
case 'MD5':
$signStr .= '&access_token=' . $this->access_token;
$sign = md5($signStr);
break;
default:
$sign = '';
}
$this->retData['key_sign'] = $sign;
return $sign;
}
}
<?php
/**
*
* @createTime: 2016-08-04 09:42
* @description:
*/
namespace Payment\Common\Weixin\Data;
use Payment\Common\PayException;
use Payment\Utils\ArrayUtil;
/**
* Class TransferData
*
* 微信当前也仅支持单笔付款,不支持批量
*
* @property string $trans_no 商户转账唯一订单号
* @property string $openid 商户appid下,某用户的openid
* @property string $check_name
* - NO_CHECK:不校验真实姓名
* - FORCE_CHECK:强校验真实姓名(未实名认证的用户会校验失败,无法转账)
* - OPTION_CHECK:针对已实名认证的用户才校验真实姓名(未实名认证用户不校验,可以转账成功)
*
* @property string $payer_real_name 收款用户真实姓名。
* @property string $amount 转账金额,单位:元。 只支持2位小数,小数点前最大支持13位,金额必须大于0。
* @property string $desc 企业付款操作说明信息。必填。
* @property string $client_ip 调用接口的机器Ip地址
*
* @package Payment\Common\Weixin\Data
*
*/
class TransferData extends WxBaseData
{
protected function buildData()
{
$this->retData = [
'mch_appid' => $this->appId,
'mchid' => $this->mchId,
'device_info' => $this->terminal_id,
'nonce_str' => $this->nonceStr,
'partner_trade_no' => $this->trans_no,
'openid' => $this->openid,
'check_name' => $this->check_name,
're_user_name' => $this->payer_real_name,
'amount' => $this->amount,// 此处需要处理单位为分
'desc' => $this->desc,
// $_SERVER["REMOTE_ADDR"] 获取客户端接口。此处获取php所在机器的ip 如果无法获取,则使用该ip
'spbill_create_ip' => $this->client_ip,
];
$this->retData = ArrayUtil::paraFilter($this->retData);
}
/**
* 检查相关参数是否设置
*
*/
protected function checkDataParam()
{
$openId = $this->openid;
$transNo = $this->trans_no;
$checkName = $this->check_name;
$realName = $this->payer_real_name;
$amount = $this->amount;
$clientIp = $this->client_ip;
if (empty($openId)) {
throw new PayException('商户appid下,某用户的openid 必须传入');
}
if (empty($transNo)) {
throw new PayException('商户订单号,需保持唯一性');
}
if ($checkName !== 'NO_CHECK' && empty($realName)) {
throw new PayException('请传入收款人真实姓名');
}
// 微信使用的单位位分.此处进行转化
$this->amount = bcmul($amount, 100, 0);
if (empty($amount) || $amount < 0) {
throw new PayException('转账金额错误');
}
if (empty($clientIp)) {
$this->client_ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1';
}
}
}
<?php
namespace Payment\Common\Sw;
use Payment\Common\BaseData;
use Payment\Common\BaseStrategy;
use Payment\Common\PayException;
use Payment\Common\SwConfig;
use Payment\Utils\ArrayUtil;
use Payment\Utils\Curl;
abstract class SwBaseStrategy implements BaseStrategy
{
protected $config;
/**
* 支付数据
* @var BaseData $reqData
*/
protected $reqData;
/**
* SwBaseStrategy constructor.
* @param array $config
* @throws PayException
*/
public function __construct(array $config)
{
/* 设置内部字符编码为 UTF-8 */
mb_internal_encoding("UTF-8");
try {
$this->config = new SwConfig($config);
} catch (PayException $e) {
throw $e;
}
}
/**
* 发送完了请求
* @param array $body
* @return mixed
* @throws PayException
*
*/
protected function sendReq($body)
{
$url = $this->getReqUrl();
if (is_null($url)) {
throw new PayException('目前不支持该接口。请联系开发者添加');
}
$responseTxt = $this->curlPost($body, $url);
if ($responseTxt['error']) {
throw new PayException('网络发生错误,请稍后再试curl返回码:' . $responseTxt['message']);
}
// 格式化为数组
$retData = (json_decode($responseTxt['body'],true));
if ($retData['return_code'] != '01') {
throw new PayException('扫呗平台返回错误提示:' . $retData['return_msg']);
}
if ($retData['result_code'] == '02') {
$msg = $retData['result_code'] .' : '. $retData['return_msg'];
throw new PayException('扫呗返回错误提示:' . $msg);
}
return $retData;
}
protected function curlPost($body, $url)
{
$curl = new Curl();
return $curl->set([
'CURLOPT_HEADER' => 0,
])->post($body, $url)->submit($url,true);
}
/**
* 获取需要的url 默认返回下单的url,根据实际情况,需要被覆写
* 默认是h5支付
*
* @return string|null
*/
protected function getReqUrl()
{
return SwConfig::UNIFIED_URL;
}
/**
* @param array $data
*
* @throws PayException
* @return array|string
*/
public function handle(array $data)
{
$buildClass = $this->getBuildDataClass();
try {
$this->reqData = new $buildClass($this->config, $data);
} catch (PayException $e) {
throw $e;
}
$this->reqData->setSign();
$body = $this->reqData->getData();
$ret = $this->sendReq($body);
// 检查返回的数据是否被篡改
$flag = true;// $this->verifySign($ret);
if (!$flag) {
throw new PayException('返回数据被篡改。请检查网络是否安全!');
}
return $this->retData($ret);
}
/**
* 处理微信的返回值并返回给客户端
* @param array $ret
* @return mixed
*
*/
protected function retData(array $ret)
{
return $ret;
}
/**
* 检查微信返回的数据是否被篡改过
* @param array $retData
* @return boolean
*
*/
protected function verifySign(array $retData)
{
$retSign = $retData['sign'];
$values = ArrayUtil::removeKeys($retData, ['sign', 'sign_type']);
$values = ArrayUtil::paraFilter($values);
$values = ArrayUtil::arraySort($values);
$signStr = ArrayUtil::createLinkstring($values);
$signStr .= '&key=' . $this->config->md5Key;
switch ($this->config->signType) {
case 'MD5':
$sign = md5($signStr);
break;
case 'HMAC-SHA256':
$sign = hash_hmac('sha256', $signStr, $this->config->md5Key);
break;
default:
$sign = '';
}
return strtoupper($sign) === $retSign;
}
}
<?php
/**
* Created by PhpStorm.
*
* Date: 2017/4/26
* Time: 下午5:39
*/
namespace Payment\Common\Weixin;
use Payment\Common\PayException;
use Payment\Common\Weixin\Data\WxBaseData;
use Payment\Common\WxConfig;
use Payment\Utils\Curl;
use Payment\Utils\DataParser;
class WechatHelper extends WxBaseData
{
public function getSandboxSignKey()
{
$this->setSign();
$xml = DataParser::toXml($this->getData());
$url = WxConfig::SANDBOX_URL;
$curl = new Curl();
$responseTxt = $curl->set([
'CURLOPT_HEADER' => 0
])->post($xml)->submit($url);
if ($responseTxt['error']) {
throw new PayException('网络发生错误,请稍后再试curl返回码:' . $responseTxt['message']);
}
// 格式化为数组
$retData = DataParser::toArray($responseTxt['body']);
if ($retData['return_code'] != 'SUCCESS') {
throw new PayException('微信返回错误提示:' . $retData['return_msg']);
}
return $retData['sandbox_signkey'];
}
protected function buildData()
{
$this->retData = [
'mch_id' => $this->mchId,
'nonce_str' => $this->nonceStr,
];
}
protected function checkDataParam()
{
// TODO: Implement checkDataParam() method.
}
}
\ No newline at end of file
<?php
namespace Payment\Common;
use Payment\Utils\ArrayUtil;
final class SwConfig extends ConfigInterface
{
public $signType = 'MD5';
public $pay_ver = 100;//版本号,当前版本100
public $pay_type;//请求类型,010微信,020支付宝,060qq钱包,090口碑,100翼支付
public $service_id;//接口类型
public $merchant_no;//商户号
public $terminal_id;//终端号
public $sub_appid;// 微信分配的公众账号ID,公众号支付时使用的appid(若传入,则open_id需要保持一致)
public $terminal_time;//终端交易时间,yyyyMMddHHmmss,全局统一时间格式
// 指定回调页面
public $notify_url;
const BASE_URL = '';
const UNIFIED_URL = self::BASE_URL.'/pay/100/jspay'; // 公众号支付统一下单url
const LITEPAY_URL = self::BASE_URL.'/pay/100/minipay';// 小程序支付url
const FACEPAY_URL = self::BASE_URL.'/pay/110/facepay';//自助收银
const SCANPAY_URL = self::BASE_URL.'/pay/100/prepay';//扫码支付(预支付)
const BARCODE_URL = self::BASE_URL.'/pay/100/barcodepay';//刷卡(条码)支付
const FACEPAY_ACCESSTOKEN_URL = self::BASE_URL.'/pay/110/faceinfo';//自助收银SDK调用凭证获取接口
const AUTH_OPENID = self::BASE_URL.'/wx/jsapi/authopenid';//用于服务商通道获取微信openid,Method:GET
const AUTHCODE_TO_OPENID_URL = self::BASE_URL.'/pay/110/authcodetoopenid';//授权码查询 OPENID 接口
const CHARGE_QUERY_URL = self::BASE_URL.'/pay/100/query'; // 支付查询url
const REFUND_URL = self::BASE_URL.'/pay/100/refund'; // 申请退款url
const CANCEL_URL = self::BASE_URL.'/pay/100/cancel';//撤销交易(只针对刷卡支付)
const CLOSE_URL = self::BASE_URL.'/pay/100/close';//关闭订单(仅限服务商模式商户且为微信支付时可用)
const SIGN_URL = self::BASE_URL.'/pay/100/sign';//注册终端(获取access_token),一台机器只有一次调用机会,遗失请联系客服申请重置
/**
* 初始化微信配置文件
* WxConfig constructor.
* @param array $config
* @throws PayException
*/
public function __construct(array $config)
{
try {
$this->initConfig($config);
} catch (PayException $e) {
throw $e;
}
$basePath = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'CacertFile' . DIRECTORY_SEPARATOR;
$this->cacertPath = "{$basePath}wx_cacert.pem";
}
/**
* 初始化配置文件参数
* @param array $config
* @throws PayException
*/
private function initConfig(array $config)
{
$config = ArrayUtil::paraFilter($config);
if (key_exists('pay_ver', $config) && !empty($config['pay_ver'])) {
$this->pay_ver = $config['pay_ver'];
}
if (key_exists('pay_type', $config) && !empty($config['pay_type'])) {
$this->pay_type = $config['pay_type'];
} else {
throw new PayException('必须提供请求类型,010微信,020支付宝,060qq钱包,090口碑,100翼支付');
}
if (key_exists('service_id', $config) && !empty($config['service_id'])) {
$this->service_id = $config['service_id'];
}
if (key_exists('merchant_no', $config) && !empty($config['merchant_no'])) {
$this->merchant_no = $config['merchant_no'];
} else {
throw new PayException('必须提供扫呗商户号');
}
if (key_exists('terminal_id', $config) && !empty($config['terminal_id'])) {
$this->terminal_id = $config['terminal_id'];
} else {
throw new PayException('必须提供扫呗终端号');
}
if (key_exists('sub_appid', $config) && !empty($config['sub_appid'])) {
$this->sub_appid = $config['sub_appid'];
}
// 检查 异步通知的url
if (key_exists('notify_url', $config) && !empty($config['notify_url'])) {
$this->notify_url = trim($config['notify_url']);
} else {
throw new PayException('异步通知的url必须提供.');
}
if (key_exists('attach', $config)) {
$this->attach = trim($config['attach']);
}
// 设置交易开始时间 格式为yyyyMMddHHmmss,在次之前一定要设置时区
$startTime = time();
$this->terminal_time = date('YmdHis', $startTime);
}
}
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-15 14:56 * @createTime: 2016-07-15 14:56
* @description: 微信配置文件 * @description: 微信配置文件
* @link https://github.com/helei112g/payment/tree/paymentv2 * @link https://github.com/helei112g/payment/tree/paymentv2
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-08-02 10:27 * @createTime: 2016-08-02 10:27
* @description: * @description:
*/ */
...@@ -16,7 +16,7 @@ namespace Payment\Common\TLpay\Data; ...@@ -16,7 +16,7 @@ namespace Payment\Common\TLpay\Data;
* @property string $prepay_id 预支付交易会话标识 * @property string $prepay_id 预支付交易会话标识
* *
* @package Payment\Common\Weixin\Data * @package Payment\Common\Weixin\Data
* anthor helei *
*/ */
class BackTLChargeData extends TLBaseData class BackTLChargeData extends TLBaseData
{ {
......
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 16/7/30 * Date: 16/7/30
* Time: 下午11:08 * Time: 下午11:08
* @link https://github.com/helei112g/payment/tree/paymentv2 * @link https://github.com/helei112g/payment/tree/paymentv2
......
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/3/6 * Date: 2017/3/6
* Time: 下午10:05 * Time: 下午10:05
*/ */
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-28 18:05 * @createTime: 2016-07-28 18:05
* @description: 微信支付相关接口的数据基类 * @description: 微信支付相关接口的数据基类
*/ */
......
...@@ -53,7 +53,7 @@ abstract class TLBaseStrategy implements BaseStrategy{ ...@@ -53,7 +53,7 @@ abstract class TLBaseStrategy implements BaseStrategy{
* @param array $body * @param array $body
* @return mixed * @return mixed
* @throws PayException * @throws PayException
* @author helei *
*/ */
protected function sendReq($body) protected function sendReq($body)
{ {
...@@ -85,7 +85,7 @@ abstract class TLBaseStrategy implements BaseStrategy{ ...@@ -85,7 +85,7 @@ abstract class TLBaseStrategy implements BaseStrategy{
* @param array $body * @param array $body
* @param string $url * @param string $url
* @return mixed * @return mixed
* @author helei *
*/ */
protected function curlPost($body, $url) protected function curlPost($body, $url)
{ {
...@@ -97,7 +97,7 @@ abstract class TLBaseStrategy implements BaseStrategy{ ...@@ -97,7 +97,7 @@ abstract class TLBaseStrategy implements BaseStrategy{
/** /**
* 获取需要的url 默认返回下单的url * 获取需要的url 默认返回下单的url
* @author helei *
* @return string|null * @return string|null
*/ */
protected function getReqUrl() protected function getReqUrl()
...@@ -107,7 +107,7 @@ abstract class TLBaseStrategy implements BaseStrategy{ ...@@ -107,7 +107,7 @@ abstract class TLBaseStrategy implements BaseStrategy{
/** /**
* @param array $data * @param array $data
* @author helei *
* @throws PayException * @throws PayException
* @return array|string * @return array|string
*/ */
...@@ -139,7 +139,7 @@ abstract class TLBaseStrategy implements BaseStrategy{ ...@@ -139,7 +139,7 @@ abstract class TLBaseStrategy implements BaseStrategy{
* 处理支付平台的返回值并返回给客户端 * 处理支付平台的返回值并返回给客户端
* @param array $ret * @param array $ret
* @return mixed * @return mixed
* @author helei *
*/ */
protected function retData(array $ret) protected function retData(array $ret)
{ {
...@@ -150,7 +150,7 @@ abstract class TLBaseStrategy implements BaseStrategy{ ...@@ -150,7 +150,7 @@ abstract class TLBaseStrategy implements BaseStrategy{
* 检查支付平台返回的数据是否被篡改过:sign=md5(string.getbyte("utf-8")).toUpperCase() * 检查支付平台返回的数据是否被篡改过:sign=md5(string.getbyte("utf-8")).toUpperCase()
* @param array $retData * @param array $retData
* @return boolean * @return boolean
* @author helei *
*/ */
protected function verifySign(array $retData) protected function verifySign(array $retData)
{ {
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-08-02 09:41 * @createTime: 2016-08-02 09:41
* @description: * @description:
*/ */
...@@ -16,7 +16,7 @@ namespace Payment\Common\Weixin\Data; ...@@ -16,7 +16,7 @@ namespace Payment\Common\Weixin\Data;
* @property string $prepay_id 预支付交易会话标识 * @property string $prepay_id 预支付交易会话标识
* *
* @package Payment\Common\Weixin\Data * @package Payment\Common\Weixin\Data
* anthor helei *
*/ */
class BackAppChargeData extends WxBaseData class BackAppChargeData extends WxBaseData
{ {
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-08-02 10:27 * @createTime: 2016-08-02 10:27
* @description: * @description:
*/ */
...@@ -16,7 +16,7 @@ namespace Payment\Common\Weixin\Data; ...@@ -16,7 +16,7 @@ namespace Payment\Common\Weixin\Data;
* @property string $prepay_id 预支付交易会话标识 * @property string $prepay_id 预支付交易会话标识
* *
* @package Payment\Common\Weixin\Data * @package Payment\Common\Weixin\Data
* anthor helei *
*/ */
class BackPubChargeData extends WxBaseData class BackPubChargeData extends WxBaseData
{ {
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-28 18:05 * @createTime: 2016-07-28 18:05
* @description: * @description:
*/ */
......
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 17/3/6 * Date: 17/3/6
* Time: 上午8:49 * Time: 上午8:49
*/ */
......
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 16/7/30 * Date: 16/7/30
* Time: 下午11:08 * Time: 下午11:08
* @link https://github.com/helei112g/payment/tree/paymentv2 * @link https://github.com/helei112g/payment/tree/paymentv2
......
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 16/7/31 * Date: 16/7/31
* Time: 上午9:20 * Time: 上午9:20
*/ */
...@@ -21,7 +21,7 @@ use Payment\Utils\ArrayUtil; ...@@ -21,7 +21,7 @@ use Payment\Utils\ArrayUtil;
* @property string $sub_openid 用户在子商户appid下的唯一标识 * @property string $sub_openid 用户在子商户appid下的唯一标识
* *
* @package Payment\Common\Weixin\Data\Charge * @package Payment\Common\Weixin\Data\Charge
* anthor helei *
*/ */
class PubChargeData extends ChargeBaseData class PubChargeData extends ChargeBaseData
{ {
......
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 16/7/31 * Date: 16/7/31
* Time: 上午8:49 * Time: 上午8:49
*/ */
......
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/3/6 * Date: 2017/3/6
* Time: 下午5:45 * Time: 下午5:45
*/ */
......
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/3/6 * Date: 2017/3/6
* Time: 下午10:05 * Time: 下午10:05
*/ */
......
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/3/7 * Date: 2017/3/7
* Time: 下午1:32 * Time: 下午1:32
*/ */
......
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/3/7 * Date: 2017/3/7
* Time: 下午4:55 * Time: 下午4:55
*/ */
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-08-03 15:14 * @createTime: 2016-08-03 15:14
* @description: * @description:
*/ */
...@@ -24,7 +24,7 @@ use Payment\Utils\ArrayUtil; ...@@ -24,7 +24,7 @@ use Payment\Utils\ArrayUtil;
* @property string $refund_account 退款账户 UNSETTLED:未结算资金退款 RECHARGE:可用余额退款 * @property string $refund_account 退款账户 UNSETTLED:未结算资金退款 RECHARGE:可用余额退款
* *
* @package Payment\Common\Weixin\Data * @package Payment\Common\Weixin\Data
* anthor helei *
*/ */
class RefundData extends WxBaseData class RefundData extends WxBaseData
{ {
...@@ -50,7 +50,7 @@ class RefundData extends WxBaseData ...@@ -50,7 +50,7 @@ class RefundData extends WxBaseData
/** /**
* 检查参数 * 检查参数
* @author helei *
*/ */
protected function checkDataParam() protected function checkDataParam()
{ {
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-08-04 09:42 * @createTime: 2016-08-04 09:42
* @description: * @description:
*/ */
...@@ -28,7 +28,7 @@ use Payment\Utils\ArrayUtil; ...@@ -28,7 +28,7 @@ use Payment\Utils\ArrayUtil;
* @property string $client_ip 调用接口的机器Ip地址 * @property string $client_ip 调用接口的机器Ip地址
* *
* @package Payment\Common\Weixin\Data * @package Payment\Common\Weixin\Data
* anthor helei *
*/ */
class TransferData extends WxBaseData class TransferData extends WxBaseData
{ {
...@@ -56,7 +56,7 @@ class TransferData extends WxBaseData ...@@ -56,7 +56,7 @@ class TransferData extends WxBaseData
/** /**
* 检查相关参数是否设置 * 检查相关参数是否设置
* @author helei *
*/ */
protected function checkDataParam() protected function checkDataParam()
{ {
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-28 18:05 * @createTime: 2016-07-28 18:05
* @description: 微信支付相关接口的数据基类 * @description: 微信支付相关接口的数据基类
*/ */
......
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/26 * Date: 2017/4/26
* Time: 下午5:39 * Time: 下午5:39
*/ */
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-28 18:04 * @createTime: 2016-07-28 18:04
* @description: 微信的策略基类 * @description: 微信的策略基类
*/ */
...@@ -20,7 +20,7 @@ use Payment\Utils\DataParser; ...@@ -20,7 +20,7 @@ use Payment\Utils\DataParser;
* 微信策略基类 * 微信策略基类
* *
* @package Payment\Common\Weixin * @package Payment\Common\Weixin
* anthor helei *
*/ */
abstract class WxBaseStrategy implements BaseStrategy abstract class WxBaseStrategy implements BaseStrategy
{ {
...@@ -59,7 +59,7 @@ abstract class WxBaseStrategy implements BaseStrategy ...@@ -59,7 +59,7 @@ abstract class WxBaseStrategy implements BaseStrategy
* @param string $xml * @param string $xml
* @return mixed * @return mixed
* @throws PayException * @throws PayException
* @author helei *
*/ */
protected function sendReq($xml) protected function sendReq($xml)
{ {
...@@ -96,7 +96,7 @@ abstract class WxBaseStrategy implements BaseStrategy ...@@ -96,7 +96,7 @@ abstract class WxBaseStrategy implements BaseStrategy
* @param string $xml * @param string $xml
* @param string $url * @param string $url
* @return array * @return array
* @author helei *
*/ */
protected function curlPost($xml, $url) protected function curlPost($xml, $url)
{ {
...@@ -108,7 +108,7 @@ abstract class WxBaseStrategy implements BaseStrategy ...@@ -108,7 +108,7 @@ abstract class WxBaseStrategy implements BaseStrategy
/** /**
* 获取需要的url 默认返回下单的url * 获取需要的url 默认返回下单的url
* @author helei *
* @return string|null * @return string|null
*/ */
protected function getReqUrl() protected function getReqUrl()
...@@ -118,7 +118,7 @@ abstract class WxBaseStrategy implements BaseStrategy ...@@ -118,7 +118,7 @@ abstract class WxBaseStrategy implements BaseStrategy
/** /**
* @param array $data * @param array $data
* @author helei *
* @throws PayException * @throws PayException
* @return array|string * @return array|string
*/ */
...@@ -150,7 +150,7 @@ abstract class WxBaseStrategy implements BaseStrategy ...@@ -150,7 +150,7 @@ abstract class WxBaseStrategy implements BaseStrategy
* 处理微信的返回值并返回给客户端 * 处理微信的返回值并返回给客户端
* @param array $ret * @param array $ret
* @return mixed * @return mixed
* @author helei *
*/ */
protected function retData(array $ret) protected function retData(array $ret)
{ {
...@@ -161,7 +161,7 @@ abstract class WxBaseStrategy implements BaseStrategy ...@@ -161,7 +161,7 @@ abstract class WxBaseStrategy implements BaseStrategy
* 检查微信返回的数据是否被篡改过 * 检查微信返回的数据是否被篡改过
* @param array $retData * @param array $retData
* @return boolean * @return boolean
* @author helei *
*/ */
protected function verifySign(array $retData) protected function verifySign(array $retData)
{ {
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-15 14:56 * @createTime: 2016-07-15 14:56
* @description: 微信配置文件 * @description: 微信配置文件
* @link https://github.com/helei112g/payment/tree/paymentv2 * @link https://github.com/helei112g/payment/tree/paymentv2
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-14 17:47 * @createTime: 2016-07-14 17:47
* @description: 支付相关的基础配置 无法被继承 * @description: 支付相关的基础配置 无法被继承
* @link https://github.com/helei112g/payment/tree/paymentv2 * @link https://github.com/helei112g/payment/tree/paymentv2
...@@ -23,6 +23,8 @@ final class Config ...@@ -23,6 +23,8 @@ final class Config
const TL_PAY ='tl'; // 通联支付 const TL_PAY ='tl'; // 通联支付
const MI_PAY = 'mipay'; // 米付 const MI_PAY = 'mipay'; // 米付
const SW_PAY ='swpay';//扫呗支付
//========================= 金额问题设置 =======================// //========================= 金额问题设置 =======================//
const PAY_MIN_FEE = '0.01';// 支付的最小金额 const PAY_MIN_FEE = '0.01';// 支付的最小金额
...@@ -83,6 +85,9 @@ final class Config ...@@ -83,6 +85,9 @@ final class Config
const WX_TRANSFER = 'wx_transfer';// 转账 const WX_TRANSFER = 'wx_transfer';// 转账
const APPLE_PAY = 'applepay_upacp';//apple支付
//========================= 招商相关接口 =======================// //========================= 招商相关接口 =======================//
// 支付常量 // 支付常量
...@@ -140,6 +145,35 @@ final class Config ...@@ -140,6 +145,35 @@ final class Config
//========================= 扫呗相关接口 =======================//
//http://www.lcsw.cn/doc/api/payment.html
// 支付常量
const SW_CHANNEL_PUB = 'sw_pub';// 微信公众号h5支付
const SW_CHANNEL_LITE = 'sw_lite';// 小程序支付
const SW_CHANNEL_SCAN = 'sw_scan';// 扫码支付
const SW_CHANNEL_BAR = 'sw_bar';// 刷卡(条码)支付 用户被扫模式
const SW_CHANNEL_FACEPAY = 'sw_facepay';// 自助收银收款
const SW_CHANNEL_FACEPAY_TOKEN = 'sw_facepay_token';// 人脸识别初始化token
const SW_BIND = 'sw_bind';// 签约API
const SW_PUB_KEY = 'sw_pub_key';// 查询公钥
const SW_CHARGE = 'sw_charge';// 统一下单
const SW_REFUND = 'sw_refund';// 退款
const SW_CANCEL = 'sw_cancel';// 交易撤销,只能撤销当天的交易,全额退款,实时返回退款结果
const SW_QUERY = 'sw_query'; // 查询接口
......
...@@ -6,7 +6,7 @@ use Payment\Common\Cmb\Data\BindCardData; ...@@ -6,7 +6,7 @@ use Payment\Common\Cmb\Data\BindCardData;
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/28 * Date: 2017/4/28
* Time: 下午12:01 * Time: 下午12:01
*/ */
......
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/29 * Date: 2017/4/29
* Time: 上午9:50 * Time: 上午9:50
*/ */
......
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/28 * Date: 2017/4/28
* Time: 上午10:43 * Time: 上午10:43
*/ */
...@@ -33,7 +33,7 @@ class HelperContext ...@@ -33,7 +33,7 @@ class HelperContext
* *
* @param array $config 配置文件 * @param array $config 配置文件
* @throws PayException * @throws PayException
* @author helei *
*/ */
public function initHelper($way, array $config) public function initHelper($way, array $config)
{ {
...@@ -60,7 +60,7 @@ class HelperContext ...@@ -60,7 +60,7 @@ class HelperContext
* *
* @return array * @return array
* @throws PayException * @throws PayException
* @author helei *
*/ */
public function helper(array $data) public function helper(array $data)
{ {
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-20 16:21 * @createTime: 2016-07-20 16:21
* @description: 支付宝回调通知 * @description: 支付宝回调通知
* *
...@@ -48,7 +48,7 @@ class AliNotify extends NotifyStrategy ...@@ -48,7 +48,7 @@ class AliNotify extends NotifyStrategy
* 如果获取数据失败,返回false * 如果获取数据失败,返回false
* *
* @return array|boolean * @return array|boolean
* @author helei *
*/ */
public function getNotifyData() public function getNotifyData()
{ {
...@@ -67,7 +67,7 @@ class AliNotify extends NotifyStrategy ...@@ -67,7 +67,7 @@ class AliNotify extends NotifyStrategy
* *
* @param array $data 由 $this->getNotifyData() 返回的数据 * @param array $data 由 $this->getNotifyData() 返回的数据
* @return boolean * @return boolean
* @author helei *
*/ */
public function checkNotifyData(array $data) public function checkNotifyData(array $data)
{ {
...@@ -92,7 +92,7 @@ class AliNotify extends NotifyStrategy ...@@ -92,7 +92,7 @@ class AliNotify extends NotifyStrategy
* 向客户端返回必要的数据 * 向客户端返回必要的数据
* @param array $data 回调机构返回的回调通知数据 * @param array $data 回调机构返回的回调通知数据
* @return array|false * @return array|false
* @author helei *
*/ */
protected function getRetData(array $data) protected function getRetData(array $data)
{ {
...@@ -160,7 +160,7 @@ class AliNotify extends NotifyStrategy ...@@ -160,7 +160,7 @@ class AliNotify extends NotifyStrategy
* @param boolean $flag 每次返回的bool值 * @param boolean $flag 每次返回的bool值
* @param string $msg 错误原因 后期考虑记录日志 * @param string $msg 错误原因 后期考虑记录日志
* @return string * @return string
* @author helei *
*/ */
protected function replyNotify($flag, $msg = '') protected function replyNotify($flag, $msg = '')
{ {
...@@ -175,7 +175,7 @@ class AliNotify extends NotifyStrategy ...@@ -175,7 +175,7 @@ class AliNotify extends NotifyStrategy
* 返回统一的交易状态 * 返回统一的交易状态
* @param $status * @param $status
* @return string * @return string
* @author helei *
*/ */
protected function getTradeStatus($status) protected function getTradeStatus($status)
{ {
...@@ -190,7 +190,7 @@ class AliNotify extends NotifyStrategy ...@@ -190,7 +190,7 @@ class AliNotify extends NotifyStrategy
* 检查支付宝数据 签名是否被篡改 * 检查支付宝数据 签名是否被篡改
* @param array $data * @param array $data
* @return boolean * @return boolean
* @author helei *
*/ */
protected function verifySign(array $data) protected function verifySign(array $data)
{ {
......
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/29 * Date: 2017/4/29
* Time: 上午10:36 * Time: 上午10:36
*/ */
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-14 17:51 * @createTime: 2016-07-14 17:51
* @description: 支付回调的策略接口 * @description: 支付回调的策略接口
* @link https://github.com/helei112g/payment/tree/paymentv2 * @link https://github.com/helei112g/payment/tree/paymentv2
...@@ -34,7 +34,7 @@ abstract class NotifyStrategy ...@@ -34,7 +34,7 @@ abstract class NotifyStrategy
* 主要任务,验证返回的数据是否正确 * 主要任务,验证返回的数据是否正确
* @param PayNotifyInterface $notify * @param PayNotifyInterface $notify
* @return mixed * @return mixed
* @author helei *
*/ */
final public function handle(PayNotifyInterface $notify) final public function handle(PayNotifyInterface $notify)
{ {
...@@ -67,7 +67,7 @@ abstract class NotifyStrategy ...@@ -67,7 +67,7 @@ abstract class NotifyStrategy
* @param array $notifyData * @param array $notifyData
* *
* @return boolean * @return boolean
* @author helei *
*/ */
protected function callback(PayNotifyInterface $notify, array $notifyData) protected function callback(PayNotifyInterface $notify, array $notifyData)
{ {
...@@ -86,7 +86,7 @@ abstract class NotifyStrategy ...@@ -86,7 +86,7 @@ abstract class NotifyStrategy
* 如果获取数据失败,返回false * 如果获取数据失败,返回false
* *
* @return array|false * @return array|false
* @author helei *
*/ */
abstract public function getNotifyData(); abstract public function getNotifyData();
...@@ -97,7 +97,7 @@ abstract class NotifyStrategy ...@@ -97,7 +97,7 @@ abstract class NotifyStrategy
* *
* @param array $data 由 $this->getNotifyData() 返回的数据 * @param array $data 由 $this->getNotifyData() 返回的数据
* @return boolean * @return boolean
* @author helei *
*/ */
abstract public function checkNotifyData(array $data); abstract public function checkNotifyData(array $data);
...@@ -105,7 +105,7 @@ abstract class NotifyStrategy ...@@ -105,7 +105,7 @@ abstract class NotifyStrategy
* 向客户端返回必要的数据 * 向客户端返回必要的数据
* @param array $data 回调机构返回的回调通知数据 * @param array $data 回调机构返回的回调通知数据
* @return array|false * @return array|false
* @author helei *
*/ */
abstract protected function getRetData(array $data); abstract protected function getRetData(array $data);
...@@ -114,7 +114,7 @@ abstract class NotifyStrategy ...@@ -114,7 +114,7 @@ abstract class NotifyStrategy
* @param boolean $flag 每次返回的bool值 * @param boolean $flag 每次返回的bool值
* @param string $msg 通知信息,错误原因 * @param string $msg 通知信息,错误原因
* @return mixed * @return mixed
* @author helei *
*/ */
abstract protected function replyNotify($flag, $msg = 'OK'); abstract protected function replyNotify($flag, $msg = 'OK');
} }
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-20 16:12 * @createTime: 2016-07-20 16:12
* @description: 提供给客户端实现的 支付异步回调 接口 * @description: 提供给客户端实现的 支付异步回调 接口
* *
...@@ -19,7 +19,7 @@ interface PayNotifyInterface ...@@ -19,7 +19,7 @@ interface PayNotifyInterface
* @param array $data 返回的数据 * @param array $data 返回的数据
* *
* @return boolean * @return boolean
* @author helei *
*/ */
public function notifyProcess(array $data); public function notifyProcess(array $data);
} }
<?php
namespace Payment\Notify;
use Payment\Common\PayException;
use Payment\Common\MiConfig;
use Payment\Config;
use Payment\Utils\ArrayUtil;
/**
* Class SwNotify
* 回调处理
* @package Payment\Notify
* @anthor yeran
*/
class SwNotify extends NotifyStrategy
{
/**
* SwNotify constructor.
* @param array $config
* @throws PayException
*/
public function __construct(array $config)
{
parent::__construct($config);
try {
$this->config = new MiConfig($config);
} catch (PayException $e) {
throw $e;
}
}
/**
* 获取返回的异步通知数据
* @return array|bool
* @author yeran
*/
public function getNotifyData()
{
$params = array();
//支持直接读取input流
$data = @file_get_contents('php://input');
if(!empty($data)){
$inputArray = json_decode($data,true);
$params = array_merge($params,$inputArray);
}
if(count($params)<1){//如果参数为空,则不进行处理
return false;
}
return $params;
}
/**
* 检查异步通知的数据是否正确
* @param array $data
*
* @author yeran
* @return boolean
*/
public function checkNotifyData(array $data)
{
if ($data['return_code'] != '01' || $data['result_code'] == '02') {
return false;
}
// 检查返回数据签名是否正确
return $this->verifySign($data);
}
/**
* 检查微信返回的数据是否被篡改过
* @param array $retData
* @return boolean
* @author yeran
*/
protected function verifySign(array $retData)
{
$retSign = $retData['key_sign'];
$values = ArrayUtil::removeKeys($retData, ['key_sign', 'pay_trace','pay_time','receipt_fee']);
$values = ArrayUtil::paraFilter($values);
$values = ArrayUtil::arraySort($values);
$signStr = ArrayUtil::createLinkstring($values);
$signStr .= '&access_token=' . $this->access_token;
switch ($this->signType) {
case 'MD5':
$sign = md5($signStr);
break;
default:
$sign = '';
}
return strtoupper($sign) === strtoupper($retSign);
}
/**
*
* 封装回调函数需要的数据格式
*
* @param array $data
*
* @return array
* @author yeran
*/
protected function getRetData(array $data)
{
$retData = [
'pay_type' => $data['pay_type'],//请求类型,010微信,020 支付宝,060qq钱包,080京东钱包,090口碑,100翼支付
'user_id' => $data['user_id'],//付款方用户id,“微信openid”、“支付宝账户”、“qq号”等
'merchant_name' => $data['merchant_name'],//商户名称
'merchant_no' => $data['merchant_no'],//商户号
'terminal_id' => $data['terminal_id'],//终端号
'terminal_trace' => $data['terminal_trace'],//终端流水号,此处传商户发起预支付或公众号支付时所传入的交易流水号
'terminal_time' => $data['terminal_time'],//终端交易时间,yyyyMMddHHmmss,全局统一时间格式(01时参与拼接)
'pay_trace' => $data['pay_trace']??'',//当前支付终端流水号,与pay_time同时传递,返回时不参与签名
'pay_time' => $data['pay_time']??'',//当前支付终端交易时间,
'total_fee' => $data['total_fee'],//金额,单位分
'end_time' => $data['end_time'],//支付完成时间,yyyyMMddHHmmss
'out_trade_no' => $data['out_trade_no'],//利楚唯一订单号
'channel_trade_no' => $data['channel_trade_no'],//通道订单号,微信订单号、支付宝订单号等
'attach' => $data['attach'],//附加数据,原样返回
'receipt_fee' => $data['receipt_fee']??'',//口碑实收金额,pay_type为090时必填
'channel' => Config::SW_CHARGE,
];
return $retData;
}
/**
* 处理完后返回的数据格式
* @param bool $flag
* @param string $msg 通知信息,错误原因
* @author yeran
* @return array|mixed
*/
protected function replyNotify($flag, $msg = 'OK')
{
// 默认为成功
$return_code ='01';
if (! $flag) {
$return_code ='02';
}
return [
'return_code' => $return_code,
'return_msg' => '数据校验失败',
];
}
}
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-20 16:46 * @createTime: 2016-07-20 16:46
* @description: * @description:
*/ */
...@@ -17,7 +17,7 @@ use Payment\Utils\DataParser; ...@@ -17,7 +17,7 @@ use Payment\Utils\DataParser;
* Class WxNotify * Class WxNotify
* 微信回调处理 * 微信回调处理
* @package Payment\Notify * @package Payment\Notify
* anthor helei *
*/ */
class WxNotify extends NotifyStrategy class WxNotify extends NotifyStrategy
{ {
...@@ -41,7 +41,7 @@ class WxNotify extends NotifyStrategy ...@@ -41,7 +41,7 @@ class WxNotify extends NotifyStrategy
/** /**
* 获取微信返回的异步通知数据 * 获取微信返回的异步通知数据
* @return array|bool * @return array|bool
* @author helei *
*/ */
public function getNotifyData() public function getNotifyData()
{ {
...@@ -63,7 +63,7 @@ class WxNotify extends NotifyStrategy ...@@ -63,7 +63,7 @@ class WxNotify extends NotifyStrategy
* 检查微信异步通知的数据是否正确 * 检查微信异步通知的数据是否正确
* @param array $data * @param array $data
* *
* @author helei *
* @return boolean * @return boolean
*/ */
public function checkNotifyData(array $data) public function checkNotifyData(array $data)
...@@ -82,7 +82,7 @@ class WxNotify extends NotifyStrategy ...@@ -82,7 +82,7 @@ class WxNotify extends NotifyStrategy
* 检查微信返回的数据是否被篡改过 * 检查微信返回的数据是否被篡改过
* @param array $retData * @param array $retData
* @return boolean * @return boolean
* @author helei *
*/ */
protected function verifySign(array $retData) protected function verifySign(array $retData)
{ {
...@@ -115,7 +115,7 @@ class WxNotify extends NotifyStrategy ...@@ -115,7 +115,7 @@ class WxNotify extends NotifyStrategy
* @param array $data * @param array $data
* *
* @return array * @return array
* @author helei *
*/ */
protected function getRetData(array $data) protected function getRetData(array $data)
{ {
...@@ -156,7 +156,7 @@ class WxNotify extends NotifyStrategy ...@@ -156,7 +156,7 @@ class WxNotify extends NotifyStrategy
* 处理完后返回的数据格式 * 处理完后返回的数据格式
* @param bool $flag * @param bool $flag
* @param string $msg 通知信息,错误原因 * @param string $msg 通知信息,错误原因
* @author helei *
* @return string * @return string
*/ */
protected function replyNotify($flag, $msg = 'OK') protected function replyNotify($flag, $msg = 'OK')
......
...@@ -12,6 +12,7 @@ use Payment\Notify\CmbNotify; ...@@ -12,6 +12,7 @@ use Payment\Notify\CmbNotify;
use Payment\Notify\MiNotify; use Payment\Notify\MiNotify;
use Payment\Notify\NotifyStrategy; use Payment\Notify\NotifyStrategy;
use Payment\Notify\PayNotifyInterface; use Payment\Notify\PayNotifyInterface;
use Payment\Notify\SwNotify;
use Payment\Notify\TLNotify; use Payment\Notify\TLNotify;
use Payment\Notify\WxNotify; use Payment\Notify\WxNotify;
use Payment\Common\PayException; use Payment\Common\PayException;
...@@ -32,7 +33,7 @@ class NotifyContext ...@@ -32,7 +33,7 @@ class NotifyContext
* *
* @param array $config 配置文件 * @param array $config 配置文件
* @throws PayException * @throws PayException
* @author helei *
*/ */
public function initNotify($channel, array $config) public function initNotify($channel, array $config)
{ {
...@@ -53,8 +54,11 @@ class NotifyContext ...@@ -53,8 +54,11 @@ class NotifyContext
case Config::MI_CHARGE: case Config::MI_CHARGE:
$this->notify = new MiNotify($config); $this->notify = new MiNotify($config);
break; break;
case Config::SW_CHARGE:
$this->notify = new SwNotify($config);
break;
default: default:
throw new PayException('当前仅支持:ALI_CHARGE WX_CHARGE CMB_CHARGE 常量'); throw new PayException('当前仅支持:ALI_CHARGE WX_CHARGE CMB_CHARGE TLNotify MiNotify SwNotify');
} }
} catch (PayException $e) { } catch (PayException $e) {
throw $e; throw $e;
...@@ -76,7 +80,7 @@ class NotifyContext ...@@ -76,7 +80,7 @@ class NotifyContext
* @param PayNotifyInterface $notify * @param PayNotifyInterface $notify
* @return array * @return array
* @throws PayException * @throws PayException
* @author helei *
*/ */
public function notify(PayNotifyInterface $notify) public function notify(PayNotifyInterface $notify)
{ {
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-28 17:23 * @createTime: 2016-07-28 17:23
* @description: 支付宝订单查询接口 * @description: 支付宝订单查询接口
*/ */
...@@ -43,7 +43,7 @@ class AliChargeQuery extends AliBaseStrategy ...@@ -43,7 +43,7 @@ class AliChargeQuery extends AliBaseStrategy
* 处理支付宝返回的数据,统一处理后返回 * 处理支付宝返回的数据,统一处理后返回
* @param array $data 支付宝返回的数据 * @param array $data 支付宝返回的数据
* @return array * @return array
* @author helei *
*/ */
protected function createBackData(array $data) protected function createBackData(array $data)
{ {
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-12-31 17:55 * @createTime: 2016-12-31 17:55
* @description: * @description:
*/ */
...@@ -18,7 +18,7 @@ use Payment\Config; ...@@ -18,7 +18,7 @@ use Payment\Config;
* 支付宝退款订单查询 * 支付宝退款订单查询
* Class AliRefundQuery * Class AliRefundQuery
* @package Payment\Query * @package Payment\Query
* anthor helei *
*/ */
class AliRefundQuery extends AliBaseStrategy class AliRefundQuery extends AliBaseStrategy
{ {
...@@ -50,7 +50,7 @@ class AliRefundQuery extends AliBaseStrategy ...@@ -50,7 +50,7 @@ class AliRefundQuery extends AliBaseStrategy
* 返回数据给客户端 未完成,目前没有数据提供 * 返回数据给客户端 未完成,目前没有数据提供
* @param array $data * @param array $data
* @return array * @return array
* @author helei *
*/ */
protected function createBackData(array $data) protected function createBackData(array $data)
{ {
......
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/3/7 * Date: 2017/3/7
* Time: 下午3:58 * Time: 下午3:58
*/ */
...@@ -51,7 +51,7 @@ class AliTransferQuery extends AliBaseStrategy ...@@ -51,7 +51,7 @@ class AliTransferQuery extends AliBaseStrategy
* 返回数据给客户端 未完成,目前没有数据提供 * 返回数据给客户端 未完成,目前没有数据提供
* @param array $data * @param array $data
* @return array * @return array
* @author helei *
*/ */
protected function createBackData(array $data) protected function createBackData(array $data)
{ {
......
...@@ -9,7 +9,7 @@ use Payment\Config; ...@@ -9,7 +9,7 @@ use Payment\Config;
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/28 * Date: 2017/4/28
* Time: 下午12:51 * Time: 下午12:51
*/ */
......
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/28 * Date: 2017/4/28
* Time: 下午5:22 * Time: 下午5:22
*/ */
......
...@@ -31,7 +31,7 @@ class MiQuery extends MiBaseStrategy { ...@@ -31,7 +31,7 @@ class MiQuery extends MiBaseStrategy {
/** /**
* 返回查询的url * 返回查询的url
* @return string * @return string
* @author helei *
*/ */
protected function getReqUrl() protected function getReqUrl()
{ {
......
<?php
/**
*
* @createTime: 2019-03-24 22:42
* @description: 支付查询
*/
namespace Payment\Query\Sw;
use Payment\Common\Sw\Data\Query\BackChargeQueryData;
use Payment\Common\Sw\Data\Query\ChargeQueryData;
use Payment\Common\Sw\SwBaseStrategy;
use Payment\Common\SwConfig;
class SwChargeQuery extends SwBaseStrategy
{
/**
* 返回查询订单的数据
*
*/
public function getBuildDataClass()
{
return ChargeQueryData::class;
}
/**
* 返回微信查询的url
* @return string
*
*/
protected function getReqUrl()
{
return SwConfig::CHARGE_QUERY_URL;
}
/**
* 处理通知的返回数据
* @param array $ret
* @return mixed
*
*/
protected function retData(array $ret)
{
$back = new BackChargeQueryData($this->config, $ret);
$backData = $back->getData();
// 移除sign
unset($backData['sign']);
return $backData;
}
}
...@@ -9,9 +9,8 @@ ...@@ -9,9 +9,8 @@
namespace Payment\Query\TLpay; namespace Payment\Query\TLpay;
use Payment\Common\BaseData;
use Payment\Common\TLConfig; use Payment\Common\TLConfig;
use Payment\Common\TLpay\Data\Query\MiQueryData; use Payment\Common\TLpay\Data\Query\TLQueryData;
use Payment\Common\TLpay\TLBaseStrategy; use Payment\Common\TLpay\TLBaseStrategy;
...@@ -19,19 +18,18 @@ class TLQuery extends TLBaseStrategy { ...@@ -19,19 +18,18 @@ class TLQuery extends TLBaseStrategy {
/** /**
* 获取支付对应的数据完成类 * 获取支付对应的数据完成类
* @return BaseData *
* @author helei
*/ */
public function getBuildDataClass() public function getBuildDataClass()
{ {
// TODO: Implement getBuildDataClass() method. // TODO: Implement getBuildDataClass() method.
return MiQueryData::class; return TlQueryData::class;
} }
/** /**
* 返回查询的url * 返回查询的url
* @return string * @return string
* @author helei *
*/ */
protected function getReqUrl() protected function getReqUrl()
{ {
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-28 17:25 * @createTime: 2016-07-28 17:25
* @description: * @description:
*/ */
...@@ -18,7 +18,7 @@ class WxChargeQuery extends WxBaseStrategy ...@@ -18,7 +18,7 @@ class WxChargeQuery extends WxBaseStrategy
/** /**
* 返回查询订单的数据 * 返回查询订单的数据
* @author helei *
*/ */
public function getBuildDataClass() public function getBuildDataClass()
{ {
...@@ -28,7 +28,7 @@ class WxChargeQuery extends WxBaseStrategy ...@@ -28,7 +28,7 @@ class WxChargeQuery extends WxBaseStrategy
/** /**
* 返回微信查询的url * 返回微信查询的url
* @return string * @return string
* @author helei *
*/ */
protected function getReqUrl() protected function getReqUrl()
{ {
...@@ -39,7 +39,7 @@ class WxChargeQuery extends WxBaseStrategy ...@@ -39,7 +39,7 @@ class WxChargeQuery extends WxBaseStrategy
* 处理通知的返回数据 * 处理通知的返回数据
* @param array $data * @param array $data
* @return mixed * @return mixed
* @author helei *
*/ */
protected function retData(array $data) protected function retData(array $data)
{ {
...@@ -74,7 +74,7 @@ class WxChargeQuery extends WxBaseStrategy ...@@ -74,7 +74,7 @@ class WxChargeQuery extends WxBaseStrategy
* 返回数据给客户端 * 返回数据给客户端
* @param array $data * @param array $data
* @return array * @return array
* @author helei *
*/ */
protected function createBackData(array $data) protected function createBackData(array $data)
{ {
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-08-02 17:55 * @createTime: 2016-08-02 17:55
* @description: * @description:
*/ */
...@@ -17,7 +17,7 @@ use Payment\Config; ...@@ -17,7 +17,7 @@ use Payment\Config;
* 微信退款订单查询 * 微信退款订单查询
* Class WxRefudnQuery * Class WxRefudnQuery
* @package Payment\Query * @package Payment\Query
* anthor helei *
*/ */
class WxRefundQuery extends WxBaseStrategy class WxRefundQuery extends WxBaseStrategy
{ {
...@@ -35,7 +35,7 @@ class WxRefundQuery extends WxBaseStrategy ...@@ -35,7 +35,7 @@ class WxRefundQuery extends WxBaseStrategy
* 处理通知的返回数据 * 处理通知的返回数据
* @param array $data * @param array $data
* @return mixed * @return mixed
* @author helei *
*/ */
protected function retData(array $data) protected function retData(array $data)
{ {
...@@ -70,7 +70,7 @@ class WxRefundQuery extends WxBaseStrategy ...@@ -70,7 +70,7 @@ class WxRefundQuery extends WxBaseStrategy
* 返回数据给客户端 * 返回数据给客户端
* @param array $data * @param array $data
* @return array * @return array
* @author helei *
*/ */
protected function createBackData(array $data) protected function createBackData(array $data)
{ {
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-08-04 10:30 * @createTime: 2016-08-04 10:30
* @description: * @description:
*/ */
...@@ -18,7 +18,7 @@ use Payment\Utils\DataParser; ...@@ -18,7 +18,7 @@ use Payment\Utils\DataParser;
/** /**
* Class WxTransferQuery * Class WxTransferQuery
* @package Payment\Query * @package Payment\Query
* anthor helei *
*/ */
class WxTransferQuery extends WxBaseStrategy class WxTransferQuery extends WxBaseStrategy
{ {
...@@ -32,7 +32,7 @@ class WxTransferQuery extends WxBaseStrategy ...@@ -32,7 +32,7 @@ class WxTransferQuery extends WxBaseStrategy
* @param string $xml * @param string $xml
* @param string $url * @param string $url
* @return array * @return array
* @author helei *
*/ */
protected function curlPost($xml, $url) protected function curlPost($xml, $url)
{ {
...@@ -52,7 +52,7 @@ class WxTransferQuery extends WxBaseStrategy ...@@ -52,7 +52,7 @@ class WxTransferQuery extends WxBaseStrategy
/** /**
* 返回付款查询url * 返回付款查询url
* @return string * @return string
* @author helei *
*/ */
protected function getReqUrl() protected function getReqUrl()
{ {
...@@ -63,7 +63,7 @@ class WxTransferQuery extends WxBaseStrategy ...@@ -63,7 +63,7 @@ class WxTransferQuery extends WxBaseStrategy
* 处理通知的返回数据 * 处理通知的返回数据
* @param array $data * @param array $data
* @return mixed * @return mixed
* @author helei *
*/ */
protected function retData(array $data) protected function retData(array $data)
{ {
...@@ -98,7 +98,7 @@ class WxTransferQuery extends WxBaseStrategy ...@@ -98,7 +98,7 @@ class WxTransferQuery extends WxBaseStrategy
* 返回数据给客户端 * 返回数据给客户端
* @param array $data * @param array $data
* @return array * @return array
* @author helei *
*/ */
protected function createBackData(array $data) protected function createBackData(array $data)
{ {
...@@ -126,7 +126,7 @@ class WxTransferQuery extends WxBaseStrategy ...@@ -126,7 +126,7 @@ class WxTransferQuery extends WxBaseStrategy
/** /**
* @param array $data * @param array $data
* @author helei *
* @throws PayException * @throws PayException
* @return array|string * @return array|string
*/ */
......
...@@ -15,6 +15,7 @@ use Payment\Query\Ali\AliTransferQuery; ...@@ -15,6 +15,7 @@ use Payment\Query\Ali\AliTransferQuery;
use Payment\Query\Cmb\CmbChargeQuery; use Payment\Query\Cmb\CmbChargeQuery;
use Payment\Query\Cmb\CmbRefundQuery; use Payment\Query\Cmb\CmbRefundQuery;
use Payment\Query\MiPay\MiQuery; use Payment\Query\MiPay\MiQuery;
use Payment\Query\Sw\SwChargeQuery;
use Payment\Query\TLpay\TLQuery; use Payment\Query\TLpay\TLQuery;
use Payment\Query\Wx\WxChargeQuery; use Payment\Query\Wx\WxChargeQuery;
use Payment\Query\Wx\WxRefundQuery; use Payment\Query\Wx\WxRefundQuery;
...@@ -36,7 +37,7 @@ class QueryContext ...@@ -36,7 +37,7 @@ class QueryContext
* *
* @param array $config 配置文件 * @param array $config 配置文件
* @throws PayException * @throws PayException
* @author helei *
*/ */
public function initQuery($channel, array $config) public function initQuery($channel, array $config)
{ {
...@@ -68,14 +69,18 @@ class QueryContext ...@@ -68,14 +69,18 @@ class QueryContext
case Config::CMB_REFUND:// 招商退款查询 case Config::CMB_REFUND:// 招商退款查询
$this->query = new CmbRefundQuery($config); $this->query = new CmbRefundQuery($config);
break; break;
case Config::TL_QUERY:// 通联退款查询 case Config::TL_QUERY:// 通联查询
$this->query = new TLQuery($config); $this->query = new TLQuery($config);
break; break;
case Config::MI_QUERY:// 通联退款查询 case Config::MI_QUERY:// Mi查询
$this->query = new MiQuery($config); $this->query = new MiQuery($config);
break; break;
case Config::SW_QUERY:// 扫呗查询
$this->query = new SwChargeQuery($config);
break;
default: default:
throw new PayException('当前仅支持:ALI_CHARGE ALI_REFUND WX_CHARGE WX_REFUND WX_TRANSFER CMB_CHARGE CMB_REFUND TLPAY'); throw new PayException('当前仅支持:ALI_CHARGE ALI_REFUND WX_CHARGE WX_REFUND WX_TRANSFER CMB_CHARGE CMB_REFUND TLPAY MI_QUERY SW_QUERY');
} }
} catch (PayException $e) { } catch (PayException $e) {
throw $e; throw $e;
...@@ -94,7 +99,7 @@ class QueryContext ...@@ -94,7 +99,7 @@ class QueryContext
* *
* @return array * @return array
* @throws PayException * @throws PayException
* @author helei *
*/ */
public function query(array $data) public function query(array $data)
{ {
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-27 10:36 * @createTime: 2016-07-27 10:36
* @description: * @description:
*/ */
......
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/28 * Date: 2017/4/28
* Time: 下午3:14 * Time: 下午3:14
*/ */
......
...@@ -27,7 +27,7 @@ class MiRefund extends MiBaseStrategy ...@@ -27,7 +27,7 @@ class MiRefund extends MiBaseStrategy
/** /**
* 返回退款的url * 返回退款的url
* @return null|string * @return null|string
* @author helei *
*/ */
protected function getReqUrl() protected function getReqUrl()
{ {
......
<?php
/**
*
* @createTime: 2019-03-24 22:42
* @description: 退款
*/
namespace Payment\Query\Sw;
use Payment\Common\Sw\Data\BackRefundData;
use Payment\Common\Sw\Data\Query\RefundData;
use Payment\Common\Sw\SwBaseStrategy;
use Payment\Common\SwConfig;
/**
* 需要商户当前账户内有大于退款金额的余额,否则会造成余额不足,退款失败;
* 限支付30天内退款,超过30天,不能进行退款操作(具体退款限制时间由通道决定)。
*
* Class SwRefund
* @package Payment\Query\Sw
*/
class SwRefund extends SwBaseStrategy
{
/**
* 返回查询订单的数据
*
*/
public function getBuildDataClass()
{
return RefundData::class;
}
/**
* 返回微信查询的url
* @return string
*
*/
protected function getReqUrl()
{
return SwConfig::REFUND_URL;
}
/**
* 处理通知的返回数据
* @param array $ret
* @return mixed
*
*/
protected function retData(array $ret)
{
$back = new BackRefundData($this->config, $ret);
$backData = $back->getData();
// 移除sign
unset($backData['sign']);
return $backData;
}
}
...@@ -28,7 +28,7 @@ class TLRefund extends TLBaseStrategy ...@@ -28,7 +28,7 @@ class TLRefund extends TLBaseStrategy
/** /**
* 返回退款的url * 返回退款的url
* @return null|string * @return null|string
* @author helei *
*/ */
protected function getReqUrl() protected function getReqUrl()
{ {
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-27 10:51 * @createTime: 2016-07-27 10:51
* @description: * @description:
*/ */
...@@ -17,7 +17,7 @@ use Payment\Utils\Curl; ...@@ -17,7 +17,7 @@ use Payment\Utils\Curl;
* Class WxRefund * Class WxRefund
* 微信退款操作 * 微信退款操作
* @package Payment\Refund * @package Payment\Refund
* anthor helei *
*/ */
class WxRefund extends WxBaseStrategy class WxRefund extends WxBaseStrategy
{ {
...@@ -31,7 +31,7 @@ class WxRefund extends WxBaseStrategy ...@@ -31,7 +31,7 @@ class WxRefund extends WxBaseStrategy
* @param string $xml * @param string $xml
* @param string $url * @param string $url
* @return array * @return array
* @author helei *
*/ */
protected function curlPost($xml, $url) protected function curlPost($xml, $url)
{ {
...@@ -52,7 +52,7 @@ class WxRefund extends WxBaseStrategy ...@@ -52,7 +52,7 @@ class WxRefund extends WxBaseStrategy
* 处理退款的返回数据 * 处理退款的返回数据
* @param array $ret * @param array $ret
* @return mixed * @return mixed
* @author helei *
*/ */
protected function retData(array $ret) protected function retData(array $ret)
{ {
...@@ -84,7 +84,7 @@ class WxRefund extends WxBaseStrategy ...@@ -84,7 +84,7 @@ class WxRefund extends WxBaseStrategy
* 处理返回的数据 * 处理返回的数据
* @param array $data * @param array $data
* @return array * @return array
* @author helei *
*/ */
protected function createBackData(array $data) protected function createBackData(array $data)
{ {
...@@ -118,7 +118,7 @@ class WxRefund extends WxBaseStrategy ...@@ -118,7 +118,7 @@ class WxRefund extends WxBaseStrategy
/** /**
* 返回退款的url * 返回退款的url
* @return null|string * @return null|string
* @author helei *
*/ */
protected function getReqUrl() protected function getReqUrl()
{ {
......
...@@ -9,6 +9,7 @@ namespace Payment; ...@@ -9,6 +9,7 @@ namespace Payment;
use Payment\Common\BaseStrategy; use Payment\Common\BaseStrategy;
use Payment\Common\PayException; use Payment\Common\PayException;
use Payment\Query\Sw\SwRefund;
use Payment\Refund\AliRefund; use Payment\Refund\AliRefund;
use Payment\Refund\CmbRefund; use Payment\Refund\CmbRefund;
use Payment\Refund\MiRefund; use Payment\Refund\MiRefund;
...@@ -31,7 +32,7 @@ class RefundContext ...@@ -31,7 +32,7 @@ class RefundContext
* *
* @param array $config 配置文件 * @param array $config 配置文件
* @throws PayException * @throws PayException
* @author helei *
*/ */
public function initRefund($channel, array $config) public function initRefund($channel, array $config)
{ {
...@@ -52,8 +53,11 @@ class RefundContext ...@@ -52,8 +53,11 @@ class RefundContext
case Config::MI_REFUND: case Config::MI_REFUND:
$this->refund = new MiRefund($config); $this->refund = new MiRefund($config);
break; break;
case Config::SW_REFUND:
$this->refund = new SwRefund($config);
break;
default: default:
throw new PayException('当前仅支持:ALI WEIXIN CMB'); throw new PayException('当前仅支持:ALI WEIXIN CMB TLRefund MiRefund SwRefund');
} }
} catch (PayException $e) { } catch (PayException $e) {
throw $e; throw $e;
...@@ -67,7 +71,7 @@ class RefundContext ...@@ -67,7 +71,7 @@ class RefundContext
* *
* @return array * @return array
* @throws PayException * @throws PayException
* @author helei *
*/ */
public function refund(array $data) public function refund(array $data)
{ {
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-27 15:28 * @createTime: 2016-07-27 15:28
* @description: 支付宝批量付款接口 * @description: 支付宝批量付款接口
*/ */
...@@ -43,7 +43,7 @@ class AliTransfer extends AliBaseStrategy ...@@ -43,7 +43,7 @@ class AliTransfer extends AliBaseStrategy
* 处理返回的数据 * 处理返回的数据
* @param array $data * @param array $data
* @return array * @return array
* @author helei *
*/ */
protected function createBackData(array $data) protected function createBackData(array $data)
{ {
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-27 15:43 * @createTime: 2016-07-27 15:43
* @description: * @description:
*/ */
...@@ -17,7 +17,7 @@ use Payment\Utils\Curl; ...@@ -17,7 +17,7 @@ use Payment\Utils\Curl;
* 微信企业付款接口 * 微信企业付款接口
* Class WxTransfer * Class WxTransfer
* @package Payment\Trans * @package Payment\Trans
* anthor helei *
*/ */
class WxTransfer extends WxBaseStrategy class WxTransfer extends WxBaseStrategy
{ {
...@@ -39,7 +39,7 @@ class WxTransfer extends WxBaseStrategy ...@@ -39,7 +39,7 @@ class WxTransfer extends WxBaseStrategy
* @param string $xml * @param string $xml
* @param string $url * @param string $url
* @return array * @return array
* @author helei *
*/ */
protected function curlPost($xml, $url) protected function curlPost($xml, $url)
{ {
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-07-27 15:40 * @createTime: 2016-07-27 15:40
* @description: * @description:
*/ */
...@@ -27,7 +27,7 @@ class TransferContext ...@@ -27,7 +27,7 @@ class TransferContext
* *
* @param array $config 配置文件 * @param array $config 配置文件
* @throws PayException * @throws PayException
* @author helei *
*/ */
public function initTransfer($channel, array $config) public function initTransfer($channel, array $config)
{ {
...@@ -54,7 +54,7 @@ class TransferContext ...@@ -54,7 +54,7 @@ class TransferContext
* *
* @return array * @return array
* @throws PayException * @throws PayException
* @author helei *
*/ */
public function transfer(array $data) public function transfer(array $data)
{ {
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-06-07 21:01 * @createTime: 2016-06-07 21:01
* @description: 常用的数组处理工具 * @description: 常用的数组处理工具
* @link https://github.com/helei112g/payment/tree/paymentv2 * @link https://github.com/helei112g/payment/tree/paymentv2
...@@ -15,7 +15,7 @@ class ArrayUtil ...@@ -15,7 +15,7 @@ class ArrayUtil
* 移除空值的key * 移除空值的key
* @param $para * @param $para
* @return array * @return array
* @author helei *
*/ */
public static function paraFilter($para) public static function paraFilter($para)
{ {
...@@ -71,7 +71,7 @@ class ArrayUtil ...@@ -71,7 +71,7 @@ class ArrayUtil
* 对输入的数组进行字典排序 * 对输入的数组进行字典排序
* @param array $param 需要排序的数组 * @param array $param 需要排序的数组
* @return array * @return array
* @author helei *
*/ */
public static function arraySort(array $param) public static function arraySort(array $param)
{ {
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-06-07 19:38 * @createTime: 2016-06-07 19:38
* @description: 一个轻量级的网络操作类,实现GET、POST、UPLOAD、DOWNLOAD常用操作,支持链式写法。 * @description: 一个轻量级的网络操作类,实现GET、POST、UPLOAD、DOWNLOAD常用操作,支持链式写法。
* @link https://github.com/helei112g/PHP-Curl * @link https://github.com/helei112g/PHP-Curl
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-06-08 13:02 * @createTime: 2016-06-08 13:02
* @description: 数据解析的工具类,主要处理,xml到数组 数组到xml的转化 * @description: 数据解析的工具类,主要处理,xml到数组 数组到xml的转化
* @link https://github.com/helei112g/payment/tree/paymentv2 * @link https://github.com/helei112g/payment/tree/paymentv2
......
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 2017/4/28 * Date: 2017/4/28
* Time: 下午3:25 * Time: 下午3:25
*/ */
...@@ -21,7 +21,7 @@ class Rc4Encrypt ...@@ -21,7 +21,7 @@ class Rc4Encrypt
/** /**
* 设置key * 设置key
* @param $key * @param $key
* @author helei *
*/ */
public function setKey($key) public function setKey($key)
{ {
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2017-03-07 09:29 * @createTime: 2017-03-07 09:29
* @description: rsa2加密算法 * @description: rsa2加密算法
* @link https://github.com/helei112g/payment/tree/paymentv2 * @link https://github.com/helei112g/payment/tree/paymentv2
...@@ -21,7 +21,7 @@ class Rsa2Encrypt ...@@ -21,7 +21,7 @@ class Rsa2Encrypt
/** /**
* 设置key * 设置key
* @param $key * @param $key
* @author helei *
*/ */
public function setKey($key) public function setKey($key)
{ {
...@@ -33,7 +33,7 @@ class Rsa2Encrypt ...@@ -33,7 +33,7 @@ class Rsa2Encrypt
* @param string $data 签名的数组 * @param string $data 签名的数组
* @throws \Exception * @throws \Exception
* @return string * @return string
* @author helei *
*/ */
public function encrypt($data) public function encrypt($data)
{ {
...@@ -59,7 +59,7 @@ class Rsa2Encrypt ...@@ -59,7 +59,7 @@ class Rsa2Encrypt
* @param string $content 需要解密的内容,密文 * @param string $content 需要解密的内容,密文
* @throws \Exception * @throws \Exception
* @return string * @return string
* @author helei *
*/ */
public function decrypt($content) public function decrypt($content)
{ {
...@@ -94,7 +94,7 @@ class Rsa2Encrypt ...@@ -94,7 +94,7 @@ class Rsa2Encrypt
* @param string $sign 要校对的的签名结果 * @param string $sign 要校对的的签名结果
* @throws \Exception * @throws \Exception
* @return bool * @return bool
* @author helei *
*/ */
public function rsaVerify($data, $sign) public function rsaVerify($data, $sign)
{ {
......
<?php <?php
/** /**
* @author: helei *
* @createTime: 2016-06-08 16:29 * @createTime: 2016-06-08 16:29
* @description: rsa加密算法 * @description: rsa加密算法
* @link https://github.com/helei112g/payment/tree/paymentv2 * @link https://github.com/helei112g/payment/tree/paymentv2
...@@ -21,7 +21,7 @@ class RsaEncrypt ...@@ -21,7 +21,7 @@ class RsaEncrypt
/** /**
* 设置key * 设置key
* @param $key * @param $key
* @author helei *
*/ */
public function setKey($key) public function setKey($key)
{ {
...@@ -33,7 +33,7 @@ class RsaEncrypt ...@@ -33,7 +33,7 @@ class RsaEncrypt
* @param string $data 签名的数组 * @param string $data 签名的数组
* @throws \Exception * @throws \Exception
* @return string * @return string
* @author helei *
*/ */
public function encrypt($data) public function encrypt($data)
{ {
...@@ -59,7 +59,7 @@ class RsaEncrypt ...@@ -59,7 +59,7 @@ class RsaEncrypt
* @param string $content 需要解密的内容,密文 * @param string $content 需要解密的内容,密文
* @throws \Exception * @throws \Exception
* @return string * @return string
* @author helei *
*/ */
public function decrypt($content) public function decrypt($content)
{ {
...@@ -91,7 +91,7 @@ class RsaEncrypt ...@@ -91,7 +91,7 @@ class RsaEncrypt
* @param string $sign 要校对的的签名结果 * @param string $sign 要校对的的签名结果
* @throws \Exception * @throws \Exception
* @return bool * @return bool
* @author helei *
*/ */
public function rsaVerify($data, $sign) public function rsaVerify($data, $sign)
{ {
......
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: helei *
* Date: 16/7/31 * Date: 16/7/31
* Time: 上午8:12 * Time: 上午8:12
*/ */
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!