This article brings you the content is about PHP server app payment callback verification signature Change Order payment status, there is a certain reference value, the need for friends can refer to, I hope to help you.
<?php//Processing Payment Callback $time = time (); $testxml = file_get_contents ("Php://input"); Receive payment success information sent by//file_put_contents (' D:\webroot\xianyijie\JK\weixin.txt ', $testxml); $result = Xmldataparse ($testxml); File_put_contents ("D:\webroot\xianyijie\JK\weixin.txt", Json_encode ($result). " \ r \ n ", file_append); Write information to TXT file for payment backup $sign _return = $result [' sign ']; If successfully returned if ($result [' return_code '] = = ' SUCCESS ' && $result [' result_code '] = = ' SUCCESS ') { $key = "Merchant Key key"; unset ($result [' sign ']); $sign = Appgetsign ($result, $key); if ($sign = = $sign _return)//Verify signature {//This is the SQL operation after successful verification//If the operation is successful return "<xml><return_code><! [cdata[success]]></return_code> <return_msg><! [cdata[ok]]></return_msg> </xml> "; If the operation fails, return "fail"; } }/* * format parameter formatted as URL parameter generate signature sign*/function appgetsign ($OBJ, $appwxpay _key) {foreach ($Obj as $k + $v) { $Parameters [$k] = $v; }//Signature step one: sorted by dictionary order parameter Ksort ($Parameters); $String = Formatbizqueryparamap ($Parameters, false); Echo ' "string1" '. $String. ' </br> '; Signature Step Two: Add key if ($appwxpay _key) {$String = $String after the String. &key= ". $appwxpay _key; }//echo "" string2 "". $String. " </br> "; Signature Step Three: MD5 encryption $String = MD5 ($String); echo "String3" ". $String." </br> "; Signature Step four: All characters to uppercase $result _ = Strtoupper ($String); echo "Result". $result _. " </br> "; return $result _; }//xml Format Data parsing functions function Xmldataparse ($data) {$xml = Simplexml_load_string ($data, null,libxml_nocdata); $array =json_decode (Json_encode ($xml), true); return $array; }?>
Related articles recommended:
PHP's curl in the post mode and get way request code
About PHP Intermediate key content parsing