Home > Mobile >  [with] the PHP to write the notify_url WeChat pay, don't know where is wrong, the great god, pl
[with] the PHP to write the notify_url WeChat pay, don't know where is wrong, the great god, pl

Time:12-22

WeChat browser pay with WeChat JSAPI,
In the previous step is complete, can pay successfully, and can query the merchant platform to orders,
In dealing with "payment result notification notify_url" this step out of the question,

I do a carefully according to the document, but found no normal operation (corresponding fields in the database is not modified), don't know what went wrong,
 & lt; ? PHP 
//$response to the XML format array
$receivexml=json_decode (json_encode (simplexml_load_string ($response, 'simplexmlelements, LIBXML_NOCDATA)), true);

//[a] little program ID
$appid_xml=$receivexml (" appid ");
/[b] bank_type
$bank_type_xml=$receivexml [" bank_type "];
[c]//cash amount
$cash_fee_xml=$receivexml [" cash_fee "];
//[I] is focus on public accounts
$is_subscribe_xml=$receivexml [" is_subscribe "];
//[m] merchants
$McH_id_xml=$receivexml [" McH_id "];
//[n] random string
$nonce_str_xml=$receivexml [" nonce_str "];
//sign (op)
$openid_xml=$receivexml [" openid "];
///ou merchant order number
$out_trade_no_xml=$receivexml (" out_trade_no ");
//[r] business results
$result_code_xml=$receivexml (" result_code ");
///ti pay complete time
$time_end_xml=$receivexml [" time_end "];
//[to] order amount
$total_fee_xml=$receivexml (" total_fee ");
///trad transaction type JSAPI, NATIVE, APP
$trade_type_xml=$receivexml [" trade_type "];
///tran WeChat payment order number
$transaction_id_xml=$receivexml [" transaction_id "];

//sign [s]
$sign_xml=$receivexml (" sign ");

$return_code_xml=$receivexml [" return_code "];
$result_code_xml=$receivexml (" result_code ");

//spell reception signature string
$stringA='appid=' $appid_xml. '& amp; Bank_type='. $bank_type_xml. '& amp; Cash_fee='. $cash_fee_xml. '& amp; Is_subscribe='. $is_subscribe_xml. '& amp; McH_id='. $McH_id_xml. '& amp; Nonce_str='. $nonce_str_xml. '& amp; Openid='. $openid_xml. '& amp; Out_trade_no='. $out_trade_no_xml. '& amp; Result_code='. $result_code_xml. '& amp; Time_end='. $time_end_xml. '& amp; Total_fee='. $total_fee_xml. '& amp; Trade_type='. $trade_type_xml. '& amp; Transaction_id='$transaction_id_xml;

//stitching key
$stringSignTemp=$stringA. '& amp; Key=* * * * * * ';
//string and MD5 encryption to uppercase
The $sign=strtoupper (md5 ($stringSignTemp));

//need to increase the judge here
If ($return_code_xml=="SUCCESS" and $result_code_xml=="SUCCESS" and "$sign==$sign_xml) {

//here to execute a stored procedure, modify database information, will pay order number WeChat transaction_id write database

Return "& lt; Xml>
";

?>


Tests, WeChat payment order number transaction_id did not write to the database,
  • Related