PHP Example Tutorial PC-side WeChat scan code to automatically jump after the successful payment

Source: Internet
Author: User
Tags php example
This article is mainly for everyone in detail the scan code after the success of the automatic jump PHP version of the code, with a certain reference value, interested in small partners can refer to

This example for everyone to share the PHP scan code after the success of the automatic jump code, for your reference, the specific content as follows

Scenario: PC-side sweep code payment

Result: The payment succeeds automatically jump

Implementation ideas:

Pay the QR code page, write the AJAX request payment status, request to the result, regardless of success or failure, jump to the corresponding results page

Specific implementation methods:

HTML section:

Payment result status setting: 0 Unpaid 1 Payment Success 2 payment failure


<input type= "hidden" id= "order_id" value= "<?php echo $order _id;?   > "><script type=" Text/javascript ">function pay_status () {var order_id = $ (" #order_id "). Val ();      $.ajax ({url: '/http ' + ' + window.location.host+ '/home/cart/pay_status_check ', DataType: ' JSON ', type: ' Post ', data:{' order_id ': order_id}, Success:function (data) {if (data = = ' 1 ') {window.clearinterval (int);//Destroy  Timer setTimeout (function () {//jumps to the results page and passes the status window.location.href= "/http" rel= "external nofollow"        Rel= "External nofollow" +window.location.host+ "/home/cart/pay_result?pay_status=success";          },1000)}else if (data = = ' 2 ') {window.clearinterval (int);//Destroy Timer setTimeout (function () { Jump to the results page and pass the Status window.location.href= "/http" rel= "external nofollow" rel= "External nofollow" +window.location        . host+ "/home/cart/pay_result?pay_status=fail"; },1000)}}, Error:function () {alert ("Error"); },   });} Start timer var int=self.setinterval (function () {pay_status ()},1000);</script>

PHP section:


Payment status Detection public  function Pay_status_check () {    $order _id = I ("order_id");    $result = M (' table ')->where ("order_id = $order _id")->find ();    echo $result [' pay_status '];  }

Basic functions on these, if you want to look good, you can add some style, such as: Pay success, plus a check the animation!

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.