Commit 92425b2b by yeran

update 3.1.0

1 parent 5d36bb51
Showing with 691 additions and 159 deletions
# payment
> 支付工具包 v1.0 from riverslei/payment
\ No newline at end of file
> 支付工具包 v1.0 from riverslei/payment
> v 2.0
* 新增通联支付
> v3.0
* 新增Mi付通道
> v3.1
* 新增扫呗支付通道
* 优化业务逻辑、修复已知bug
\ No newline at end of file
<?php
/**
* @author: helei
*
* @createTime: 2016-08-01 11:37
* @description: 微信配置文件
*/
......
<?php
/**
* 手机app支付demo
* Created by PhpStorm.
* User: helei
* Date: 2017/4/30
* Time: 下午5:38
*/
require_once __DIR__ . '/../../autoload.php';
......
......@@ -2,7 +2,7 @@
/**
* 条码支付
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/30
* Time: 下午4:32
*/
......
<?php
/**
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/30
* Time: 下午4:29
*/
......
......@@ -2,7 +2,7 @@
/**
* 查询订单
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/30
* Time: 下午5:35
*/
......
......@@ -2,7 +2,7 @@
/**
* 查询订单退款状态
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/30
* Time: 下午5:55
*/
......
......@@ -2,7 +2,7 @@
/**
* 转账查询
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/30
* Time: 下午6:00
*/
......
......@@ -2,7 +2,7 @@
/**
* 退款操作
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/30
* Time: 下午5:43
*/
......
......@@ -2,7 +2,7 @@
/**
* 支付转账操作
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/30
* Time: 下午5:57
*/
......
......@@ -2,7 +2,7 @@
/**
* wap网站支付
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/30
* Time: 上午11:31
*/
......
......@@ -2,7 +2,7 @@
/**
* 电脑支付 即时到账接口
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/30
* Time: 下午4:34
*/
......
<?php
/**
* @author: helei
*
* @createTime: 2016-07-15 17:19
* @description:
*/
......
......@@ -2,7 +2,7 @@
/**
* 招商绑卡操作 签约
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/30
* Time: 下午1:39
*/
......
......@@ -2,7 +2,7 @@
/**
* 招商一网通支付
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/30
* Time: 上午11:55
*/
......
<?php
/**
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/30
* Time: 下午2:18
*/
......
......@@ -2,7 +2,7 @@
/**
* 招商一网通支付
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/30
* Time: 上午11:55
*/
......
<?php
/**
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/30
* Time: 下午2:29
*/
......
......@@ -2,7 +2,7 @@
/**
* 招商退款操作
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/30
* Time: 下午6:03
*/
......
......@@ -2,7 +2,7 @@
/**
* 招商一网通配置文件
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/27
* Time: 上午11:29
*/
......
<?php
/**
* @author: helei
*
* @createTime: 2016-08-01 11:37
* @description: 微信配置文件
*/
......
......@@ -2,7 +2,7 @@
/**
* 退款处理 金额必须是 3.01
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/30
* Time: 下午3:51
*/
......
<?php
/**
* 第三方支付回调处理
* @author: helei
*
* @createTime: 2016-07-25 15:57
* @description: 支付通知回调
*/
......
......@@ -3,7 +3,7 @@
use Payment\Notify\PayNotifyInterface;
use Payment\Config;
/**
* @author: helei
*
* @createTime: 2016-07-20 18:31
* @description:
*/
......@@ -11,7 +11,7 @@ use Payment\Config;
/**
* 客户端需要继承该接口,并实现这个方法,在其中实现对应的业务逻辑
* Class TestNotify
* anthor helei
*
*/
class TestNotify implements PayNotifyInterface
{
......
......@@ -2,7 +2,7 @@
/**
* 公众号支付
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/30
* Time: 下午3:33
*/
......
......@@ -2,7 +2,7 @@
/**
* 公众号支付
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/30
* Time: 下午3:33
*/
......
......@@ -2,7 +2,7 @@
/**
* 查询支付的订单
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/30
* Time: 下午3:43
*/
......
......@@ -2,7 +2,7 @@
/**
* 退款处理 金额必须是 3.01
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/30
* Time: 下午3:51
*/
......
......@@ -2,7 +2,7 @@
/**
* app支付
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/30
* Time: 上午11:50
*/
......
......@@ -2,7 +2,7 @@
/**
* 刷卡支付
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/30
* Time: 下午3:12
*/
......
......@@ -2,7 +2,7 @@
/**
* 公众号支付
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/30
* Time: 下午3:33
*/
......
......@@ -2,7 +2,7 @@
/**
* 公众号支付
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/30
* Time: 下午3:33
*/
......
......@@ -2,7 +2,7 @@
/**
* 微信扫码支付
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/30
* Time: 下午2:46
*/
......
......@@ -2,7 +2,7 @@
/**
* 查询支付的订单
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/30
* Time: 下午3:43
*/
......
......@@ -2,7 +2,7 @@
/**
* 查询退款订单
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/30
* Time: 下午3:43
*/
......
......@@ -2,7 +2,7 @@
/**
* 转账查询 没有沙箱模式
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/30
* Time: 下午3:48
*/
......
......@@ -2,7 +2,7 @@
/**
* 退款处理 金额必须是 3.01
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/30
* Time: 下午3:51
*/
......
<?php
/**
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/30
* Time: 下午4:13
*/
......
......@@ -2,7 +2,7 @@
/**
* 微信wap支付
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/30
* Time: 下午3:40
*/
......
<?php
/**
* @author: helei
*
* @createTime: 2016-08-01 11:37
* @description: 微信配置文件
*/
......
......@@ -8,6 +8,7 @@
namespace Payment;
use Payment\Charge\MiPay\MiCancel;
use Payment\Charge\Sw\SwCancel;
use Payment\Charge\TLpay\TLCancel;
use Payment\Common\BaseStrategy;
use Payment\Common\PayException;
......@@ -46,6 +47,9 @@ class CancelContext
case Config::MI_CHANNEL_LITE:
$this->cancelHandler = new MiCancel($config);
break;
case Config::SW_CHARGE:
$this->cancelHandler = new SwCancel($config);
break;
default:
throw new PayException('当前仅支持:通联支付平台');
}
......
<?php
/**
* @author: helei
*
* @createTime: 2016-07-14 18:20
* @description: 支付宝移动支付接口
* @link https://github.com/helei112g/payment/tree/paymentv2
......@@ -20,7 +20,7 @@ class AliAppCharge extends AliBaseStrategy
/**
* 获取支付对应的数据完成类
* @return string
* @author helei
*
*/
public function getBuildDataClass()
{
......
......@@ -47,7 +47,7 @@ class AliBarCharge extends AliBaseStrategy
*
* @throws PayException
* @return string 可生产二维码的uri
* @author helei
*
*/
protected function retData(array $ret)
{
......
......@@ -30,7 +30,7 @@ class AliQrCharge extends AliBaseStrategy
*
* @throws PayException
* @return string 可生产二维码的uri
* @author helei
*
*/
protected function retData(array $ret)
{
......
<?php
/**
* @author: helei
*
* @createTime: 2016-07-14 18:19
* @description: 支付宝 手机网站支付 接口
* @link https://github.com/helei112g/payment/tree/paymentv2
......@@ -19,7 +19,7 @@ class AliWapCharge extends AliBaseStrategy
/**
* 获取支付对应的数据完成类
* @return string
* @author helei
*
*/
public function getBuildDataClass()
{
......
<?php
/**
* @author: helei
*
* @createTime: 2016-07-14 17:56
* @description: 支付宝 即时到账 接口
* @link https://github.com/helei112g/payment/tree/paymentv2
......@@ -18,7 +18,7 @@ class AliWebCharge extends AliBaseStrategy
/**
* 获取支付对应的数据完成类
* @return string
* @author helei
*
*/
public function getBuildDataClass()
{
......
......@@ -8,7 +8,7 @@ use Payment\Common\Cmb\Data\Charge\ChargeData;
/**
* 一网通支付API 接口
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/27
* Time: 下午12:36
*/
......
......@@ -21,7 +21,7 @@ class MiCancel extends MiBaseStrategy{
/**
* 交易撤销 的url
* @return null|string
* @author helei
*
*/
protected function getReqUrl()
{
......@@ -31,7 +31,7 @@ class MiCancel extends MiBaseStrategy{
/**
* 获取交易退款对应的数据完成类
* @return MiCancelData
* @author helei
*
*/
public function getBuildDataClass()
{
......
......@@ -41,7 +41,7 @@ class MiLiteCharge extends MiBaseStrategy
* 'paySign' => '', // 签名
* ];
* ```
* @author helei
*
*/
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{
/**
* 交易撤销 的url
* @return null|string
* @author helei
*
*/
protected function getReqUrl()
{
......@@ -31,7 +31,7 @@ class TLCancel extends TLBaseStrategy{
/**
* 获取交易退款对应的数据完成类
* @return TLCancelData
* @author helei
*
*/
public function getBuildDataClass()
{
......
<?php
/**
* @author: helei
*
* @createTime: 2016-07-14 18:28
* @description: 微信 公众号 支付接口
* @link https://github.com/helei112g/payment/tree/paymentv2
......@@ -19,7 +19,7 @@ use Payment\Common\TLpay\TLBaseStrategy;
* 通联支付-微信小程序支付
*
* @package Payment\Charge\TLpay
* anthor helei
*
*/
class TLLiteCharge extends TLBaseStrategy
{
......@@ -45,7 +45,7 @@ class TLLiteCharge extends TLBaseStrategy
* 'paySign' => '', // 签名
* ];
* ```
* @author helei
*
*/
protected function retData(array $ret)
{
......
<?php
/**
* @author: helei
*
* @createTime: 2016-07-14 17:56
* @description: 微信 app 支付接口
* @link https://github.com/helei112g/payment/tree/paymentv2
......@@ -9,7 +9,7 @@
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\WxBaseStrategy;
......@@ -38,11 +38,11 @@ class WxAppCharge extends WxBaseStrategy
* 'sign' => '', // 签名
* ];
* ```
* @author helei
*
*/
protected function retData(array $ret)
{
$back = new BackAppChargeData($this->config, $ret);
$back = new BackLiteChargeData($this->config, $ret);
$back->setSign();
$backData = $back->getData();
......
<?php
/**
* @author: helei
*
* @createTime: 2017-03-06 18:29
* @description: 微信 刷卡支付 对应支付宝的条码支付
* @link https://github.com/helei112g/payment/tree/paymentv2
......@@ -9,7 +9,7 @@
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\WxConfig;
......@@ -17,7 +17,7 @@ class WxBarCharge extends WxBaseStrategy
{
public function getBuildDataClass()
{
return BarChargeData::class;
return ScanChargeData::class;
}
/**
......
<?php
/**
* @author: helei
*
* @createTime: 2016-07-14 18:28
* @description: 微信 公众号 支付接口
* @link https://github.com/helei112g/payment/tree/paymentv2
* @link https://helei112g.github.io/
*/
namespace Payment\Charge\Wx;
......@@ -19,7 +17,7 @@ use Payment\Common\Weixin\WxBaseStrategy;
* 微信公众号支付
*
* @package Payment\Charge\Weixin
* anthor helei
*
*/
class WxPubCharge extends WxBaseStrategy
{
......@@ -45,7 +43,7 @@ class WxPubCharge extends WxBaseStrategy
* 'paySign' => '', // 签名
* ];
* ```
* @author helei
*
*/
protected function retData(array $ret)
{
......
<?php
/**
* @author: helei
*
* @createTime: 2016-07-14 18:29
* @description: 微信 扫码支付 主要用于网站上
* @link https://github.com/helei112g/payment/tree/paymentv2
......@@ -24,7 +24,7 @@ class WxQrCharge extends WxBaseStrategy
* 处理扫码支付的返回值
* @param array $ret
* @return string 可生产二维码的uri
* @author helei
*
*/
protected function retData(array $ret)
{
......
<?php
/**
* Created by PhpStorm.
* User: helei
*
* Date: 2017/3/6
* Time: 下午5:44
*/
......
<?php
/**
* @author: helei
*
* @createTime: 2016-07-14 17:42
* @description: 暴露给客户端调用的接口
* @link https://github.com/helei112g/payment/tree/paymentv2
......@@ -17,6 +17,12 @@ use Payment\Charge\Ali\AliQrCharge;
use Payment\Charge\Cmb\CmbCharge;
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\Wx\WxAppCharge;
use Payment\Charge\Wx\WxBarCharge;
......@@ -32,7 +38,7 @@ use Payment\Common\PayException;
* 支付的上下文类
*
* @package Payment
* anthor helei
*
*/
class ChargeContext
{
......@@ -49,7 +55,6 @@ class ChargeContext
* - @see Config
* @param array $config 配置文件
* @throws PayException
* @author helei
*/
public function initCharge($channel, array $config)
{
......@@ -92,14 +97,35 @@ class ChargeContext
case Config::CMB_CHANNEL_APP:
$this->channel = new CmbCharge($config);
break;
case Config::TL_CHANNEL_LITE: //通联支付
$this->channel = new TLLiteCharge($config);
break;
case Config::MI_CHANNEL_LITE: //米付小程序通道
$this->channel = new MiLiteCharge($config);
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:
throw new PayException('当前支持:支付宝 微信 招商一网通 通联支付 米付');
}
......@@ -125,7 +151,7 @@ class ChargeContext
*
* @return array
* @throws PayException
* @author helei
*
*/
public function charge(array $data)
{
......
......@@ -36,6 +36,8 @@ class Cancel
Config::TL_CHANNEL_LITE,//通联支付
Config::MI_CHANNEL_LITE, //米付
Config::SW_CHARGE,//扫呗支付退款
];
/**
......
......@@ -25,12 +25,20 @@ class Charge
Config::WX_CHANNEL_LITE,// 微信小程序支付
Config::CMB_CHANNEL_APP,// 招行一网通
'applepay_upacp',// Apple Pay
Config::APPLE_PAY,// Apple Pay
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 @@
namespace Payment\Client;
use Payment\CancelContext;
use Payment\CloseContext;
use Payment\Common\PayException;
use Payment\Config;
class OrderCancel {
/**
* 关闭订单
*
* Class Close
* @package Payment\Client
*/
class Close {
private static $supportChannel = [
Config::TL_CHANNEL_LITE,
Config::SW_CHARGE,//扫呗支付关闭订单
];
/**
* @var CancelContext
* @var CloseContext
*/
protected static $instance;
protected static function getInstance($channel, $config)
{
protected static function getInstance($channel, $config){
if (is_null(self::$instance)) {
static::$instance = new CancelContext();
static::$instance = new CloseContext();
try {
static::$instance->initCancelHandler($channel, $config);
static::$instance->initCloseHandler($channel, $config);
} catch (PayException $e) {
throw $e;
}
......@@ -58,7 +64,7 @@ class OrderCancel {
try {
$instance = self::getInstance($channel, $config);
$ret = $instance->cancel($metadata);
$ret = $instance->close($metadata);
} catch (PayException $e) {
throw $e;
}
......
<?php
/**
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/28
* Time: 上午10:44
*/
......
......@@ -22,6 +22,8 @@ class Notify
Config::TL_CHARGE,//通联支付
Config::MI_CHARGE,//米付
Config::SW_CHARGE,//扫呗
];
/**
......
......@@ -36,6 +36,8 @@ class Query
Config::TL_QUERY,//通联支付
Config::MI_QUERY,//米付
Config::SW_QUERY,//扫呗
];
/**
......
......@@ -31,6 +31,8 @@ class Refund
Config::TL_REFUND,//通联支付
Config::MI_REFUND,//米付
Config::SW_REFUND,//扫呗
];
/**
......
<?php
/**
* Created by PhpStorm.
* User: helei
*
* Date: 2017/3/7
* 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
/**
* @author: helei
*
* @createTime: 2016-07-15 17:10
* @description: 支付宝支付接口的基类。
* @link https://github.com/helei112g/payment/tree/paymentv2
......@@ -111,7 +111,7 @@ abstract class AliBaseStrategy implements BaseStrategy
* 处理支付宝的返回值并返回给客户端
* @param array $data
* @return string|array
* @author helei
*
*/
protected function retData(array $data)
{
......@@ -134,7 +134,7 @@ abstract class AliBaseStrategy implements BaseStrategy
* 返回统一的交易状态 做一些转化,方便处理
* @param $status
* @return string
* @author helei
*
*/
protected function getTradeStatus($status)
{
......@@ -156,7 +156,7 @@ abstract class AliBaseStrategy implements BaseStrategy
* @param array $data
* @param string $sign 支付宝返回的签名结果
* @return bool
* @author helei
*
*/
protected function verifySign(array $data, $sign)
{
......
<?php
/**
* @author: helei
*
* @createTime: 2016-07-15 17:28
* @description: 支付宝相关数据的基类
* @link https://github.com/helei112g/payment/tree/paymentv2
......@@ -33,7 +33,7 @@ use Payment\Utils\RsaEncrypt;
* @property string $partner 合作id
*
* @package Payment\Charge\Ali\Data
* anthor helei
*
*/
abstract class AliBaseData extends BaseData
{
......@@ -51,7 +51,7 @@ abstract class AliBaseData extends BaseData
* 签名算法实现
* @param string $signStr
* @return string
* @author helei
*
*/
protected function makeSign($signStr)
{
......
<?php
/**
* @author: helei
*
* @createTime: 2016-07-25 14:49
* @description:
*/
......
<?php
/**
* Created by PhpStorm.
* User: helei <dayugog@gmail.com>
* <dayugog@gmail.com>
* Date: 2016/12/28
* Time: 20:24
*/
......
<?php
/**
* @author: helei
*
* @createTime: 2016-07-20 14:33
* @description:
*/
......@@ -27,14 +27,14 @@ use Payment\Utils\ArrayUtil;
* @property string $store_id 商户门店编号
*
* @package Payment\Common\Ali\Data\Charge
* anthor helei
*
*/
abstract class ChargeBaseData extends AliBaseData
{
/**
* 构建 APP支付 加密数据
* @author helei
*
*/
protected function buildData()
{
......@@ -70,7 +70,7 @@ abstract class ChargeBaseData extends AliBaseData
*
* 如果输入参数不符合规范,直接抛出异常
*
* @author helei
*
*/
protected function checkDataParam()
{
......
<?php
/**
* Created by PhpStorm.
* User: helei <dayugog@gmail.com>
* <dayugog@gmail.com>
* Date: 2016/12/28
* Time: 20:24
*/
......
<?php
/**
* @author: helei
*
* @createTime: 2016-07-22 17:02
* @description:
*/
......
<?php
/**
* @author: helei
*
* @createTime: 2016-07-15 17:28
* @description: 即时到帐 接口的数据处理类
* @link https://github.com/helei112g/payment/tree/paymentv2
......@@ -19,7 +19,7 @@ use Payment\Utils\ArrayUtil;
* @property integer $qr_mod
*
* @package Payment\Charge\Ali\Data
* anthor helei
*
*/
class WebChargeData extends ChargeBaseData
{
......
<?php
/**
* @author: helei
*
* @createTime: 2017-03-06 22:32
* @description:
*/
......@@ -17,13 +17,13 @@ use Payment\Utils\ArrayUtil;
* @property string $out_trade_no 商户系统内部的订单号
*
* @package Payment\Common\Ali\Data\Query
* anthor helei
*
*/
class ChargeQueryData extends QueryBaseData
{
/**
* 检查参数
* @author helei
*
*/
protected function checkDataParam()
{
......
<?php
/**
* Created by PhpStorm.
* User: helei
*
* Date: 2017/3/6
* Time: 下午10:37
*/
......@@ -16,7 +16,7 @@ abstract class QueryBaseData extends AliBaseData
{
/**
* 构建 APP支付 加密数据
* @author helei
*
*/
protected function buildData()
{
......
<?php
/**
* Created by PhpStorm.
* User: helei
*
* Date: 2017/3/7
* Time: 下午1:45
*/
......
<?php
/**
* Created by PhpStorm.
* User: helei
*
* Date: 2017/3/7
* Time: 下午3:59
*/
......
<?php
/**
* @author: helei
*
* @createTime: 2016-07-26 18:18
* @description:
*/
......@@ -23,14 +23,14 @@ use Payment\Utils\ArrayUtil;
* @property string $store_id 商户门店编号
*
* @package Payment\Common\Ali\Data
* anthor helei
*
*/
class RefundData extends AliBaseData
{
/**
* 检查退款数据是否正常
* @author helei
*
*/
protected function checkDataParam()
{
......
<?php
/**
* @author: helei
*
* @createTime: 2016-07-27 13:05
* @description:
*/
......@@ -27,13 +27,13 @@ use Payment\Utils\ArrayUtil;
* @property string $remark 转账备注 当付款方为企业账户,且转账金额达到(大于等于)50000元,remark不能为空
*
* @package Payment\Common\Ali\Data
* anthor helei
*
*/
class TransData extends AliBaseData
{
/**
* 检查参数是否合法
* @author helei
*
*/
protected function checkDataParam()
{
......
<?php
/**
* @author: helei
*
* @createTime: 2016-07-15 14:56
* @description: 支付宝配置文件 所有支付的配置文件,均需要继承 ConfigInterface 这个接口
* @link https://github.com/helei112g/payment/tree/paymentv2
......@@ -94,7 +94,7 @@ final class AliConfig extends ConfigInterface
* 检查传入的配置文件信息是否正确
* @param array $config
* @throws PayException
* @author helei
*
*/
private function initConfig(array $config)
{
......
<?php
/**
* @author: helei
* @createTime: 2016-07-28 18:05
*
* @description: 支付相关接口的数据基类
*/
......@@ -13,12 +13,7 @@ use Payment\Utils\ArrayUtil;
/**
* Class BaseData
* 支付相关接口的数据基类
* @package Payment\Common\Weixin\Dataa
*
* @property string $limitPay 用户不可用指定渠道支付
* @property boolean $returnRaw 是否返回原始数据,只进行签名检查
* @property string $useSandbox 是否使用的测试模式
* @property string $signType 签名算法
* @package Payment\Common\Sw\Data
*
*/
abstract class BaseData
......@@ -60,6 +55,8 @@ abstract class BaseData
$this->channel = Config::TL_PAY;
} elseif ($config instanceof MiConfig) {
$this->channel = Config::MI_PAY;
}elseif ($config instanceof SwConfig) {
$this->channel = Config::SW_PAY;
}
$this->data = array_merge($config->toArray(), $reqData);//配置信息合并
......@@ -76,7 +73,7 @@ abstract class BaseData
* 获取变量,通过魔术方法
* @param string $name
* @return null|string
* @author helei
*
*/
public function __get($name)
{
......@@ -91,7 +88,7 @@ abstract class BaseData
* 设置变量
* @param $name
* @param $value
* @author helei
*
*/
public function __set($name, $value)
{
......@@ -100,7 +97,7 @@ abstract class BaseData
/**
* 设置签名
* @author helei
*
*/
public function setSign()
{
......@@ -128,7 +125,15 @@ abstract class BaseData
$this->cacertPath = "{$basePath}mipay".DIRECTORY_SEPARATOR."ldy_private_key.pem";
$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::arraySort($values);
$signStr = ArrayUtil::createLinkstring($values);
......@@ -139,7 +144,7 @@ abstract class BaseData
/**
* 返回处理之后的数据
* @return array
* @author helei
*
*/
public function getData()
{
......
<?php
/**
* @author: helei
*
* @createTime: 2016-07-28 16:45
* @description: 所有的策略类接口
*/
......@@ -13,14 +13,14 @@ interface BaseStrategy
* 处理具体的业务
* @param array $data
* @return mixed
* @author helei
*
*/
public function handle(array $data);
/**
* 获取支付对应的数据完成类
* @return BaseData
* @author helei
*
*/
public function getBuildDataClass();
}
......@@ -11,7 +11,7 @@ use Payment\Utils\Curl;
/**
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/27
* Time: 下午12:36
*/
......@@ -73,7 +73,7 @@ abstract class CmbBaseStrategy implements BaseStrategy
* 处理微信的返回值并返回给客户端
* @param array $ret
* @return mixed
* @author helei
*
*/
protected function retData(array $ret)
{
......@@ -92,7 +92,7 @@ abstract class CmbBaseStrategy implements BaseStrategy
* @param string $json
* @return mixed
* @throws PayException
* @author helei
*
*/
protected function sendReq($json)
{
......@@ -116,7 +116,7 @@ abstract class CmbBaseStrategy implements BaseStrategy
* @param string $json
* @param string $url
* @return array
* @author helei
*
*/
protected function curlPost($json, $url)
{
......@@ -130,7 +130,7 @@ abstract class CmbBaseStrategy implements BaseStrategy
* 返回统一的交易状态 做一些转化,方便处理
* @param $status
* @return string
* @author helei
*
*/
protected function getTradeStatus($status)
{
......
<?php
/**
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/28
* Time: 上午10:48
*/
......
......@@ -9,7 +9,7 @@ use Payment\Config;
/**
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/27
* Time: 下午1:01
*
......
<?php
/**
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/27
* Time: 下午1:00
*/
......
<?php
/**
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/29
* Time: 上午9:52
*/
......
......@@ -6,7 +6,7 @@ use Payment\Common\PayException;
/**
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/28
* Time: 下午12:52
*
......
<?php
/**
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/28
* Time: 下午5:23
*/
......
<?php
/**
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/28
* Time: 下午3:16
*/
......
<?php
/**
* Created by PhpStorm.
* User: helei
*
* Date: 2017/4/27
* Time: 上午11:28
*/
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!