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;
/// <summary>
/// Ips在线支付(*号的字段表示必填项,需自定义填写)
/// </summary>
public class IpsPay
{
private string _Mercode = "000015"; //商户号(*)
private string _Billstr = string.Empty; //订单号(*)
private string _Amount = string.Empty; //订单金额(*)
private string _Date = System.DateTime.Now.ToString("yyyyMMdd"); //支付日期(*)
private string _StrCert = "GDgLwwdK270Qj1w4xho8lyTpRQZV9Jm5x4NwWOTThUa4fMhEBK9jOXFrKRT6xhlJuU2FEa89ov0ryyjfJuuPkcGzO5CeVx5ZIrkkt1aBlZV36ySvHOMcNv8rncRiy3DQ"; //证书(Key)(*)
private string _SignMD5 = string.Empty; //订单支付接口的Md5摘要(*)
private string _Currency_Type = "RMB"; //币种
private string _Gateway_Type = "01"; //支付卡种
private string _Lang="GB"; //语言
private string _Merchanturl = "../OrderReturnBy.aspx"; //支付成功返回的商户URL(*)
private string _FailUrl = string.Empty; //支付失败返回的商户URL
private string _ErrorUrl = string.Empty; //支付错误返回的商户URL
private string _Attach = string.Empty; //备注信息
private string _DispAmount = string.Empty; //显示金额
private int _OrderEncodeType=2; //订单支付加密方式(*)默认:md5
private int _RetEncodeType = 12; //交易返回接口加密方式(*)默认:md5
private int _Rettype = 0; //是否提供Server返回方式
private string _ServerUrl = string.Empty; //Server to Server 返回页面
private string _ForUrl = "http://pay.ips.net.cn/ipayment.aspx"; //提交地址
public IpsPay()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
#region 支付属性
/// <summary>
/// 商户号
/// </summary>
public string Mercode
{
get { return _Mercode; }
set { _Mercode = value; }
}
/// <summary>
/// 订单号
/// </summary>
public string Billstr
{
get { return _Billstr; }
set { _Billstr = value; }
}
/// <summary>
/// 订单金额
/// </summary>
public string Amount
{
get { return _Amount; }
set { _Amount = value; }
}
/// <summary>
/// 支付日期
/// </summary>
public string Date
{
get { return _Date; }
set { _Date = value; }
}
/// <summary>
/// 证书(Key)
/// </summary>
public string StrCert
{
get { return _StrCert; }
set { _StrCert = value; }
}
/// <summary>
/// 订单支付接口的Md5摘要
/// </summary>
public string SignMD5
{
get
{
string strcontent = Billstr + Amount + Date + Currency_Type + StrCert; //拼凑md5签名字符串
_SignMD5 = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(strcontent, "MD5").ToLower(); //用md5签名验证信息
return _SignMD5;
}
}
/// <summary>
/// 币种
/// </summary>
public string Currency_Type
{
get { return _Currency_Type; }
set { _Currency_Type = value; }
}
/// <summary>
/// 支付卡种
/// </summary>
public string Gateway_Type
{
get { return _Gateway_Type; }
set { _Gateway_Type = value; }
}
/// <summary>
/// 语言
/// </summary>
public string Lang
{
get { return _Lang; }
set { _Lang = value; }
}
/// <summary>
/// 支付成功返回的商户URL
/// </summary>
public string Merchanturl
{
get { return _Merchanturl; }
set { _Merchanturl = value; }
}
/// <summary>
/// 支付失败返回的商户URL
/// </summary>
public string FailUrl
{
get { return _FailUrl; }
set { _FailUrl = value; }
}
/// <summary>
/// 支付错误返回的商户URL
/// </summary>
public string ErrorUrl
{
get { return _ErrorUrl; }
set { _ErrorUrl = value; }
}
/// <summary>
/// 备注信息
/// </summary>
public string Attach
{
get { return _Attach; }
set { _Attach = value; }
}
/// <summary>
/// 显示金额
/// </summary>
public string DispAmount
{
get { return _DispAmount; }
set { _DispAmount = value; }
}
/// <summary>
/// 订单支付加密方式
/// </summary>
public int OrderEncodeType
{
get { return _OrderEncodeType; }
set { _OrderEncodeType = value; }
}
/// <summary>
/// 交易返回接口加密方式
/// </summary>
public int RetEncodeType
{
get { return _RetEncodeType; }
set { _RetEncodeType = value; }
}
/// <summary>
/// 是否提供Server返回方式
/// </summary>
public int Rettype
{
get { return _Rettype; }
set { _Rettype = value; }
}
/// <summary>
/// Server to Server 返回页面
/// </summary>
public string ServerUrl
{
get { return _ServerUrl; }
set { _ServerUrl = value; }
}
/// <summary>
/// 提交地址
/// </summary>
public string ForUrl
{
get { return _ForUrl; }
}
#endregion 支付属性
#region 支付方法
/// <summary>
/// 构造支付Url
/// </summary>
/// <param name="IpsPay"></param>
/// <returns></returns>
public static string CreatUrl(IpsPay ipsPay)
{
string[] OrderUrl ={
"Billstr="+ipsPay.Billstr,
"Amount="+ipsPay.Amount
};
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 支付方法