Commit 3585361b by 赵凯(PHP)

update

1 parent 8726d1e3
Showing with 2676 additions and 19 deletions
...@@ -8,11 +8,13 @@ use Payment\Config; ...@@ -8,11 +8,13 @@ use Payment\Config;
date_default_timezone_set('Asia/Shanghai'); date_default_timezone_set('Asia/Shanghai');
$configStr = "{\"pay_var\":\"100\",\"pay_type\":\"010\",\"service_id\":\"015\",\"mch_id\":\"858100307000002\",\"merchant_no\":\"858100307000002\",\"terminal_id\":\"30055973\",\"sub_appid\":\"wx24863377e74518f8\",\"app_id\":\"wx24863377e74518f8\",\"limit_pay\":[\"\"],\"access_token\":\"bae3420022594dd9a14703f890765f9e\",\"notify_url\":\"http://www.ledian.com/payments/notify\",\"use_sandbox\":false,\"return_raw\":false}"; $configStr = '{"pay_var":"100","pay_type":"010","mch_id":"879104816000039","merchant_no":"879104816000039","terminal_id":"11558708","sub_appid":"wx2eaddb8e674394aa","app_id":"wx2eaddb8e674394aa","limit_pay":[""],"access_token":"3846bb6b7909488595c58e19a2211131","base_url":"https://pay.lcsw.cn/lcsw","notify_url":"http://api.test.ledianyun.com/payments/notify","use_sandbox":false,"return_raw":false} [] []
';
$config = json_decode($configStr,true); $config = json_decode($configStr,true);
// 订单信息 // 订单信息
$payDataStr = "{\"terminal_trace\":\"20190327151722366145505357545320\",\"total_fee\":1,\"order_body\":\"支付测试\",\"open_id\":\"oUlAM0Wp1K1rJEGJ0t__Ls5-qFKE\",\"attach\":\"10054c238f670a2e9649a8b100f20562\"}"; $payDataStr = '{"service_id":"015","terminal_trace":"20210610120224954476481015748920","total_fee":2,"order_body":"【乐店云】微信支付","open_id":"oDqg_5WEH2ROdZhRN7g3ERebi4e4","attach":"c7264439ab86385bc16a73b85ce3d134"} [] []
';
$payData = json_decode($payDataStr,true); $payData = json_decode($payDataStr,true);
$config['base_url'] = 'https://pay.lcsw.cn/lcsw'; $config['base_url'] = 'https://pay.lcsw.cn/lcsw';
......
...@@ -15,30 +15,17 @@ use Payment\Config; ...@@ -15,30 +15,17 @@ use Payment\Config;
use Payment\Utils\ArrayUtil; use Payment\Utils\ArrayUtil;
date_default_timezone_set('Asia/Shanghai'); date_default_timezone_set('Asia/Shanghai');
$configStr = "{\"pay_var\":\"100\",\"pay_type\":\"010\",\"service_id\":\"015\",\"mch_id\":\"858100307000002\",\"merchant_no\":\"858100307000002\",\"terminal_id\":\"30055973\",\"sub_appid\":\"wx24863377e74518f8\",\"app_id\":\"wx24863377e74518f8\",\"limit_pay\":[\"\"],\"access_token\":\"bae3420022594dd9a14703f890765f9e\",\"notify_url\":\"http://www.ledian.com/payments/notify\",\"use_sandbox\":false,\"return_raw\":false}"; $configStr = '{"pay_var":"201","pay_type":"010","mch_id":"879104816000039","merchant_no":"879104816000039","terminal_id":"11558708","sub_appid":"wx2eaddb8e674394aa","app_id":"wx2eaddb8e674394aa","limit_pay":[""],"access_token":"3846bb6b7909488595c58e19a2211131","base_url":"https://pay.lcsw.cn/lcsw","notify_url":"http://api.test.ledianyun.com/payments/notify","use_sandbox":false,"return_raw":false}';
$config = json_decode($configStr,true); $config = json_decode($configStr,true);
$callback = new TestNotify(); $callback = new TestNotify();
try { try {
if (!empty($config)){ if (!empty($config)){
// Notify::run(Config::SW_CHARGE,$config,$callback);
// $retData = Notify::getNotifyData($type, $config);// 获取第三方的原始数据,未进行签名检查
$retDataStr = "{\"attach\":\"a3f7a2b605e84762868ecf92f97146bf\",\"channel_trade_no\":\"4200000277201903277386709856\",\"end_time\":\"20190327172739\",\"key_sign\":\"572c4d043a58f605202e4d2f0e4e66d8\",\"merchant_name\":\"袁梦对接专用(勿动)\",\"merchant_no\":\"858100307000002\",\"out_trade_no\":\"300559730021619032717272800016\",\"pay_type\":\"010\",\"receipt_fee\":\"1\",\"result_code\":\"01\",\"return_code\":\"01\",\"return_msg\":\"支付成功\",\"terminal_id\":\"30055973\",\"terminal_time\":\"20190327172726\",\"terminal_trace\":\"20190327172726469910101555098120\",\"total_fee\":\"1\",\"user_id\":\"oO4lo5KBwCtX5CPayZV2WedgMjRc\"}"; $retDataStr = "{\"attach\":\"a3f7a2b605e84762868ecf92f97146bf\",\"channel_trade_no\":\"4200000277201903277386709856\",\"end_time\":\"20190327172739\",\"key_sign\":\"572c4d043a58f605202e4d2f0e4e66d8\",\"merchant_name\":\"袁梦对接专用(勿动)\",\"merchant_no\":\"858100307000002\",\"out_trade_no\":\"300559730021619032717272800016\",\"pay_type\":\"010\",\"receipt_fee\":\"1\",\"result_code\":\"01\",\"return_code\":\"01\",\"return_msg\":\"支付成功\",\"terminal_id\":\"30055973\",\"terminal_time\":\"20190327172726\",\"terminal_trace\":\"20190327172726469910101555098120\",\"total_fee\":\"1\",\"user_id\":\"oO4lo5KBwCtX5CPayZV2WedgMjRc\"}";
$retData = json_decode($retDataStr,true); $retData = json_decode($retDataStr,true);
$notify = new \Payment\Notify\SwNotify($config); $notify = new \Payment\Notify\SwNotify($config);
$ret = $notify->checkNotifyData($retData); $ret = $notify->checkNotifyData($retData);
die($ret); die($ret);
// $basePath = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'CacertFile' . DIRECTORY_SEPARATOR;
// $publicKeyPath = "{$basePath}mipay".DIRECTORY_SEPARATOR."meepay_public_key.pem";
// $publicKeyPath = "/project/ldy/payment/src/CacertFile/mipay/meepay_public_key.pem";
// $retData = "{\"result_code\":\"SUCCESS\",\"out_trade_sn\":\"SN20181031020706\",\"meepay_trade_no\":\"MF0118103102070684504\",\"transaction_id\":\"4200000203201810316768166604\",\"sub_merchant_id\":\"10002\",\"sub_appid\":\"wx03b4aeb839cc8d85\",\"sub_openid\":\"oUlAM0fD5RsWs9CvOCCMU_nYEDSY\",\"total_amount\":\"1\",\"trade_type\":\"NATIVE\",\"nonce_str\":\"af7rhpf50cjqjadyzthu82hyl7rzdkgk\",\"fee_type\":\"CNY\",\"cash_fee\":\"1\",\"attach\":\"1233\",\"sign_type\":\"RSA2\",\"sign\":\"d0AsaPytw9by+gfD9DLBHp9s1U+aQt9qVd1DYjPP4xvp+7umDU/bLsuxER+0XPF5M0vwdcks/Tge+KCWX3wWdMIOnltVKfDRFfsf7HOznwr4sE5zUxb0nkfCayLMZ/m/kcgqy9QryAl+SY/+MmLlmnxEI6eyjtnX0rf8qZyZDGI=\"}";
//
// $ret = ArrayUtil::SignVerify(json_decode($retData,true),$publicKeyPath);
// echo $ret;
} }
} catch (PayException $e) { } catch (PayException $e) {
echo $e->errorMessage(); echo $e->errorMessage();
......
<?php
require_once __DIR__ . '/../../autoload.php';
use Payment\Common\PayException;
use Payment\Client\Cancel;
use Payment\Config;
date_default_timezone_set('Asia/Shanghai');
//$configStr = "{\"pay_var\":\"201\",\"pay_type\":\"010\",\"service_id\":\"015\",\"mch_id\":\"858100307000002\",\"merchant_no\":\"858100307000002\",\"terminal_id\":\"30055973\",\"sub_appid\":\"wx24863377e74518f8\",\"app_id\":\"wx24863377e74518f8\",\"limit_pay\":[\"\"],\"access_token\":\"bae3420022594dd9a14703f890765f9e\",\"notify_url\":\"http://www.ledian.com/payments/notify\",\"use_sandbox\":false,\"return_raw\":false}";
$configStr = '{"pay_type":"010","mch_id":"879104816000039","merchant_no":"879104816000039","terminal_id":"11558708","sub_appid":"wx2eaddb8e674394aa","app_id":"wx2eaddb8e674394aa","limit_pay":[""],"access_token":"3846bb6b7909488595c58e19a2211131","base_url":"https://pay.lcsw.cn/lcsw","notify_url":"http://api.test.ledianyun.com/payments/notify","use_sandbox":false,"return_raw":false}';
$config = json_decode($configStr,true);
// 订单信息
//$payDataStr = "{\"terminal_trace\":\"20190327151722366145505357545320\",\"total_fee\":1,\"order_body\":\"支付测试\",\"open_id\":\"oUlAM0Wp1K1rJEGJ0t__Ls5-qFKE\",\"attach\":\"10054c238f670a2e9649a8b100f20562\"}";
$payDataStr = '{"pay_type":"010","terminal_trace":"20210610120232330798565348995620","out_trade_no":"115587081421321062314555821032"}';
$payData = json_decode($payDataStr,true);
$config['base_url'] = 'https://pay.lcsw.cn/lcsw';
try {
$ret = Cancel::run(Config::SW_T_CHARGE, $config, $payData);
} catch (PayException $e) {
echo $e->errorMessage();
exit;
}
echo json_encode($ret, JSON_UNESCAPED_UNICODE);
/**
* {"attach":"e0c3b706044a99f143be92ee11071370","channel_order_no":"115587081421321062314555821032","channel_trade_no":"","end_time":"20210623155646","merchant_name":"西安乐店蜂抢信息科技有限公司1","mercha816000039","out_trade_no":"115587081421321062314555821032","pay_time":"20210623145558","pay_trace":"20210610120232330798565348995620","pay_type":"010","result_code":"03","return_code":"01","return_msg":"未支付","terminal_id":"11558708","terminal_time":"20210623155645","terminal_trace":"20210610120232330798565348995620","total_fee":"2","trade_state":"NOTPAY","typeMsg":"","user_id":""}%
*/
\ No newline at end of file
<?php
require_once __DIR__ . '/../../autoload.php';
use Payment\Common\PayException;
use Payment\Client\Close;
use Payment\Config;
date_default_timezone_set('Asia/Shanghai');
//$configStr = "{\"pay_var\":\"201\",\"pay_type\":\"010\",\"service_id\":\"015\",\"mch_id\":\"858100307000002\",\"merchant_no\":\"858100307000002\",\"terminal_id\":\"30055973\",\"sub_appid\":\"wx24863377e74518f8\",\"app_id\":\"wx24863377e74518f8\",\"limit_pay\":[\"\"],\"access_token\":\"bae3420022594dd9a14703f890765f9e\",\"notify_url\":\"http://www.ledian.com/payments/notify\",\"use_sandbox\":false,\"return_raw\":false}";
$configStr = '{"pay_type":"010","mch_id":"879104816000039","merchant_no":"879104816000039","terminal_id":"11558708","sub_appid":"wx2eaddb8e674394aa","app_id":"wx2eaddb8e674394aa","limit_pay":[""],"access_token":"3846bb6b7909488595c58e19a2211131","base_url":"https://pay.lcsw.cn/lcsw","notify_url":"http://api.test.ledianyun.com/payments/notify","use_sandbox":false,"return_raw":false}';
$config = json_decode($configStr,true);
// 订单信息
//$payDataStr = "{\"terminal_trace\":\"20190327151722366145505357545320\",\"total_fee\":1,\"order_body\":\"支付测试\",\"open_id\":\"oUlAM0Wp1K1rJEGJ0t__Ls5-qFKE\",\"attach\":\"10054c238f670a2e9649a8b100f20562\"}";
$payDataStr = '{"pay_type":"010","terminal_trace":"20210610120232330798565348995620","out_trade_no":"115587081421321062314555821032"}';
$payData = json_decode($payDataStr,true);
$config['base_url'] = 'https://pay.lcsw.cn/lcsw';
try {
$ret = Close::run(Config::SW_T_CHARGE, $config, $payData);
} catch (PayException $e) {
echo $e->errorMessage();
exit;
}
echo json_encode($ret, JSON_UNESCAPED_UNICODE);
/**
* {"package":{"result_code":"01"},"other":{"pay_type":"010","merchant_no":"879104816000039","terminal_id":"11558708","terminal_trace":"20210610120232330798565348995620","terminal_time":"20210623165004"}}
*/
\ No newline at end of file
<?php
require_once __DIR__ . '/../../autoload.php';
use Payment\Common\PayException;
use Payment\Client\Charge;
use Payment\Config;
date_default_timezone_set('Asia/Shanghai');
//$configStr = "{\"pay_var\":\"201\",\"pay_type\":\"010\",\"service_id\":\"015\",\"mch_id\":\"858100307000002\",\"merchant_no\":\"858100307000002\",\"terminal_id\":\"30055973\",\"sub_appid\":\"wx24863377e74518f8\",\"app_id\":\"wx24863377e74518f8\",\"limit_pay\":[\"\"],\"access_token\":\"bae3420022594dd9a14703f890765f9e\",\"notify_url\":\"http://www.ledian.com/payments/notify\",\"use_sandbox\":false,\"return_raw\":false}";
$configStr = '{"pay_var":"201","pay_type":"010","mch_id":"879104816000039","merchant_no":"879104816000039","terminal_id":"11558708","sub_appid":"wx2eaddb8e674394aa","app_id":"wx2eaddb8e674394aa","limit_pay":[""],"access_token":"3846bb6b7909488595c58e19a2211131","base_url":"https://pay.lcsw.cn/lcsw","notify_url":"http://api.test.ledianyun.com/payments/notify","use_sandbox":false,"return_raw":false}';
$config = json_decode($configStr,true);
// 订单信息
//$payDataStr = "{\"terminal_trace\":\"20190327151722366145505357545320\",\"total_fee\":1,\"order_body\":\"支付测试\",\"open_id\":\"oUlAM0Wp1K1rJEGJ0t__Ls5-qFKE\",\"attach\":\"10054c238f670a2e9649a8b100f20562\"}";
$payDataStr = '{"service_id":"015","terminal_trace":"20210610120224954476481015748920","total_fee":2,"order_body":"【乐店云】微信支付","open_id":"oDqg_5WEH2ROdZhRN7g3ERebi4e4","attach":"c7264439ab86385bc16a73b85ce3d134"}';
$payData = json_decode($payDataStr,true);
$config['base_url'] = 'https://pay.lcsw.cn/lcsw';
try {
$ret = Charge::run(Config::SW_T_CHANNEL_LITE, $config, $payData);
} catch (PayException $e) {
echo $e->errorMessage();
exit;
}
echo json_encode($ret, JSON_UNESCAPED_UNICODE);
/**
*{"jspackage":{"timeStamp":"1624435123","nonceStr":"c15e4cbeb7eb4bc0b3e0f854c78aa567","package":"prepay_id=wx231558436993717e6c28d89771ac690000","signType":"RSA","paySign":"HNLOvvAnQ8r4Y1Ciu5wt8fxckykaLMBheT7vqFgZGKcR4aPPJwpJ5OVMs9fhoLIADkPPFaVLIxd7eFxVzQWlW2axzZQrKJwA\/52KtRxlEfwAY2Uko\/lmNecfcdJmwFMtmb+qw+8aQrAo7Ck4p7fnqZnErtwV3R0i8c+g2dnbum37YP1XbvFpXwPCCDoSpcOThDHf4ss\/TxKMJUh3oK36HAXVfJTB\/Vgs3Va\/QaUpWNbhXCoQUbvlAiO26mFXotTxd2Gph7hzkcwJcmyEwvaeenAvmrq5XGihnFVZ0t7Wvec0rxpmfHA2FPcQMWBqfzuDsW4pDK1A9PF5OLmhs3j5mA=="},"other":{"pay_type":"010","merchant_name":"西安乐店蜂抢信息科技有限公司1","merchan16000039","terminal_id":"11558708","terminal_trace":"20210610120224954476481015748920","terminal_time":"20210623155842","total_fee":"2","out_trade_no":"115587084621621062315584324331"}}
*/
\ No newline at end of file
<?php
/**
* 第三方支付回调处理
*
* @createTime: 2016-07-25 15:57
* @description: 支付通知回调
*/
require_once __DIR__ . '/../../autoload.php';
require_once __DIR__ . '/../testNotify.php';
use Payment\Common\PayException;
use Payment\Client\Notify;
use Payment\Config;
use Payment\Utils\ArrayUtil;
date_default_timezone_set('Asia/Shanghai');
$configStr = "{\"pay_var\":\"100\",\"pay_type\":\"010\",\"service_id\":\"015\",\"mch_id\":\"858100307000002\",\"merchant_no\":\"858100307000002\",\"terminal_id\":\"30055973\",\"sub_appid\":\"wx24863377e74518f8\",\"app_id\":\"wx24863377e74518f8\",\"limit_pay\":[\"\"],\"access_token\":\"bae3420022594dd9a14703f890765f9e\",\"notify_url\":\"http://www.ledian.com/payments/notify\",\"use_sandbox\":false,\"return_raw\":false}";
$config = json_decode($configStr,true);
$callback = new TestNotify();
try {
if (!empty($config)){
// Notify::run(Config::SW_CHARGE,$config,$callback);
// $retData = Notify::getNotifyData($type, $config);// 获取第三方的原始数据,未进行签名检查
$retDataStr = "{\"attach\":\"a3f7a2b605e84762868ecf92f97146bf\",\"channel_trade_no\":\"4200000277201903277386709856\",\"end_time\":\"20190327172739\",\"key_sign\":\"572c4d043a58f605202e4d2f0e4e66d8\",\"merchant_name\":\"袁梦对接专用(勿动)\",\"merchant_no\":\"858100307000002\",\"out_trade_no\":\"300559730021619032717272800016\",\"pay_type\":\"010\",\"receipt_fee\":\"1\",\"result_code\":\"01\",\"return_code\":\"01\",\"return_msg\":\"支付成功\",\"terminal_id\":\"30055973\",\"terminal_time\":\"20190327172726\",\"terminal_trace\":\"20190327172726469910101555098120\",\"total_fee\":\"1\",\"user_id\":\"oO4lo5KBwCtX5CPayZV2WedgMjRc\"}";
$retData = json_decode($retDataStr,true);
$notify = new \Payment\Notify\SwNotify($config);
$ret = $notify->checkNotifyData($retData);
die($ret);
// $basePath = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'CacertFile' . DIRECTORY_SEPARATOR;
// $publicKeyPath = "{$basePath}mipay".DIRECTORY_SEPARATOR."meepay_public_key.pem";
// $publicKeyPath = "/project/ldy/payment/src/CacertFile/mipay/meepay_public_key.pem";
// $retData = "{\"result_code\":\"SUCCESS\",\"out_trade_sn\":\"SN20181031020706\",\"meepay_trade_no\":\"MF0118103102070684504\",\"transaction_id\":\"4200000203201810316768166604\",\"sub_merchant_id\":\"10002\",\"sub_appid\":\"wx03b4aeb839cc8d85\",\"sub_openid\":\"oUlAM0fD5RsWs9CvOCCMU_nYEDSY\",\"total_amount\":\"1\",\"trade_type\":\"NATIVE\",\"nonce_str\":\"af7rhpf50cjqjadyzthu82hyl7rzdkgk\",\"fee_type\":\"CNY\",\"cash_fee\":\"1\",\"attach\":\"1233\",\"sign_type\":\"RSA2\",\"sign\":\"d0AsaPytw9by+gfD9DLBHp9s1U+aQt9qVd1DYjPP4xvp+7umDU/bLsuxER+0XPF5M0vwdcks/Tge+KCWX3wWdMIOnltVKfDRFfsf7HOznwr4sE5zUxb0nkfCayLMZ/m/kcgqy9QryAl+SY/+MmLlmnxEI6eyjtnX0rf8qZyZDGI=\"}";
//
// $ret = ArrayUtil::SignVerify(json_decode($retData,true),$publicKeyPath);
// echo $ret;
}
} catch (PayException $e) {
echo $e->errorMessage();
exit;
}
var_dump($ret);
exit;
<?php
require_once __DIR__ . '/../../autoload.php';
use Payment\Common\PayException;
use Payment\Client\Query;
use Payment\Config;
date_default_timezone_set('Asia/Shanghai');
//$configStr = "{\"pay_var\":\"201\",\"pay_type\":\"010\",\"service_id\":\"015\",\"mch_id\":\"858100307000002\",\"merchant_no\":\"858100307000002\",\"terminal_id\":\"30055973\",\"sub_appid\":\"wx24863377e74518f8\",\"app_id\":\"wx24863377e74518f8\",\"limit_pay\":[\"\"],\"access_token\":\"bae3420022594dd9a14703f890765f9e\",\"notify_url\":\"http://www.ledian.com/payments/notify\",\"use_sandbox\":false,\"return_raw\":false}";
$configStr = '{"pay_type":"010","mch_id":"879104816000039","merchant_no":"879104816000039","terminal_id":"11558708","sub_appid":"wx2eaddb8e674394aa","app_id":"wx2eaddb8e674394aa","limit_pay":[""],"access_token":"3846bb6b7909488595c58e19a2211131","base_url":"https://pay.lcsw.cn/lcsw","notify_url":"http://api.test.ledianyun.com/payments/notify","use_sandbox":false,"return_raw":false}';
$config = json_decode($configStr,true);
// 订单信息
//$payDataStr = "{\"terminal_trace\":\"20190327151722366145505357545320\",\"total_fee\":1,\"order_body\":\"支付测试\",\"open_id\":\"oUlAM0Wp1K1rJEGJ0t__Ls5-qFKE\",\"attach\":\"10054c238f670a2e9649a8b100f20562\"}";
$payDataStr = '{"pay_type":"010","terminal_trace":"20210610120232330798565348995620","out_trade_no":"115587081421321062314555821032"}';
$payData = json_decode($payDataStr,true);
$config['base_url'] = 'https://pay.lcsw.cn/lcsw';
try {
$ret = Query::run(Config::SW_T_QUERY, $config, $payData);
} catch (PayException $e) {
echo $e->errorMessage();
exit;
}
echo json_encode($ret, JSON_UNESCAPED_UNICODE);
/**
* {"attach":"e0c3b706044a99f143be92ee11071370","channel_order_no":"115587081421321062314555821032","channel_trade_no":"","end_time":"20210623155646","merchant_name":"西安乐店蜂抢信息科技有限公司1","mercha816000039","out_trade_no":"115587081421321062314555821032","pay_time":"20210623145558","pay_trace":"20210610120232330798565348995620","pay_type":"010","result_code":"03","return_code":"01","return_msg":"未支付","terminal_id":"11558708","terminal_time":"20210623155645","terminal_trace":"20210610120232330798565348995620","total_fee":"2","trade_state":"NOTPAY","typeMsg":"","user_id":""}%
*/
\ No newline at end of file
<?php
require_once __DIR__ . '/../../autoload.php';
use Payment\Common\PayException;
use Payment\Client\Refund;
use Payment\Config;
date_default_timezone_set('Asia/Shanghai');
$configStr = '{"pay_type":"010","mch_id":"879104816000039","merchant_no":"879104816000039","terminal_id":"11558708","sub_appid":"wx2eaddb8e674394aa","app_id":"wx2eaddb8e674394aa","limit_pay":[""],"access_token":"3846bb6b7909488595c58e19a2211131","base_url":"https://pay.lcsw.cn/lcsw","notify_url":"http://api.test.ledianyun.com/payments/notify","use_sandbox":false,"return_raw":false}';
$config = json_decode($configStr,true);
// 订单信息
$payDataStr = '{"pay_type":"010","terminal_trace":"20210610120232330798565348995620","out_trade_no":"115587081421321062314555821032","refund_fee":"2"}';
$payData = json_decode($payDataStr,true);
$config['base_url'] = 'https://pay.lcsw.cn/lcsw';
try {
$ret = Refund::run(Config::SW_T_REFUND, $config, $payData);
} catch (PayException $e) {
echo $e->errorMessage();
exit;
}
echo json_encode($ret, JSON_UNESCAPED_UNICODE);
/**
* 支付平台返回错误提示:02 : 原交易状态为非成功
*/
\ No newline at end of file
<?php
require_once __DIR__ . '/../../autoload.php';
use Payment\Common\PayException;
use Payment\Client\Charge;
use Payment\Config;
date_default_timezone_set('Asia/Shanghai');
//$configStr = "{\"pay_var\":\"201\",\"pay_type\":\"010\",\"service_id\":\"015\",\"mch_id\":\"858100307000002\",\"merchant_no\":\"858100307000002\",\"terminal_id\":\"30055973\",\"sub_appid\":\"wx24863377e74518f8\",\"app_id\":\"wx24863377e74518f8\",\"limit_pay\":[\"\"],\"access_token\":\"bae3420022594dd9a14703f890765f9e\",\"notify_url\":\"http://www.ledian.com/payments/notify\",\"use_sandbox\":false,\"return_raw\":false}";
$configStr = '{"pay_var":"201","pay_type":"010","mch_id":"879104816000039","merchant_no":"879104816000039","terminal_id":"11558708","sub_appid":"wx2eaddb8e674394aa","app_id":"wx2eaddb8e674394aa","limit_pay":[""],"access_token":"3846bb6b7909488595c58e19a2211131","base_url":"https://pay.lcsw.cn/lcsw","notify_url":"http://api.test.ledianyun.com/payments/notify","use_sandbox":false,"return_raw":false}';
$config = json_decode($configStr,true);
// 订单信息
//$payDataStr = "{\"terminal_trace\":\"20190327151722366145505357545320\",\"total_fee\":1,\"order_body\":\"支付测试\",\"open_id\":\"oUlAM0Wp1K1rJEGJ0t__Ls5-qFKE\",\"attach\":\"10054c238f670a2e9649a8b100f20562\"}";
$payDataStr = '{"pay_ver":"201","pay_type":"010","service_id":"012","terminal_trace":"20210610120232330798565348995620","total_fee":2,"order_body":"【乐店云】微信支付","open_id":"oDqg_5WEH2ROdZhRN7g3ERebi4e4","openid":"oDqg_5WEH2ROdZhRN7g3ERebi4e4","attach":"e0c3b706044a99f143be92ee11071370"}';
$payData = json_decode($payDataStr,true);
$config['base_url'] = 'https://pay.lcsw.cn/lcsw';
try {
$ret = Charge::run(Config::SW_T_CHANNEL_PUB, $config, $payData);
} catch (PayException $e) {
echo $e->errorMessage();
exit;
}
echo json_encode($ret, JSON_UNESCAPED_UNICODE);
/**
* {"jspackage":{"appId":"wx2eaddb8e674394aa","timeStamp":"1624435057","nonceStr":"a410b9b125304c2992c8be9cdb752f17","package":"prepay_id=wx23155737206767b91d90be7ec033180000","signType":"RSA","paySign":"3C1FR8cXtqBzbp8dBQSjdfnUGKwv9TqyRbf7RadvNqFCd7I3ayRkzDSVPy7\/Nd2g1FbQIgtyeN7RH1y+RA7If\/jqUP5NVTJJnxmUpqi0a4zFq\/5UYNmGJ0xTXHmquVBvnFaddkyQ\/MmsxMrbTlTDaHb6CQwr6o9qEaTutzMOd97\/MAj1T5h86Vyu4fu5BHcaMWo4mUyBWBXl7bB3fqrlNzKLxijEZzov\/MhTZQ4MpTC7OBOGU7t3yJ+iSw+W87WHiHhsssFO\/jZZ\/PJ0pKiKrVF5hj\/te9whqXpjCpoWoc9hDKd92NrhO82H3acpfjge1FyimbYjPTQXzgkcoZNB7Q=="},"other":{"out_trade_no":"115587085921321062315573623420"}}
*/
\ No newline at end of file
...@@ -11,6 +11,7 @@ use Payment\Cancel\FuCancel; ...@@ -11,6 +11,7 @@ use Payment\Cancel\FuCancel;
use Payment\Charge\LTF\LTFCancel; 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\SwThree\SwThreeCancel;
use Payment\Charge\TLpay\TLCancel; use Payment\Charge\TLpay\TLCancel;
use Payment\Charge\YS\YSCancel; use Payment\Charge\YS\YSCancel;
use Payment\Common\BaseStrategy; use Payment\Common\BaseStrategy;
...@@ -51,6 +52,9 @@ class CancelContext{ ...@@ -51,6 +52,9 @@ class CancelContext{
case Config::SW_CHARGE: case Config::SW_CHARGE:
$this->cancelHandler = new SwCancel($config); $this->cancelHandler = new SwCancel($config);
break; break;
case Config::SW_T_CHARGE:
$this->cancelHandler = new SwThreeCancel($config);
break;
case Config::FU_CHARGE: case Config::FU_CHARGE:
$this->cancelHandler = new FuCancel($config); $this->cancelHandler = new FuCancel($config);
break; 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;
}
}
...@@ -28,6 +28,10 @@ use Payment\Charge\Sw\SwBarCharge; ...@@ -28,6 +28,10 @@ use Payment\Charge\Sw\SwBarCharge;
use Payment\Charge\Sw\SwFaceCharge; use Payment\Charge\Sw\SwFaceCharge;
use Payment\Charge\Sw\SwFaceInfo; use Payment\Charge\Sw\SwFaceInfo;
use Payment\Charge\Sw\SwLiteCharge; use Payment\Charge\Sw\SwLiteCharge;
use Payment\Charge\SwThree\SwLiteThreeCharge;
use Payment\Charge\SwThree\SwPubThreeCharge;
use Payment\Charge\SwThree\SwScanThreeCharge;
use Payment\Charge\SwThree\SwBarThreeCharge;
use Payment\Charge\Sw\SwPubCharge; use Payment\Charge\Sw\SwPubCharge;
use Payment\Charge\Sw\SwScanCharge; use Payment\Charge\Sw\SwScanCharge;
use Payment\Charge\TLpay\TLLiteCharge; use Payment\Charge\TLpay\TLLiteCharge;
...@@ -140,6 +144,26 @@ class ChargeContext ...@@ -140,6 +144,26 @@ class ChargeContext
$this->channel = new SwFaceInfo($config); $this->channel = new SwFaceInfo($config);
break; 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_PUB:
case Config::FU_CHANNEL_LITE: case Config::FU_CHANNEL_LITE:
......
...@@ -39,6 +39,7 @@ class Cancel ...@@ -39,6 +39,7 @@ class Cancel
Config::MI_CHANNEL_LITE, //米付 Config::MI_CHANNEL_LITE, //米付
Config::SW_CHARGE, //扫呗支付退款 Config::SW_CHARGE, //扫呗支付退款
Config::SW_T_CHARGE, //扫呗支付(3.0)撤销(退款)
Config::FU_CHARGE, //富友 Config::FU_CHARGE, //富友
Config::LTF_CHARGE, Config::LTF_CHARGE,
......
...@@ -37,6 +37,12 @@ class Charge ...@@ -37,6 +37,12 @@ class Charge
Config::SW_CHANNEL_FACEPAY, Config::SW_CHANNEL_FACEPAY,
Config::SW_CHANNEL_BAR, Config::SW_CHANNEL_BAR,
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_PUB,
Config::FU_CHANNEL_LITE, Config::FU_CHANNEL_LITE,
Config::FU_CHANNEL_SCAN, Config::FU_CHANNEL_SCAN,
......
...@@ -16,6 +16,7 @@ class Close { ...@@ -16,6 +16,7 @@ class Close {
private static $supportChannel = [ private static $supportChannel = [
Config::SW_CHARGE, //扫呗支付关闭订单 Config::SW_CHARGE, //扫呗支付关闭订单
Config::SW_T_CHARGE, //扫呗支付(3.0)关闭订单
Config::FU_CHARGE, //富友支付关闭订单 Config::FU_CHARGE, //富友支付关闭订单
Config::LTF_CHARGE,//联拓富支付关闭订单 Config::LTF_CHARGE,//联拓富支付关闭订单
Config::YS_CHARGE,//易生支付关闭订单 Config::YS_CHARGE,//易生支付关闭订单
......
...@@ -26,6 +26,8 @@ class Notify ...@@ -26,6 +26,8 @@ class Notify
Config::SW_CHARGE,//扫呗 Config::SW_CHARGE,//扫呗
Config::SW_T_CHARGE,//扫呗(3.0)
Config::FU_CHARGE, //富友 Config::FU_CHARGE, //富友
Config::LTF_CHARGE, //联拓富 Config::LTF_CHARGE, //联拓富
......
...@@ -39,6 +39,7 @@ class Query ...@@ -39,6 +39,7 @@ class Query
Config::MI_QUERY,//米付 Config::MI_QUERY,//米付
Config::SW_QUERY,//扫呗 Config::SW_QUERY,//扫呗
Config::SW_T_QUERY,//扫呗(3.0)
Config::FU_CHARGE, Config::FU_CHARGE,
Config::FU_REFUND, Config::FU_REFUND,
......
...@@ -33,6 +33,7 @@ class Refund ...@@ -33,6 +33,7 @@ class Refund
Config::MI_REFUND,//米付 Config::MI_REFUND,//米付
Config::SW_REFUND,//扫呗 Config::SW_REFUND,//扫呗
Config::SW_T_REFUND,//扫呗(3.0)
Config::FU_REFUND, //富友 Config::FU_REFUND, //富友
Config::LTF_REFUND, Config::LTF_REFUND,
......
...@@ -5,6 +5,7 @@ namespace Payment; ...@@ -5,6 +5,7 @@ namespace Payment;
use Payment\Charge\Fu\FuClose; use Payment\Charge\Fu\FuClose;
use Payment\Charge\LTF\LTFClose; use Payment\Charge\LTF\LTFClose;
use Payment\Charge\Sw\SwClose; use Payment\Charge\Sw\SwClose;
use Payment\Charge\SwThree\SwThreeClose;
use Payment\Charge\YS\YSClose; use Payment\Charge\YS\YSClose;
use Payment\Common\BaseStrategy; use Payment\Common\BaseStrategy;
use Payment\Common\PayException; use Payment\Common\PayException;
...@@ -38,6 +39,9 @@ class CloseContext{ ...@@ -38,6 +39,9 @@ class CloseContext{
case Config::SW_CHARGE: case Config::SW_CHARGE:
$this->closeHandler = new SwClose($config); $this->closeHandler = new SwClose($config);
break; break;
case Config::SW_T_CHARGE:
$this->closeHandler = new SwThreeClose($config);
break;
case Config::FU_CHARGE: case Config::FU_CHARGE:
$this->closeHandler = new FuClose($config); $this->closeHandler = new FuClose($config);
break; break;
......
...@@ -63,6 +63,8 @@ abstract class BaseData ...@@ -63,6 +63,8 @@ abstract class BaseData
$this->channel = Config::LTF_PAY; $this->channel = Config::LTF_PAY;
} elseif ($config instanceof YSConfig) { } elseif ($config instanceof YSConfig) {
$this->channel = Config::YS_PAY; $this->channel = Config::YS_PAY;
}elseif ($config instanceof SwThreeConfig) {
$this->channel = Config::SW_T_PAY;
} }
$this->data = array_merge($config->toArray(), $reqData);//配置信息合并 $this->data = array_merge($config->toArray(), $reqData);//配置信息合并
...@@ -140,6 +142,14 @@ abstract class BaseData ...@@ -140,6 +142,14 @@ abstract class BaseData
$signStr = ArrayUtil::createLinkstring($values); $signStr = ArrayUtil::createLinkstring($values);
$this->makeSign($signStr); $this->makeSign($signStr);
break; break;
case Config::SW_T_PAY:
//添加令牌,参数由makesign函数自由控制
$signData = $this->retData ?? $data;
$values = ArrayUtil::removeKeys($signData, ['key_sign']);
$values = ArrayUtil::arraySort($values);
$signStr = ArrayUtil::createLinkstring($values);
$this->makeSign($signStr);
break;
case Config::FU_PAY: case Config::FU_PAY:
$signData = ArrayUtil::arraySort(ArrayUtil::removeKeys(empty($this->certainSignData) ? $data : $this->certainSignData, ['sign'])); $signData = ArrayUtil::arraySort(ArrayUtil::removeKeys(empty($this->certainSignData) ? $data : $this->certainSignData, ['sign']));
foreach ($signData as $key => $value) if (false !== strpos($key, 'reserved_')) unset($signData[$key]); foreach ($signData as $key => $value) if (false !== strpos($key, 'reserved_')) unset($signData[$key]);
......
<?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->pay_ver = '201';
$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->pay_ver = '201';
$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()
{
}
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()
{
$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($signData);
}
}
\ 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);
}
}
...@@ -34,6 +34,8 @@ final class Config{ ...@@ -34,6 +34,8 @@ final class Config{
const YS_PAY = 'yspay'; //易生支付 const YS_PAY = 'yspay'; //易生支付
const SW_T_PAY = 'swpay_t'; //扫呗支付(3.0)
//========================= 金额问题设置 =======================// //========================= 金额问题设置 =======================//
const PAY_MIN_FEE = '0.01';// 支付的最小金额 const PAY_MIN_FEE = '0.01';// 支付的最小金额
...@@ -143,8 +145,7 @@ final class Config{ ...@@ -143,8 +145,7 @@ final class Config{
const MI_QUERY = 'mi_query'; // 米付查询接口 const MI_QUERY = 'mi_query'; // 米付查询接口
//========================= 扫呗相关接口 =======================// //========================= 扫呗相关接口 =======================//
//http://www.lcsw.cn/doc/api/payment.html //http://www.lcsw.cn/doc/api/payment.html
// 支付常量 // 支付常量
const SW_CHANNEL_PUB = 'sw_pub';// 微信公众号h5支付 const SW_CHANNEL_PUB = 'sw_pub';// 微信公众号h5支付
...@@ -171,6 +172,26 @@ final class Config{ ...@@ -171,6 +172,26 @@ final class Config{
const SW_QUERY = 'sw_query'; // 查询接口 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; ...@@ -15,6 +15,7 @@ use Payment\Notify\MiNotify;
use Payment\Notify\NotifyStrategy; use Payment\Notify\NotifyStrategy;
use Payment\Notify\PayNotifyInterface; use Payment\Notify\PayNotifyInterface;
use Payment\Notify\SwNotify; use Payment\Notify\SwNotify;
use Payment\Notify\SwThreeNotify;
use Payment\Notify\TLNotify; use Payment\Notify\TLNotify;
use Payment\Notify\WxNotify; use Payment\Notify\WxNotify;
use Payment\Common\PayException; use Payment\Common\PayException;
...@@ -60,6 +61,9 @@ class NotifyContext ...@@ -60,6 +61,9 @@ class NotifyContext
case Config::SW_CHARGE: case Config::SW_CHARGE:
$this->notify = new SwNotify($config); $this->notify = new SwNotify($config);
break; break;
case Config::SW_T_CHARGE:
$this->notify = new SwThreeNotify($config);
break;
case Config::FU_CHARGE: case Config::FU_CHARGE:
$this->notify = new FuNotify($config); $this->notify = new FuNotify($config);
break; 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)
{
// 移除sign
unset($ret['key_sign']);
return $ret;
}
}
...@@ -21,6 +21,7 @@ use Payment\Query\LTF\LTFChargeQuery; ...@@ -21,6 +21,7 @@ use Payment\Query\LTF\LTFChargeQuery;
use Payment\Query\LTF\LTFRefundQuery; 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\SwThree\SwChargeThreeQuery;
use Payment\Query\TLpay\TLQuery; use Payment\Query\TLpay\TLQuery;
use Payment\Query\Wx\WxChargeQuery; use Payment\Query\Wx\WxChargeQuery;
use Payment\Query\Wx\WxPayBankQuery; use Payment\Query\Wx\WxPayBankQuery;
...@@ -89,7 +90,9 @@ class QueryContext ...@@ -89,7 +90,9 @@ class QueryContext
case Config::SW_QUERY:// 扫呗查询 case Config::SW_QUERY:// 扫呗查询
$this->query = new SwChargeQuery($config); $this->query = new SwChargeQuery($config);
break; break;
case Config::SW_T_QUERY:// 扫呗(3.0)查询
$this->query = new SwChargeThreeQuery($config);
break;
case Config::FU_CHARGE: case Config::FU_CHARGE:
$this->query = new FuChargeQuery($config); $this->query = new FuChargeQuery($config);
break; break;
......
<?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; ...@@ -16,6 +16,7 @@ use Payment\Refund\FuRefund;
use Payment\Refund\LTFRefund; use Payment\Refund\LTFRefund;
use Payment\Refund\MiRefund; use Payment\Refund\MiRefund;
use Payment\Refund\SwRefund; use Payment\Refund\SwRefund;
use Payment\Refund\SwThreeRefund;
use Payment\Refund\TLRefund; use Payment\Refund\TLRefund;
use Payment\Refund\WxRefund; use Payment\Refund\WxRefund;
use Payment\Refund\YSRefund; use Payment\Refund\YSRefund;
...@@ -60,6 +61,9 @@ class RefundContext ...@@ -60,6 +61,9 @@ class RefundContext
case Config::SW_REFUND: case Config::SW_REFUND:
$this->refund = new SwRefund($config); $this->refund = new SwRefund($config);
break; break;
case Config::SW_T_REFUND:
$this->refund = new SwThreeRefund($config);
break;
case Config::FU_REFUND: case Config::FU_REFUND:
$this->refund = new FuRefund($config); $this->refund = new FuRefund($config);
break; break;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!