Commit 60cc11a3 by zcb

联拓富支付接入

1 parent 693ba320
<?php
date_default_timezone_set('Asia/Shanghai');
require_once __DIR__.'/../../autoload.php';
//require_once __DIR__.'/common.php';
use Payment\Client\Cancel;
use Payment\Client\Close;
use Payment\Client\Query;
use Payment\Client\Refund;
use Payment\Common\PayException;
use Payment\Client\Charge;
use Payment\Config;
$config = [
'ltf_appid' => 'EW_N3213842400',
'key' => '730ed24645b1a54e82a3d2bcff63db37',
'merchant_code' => 'EW_N5247492162',
// 'notify_url' => 'https://www.test.com/test/test.t',
// 'order_type' => 'WXPAY',
// 'trade_type' => 'MINIAPP',
// 'sub_appid' => 'wxd678efh567hg6787',
];
$payData = [
'out_trade_no' => '2019062017085196425851101912',
'refund_no' => '2019062017085196425851101912',
];
//2019062017085196425851101985
try{
$ret = Close::run(Config::LTF_CHARGE, $config, $payData);
}catch(PayException $e){
exit($e->errorMessage());
}
echo json_encode($ret, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
...@@ -8,78 +8,79 @@ ...@@ -8,78 +8,79 @@
namespace Payment; namespace Payment;
use Payment\Cancel\FuCancel; use Payment\Cancel\FuCancel;
use Payment\Charge\LTF\LTFCancel;
use Payment\Charge\MiPay\MiCancel; use Payment\Charge\MiPay\MiCancel;
use Payment\Charge\Sw\SwCancel; 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;
/** /**
* Class CancelContext * Class CancelContext
*
* @package Payment * @package Payment
*/ */
class CancelContext class CancelContext{
{
/**
* 退款的渠道
* @var BaseStrategy
*/
protected $cancelHandler;
/**
* 退款的渠道
*
* @var BaseStrategy
*/
protected $cancelHandler;
/** /**
* 设置对应的退款渠道 * 设置对应的退款渠道
* @param string $channel 退款渠道 *
* - @see Config * @param string $channel 退款渠道
* * - @param array $config 配置文件
* @param array $config 配置文件 * @throws PayException
* @throws PayException * @see Config
* @author yeran * @author yeran
*/ */
public function initCancelHandler($channel, array $config) public function initCancelHandler($channel, array $config){
{ try{
try { switch($channel){
switch ($channel) { case Config::TL_CHANNEL_LITE:
case Config::TL_CHANNEL_LITE: $this->cancelHandler = new TLCancel($config);
$this->cancelHandler = new TLCancel($config); break;
break; 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:
case Config::SW_CHARGE: $this->cancelHandler = new SwCancel($config);
$this->cancelHandler = new SwCancel($config); break;
break; case Config::FU_CHARGE:
case Config::FU_CHARGE: $this->cancelHandler = new FuCancel($config);
$this->cancelHandler = new FuCancel($config); break;
break; case Config::LTF_CHARGE:
default: $this->cancelHandler = new LTFCancel($config);
throw new PayException('当前仅支持:通联支付平台'); break;
} default:
} catch (PayException $e) { throw new PayException('当前仅支持:通联支付平台');
throw $e; }
} }catch(PayException $e){
} throw $e;
}
}
/** /**
* 通过环境类调用交易撤销操作 * 通过环境类调用交易撤销操作
* *
* @param array $data * @param array $data
* * @return array
* @return array * @throws PayException
* @throws PayException * @author yeran
* @author yeran */
*/ public function cancel(array $data){
public function cancel(array $data) if(!$this->cancelHandler instanceof BaseStrategy){
{ throw new PayException('请检查初始化是否正确');
if (!$this->cancelHandler instanceof BaseStrategy) { }
throw new PayException('请检查初始化是否正确');
}
try { try{
return $this->cancelHandler->handle($data); return $this->cancelHandler->handle($data);
} catch (PayException $e) { }catch(PayException $e){
throw $e; throw $e;
} }
} }
} }
<?php
namespace Payment\Charge\LTF;
use Payment\Common\BaseData;
use Payment\Common\LTFConfig;
use Payment\Common\LTFpay\Data\Charge\BarChargeData;
use Payment\Common\LTFpay\LTFBaseStrategy;
class LTFBarCharge extends LTFBaseStrategy{
/**
* 获取支付对应的数据完成类
*
* @return BaseData
*/
public function getBuildDataClass(){
// TODO: Implement getBuildDataClass() method.
return BarChargeData::class;
}
protected function getReqUrl($url = null){
return parent::getReqUrl($url??LTFConfig::MICROPAY_URL); // TODO: Change the autogenerated stub
}
}
<?php
namespace Payment\Charge\LTF;
use Payment\Common\BaseData;
use Payment\Common\LTFConfig;
use Payment\Common\LTFpay\Data\Cancel\CancelData;
use Payment\Common\LTFpay\LTFBaseStrategy;
class LTFCancel extends LTFBaseStrategy{
/**
* 获取支付对应的数据完成类
*
* @return BaseData
*/
public function getBuildDataClass(){
// TODO: Implement getBuildDataClass() method.
return CancelData::class;
}
protected function getReqUrl($url = null){
return parent::getReqUrl($url??LTFConfig::CANCEL_URL); // TODO: Change the autogenerated stub
}
}
<?php
namespace Payment\Charge\LTF;
use Payment\Common\BaseData;
use Payment\Common\LTFConfig;
use Payment\Common\LTFpay\Data\Cancel\CloseData;
use Payment\Common\LTFpay\LTFBaseStrategy;
class LTFClose extends LTFBaseStrategy{
/**
* 获取支付对应的数据完成类
*
* @return BaseData
*/
public function getBuildDataClass(){
// TODO: Implement getBuildDataClass() method.
return CloseData::class;
}
protected function getReqUrl($url = null){
return parent::getReqUrl($url??LTFConfig::CLOSE_URL); // TODO: Change the autogenerated stub
}
}
<?php
namespace Payment\Charge\LTF;
use Payment\Common\BaseData;
use Payment\Common\LTFConfig;
use Payment\Common\LTFpay\Data\Charge\LiteChargeData;
use Payment\Common\LTFpay\LTFBaseStrategy;
class LTFLiteCharge extends LTFBaseStrategy{
/**
* 获取支付对应的数据完成类
*
* @return BaseData
*/
public function getBuildDataClass(){
// TODO: Implement getBuildDataClass() method.
return LiteChargeData::class;
}
protected function getReqUrl($url = null){
return parent::getReqUrl($url??LTFConfig::SCANPAY_URL); // TODO: Change the autogenerated stub
}
}
<?php
namespace Payment\Charge\LTF;
use Payment\Common\BaseData;
use Payment\Common\LTFConfig;
use Payment\Common\LTFpay\Data\Charge\PayChargeData;
use Payment\Common\LTFpay\LTFBaseStrategy;
class LTFPayCharge extends LTFBaseStrategy{
/**
* 获取支付对应的数据完成类
*
* @return BaseData
*/
public function getBuildDataClass(){
// TODO: Implement getBuildDataClass() method.
return PayChargeData::class;
}
protected function getReqUrl($url = null){
return parent::getReqUrl($url??LTFConfig::PAY_URL); // TODO: Change the autogenerated stub
}
}
<?php
namespace Payment\Charge\LTF;
use Payment\Common\BaseData;
use Payment\Common\LTFConfig;
use Payment\Common\LTFpay\Data\Charge\PubChargeData;
use Payment\Common\LTFpay\LTFBaseStrategy;
class LTFPubCharge extends LTFBaseStrategy{
/**
* 获取支付对应的数据完成类
*
* @return BaseData
*/
public function getBuildDataClass(){
// TODO: Implement getBuildDataClass() method.
return PubChargeData::class;
}
protected function getReqUrl($url = null){
return parent::getReqUrl($url??LTFConfig::SCANPAY_URL); // TODO: Change the autogenerated stub
}
}
<?php
namespace Payment\Charge\LTF;
use Payment\Common\BaseData;
use Payment\Common\LTFConfig;
use Payment\Common\LTFpay\Data\Charge\ScanChargeData;
use Payment\Common\LTFpay\LTFBaseStrategy;
class LTFScanCharge extends LTFBaseStrategy{
/**
* 获取支付对应的数据完成类
*
* @return BaseData
*/
public function getBuildDataClass(){
// TODO: Implement getBuildDataClass() method.
return ScanChargeData::class;
}
protected function getReqUrl($url = null){
return parent::getReqUrl($url??LTFConfig::SCANPAY_URL); // TODO: Change the autogenerated stub
}
}
...@@ -18,6 +18,11 @@ use Payment\Charge\Cmb\CmbCharge; ...@@ -18,6 +18,11 @@ use Payment\Charge\Cmb\CmbCharge;
use Payment\Charge\Fu\FuBarCharge; use Payment\Charge\Fu\FuBarCharge;
use Payment\Charge\Fu\FuPubCharge; use Payment\Charge\Fu\FuPubCharge;
use Payment\Charge\Fu\FuScanCharge; use Payment\Charge\Fu\FuScanCharge;
use Payment\Charge\LTF\LTFBarCharge;
use Payment\Charge\LTF\LTFLiteCharge;
use Payment\Charge\LTF\LTFPayCharge;
use Payment\Charge\LTF\LTFPubCharge;
use Payment\Charge\LTF\LTFScanCharge;
use Payment\Charge\MiPay\MiLiteCharge; use Payment\Charge\MiPay\MiLiteCharge;
use Payment\Charge\Sw\SwBarCharge; use Payment\Charge\Sw\SwBarCharge;
use Payment\Charge\Sw\SwFaceCharge; use Payment\Charge\Sw\SwFaceCharge;
...@@ -144,8 +149,24 @@ class ChargeContext ...@@ -144,8 +149,24 @@ class ChargeContext
$this->channel = new FuBarCharge($config); $this->channel = new FuBarCharge($config);
break; break;
//联拓富
case Config::LTF_CHANNEL_PUB:
$this->channel = new LTFPubCharge($config);
break;
case Config::LTF_CHANNEL_LITE:
$this->channel = new LTFLiteCharge($config);
break;
case Config::LTF_CHANNEL_SCAN:
$this->channel = new LTFScanCharge($config);
break;
case Config::LTF_CHANNEL_BAR:
$this->channel= new LTFBarCharge($config);
break;
case Config::LTF_CHANNEL_PAY:
$this->channel=new LTFPayCharge($config);
break;
default: default:
throw new PayException('当前支持:支付宝、微信、招商一网通、通联支付、米付支付、扫呗支付、富友支付。'); throw new PayException('当前支持:支付宝、微信、招商一网通、通联支付、米付支付、扫呗支付、富友支付、联拓富。');
} }
} catch (PayException $e) { } catch (PayException $e) {
throw $e; throw $e;
......
...@@ -41,6 +41,7 @@ class Cancel ...@@ -41,6 +41,7 @@ class Cancel
Config::SW_CHARGE, //扫呗支付退款 Config::SW_CHARGE, //扫呗支付退款
Config::FU_CHARGE, //富友 Config::FU_CHARGE, //富友
Config::LTF_CHARGE,
]; ];
/** /**
...@@ -88,4 +89,4 @@ class Cancel ...@@ -88,4 +89,4 @@ class Cancel
return $ret; return $ret;
} }
} }
\ No newline at end of file
...@@ -42,6 +42,12 @@ class Charge ...@@ -42,6 +42,12 @@ class Charge
Config::FU_CHANNEL_SCAN, Config::FU_CHANNEL_SCAN,
Config::FU_CHANNEL_BAR, Config::FU_CHANNEL_BAR,
Config::LTF_CHANNEL_PUB,
Config::LTF_CHANNEL_LITE,
Config::LTF_CHANNEL_SCAN,
Config::LTF_CHANNEL_BAR,
Config::LTF_CHANNEL_PAY,
]; ];
/** /**
...@@ -89,4 +95,4 @@ class Charge ...@@ -89,4 +95,4 @@ class Charge
return $ret; return $ret;
} }
} }
\ No newline at end of file
...@@ -17,6 +17,7 @@ class Close { ...@@ -17,6 +17,7 @@ class Close {
private static $supportChannel = [ private static $supportChannel = [
Config::SW_CHARGE, //扫呗支付关闭订单 Config::SW_CHARGE, //扫呗支付关闭订单
Config::FU_CHARGE, //富友支付关闭订单 Config::FU_CHARGE, //富友支付关闭订单
Config::LTF_CHARGE,//联拓富支付关闭订单
]; ];
/** /**
...@@ -64,4 +65,4 @@ class Close { ...@@ -64,4 +65,4 @@ class Close {
return $ret; return $ret;
} }
} }
\ No newline at end of file
...@@ -27,6 +27,8 @@ class Notify ...@@ -27,6 +27,8 @@ class Notify
Config::SW_CHARGE,//扫呗 Config::SW_CHARGE,//扫呗
Config::FU_CHARGE, //富友 Config::FU_CHARGE, //富友
Config::LTF_CHARGE, //联拓富
]; ];
/** /**
...@@ -92,4 +94,4 @@ class Notify ...@@ -92,4 +94,4 @@ class Notify
throw $e; throw $e;
} }
} }
} }
\ No newline at end of file
...@@ -42,6 +42,8 @@ class Query ...@@ -42,6 +42,8 @@ class Query
Config::FU_CHARGE, Config::FU_CHARGE,
Config::FU_REFUND, Config::FU_REFUND,
Config::LTF_CHARGE,
Config::LTF_REFUND,
]; ];
/** /**
......
...@@ -35,6 +35,7 @@ class Refund ...@@ -35,6 +35,7 @@ class Refund
Config::SW_REFUND,//扫呗 Config::SW_REFUND,//扫呗
Config::FU_REFUND, //富友 Config::FU_REFUND, //富友
Config::LTF_REFUND,
]; ];
/** /**
...@@ -74,4 +75,4 @@ class Refund ...@@ -74,4 +75,4 @@ class Refund
return $ret; return $ret;
} }
} }
\ No newline at end of file
...@@ -3,68 +3,71 @@ ...@@ -3,68 +3,71 @@
namespace Payment; namespace Payment;
use Payment\Charge\Fu\FuClose; use Payment\Charge\Fu\FuClose;
use Payment\Charge\LTF\LTFClose;
use Payment\Charge\Sw\SwClose; use Payment\Charge\Sw\SwClose;
use Payment\Common\BaseStrategy; use Payment\Common\BaseStrategy;
use Payment\Common\PayException; use Payment\Common\PayException;
/** /**
* Class CloseContext * Class CloseContext
*
* @package Payment * @package Payment
*/ */
class CloseContext class CloseContext{
{
/**
* 关闭订单的渠道
* @var BaseStrategy
*/
protected $closeHandler;
/** /**
* 设置对应的关闭订单渠道 * 关闭订单的渠道
* @param string $channel 关闭订单渠道 *
* - @see Config * @var BaseStrategy
* */
* @param array $config 配置文件 protected $closeHandler;
* @throws PayException
* @author yeran
*/
public function initCloseHandler($channel, array $config)
{
try {
switch ($channel) {
case Config::SW_CHARGE:
$this->closeHandler = new SwClose($config);
break;
case Config::FU_CHARGE:
$this->closeHandler = new FuClose($config);
break;
default:
throw new PayException('当前仅支持:SW_CHARGE、FU_CHARGE');
}
} catch (PayException $e) {
throw $e;
}
}
/** /**
* 通过环境类调用交易关闭操作 * 设置对应的关闭订单渠道
* *
* @param array $data * @param string $channel 关闭订单渠道
* * - @param array $config 配置文件
* @return array * @throws PayException
* @throws PayException * @see Config
* @author yeran * @author yeran
*/ */
public function close(array $data) public function initCloseHandler($channel, array $config){
{ try{
if (!$this->closeHandler instanceof BaseStrategy) { switch($channel){
throw new PayException('请检查初始化是否正确'); case Config::SW_CHARGE:
} $this->closeHandler = new SwClose($config);
break;
case Config::FU_CHARGE:
$this->closeHandler = new FuClose($config);
break;
case Config::LTF_CHARGE:
$this->closeHandler = new LTFClose($config);
break;
default:
throw new PayException('当前仅支持:SW_CHARGE、FU_CHARGE、LTF_CHARGE');
}
}catch(PayException $e){
throw $e;
}
}
try { /**
return $this->closeHandler->handle($data); * 通过环境类调用交易关闭操作
} 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;
}
}
} }
...@@ -59,7 +59,9 @@ abstract class BaseData ...@@ -59,7 +59,9 @@ abstract class BaseData
$this->channel = Config::SW_PAY; $this->channel = Config::SW_PAY;
} elseif ($config instanceof FuConfig) { } elseif ($config instanceof FuConfig) {
$this->channel = Config::FU_PAY; $this->channel = Config::FU_PAY;
} } elseif ($config instanceof LTFConfig) {
$this->channel = Config::LTF_PAY;
}
$this->data = array_merge($config->toArray(), $reqData);//配置信息合并 $this->data = array_merge($config->toArray(), $reqData);//配置信息合并
try { try {
...@@ -142,6 +144,13 @@ abstract class BaseData ...@@ -142,6 +144,13 @@ abstract class BaseData
$this->retData['sign'] = $this->makeSign(mb_convert_encoding(ArrayUtil::createLinkstring($signData), 'gbk', 'utf-8')); $this->retData['sign'] = $this->makeSign(mb_convert_encoding(ArrayUtil::createLinkstring($signData), 'gbk', 'utf-8'));
unset($signData); unset($signData);
break; break;
case Config::LTF_PAY:
$signData = $this->certainSignData ?? $data;
$values = ArrayUtil::removeKeys($signData, ['sign']);
if ($this->sign_sort) $values = ArrayUtil::arraySort($values);
$signStr = ArrayUtil::createLinkstring($values);
$this->makeSign($signStr);
break;
default: default:
$values = ArrayUtil::removeKeys($data, ['sign']); $values = ArrayUtil::removeKeys($data, ['sign']);
$values = ArrayUtil::arraySort($values); $values = ArrayUtil::arraySort($values);
......
<?php
namespace Payment\Common;
use Payment\Utils\ArrayUtil;
use Payment\Utils\StrUtil;
final class LTFConfig extends ConfigInterface{
public const UNIFIED_URL = 'wxPreCreate'; //公众号/服务窗统一下单
public const SCANPAY_URL = 'precreate'; //主扫统一下单,扫码支付(预支付)
public const MICROPAY_URL = 'pay '; //条码支付,商户扫用户二维码收款
public const QUERY_URL = 'pay/query'; //订单查询
public const REFUND_URL = 'refund'; //退款申请
public const CLOSE_URL = 'close'; //关闭订单(只有未支付的订单才能发起关闭。订单生成后不能马上调用关单接口,最短调用时间间隔为5分钟)
public const CANCEL_URL = 'cancel'; //订单撤销
public const CHARGE_QUERY_URL = 'pay/query'; //订单查询
public const REFUND_QUERY_URL = 'refund/query'; //退款查询
public const BASE_URL = 'https://api.liantuofu.com/open/';
public const PAY_URL='jspay';//聚合支付
public $base_url = 'https://api.liantuofu.com/open/';
public $version = '1.0';
public $signType = 'MD5';
public $appId; //合作方标识
public $merchantCode; //门店编号
public $payChannel="WXPAY";//支付渠道
public $subAppId; //子商户公众号id,微信交易为商户的appid(小程序,公众号必填)
public $randomStr; //随机字符串
public $attach; //附加数据
public $startTime; //交易开始时间(秒级时间戳)
public $certainSignData = []; //专门用于签名的数据
public $privateKey; //私钥
/**
* FuConfig constructor.
* @param array $config
* @throws PayException
*/
public function __construct(array $config)
{
try {
$this->initConfig($config);
} catch (PayException $e) {
throw $e;
}
}
/**
* 初始化配置文件参数
* @param array $config
* @throws PayException
*/
/**
* 初始化配置文件参数
* @param array $config
* @throws PayException
*/
private function initConfig(array $config)
{
$config = ArrayUtil::paraFilter($config);
if (key_exists('ltf_appid', $config) && !empty($config['ltf_appid'])) $this->appId = $config['ltf_appid'];else throw new PayException('必须提供合作方标识');
if (key_exists('merchant_code', $config) && !empty($config['merchant_code'])) $this->merchantCode = $config['merchant_code']; else throw new PayException('必须提供门店编号');
if (key_exists('sub_appid', $config) && !empty($config['sub_appid'])) $this->subAppId = $config['sub_appid'];
if (key_exists('channel', $config) && !empty($config['channel'])) $this->payChannel = $config['channel'];
if (key_exists('notify_url', $config) && !empty($config['notify_url'])) $this->notifyUrl = $config['notify_url'];
$this->randomStr = StrUtil::getNonceStr(); //生成随机字符串
$this->startTime = time();
$this->order_type = $config['trade_type'] ?? ($config['order_type'] ?? '');
$this->trade_type = $config['trade_type'] ?? 'MINIAPP';
}
}
<?php
namespace Payment\Common\LTFpay\Data;
class BackBarChargeData extends LTFBaseData{
/**
* 构建用于支付的签名相关数据
*
* @return array
*/
protected function buildData(){
// TODO: Implement buildData() method.
}}
<?php
namespace Payment\Common\LTFpay\Data;
class BackPubChargeData extends LTFBaseData{
/**
* 构建用于支付的签名相关数据
*
* @return array
*/
protected function buildData(){
// TODO: Implement buildData() method.
}}
<?php
namespace Payment\Common\LTFpay\Data;
class BackScanChargeData extends LTFBaseData
{
public function getData()
{
return parent::getData();
}
protected function buildData()
{
}
protected function checkDataParam()
{
}
}
<?php
namespace Payment\Common\LTFpay\Data\Cancel;
use Payment\Common\LTFpay\Data\LTFBaseData;
use Payment\Common\PayException;
use Payment\Utils\ArrayUtil;
class CancelData extends LTFBaseData{
/**
* 构建用于支付的签名相关数据
*
* @return array
*/
protected function buildData(){
// TODO: Implement buildData() method.
$this->certainSignData = [
'appId' => $this->appId,
'random' => $this->randomStr,
'merchantCode' => $this->merchantCode,
'outTradeNo' => $this->out_trade_no,
];
$signData = array_merge($this->certainSignData, []);
if(isset($this->operatorId)){
$signData['operatorId'] = $this->operatorId;
}
if(isset($this->reason)){
$signData['reason'] = $this->reason;
}
$this->retData = ArrayUtil::paraFilter($signData);
}
/**
* 检查传入的参数. $reqData是否正确.
*
* @return mixed
* @throws PayException
*/
protected function checkDataParam(){
// TODO: Implement checkDataParam() method.
parent::checkDataParam();
}
}
<?php
namespace Payment\Common\LTFpay\Data\Cancel;
use Payment\Common\LTFpay\Data\LTFBaseData;
use Payment\Common\PayException;
use Payment\Utils\ArrayUtil;
class CloseData extends LTFBaseData{
/**
* 构建用于支付的签名相关数据
*
* @return array
*/
protected function buildData(){
// TODO: Implement buildData() method.
$this->certainSignData = [
'appId' => $this->appId,
'random' => $this->randomStr,
'merchantCode' => $this->merchantCode,
'outTradeNo' => $this->out_trade_no,
];
$signData = array_merge($this->certainSignData, []);
if(isset($this->operatorId)){
$signData['operatorId'] = $this->operatorId;
}
if(isset($this->reason)){
$signData['reason'] = $this->reason;
}
$this->retData = ArrayUtil::paraFilter($signData);
}
/**
* 检查传入的参数. $reqData是否正确.
*
* @return mixed
* @throws PayException
*/
protected function checkDataParam(){
// TODO: Implement checkDataParam() method.
parent::checkDataParam();
}
}
<?php
namespace Payment\Common\LTFpay\Data\Charge;
use Payment\Common\LTFpay\Data\LTFBaseData;
use Payment\Common\PayException;
use Payment\Utils\ArrayUtil;
class BarChargeData extends LTFBaseData{
/**
* 构建用于支付的签名相关数据
*
* @return array
*/
protected function buildData(){
// TODO: Implement buildData() method.
$this->certainSignData = [
'appId' => $this->appId,
'random' => $this->randomStr,
'merchantCode' => $this->merchantCode,
'outTradeNo' => $this->out_trade_no,
'totalAmount' => $this->total_fee,
'authCode' => $this->auth_code,
];
$signData = array_merge($this->certainSignData, []);
if(isset($this->discountAmount)){
$signData['discountAmount'] = $this->discountAmount;
}
if(isset($this->unDiscountAmount)){
$signData['unDiscountAmount'] = $this->unDiscountAmount;
}
if(isset($this->goodsDetail)){
$signData['goodsDetail'] = $this->goodsDetail;
}
if(isset($this->subAppId)){
$signData['subAppId'] = $this->subAppId;
}
if(isset($this->operatorId)){
$signData['operatorId'] = $this->operatorId;
}
if(isset($this->orderRemark)){
$signData['orderRemark'] = $this->orderRemark;
}
if(isset($this->terminalId)){
$signData['terminalId'] = $this->terminalId;
}
if(isset($this->subject)){
$signData['subject'] = $this->subject;
}
if(isset($this->hbFqNum)){
$signData['hbFqNum'] = $this->hbFqNum;
}
if(isset($this->hbFqSellerPercent)){
$signData['hbFqSellerPercent'] = $this->hbFqSellerPercent;
}
if(isset($this->sysServiceProviderId)){
$signData['sysServiceProviderId'] = $this->sysServiceProviderId;
}
if(isset($this->orderSource)){
$signData['orderSource'] = $this->orderSource;
}
if(isset($this->appType)){
$signData['appType'] = $this->appType;
}
if(isset($this->appSource)){
$signData['appSource'] = $this->appSource;
}
if(isset($this->appExtNo)){
$signData['appExtNo'] = $this->appExtNo;
}
if(isset($this->appVersion)){
$signData['appVersion'] = $this->appVersion;
}
if(isset($this->deviceInfo)){
$signData['deviceInfo'] = $this->deviceInfo;
}
// 移除数组中的空值
$this->retData = ArrayUtil::paraFilter($signData);
}
/**
* 检查传入的参数. $reqData是否正确.
*
* @return mixed
* @throws PayException
*/
protected function checkDataParam(){
// TODO: Implement checkDataParam() method.
parent::checkDataParam();
if(empty($this->auth_code)){
throw new PayException('无效的支付授权码');
}
}
}
<?php
namespace Payment\Common\LTFpay\Data\Charge;
use Payment\Common\LTFpay\Data\LTFBaseData;
use Payment\Common\PayException;
use Payment\Config;
abstract class ChargeBaseData extends LTFBaseData{
/**
* 检查传入的参数. $reqData是否正确.
*
* @return mixed
* @throws \Payment\Common\PayException
*/
protected function checkDataParam(){
// TODO: Implement checkDataParam() method.
// 检查金额不能低于0.01
if ($this->total_fee < 1) {
throw new PayException('支付金额不能低于 ' . Config::PAY_MIN_FEE . ' 元');
}
}
}
<?php
namespace Payment\Common\LTFpay\Data\Charge;
use Payment\Common\PayException;
use Payment\Utils\ArrayUtil;
class LiteChargeData extends ChargeBaseData{
/**
* 构建用于支付的签名相关数据
*
* @return void
*/
protected function buildData(){
// TODO: Implement buildData() method.
$this->certainSignData = [
'appId' => $this->appId,
'random' => $this->randomStr,
'merchantCode' => $this->merchantCode,
'outTradeNo' => $this->out_trade_no,
'totalAmount' => $this->total_fee,
'channel' => $this->payChannel ?? "WXPAY",
'tradeType' => $this->tradeType ?? "MINIAPP",
'notifyUrl' => $this->notifyUrl,
'openId' => $this->open_id,
'subAppId' => $this->subAppId,
];
$signData = array_merge($this->certainSignData, []);
if(isset($this->rechargeGiveAmount)){
$signData['rechargeGiveAmount'] = $this->rechargeGiveAmount;
}
if(isset($this->discountAmount)){
$signData['discountAmount'] = $this->discountAmount;
}
if(isset($this->unDiscountAmount)){
$signData['unDiscountAmount'] = $this->unDiscountAmount;
}
if(isset($this->goodsDetail)){
$signData['goodsDetail'] = $this->goodsDetail;
}
if(isset($this->operatorId)){
$signData['operatorId'] = $this->operatorId;
}
if(isset($this->orderRemark)){
$signData['orderRemark'] = $this->orderRemark;
}
if(isset($this->subject)){
$signData['subject'] = $this->subject;
}
if(isset($this->expireMinutes)){
$signData['expireMinutes'] = $this->expireMinutes;
}
if(isset($this->unionId)){
$signData['unionId'] = $this->unionId;
}
if(isset($this->memberId)){
$signData['memberId'] = $this->memberId;
}
if(isset($this->orderType)){
$signData['orderType'] = $this->orderType;
}
// 移除数组中的空值
$this->retData = ArrayUtil::paraFilter($signData);
}
protected function checkDataParam(){
parent::checkDataParam(); // TODO: Change the autogenerated stub
if(empty($this->notifyUrl)){
throw new PayException('支付通知地址不能为空');
}
if(empty($this->open_id)){
throw new PayException('支付的用户Openid不能为空');
}
if(empty($this->subAppId)){
throw new PayException('小程序的APPID不能为空');
}
}
}
<?php
namespace Payment\Common\LTFpay\Data\Charge;
use Payment\Common\PayException;
use Payment\Utils\ArrayUtil;
class PayChargeData extends ChargeBaseData{
/**
* 构建用于支付的签名相关数据
*
* @return array
*/
protected function buildData(){
// TODO: Implement buildData() method.
$this->certainSignData = [
'appId' => $this->appId,
'random' => $this->randomStr,
'merchantCode' => $this->merchantCode,
'outTradeNo' => $this->out_trade_no,
'totalAmount' => $this->total_fee,
'notifyUrl' => $this->notifyUrl,
];
$signData = array_merge($this->certainSignData, []);
if(isset($this->expireSeconds)){
$signData['expireSeconds'] = $this->expireSeconds;
}
if(isset($this->operatorId)){
$signData['operatorId'] = $this->operatorId;
}
if(isset($this->orderRemark)){
$signData['orderRemark'] = $this->orderRemark;
}
if(isset($this->returnUrl)){
$signData['returnUrl'] = $this->returnUrl;
}
$this->retData = ArrayUtil::paraFilter($signData);
}
protected function checkDataParam(){
parent::checkDataParam(); // TODO: Change the autogenerated stub
if(empty($this->notifyUrl)){
throw new PayException('支付通知地址不能为空');
}
}
}
<?php
namespace Payment\Common\LTFpay\Data\Charge;
use Payment\Common\PayException;
use Payment\Utils\ArrayUtil;
class PubChargeData extends ChargeBaseData{
/**
* 构建用于支付的签名相关数据
*
* @return void
*/
protected function buildData(){
// TODO: Implement buildData() method.
$this->certainSignData = [
'appId' => $this->appId,
'random' => $this->randomStr,
'merchantCode' => $this->merchantCode,
'outTradeNo' => $this->out_trade_no,
'totalAmount' => $this->total_fee,
'channel' => $this->payChannel ?? "WXPAY",
'tradeType' => $this->tradeType ?? "JSAPI",
'notifyUrl' => $this->notifyUrl,
'openId' => $this->open_id,
];
$signData = array_merge($this->certainSignData, []);
if(isset($this->unDiscountAmount)){
$signData['unDiscountAmount'] = $this->unDiscountAmount;
}
if(isset($this->goodsDetail)){
$signData['goodsDetail'] = $this->goodsDetail;
}
if(isset($this->subAppId)){
$signData['subAppId'] = $this->subAppId;
}
if(isset($this->operatorId)){
$signData['operatorId'] = $this->operatorId;
}
if(isset($this->orderRemark)){
$signData['orderRemark'] = $this->orderRemark;
}
if(isset($this->subject)){
$signData['subject'] = $this->subject;
}
if(isset($this->expireMinutes)){
$signData['expireMinutes'] = $this->expireMinutes;
}
if(isset($this->hbFqNum)){
$signData['hbFqNum'] = $this->hbFqNum;
}
if(isset($this->hbFqSellerPercent)){
$signData['hbFqSellerPercent'] = $this->hbFqSellerPercent;
}
if(isset($this->sysServiceProviderId)){
$signData['sysServiceProviderId'] = $this->sysServiceProviderId;
}
// 移除数组中的空值
$this->retData = ArrayUtil::paraFilter($signData);
}
protected function checkDataParam(){
parent::checkDataParam(); // TODO: Change the autogenerated stub
if(empty($this->notifyUrl)){
throw new PayException('支付通知地址不能为空');
}
if(empty($this->open_id)){
throw new PayException('用户OPENID 不能为空');
}
}
}
<?php
namespace Payment\Common\LTFpay\Data\Charge;
use Payment\Common\LTFpay\Data\LTFBaseData;
use Payment\Common\PayException;
use Payment\Utils\ArrayUtil;
class ScanChargeData extends LTFBaseData{
/**
* 构建用于支付的签名相关数据
*
* @return void
*/
protected function buildData(){
// TODO: Implement buildData() method.
$this->certainSignData = [
'appId' => $this->appId,
'random' => $this->randomStr,
'merchantCode' => $this->merchantCode,
'outTradeNo' => $this->out_trade_no,
'totalAmount' => $this->total_fee,
'channel' => $this->payChannel ?? "WXPAY",
'tradeType' => $this->tradeType ?? "NATIVE",
'notifyUrl' => $this->notifyUrl,
];
$signData = array_merge($this->certainSignData, []);
if(isset($this->unDiscountAmount)){
$signData['unDiscountAmount'] = $this->unDiscountAmount;
}
if(isset($this->goodsDetail)){
$signData['goodsDetail'] = $this->goodsDetail;
}
if(isset($this->openId)){
$signData['openId'] = $this->openId;
}
if(isset($this->subAppId)){
$signData['subAppId'] = $this->subAppId;
}
if(isset($this->operatorId)){
$signData['operatorId'] = $this->operatorId;
}
if(isset($this->orderRemark)){
$signData['orderRemark'] = $this->orderRemark;
}
if(isset($this->subject)){
$signData['subject'] = $this->subject;
}
if(isset($this->expireMinutes)){
$signData['expireMinutes'] = $this->expireMinutes;
}
if(isset($this->hbFqNum)){
$signData['hbFqNum'] = $this->hbFqNum;
}
if(isset($this->hbFqSellerPercent)){
$signData['hbFqSellerPercent'] = $this->hbFqSellerPercent;
}
if(isset($this->sysServiceProviderId)){
$signData['sysServiceProviderId'] = $this->sysServiceProviderId;
}
if(isset($this->loginToken)){
$signData['loginToken'] = $this->loginToken;
}
// 移除数组中的空值
$this->retData = ArrayUtil::paraFilter($signData);
}
protected function checkDataParam(){
parent::checkDataParam(); // TODO: Change the autogenerated stub
if(empty($this->notifyUrl)){
throw new PayException('支付通知地址不能为空');
}
}
}
<?php
namespace Payment\Common\LTFpay\Data;
use Payment\Common\BaseData;
use Payment\Common\PayException;
abstract class LTFBaseData extends BaseData{
/**
* 签名算法实现 便于后期扩展微信不同的加密方式
*
* @param string $signStr
* @return string
*/
protected function makeSign($signStr){
switch ($this->signType) {
case 'MD5':
$signStr .= '&key=' . $this->key;
$sign = md5($signStr);
break;
default:
$sign = '';
}
$this->retData['sign'] = $sign;
return $sign;
// TODO: Implement makeSign() method.
}
protected function checkDataParam(){
// TODO: Implement checkDataParam() method.
// 检查订单号是否合法
if (empty($this->out_trade_no) || mb_strlen($this->out_trade_no) > 64) {
throw new PayException('商户系统的订单号不能为空且长度不能超过64位');
}
if (empty($this->appId) || empty($this->merchantCode)) {
throw new PayException('必须提供合作方标识与门店编号');
}
}
}
<?php
namespace Payment\Common\LTFpay\Data\Query;
use Payment\Common\LTFpay\Data\LTFBaseData;
use Payment\Common\PayException;
use Payment\Utils\ArrayUtil;
class ChargeQueryData extends LTFBaseData{
/**
* 构建用于支付的签名相关数据
*
* @return array
*/
protected function buildData(){
// TODO: Implement buildData() method.
$this->certainSignData = [
'appId' => $this->appId,
'random' => $this->randomStr,
'merchantCode' => $this->merchantCode,
'outTradeNo' => $this->out_trade_no,
'outTransactionId' => $this->out_transaction_id,
];
$signData = array_merge($this->certainSignData, []);
if(isset($this->operatorId)){
$signData['operatorId'] = $this->operatorId;
}
$this->retData = ArrayUtil::paraFilter($signData);
}
/**
* 检查传入的参数. $reqData是否正确.
*
* @return mixed
* @throws PayException
*/
protected function checkDataParam(){
// TODO: Implement checkDataParam() method.
parent::checkDataParam();
if(empty($this->out_transaction_id)){
throw new PayException('第三方订单号不能为空');
}
}
}
<?php
namespace Payment\Common\LTFpay\Data\Query;
use Payment\Common\LTFpay\Data\LTFBaseData;
use Payment\Common\PayException;
use Payment\Utils\ArrayUtil;
class RefundQueryData extends LTFBaseData{
/**
* 构建用于支付的签名相关数据
*
* @return array
*/
protected function buildData(){
// TODO: Implement buildData() method.
$this->certainSignData = [
'appId' => $this->appId,
'random' => $this->randomStr,
'merchantCode' => $this->merchantCode,
'refundNo' => $this->refund_no,
];
$signData = array_merge($this->certainSignData, []);
if(isset($this->operatorId)){
$signData['operatorId'] = $this->operatorId;
}
$this->retData = ArrayUtil::paraFilter($signData);
}
protected function checkDataParam(){
parent::checkDataParam();
if(empty($this->refund_no)){
throw new PayException('必须提供退款订单号');
}
}
}
<?php
namespace Payment\Common\LTFpay\Data;
use Payment\Common\PayException;
use Payment\Utils\ArrayUtil;
class RefundData extends LTFBaseData{
/**
* 构建用于支付的签名相关数据
*
* @return array
*/
protected function buildData(){
// TODO: Implement buildData() method.
$this->certainSignData = [
'appId' => $this->appId,
'random' => $this->randomStr,
'merchantCode' => $this->merchantCode,
'outTradeNo' => $this->out_trade_no,
'refundNo' => $this->refund_no,
];
$signData = array_merge($this->certainSignData, []);
if(isset($this->outTransactionId)){
$signData['outTransactionId'] = $this->outTransactionId;
}
if(isset($this->refundAmount)){
$signData['refundAmount'] = $this->refundAmount;
}
if(isset($this->refundReason)){
$signData['refundReason'] = $this->refundReason;
}
if(isset($this->operatorId)){
$signData['operatorId'] = $this->operatorId;
}
$this->retData = ArrayUtil::paraFilter($signData);
}
/**
* 检查传入的参数. $reqData是否正确.
*
* @return mixed
* @throws PayException
*/
protected function checkDataParam(){
// TODO: Implement checkDataParam() method.
parent::checkDataParam();
if(empty($this->refund_no)){
throw new PayException('请生成商户退款订单号');
}
}
}
<?php
namespace Payment\Common\LTFpay;
use Payment\Common\BaseData;
use Payment\Common\BaseStrategy;
use Payment\Common\LTFConfig;
use Payment\Common\PayException;
use Payment\Utils\ArrayUtil;
use Payment\Utils\Curl;
abstract class LTFBaseStrategy implements BaseStrategy{
protected $config;
/**
* 支付数据
* @var BaseData $reqData
*/
protected $reqData;
/**
* FuBaseStrategy constructor.
* @param array $config
* @throws PayException
*/
public function __construct(array $config)
{
/* 设置内部字符编码为 UTF-8 */
mb_internal_encoding("UTF-8");
try {
$this->config = new LTFConfig($config);
} catch (PayException $e) {
throw $e;
}
}
/**
* 发送完了请求
* @param $body
* @return mixed
* @throws \Payment\Common\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['code'] != 'SUCCESS') {
throw new PayException('支付平台返回错误提示:' . $retData['subMsg']);
}
return $retData;
}
protected function curlPost($body, $url)
{
$curl = new Curl();
return $curl->set([
'CURLOPT_HEADER' => 0
])->post($body, $url)->submit($url);
}
/**
* 处理具体的业务
*
* @param array $data
* @return mixed
* @throws \Payment\Common\PayException
*/
public function handle(array $data){
// TODO: Implement handle() method.
$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 null $url
* @return string
*/
protected function getReqUrl($url = null)
{
if(isset($this->config->base_url) && !empty($this->config->base_url)){
$_pre = $this->config->base_url;
}else{
$_pre = LTFConfig::BASE_URL;
}
return $_pre.($url??LTFConfig::SCANPAY_URL);
}
/**
* 处理微信的返回值并返回给客户端
* @param array $ret
* @return mixed
*
*/
protected function retData(array $ret)
{
return $ret;
}
/**
* 检查微信返回的数据是否被篡改过
*
* @param array $retData
* @return boolean
* @throws \Exception
*/
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
namespace Payment\Notify;
use Payment\Common\LTFConfig;
use Payment\Common\PayException;
use Payment\Config;
use Payment\Utils\DataParser;
class LTFNotify extends NotifyStrategy{
/**
* SwNotify constructor.
*
* @param array $config
* @throws PayException
*/
public function __construct(array $config){
parent::__construct($config);
try{
$this->config = new LTFConfig($config);
}catch(PayException $e){
throw $e;
}
}
/**
* 获取移除通知的数据 并进行简单处理(如:格式化为数组)
* 如果获取数据失败,返回false
*
* @return array|false
*/
public function getNotifyData(){
$params = [];
$data = $_POST['req'] ?? file_get_contents('php://input');
if (empty($data)) return false;
$params = DataParser::toArray(urldecode($data));
if (empty($params) || count($params) < 1) return false;
foreach ($params as $key => &$value) $value = is_array($value) && empty($value) ? '' : $value;
unset($value);
return $params;
// TODO: Implement getNotifyData() method.
}
/**
* 检查异步通知的数据是否合法
* 如果检查失败,返回false
*
* @param array $data 由 $this->getNotifyData() 返回的数据
* @return boolean
*/
public function checkNotifyData(array $data){
if ($data['code'] != 'SUCCESS') return false;
return $this->verifySign($data);
// TODO: Implement checkNotifyData() method.
}
/**
* 检查数据是否被篡改过
* @param array $retData
* @return bool
*/
protected function verifySign(array $retData)
{
$retSign = $retData['sign'] ?? '';
return true;
}
/**
* 向客户端返回必要的数据
*
* @param array $data 回调机构返回的回调通知数据
* @return array|false
*/
protected function getRetData(array $data){
// TODO: Implement getRetData() method.
if ($this->config->returnRaw) return array_merge($data, ['channel' => Config::LTF_CHARGE]);
$retData = [
'ins_cd' => $data['ins_cd'], //机构号
'mchnt_cd' => $data['mchnt_cd'], //商户号
'term_id' => $data['term_id'] ?? '', //终端号
'user_id' => $data['user_id'] ?? '', //用户在商户的id
'buyer_id' => $data['reserved_buyer_logon_id'] ?? '', //买家在渠道登录账号
'pay_time' => date('Y-m-d H:i:s', strtotime($data['txn_fin_ts'])),//支付完成时间
'amount' => $data['order_amt'], //订单金额
'amount_settle' => $data['settle_order_amt'], //应结订单金额
'transaction_id' => $data['transaction_id'] ?? '', //渠道交易流水号
'order_no' => $data['mchnt_order_no'] ?? '', //商户订单号, 商户系统内部的订单号
'return_param' => $data['reserved_addn_inf'] ?? '', //附加数据
'channel' => Config::WX_CHARGE, //通道
];
return $retData;
}
/**
* 根据返回结果,回答支付机构。是否回调通知成功
*
* @param boolean $flag 每次返回的bool值
* @param string $msg 通知信息,错误原因
* @return mixed
*/
protected function replyNotify($flag, $msg = 'OK'){
return ($flag ? 1 : 0);
// TODO: Implement replyNotify() method.
}
}
...@@ -10,6 +10,7 @@ namespace Payment; ...@@ -10,6 +10,7 @@ namespace Payment;
use Payment\Notify\AliNotify; use Payment\Notify\AliNotify;
use Payment\Notify\CmbNotify; use Payment\Notify\CmbNotify;
use Payment\Notify\FuNotify; use Payment\Notify\FuNotify;
use Payment\Notify\LTFNotify;
use Payment\Notify\MiNotify; use Payment\Notify\MiNotify;
use Payment\Notify\NotifyStrategy; use Payment\Notify\NotifyStrategy;
use Payment\Notify\PayNotifyInterface; use Payment\Notify\PayNotifyInterface;
...@@ -61,6 +62,9 @@ class NotifyContext ...@@ -61,6 +62,9 @@ class NotifyContext
case Config::FU_CHARGE: case Config::FU_CHARGE:
$this->notify = new FuNotify($config); $this->notify = new FuNotify($config);
break; break;
case Config::LTF_CHARGE:
$this->notify = new LTFNotify($config);
break;
default: default:
throw new PayException('当前仅支持:ALI_CHARGE WX_CHARGE CMB_CHARGE TL_CHARGE MI_CHARGE SW_CHARGE FU_CHARGE'); throw new PayException('当前仅支持:ALI_CHARGE WX_CHARGE CMB_CHARGE TL_CHARGE MI_CHARGE SW_CHARGE FU_CHARGE');
} }
......
<?php
namespace Payment\Query\LTF;
use Payment\Common\LTFConfig;
use Payment\Common\LTFpay\Data\Query\ChargeQueryData;
use Payment\Common\LTFpay\LTFBaseStrategy;
class LTFChargeQuery extends LTFBaseStrategy{
public function getBuildDataClass(){
return ChargeQueryData::class;
}
/**
* 返回
* @param null $url
* @return string
*/
public function getReqUrl($url = null){
return parent::getReqUrl($url ?? LTFConfig::CHARGE_QUERY_URL); // TODO: Change the autogenerated stub
}
}
<?php
namespace Payment\Query\LTF;
use Payment\Common\LTFConfig;
use Payment\Common\LTFpay\Data\Query\RefundQueryData;
use Payment\Common\LTFpay\LTFBaseStrategy;
class LTFRefundQuery extends LTFBaseStrategy{
public function getBuildDataClass(){
return RefundQueryData::class;
}
public function getReqUrl($url = null){
return parent::getReqUrl($url ?? LTFConfig::REFUND_QUERY_URL); // TODO: Change the autogenerated stub
}
}
...@@ -17,6 +17,8 @@ use Payment\Query\Cmb\CmbChargeQuery; ...@@ -17,6 +17,8 @@ use Payment\Query\Cmb\CmbChargeQuery;
use Payment\Query\Cmb\CmbRefundQuery; use Payment\Query\Cmb\CmbRefundQuery;
use Payment\Query\Fu\FuChargeQuery; use Payment\Query\Fu\FuChargeQuery;
use Payment\Query\Fu\FuRefundQuery; use Payment\Query\Fu\FuRefundQuery;
use Payment\Query\LTF\LTFChargeQuery;
use Payment\Query\LTF\LTFRefundQuery;
use Payment\Query\MiPay\MiQuery; use Payment\Query\MiPay\MiQuery;
use Payment\Query\Sw\SwChargeQuery; use Payment\Query\Sw\SwChargeQuery;
use Payment\Query\TLpay\TLQuery; use Payment\Query\TLpay\TLQuery;
...@@ -93,7 +95,12 @@ class QueryContext ...@@ -93,7 +95,12 @@ class QueryContext
case Config::FU_REFUND: case Config::FU_REFUND:
$this->query = new FuRefundQuery($config); $this->query = new FuRefundQuery($config);
break; break;
case Config::LTF_CHARGE:
$this->query=new LTFChargeQuery($config);
break;
case Config::LTF_REFUND:
$this->query=new LTFRefundQuery($config);
break;
default: default:
throw new PayException('当前仅支持:ALI_CHARGE ALI_REFUND WX_CHARGE WX_REFUND WX_TRANSFER WX_PAY_BANK CMB_CHARGE CMB_REFUND TLPAY MI_QUERY SW_QUERY FU_CHARGE FU_REFUND'); throw new PayException('当前仅支持:ALI_CHARGE ALI_REFUND WX_CHARGE WX_REFUND WX_TRANSFER WX_PAY_BANK CMB_CHARGE CMB_REFUND TLPAY MI_QUERY SW_QUERY FU_CHARGE FU_REFUND');
} }
......
<?php
namespace Payment\Refund;
use Payment\Common\LTFConfig;
use Payment\Common\LTFpay\Data\RefundData;
use Payment\Common\LTFpay\LTFBaseStrategy;
class LTFRefund extends LTFBaseStrategy{
public function getBuildDataClass(){
return RefundData::class;
}
public function getReqUrl($url = null){
return parent::getReqUrl($url ?? LTFConfig::REFUND_URL); // TODO: Change the autogenerated stub
}
}
...@@ -13,6 +13,7 @@ use Payment\Common\PayException; ...@@ -13,6 +13,7 @@ use Payment\Common\PayException;
use Payment\Refund\AliRefund; use Payment\Refund\AliRefund;
use Payment\Refund\CmbRefund; use Payment\Refund\CmbRefund;
use Payment\Refund\FuRefund; use Payment\Refund\FuRefund;
use Payment\Refund\LTFRefund;
use Payment\Refund\MiRefund; use Payment\Refund\MiRefund;
use Payment\Refund\SwRefund; use Payment\Refund\SwRefund;
use Payment\Refund\TLRefund; use Payment\Refund\TLRefund;
...@@ -61,6 +62,9 @@ class RefundContext ...@@ -61,6 +62,9 @@ class RefundContext
case Config::FU_REFUND: case Config::FU_REFUND:
$this->refund = new FuRefund($config); $this->refund = new FuRefund($config);
break; break;
case Config::LTF_REFUND:
$this->refund= new LTFRefund($config);
break;
default: default:
throw new PayException('当前仅支持:ALI WEIXIN CMB TL MI SW FU'); throw new PayException('当前仅支持:ALI WEIXIN CMB TL MI SW FU');
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!