Micro-credit payment development transaction Notification Instance _php instance

Source: Internet
Author: User
Tags cdata openid

I. NOTICE OF transaction

After the user completes the payment successfully, the micro-credit background notification (POST) merchant Server (Notify_url) pays the result. The merchant can use the Notify_url notice result to carry on the personalized page display.

When you interact with a background notification, if the micro-letter received the merchant's answer is not success or timeout, the micro-letter is not a notification failure, the micro-trust through a certain strategy (such as 30 minutes a total of 8 times) to restart the notice, as far as possible to increase the success rate of notification, but the micro-letter does not guarantee

Background notification through the request in the Notify_url, using the POST mechanism.

Also, XML data will be included in PostData.

Ii. acquisition and response of transaction results

According to the official documentation, create notice.php to inform the results.

The program contents are as follows:

<?php

foreach ($_get as $key => $value) 
{
 logger ("key: $key; Value: $value ");
}
$POSTSTR = $GLOBALS ["Http_raw_post_data"];
Logger ($POSTSTR);

if (Isset ($_get)) {
 echo "success";
}

Log record
function logger ($log _content)
{
 $max _size = 100000;
 $log _filename = "Log.xml";
 if (file_exists ($log _filename) and (ABS (FileSize ($log _filename)) > $max _size)) {unlink ($log _filename);}
 File_put_contents ($log _filename, date (' H:i:s '). " ". $log _content." \ r \ n ", file_append);
}
? >

The functions of the above procedures are:

Gets the notification of post to URL, they are in the form of a Get variable

Get the XML packet for the post

Return success Message Success

Place the full path of notice.php into the notice URL of the JS API payment.

$wxPayHelper->setparameter ("Notify_url", http://www.doucube.com/wxpay/notice.php);

So when the transaction is complete, the URL will be notified and recorded in the log file, and our tests are as follows:

The get variable and XML obtained by

are as follows:

Key:bank_billno; value:201405273540085997 Key:bank_type; value:2011 Key:discount; Value:0 Key:fee_type; Value:1 Key:input_charset; VALUE:GBK key:notify_id; Value:gx8ov6tt6_yaarrtkg6rfz4kivtkqvnjzvulfltej3dhbg38irtks0ptxxfgh8wnh15mihg6j65ggbzzyguh1mutg3b5ohsk Key:out_ Trade_no; VALUE:JFUKDIBIG4ZZNE4N Key:partner; value:1234567890 Key:product_fee; Value:1 key:sign; value:08876c4a9f7a36a9ea972c211c122362 Key:sign_type; VALUE:MD5 Key:time_end; value:20140527194139 Key:total_fee; Value:1 Key:trade_mode; Value:1 key:trade_state; Value:0 key:transaction_id; value:1218614901201405273313473135 Key:transport_fee; value:0 <xml><openid><! [cdata[o0pk9uivnly-fjkzfkebq6lj4cfc]]></openid> <appid><! [cdata[wx0000000000000000]]></appid> <IsSubscribe>1</IsSubscribe> <TimeStamp> 1401190899</timestamp> <noncestr><! [cdata[iob2flj0ilfambqj]]></noncestr> <appsignature><! [cdata[66678894Aae680ba140e18e66d1295dfadabd9ab]]></appsignature> <signmethod><! [cdata[sha1]]></signmethod> </xml>

And in the micro-letter window will receive a OK pop-up window

The above is to micro-letter payment development Trading notice of the data collation, thank you for your support!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.