网银在线支付接口类

using  System;
using  System.Data;
using  System.Configuration;
using  System.Web;
using  System.Web.Security;
using  System.Web.UI;
using  System.Web.UI.WebControls;
using  System.Web.UI.WebControls.WebParts;
using  System.Web.UI.HtmlControls;

namespace  Pay
{
    
///  <summary>
    
///  网银在线支付
    
///  </summary>
     public  class  ChinaBank
    {
        
// 必要的交易信息
          private  string  _v_amount;
        
private  string  _v_moneytype  =  " CNY " ;
        
private  string  _v_md5info;
        
private  string  _v_mid;
        
private  string  _v_url  =  " /Receive.aspx " ;
        
private  string  _v_oid;
        
private  string  _v_key;
        
private  ReceiveStruct _Receive;
        
private  OrderStruct _Order;
        
private  ReMarkStruct _ReMark;

        
#region  收货信息结构

        
///  <summary>
        
///  收货信息结构
        
///  </summary>
         public  struct  ReceiveStruct
        {
           
public  string  v_rcvname;                                                             //  收货人
             public  string  v_rcvaddr;                                                             //  收货地址
             public  string  v_rcvtel;                                                              //  收货人电话
             public  string  v_rcvpost;                                                             //  收货人邮编
             public  string  v_rcvemail;                                                            //  收货人邮件
             public  string  v_rcvmobile;                                                           //  收货人手机号
             public  string [] v_rcv
            {
                
get
                {
                    
return  new  string []
                    { 
                        
" v_rcvname= " + v_rcvname,
                        
" v_rcvaddr= " + v_rcvaddr,
                        
" v_rcvtel= " + v_rcvtel,
                        
" v_rcvpost= " + v_rcvpost,
                        
" v_rcvemail= " + v_rcvemail,
                        
" v_rcvmobile= " + v_rcvmobile
                    };
                }
            }
        }

        
#endregion  收货信息结构

        
#region  订货人信息结构

        
///  <summary>
        
///  订货人信息结构
        
///  </summary>
         public  struct  OrderStruct
        {
           
public  string  v_ordername;                                                           //  订货人姓名
             public  string  v_orderaddr;                                                           //  订货人地址
             public  string  v_ordertel;                                                            //  订货人电话
             public  string  v_orderpost;                                                           //  订货人邮编
             public  string  v_orderemail;                                                          //  订货人邮件
             public  string  v_ordermobile;                                                         //  订货人手机号
             public  string [] v_order
            {
                
get
                {
                    
return  new  string []
                    { 
                        
" v_ordername= " + v_ordername,
                        
" v_orderaddr= " + v_orderaddr,
                        
" v_ordertel= " + v_ordertel,
                        
" v_orderpost= " + v_orderpost,
                        
" v_orderemail= " + v_orderemail,
                        
" v_ordermobile= " + v_ordermobile
                    };
                }
            }
        }

        
#endregion  订货人信息结构

        
#region  两个备注结构

        
///  <summary>
        
///  两个备注结构
        
///  </summary>
         public  struct  ReMarkStruct
        {
            
public  string  remark1;
            
public  string  remark2;
            
public  string [] remark
            {
                
get
                {
                    
return  new  string []
                    { 
                        
" remark1= " + remark1,
                        
" remark2= " + remark2
                    };
                }
            }
        }

        
#endregion  两个备注结构
        
        
#region  网银在线基础属性

        
///  <summary>
        
///  订单金额
        
///  </summary>
         public  string  v_amount
        {
            
get  {  return  _v_amount;  }
            
set  { _v_amount  =  value; }
        }
        
///  <summary>
        
///  币种
        
///  </summary>
         public  string  v_moneytype
        {
            
get  {  return  _v_moneytype; }
            
set  { _v_moneytype  =  value; }
        }
        
///  <summary>
        
///  对拼凑串MD5私钥加密后的值
        
///  </summary>
         public  string  v_md5info
        {
            
get  
            {
                
string  text  =  v_amount  +  v_moneytype  +  v_oid  +  v_mid  +  v_url  +  v_key;                            //  拼凑加密串
                _v_md5info  =  System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(text,  " md5 " ).ToUpper();
                
return  _v_md5info;
            }
        }
        
///  <summary>
        
///  商户号
        
///  </summary>
         public  string  v_mid
        {
            
get  {  return  _v_mid; }
            
set  { _v_mid  =  value; }
        }
        
///  <summary>
        
///  返回页地址
        
///  </summary>
         public  string  v_url
        {
            
get  {  return  _v_url; }
            
set  { _v_url  =  value; }
        }
        
///  <summary>
        
/// 推荐订单号构成格式为 年月日-商户号-小时分钟秒
        
///  </summary>
         public  string  v_oid
        {
            
get  {  return  _v_oid; }
            
set  { _v_oid  =  value; }
        }
        
///  <summary>
        
///  MD5密钥
        
///  </summary>
         public  string  v_key
        {
            
get  {  return  _v_key; }
            
set  { _v_key  =  value; }
        }
        
///  <summary>
        
///  收获人信息
        
///  </summary>
         public  ReceiveStruct Receive
        {
            
get  {  return  _Receive; }
            
set  { _Receive  =  value; }
        }
        
///  <summary>
        
///  订货人信息
        
///  </summary>
         public  OrderStruct Order
        {
            
get  {  return  _Order; }
            
set  { _Order  =  value; }
        }
        
///  <summary>
        
///  备注信息
        
///  </summary>
         public  ReMarkStruct ReMark
        {
            
get  {  return  _ReMark; }
            
set  { _ReMark  =  value; }
        }
        
#endregion  网银在线基础属性

        
#region   网银在线方法

        
///  <summary>
        
///  构造支付Url 
        
///  </summary>
        
///  <param name="chinabank"></param>
        
///  <returns></returns>
         public  static  string  CreatUrl(ChinaBank chinabank)
        {
            
string [] OrderUrl  = {
                
" v_oid= " + chinabank.v_oid,
                
" v_amount= " + chinabank.v_amount,
                SplitUrl(chinabank.Receive.v_rcv),
                SplitUrl(chinabank.Order.v_order),
                SplitUrl(chinabank.ReMark.remark)
            };
            
return  SplitUrl(OrderUrl).ToString();
        }
        
///  <summary>
        
///  构造支付Url
        
///  </summary>
        
///  <param name="OrderUrl"></param>
        
///  <returns></returns>
         private  static  string  SplitUrl( string [] OrderUrl)
        {
            System.Text.StringBuilder parameter 
=  new  System.Text.StringBuilder();
            
int  k  =  0 ;
            
for  ( int  i  =  0 ; i  <  OrderUrl.Length; i ++ )
            {
                k
++ ;
                
if  (k == 1 )
                {
                    parameter.Append(OrderUrl[i]);
                }
                
else
                {
                    parameter.Append(
" & "  +  OrderUrl[i]);
                }
            }
            
return  parameter.ToString();
        }
        
#endregion  网银在线方法
    }
}

你可能感兴趣的:(接口)