Commit f52e41d8 by 赵凯(PHP)

update

1 parent b01d0be6
Showing with 5278 additions and 30 deletions
.idea
.DS_Store
/codecept.phar
/examples/test.php
/examples/wx/pem
/vendor/
/examples_bak/
/composer.lock
/examples/wxconfig-bak.php
/examples/wx/pem/
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="DuplicatedCode" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<Languages>
<language minSize="60" name="PHP" />
</Languages>
</inspection_tool>
</profile>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/payment.iml" filepath="$PROJECT_DIR$/.idea/payment.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" packagePrefix="Payment\" />
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PhpProjectSharedConfiguration" php_language_level="7" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
......@@ -8,11 +8,13 @@ use Payment\Config;
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);
// 订单信息
$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';
......
......@@ -15,30 +15,17 @@ 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}";
$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);
$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();
......
<?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
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
<?php
date_default_timezone_set('Asia/Shanghai');
require_once __DIR__.'/../../autoload.php';
//require_once __DIR__.'/common.php';
use Payment\Common\PayException;
use Payment\Client\Charge;
use Payment\Config;
$config = [
'channelid' => '860010010210008',
'key' => 'fkdkldvkij5dfd24dl24dk2dddflaaf2',
'merid' => '880210010215460',
'termid' => '10006468',
];
$payData = [
'tradetrace' => '11620210303155407146230',
'oritradetrace' => '2019062017085196425851101914',
];
try{
$ret = \Payment\Client\Cancel::run(Config::YS_CHARGE, $config, $payData);
}catch(PayException $e){
exit($e->errorMessage());
}
echo json_encode($ret, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
<?php
date_default_timezone_set('Asia/Shanghai');
require_once __DIR__.'/../../autoload.php';
//require_once __DIR__.'/common.php';
use Payment\Common\PayException;
use Payment\Client\Charge;
use Payment\Config;
$config = [
'channelid' => '860010010210008',
'key' => 'fkdkldvkij5dfd24dl24dk2dddflaaf2',
'merid' => '880210010215460',
'termid' => '10006468',
];
$payData = [
// 'tradetrace' => '11620210304155042147189',
'tradetrace' => '2019062017085196425851101914',
// 'oritradetrace' => '2019062017085196425851101914',
];
try{
$ret = \Payment\Client\Close::run(Config::YS_CHARGE, $config, $payData);
}catch(PayException $e){
exit($e->errorMessage());
}
echo json_encode($ret, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
<?php
date_default_timezone_set('Asia/Shanghai');
require_once __DIR__.'/../../autoload.php';
//require_once __DIR__.'/common.php';
use Payment\Common\PayException;
use Payment\Client\Charge;
use Payment\Config;
$config = [
'channelid' => '860010010210008',
'key' => 'fkdkldvkij5dfd24dl24dk2dddflaaf2',
'merid' => '880210010215460',
'termid' => '10006468'
];
$payData = [
'notifyurl' => 'https://www.test.com/test/test.t',
'tradetrace' => '2019062017085196425851101915',
// 'openid' =>'oDqg_5Za0tc23LhTkUR6PfFZ8O2g',
'openid' =>'ohWpr5L1oy5SK4LMyoazVG4BJVGY',
'tradeamt'=>1
];
// $payData = [
// "out_trade_no" => "2019062017085196425851101915",
// "total_fee" => 1,
// "body" => 'hello 你好呀',
// "extra_param" => '',
// 'open_id' => "oDqg_5Za0tc23LhTkUR6PfFZ8O2g"
// ];
try{
$ret = Charge::run(Config::YS_CHANNEL_LITE, $config, $payData);
}catch(PayException $e){
exit($e->errorMessage());
}
echo json_encode($ret, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
<?php
date_default_timezone_set('Asia/Shanghai');
require_once __DIR__.'/../../autoload.php';
//require_once __DIR__.'/common.php';
use Payment\Common\PayException;
use Payment\Client\Charge;
use Payment\Config;
$config = [
'partner_id' => '826791873720039',
'seller_id' => 'QRY210802574454',
'seller_name' => '铜川市耀州区青丝坊发型设计室',
'business_code' => '3010002',
];
$payData = [
// 'method'=>'ysepay.online.weixin.pay',
'notify_url' => 'http://www.test.com/test/test.t',
'out_trade_no' =>'2019062017085196425851101912',
'shopdate' =>date('Ymd'),
'timestamp' =>date('Y-m-d H:i:s',time()),
'subject' =>'乐店云支付测试',
'total_amount' => 0.01,
'timeout_express' => '9h',
'sub_openid' => 'ohWpr5HtNcnMC94YBd6i9pqNU07Y',
'appid' => 'wxe48ea18f1edba2c7',
'extra_common_param' => '123123123213', //公用回传参数
];
try{
$ret = Charge::run(Config::YSE_CHANNEL_PUB, $config, $payData);
}catch(PayException $e){
exit($e->errorMessage());
}
echo json_encode($ret, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
<?php
date_default_timezone_set('Asia/Shanghai');
require_once __DIR__.'/../../autoload.php';
//require_once __DIR__.'/common.php';
use Payment\Common\PayException;
use Payment\Client\Query;
use Payment\Config;
$config = [
'partner_id' => '826791873720039',
'seller_id' => '826791873720039',
'seller_name' => '西安汇集信电子技术有限公司',
'business_code' => '3010002',
];
$payData = [
// 'method'=>'ysepay.online.weixin.pay',
'out_trade_no' =>'2019062017085196425851101912',
'shopdate' =>date('Ymd'),
'timestamp' =>date('Y-m-d H:i:s',time()),
];
try{
$ret = Query::run(Config::YSE_QUERY, $config, $payData);
}catch(PayException $e){
exit($e->errorMessage());
}
echo json_encode($ret, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
<?php
date_default_timezone_set('Asia/Shanghai');
require_once __DIR__.'/../../autoload.php';
//require_once __DIR__.'/common.php';
use Payment\Common\PayException;
use Payment\Client\Refund;
use Payment\Config;
$config = [
'partner_id' => '826791873720039',
'seller_id' => '826791873720039',
'seller_name' => '西安汇集信电子技术有限公司',
'business_code' => '3010002',
];
$payData = [
// 'method'=>'ysepay.online.trade.refund',
'out_trade_no' =>'2019062017085196425851101912',
'shopdate' =>'20210810',
'refund_amount' => 0.01,
'refund_reason' => '测试退款',
'out_request_no' => 'out_request_no',
];
try{
$ret = Refund::run(Config::YSE_REFUND, $config, $payData);
}catch(PayException $e){
exit($e->errorMessage());
}
echo json_encode($ret, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
<?php
date_default_timezone_set('Asia/Shanghai');
require_once __DIR__.'/../../autoload.php';
//require_once __DIR__.'/common.php';
use Payment\Common\PayException;
use Payment\Client\Charge;
use Payment\Config;
$config = [
'channelid' => 'D01X00000800856',
'key' => 'lldilrd58lr0o1204l3a32ji5ladavf5',
'merid' => '531000008882415',
'termid' => 'W0725858',
];
// {"sign":"5A21EDDAA1092578740FF5CFE4B12F27","wxopenid":"ohWpr5DmiDNk0tOh7eJ2NKEaOfjQ","wxtimeend":"20210814114050","tradetrace":"2021081411404288702697100565","clearamt":"1680","wxtransactionid":"4200001236202108145338315235","acctype":"U","payamt":"1680","wtorderid":"11620210814114046400091"}
$payData = [
'tradetrace' => '11620210814155733791279',
'oritradetrace' => '2021081415572994384657101545',
];
try{
$ret = \Payment\Client\Cancel::run(Config::YS_CHARGE, $config, $payData);
}catch(PayException $e){
exit($e->errorMessage());
}
echo json_encode($ret, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
<?php
date_default_timezone_set('Asia/Shanghai');
require_once __DIR__.'/../../autoload.php';
//require_once __DIR__.'/common.php';
use Payment\Common\PayException;
use Payment\Client\Charge;
use Payment\Config;
$config = [
'channelid' => '860010010210008',
'key' => 'fkdkldvkij5dfd24dl24dk2dddflaaf2',
'merid' => '880210010215460',
'termid' => '10006468',
];
$payData = [
// 'tradetrace' => '11620210304155042147189',
'tradetrace' => '2019062017085196425851101914',
// 'oritradetrace' => '2019062017085196425851101914',
];
try{
$ret = \Payment\Client\Close::run(Config::YS_CHARGE, $config, $payData);
}catch(PayException $e){
exit($e->errorMessage());
}
echo json_encode($ret, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
<?php
date_default_timezone_set('Asia/Shanghai');
require_once __DIR__.'/../../autoload.php';
//require_once __DIR__.'/common.php';
use Payment\Common\PayException;
use Payment\Client\Charge;
use Payment\Config;
$config = [
'channelid' => '860010010210008',
'key' => 'fkdkldvkij5dfd24dl24dk2dddflaaf2',
'merid' => '880210010215460',
'termid' => '10006468'
];
$payData = [
'notifyurl' => 'https://www.test.com/test/test.t',
'tradetrace' => '2019062017085196425851101915',
// 'openid' =>'oDqg_5Za0tc23LhTkUR6PfFZ8O2g',
'openid' =>'ohWpr5L1oy5SK4LMyoazVG4BJVGY',
'tradeamt'=>1
];
// $payData = [
// "out_trade_no" => "2019062017085196425851101915",
// "total_fee" => 1,
// "body" => 'hello 你好呀',
// "extra_param" => '',
// 'open_id' => "oDqg_5Za0tc23LhTkUR6PfFZ8O2g"
// ];
try{
$ret = Charge::run(Config::YS_CHANNEL_LITE, $config, $payData);
}catch(PayException $e){
exit($e->errorMessage());
}
echo json_encode($ret, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
<?php
date_default_timezone_set('Asia/Shanghai');
require_once __DIR__.'/../../autoload.php';
//require_once __DIR__.'/common.php';
use Payment\Common\PayException;
use Payment\Client\Charge;
use Payment\Config;
$config = [
'channelid' => 'D01X00000800856',
'key' => 'lldilrd58lr0o1204l3a32ji5ladavf5',
'merid' => '531000009218530',
'termid' => 'W0810460',
];
$payData = [
'notifyurl' => 'https://www.test.com/test/test.t',
'tradetrace' => '2019062017085196425851101912',
'openid' =>'oDqg_5Za0tc23LhTkUR6PfFZ8O2g',
'tradeamt'=>1
];
try{
$ret = Charge::run(Config::YS_CHANNEL_PUB, $config, $payData);
}catch(PayException $e){
exit($e->errorMessage());
}
echo json_encode($ret, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
<?php
date_default_timezone_set('Asia/Shanghai');
require_once __DIR__.'/../../autoload.php';
//require_once __DIR__.'/common.php';
use Payment\Common\PayException;
use Payment\Client\Charge;
use Payment\Config;
$config = [
'channelid' => '860010010210008',
'key' => 'fkdkldvkij5dfd24dl24dk2dddflaaf2',
'merid' => '880210010215460',
'termid' => '10006468',
];
$payData = [
// 'notifyurl' => 'https://www.test.com/test/test.t',
'tradetrace' => '2019062017085196425851101914',
// 'tradetrace' => '2019062017085196425851101915',
// 'openid' =>'oDqg_5Za0tc23LhTkUR6PfFZ8O2g',
// 'tradeamt'=>1
];
try{
$ret = \Payment\Client\Query::run(Config::YS_QUERY, $config, $payData);
}catch(PayException $e){
exit($e->errorMessage());
}
echo json_encode($ret, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
File mode changed
File mode changed
......@@ -11,7 +11,9 @@ 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\Charge\YS\YSCancel;
use Payment\Common\BaseStrategy;
use Payment\Common\PayException;
......@@ -50,12 +52,18 @@ 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;
case Config::LTF_CHARGE:
$this->cancelHandler = new LTFCancel($config);
break;
case Config::YS_CHARGE:
$this->cancelHandler = new YSCancel($config);
break;
default:
throw new PayException('当前仅支持:通联支付平台');
}
......
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
<?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;
}
}
<?php
namespace Payment\Charge\YS;
use Payment\Common\BaseData;
use Payment\Common\YSConfig;
use Payment\Common\YSpay\Data\Cancel\CancelData;
use Payment\Common\YSpay\YSBaseStrategy;
class YSCancel extends YSBaseStrategy{
/**
* 获取支付对应的数据完成类
*
* @return BaseData
*/
public function getBuildDataClass(){
// TODO: Implement getBuildDataClass() method.
return CancelData::class;
}
protected function getReqUrl($url = null){
return parent::getReqUrl($url ?? YSConfig::REQUEST_URL); // TODO: Change the autogenerated stub
}
}
<?php
namespace Payment\Charge\YS;
use Payment\Common\BaseData;
use Payment\Common\YSConfig;
use Payment\Common\YSpay\Data\Cancel\CloseData;
use Payment\Common\YSpay\YSBaseStrategy;
class YSClose extends YSBaseStrategy{
/**
* 获取支付对应的数据完成类
*
* @return BaseData
*/
public function getBuildDataClass(){
// TODO: Implement getBuildDataClass() method.
return CloseData::class;
}
protected function getReqUrl($url = null){
return parent::getReqUrl($url ?? YSConfig::REQUEST_URL); // TODO: Change the autogenerated stub
}
}
<?php
namespace Payment\Charge\YS;
use Payment\Common\BaseData;
use Payment\Common\YSConfig;
use Payment\Common\YSpay\Data\Charge\NatChargeData;
use Payment\Common\YSpay\YSBaseStrategy;
class YSNatCharge extends YSBaseStrategy{
/**
* 获取支付对应的数据完成类
*
* @return BaseData
*/
public function getBuildDataClass(){
// TODO: Implement getBuildDataClass() method.
return NatChargeData::class;
}
protected function getReqUrl($url = null){
return parent::getReqUrl($url??LTFConfig::SCANPAY_URL); // TODO: Change the autogenerated stub
}
}
<?php
namespace Payment\Charge\YS;
use Payment\Common\BaseData;
use Payment\Common\YSConfig;
use Payment\Common\YSpay\Data\Charge\PubChargeData;
use Payment\Common\YSpay\YSBaseStrategy;
class YSPubCharge extends YSBaseStrategy{
/**
* 获取支付对应的数据完成类
*
* @return BaseData
*/
public function getBuildDataClass(){
// TODO: Implement getBuildDataClass() method.
return PubChargeData::class;
}
protected function getReqUrl($url = null){
return parent::getReqUrl($url ?? YSConfig::REQUEST_URL); // TODO: Change the autogenerated stub
}
}
<?php
namespace Payment\Charge\YS;
use Payment\Common\BaseData;
use Payment\Common\YSConfig;
use Payment\Common\YSpay\Data\Charge\ScanChargeData;
use Payment\Common\YSpay\YSBaseStrategy;
class YSScanCharge extends YSBaseStrategy{
/**
* 获取支付对应的数据完成类
*
* @return BaseData
*/
public function getBuildDataClass(){
// TODO: Implement getBuildDataClass() method.
return ScanChargeData::class;
}
protected function getReqUrl($url = null){
return parent::getReqUrl($url??LTFConfig::SCANPAY_URL); // TODO: Change the autogenerated stub
}
}
<?php
namespace Payment\Charge\YSE;
use Payment\Common\BaseData;
use Payment\Common\YSEConfig;
use Payment\Common\YSEpay\Data\Cancel\CancelData;
use Payment\Common\YSEpay\YSEBaseStrategy;
class YSECancel extends YSEBaseStrategy{
/**
* 获取支付对应的数据完成类
*
* @return BaseData
*/
public function getBuildDataClass(){
// TODO: Implement getBuildDataClass() method.
return CancelData::class;
}
protected function getReqUrl($url = null){
return parent::getReqUrl($url ?? YSEConfig::REQUEST_URL); // TODO: Change the autogenerated stub
}
}
<?php
namespace Payment\Charge\YSE;
use Payment\Common\BaseData;
use Payment\Common\YSEConfig;
use Payment\Common\YSEpay\Data\Cancel\CloseData;
use Payment\Common\YSEpay\YSEBaseStrategy;
class YSEClose extends YSEBaseStrategy{
/**
* 获取支付对应的数据完成类
*
* @return BaseData
*/
public function getBuildDataClass(){
// TODO: Implement getBuildDataClass() method.
return CloseData::class;
}
protected function getReqUrl($url = null){
return parent::getReqUrl($url ?? YSEConfig::REQUEST_URL); // TODO: Change the autogenerated stub
}
}
<?php
namespace Payment\Charge\YSE;
use Payment\Common\BaseData;
use Payment\Common\YSEConfig;
use Payment\Common\YSEpay\Data\Charge\NatChargeData;
use Payment\Common\YSEpay\YSEBaseStrategy;
class YSENatCharge extends YSEBaseStrategy{
/**
* 获取支付对应的数据完成类
*
* @return BaseData
*/
public function getBuildDataClass(){
// TODO: Implement getBuildDataClass() method.
return NatChargeData::class;
}
protected function getReqUrl($url = null){
return parent::getReqUrl($url ?? YSEConfig::SCANPAY_URL); // TODO: Change the autogenerated stub
}
}
<?php
namespace Payment\Charge\YSE;
use Payment\Common\BaseData;
use Payment\Common\YSEConfig;
use Payment\Common\YSEpay\Data\Charge\PubChargeData;
use Payment\Common\YSEpay\YSEBaseStrategy;
class YSEPubCharge extends YSEBaseStrategy{
/**
* 获取支付对应的数据完成类
*
* @return BaseData
*/
public function getBuildDataClass(){
// TODO: Implement getBuildDataClass() method.
return PubChargeData::class;
}
protected function getReqUrl($url = null){
return parent::getReqUrl($url ?? YSEConfig::REQUEST_URL); // TODO: Change the autogenerated stub
}
}
<?php
namespace Payment\Charge\YSE;
use Payment\Common\BaseData;
use Payment\Common\YSEConfig;
use Payment\Common\YSEpay\Data\Charge\ScanChargeData;
use Payment\Common\YSEpay\YSEBaseStrategy;
class YSEScanCharge extends YSEBaseStrategy{
/**
* 获取支付对应的数据完成类
*
* @return BaseData
*/
public function getBuildDataClass(){
// TODO: Implement getBuildDataClass() method.
return ScanChargeData::class;
}
protected function getReqUrl($url = null){
return parent::getReqUrl($url??YSEConfig::SCANPAY_URL); // TODO: Change the autogenerated stub
}
}
......@@ -28,6 +28,10 @@ use Payment\Charge\Sw\SwBarCharge;
use Payment\Charge\Sw\SwFaceCharge;
use Payment\Charge\Sw\SwFaceInfo;
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\SwScanCharge;
use Payment\Charge\TLpay\TLLiteCharge;
......@@ -36,6 +40,11 @@ use Payment\Charge\Wx\WxBarCharge;
use Payment\Charge\Wx\WxPubCharge;
use Payment\Charge\Wx\WxQrCharge;
use Payment\Charge\Wx\WxWapCharge;
use Payment\Charge\YS\YSNatCharge;
use Payment\Charge\YS\YSPubCharge;
use Payment\Charge\YS\YSScanCharge;
use Payment\Charge\YSE\YSEPubCharge;
use Payment\Common\BaseStrategy;
use Payment\Common\PayException;
......@@ -137,6 +146,26 @@ 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:
......@@ -165,8 +194,25 @@ class ChargeContext
case Config::LTF_CHANNEL_PAY:
$this->channel=new LTFPayCharge($config);
break;
//易生支付
case Config::YS_CHANNEL_PUB:
case Config::YS_CHANNEL_LITE: //小程序、公众号
$this->channel = new YSPubCharge($config);
break;
case Config::YS_CHANNEL_SCAN: //被扫
$this->channel = new YSScanCharge($config);
break;
case Config::YS_CHANNEL_NATIVE: //主扫
$this->channel = new YSNatCharge($config);
break;
case Config::YSE_CHANNEL_PUB:
case Config::YSE_CHANNEL_LITE: //小程序、公众号
$this->channel = new YSEPubCharge($config);
break;
default:
throw new PayException('当前支持:支付宝、微信、招商一网通、通联支付、米付支付、扫呗支付、富友支付、联拓富。');
throw new PayException('当前支持:支付宝、微信、招商一网通、通联支付、米付支付、扫呗支付、富友支付、联拓富、易生支付。');
}
} catch (PayException $e) {
throw $e;
......
......@@ -39,9 +39,12 @@ class Cancel
Config::MI_CHANNEL_LITE, //米付
Config::SW_CHARGE, //扫呗支付退款
Config::SW_T_CHARGE, //扫呗支付(3.0)撤销(退款)
Config::FU_CHARGE, //富友
Config::LTF_CHARGE,
Config::YS_CHARGE,//易生支付
];
/**
......
......@@ -37,6 +37,12 @@ class Charge
Config::SW_CHANNEL_FACEPAY,
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_LITE,
Config::FU_CHANNEL_SCAN,
......@@ -48,6 +54,16 @@ class Charge
Config::LTF_CHANNEL_BAR,
Config::LTF_CHANNEL_PAY,
//易生支付
Config::YS_CHANNEL_PUB,
Config::YS_CHANNEL_LITE,
Config::YS_CHANNEL_SCAN,
Config::YS_CHANNEL_NATIVE,
// Config::YS_CHANNEL_BAR
//盛银支付
Config::YSE_CHANNEL_PUB,
Config::YSE_CHANNEL_LITE,
];
/**
......
......@@ -16,8 +16,10 @@ class Close {
private static $supportChannel = [
Config::SW_CHARGE, //扫呗支付关闭订单
Config::SW_T_CHARGE, //扫呗支付(3.0)关闭订单
Config::FU_CHARGE, //富友支付关闭订单
Config::LTF_CHARGE,//联拓富支付关闭订单
Config::YS_CHARGE,//易生支付关闭订单
];
/**
......
......@@ -26,9 +26,15 @@ class Notify
Config::SW_CHARGE,//扫呗
Config::SW_T_CHARGE,//扫呗(3.0)
Config::FU_CHARGE, //富友
Config::LTF_CHARGE, //联拓富
Config::YS_CHARGE, //易生
Config::YSE_CHARGE, //银盛
];
/**
......
......@@ -39,11 +39,16 @@ class Query
Config::MI_QUERY,//米付
Config::SW_QUERY,//扫呗
Config::SW_T_QUERY,//扫呗(3.0)
Config::FU_CHARGE,
Config::FU_REFUND,
Config::LTF_CHARGE,
Config::LTF_REFUND,
Config::YS_QUERY,//易生
Config::YSE_QUERY,//易生
];
/**
......
......@@ -33,9 +33,14 @@ class Refund
Config::MI_REFUND,//米付
Config::SW_REFUND,//扫呗
Config::SW_T_REFUND,//扫呗(3.0)
Config::FU_REFUND, //富友
Config::LTF_REFUND,
Config::YS_REFUND,//易生支付
Config::YSE_REFUND,//银盛支付
];
/**
......
......@@ -5,6 +5,8 @@ namespace Payment;
use Payment\Charge\Fu\FuClose;
use Payment\Charge\LTF\LTFClose;
use Payment\Charge\Sw\SwClose;
use Payment\Charge\SwThree\SwThreeClose;
use Payment\Charge\YS\YSClose;
use Payment\Common\BaseStrategy;
use Payment\Common\PayException;
......@@ -37,12 +39,18 @@ 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;
case Config::LTF_CHARGE:
$this->closeHandler = new LTFClose($config);
break;
case Config::YS_CHARGE: //易生支付
$this->closeHandler = new YSClose($config);
break;
default:
throw new PayException('当前仅支持:SW_CHARGE、FU_CHARGE、LTF_CHARGE');
}
......
......@@ -61,6 +61,12 @@ abstract class BaseData
$this->channel = Config::FU_PAY;
} elseif ($config instanceof LTFConfig) {
$this->channel = Config::LTF_PAY;
} elseif ($config instanceof YSConfig) {
$this->channel = Config::YS_PAY;
}elseif ($config instanceof YSEConfig) {
$this->channel = Config::YSE_PAY;
}elseif ($config instanceof SwThreeConfig) {
$this->channel = Config::SW_T_PAY;
}
$this->data = array_merge($config->toArray(), $reqData);//配置信息合并
......@@ -138,6 +144,14 @@ abstract class BaseData
$signStr = ArrayUtil::createLinkstring($values);
$this->makeSign($signStr);
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:
$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]);
......@@ -151,6 +165,18 @@ abstract class BaseData
$signStr = ArrayUtil::createLinkstring($values);
$this->makeSign($signStr);
break;
case Config::YS_PAY:
$values = ArrayUtil::removeKeys($data, ['sign']);
$values = ArrayUtil::arraySort($values);
$signStr = ArrayUtil::createLinkstring($values);
$this->makeSign($signStr);
break;
case Config::YSE_PAY:
$values = ArrayUtil::removeKeys($data, ['sign']);
$values = ArrayUtil::arraySort($values);
$signStr = ArrayUtil::createLinkstring($values);
$this->makeSign($signStr);
break;
default:
$values = ArrayUtil::removeKeys($data, ['sign']);
$values = ArrayUtil::arraySort($values);
......
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
......@@ -17,7 +17,7 @@ abstract class LTFBaseData extends BaseData{
switch ($this->signType) {
case 'MD5':
$signStr .= '&key=' . $this->key;
$sign = md5($signStr);
$sign = strtoupper(md5($signStr));
break;
default:
......
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
<?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);
}
}
<?php
namespace Payment\Common;
use Payment\Utils\ArrayUtil;
use Payment\Utils\StrUtil;
final class YSConfig extends ConfigInterface{
public const REQUEST_URL = 'https://open.eycard.cn:8443/WorthTech_Access_AppPaySystemV2/apppayacc';
public $request_url = 'https://open.eycard.cn:8443/WorthTech_Access_AppPaySystemV2/apppayacc';
public $signType = 'MD5';
// public $notifyurl;
public $channelid;//渠道编号
public $merid;//门店编号
public $termid; //终端编号
public $key; //签名密钥
// public $tradetrace; //订单号
//
// public $tradeamt; //订单号
//
// public $openid; //订单号
/**
* FuConfig constructor.
* @param array $config
* @throws PayException
*/
public function __construct(array $config)
{
try {
$this->initConfig($config);
} catch (PayException $e) {
throw $e;
}
}
/**
* 初始化配置文件参数
* @param array $config
* @throws PayException
*/
/**
* 初始化配置文件参数
* @param array $config
* @throws PayException
*/
private function initConfig(array $config)
{
$config = ArrayUtil::paraFilter($config);
if (key_exists('channelid', $config) && !empty($config['channelid'])) $this->channelid = $config['channelid'];else throw new PayException('必须提供渠道号标识');
if (key_exists('merid', $config) && !empty($config['merid'])) $this->merid = $config['merid']; else throw new PayException('必须提供商户编号');
if (key_exists('termid', $config) && !empty($config['termid'])) $this->termid = $config['termid'];
if (key_exists('key', $config) && !empty($config['key'])) $this->key = $config['key'];
// if (key_exists('out_trade_no', $config) && !empty($config['out_trade_no'])) $this->tradetrace = $config['out_trade_no'];
//
// if (key_exists('total_fee', $config) && !empty($config['total_fee'])) $this->tradeamt = $config['total_fee'];
//
// if (key_exists('open_id', $config) && !empty($config['open_id'])) $this->openid = $config['open_id'];
}
}
<?php
namespace Payment\Common;
use Payment\Utils\ArrayUtil;
use Payment\Utils\StrUtil;
final class YSEConfig extends ConfigInterface{
public const REQUEST_URL = 'https://qrcode.ysepay.com/gateway.do';
public const REFUND_URL = 'https://openapi.ysepay.com/gateway.do';
public const QUERY_URL = 'https://search.ysepay.com/gateway.do';
public $sign; //签名
public $sign_type = 'RSA';
public $partner_id;//商户号
public $business_code;//业务代码
public $seller_id;//收款方银盛支付用户号
public $seller_name;//收款方银盛支付客户名
public $charset = 'UTF-8'; //编码格式
public $version = '3.0'; //调用的接口版本
public $notify_url; //银盛支付服务器主动通知商户服务器里指定的页面 http 路径。
public $biz_content; //JSON 格式,具体包含的内容参见各个接口的业务参数描述
/**
* FuConfig constructor.
* @param array $config
* @throws PayException
*/
public function __construct(array $config)
{
try {
$this->initConfig($config);
} catch (PayException $e) {
throw $e;
}
}
/**
* 初始化配置文件参数
* @param array $config
* @throws PayException
*/
/**
* 初始化配置文件参数
* @param array $config
* @throws PayException
*/
private function initConfig(array $config)
{
$config = ArrayUtil::paraFilter($config);
if (key_exists('partner_id', $config) && !empty($config['partner_id'])) $this->partner_id = $config['partner_id'];else throw new PayException('必须提供商户号标识');
if (key_exists('seller_id', $config) && !empty($config['seller_id'])) $this->seller_id = $config['seller_id'];else throw new PayException('必须提供收款方银盛支付用户号');
if (key_exists('seller_name', $config) && !empty($config['seller_name'])) $this->seller_name = $config['seller_name'];else throw new PayException('必须提供收款方银盛支付客户名');
if (key_exists('business_code', $config) && !empty($config['business_code'])) $this->business_code = $config['business_code'];else throw new PayException('必须提供业务代码');
}
}
<?php
namespace Payment\Common\YSEpay\Data\Cancel;
use Payment\Common\YSEpay\Data\YSEBaseData;
use Payment\Common\PayException;
use Payment\Utils\ArrayUtil;
class CancelData extends YSEBaseData{
/**
* 构建用于支付的签名相关数据
*
* @return array
*/
protected function buildData(){
// TODO: Implement buildData() method.
$this->certainSignData = [
'channelid' => $this->channelid, //渠道编号
'opt' => $this->opt ?? "cancel", //操作类型(“cancel”)
'merid' => $this->merid, //商戶编号
'termid' => $this->termid, //终端编号
'tradetrace' => $this->tradetrace, //原交易流水(建议使用易生流水号查询:wtorderid)
// 'oritradetrace' => $this->oritradetrace, //原交易流水; 与 oriwtorderid 字段可以二选一上送,如果都上送,以 本节点为准。
// 'oriwtorderid' => $this->oriwtorderid, //原交易的系统订单号;与 oritradetrace 字段可以二选一上送,如果都 上送,以 oritradetrace 节点为准
];
$signData = array_merge($this->certainSignData, []);
if(isset($this->version)){
$signData['version'] = $this->version; //填写的值为 2 时,交易成功后返回优惠信息
}
if(isset($this->oritradetrace)){
$signData['oritradetrace'] = $this->oritradetrace; //退货金额,以分为单位,不大于原交易金额与已成功退货金额之差
}else{
if(isset($this->oriwtorderid)){
$signData['oriwtorderid'] = $this->oriwtorderid; //退货金额,以分为单位,不大于原交易金额与已成功退货金额之差
}
}
$this->retData = ArrayUtil::paraFilter($signData);
}
/**
* 检查传入的参数. $reqData是否正确.
*
* @return mixed
* @throws PayException
*/
protected function checkDataParam(){
// TODO: Implement checkDataParam() method.
parent::checkDataParam();
}
}
<?php
namespace Payment\Common\YSEpay\Data\Cancel;
use Payment\Common\YSEpay\Data\YSEBaseData;
use Payment\Common\PayException;
use Payment\Utils\ArrayUtil;
class CloseData extends YSEBaseData{
/**
* 构建用于支付的签名相关数据
*
* @return array
*/
protected function buildData(){
// TODO: Implement buildData() method.
$this->certainSignData = [
'channelid' => $this->channelid, //渠道编号
'opt' => $this->opt ?? "close", //操作类型(“close”)
'merid' => $this->merid, //商戶编号
'termid' => $this->termid, //终端编号
'tradetrace' => $this->tradetrace, //原交易流水(建议使用易生流水号查询:wtorderid)
];
$signData = array_merge($this->certainSignData, []);
$this->retData = ArrayUtil::paraFilter($signData);
}
/**
* 检查传入的参数. $reqData是否正确.
*
* @return mixed
* @throws PayException
*/
protected function checkDataParam(){
// TODO: Implement checkDataParam() method.
parent::checkDataParam();
}
}
<?php
namespace Payment\Common\YSEpay\Data\Charge;
use Payment\Common\YSEpay\Data\YSEBaseData;
use Payment\Common\PayException;
use Payment\Config;
abstract class ChargeBaseData extends YSEBaseData{
/**
* 检查传入的参数. $reqData是否正确.
*
* @return mixed
* @throws \Payment\Common\PayException
*/
protected function checkDataParam(){
// TODO: Implement checkDataParam() method.
// 检查金额不能低于0.01
if ($this->total_amount < 0.01) {
throw new PayException('支付金额不能低于 ' . Config::PAY_MIN_FEE . ' 元');
}
}
}
<?php
namespace Payment\Common\YSEpay\Data\Charge;
use Payment\Common\PayException;
use Payment\Utils\ArrayUtil;
class NatChargeData extends ChargeBaseData{
/**
* 构建用于支付的签名相关数据
*
* @return void
*/
protected function buildData(){
// TODO: Implement buildData() method.
$this->certainSignData = [
'channelid' => $this->channelid, //渠道编号
'opt' => $this->opt ?? "apPreOrder", //操作类型(“apPreOrder”:支付宝;“upPreOrder”:银联)
'merid' => $this->merid, //商戶编号
'termid' => $this->termid, //终端编号
'tradetrace' => $this->tradetrace, //商户订单号(控制在 50 位长度以内,确保在请求接口的系统中全局 唯一;可以包含数字与字母;不能包含其他特殊字符)
'tradeamt' => $this->tradeamt, //交易金额(单位:分)
'tradetype' => $this->tradetype ?? "NATIVE", //支付方式
'notifyurl' => $this->notifyurl, //客户端接收支付成功通知的地址
'body' => $this->body ?? "乐店云支付", //商品或支付单简要描述
];
$signData = array_merge($this->certainSignData, []);
if(isset($this->openid)){ //支付宝(买家支付宝用户ID),上送支付宝用户ID时,当前订单仅当前支付宝用户支付
$signData['openid'] = $this->openid;
}
if(isset($this->instalment)){ //支付宝花呗分期
$signData['instalment'] = $this->instalment;
}
if(isset($this->handingfee)){
$signData['handingfee'] = $this->handingfee; //手续费(以分为单位,第一位是 D 或 C,表示借、贷)
}
if(isset($this->version)){
$signData['version'] = $this->version; //填写的值为 2 时,交易成功后返回优惠信息
}
if(isset($this->identity)){
$signData['identity'] = $this->identity; //JSON 格式指定付款人信息(格式繁琐,不推荐使用)
}
if(isset($this->patnersettleflag)){
$signData['patnersettleflag'] = $this->patnersettleflag;//资金结算秒到标识(取值:1、2) 1:本次交易正常T1结算,2:本次交易秒到(前提条件:代理需开通白名单、商户需要开通秒到功能)
}
// 移除数组中的空值
$this->retData = ArrayUtil::paraFilter($signData);
}
protected function checkDataParam(){
parent::checkDataParam(); // TODO: Change the autogenerated stub
if(empty($this->notifyurl)){
throw new PayException('支付通知地址不能为空');
}
}
}
<?php
namespace Payment\Common\YSEpay\Data\Charge;
use Payment\Common\PayException;
use Payment\Utils\ArrayUtil;
class PubChargeData extends ChargeBaseData{
/**
* 构建用于支付的签名相关数据
*
* @return void
*/
protected function buildData(){
// TODO: Implement buildData() method.
$this->certainSignData = [
'partner_id' => $this->partner_id,
'method' => $this->method ?? 'ysepay.online.weixin.pay',
'charset' => $this->charset ?? 'utf-8',
'sign_type' => $this->sign_type ?? 'RSA',
'notify_url' => $this->notify_url,
'timestamp' => $this->timestamp ?? date('Y-m-d H:i:s',time()),
'version' => $this->version ?? "3.0",
];
$signData = array_merge($this->certainSignData, []);
$biz_content = [
'out_trade_no' =>$this->out_trade_no,
'shopdate' =>$this->shopdate ?? date('Ymd'),
'subject' =>$this->subject,
'total_amount' =>$this->total_amount,
'seller_id' => $this->seller_id,
'seller_name' => $this->seller_name,
'timeout_express' => $this->timeout_express,
'business_code' => $this->business_code,
'sub_openid' => $this->sub_openid,
'appid' => $this->appid,
'is_minipg' => $this->is_minipg ?? '2', //小程序支付,值为 1,表示小程序支付;不传或值为 2,表示公众账号内支付
'extra_common_param' => $this->extra_common_param ?? '', //公用回传参数
];
$signData['biz_content'] = json_encode(ArrayUtil::paraFilter(ArrayUtil::arraySort($biz_content)),JSON_UNESCAPED_UNICODE);
// 移除数组中的空值
$this->retData = ArrayUtil::paraFilter($signData);
}
protected function checkDataParam(){
parent::checkDataParam(); // TODO: Change the autogenerated stub
if(empty($this->notify_url)){
throw new PayException('支付通知地址不能为空');
}
if(empty($this->sub_openid)){
throw new PayException('用户OPENID 不能为空');
}
if(empty($this->appid)){
throw new PayException('小程序appid 不能为空');
}
}
}
<?php
namespace Payment\Common\YSEpay\Data\Charge;
use Payment\Common\YSpay\Data\YSBaseData;
use Payment\Common\PayException;
use Payment\Utils\ArrayUtil;
class ScanChargeData extends YSEBaseData{
/**
* 构建用于支付的签名相关数据
*
* @return void
*/
protected function buildData(){
// TODO: Implement buildData() method.
$this->certainSignData = [
'channelid' => $this->channelid, //渠道编号
'opt' => $this->opt ?? "scanPay", //操作类型(“scanPay”)
'merid' => $this->merid, //商戶编号
'termid' => $this->termid, //终端编号
'tradetrace' => $this->tradetrace, //商户订单号(控制在 50 位长度以内,确保在请求接口的系统中全局 唯一;可以包含数字与字母;不能包含其他特殊字符)
'tradeamt' => $this->tradeamt, //交易金额(单位:分)
'authcode' => $this->authcode, //扫码支付授权码,设备读取用户微信、支付宝、银联钱包中的条码或 者二维码信息
'body' => $this->body ?? "乐店云支付", //商品或支付单简要描述
];
$signData = array_merge($this->certainSignData, []);
if(isset($this->maintradetype)){ //刷脸类型填写(faceScanPay)
$signData['maintradetype'] = $this->maintradetype;
}
if(isset($this->instalment)){ //支付宝花呗分期
$signData['instalment'] = $this->instalment;
}
if(isset($this->handingfee)){
$signData['handingfee'] = $this->handingfee; //手续费(以分为单位,第一位是 D 或 C,表示借、贷)
}
if(isset($this->version)){
$signData['version'] = $this->version; //填写的值为 2 时,交易成功后返回优惠信息
}
if(isset($this->identity)){
$signData['identity'] = $this->identity; //JSON 格式指定付款人信息(格式繁琐,不推荐使用)
}
if(isset($this->patnersettleflag)){
$signData['patnersettleflag'] = $this->patnersettleflag;//资金结算秒到标识(取值:1、2) 1:本次交易正常T1结算,2:本次交易秒到(前提条件:代理需开通白名单、商户需要开通秒到功能)
}
// 移除数组中的空值
$this->retData = ArrayUtil::paraFilter($signData);
}
protected function checkDataParam(){
parent::checkDataParam(); // TODO: Change the autogenerated stub
if(empty($this->notifyUrl)){
throw new PayException('支付通知地址不能为空');
}
}
}
<?php
namespace Payment\Common\YSEpay\Data\Query;
use Payment\Common\YSEpay\Data\YSEBaseData;
use Payment\Common\PayException;
use Payment\Utils\ArrayUtil;
class ChargeQueryData extends YSEBaseData{
/**
* 构建用于支付的签名相关数据
*
* @return array
*/
protected function buildData(){
// TODO: Implement buildData() method.
$this->certainSignData = [
'partner_id' => $this->partner_id,
'method' => $this->method ?? 'ysepay.online.trade.query',
'charset' => $this->charset ?? 'utf-8',
'sign_type' => $this->sign_type ?? 'RSA',
'notify_url' => $this->notify_url,
'timestamp' => $this->timestamp ?? date('Y-m-d H:i:s',time()),
'version' => $this->version ?? "3.0",
];
$signData = array_merge($this->certainSignData, []);
$biz_content = [
'out_trade_no' =>$this->out_trade_no,
'shopdate' =>$this->shopdate ?? date('Ymd'),
'trade_no' =>$this->trade_no ?? '',
];
$signData['biz_content'] = json_encode(ArrayUtil::paraFilter($biz_content),JSON_UNESCAPED_UNICODE);
// 移除数组中的空值
$this->retData = ArrayUtil::paraFilter($signData);
}
/**
* 检查传入的参数. $reqData是否正确.
*
* @return mixed
* @throws PayException
*/
protected function checkDataParam(){
// TODO: Implement checkDataParam() method.
parent::checkDataParam();
}
}
<?php
namespace Payment\Common\YSEpay\Data;
use Payment\Common\PayException;
use Payment\Utils\ArrayUtil;
class RefundData extends YSEBaseData{
/**
* 构建用于支付的签名相关数据
*
* @return array
*/
protected function buildData(){
// TODO: Implement buildData() method.
$this->certainSignData = [
'partner_id' => $this->partner_id,
'method' => $this->method ?? 'ysepay.online.trade.refund',
'charset' => $this->charset ?? 'utf-8',
'sign_type' => $this->sign_type ?? 'RSA',
'notify_url' => $this->notify_url ?? '',
'timestamp' => $this->timestamp ?? date('Y-m-d H:i:s',time()),
'version' => $this->version ?? "3.0",
];
$signData = array_merge($this->certainSignData, []);
$biz_content = [
'out_trade_no' =>$this->out_trade_no,
'shopdate' =>$this->shopdate ?? date('Ymd'),
'trade_no' =>$this->trade_no ?? '',
'refund_amount' =>$this->refund_amount, //单位:元
'refund_reason' => $this->refund_reason,
'out_request_no' => $this->out_request_no
];
$signData['biz_content'] = json_encode(ArrayUtil::paraFilter($biz_content));
// 移除数组中的空值
$this->retData = ArrayUtil::paraFilter($signData);
}
/**
* 检查传入的参数. $reqData是否正确.
*
* @return mixed
* @throws PayException
*/
protected function checkDataParam(){
// TODO: Implement checkDataParam() method.
parent::checkDataParam();
}
}
<?php
namespace Payment\Common\YSEpay\Data;
use Payment\Common\BaseData;
use Payment\Common\PayException;
abstract class YSEBaseData extends BaseData{
//测试
protected $privateKey = "MIIEpAIBAAKCAQEAtuZdH/xV/r1fhTz1znGYRrYXorZMJH60QUNFY4j050i6nBjagqfjg/DRSj57IT7+nPTf9cqP7+NMS694OlIhI9YiJ2+JcvfpJSDsXk7AyEO3KbvjYPZWKU7d7i6pNGNPXW73EGdEuyD3/DMV1GZZpKIlZN6/O3SiPSepAngyklia+69xBXGugqoWiEsT8UbtJ4YmlUB5rTH9pxCBRi91dZ+4X6aNlcD0gTNWsC4tutpTSkDPl2MkmdKU5yt5KdZJT1hlh/orIfCrlRYrpGrO9eS400zrLv/VH37vGOVKpMSMK44BULAIOJjEzYCu8sKzxz4wqebnAHWFfOFeIOR+iQIDAQABAoIBAHJYGqhAjVKw+eLGdbYW9mhetvAWoAvA2thiQiM0IEfoBCJKt3EvnOGD0JRl83yZcXyW6t0zQkFrDOvUS4nKhsVsvfWBmaCytKNtrdhXy9Zn3z7MJB8eYkd48u5RZZ9G5vs2wGcU6LdEqUSWe3NKeYifhllFmLCG/lbVUKgmlRdAFxv3esFooEso1uSGwgB7f0HJLH10jT1kSUyfAvG35mJ8oYBuN0Hrbgyepo5H7qh3l7YSOAB9yHtTe5GMUPFoexuTGjdun85ydX7YQOO6QjDYTrVfLIQvoGGP/z0IXr13W+jpBpsN3ctvtCoCJgWxKjYk2CRbxdCvE118HtReyPECgYEA3koVhF9cXksqyf6QMb+0yRvKK8Czq4EXjzwVFAX2iZ6OUdLcT73PcuQvVJW+8U0i3awoQPxBye+IoNtWc9UV6vYJ+ELhNIv49evwwc4P7WnRTmC4W8HDvoGuwCM/Xd0ci4fd0ziWSGlAiSheNUfUGWUAyKc/Ksx0/HrmrySwgdcCgYEA0qMQeQCJHmhgOGKn+Sqp3Eip675GaL1msTFSdDghxwLPseVw2D9YpronGmPsJMINiHoE+Y7F0yxGqUL93kgfCZ+Sa7RcEsVW7pxjkmaLB6qmuba/osZoXzARaMlDeu1B0uawDuC2v3oV1HbvCka90WWeqdvKyUvjt+P3W4gTtp8CgYB1jpJwjgoIaBI5/yF83dibHtI9b0zVn5C5FFpFW531S+AST8Rpe4VRSnHpdsQjUtrkhp5HN+EHDWGhSD4hRgiwWOwO2jfFlVzVmbCangJ4WSTzIV1+USvW/ThQrpNdbYkiFXlvshZwNxGFN88SuGjoAS138FMMrFIWEF0dNPcPwwKBgQDO1bS9PRtoMpIZjDbpY018tBW3GhbFjwaiBI609NGmPEp6o5TVpA6HWdBAB9LAnZTwaPEtpVb4cEfKua/Ub/maV4lOHcMz43fjwsm73tmy443oW11+l1mx7t+Jh+itcwDp+gDz+xE4oMeC5G8CJkkKr8DHhr5wQAcScdZZmRvSfQKBgQClcdT5nTzxj3W45YWP9GEeZtUkE4VnT6ZHU5KInbZhNEbxNcEg69Ve6pviadyTjSBetB/Z2OPQPeE7LIlYHmPLjDHCPDqb6D++/6zL8qxlORf2oScKaEQFLnkqR+M2uZxe/D+HABHxAbbOTdJYK6kiokhPLEMAGc//dW6e2a+EqA==";
protected $pubKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtuZdH/xV/r1fhTz1znGYRrYXorZMJH60QUNFY4j050i6nBjagqfjg/DRSj57IT7+nPTf9cqP7+NMS694OlIhI9YiJ2+JcvfpJSDsXk7AyEO3KbvjYPZWKU7d7i6pNGNPXW73EGdEuyD3/DMV1GZZpKIlZN6/O3SiPSepAngyklia+69xBXGugqoWiEsT8UbtJ4YmlUB5rTH9pxCBRi91dZ+4X6aNlcD0gTNWsC4tutpTSkDPl2MkmdKU5yt5KdZJT1hlh/orIfCrlRYrpGrO9eS400zrLv/VH37vGOVKpMSMK44BULAIOJjEzYCu8sKzxz4wqebnAHWFfOFeIOR+iQIDAQAB";
/**
* 签名算法实现 便于后期扩展微信不同的加密方式
*
* @param string $signStr
* @return string
*/
protected function makeSign($signStr){
switch ($this->signType) {
case 'MD5':
$sign = strtoupper(md5($signStr));
break;
case 'RSA':
$sign = $this->genSign($signStr,$this->privateKey);
break;
default:
$sign = '';
}
$this->retData['sign'] = $sign;
return $sign;
// TODO: Implement makeSign() method.
}
//生成 sha1WithRSA 签名
protected function genSign($toSign, $privateKey){
$privateKey = "-----BEGIN RSA PRIVATE KEY-----\n" .
wordwrap($privateKey, 64, "\n", true) .
"\n-----END RSA PRIVATE KEY-----";
$key = openssl_get_privatekey($privateKey);
openssl_sign($toSign, $signature, $key);
openssl_free_key($key);
$sign = base64_encode($signature);
return $sign;
}
//校验 sha1WithRSA 签名
protected function verifySign($data, $sign, $pubKey){
$sign = base64_decode($sign);
$pubKey = "-----BEGIN PUBLIC KEY-----\n" .
wordwrap($pubKey, 64, "\n", true) .
"\n-----END PUBLIC KEY-----";
$key = openssl_pkey_get_public($pubKey);
$result = openssl_verify($data, $sign, $key, OPENSSL_ALGO_SHA1) === 1;
return $result;
}
protected function checkDataParam(){
// TODO: Implement checkDataParam() method.
// 检查订单号是否合法
if (empty($this->out_trade_no) || mb_strlen($this->out_trade_no) > 64) {
throw new PayException('商户系统的订单号不能为空且长度不能超过64位');
}
if (empty($this->partner_id) || empty($this->business_code)) {
throw new PayException('必须提供商户号与业务代码');
}
}
}
<?php
namespace Payment\Common\YSEpay;
use Payment\Common\BaseData;
use Payment\Common\BaseStrategy;
use Payment\Common\YSEConfig;
use Payment\Common\PayException;
use Payment\Utils\ArrayUtil;
use Payment\Utils\Curl;
abstract class YSEBaseStrategy implements BaseStrategy
{
protected $config;
/**
* 支付数据
* @var BaseData $reqData
*/
protected $reqData;
/**
* FuBaseStrategy constructor.
* @param array $config
* @throws PayException
*/
public function __construct(array $config)
{
/* 设置内部字符编码为 UTF-8 */
mb_internal_encoding("UTF-8");
try {
$this->config = new YSEConfig($config);
} catch (PayException $e) {
throw $e;
}
}
/**
* 发送完了请求
* @param $body
* @return mixed
* @throws \Payment\Common\PayException
*/
protected function sendReq($body)
{
$url = $this->getReqUrl();
if (is_null($url)) {
throw new PayException('目前不支持该接口。请联系开发者添加');
}
$method = str_replace('.','_',$body['method']).'_response';
$body['biz_content'] = urlencode($body['biz_content']);
$body['sign'] = urlencode($body['sign']);
$body = ArrayUtil::arraySort($body);
$body = ArrayUtil::createLinkstring($body,false);
$responseTxt = $this->curlPost($body, $url);
// 格式化为数组
$retData = (json_decode($responseTxt, true));
if ($retData[$method]['code'] != '10000') {
throw new PayException('支付平台返回错误提示:' . $retData[$method]['sub_msg']);
}
return $retData[$method];
}
protected function curlPost($body, $url)
{
$curl = new Curl();
return $curl->set([
'CURLOPT_HEADER' => 0
])->request($url,$body);
}
/**
* 处理具体的业务
*
* @param array $data
* @return mixed
* @throws \Payment\Common\PayException
*/
public function handle(array $data)
{
// TODO: Implement handle() method.
$buildClass = $this->getBuildDataClass();
try {
$this->reqData = new $buildClass($this->config, $data);
} catch (PayException $e) {
throw $e;
}
$this->reqData->setSign();
$body = $this->reqData->getData();
$ret = $this->sendReq($body);
// 检查返回的数据是否被篡改
$flag = true;
if (!$flag) {
throw new PayException('返回数据被篡改。请检查网络是否安全!');
}
return $this->retData($ret);
}
/**
* 获取请求地址
* @param null $url
* @return string
*/
protected function getReqUrl($url = null)
{
if (isset($this->config->base_url) && !empty($this->config->base_url)) {
$_pre = $this->config->base_url;
} else {
$_pre = YSEConfig::REQUEST_URL;
}
return $_pre;
}
/**
* 处理微信的返回值并返回给客户端
* @param array $ret
* @return mixed
*
*/
protected function retData(array $ret)
{
return $ret;
}
/**
* 检查微信返回的数据是否被篡改过
*
* @param array $retData
* @return boolean
* @throws \Exception
*/
protected function verifySign(array $retData)
{
$retSign = $retData['sign'];
$values = ArrayUtil::removeKeys($retData, ['sign']);
$values = ArrayUtil::paraFilter($values);
$values = ArrayUtil::arraySort($values);
$signStr = ArrayUtil::createLinkstring($values);
$signStr = str_replace(' ', '', $signStr);
$signStr .= '&key=' . $this->config->key;
switch ($this->config->signType) {
case 'MD5':
$sign = md5($signStr);
break;
case 'HMAC-SHA256':
$sign = hash_hmac('sha256', $signStr, $this->config->key);
break;
default:
$sign = '';
}
// echo $retSign;echo"<br>";
// echo strtoupper($sign);die;
return strtoupper($sign) === $retSign;
}
}
<?php
namespace Payment\Common\YSpay\Data\Cancel;
use Payment\Common\YSpay\Data\YSBaseData;
use Payment\Common\PayException;
use Payment\Utils\ArrayUtil;
class CancelData extends YSBaseData{
/**
* 构建用于支付的签名相关数据
*
* @return array
*/
protected function buildData(){
// TODO: Implement buildData() method.
$this->certainSignData = [
'channelid' => $this->channelid, //渠道编号
'opt' => $this->opt ?? "cancel", //操作类型(“cancel”)
'merid' => $this->merid, //商戶编号
'termid' => $this->termid, //终端编号
'tradetrace' => $this->tradetrace, //原交易流水(建议使用易生流水号查询:wtorderid)
// 'oritradetrace' => $this->oritradetrace, //原交易流水; 与 oriwtorderid 字段可以二选一上送,如果都上送,以 本节点为准。
// 'oriwtorderid' => $this->oriwtorderid, //原交易的系统订单号;与 oritradetrace 字段可以二选一上送,如果都 上送,以 oritradetrace 节点为准
];
$signData = array_merge($this->certainSignData, []);
if(isset($this->version)){
$signData['version'] = $this->version; //填写的值为 2 时,交易成功后返回优惠信息
}
if(isset($this->oritradetrace)){
$signData['oritradetrace'] = $this->oritradetrace; //退货金额,以分为单位,不大于原交易金额与已成功退货金额之差
}else{
if(isset($this->oriwtorderid)){
$signData['oriwtorderid'] = $this->oriwtorderid; //退货金额,以分为单位,不大于原交易金额与已成功退货金额之差
}
}
$this->retData = ArrayUtil::paraFilter($signData);
}
/**
* 检查传入的参数. $reqData是否正确.
*
* @return mixed
* @throws PayException
*/
protected function checkDataParam(){
// TODO: Implement checkDataParam() method.
parent::checkDataParam();
}
}
<?php
namespace Payment\Common\YSpay\Data\Cancel;
use Payment\Common\YSpay\Data\YSBaseData;
use Payment\Common\PayException;
use Payment\Utils\ArrayUtil;
class CloseData extends YSBaseData{
/**
* 构建用于支付的签名相关数据
*
* @return array
*/
protected function buildData(){
// TODO: Implement buildData() method.
$this->certainSignData = [
'channelid' => $this->channelid, //渠道编号
'opt' => $this->opt ?? "close", //操作类型(“close”)
'merid' => $this->merid, //商戶编号
'termid' => $this->termid, //终端编号
'tradetrace' => $this->tradetrace, //原交易流水(建议使用易生流水号查询:wtorderid)
];
$signData = array_merge($this->certainSignData, []);
$this->retData = ArrayUtil::paraFilter($signData);
}
/**
* 检查传入的参数. $reqData是否正确.
*
* @return mixed
* @throws PayException
*/
protected function checkDataParam(){
// TODO: Implement checkDataParam() method.
parent::checkDataParam();
}
}
<?php
namespace Payment\Common\YSpay\Data\Charge;
use Payment\Common\YSpay\Data\YSBaseData;
use Payment\Common\PayException;
use Payment\Config;
abstract class ChargeBaseData extends YSBaseData{
/**
* 检查传入的参数. $reqData是否正确.
*
* @return mixed
* @throws \Payment\Common\PayException
*/
protected function checkDataParam(){
// TODO: Implement checkDataParam() method.
// 检查金额不能低于0.01
if ($this->tradeamt < 1) {
throw new PayException('支付金额不能低于 ' . Config::PAY_MIN_FEE . ' 元');
}
}
}
<?php
namespace Payment\Common\YSpay\Data\Charge;
use Payment\Common\PayException;
use Payment\Utils\ArrayUtil;
class NatChargeData extends ChargeBaseData{
/**
* 构建用于支付的签名相关数据
*
* @return void
*/
protected function buildData(){
// TODO: Implement buildData() method.
$this->certainSignData = [
'channelid' => $this->channelid, //渠道编号
'opt' => $this->opt ?? "apPreOrder", //操作类型(“apPreOrder”:支付宝;“upPreOrder”:银联)
'merid' => $this->merid, //商戶编号
'termid' => $this->termid, //终端编号
'tradetrace' => $this->tradetrace, //商户订单号(控制在 50 位长度以内,确保在请求接口的系统中全局 唯一;可以包含数字与字母;不能包含其他特殊字符)
'tradeamt' => $this->tradeamt, //交易金额(单位:分)
'tradetype' => $this->tradetype ?? "NATIVE", //支付方式
'notifyurl' => $this->notifyurl, //客户端接收支付成功通知的地址
'body' => $this->body ?? "乐店云支付", //商品或支付单简要描述
];
$signData = array_merge($this->certainSignData, []);
if(isset($this->openid)){ //支付宝(买家支付宝用户ID),上送支付宝用户ID时,当前订单仅当前支付宝用户支付
$signData['openid'] = $this->openid;
}
if(isset($this->instalment)){ //支付宝花呗分期
$signData['instalment'] = $this->instalment;
}
if(isset($this->handingfee)){
$signData['handingfee'] = $this->handingfee; //手续费(以分为单位,第一位是 D 或 C,表示借、贷)
}
if(isset($this->version)){
$signData['version'] = $this->version; //填写的值为 2 时,交易成功后返回优惠信息
}
if(isset($this->identity)){
$signData['identity'] = $this->identity; //JSON 格式指定付款人信息(格式繁琐,不推荐使用)
}
if(isset($this->patnersettleflag)){
$signData['patnersettleflag'] = $this->patnersettleflag;//资金结算秒到标识(取值:1、2) 1:本次交易正常T1结算,2:本次交易秒到(前提条件:代理需开通白名单、商户需要开通秒到功能)
}
// 移除数组中的空值
$this->retData = ArrayUtil::paraFilter($signData);
}
protected function checkDataParam(){
parent::checkDataParam(); // TODO: Change the autogenerated stub
if(empty($this->notifyurl)){
throw new PayException('支付通知地址不能为空');
}
}
}
<?php
namespace Payment\Common\YSpay\Data\Charge;
use Payment\Common\PayException;
use Payment\Utils\ArrayUtil;
class PubChargeData extends ChargeBaseData{
/**
* 构建用于支付的签名相关数据
*
* @return void
*/
protected function buildData(){
// TODO: Implement buildData() method.
$this->certainSignData = [
'channelid' => $this->channelid, //渠道编号
'opt' => $this->opt ?? "wxPreOrder", //操作类型(“wxPreOrder”:微信;“apPreOrder”:支付宝)
'merid' => $this->merid, //商戶编号
'termid' => $this->termid, //终端编号
'tradetrace' => $this->tradetrace, //商户订单号(控制在 50 位长度以内,确保在请求接口的系统中全局 唯一;可以包含数字与字母;不能包含其他特殊字符)
'tradeamt' => $this->tradeamt, //交易金额(单位:分)
'tradetype' => $this->tradetype ?? "JSAPI", //支付方式
'notifyurl' => $this->notifyurl, //客户端接收支付成功通知的地址
'openid' => $this->openid, //支付宝(买家支付宝用户ID);微信(用户在商户sub_appid下的唯一标识)
'body' => $this->body ?? "乐店云支付", //商品或支付单简要描述
'version' => 2, //填写的值为 2 时,交易成功后返回优惠信息
];
$signData = array_merge($this->certainSignData, []);
if(isset($this->handingfee)){
$signData['handingfee'] = $this->handingfee; //手续费(以分为单位,第一位是 D 或 C,表示借、贷)
}
if(isset($this->identity)){
$signData['identity'] = $this->identity; //JSON 格式指定付款人信息(格式繁琐,不推荐使用)
}
if(isset($this->patnersettleflag)){
$signData['patnersettleflag'] = $this->patnersettleflag;//资金结算秒到标识(取值:1、2) 1:本次交易正常T1结算,2:本次交易秒到(前提条件:代理需开通白名单、商户需要开通秒到功能)
}
// 移除数组中的空值
$this->retData = ArrayUtil::paraFilter($signData);
}
protected function checkDataParam(){
parent::checkDataParam(); // TODO: Change the autogenerated stub
if(empty($this->notifyurl)){
throw new PayException('支付通知地址不能为空');
}
if(empty($this->openid)){
throw new PayException('用户OPENID 不能为空');
}
}
}
<?php
namespace Payment\Common\YSpay\Data\Charge;
use Payment\Common\YSpay\Data\YSBaseData;
use Payment\Common\PayException;
use Payment\Utils\ArrayUtil;
class ScanChargeData extends YSBaseData{
/**
* 构建用于支付的签名相关数据
*
* @return void
*/
protected function buildData(){
// TODO: Implement buildData() method.
$this->certainSignData = [
'channelid' => $this->channelid, //渠道编号
'opt' => $this->opt ?? "scanPay", //操作类型(“scanPay”)
'merid' => $this->merid, //商戶编号
'termid' => $this->termid, //终端编号
'tradetrace' => $this->tradetrace, //商户订单号(控制在 50 位长度以内,确保在请求接口的系统中全局 唯一;可以包含数字与字母;不能包含其他特殊字符)
'tradeamt' => $this->tradeamt, //交易金额(单位:分)
'authcode' => $this->authcode, //扫码支付授权码,设备读取用户微信、支付宝、银联钱包中的条码或 者二维码信息
'body' => $this->body ?? "乐店云支付", //商品或支付单简要描述
];
$signData = array_merge($this->certainSignData, []);
if(isset($this->maintradetype)){ //刷脸类型填写(faceScanPay)
$signData['maintradetype'] = $this->maintradetype;
}
if(isset($this->instalment)){ //支付宝花呗分期
$signData['instalment'] = $this->instalment;
}
if(isset($this->handingfee)){
$signData['handingfee'] = $this->handingfee; //手续费(以分为单位,第一位是 D 或 C,表示借、贷)
}
if(isset($this->version)){
$signData['version'] = $this->version; //填写的值为 2 时,交易成功后返回优惠信息
}
if(isset($this->identity)){
$signData['identity'] = $this->identity; //JSON 格式指定付款人信息(格式繁琐,不推荐使用)
}
if(isset($this->patnersettleflag)){
$signData['patnersettleflag'] = $this->patnersettleflag;//资金结算秒到标识(取值:1、2) 1:本次交易正常T1结算,2:本次交易秒到(前提条件:代理需开通白名单、商户需要开通秒到功能)
}
// 移除数组中的空值
$this->retData = ArrayUtil::paraFilter($signData);
}
protected function checkDataParam(){
parent::checkDataParam(); // TODO: Change the autogenerated stub
if(empty($this->notifyUrl)){
throw new PayException('支付通知地址不能为空');
}
}
}
<?php
namespace Payment\Common\YSpay\Data\Query;
use Payment\Common\YSpay\Data\YSBaseData;
use Payment\Common\PayException;
use Payment\Utils\ArrayUtil;
class ChargeQueryData extends YSBaseData{
/**
* 构建用于支付的签名相关数据
*
* @return array
*/
protected function buildData(){
// TODO: Implement buildData() method.
$this->certainSignData = [
'channelid' => $this->channelid, //渠道编号
'opt' => $this->opt ?? "tradeQuery", //操作类型(“tradeQuery”)
'merid' => $this->merid, //商戶编号
'termid' => $this->termid, //终端编号
'tradetrace' => $this->tradetrace, //原交易流水(建议使用易生流水号查询:wtorderid)
];
$signData = array_merge($this->certainSignData, []);
if(isset($this->tradetype)){
$signData['tradetype'] = $this->tradetype; //交易类型(“samecardQuery”:同名卡转出查询;其他查询为空)
}
$this->retData = ArrayUtil::paraFilter($signData);
}
/**
* 检查传入的参数. $reqData是否正确.
*
* @return mixed
* @throws PayException
*/
protected function checkDataParam(){
// TODO: Implement checkDataParam() method.
parent::checkDataParam();
if(empty($this->tradetrace)){
throw new PayException('第三方订单号不能为空');
}
}
}
<?php
namespace Payment\Common\YSpay\Data;
use Payment\Common\PayException;
use Payment\Utils\ArrayUtil;
class RefundData extends YSBaseData{
/**
* 构建用于支付的签名相关数据
*
* @return array
*/
protected function buildData(){
// TODO: Implement buildData() method.
$this->certainSignData = [
'channelid' => $this->channelid, //渠道编号
'opt' => $this->opt ?? "zwrefund", //操作类型(“zwrefund”)
'merid' => $this->merid, //商戶编号
'termid' => $this->termid, //终端编号
'tradetrace' => $this->tradetrace, //原交易流水(建议使用易生流水号查询:wtorderid)
// 'oritradetrace' => $this->oritradetrace, //原交易流水; 与 oriwtorderid 字段可以二选一上送,如果都上送,以 本节点为准。
// 'oriwtorderid' => $this->oriwtorderid, //原交易的系统订单号;与 oritradetrace 字段可以二选一上送,如果都 上送,以 oritradetrace 节点为准
'tradeamt' => $this->tradeamt, //退货金额,以分为单位,不大于原交易金额与已成功退货金额之差
];
$signData = array_merge($this->certainSignData, []);
if(isset($this->oritradetrace)){
$signData['oritradetrace'] = $this->oritradetrace; //退货金额,以分为单位,不大于原交易金额与已成功退货金额之差
}else{
if(isset($this->oriwtorderid)){
$signData['oriwtorderid'] = $this->oriwtorderid; //退货金额,以分为单位,不大于原交易金额与已成功退货金额之差
}
}
$this->retData = ArrayUtil::paraFilter($signData);
}
/**
* 检查传入的参数. $reqData是否正确.
*
* @return mixed
* @throws PayException
*/
protected function checkDataParam(){
// TODO: Implement checkDataParam() method.
parent::checkDataParam();
if(empty($this->oritradetrace)&&empty($this->oriwtorderid)){
throw new PayException('必须提供原交易系统的交易流水或者交易订单号');
}
}
}
<?php
namespace Payment\Common\YSpay\Data;
use Payment\Common\BaseData;
use Payment\Common\PayException;
abstract class YSBaseData extends BaseData{
/**
* 签名算法实现 便于后期扩展微信不同的加密方式
*
* @param string $signStr
* @return string
*/
protected function makeSign($signStr){
if(empty($this->key)) throw new PayException('请检查签名密钥是否正确');
switch ($this->signType) {
case 'MD5':
$signStr .= '&key=' . $this->key;
$sign = strtoupper(md5($signStr));
break;
default:
$sign = '';
}
$this->retData['sign'] = $sign;
return $sign;
// TODO: Implement makeSign() method.
}
protected function checkDataParam(){
// TODO: Implement checkDataParam() method.
// 检查订单号是否合法
if (empty($this->tradetrace) || mb_strlen($this->tradetrace) > 64) {
throw new PayException('商户系统的订单号不能为空且长度不能超过64位');
}
if (empty($this->merid) || empty($this->channelid)) {
throw new PayException('必须提供合作方标识与门店编号');
}
}
}
<?php
namespace Payment\Common\YSpay;
use Payment\Common\BaseData;
use Payment\Common\BaseStrategy;
use Payment\Common\YSConfig;
use Payment\Common\PayException;
use Payment\Utils\ArrayUtil;
use Payment\Utils\Curl;
abstract class YSBaseStrategy implements BaseStrategy
{
protected $config;
/**
* 支付数据
* @var BaseData $reqData
*/
protected $reqData;
/**
* FuBaseStrategy constructor.
* @param array $config
* @throws PayException
*/
public function __construct(array $config)
{
/* 设置内部字符编码为 UTF-8 */
mb_internal_encoding("UTF-8");
try {
$this->config = new YSConfig($config);
} catch (PayException $e) {
throw $e;
}
}
/**
* 发送完了请求
* @param $body
* @return mixed
* @throws \Payment\Common\PayException
*/
protected function sendReq($body)
{
$url = $this->getReqUrl();
if (is_null($url)) {
throw new PayException('目前不支持该接口。请联系开发者添加');
}
$responseTxt = $this->curlPost($body, $url);
if ($responseTxt['error']) {
throw new PayException('网络发生错误,请稍后再试curl返回码:' . $responseTxt['message']);
}
// 格式化为数组
$retData = (json_decode($responseTxt['body'], true));
// print_r($retData);die;
if ($retData['resultcode'] != '00' && $retData['resultcode'] != 'W6') {
throw new PayException('支付平台返回错误提示:' . $retData['returnmsg']);
}
return $retData;
}
protected function curlPost($body, $url)
{
$curl = new Curl();
return $curl->set([
'CURLOPT_HEADER' => 0
])->post($body, $url)->submit($url);
}
/**
* 处理具体的业务
*
* @param array $data
* @return mixed
* @throws \Payment\Common\PayException
*/
public function handle(array $data)
{
// TODO: Implement handle() method.
$buildClass = $this->getBuildDataClass();
try {
$this->reqData = new $buildClass($this->config, $data);
} catch (PayException $e) {
throw $e;
}
$this->reqData->setSign();
$body = $this->reqData->getData();
// echo "<pre>";
// var_dump(json_encode($body));
// echo "</pre>";
$ret = $this->sendReq($body);
// 检查返回的数据是否被篡改
$flag = true;
// $flag = $this->verifySign($ret);
if (!$flag) {
throw new PayException('返回数据被篡改。请检查网络是否安全!');
}
return $this->retData($ret);
}
/**
* 获取请求地址
* @param null $url
* @return string
*/
protected function getReqUrl($url = null)
{
if (isset($this->config->base_url) && !empty($this->config->base_url)) {
$_pre = $this->config->base_url;
} else {
$_pre = YSConfig::REQUEST_URL;
}
return $_pre;
}
/**
* 处理微信的返回值并返回给客户端
* @param array $ret
* @return mixed
*
*/
protected function retData(array $ret)
{
return $ret;
}
/**
* 检查微信返回的数据是否被篡改过
*
* @param array $retData
* @return boolean
* @throws \Exception
*/
protected function verifySign(array $retData)
{
$retSign = $retData['sign'];
$values = ArrayUtil::removeKeys($retData, ['sign']);
$values = ArrayUtil::paraFilter($values);
$values = ArrayUtil::arraySort($values);
$signStr = ArrayUtil::createLinkstring($values);
$signStr = str_replace(' ', '', $signStr);
$signStr .= '&key=' . $this->config->key;
switch ($this->config->signType) {
case 'MD5':
$sign = md5($signStr);
break;
case 'HMAC-SHA256':
$sign = hash_hmac('sha256', $signStr, $this->config->key);
break;
default:
$sign = '';
}
// echo $retSign;echo"<br>";
// echo strtoupper($sign);die;
return strtoupper($sign) === $retSign;
}
}
......@@ -32,6 +32,12 @@ final class Config{
const LTF_PAY = 'ltfpay'; //富友支付
const YS_PAY = 'yspay'; //易生支付
const YSE_PAY = 'ysepay'; //盛银支付
const SW_T_PAY = 'swpay_t'; //扫呗支付(3.0)
//========================= 金额问题设置 =======================//
const PAY_MIN_FEE = '0.01';// 支付的最小金额
......@@ -142,7 +148,6 @@ final class Config{
//========================= 扫呗相关接口 =======================//
//http://www.lcsw.cn/doc/api/payment.html
// 支付常量
const SW_CHANNEL_PUB = 'sw_pub';// 微信公众号h5支付
......@@ -169,6 +174,26 @@ 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'; // 查询接口
//========================= 富友相关接口 =======================//
// 支付常量
......@@ -203,4 +228,37 @@ final class Config{
const LTF_CANCEL = 'ltf_cancel';// 交易撤销,只能撤销当天的交易,全额退款,实时返回退款结果
const LTF_CHANNEL_PAY = 'ltf_pay';// 聚合支付
//=======================易生支付 相关接口===================//
//支付常量
const YS_CHARGE = 'ys_charge';// 统一下单
const YS_CHANNEL_PUB = 'ys_pub'; // 微信公众号h5支付
const YS_CHANNEL_LITE = 'ys_lite';// 小程序支付
const YS_CHANNEL_SCAN = 'ys_scan';// 付款码支付
// const YS_CHANNEL_BAR = 'ys_bar';// 刷卡(条码)支付 用户被扫模式
const YS_CHANNEL_NATIVE = 'ys_native';//主扫模式
const YS_QUERY = 'ys_query'; // 查询接口
const YS_REFUND = 'ys_refund';// 退款
const YS_CANCEL = 'ys_cancel';// 交易撤销,只能撤销当天的交易,全额退款,实时返回退款结果
//=======================银盛支付 相关接口===================//
//支付常量
const YSE_CHARGE = 'yse_charge';// 统一下单
const YSE_REFUND = 'yse_refund';// 退款
const YSE_QUERY = 'yse_query';// 订单查询
const YSE_CHANNEL_PUB = 'yse_pub'; // 公众号支付
const YSE_CHANNEL_LITE = 'yse_lite';// 小程序支付
}
File mode changed
File mode changed
File mode changed
File mode changed
<?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,
];
}
}
<?php
namespace Payment\Notify;
use Payment\Common\YSEConfig;
use Payment\Common\PayException;
use Payment\Config;
use Payment\Utils\ArrayUtil;
class YSENotify extends NotifyStrategy{
/**
* SwNotify constructor.
*
* @param array $config
* @throws PayException
*/
public function __construct(array $config){
parent::__construct($config);
try{
$this->config = new YSEConfig($config);
}catch(PayException $e){
throw $e;
}
}
/**
* 获取移除通知的数据 并进行简单处理(如:格式化为数组)
* 如果获取数据失败,返回false
*
* @return array|false
*/
public function getNotifyData(){
$params = array();
//支持直接读取input流
// $data = @file_get_contents('php://input');
$data = $_POST;
if(!empty($data)){
// $inputArray = json_decode($data, true);
$params = array_merge($params, $data);
}
if(count($params) < 1){//如果参数为空,则不进行处理
return false;
}
return $params;
// TODO: Implement getNotifyData() method.
}
/**
* 检查异步通知的数据是否合法
* 如果检查失败,返回false
*
* @param array $data 由 $this->getNotifyData() 返回的数据
* @return boolean
* @throws \Exception
*/
public function checkNotifyData(array $data){
return $this->verifySign($data);
}
/**
* 检查数据是否被篡改过
*
* @param array $retData
* @return bool
* @throws \Exception
*/
protected function verifySign(array $retData){
$retSign = $retData['sign'];//先不验证加密s
return true;
$data = ArrayUtil::removeKeys($retData, ['sign']);
$values = [
'return_code' => $data['code'],
'return_msg' => $data['msg'],
'out_trade_no' => $data['outTradeNo'],
'transaction_id' => $data['transactionId'],
'pay_type' => $data['payType'],
'total_fee' => $data['totalAmount'],
'user_id' => $data['buyerId'],
'out_transaction_id' => $data['outTransactionId'],
];
$values = ArrayUtil::paraFilter($values);
// $values = ArrayUtil::arraySort($values);
$signStr = ArrayUtil::createLinkstring($values);
switch($this->config->signType){
case 'MD5':
$sign = md5($signStr);
break;
default:
$sign = '';
}
return strtoupper($sign) === strtoupper($retSign);
}
/**
* 向客户端返回必要的数据
*
* @param array $data
* @return void
*/
protected function getRetData(array $data){
// TODO: Implement getRetData() method.
$retData = [
'sign' => $data['sign'],
'notify_type' => $data['notify_type'],
'notify_time' => $data['notify_time'],
'out_trade_no' => $data['out_trade_no'],
'total_amount' => $data['total_amount'] ?? 0,
'trade_no' => $data['trade_no'] ?? '',
'trade_status' => $data['trade_status'],
];
return $retData;
}
/**
* 根据返回结果,回答支付机构。是否回调通知成功
*
* @param boolean $flag 每次返回的bool值
* @param string $msg 通知信息,错误原因
* @return mixed
*/
protected function replyNotify($flag, $msg = 'OK'){
if (! $flag) {
return 'FAIL';
}
return 'SUCCESS';
}
}
<?php
namespace Payment\Notify;
use Payment\Common\YSConfig;
use Payment\Common\PayException;
use Payment\Config;
use Payment\Utils\ArrayUtil;
class YSNotify extends NotifyStrategy{
/**
* SwNotify constructor.
*
* @param array $config
* @throws PayException
*/
public function __construct(array $config){
parent::__construct($config);
try{
$this->config = new YSConfig($config);
}catch(PayException $e){
throw $e;
}
}
/**
* 获取移除通知的数据 并进行简单处理(如:格式化为数组)
* 如果获取数据失败,返回false
*
* @return array|false
*/
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;
// TODO: Implement getNotifyData() method.
}
/**
* 检查异步通知的数据是否合法
* 如果检查失败,返回false
*
* @param array $data 由 $this->getNotifyData() 返回的数据
* @return boolean
* @throws \Exception
*/
public function checkNotifyData(array $data){
return $this->verifySign($data);
}
/**
* 检查数据是否被篡改过
*
* @param array $retData
* @return bool
* @throws \Exception
*/
protected function verifySign(array $retData){
$retSign = $retData['sign'];//先不验证加密s
return true;
$data = ArrayUtil::removeKeys($retData, ['sign']);
$values = [
'return_code' => $data['code'],
'return_msg' => $data['msg'],
'out_trade_no' => $data['outTradeNo'],
'transaction_id' => $data['transactionId'],
'pay_type' => $data['payType'],
'total_fee' => $data['totalAmount'],
'user_id' => $data['buyerId'],
'out_transaction_id' => $data['outTransactionId'],
];
$values = ArrayUtil::paraFilter($values);
// $values = ArrayUtil::arraySort($values);
$signStr = ArrayUtil::createLinkstring($values);
switch($this->config->signType){
case 'MD5':
$sign = md5($signStr);
break;
default:
$sign = '';
}
return strtoupper($sign) === strtoupper($retSign);
}
/**
* 向客户端返回必要的数据
*
* @param array $data
* @return void
*/
protected function getRetData(array $data){
// TODO: Implement getRetData() method.
$retData = [
'tradetrace' => $data['tradetrace'],
'wtorderid' => $data['wtorderid'],
'wxtransactionid' => $data['wxtransactionid'],
'wxtimeend' => $data['wxtimeend'] ?? '',
'wxopenid' => $data['wxopenid'] ?? '',
'channel' => Config::YS_CHARGE,
'sign' => $data['sign']
];
if(isset($data['clearamt'])){
$retData['clearamt'] = $data['clearamt'];
}
if(isset($data['payamt'])){
$retData['payamt'] = $data['payamt'];
}
return $retData;
}
/**
* 根据返回结果,回答支付机构。是否回调通知成功
*
* @param boolean $flag 每次返回的bool值
* @param string $msg 通知信息,错误原因
* @return mixed
*/
protected function replyNotify($flag, $msg = 'OK'){
if (! $flag) {
return 'FAIL';
}
return 'SUCCESS';
}
}
......@@ -15,9 +15,12 @@ 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;
use Payment\Notify\YSNotify;
use Payment\Notify\YSENotify;
class NotifyContext
{
......@@ -59,12 +62,21 @@ 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;
case Config::LTF_CHARGE:
$this->notify = new LTFNotify($config);
break;
case Config::YS_CHARGE:
$this->notify = new YSNotify($config);
break;
case Config::YSE_CHARGE:
$this->notify = new YSENotify($config);
break;
default:
throw new PayException('当前仅支持:ALI_CHARGE WX_CHARGE CMB_CHARGE TL_CHARGE MI_CHARGE SW_CHARGE FU_CHARGE');
}
......
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
File mode changed
<?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;
}
}
File mode changed
<?php
namespace Payment\Query\YS;
use Payment\Common\YSConfig;
use Payment\Common\YSpay\Data\Query\ChargeQueryData;
use Payment\Common\YSpay\YSBaseStrategy;
class YSChargeQuery extends YSBaseStrategy{
public function getBuildDataClass(){
return ChargeQueryData::class;
}
/**
* 返回
* @param null $url
* @return string
*/
public function getReqUrl($url = null){
return parent::getReqUrl($url ?? YSConfig::REQUEST_URL); // TODO: Change the autogenerated stub
}
}
<?php
namespace Payment\Query\YS;
use Payment\Common\YSConfig;
use Payment\Common\YSpay\Data\Query\RefundQueryData;
use Payment\Common\YSpay\YSBaseStrategy;
class YSRefundQuery extends YSBaseStrategy{
public function getBuildDataClass(){
return RefundQueryData::class;
}
public function getReqUrl($url = null){
return parent::getReqUrl($url ?? YSConfig::REQUEST_URL); // TODO: Change the autogenerated stub
}
}
<?php
namespace Payment\Query\YSE;
use Payment\Common\YSEConfig;
use Payment\Common\YSEpay\Data\Query\ChargeQueryData;
use Payment\Common\YSEpay\YSEBaseStrategy;
class YSEChargeQuery extends YSEBaseStrategy{
public function getBuildDataClass(){
return ChargeQueryData::class;
}
/**
* 返回
* @param null $url
* @return string
*/
public function getReqUrl($url = null){
return parent::getReqUrl($url ?? YSEConfig::QUERY_URL); // TODO: Change the autogenerated stub
}
}
<?php
namespace Payment\Query\YS;
use Payment\Common\YSConfig;
use Payment\Common\YSpay\Data\Query\RefundQueryData;
use Payment\Common\YSpay\YSBaseStrategy;
class YSRefundQuery extends YSBaseStrategy{
public function getBuildDataClass(){
return RefundQueryData::class;
}
public function getReqUrl($url = null){
return parent::getReqUrl($url ?? YSConfig::REQUEST_URL); // TODO: Change the autogenerated stub
}
}
......@@ -21,11 +21,14 @@ 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;
use Payment\Query\Wx\WxRefundQuery;
use Payment\Query\Wx\WxTransferQuery;
use Payment\Query\YS\YSChargeQuery;
use Payment\Query\YSE\YSEChargeQuery;
class QueryContext
{
......@@ -88,7 +91,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);
break;
......@@ -101,6 +106,13 @@ class QueryContext
case Config::LTF_REFUND:
$this->query=new LTFRefundQuery($config);
break;
case Config::YS_QUERY://易生支付
$this->query = new YSChargeQuery($config);
break;
case Config::YSE_QUERY://银盛支付
$this->query = new YSEChargeQuery($config);
break;
default:
throw new PayException('当前仅支持:ALI_CHARGE ALI_REFUND WX_CHARGE WX_REFUND WX_TRANSFER WX_PAY_BANK CMB_CHARGE CMB_REFUND TLPAY MI_QUERY SW_QUERY FU_CHARGE FU_REFUND');
}
......
File mode changed
File mode changed
File mode changed
File mode changed
<?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;
}
}
<?php
namespace Payment\Refund;
use Payment\Common\YSEConfig;
use Payment\Common\YSEpay\Data\RefundData;
use Payment\Common\YSEpay\YSEBaseStrategy;
class YSERefund extends YSEBaseStrategy{
public function getBuildDataClass(){
return RefundData::class;
}
public function getReqUrl($url = null){
return parent::getReqUrl($url ?? YSEConfig::REFUND_URL); // TODO: Change the autogenerated stub
}
}
<?php
namespace Payment\Refund;
use Payment\Common\YSConfig;
use Payment\Common\YSpay\Data\RefundData;
use Payment\Common\YSpay\YSBaseStrategy;
class YSRefund extends YSBaseStrategy{
public function getBuildDataClass(){
return RefundData::class;
}
public function getReqUrl($url = null){
return parent::getReqUrl($url ?? YSConfig::REQUEST_URL); // TODO: Change the autogenerated stub
}
}
......@@ -16,8 +16,11 @@ 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;
use Payment\Refund\YSRefund;
use Payment\Refund\YSERefund;
class RefundContext
{
......@@ -59,12 +62,21 @@ 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;
case Config::LTF_REFUND:
$this->refund= new LTFRefund($config);
break;
case Config::YS_REFUND:
$this->refund = new YSRefund($config);
break;
case Config::YSE_REFUND:
$this->refund = new YSERefund($config);
break;
default:
throw new PayException('当前仅支持:ALI WEIXIN CMB TL MI SW FU');
}
......
File mode changed
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!