Commit 54a1c890 by 赵凯(PHP)

update

1 parent b01d0be6
Showing with 2852 additions and 0 deletions
......@@ -11,6 +11,7 @@ use Payment\Cancel\FuCancel;
use Payment\Charge\LTF\LTFCancel;
use Payment\Charge\MiPay\MiCancel;
use Payment\Charge\Sw\SwCancel;
use Payment\Charge\SwThree\SwThreeCancel;
use Payment\Charge\TLpay\TLCancel;
use Payment\Common\BaseStrategy;
use Payment\Common\PayException;
......@@ -50,6 +51,9 @@ class CancelContext{
case Config::SW_CHARGE:
$this->cancelHandler = new SwCancel($config);
break;
case Config::SW_T_CHARGE:
$this->cancelHandler = new SwThreeCancel($config);
break;
case Config::FU_CHARGE:
$this->cancelHandler = new FuCancel($config);
break;
......
<?php
namespace Payment\Charge\SwThree;
use Payment\Common\SwThree\Data\BackBarChargeData;
use Payment\Common\SwThree\Data\Charge\BarChargeData;
use Payment\Common\SwThree\SwBaseStrategy;
use Payment\Common\SwThreeConfig;
/**
* Class SwBarCharge
*
* 扫呗刷卡(条码)支付
*
* @package Payment\Charge\Sw
*
*/
class SwBarThreeCharge extends SwBaseStrategy
{
public function getBuildDataClass()
{
return BarChargeData::class;
}
protected function getReqUrl($url=null){
return parent::getReqUrl($url??SwThreeConfig::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\SwThree;
use Payment\Common\SwThree\Data\BackFaceChargeData;
use Payment\Common\SwThree\Data\Charge\FaceChargeData;
use Payment\Common\SwThree\SwBaseStrategy;
use Payment\Common\SwThreeConfig;
/**
* Class SwFaceCharge
*
* 扫呗自主收银(人脸支付)
*
* @package Payment\Charge\Sw
*
*/
class SwFaceCharge extends SwBaseStrategy
{
public function getBuildDataClass()
{
return FaceChargeData::class;
}
protected function getReqUrl($url=null){
return parent::getReqUrl($url??SwThreeConfig::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($url = null){
return parent::getReqUrl($url??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\SwThree;
use Payment\Common\SwThree\Data\BackLiteChargeData;
use Payment\Common\SwThree\Data\Charge\LiteChargeData;
use Payment\Common\SwThree\SwBaseStrategy;
use Payment\Common\SwThreeConfig;
/**
* Class SwLiteCharge
*
* 扫呗小程序支付
*
* @package Payment\Charge\Sw
*
*/
class SwLiteThreeCharge extends SwBaseStrategy
{
public function getBuildDataClass()
{
return LiteChargeData::class;
}
protected function getReqUrl($url=null){
return parent::getReqUrl($url??SwThreeConfig::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\SwThree;
use Payment\Common\SwThree\Data\BackPubChargeData;
use Payment\Common\SwThree\Data\Charge\PubChargeData;
use Payment\Common\SwThree\SwBaseStrategy;
/**
* Class SwPubCharge
*
* 扫呗微信公众号支付
*
* @package Payment\Charge\Sw
*
*/
class SwPubThreeCharge 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' => '', // 签名
* ];
* ```
*
* @throws \Payment\Common\PayException
*/
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\SwThree;
use Payment\Common\SwThree\Data\BackScanChargeData;
use Payment\Common\SwThree\Data\Charge\ScanChargeData;
use Payment\Common\SwThree\SwBaseStrategy;
use Payment\Common\SwThreeConfig;
/**
* Class SwScanCharge
*
* 扫呗扫码支付
*
* @package Payment\Charge\Sw
*
*/
class SwScanThreeCharge extends SwBaseStrategy
{
public function getBuildDataClass()
{
return ScanChargeData::class;
}
protected function getReqUrl($url=null){
return parent::getReqUrl($url??SwThreeConfig::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;
}
}
<?php
namespace Payment\Charge\SwThree;
use Payment\Common\SwThree\Data\Cancel\BackCancelData;
use Payment\Common\SwThree\Data\Cancel\CancelData;
use Payment\Common\SwThree\SwBaseStrategy;
use Payment\Common\SwThreeConfig;
/**
* Class SwCancel
*
* 扫呗取消订单 (只针对刷卡支付!!!!!!)
*
* @package Payment\Charge\Sw
*
*/
class SwThreeCancel extends SwBaseStrategy
{
public function getBuildDataClass()
{
return CancelData::class;
}
protected function getReqUrl($url=null){
return parent::getReqUrl($url??SwThreeConfig::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\SwThree;
use Payment\Common\SwThree\Data\Cancel\BackCloseData;
use Payment\Common\SwThree\Data\Cancel\CloseData;
use Payment\Common\SwThree\SwBaseStrategy;
use Payment\Common\SwThreeConfig;
/**
* Class SwClose
*
* 扫呗关闭订单 ((仅限服务商模式商户且为微信支付时可用)!!!!!!)
*
* 此接口也支持支付宝,但仅限扫了二维码但没有输密码的情况下
* 刷卡支付不能进行关单操作
*
* @package Payment\Charge\Sw
*
*/
class SwThreeClose extends SwBaseStrategy
{
public function getBuildDataClass()
{
return CloseData::class;
}
protected function getReqUrl($url=null){
return parent::getReqUrl($url??SwThreeConfig::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;
}
}
......@@ -30,6 +30,10 @@ use Payment\Charge\Sw\SwFaceInfo;
use Payment\Charge\Sw\SwLiteCharge;
use Payment\Charge\Sw\SwPubCharge;
use Payment\Charge\Sw\SwScanCharge;
use Payment\Charge\SwThree\SwBarThreeCharge;
use Payment\Charge\SwThree\SwLiteThreeCharge;
use Payment\Charge\SwThree\SwPubThreeCharge;
use Payment\Charge\SwThree\SwScanThreeCharge;
use Payment\Charge\TLpay\TLLiteCharge;
use Payment\Charge\Wx\WxAppCharge;
use Payment\Charge\Wx\WxBarCharge;
......@@ -137,6 +141,27 @@ class ChargeContext
$this->channel = new SwFaceInfo($config);
break;
//扫呗(3.0)
case Config::SW_T_CHANNEL_PUB:
$this->channel = new SwPubThreeCharge($config);
break;
case Config::SW_T_CHANNEL_LITE:
$this->channel = new SwLiteThreeCharge($config);
break;
case Config::SW_T_CHANNEL_SCAN: //目前主扫模式已经逐步被被扫模式替换
$this->channel = new SwScanThreeCharge($config);
break;
case Config::SW_T_CHANNEL_BAR: //用户被扫模式
$this->channel = new SwBarThreeCharge($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;
//富友
case Config::FU_CHANNEL_PUB:
case Config::FU_CHANNEL_LITE:
......
......@@ -39,6 +39,7 @@ class Cancel
Config::MI_CHANNEL_LITE, //米付
Config::SW_CHARGE, //扫呗支付退款
Config::SW_T_CHARGE, //扫呗支付(3.0)撤销(退款)
Config::FU_CHARGE, //富友
Config::LTF_CHARGE,
......
......@@ -37,6 +37,13 @@ class Charge
Config::SW_CHANNEL_FACEPAY,
Config::SW_CHANNEL_BAR,
//立楚扫呗(3.0):公众号、小程序、扫码、自助收款
Config::SW_T_CHANNEL_PUB,
Config::SW_T_CHANNEL_LITE,
Config::SW_T_CHANNEL_SCAN,
Config::SW_T_CHANNEL_FACEPAY,
Config::SW_T_CHANNEL_BAR,
Config::FU_CHANNEL_PUB,
Config::FU_CHANNEL_LITE,
Config::FU_CHANNEL_SCAN,
......
......@@ -16,6 +16,7 @@ class Close {
private static $supportChannel = [
Config::SW_CHARGE, //扫呗支付关闭订单
Config::SW_T_CHARGE, //扫呗支付(3.0)关闭订单
Config::FU_CHARGE, //富友支付关闭订单
Config::LTF_CHARGE,//联拓富支付关闭订单
];
......
......@@ -26,6 +26,8 @@ class Notify
Config::SW_CHARGE,//扫呗
Config::SW_T_CHARGE,//扫呗(3.0)
Config::FU_CHARGE, //富友
Config::LTF_CHARGE, //联拓富
......
......@@ -39,6 +39,7 @@ class Query
Config::MI_QUERY,//米付
Config::SW_QUERY,//扫呗
Config::SW_T_QUERY,//扫呗(3.0)
Config::FU_CHARGE,
Config::FU_REFUND,
......
......@@ -33,6 +33,8 @@ class Refund
Config::MI_REFUND,//米付
Config::SW_REFUND,//扫呗
Config::SW_T_REFUND,//扫呗(3.0)
Config::FU_REFUND, //富友
Config::LTF_REFUND,
......
......@@ -5,6 +5,7 @@ namespace Payment;
use Payment\Charge\Fu\FuClose;
use Payment\Charge\LTF\LTFClose;
use Payment\Charge\Sw\SwClose;
use Payment\Charge\SwThree\SwThreeClose;
use Payment\Common\BaseStrategy;
use Payment\Common\PayException;
......@@ -37,6 +38,9 @@ class CloseContext{
case Config::SW_CHARGE:
$this->closeHandler = new SwClose($config);
break;
case Config::SW_T_CHARGE:
$this->closeHandler = new SwThreeClose($config);
break;
case Config::FU_CHARGE:
$this->closeHandler = new FuClose($config);
break;
......
<?php
namespace Payment\Common\SwThree\Data;
/**
* Class BackBarChargeData
*
* 刷卡(条码)支付,数据回调处理
*
* @package Payment\Common\Sw\Data
*
*/
class BackBarChargeData extends SwBaseData
{
public function getData()
{
$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;
}
return parent::getData(); // TODO: Change the autogenerated stub
}
protected function buildData(){
}
protected function checkDataParam()
{
// 对于返回数据不做检查检查
}
}
<?php
namespace Payment\Common\SwThree\Data;
/**
* Class BackFaceChargeData
*
*
* @package Payment\Common\Sw\Data
*
*/
class BackFaceChargeData extends SwBaseData
{
public function getData()
{
$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??'',
];
return parent::getData(); // TODO: Change the autogenerated stub
}
protected function buildData()
{
}
protected function checkDataParam()
{
// 对于返回数据不做检查检查
}
}
<?php
namespace Payment\Common\SwThree\Data;
/**
* Class BackFaceInfoData
*
*
* @package Payment\Common\Sw\Data
*
*/
class BackFaceInfoData extends SwBaseData
{
public function getData()
{
$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;
}
return parent::getData(); // TODO: Change the autogenerated stub
}
protected function buildData()
{
}
protected function checkDataParam()
{
// 对于返回数据不做检查检查
}
}
<?php
namespace Payment\Common\SwThree\Data;
use Payment\Common\PayException;
/**
* Class BackLiteChargeData
*
*
* @package Payment\Common\Sw\Data
*
*/
class BackLiteChargeData extends SwBaseData
{
public function getData()
{
switch ($this->pay_type){
case '010':{ //微信
$data = [
'timeStamp' => $this->timeStamp,//time() . '',
'nonceStr' => $this->nonceStr,
'package' => $this->package_str,
'signType' => $this->signType,// 签名算法,暂支持MD5
'paySign' => $this->paySign
];
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
];
return parent::getData();
}
protected function checkDataParam()
{
// 对于返回数据不做检查检查
}
/**
* 构建用于支付的签名相关数据
* @return array
*/
protected function buildData()
{
// TODO: Implement buildData() method.
}
}
<?php
namespace Payment\Common\SwThree\Data;
/**
* Class BackPubChargeData
* 小程序数据也在这里处理
* @property string $device_info 设备号
* @property string $trade_type 交易类型
* @property string $prepay_id 预支付交易会话标识
*
* @package Payment\Common\Sw\Data
*
*/
class BackPubChargeData extends SwBaseData
{
public function getData()
{
$data = [];
switch ($this->pay_type) {
case '010':
{ //微信
$data = [
'appId' => $this->appId,
'timeStamp' => $this->timeStamp,
'nonceStr' => $this->nonceStr,
'package' => $this->package_str,
'signType' => $this->signType, // 签名算法,暂支持MD5
'paySign' => $this->paySign
];
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
];
return parent::getData(); // TODO: Change the autogenerated stub
}
protected function buildData()
{
}
protected function checkDataParam()
{
// 不进行检查
}
}
<?php
namespace Payment\Common\SwThree\Data;
/**
* Class BackRefundData
*
*
* @package Payment\Common\Sw\Data
*
*/
class BackRefundData extends SwBaseData
{
public function getData()
{
$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,//退款金额,单位分
];
return parent::getData(); // TODO: Change the autogenerated stub
}
protected function buildData()
{
}
protected function checkDataParam()
{
// 对于返回数据不做检查检查
}
}
<?php
namespace Payment\Common\SwThree\Data;
use Payment\Common\PayException;
/**
* Class BackScanChargeData
*
*
* @package Payment\Common\Sw\Data
*
*/
class BackScanChargeData extends SwBaseData
{
public function getData()
{
$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
];
return parent::getData(); // TODO: Change the autogenerated stub
}
protected function buildData()
{
}
protected function checkDataParam()
{
// 对于返回数据不做检查检查
}
}
<?php
namespace Payment\Common\SwThree\Data\Cancel;
use Payment\Common\SwThree\Data\SwBaseData;
/**
* Class BackCancelData
*
*
* @package Payment\Common\Sw\Data
*
*/
class BackCancelData extends SwBaseData
{
public function getData()
{
$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
];
return parent::getData(); // TODO: Change the autogenerated stub
}
protected function buildData()
{
}
protected function checkDataParam()
{
// 对于返回数据不做检查检查
}
}
<?php
namespace Payment\Common\SwThree\Data\Cancel;
use Payment\Common\SwThree\Data\SwBaseData;
/**
* Class BackCloseData
*
*
* @package Payment\Common\Sw\Data
*
*/
class BackCloseData extends SwBaseData
{
public function getData()
{
$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??'',
];
return parent::getData(); // TODO: Change the autogenerated stub
}
protected function buildData()
{
}
protected function checkDataParam()
{
// 对于返回数据不做检查检查
}
}
<?php
namespace Payment\Common\SwThree\Data\Cancel;
use Payment\Common\SwThree\Data\SwBaseData;
use Payment\Utils\ArrayUtil;
/**
* Class CancelData
* 扫呗取消订单
*
*
* @package Payment\Common\Sw\Data\Charge
*
*/
class CancelData extends SwBaseData
{
protected function checkDataParam()
{
$this->pay_ver = '201';
$this->service_id = '040';
}
protected function buildData(){
$this->certainSignData = [
// 基本数据
'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,
];
$signData = array_merge($this->certainSignData,[]);
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\SwThree\Data\Cancel;
use Payment\Common\SwThree\Data\SwBaseData;
use Payment\Utils\ArrayUtil;
/**
* Class CloseData
* 扫呗关闭订单
*
*
* @package Payment\Common\Sw\Data\Charge
*
*/
class CloseData extends SwBaseData
{
protected function checkDataParam()
{
$this->pay_ver = '201';
$this->service_id = '041';
}
protected function buildData(){
$this->certainSignData = [
// 基本数据
'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,
];
$signData = array_merge($this->certainSignData,[]);
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\SwThree\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()
{
$this->certainSignData = [
// 基本数据
'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,
'auth_no' =>$this->auth_no,//授权码,客户的付款码
'total_fee' => $this->total_fee, // 金额,单位分
];
$signData = array_merge($this->certainSignData,[]);
if(isset($this->sub_appid)){
$signData['sub_appid'] = $this->sub_appid;
}
if(isset($this->order_body)){
$signData['order_body'] = $this->order_body;
}
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\SwThree\Data\Charge;
use Payment\Common\PayException;
use Payment\Common\SwThree\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\SwThree\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()
{
$this->sign_sort = true;//需要按照字典排序
$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,
'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;
}
$signData['total_fee'] = $this->total_fee; // 金额,单位分
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\SwThree\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()
{
$this->sign_sort = true;
$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\SwThree\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()
{
$this->certainSignData = [
// 基本数据
'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,
];
$signData = array_merge($this->certainSignData,[]);
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\SwThree\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->open_id)) throw new PayException('用户在商户appid下的唯一标识,用户标识(微信openid,支付宝userid),pay_type为010及020时需要传入.');
}
$this->service_id = '012';
}
protected function buildData()
{
$this->certainSignData = [
// 基本数据
'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,
];
$signData = array_merge($this->certainSignData, []);
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\SwThree\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()
{
$this->certainSignData = [
// 基本数据
'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,
];
$signData = array_merge($this->certainSignData,[]);
if(isset($this->sub_appid)){
$signData['sub_appid'] = $this->sub_appid;
}
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\SwThree\Data\Query;
use Payment\Common\SwThree\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\SwThree\Data\Query;
use Payment\Common\PayException;
use Payment\Common\SwThree\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 = '201';
$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(){
$this->certainSignData = [
// 基本数据
'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
];
$signData = array_merge($this->certainSignData,[]);
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\SwThree\Data;
use Payment\Common\PayException;
use Payment\Utils\ArrayUtil;
/**
* 退款交易的数据结构
* Class RefundData
*
*
* @package Payment\Common\Sw\Data\Query
*/
class RefundData extends SwBaseData
{
protected function checkDataParam()
{
// parent::checkDataParam();
$this->pay_ver = '201';
$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(){
$this->certainSignData = [
// 基本数据
'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,//订单号,查询凭据,利楚订单号、微信订单号、支付宝订单号任意一个
];
$signData = array_merge($this->certainSignData,[]);
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($signData);
}
}
\ No newline at end of file
<?php
namespace Payment\Common\SwThree\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
namespace Payment\Common\SwThree;
use Payment\Common\BaseData;
use Payment\Common\BaseStrategy;
use Payment\Common\PayException;
use Payment\Common\SwThreeConfig;
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 SwThreeConfig($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();
$this_header = array("content-type: application/json;charset=UTF-8");
return $curl->set([
'CURLOPT_HEADER' => 0,
'CURLOPT_HTTPHEADER' => $this_header
])->post($body, $url)->submit($url,true);
}
/**
* 获取需要的url 默认返回下单的url,根据实际情况,需要被覆写
* 默认是h5支付
*
* @param null $url
* @return null|string
*/
protected function getReqUrl($url=null)
{
if(isset($this->config->base_url) && !empty($this->config->base_url)){
$_pre = $this->config->base_url;
}else{
$_pre = SwThreeConfig::BASE_URL;
}
return $_pre.($url??SwThreeConfig::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
namespace Payment\Common;
use Payment\Utils\ArrayUtil;
final class SwThreeConfig extends ConfigInterface
{
public $signType = 'MD5';
public $pay_ver = 201;//版本号,当前版本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 $certainSignData = null;//专门用于签名的数组
public $sign_sort = false;//签名是否需要字典排序
// 指定回调页面
public $notify_url;
const BASE_URL = 'https://pay.lcsw.cn/lcsw';// 'http://test.lcsw.cn:8045/lcsw';
const UNIFIED_URL = '/pay/open/jspay'; // 公众号支付统一下单url
const LITEPAY_URL = '/pay/open/minipay';// 小程序支付url
// const FACEPAY_URL = '/pay/110/facepay';//自助收银
const SCANPAY_URL = '/pay/open/prepay';//扫码支付(预支付)
// const BARCODE_URL = '/pay/100/barcodepay';//刷卡(条码)支付
// const FACEPAY_ACCESSTOKEN_URL = '/pay/110/faceinfo';//自助收银SDK调用凭证获取接口
// const AUTH_OPENID = '/wx/jsapi/authopenid';//用于服务商通道获取微信openid,Method:GET
// const AUTHCODE_TO_OPENID_URL = '/pay/110/authcodetoopenid';//授权码查询 OPENID 接口
const CHARGE_QUERY_URL = '/pay/open/query'; // 支付查询url
const REFUND_URL = '/pay/open/refund'; // 申请退款url
const CANCEL_URL = '/pay/open/cancel';//撤销交易(只针对刷卡支付)
const CLOSE_URL = '/pay/open/close';//关闭订单(仅限服务商模式商户且为微信支付时可用)
// const SIGN_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('必须提供SW商户号');
}
if (key_exists('terminal_id', $config) && !empty($config['terminal_id'])) {
$this->terminal_id = $config['terminal_id'];
} else {
throw new PayException('必须提供SW终端号');
}
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']);
}
if (key_exists('access_token', $config)) {
$this->access_token = trim($config['access_token']);
}
if (key_exists('base_url', $config)) {
$this->base_url = trim($config['base_url']);
}
// 设置交易开始时间 格式为yyyyMMddHHmmss,在次之前一定要设置时区
$startTime = time();
$this->terminal_time = date('YmdHis', $startTime);
}
}
......@@ -169,6 +169,28 @@ final class Config{
const SW_QUERY = 'sw_query'; // 查询接口
//========================= 扫呗(3.0)支付相关接口 =======================//
//https://lcsw.yuque.com/docs/share/f8d585bb-e0b4-46d0-a83a-dfaedc6b55af?#9e870768
const SW_T_CHANNEL_PUB = 'sw_t_pub';// 微信公众号h5支付
const SW_T_CHANNEL_LITE = 'sw_t_lite';// 小程序支付
const SW_T_CHANNEL_SCAN = 'sw_t_scan';// 扫码支付
const SW_T_CHANNEL_BAR = 'sw_t_bar';// 刷卡(条码)支付 用户被扫模式
const SW_T_CHANNEL_FACEPAY = 'sw_t_facepay';// 自助收银收款
const SW_T_CHARGE = 'sw_t_charge';// 统一下单
const SW_T_REFUND = 'sw_t_refund';// 退款
const SW_T_CANCEL = 'sw_t_cancel';// 交易撤销,只能撤销当天的交易,全额退款,实时返回退款结果
const SW_T_QUERY = 'sw_t_query'; // 查询接口
//========================= 富友相关接口 =======================//
// 支付常量
......
<?php
namespace Payment\Notify;
use Payment\Common\PayException;
use Payment\Common\SwThreeConfig;
use Payment\Config;
use Payment\Utils\ArrayUtil;
/**
* Class SwNotify
* 回调处理
* @package Payment\Notify
* @anthor yeran
*/
class SwThreeNotify extends NotifyStrategy
{
/**
* SwNotify constructor.
* @param array $config
* @throws PayException
*/
public function __construct(array $config)
{
parent::__construct($config);
try {
$this->config = new SwThreeConfig($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'];
$data = ArrayUtil::removeKeys($retData, ['key_sign', 'pay_trace','pay_time','receipt_fee']);
$values = [
'return_code' => $data['return_code'],
'return_msg' => $data['return_msg'],
'result_code' => $data['result_code'],
'pay_type' => $data['pay_type'],
'user_id' => $data['user_id'],
'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'],
'total_fee' => $data['total_fee'],
'end_time' => $data['end_time'],
'out_trade_no' => $data['out_trade_no'],
'channel_trade_no' => $data['channel_trade_no'],
'attach' => $data['attach'],
];
$values = ArrayUtil::paraFilter($values);
// $values = ArrayUtil::arraySort($values);
$signStr = ArrayUtil::createLinkstring($values);
$signStr .= '&access_token=' . $this->config->access_token;
switch ($this->config->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';
$return_msg ='数据校验成功,回调完成处理';
if (! $flag) {
$return_code ='02';
$return_msg = '数据校验失败';
}
return [
'return_code' => $return_code,
'return_msg' => $return_msg,
];
}
}
......@@ -15,6 +15,7 @@ use Payment\Notify\MiNotify;
use Payment\Notify\NotifyStrategy;
use Payment\Notify\PayNotifyInterface;
use Payment\Notify\SwNotify;
use Payment\Notify\SwThreeNotify;
use Payment\Notify\TLNotify;
use Payment\Notify\WxNotify;
use Payment\Common\PayException;
......@@ -59,6 +60,9 @@ class NotifyContext
case Config::SW_CHARGE:
$this->notify = new SwNotify($config);
break;
case Config::SW_T_CHARGE:
$this->notify = new SwThreeNotify($config);
break;
case Config::FU_CHARGE:
$this->notify = new FuNotify($config);
break;
......
<?php
/**
*
* @createTime: 2019-03-24 22:42
* @description: 支付查询
*/
namespace Payment\Query\SwThree;
use Payment\Common\SwThree\Data\Query\BackChargeQueryData;
use Payment\Common\SwThree\Data\Query\ChargeQueryData;
use Payment\Common\SwThree\SwBaseStrategy;
use Payment\Common\SwThreeConfig;
class SwChargeThreeQuery extends SwBaseStrategy
{
/**
* 返回查询订单的数据
*
*/
public function getBuildDataClass()
{
return ChargeQueryData::class;
}
/**
* 返回微信查询的url
* @param null $url
* @return string
*/
protected function getReqUrl($url=null)
{
return parent::getReqUrl($url??SwThreeConfig::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;
}
}
......@@ -21,6 +21,7 @@ use Payment\Query\LTF\LTFChargeQuery;
use Payment\Query\LTF\LTFRefundQuery;
use Payment\Query\MiPay\MiQuery;
use Payment\Query\Sw\SwChargeQuery;
use Payment\Query\SwThree\SwChargeThreeQuery;
use Payment\Query\TLpay\TLQuery;
use Payment\Query\Wx\WxChargeQuery;
use Payment\Query\Wx\WxPayBankQuery;
......@@ -88,6 +89,9 @@ class QueryContext
case Config::SW_QUERY:// 扫呗查询
$this->query = new SwChargeQuery($config);
break;
case Config::SW_T_QUERY:// 扫呗(3.0)查询
$this->query = new SwChargeThreeQuery($config);
break;
case Config::FU_CHARGE:
$this->query = new FuChargeQuery($config);
......
<?php
/**
*
* @createTime: 2019-03-24 22:42
* @description: 退款
*/
namespace Payment\Refund;
use Payment\Common\SwThree\Data\BackRefundData;
use Payment\Common\SwThree\Data\RefundData;
use Payment\Common\SwThree\SwBaseStrategy;
use Payment\Common\SwThreeConfig;
/**
* 需要商户当前账户内有大于退款金额的余额,否则会造成余额不足,退款失败;
* 限支付30天内退款,超过30天,不能进行退款操作(具体退款限制时间由通道决定)。
*
* Class SwRefund
* @package Payment\Refund\Sw
*/
class SwThreeRefund extends SwBaseStrategy
{
/**
* 返回查询订单的数据
*
*/
public function getBuildDataClass()
{
return RefundData::class;
}
/**
* 返回微信查询的url
* @param null $url
* @return string
*/
protected function getReqUrl($url=null)
{
return parent::getReqUrl($url??SwThreeConfig::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;
}
}
......@@ -16,6 +16,7 @@ use Payment\Refund\FuRefund;
use Payment\Refund\LTFRefund;
use Payment\Refund\MiRefund;
use Payment\Refund\SwRefund;
use Payment\Refund\SwThreeRefund;
use Payment\Refund\TLRefund;
use Payment\Refund\WxRefund;
......@@ -59,6 +60,9 @@ class RefundContext
case Config::SW_REFUND:
$this->refund = new SwRefund($config);
break;
case Config::SW_T_REFUND:
$this->refund = new SwThreeRefund($config);
break;
case Config::FU_REFUND:
$this->refund = new FuRefund($config);
break;
......
<?php
namespace Payment\Charge\SwThree;
use Payment\Common\SwThree\Data\BackBarChargeData;
use Payment\Common\SwThree\Data\Charge\BarChargeData;
use Payment\Common\SwThree\SwBaseStrategy;
use Payment\Common\SwThreeConfig;
/**
* Class SwBarCharge
*
* 扫呗刷卡(条码)支付
*
* @package Payment\Charge\Sw
*
*/
class SwBarThreeCharge extends SwBaseStrategy
{
public function getBuildDataClass()
{
return BarChargeData::class;
}
protected function getReqUrl($url=null){
return parent::getReqUrl($url??SwThreeConfig::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\SwThree;
use Payment\Common\SwThree\Data\BackFaceChargeData;
use Payment\Common\SwThree\Data\Charge\FaceChargeData;
use Payment\Common\SwThree\SwBaseStrategy;
use Payment\Common\SwThreeConfig;
/**
* Class SwFaceCharge
*
* 扫呗自主收银(人脸支付)
*
* @package Payment\Charge\Sw
*
*/
class SwFaceCharge extends SwBaseStrategy
{
public function getBuildDataClass()
{
return FaceChargeData::class;
}
protected function getReqUrl($url=null){
return parent::getReqUrl($url??SwThreeConfig::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($url = null){
return parent::getReqUrl($url??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\SwThree;
use Payment\Common\SwThree\Data\BackLiteChargeData;
use Payment\Common\SwThree\Data\Charge\LiteChargeData;
use Payment\Common\SwThree\SwBaseStrategy;
use Payment\Common\SwThreeConfig;
/**
* Class SwLiteCharge
*
* 扫呗小程序支付
*
* @package Payment\Charge\Sw
*
*/
class SwLiteThreeCharge extends SwBaseStrategy
{
public function getBuildDataClass()
{
return LiteChargeData::class;
}
protected function getReqUrl($url=null){
return parent::getReqUrl($url??SwThreeConfig::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\SwThree;
use Payment\Common\SwThree\Data\BackPubChargeData;
use Payment\Common\SwThree\Data\Charge\PubChargeData;
use Payment\Common\SwThree\SwBaseStrategy;
/**
* Class SwPubCharge
*
* 扫呗微信公众号支付
*
* @package Payment\Charge\Sw
*
*/
class SwPubThreeCharge 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' => '', // 签名
* ];
* ```
*
* @throws \Payment\Common\PayException
*/
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\SwThree;
use Payment\Common\SwThree\Data\BackScanChargeData;
use Payment\Common\SwThree\Data\Charge\ScanChargeData;
use Payment\Common\SwThree\SwBaseStrategy;
use Payment\Common\SwThreeConfig;
/**
* Class SwScanCharge
*
* 扫呗扫码支付
*
* @package Payment\Charge\Sw
*
*/
class SwScanThreeCharge extends SwBaseStrategy
{
public function getBuildDataClass()
{
return ScanChargeData::class;
}
protected function getReqUrl($url=null){
return parent::getReqUrl($url??SwThreeConfig::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;
}
}
<?php
namespace Payment\Charge\SwThree;
use Payment\Common\SwThree\Data\BackCancelData;
use Payment\Common\SwThree\Data\Cancel\CancelData;
use Payment\Common\SwThree\SwBaseStrategy;
use Payment\Common\SwThreeConfig;
/**
* Class SwCancel
*
* 扫呗取消订单 (只针对刷卡支付!!!!!!)
*
* @package Payment\Charge\Sw
*
*/
class SwThreeCancel extends SwBaseStrategy
{
public function getBuildDataClass()
{
return CancelData::class;
}
protected function getReqUrl($url=null){
return parent::getReqUrl($url??SwThreeConfig::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\SwThree;
use Payment\Common\SwThree\Data\Cancel\BackCloseData;
use Payment\Common\SwThree\Data\Cancel\CloseData;
use Payment\Common\SwThree\SwBaseStrategy;
use Payment\Common\SwThreeConfig;
/**
* Class SwClose
*
* 扫呗关闭订单 ((仅限服务商模式商户且为微信支付时可用)!!!!!!)
*
* 此接口也支持支付宝,但仅限扫了二维码但没有输密码的情况下
* 刷卡支付不能进行关单操作
*
* @package Payment\Charge\Sw
*
*/
class SwThreeClose extends SwBaseStrategy
{
public function getBuildDataClass()
{
return CloseData::class;
}
protected function getReqUrl($url=null){
return parent::getReqUrl($url??SwThreeConfig::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;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!