search
HomeWeChat AppletWeChat DevelopmentWeChat payment development alarm notification

This article introduces how to obtain alarm notifications in WeChat payment.

1. Alarm notification

In order to promptly notify merchants of abnormalities and improve merchants’ service quality on the WeChat platform. The WeChat backend will push alarm notifications to merchants, including delivery delays, call failures, notification failures, etc. The notification address is the alarm notification URL filled in by the merchant when applying for payment, which can be found in "Public Platform - Service - Service Center - Merchant Functions - Merchant Basic Information - Alarm Notification URL" can be viewed. After receiving the alarm notification, merchants need to repair the problems mentioned in it as soon as possible to avoid affecting online operations.

The postData received by the alarm notification URL will also contain xml data in the following format:

<xml>
    <AppId><![CDATA[wxf8b4f85f3a794e77]]></AppId>
    <ErrorType>1001</ErrorType>
    <Description><![CDATA[错识描述]]></Description>
    <AlarmContent><![CDATA[错误详情]]></AlarmContent>
    <TimeStamp>1393860740</TimeStamp>
    <AppSignature><![CDATA[f8164781a303f4d5a944a2dfc68411a8c7e4fbea]]></AppSignature>
    <SignMethod><![CDATA[sha1]]></SignMethod>
</xml>

2. Program reception

Developed in WeChat payment (1) WeChat payment URL configuration As mentioned in, the alarm notification url is set to

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

Now is the alarm.php function has been implemented, just imitate the WeChat basic interface SDK to obtain it. Write detailed information to the database or other storage

$postStr = $GLOBALS["HTTP_RAW_POST_DATA"];
$postObj = simplexml_load_string($postStr, &#39;SimpleXMLElement&#39;, LIBXML_NOCDATA);
logger("错误类型:".$postObj->ErrorType."错识描述:".$postObj->Description."错误详情:".$postObj->AlarmContent);

//日志记录
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(&#39;H:i:s&#39;)." ".$log_content."\r\n", FILE_APPEND);
}

For more WeChat payment development and alarm notification related articles, please pay attention to the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools