Micro-credit payment development Alarm Notification Instance _php instance

Source: Internet
Author: User
Tags cdata

First, Alarm notification

In order to inform merchant abnormal, improve the service quality of the micro-trust platform. Micro-letter background will be pushed to the merchant alarm notice, including delivery delay, call failure, notification failure, etc., the address of the notice is the merchant in the application for payment when the alarm notification URL, in the "Public platform-service-service center-merchant Function-Merchant basic information-alarm notification URL" can be viewed. When the merchant receives the warning notice, it needs to fix the problems mentioned in it as soon as possible so as not to affect the online operation.

The alert notification URL receives a postdata containing XML data in the following format:

<xml>
  <appid><![ cdata[wxf8b4f85f3a794e77]]></appid>
  <ErrorType>1001</ErrorType>
  <description ><! [cdata[false Description]]></description>
  <alarmcontent><![ cdata[Error Details]]></alarmcontent>
  <TimeStamp>1393860740</TimeStamp>
  <appsignature ><! [cdata[f8164781a303f4d5a944a2dfc68411a8c7e4fbea]]></appsignature>
  <signmethod><![ Cdata[sha1]]></signmethod>
</xml>

Second, the procedure receives

In the micro-credit payment development (1) micro-letter Payment URL configuration has been mentioned, set the alarm notification URL for

http://www.doucube.com/wxpay/alarm.php

Now is the implementation of the alarm.php function, modeled after the micro-letter Basic Interface SDK access. Write details to a database or other storage

$POSTSTR = $GLOBALS ["Http_raw_post_data"];
$POSTOBJ = simplexml_load_string ($postStr, ' simplexmlelement ', libxml_nocdata);
Logger ("Error type:". $POSTOBJ->errortype. " Wrong description: ". $POSTOBJ->description." Error details: ". $POSTOBJ->alarmcontent);

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 above is to micro-letter payment development alarm Notification data collation, micro-credit payment development friends can refer to, thank you support!

Related Article

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.