歡迎來到安信科技官方網(wǎng)站!【www.boomerlogic.com】
      18112005550
      工作時(shí)間: 8:30-21:30
      新聞中心
      News Center

      微信公眾號(hào)支付ASP源碼下載(接口文件)

      資訊分類: 資源共享  瀏覽: 2017年6月29日
      接口程序文件源碼:wxpay.asp
       
      本頁(yè)應(yīng)該包含該頁(yè)面http://www.boomerlogic.com/news/92.html的類文件:include file="weipay.class.asp"
      '   注意:本頁(yè)面必須是 UTF-8編碼
      '   本頁(yè)面為偽代碼,代碼不全,僅是為了演示用法
       
      set wechat = new WeChatPay()
       
      out_trade_no = request("trade_no")
       
      set rs.open "select * from order_list where o_status='未支付' and o_tradeno='" & out_trade_no & "'", conn, 3, 2
       
      '創(chuàng)建支付
      if request("action") = "ajax" then
          '創(chuàng)建訂單
       
          if rs.eof then
              result = wechat.Pay("訂單號(hào)", "產(chǎn)品名", "不需要傳值,此值暫時(shí)無用,為了與支付寶保持兼容", "支付金額,單位元")
              if left(result, 15) = "weixin://wxpay/" then
                 '支付成功,返回 支付鏈接,通過前臺(tái) ajax 返回到前臺(tái),通過 jQuery.qrcode 插件二維碼
                   response.write "{""status"":true, ""payUrl"":""" & result & """}"
              else
                  '支付失敗,返回錯(cuò)誤信息
                  response.write "{""status"":false, ""errMsg"":""" & result & """}"
              end if
          else
              response.write "{""status"":false, ""errMsg"":""已經(jīng)處理完畢""}"
          end if
      else request("action") = "check" then
          '檢查支付狀態(tài),【微信支付后臺(tái)通知(異步)】設(shè)為 完成后,返回成功
           
          '如果 當(dāng)前訂單不是 未支付狀態(tài)了,說明已經(jīng)支付
          if rs.eof then
              response.write "{""status"":true}""
          else
              response.write "{""status"":false}""
          end if
      else
           
          '微信支付后臺(tái)通知(異步)
          set result = wechat.GetNotify()
          if result.item("status") = false then
              '校驗(yàn)失敗
              response.write result.item("message")
          else
              '校驗(yàn)成功,修改o_status為已支付
              if not rs.eof then
                  rs("wx_tradeno") = trade_no
                  rs("o_paytme") = now()
                  rs("o_status") = "已支付"
                  rs.update
              end if
              response.write "<return_code>SUCCESS</return_code><return_msg>OK</return_msg>"
          end if
       
      end if
       
      3.Ajax前臺(tái)創(chuàng)建支付請(qǐng)求和刷新訂單狀態(tài)的方法
      $(function(){
          $.ajax({
              url : "/wxapi.asp?action=ajax&trade_no=<% =trade_no %>",
              dataType : "json",
              type : "GET",
              success : function(result){
                  if( result.status != true ){
                      alert(result.errMsg);
                  }else{
                      jQuery('#qrcodeCanvas').html("").qrcode({
                          text : result.payUrl
                      });
                      setTimeout(function(){
                          jQuery('#qrcodeImage img').attr("src", $("#qrcodeCanvas canvas")[0].toDataURL("image/png"));
                      }, 100);
                      setInterval(function(){
                          $.ajax({
                              url : "/wxapi.asp?action=check&trade_no=<% =trade_no %>",
                              dataType : "json",
                              success : function(result){
                                  if( result.status === false ){
                                      alert("支付成功");
                                      location.href = "?action=info&trade_no=<% =trade_no %>";
                                  }
                              }
                          });
                      }, 5000);
                  }
              }
          });
      })
      Copyright © 2007-2022 安信科技(十五周年紀(jì)念版) All Rights Reserved  備案號(hào):蘇ICP備15047094號(hào)-3 
      網(wǎng)站首頁(yè) |  新聞資訊 |  服務(wù)項(xiàng)目 |  軟件產(chǎn)品 |  試用下載 |  需求提交 |  模版建站 |  關(guān)于安信 |  產(chǎn)品授權(quán) |  聯(lián)系我們 |  定制開發(fā) | 
      服務(wù)熱線:181-1200-5550  客服QQ: 120094883  | 郵箱:120094883#qq.com(#改@)