wlzboy
2025-07-09 ab0742bf945b5de8554761de6fa4ecda29f640e0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<% @LANGUAGE="VBSCRIPT" CODEPAGE="65001" %> 
<% Session.CodePage=65001 %> 
<% Response.charset = "utf-8" %>
<!--#include virtual="/inc/odbc.asp"-->
<!--#include virtual="/inc/function.asp"-->
<!--#include virtual="/inc/core.asp"-->
<%
Set rs = Server.CreateObject("ADODB.Recordset")
order_pay_weixin= SafeRequest(trim(request("order_pay_weixin")))
code=request("code")
state=request("state")
OpenID            = SafeRequest(trim(request("OpenID")))
DispatchOrdID    = SafeRequest(trim(request("DispatchOrdID")))
ServiceOrdID    = SafeRequest(trim(request("ServiceOrdID")))
Total_fee        = SafeRequest(trim(request("Total_fee")))
attach            = SafeRequest(trim(request("attach")))
If state="" Then state=session("state")
session("state")=state
 
If code<>"" And Right(state,1)="N" Then
    OpenID=GetOpenID(code)
    stateSP=SPLIT(state,"|")
    ServiceOrdID=stateSP(0)
    DispatchOrdID=stateSP(1)
    Total_fee=stateSP(2)
 
ElseIf order_pay_weixin="1" Then
    'Request.ServerVariables("QUERY_STRING")
    If Request.ServerVariables("QUERY_STRING")<>"" then
      redirect_uri="http://"&Request.ServerVariables("HTTP_HOST")&Request.ServerVariables("URL")&"?"&Request.ServerVariables("QUERY_STRING")
    Else
      redirect_uri="http://"&Request.ServerVariables("HTTP_HOST")&Request.ServerVariables("URL")
    End If
    state=ServiceOrdID&"|"&DispatchOrdID&"|"&Total_fee
    Call GetCode(state)
    'Response.Redirect "https://open.weixin.qq.com/connect/qrconnect?appid="&corpid&"&redirect_uri="&redirect_uri&"&response_type=code&scope=SCOPE&state="&state&"#wechat_redirect"
    'Response.end
End If
 
APPPayID    = "Pay966120"
If OpenID<>"" Then 
    trade_type="JSAPI"
Else
    trade_type="MWEB"
End If
If ServiceOrdID<>"" Then
    order_no=ServiceOrdID
Else
    order_no=DispatchOrdID
End If
spbill_create_ip=getip()
args1="order_no="&order_no            '订单编号
args1=args1&"&APPID="&APPPayID            '商户APPID
args1=args1&"&openid="&openid        'openid
args1=args1&"&Total_fee="&Total_fee        '支付金额
args1=args1&"&trade_type="&trade_type    '支付类型
args1=args1&"&spbill_create_ip="&spbill_create_ip    '客户IP
args1=args1&"&attach="&attach    '附加数据
'args1=args1&"&UnixTime="&ToUnixTime(now(),+8)            '时间戳
Sign1=SignArgs(args1)
HTMLCODE = GetBody("https://api.966120.com.cn/v3/weixin/weixin_pay.asp",args1&"&Sign="&Sign1)
Response.Write HTMLCODE&"<br>"
'Response.end
json=HTMLCODE
%>
<script language="jscript" runat="server">
Array.prototype.get = function(i)
{
 return this[i]; 
};
function getjson(str){
 try{
  eval("var jsonStr = (" + str + ")");
 }catch(ex){
  var jsonStr = null;
 }
 return jsonStr;
}
</script>
<%
        str=json
        str=right(str,len(str)-instr(str,"?{")+1)
        str=left(str,InstrRev(str,"}"))
        dim obj
        set obj = getjson(str)
        str0=""
        result    = obj.result    '    处理结果:1-成功,2-失败
        If result<>1 Then Response.Redirect "/OrdEvaluateError.asp?1=2"
        prepay_id=obj.prepay_id        'prepay_id
        mch_key=obj.mch_key        'prepay_id
 
        If trade_type="MWEB" Then
            mweb_url=obj.mweb_url    'mweb_url
            Response.Redirect mweb_url
        ElseIf trade_type="JSAPI" Then
        '时间戳  
        time_stamp = DateDiff("s", "1970-1-1 00:00:00", Now())  
 
        rdCode = Int((32767)*Rnd +1000)  
        nonce_str = MD5(rdCode,"utf-8")
 
        'JS API签名
        stringA = "appId="&appid &"&nonceStr="&nonce_str&"&package=prepay_id="&prepay_id&"&signType=MD5&timeStamp="&time_stamp
        stringSignTemp = stringA & "&key=" & mch_key  
        'Response.Write stringSignTemp
'Response.end
        sign = UCase(MD5(stringSignTemp,"utf-8")) 
            %>
            <%If prepay_id<>"" then%>
            <script type="text/javascript">
            //调用微信JS api 支付
                function jsApiCall()
                {
                    WeixinJSBridge.invoke(
                        'getBrandWCPayRequest',
                        {
                       "appId":"<%=appid%>",     //公众号名称,由商户传入     
                       "timeStamp":"<%=time_stamp%>",         //时间戳,自1970年以来的秒数     
                       "nonceStr":"<%=nonce_str%>", //随机串     
                       "package":"prepay_id=<%=prepay_id%>",     
                       "signType":"MD5",         //微信签名方式
                       "paySign":"<%=sign%>" //微信签名 
                       },
                        function(res){
                            if(res.err_msg == "get_brand_wcpay_request:ok" ) {alert("支付完成");window.location.href="/pay/alipay_payOK.php"}
                            //WeixinJSBridge.log(res.err_msg);
                            //alert("返回订单");
                            //window.location.href="/my/order_detail.asp?OrderID="+<%=ShopOrdID%>
                        }
                    );
                }
 
                function callpay()
                {
                    if (typeof WeixinJSBridge == "undefined"){
                        if( document.addEventListener ){
                            document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
                        }else if (document.attachEvent){
                            document.attachEvent('WeixinJSBridgeReady', jsApiCall); 
                            document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
                        }
                    }else{
                        jsApiCall();
                    }
                }
            callpay()
            </script>
        <%else%>
        1
        <%End If%>
 
            <%
 
        Else
            Response.Redirect "/OrdEvaluateError.asp?1=3"
        End If
'Response.Write mweb_url
 
%>