username@email.com
2022-01-21 b18a7c8e54b51a5caa400e55cb8cc428c0301a0c
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
using System;
using System.Text;
using System.Web;
using System.Web.UI;
 
namespace JumbotCms.API.Tenpay
{
    /// <summary>
    /// PayRequestHandler µÄժҪ˵Ã÷¡£
    /// </summary>
    /**
    * ¼´Ê±µ½ÕÊÇëÇóÀà
    * ============================================================================
    * api˵Ã÷£º
    * init(),³õʼ»¯º¯Êý£¬Ä¬ÈϸøÒ»Ð©²ÎÊý¸³Öµ£¬Èçcmdno,dateµÈ¡£
    * getGateURL()/setGateURL(),»ñÈ¡/ÉèÖÃÈë¿ÚµØÖ·,²»°üº¬²ÎÊýÖµ
    * getKey()/setKey(),»ñÈ¡/ÉèÖÃÃÜÔ¿
    * getParameter()/setParameter(),»ñÈ¡/ÉèÖòÎÊýÖµ
    * getAllParameters(),»ñÈ¡ËùÓвÎÊý
    * getRequestURL(),»ñÈ¡´ø²ÎÊýµÄÇëÇóURL
    * doSend(),ÖØ¶¨Ïòµ½²Æ¸¶Í¨Ö§¸¶
    * getDebugInfo(),»ñÈ¡debugÐÅÏ¢
    * 
    * ============================================================================
    *
    */
    public class PayRequestHandler:RequestHandler
    {
        public PayRequestHandler(HttpContext httpContext) : base(httpContext)
        {
            
            this.setGateUrl("https://www.tenpay.com/cgi-bin/v1.0/pay_gate.cgi");
        }
        public string YinHang { get; set; }
 
        /**
            * @Override
            * ³õʼ»¯º¯Êý£¬Ä¬ÈϸøÒ»Ð©²ÎÊý¸³Öµ£¬Èçcmdno,dateµÈ¡£
        */
        public override void init() 
        {
 
            //ÈÎÎñ´úÂë
            this.setParameter("cmdno", "1");
        
            //ÈÕÆÚ
            this.setParameter("date",DateTime.Now.ToString("yyyyMMdd"));
        
            //ÉÌ»§ºÅ
            this.setParameter("bargainor_id", "");
        
            //²Æ¸¶Í¨½»Ò×µ¥ºÅ
            this.setParameter("transaction_id", "");
        
            //É̼Ҷ©µ¥ºÅ
            this.setParameter("sp_billno", "");
        
            //ÉÌÆ·¼Û¸ñ£¬ÒÔ·ÖΪµ¥Î»
            this.setParameter("total_fee", "");
        
            //»õ±ÒÀàÐÍ
            this.setParameter("fee_type",  "1");
        
            //·µ»Øurl
            this.setParameter("return_url",  "");
        
            //×Ô¶¨Òå²ÎÊý
            this.setParameter("attach",  "");
        
            //Óû§ip
            this.setParameter("spbill_create_ip",  "");
        
            //ÉÌÆ·Ãû³Æ
            this.setParameter("desc",  "");
 
            //ÒøÐбàÂë
            YinHang = string.IsNullOrEmpty(YinHang) ? "0" : YinHang;
            this.setParameter("bank_type", YinHang);
        
            //×Ö·û¼¯±àÂë
            this.setParameter("cs","utf-8");
        
            //ÕªÒª
            this.setParameter("sign", "");
        }
 
 
 
        /**
     * @Override
     * ´´½¨Ç©Ãû
     */
        protected override void createSign() 
        {
        
            //»ñÈ¡²ÎÊý
            string cmdno = getParameter("cmdno");
            string date = getParameter("date");
            string bargainor_id = getParameter("bargainor_id");
            string transaction_id = getParameter("transaction_id");
            string sp_billno = getParameter("sp_billno");
            string total_fee = getParameter("total_fee");
            string fee_type = getParameter("fee_type");
            string return_url = getParameter("return_url");
            string attach = getParameter("attach");
            string spbill_create_ip = getParameter("spbill_create_ip");
            string key = getParameter("key");
        
            //×é֯ǩÃû
            StringBuilder sb = new StringBuilder();
            sb.Append("cmdno=" + cmdno + "&");
            sb.Append("date=" + date + "&");
            sb.Append("bargainor_id=" + bargainor_id + "&");
            sb.Append("transaction_id=" + transaction_id + "&");
            sb.Append("sp_billno=" + sp_billno + "&");
            sb.Append("total_fee=" + total_fee + "&");
            sb.Append("fee_type=" + fee_type + "&");
            sb.Append("return_url=" + return_url + "&");
            sb.Append("attach=" + attach + "&");
            if( !"".Equals(spbill_create_ip) ) 
            {
                sb.Append("spbill_create_ip=" + spbill_create_ip + "&");
            }
            sb.Append("key=" + getKey());
        
            //Ëã³öÕªÒª
            string sign = MD5Util.GetMD5(sb.ToString(),getCharset());
                
            setParameter("sign", sign);
    
            //debugÐÅÏ¢
            setDebugInfo(sb.ToString() + " => sign:"  + sign);
        
        }
 
    }
}