Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
haishi
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
冷斌
haishi
Commits
ebf35c0b
Commit
ebf35c0b
authored
Mar 27, 2020
by
冷斌
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug
parent
1b78bd4b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
122 additions
and
0 deletions
+122
-0
wxpay/notify_url.php
+122
-0
No files found.
wxpay/notify_url.php
0 → 100755
View file @
ebf35c0b
<?php
function
xmlToArray
(
$xmlStr
)
{
return
(
array
)
simplexml_load_string
(
$xmlStr
,
'SimpleXMLElement'
,
LIBXML_NOCDATA
);
}
function
returnInfo
(
$type
,
$msg
)
{
if
(
$type
==
"SUCCESS"
)
{
return
$returnXml
=
"<xml><return_code><![CDATA[
{
$type
}
]]></return_code></xml>"
;
}
else
{
return
$returnXml
=
"<xml><return_code><![CDATA[
{
$type
}
]]></return_code><return_msg><![CDATA[
{
$msg
}
]]></return_msg></xml>"
;
}
}
function
getConfig
(
$link
)
{
$config
=
M
(
"options"
)
->
where
(
"option_name='configpri'"
)
->
getField
(
"option_value"
);
$result
=
mysqli_query
(
$link
,
"select option_value from cmf_options where option_name='configpri' "
);
$row
=
mysqli_fetch_assoc
(
$result
);
return
json_decode
(
$config
,
$row
[
'option_value'
]);
}
$xmlInfo
=
file_get_contents
(
"php://input"
);
$arrayInfo
=
xmlToArray
(
$xmlInfo
);
file_put_contents
(
'./logali.txt'
,
date
(
'y-m-d h:i:s'
)
.
' msg:'
.
' 返回参数:'
.
http_build_query
(
$xmlInfo
)
.
"
\r\n
"
,
FILE_APPEND
);
$link
=
mysqli_connect
(
"mysql"
,
"zhibo"
,
"Rni43v7RpkWUP9FD"
);
if
(
!
$link
)
{
file_put_contents
(
'./logali.txt'
,
date
(
'y-m-d h:i:s'
)
.
' msg:'
.
' 数据库连接失败:'
.
"
\r\n
"
,
FILE_APPEND
);
echo
$this
->
returnInfo
(
"FAIL"
,
"数据库连接失败"
);
die
;
}
mysqli_select_db
(
$link
,
'zhibo'
);
mysqli_query
(
$link
,
"set names utf8"
);
$config
=
getConfig
(
$link
);
var_dump
(
$config
);
die
;
if
(
$arrayInfo
[
'return_code'
]
==
"SUCCESS"
)
{
$wxSign
=
$arrayInfo
[
'sign'
];
unset
(
$arrayInfo
[
'sign'
]);
$arrayInfo
[
'appid'
]
=
$config
[
'wx_appid'
];
$arrayInfo
[
'mch_id'
]
=
$config
[
'wx_mchid'
];
$key
=
$config
[
'wx_key'
];
ksort
(
$arrayInfo
);
//按照字典排序参数数组
$sign
=
$this
->
sign
(
$arrayInfo
,
$key
);
//生成签名
$this
->
logwx
(
"数据打印测试签名signmy:"
.
$sign
.
":::微信sign:"
.
$wxSign
);
//log打印保存
if
(
$this
->
checkSign
(
$wxSign
,
$sign
))
{
echo
$this
->
returnInfo
(
"SUCCESS"
,
"OK"
);
$this
->
logwx
(
"签名验证结果成功:"
.
$sign
);
//log打印保存
$this
->
orderServer
();
//订单处理业务逻辑
exit
;
}
else
{
echo
$this
->
returnInfo
(
"FAIL"
,
"签名失败"
);
$this
->
logwx
(
"签名验证结果失败:本地加密:"
.
$sign
.
':::::三方加密'
.
$wxSign
);
//log打印保存
exit
;
}
}
else
{
echo
$this
->
returnInfo
(
"FAIL"
,
"签名失败"
);
$this
->
logwx
(
$arrayInfo
[
'return_code'
]);
//log打印保存
exit
;
}
if
(
$trade_status
==
'TRADE_SUCCESS'
)
{
//判断该笔订单是否在商户网站中已经做过处理
//如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
//如果有做过处理,不执行商户的业务程序
//注意:
//付款完成后,支付宝系统发送该交易状态通知
//请务必判断请求时的total_fee、seller_id与通知时获取的total_fee、seller_id为一致的
//调试用,写文本函数记录程序运行情况是否正常
//logResult("这里写入想要调试的代码变量值,或其他运行的结果记录");
$out_trade_no
=
$_POST
[
'out_trade_no'
];
//支付宝交易号
$trade_no
=
$_POST
[
'trade_no'
];
$link
=
mysqli_connect
(
"mysql"
,
"zhibo"
,
"Rni43v7RpkWUP9FD"
);
if
(
$link
)
{
mysqli_select_db
(
$link
,
'zhibo'
);
mysqli_query
(
$link
,
"set names utf8"
);
$result
=
mysqli_query
(
$link
,
"select * from cmf_users_charge where orderno='
$out_trade_no
' and status='0' and type='1'"
);
$row
=
mysqli_fetch_assoc
(
$result
);
if
(
$row
)
{
mysqli_query
(
$link
,
"update cmf_users set coin=coin+
{
$row
[
'coin'
]
}
where id='
$row[touid]
'"
);
mysqli_query
(
$link
,
"update cmf_users_charge set status='1',trade_no='
$trade_no
' where id=
{
$row
[
'id'
]
}
"
);
file_put_contents
(
'./logali.txt'
,
date
(
'y-m-d h:i:s'
)
.
' msg:'
.
"支付成功:
\r\n
"
,
FILE_APPEND
);
}
else
{
file_put_contents
(
'./logali.txt'
,
date
(
'y-m-d h:i:s'
)
.
' msg:'
.
"orderno:"
.
$out_trade_no
.
' 订单信息不存在'
.
"
\r\n
"
,
FILE_APPEND
);
}
}
echo
"success"
;
//请不要修改或删除
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
else
{
file_put_contents
(
'./logali.txt'
,
date
(
'y-m-d h:i:s'
)
.
' msg:'
.
' 验证失败:'
.
http_build_query
(
$_POST
)
.
"
\r\n
"
,
FILE_APPEND
);
//验证失败
echo
"fail"
;
//调试用,写文本函数记录程序运行情况是否正常
//logResult("这里写入想要调试的代码变量值,或其他运行的结果记录");
}
?>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment