Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
xiaozhan
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
冷斌
xiaozhan
Commits
e43b8728
Commit
e43b8728
authored
May 06, 2020
by
冷斌
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
5f943871
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
97 additions
and
0 deletions
+97
-0
wxpay/notify_url.php
+97
-0
No files found.
wxpay/notify_url.php
0 → 100644
View file @
e43b8728
<?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
)
{
$result
=
mysqli_query
(
$link
,
"select option_value from cmf_options where option_name='configpri' "
);
$row
=
mysqli_fetch_assoc
(
$result
);
return
json_decode
(
$row
[
'option_value'
],
true
);
}
function
sign
(
$param
,
$key
)
{
$sign
=
""
;
foreach
(
$param
as
$k
=>
$v
)
{
$sign
.=
$k
.
"="
.
$v
.
"&"
;
}
$sign
.=
"key="
.
$key
;
$sign
=
strtoupper
(
md5
(
$sign
));
return
$sign
;
}
function
checkSign
(
$sign1
,
$sign2
)
{
return
trim
(
$sign1
)
==
trim
(
$sign2
);
}
$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
);
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
=
sign
(
$arrayInfo
,
$key
);
//生成签名
file_put_contents
(
'./logali.txt'
,
date
(
'y-m-d h:i:s'
)
.
' msg:'
.
' 数据打印测试签名signmy:'
.
$sign
.
":::微信sign:"
.
$wxSign
.
"
\r\n
"
,
FILE_APPEND
);
if
(
checkSign
(
$wxSign
,
$sign
))
{
echo
returnInfo
(
"SUCCESS"
,
"OK"
);
file_put_contents
(
'./logali.txt'
,
date
(
'y-m-d h:i:s'
)
.
' msg:'
.
' 签名验证结果成功:'
.
$sign
.
"
\r\n
"
,
FILE_APPEND
);
$out_trade_no
=
$arrayInfo
[
'out_trade_no'
];
$trade_no
=
$arrayInfo
[
'transaction_id'
];
$result
=
mysqli_query
(
$link
,
"select * from cmf_users_charge where orderno='
$out_trade_no
' and status='0' and type='2'"
);
$row
=
mysqli_fetch_assoc
(
$result
);
if
(
$row
)
{
$coin
=
$row
[
'coin'
]
+
$row
[
'coin_give'
];
mysqli_query
(
$link
,
"update cmf_users set coin=coin+
{
$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
);
}
exit
;
}
else
{
echo
returnInfo
(
"FAIL"
,
"签名失败"
);
file_put_contents
(
'./logali.txt'
,
date
(
'y-m-d h:i:s'
)
.
' msg:'
.
' 签名失败:'
.
"
\r\n
"
,
FILE_APPEND
);
exit
;
}
}
else
{
echo
returnInfo
(
"FAIL"
,
"签名失败"
);
if
(
empty
(
$arrayInfo
[
'return_code'
]))
{
$arrayInfo
[
'return_code'
]
=
'000000'
;
}
file_put_contents
(
'./logali.txt'
,
date
(
'y-m-d h:i:s'
)
.
' msg:'
.
$arrayInfo
[
'return_code'
]
.
"
\r\n
"
,
FILE_APPEND
);
exit
;
}
?>
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