欢迎来到安信科技官方网站!【www.anxin66.com】
18112005550
工作时间: 8:30-21:30
新闻中心
News Center

微信公众号支付ASP源码下载(接口文件)

资讯分类: 资源共享  浏览: 2017年6月29日
接口程序文件源码:wxpay.asp
 
本页应该包含该页面http://www.anxin66.com/news/92.html的类文件:include file="weipay.class.asp"
'   注意:本页面必须是 UTF-8编码
'   本页面为伪代码,代码不全,仅是为了演示用法
 
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
 
'创建支付
if request("action") = "ajax" then
    '创建订单
 
    if rs.eof then
        result = wechat.Pay("订单号", "产品名", "不需要传值,此值暂时无用,为了与支付宝保持兼容", "支付金额,单位元")
        if left(result, 15) = "weixin://wxpay/" then
           '支付成功,返回 支付链接,通过前台 ajax 返回到前台,通过 jQuery.qrcode 插件二维码
             response.write "{""status"":true, ""payUrl"":""" & result & """}"
        else
            '支付失败,返回错误信息
            response.write "{""status"":false, ""errMsg"":""" & result & """}"
        end if
    else
        response.write "{""status"":false, ""errMsg"":""已经处理完毕""}"
    end if
else request("action") = "check" then
    '检查支付状态,【微信支付后台通知(异步)】设为 完成后,返回成功
     
    '如果 当前订单不是 未支付状态了,说明已经支付
    if rs.eof then
        response.write "{""status"":true}""
    else
        response.write "{""status"":false}""
    end if
else
     
    '微信支付后台通知(异步)
    set result = wechat.GetNotify()
    if result.item("status") = false then
        '校验失败
        response.write result.item("message")
    else
        '校验成功,修改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前台创建支付请求和刷新订单状态的方法
$(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 安信科技(十五周年纪念版) All Rights Reserved  备案号:苏ICP备15047094号-3 
网站首页 |  新闻资讯 |  服务项目 |  软件产品 |  试用下载 |  需求提交 |  模版建站 |  关于安信 |  产品授权 |  联系我们 |  定制开发 | 
服务热线:181-1200-5550  客服QQ: 120094883  | 邮箱:120094883#qq.com(#改@)