Wemall App Store source Android Universal Notification Interface Demo

Source: Internet
Author: User

Wemall-mobile is based on the Wemall Android App Store, only need to upload the interface file in the original mall directory to complete the server configuration, the client can be customized modification. This article shares native (native) payment mode a demo for technician reference study.

Wemall website Address: http://www.wemallshop.com

After payment is completed, the relevant payment and user information will be sent to the notification URL set by the merchant, after the merchant receives the callback information, set up the corresponding processing process according to the need. Here is an example of logging callback information using the log file.

notify_url.php

<?phpinclude_once ("./log_.php"); Include_once ('.. /..    /config.php '); Use the generic notification interface $notify = new Notify_pub (),//Store callback $xml = $GLOBALS [' Http_raw_post_data ']; $notify->savedata ($xml);//Verify Signature , and responded. In the background notification interaction, if the receipt of the merchant's response is not a success or timeout, the notification failed,//will be a certain policy (such as 30 minutes a total of 8 times) periodically re-initiate the notification,//To maximize the success of the notification, but do not guarantee that the notification will eventually succeed. if ($notify->checksign () = = FALSE) {$notify->setreturnparameter ("Return_code", "FAIL");//Return Status code $notify-> Setreturnparameter ("Return_msg", "Signature failed");//return information}else{$notify->setreturnparameter ("Return_code", "SUCCESS");// Set return code} $RETURNXML = $notify->returnxml (); Echo $returnXml;//== Merchant Sets the appropriate processing flow according to the actual situation, here only for example =======//log callback information as a log file $ Log_ = new Log_ (); $log _name= "./notify_url.log";//log file path $log_->log_result ($log _name, "" Notify notification Received: \ n ". $xml." \ n "), if ($notify->checksign () = = TRUE) {if ($notify->data[" return_code "] = =" FAIL ") {///here should update order status, Merchant's own additions and deletions $log _->log_result ($log _name, "Communication error: \ n". $xml. " \ n ");} ElseIf ($notify->data["result_code"] = = "FAIL") {//Here should update the status of the order, Merchant's own additions and deletions Operation $log_->log_result ($log _name, "" BusinessError ': \ n '. $xml. " \ n ");} else{//here should update the status of the order, the merchant to delete the operation $log_->log_result ($log _name, "" Payment success: \ n ". $xml." \ n ");} Merchants to increase the processing process,//For example: Update order status//For example: Database Operations//For example: Push payment completion information $xml = $notify->xmltoarray ($xml);//Merchant order Number $out_trade_no = $xml [' Out_trade_no ']; $total _fee = $xml [' Total_fee ']; $uid = $xml [' OpenID ']; $log _->log_result ($log _name, "" Order number: \ n ". $out _trade_no. " \ n ");//Determine if the order has been processed in the merchant's website//If it has not been processed, according to the order number (OUT_TRADE_NO) in the Merchant website's order system to find out the details of the order, and to carry out the merchant's business procedures//If there has been processed, do not execute the merchant's business procedures if (! empty ($out _trade_no)) {$sql = "Update". Db_prefix. "Order set Pay_status=1 where orderid= '". $out _trade_no.            "‘"; mysql_query ($sql, $conn);}}? >

  

log_.php

<?phpclass log_{//Print logfunction  log_result ($file, $word) {    $fp = fopen ($file, "a");    Flock ($FP, lock_ex);    Fwrite ($fp, "Execution Date:". Strftime ("%y-%m-%d-%h:%m:%s", Time ()). " \ n ". $word." \ n ");    Flock ($FP, lock_un);    Fclose ($FP);}? >

  

config.php

<?phpheader (' content-type:text/html; Charset=utf-8 '); error_reporting (E_all & ~e_notice);d efine (' DB_HOST ', ' localhost ');d efine (' Db_user ', ' root ');d efine (' db_pwd ', ' root ');d efine (' db_name ', ' open ');d efine (' Db_prefix ', ' Wemall_ '); $conn = @mysql_connect (Db_host, Db_user, db_pwd) or Die (' Database link failed: '. mysql_error ()); @mysql_select_db (db_name ) or Die (' Database error: '. mysql_error ()); @mysql_query (' Set NAMES UTF8 ') or Die (' CharSet error: '. mysql_error ());? >

  

Wemall-Open Source Micro-Mall Mall Mall Source Distribution Mall B2B2C Mall system

Wemall website Address: http://www.wemallshop.com

Wemall App Store source Android Universal Notification Interface Demo

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.