Commit fc5c4d8e by 赵凯(PHP)

update

1 parent 54a1c890
<?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
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
namespace Payment\Charge\SwThree; namespace Payment\Charge\SwThree;
use Payment\Common\SwThree\Data\Cancel\BackCancelData; use Payment\Common\SwThree\Data\BackCancelData;
use Payment\Common\SwThree\Data\Cancel\CancelData; use Payment\Common\SwThree\Data\Cancel\CancelData;
use Payment\Common\SwThree\SwBaseStrategy; use Payment\Common\SwThree\SwBaseStrategy;
......
...@@ -29,7 +29,8 @@ class LiteChargeData extends ChargeBaseData ...@@ -29,7 +29,8 @@ class LiteChargeData extends ChargeBaseData
throw new PayException('用户标识(微信openid),需要传入,通过微信官方接口获得'); throw new PayException('用户标识(微信openid),需要传入,通过微信官方接口获得');
} }
} }
$this->pay_ver = '201';
$this->service_id = '015'; $this->service_id = '015';
} }
...@@ -67,7 +68,6 @@ class LiteChargeData extends ChargeBaseData ...@@ -67,7 +68,6 @@ class LiteChargeData extends ChargeBaseData
if(isset($this->attach)){ if(isset($this->attach)){
$signData['attach'] = $this->attach; $signData['attach'] = $this->attach;
} }
// 移除数组中的空值 // 移除数组中的空值
$this->retData = ArrayUtil::paraFilter($signData); $this->retData = ArrayUtil::paraFilter($signData);
} }
......
...@@ -30,8 +30,10 @@ class PubChargeData extends ChargeBaseData ...@@ -30,8 +30,10 @@ class PubChargeData extends ChargeBaseData
if (($payType == '010' || $payType == '020')) { if (($payType == '010' || $payType == '020')) {
if (empty($this->open_id)) throw new PayException('用户在商户appid下的唯一标识,用户标识(微信openid,支付宝userid),pay_type为010及020时需要传入.'); if (empty($this->open_id)) throw new PayException('用户在商户appid下的唯一标识,用户标识(微信openid,支付宝userid),pay_type为010及020时需要传入.');
} }
$this->pay_ver = '201';
$this->service_id = '012'; $this->service_id = '012';
} }
protected function buildData() protected function buildData()
......
...@@ -17,33 +17,6 @@ class BackChargeQueryData extends SwBaseData ...@@ -17,33 +17,6 @@ class BackChargeQueryData extends SwBaseData
{ {
protected function buildData() protected function buildData()
{ {
$this->retData['package'] = [
'trade_state' => $this->trade_state??'',//交易订单状态,SUCCESS支付成功,REFUND转入退款,NOTPAY未支付,CLOSED已关闭,USERPAYING用户支付中,REVOKED已撤销,NOPAY未支付支付超时,PAYERROR支付失败
'channel_order_no' => $this->channel_order_no??'',//银行渠道订单号,微信支付时显示在支付成功页面的条码,可用作扫码查询和扫码退款时匹配
'channel_trade_no' => $this->channel_trade_no??'',//通道订单号,微信订单号、支付宝订单号等,返回时不参与签名
'user_id' => $this->user_id,//付款方用户id,“微信openid”、“支付宝账户”、“qq号”等,返回时不参与签名
'pay_trace' => $this->pay_trace,//当前支付终端流水号
'pay_time' => $this->pay_time,//当前支付终端交易时间
'total_fee' => $this->total_fee,
'end_time' => $this->end_time??'',
];
$this->retData['other'] = [
'pay_type' => $this->pay_type,
'merchant_name' => $this->merchant_name,
'merchant_no' => $this->merchant_no,
'terminal_id' => $this->terminal_id,
'terminal_trace'=> $this->terminal_trace,
'terminal_time' => $this->terminal_time,
'total_fee' => $this->total_fee,
'end_time' => $this->end_time??'',
'out_trade_no' => $this->out_trade_no??'',//订单号
'order_body' => $this->order_body??'',
'attach' => $this->attach??'',
];
if($this->pay_type == '090'){//口碑实收金额,pay_type为090时必填
$this->retData['package']['receipt_fee'] = $this->receipt_fee;
}
} }
protected function checkDataParam() protected function checkDataParam()
......
...@@ -19,9 +19,6 @@ class ChargeQueryData extends SwBaseData ...@@ -19,9 +19,6 @@ class ChargeQueryData extends SwBaseData
{ {
protected function checkDataParam() protected function checkDataParam()
{ {
parent::checkDataParam();
$this->pay_ver = '201'; $this->pay_ver = '201';
$this->service_id = '020'; $this->service_id = '020';
...@@ -63,10 +60,7 @@ class ChargeQueryData extends SwBaseData ...@@ -63,10 +60,7 @@ class ChargeQueryData extends SwBaseData
if(isset($this->pay_time)){ if(isset($this->pay_time)){
$signData['pay_time'] = $this->pay_time; $signData['pay_time'] = $this->pay_time;
} }
$this->retData = ArrayUtil::paraFilter($signData);
$this->retData = ArrayUtil::paraFilter($this->retData);
} }
} }
\ No newline at end of file
...@@ -23,14 +23,12 @@ abstract class SwBaseData extends BaseData ...@@ -23,14 +23,12 @@ abstract class SwBaseData extends BaseData
switch ($this->signType) { switch ($this->signType) {
case 'MD5': case 'MD5':
$signStr .= '&access_token=' . $this->access_token; $signStr .= '&access_token=' . $this->access_token;
$sign = md5($signStr); $sign = md5($signStr);
break; break;
default: default:
$sign = ''; $sign = '';
} }
$this->retData['key_sign'] = $sign; $this->retData['key_sign'] = $sign;
return $sign; return $sign;
......
...@@ -52,14 +52,12 @@ abstract class SwBaseStrategy implements BaseStrategy ...@@ -52,14 +52,12 @@ abstract class SwBaseStrategy implements BaseStrategy
if (is_null($url)) { if (is_null($url)) {
throw new PayException('目前不支持该接口。请联系开发者添加'); throw new PayException('目前不支持该接口。请联系开发者添加');
} }
$responseTxt = $this->curlPost($body, $url); $responseTxt = $this->curlPost($body, $url);
if ($responseTxt['error']) { if ($responseTxt['error']) {
throw new PayException('网络发生错误,请稍后再试curl返回码:' . $responseTxt['message']); throw new PayException('网络发生错误,请稍后再试curl返回码:' . $responseTxt['message']);
} }
// 格式化为数组 // 格式化为数组
$retData = (json_decode($responseTxt['body'],true)); $retData = (json_decode($responseTxt['body'],true));
if ($retData['return_code'] != '01') { if ($retData['return_code'] != '01') {
throw new PayException('支付平台返回错误提示:' . $retData['return_msg']); throw new PayException('支付平台返回错误提示:' . $retData['return_msg']);
} }
...@@ -109,15 +107,12 @@ abstract class SwBaseStrategy implements BaseStrategy ...@@ -109,15 +107,12 @@ abstract class SwBaseStrategy implements BaseStrategy
public function handle(array $data) public function handle(array $data)
{ {
$buildClass = $this->getBuildDataClass(); $buildClass = $this->getBuildDataClass();
try { try {
$this->reqData = new $buildClass($this->config, $data); $this->reqData = new $buildClass($this->config, $data);
} catch (PayException $e) { } catch (PayException $e) {
throw $e; throw $e;
} }
$this->reqData->setSign(); $this->reqData->setSign();
$body = $this->reqData->getData(); $body = $this->reqData->getData();
$ret = $this->sendReq($body); $ret = $this->sendReq($body);
......
...@@ -43,11 +43,8 @@ class SwChargeThreeQuery extends SwBaseStrategy ...@@ -43,11 +43,8 @@ class SwChargeThreeQuery extends SwBaseStrategy
*/ */
protected function retData(array $ret) protected function retData(array $ret)
{ {
$back = new BackChargeQueryData($this->config, $ret);
$backData = $back->getData();
// 移除sign // 移除sign
unset($backData['sign']); unset($ret['key_sign']);
return $ret;
return $backData;
} }
} }
<?php
namespace Payment\Charge\SwThree;
use Payment\Common\SwThree\Data\BackBarChargeData;
use Payment\Common\SwThree\Data\Charge\BarChargeData;
use Payment\Common\SwThree\SwBaseStrategy;
use Payment\Common\SwThreeConfig;
/**
* Class SwBarCharge
*
* 扫呗刷卡(条码)支付
*
* @package Payment\Charge\Sw
*
*/
class SwBarThreeCharge extends SwBaseStrategy
{
public function getBuildDataClass()
{
return BarChargeData::class;
}
protected function getReqUrl($url=null){
return parent::getReqUrl($url??SwThreeConfig::BARCODE_URL);
}
/**
* 处理扫码支付的返回值
* @param array $ret
*
* @return array $backData
*
*
*/
protected function retData(array $ret)
{
$back = new BackBarChargeData($this->config, $ret);
$backData = $back->getData();
// 移除sign
unset($backData['sign']);
return $backData;
}
}
<?php
namespace Payment\Charge\SwThree;
use Payment\Common\SwThree\Data\BackFaceChargeData;
use Payment\Common\SwThree\Data\Charge\FaceChargeData;
use Payment\Common\SwThree\SwBaseStrategy;
use Payment\Common\SwThreeConfig;
/**
* Class SwFaceCharge
*
* 扫呗自主收银(人脸支付)
*
* @package Payment\Charge\Sw
*
*/
class SwFaceCharge extends SwBaseStrategy
{
public function getBuildDataClass()
{
return FaceChargeData::class;
}
protected function getReqUrl($url=null){
return parent::getReqUrl($url??SwThreeConfig::FACEPAY_URL);
}
/**
* 处理小程序支付的返回值
* @param array $ret
*
* @return array $backData
*
*
*/
protected function retData(array $ret)
{
$back = new BackFaceChargeData($this->config, $ret);
$backData = $back->getData();
// 移除sign
unset($backData['sign']);
return $backData;
}
}
<?php
namespace Payment\Charge\Sw;
use Payment\Common\Sw\Data\BackFaceInfoData;
use Payment\Common\Sw\Data\Charge\FaceInfoData;
use Payment\Common\Sw\SwBaseStrategy;
use Payment\Common\SwConfig;
/**
* Class SwFaceInfo
*
* 自助收银SDK调用凭证获取接口
*
* @package Payment\Charge\Sw
*
*/
class SwFaceInfo extends SwBaseStrategy
{
public function getBuildDataClass()
{
return FaceInfoData::class;
}
protected function getReqUrl($url = null){
return parent::getReqUrl($url??SwConfig::FACEPAY_ACCESSTOKEN_URL);
}
/**
* 处理小程序支付的返回值
* @param array $ret
*
* @return array $backData
*
*
*/
protected function retData(array $ret)
{
$back = new BackFaceInfoData($this->config, $ret);
$backData = $back->getData();
// 移除sign
unset($backData['sign']);
return $backData;
}
}
<?php
namespace Payment\Charge\SwThree;
use Payment\Common\SwThree\Data\BackLiteChargeData;
use Payment\Common\SwThree\Data\Charge\LiteChargeData;
use Payment\Common\SwThree\SwBaseStrategy;
use Payment\Common\SwThreeConfig;
/**
* Class SwLiteCharge
*
* 扫呗小程序支付
*
* @package Payment\Charge\Sw
*
*/
class SwLiteThreeCharge extends SwBaseStrategy
{
public function getBuildDataClass()
{
return LiteChargeData::class;
}
protected function getReqUrl($url=null){
return parent::getReqUrl($url??SwThreeConfig::LITEPAY_URL);
}
/**
* 处理小程序支付的返回值
* @param array $ret
*
* @return array $backData
*
*
*/
protected function retData(array $ret)
{
$back = new BackLiteChargeData($this->config, $ret);
$backData = $back->getData();
// 移除sign
unset($backData['sign']);
return $backData;
}
}
<?php
namespace Payment\Charge\SwThree;
use Payment\Common\SwThree\Data\BackPubChargeData;
use Payment\Common\SwThree\Data\Charge\PubChargeData;
use Payment\Common\SwThree\SwBaseStrategy;
/**
* Class SwPubCharge
*
* 扫呗微信公众号支付
*
* @package Payment\Charge\Sw
*
*/
class SwPubThreeCharge extends SwBaseStrategy
{
public function getBuildDataClass()
{
// $this->config->tradeType = 'JSAPI';
return PubChargeData::class;
}
/**
* 处理公众号支付的返回值。直接返回与微信文档对应的字段
* @param array $ret
*
* @return array $data 包含以下键
*
* ```php
* $data = [
* 'appId' => '', // 公众号id
* 'package' => '', // 订单详情扩展字符串 统一下单接口返回的prepay_id参数值,提交格式如:prepay_id=***
* 'nonceStr' => '', // 随机字符串
* 'timeStamp' => '', // 时间戳
* 'signType' => '', // 签名算法,暂支持MD5
* 'paySign' => '', // 签名
* ];
* ```
*
* @throws \Payment\Common\PayException
*/
protected function retData(array $ret)
{
$back = new BackPubChargeData($this->config, $ret);
// $back->setSign();
$backData = $back->getData();
// $backData['paySign'] = $backData['sign'];
// 移除sign
unset($backData['sign']);
// 公众号支付返回数组结构
return $backData;
}
}
<?php
namespace Payment\Charge\SwThree;
use Payment\Common\SwThree\Data\BackScanChargeData;
use Payment\Common\SwThree\Data\Charge\ScanChargeData;
use Payment\Common\SwThree\SwBaseStrategy;
use Payment\Common\SwThreeConfig;
/**
* Class SwScanCharge
*
* 扫呗扫码支付
*
* @package Payment\Charge\Sw
*
*/
class SwScanThreeCharge extends SwBaseStrategy
{
public function getBuildDataClass()
{
return ScanChargeData::class;
}
protected function getReqUrl($url=null){
return parent::getReqUrl($url??SwThreeConfig::SCANPAY_URL);
}
/**
* 处理扫码支付的返回值
* @param array $ret
*
* @return array $backData
*
*
*/
protected function retData(array $ret)
{
$back = new BackScanChargeData($this->config, $ret);
$backData = $back->getData();
// 移除sign
unset($backData['sign']);
return $backData;
}
}
<?php
namespace Payment\Charge\SwThree;
use Payment\Common\SwThree\Data\BackCancelData;
use Payment\Common\SwThree\Data\Cancel\CancelData;
use Payment\Common\SwThree\SwBaseStrategy;
use Payment\Common\SwThreeConfig;
/**
* Class SwCancel
*
* 扫呗取消订单 (只针对刷卡支付!!!!!!)
*
* @package Payment\Charge\Sw
*
*/
class SwThreeCancel extends SwBaseStrategy
{
public function getBuildDataClass()
{
return CancelData::class;
}
protected function getReqUrl($url=null){
return parent::getReqUrl($url??SwThreeConfig::CANCEL_URL);
}
/**
* 处理小程序支付的返回值
* @param array $ret
*
* @return array $backData
*
*
*/
protected function retData(array $ret)
{
$back = new BackCancelData($this->config, $ret);
$backData = $back->getData();
// 移除sign
unset($backData['sign']);
return $backData;
}
}
<?php
namespace Payment\Charge\SwThree;
use Payment\Common\SwThree\Data\Cancel\BackCloseData;
use Payment\Common\SwThree\Data\Cancel\CloseData;
use Payment\Common\SwThree\SwBaseStrategy;
use Payment\Common\SwThreeConfig;
/**
* Class SwClose
*
* 扫呗关闭订单 ((仅限服务商模式商户且为微信支付时可用)!!!!!!)
*
* 此接口也支持支付宝,但仅限扫了二维码但没有输密码的情况下
* 刷卡支付不能进行关单操作
*
* @package Payment\Charge\Sw
*
*/
class SwThreeClose extends SwBaseStrategy
{
public function getBuildDataClass()
{
return CloseData::class;
}
protected function getReqUrl($url=null){
return parent::getReqUrl($url??SwThreeConfig::CLOSE_URL);
}
/**
* 处理小程序支付的返回值
* @param array $ret
*
* @return array $backData
*
*
*/
protected function retData(array $ret)
{
$back = new BackCloseData($this->config, $ret);
$backData = $back->getData();
// 移除sign
unset($backData['sign']);
return $backData;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!