Authored by whb

Merge branch 'temp'

... ... @@ -19,7 +19,6 @@ function coverParamsToString($params)
continue;
}
$sign_str .= sprintf("%s=%s&", $key, $val);
// $sign_str .= $key . '=' . $val . '&';
}
return substr($sign_str, 0, strlen($sign_str) - 1);
}
... ...
... ... @@ -47,20 +47,22 @@ function sign(&$params)
function verify($params)
{
$log = new PhpLog (SDK_LOG_FILE_PATH, "PRC", SDK_LOG_LEVEL);
$log->LogInfo('=====返回参数====');
$log->LogInfo(var_export($params, true));
// 公钥
$public_key = getPulbicKeyByCertId($params ['certId']);
// echo $public_key.'<br/>';
$public_key = getPulbicKeyByCertId($params['certId']);
// 签名串
$signature_str = $params ['signature'];
unset ($params ['signature']);
$signature_str = $params['signature'];
unset($params['signature']);
$params_str = coverParamsToString($params);
$log->LogInfo('报文去[signature] key=val&串>' . $params_str);
$signature = base64_decode($signature_str);
// echo date('Y-m-d',time());
$params_sha1x16 = sha1($params_str, FALSE);
$log->LogInfo('摘要shax16>' . $params_sha1x16);
$isSuccess = openssl_verify($params_sha1x16, $signature, $public_key, OPENSSL_ALGO_SHA1);
$log->LogInfo($isSuccess ? '验签成功' : '验签失败');
return $isSuccess;
}
... ...
... ... @@ -35,24 +35,26 @@ class Service extends PayAbstract
*/
public function parseResponse(array $package)
{
$this->log->LogInfo(var_export($package, true));
$verify = false;
if (isset($package ['signature']) && verify($package)) {
$verify = true;
$this->log->LogInfo('验签成功');
} else {
return false;
}
$responseData = new Rspparams();
if ($package['respCode'] !== '00') {
if (!isset($package['respCode']) || $package['respCode'] !== '00') {
$this->log->LogInfo('支付返回码有误');
return false;
$responseData->payResult = -1;
return $responseData;
}
if (isset($package['signature'])) { // TODO isset($package['signature']) && verify($package)验证签名待做
$verify = true;
$this->log->LogInfo('验签成功');
}
$responseData = new Rspparams();
if ($verify) {
//更改订单状态
$responseData->orderCode = $package['orderId'];
$responseData->payResult = 0;
$responseData->payResult = 200;
$responseData->payTime = time();
$responseData->totalFee = $package['txnAmt'] * 0.01;
$responseData->bankName = '';
... ... @@ -65,6 +67,8 @@ class Service extends PayAbstract
$responseData->payResult = -1;
}
$this->log->LogInfo(var_export($responseData, true));
return $responseData;
}
... ...
... ... @@ -50,7 +50,7 @@ const SDK_App_Request_Url = 'https://gateway.95516.com/gateway/api/appTransReq.d
// 前台通知地址 (商户自行配置通知地址)
const SDK_FRONT_NOTIFY_URL = 'http://www.yohobuy.com/pay/notice/unionpaywebreturn';
// 后台通知地址 (商户自行配置通知地址)
const SDK_BACK_NOTIFY_URL = 'http://pay.yohobuy.com/notify/unionpaywebnotice';
const SDK_BACK_NOTIFY_URL = 'http://www.yohobuy.com/pay/notice/unionpaywebnotice';
//文件下载目录
const SDK_FILE_DOWN_PATH = '/tmp/unionpay/files/';
... ...
-----BEGIN CERTIFICATE-----
MIIDNjCCAh6gAwIBAgIQEAAAAAAAAAAAAAAQBQdAIDANBgkqhkiG9w0BAQUFADAh
MQswCQYDVQQGEwJDTjESMBAGA1UEChMJQ0ZDQSBPQ0ExMB4XDTEyMTIxODAyMDA1
MVoXDTE1MTIxODAyMDA1MVowfDELMAkGA1UEBhMCQ04xDTALBgNVBAoTBE9DQTEx
ETAPBgNVBAsTCENGQ0EgTFJBMRkwFwYDVQQLExBPcmdhbml6YXRpb25hbC0xMTAw
LgYDVQQDFCc4MzEwMDAwMDAwMDgzMDQwQDAwMDQwMDAwOlNJR05AMDAwMDAwMDEw
ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDFG+NnBXN++aUUAbgVFOt/
pi2McB79P+tmkS98Pnlj+pEvCc2nltq2VZzfJvGb1UE6lXKXoCG+NosZMj64uda9
Du2up78Z92HGdT2tkZ0RaoouR4jCY0Bmz0+5zObjR607vwBTvln9idG9ZGK2Lm35
QSxjpLolRPEnz/rgxFG9ezxVfI9eQ7JmuBk/OXyzjA1JQwAMhdAT3GJO0JMmMDvC
Q0pNyTsu1oyQPJoCaV3qPfpcvatMKYsVxo2Zeogqw2x2L6KE8BODrj6m6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O0JMmMDvC
Q0pNyTsu1oyQPJoCaV3qPfpcvatMKYsVxo2Zeogqw2x2L6KE8BODrj6m6Ue1aUMn
9Ch1XbR/dB8M2M+nVtOAVb6DA6kVuNFlMl2uzxD8MQlhos8aT+vCx1v9p21k3+jz
AgMBAAGjDzANMAsGA1UdDwQEAwIGwDANBgkqhkiG9w0BAQUFAAOCAQEAhgW/gcDa
fqs0oWDH81XnTVvDCp5mwDo+wxgzVRTEtudU6seKcc2kiBe1RqegtUX2le/eAzcD
mo7nxHMy73ANdP/wha+P2gp+mo3buhO244pQphMV+Yu8djHTFH8+hRkCbnsrndYc
qNiJ/yhsUpaJ4nY+oEoyut0id6QddKiNPYoTFz0fy/VqNP6g+23zFy6sIg+gffVZ
6o3CsZVu9z5umUjzfV384iSWovq+/IdSZ4g/jerdPtje/CKYTmzG5nsCa/s+i7Rf
D5scSlfi7iW2Q7Sc/HlrtOAglt7IyjRSsFPPxuBXmSITc2GDKyKI46u8RXpccAUh
YspJ5MXOYLZN7A==
-----END CERTIFICATE-----
\ No newline at end of file
... ...
... ... @@ -46,7 +46,7 @@ const SDK_App_Request_Url = 'https://101.231.204.80:5000/gateway/api/appTransReq
// 前台通知地址 (商户自行配置通知地址)
const SDK_FRONT_NOTIFY_URL = 'http://www.yohobuy.com/pay/notice/unionpaywebreturn';
// 后台通知地址 (商户自行配置通知地址)
const SDK_BACK_NOTIFY_URL = 'http://pay.test.yohobuy.com/notify/unionpaywebnotice';
const SDK_BACK_NOTIFY_URL = 'http://www.yohobuy.com/pay/notice/unionpaywebnotice';
//文件下载目录
const SDK_FILE_DOWN_PATH = '/tmp/unionpay/files/';
... ...
... ... @@ -294,7 +294,7 @@ class NoticeController extends WebAction
{
$payment = PayModel::getPaymentById(25);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($_GET);
$res = $payService->parseResponse($_REQUEST);
if ($res->payResult != -1) {
$this->payResultProc($res, 25);
echo "OK";
... ...