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!