asp.net实现网上银行在线交易是怎么实现的?说的详细一点最好说出具体的流程还有代码!谢谢!
展开全部
各大银行基本不会为你提供在线支付接口的 除非你的网站够大够强。
试试第三方支付平台接口使用 其实和银行的接口程序使用方式一样。
说说支付宝接口吧。要收费的。现在没有免费的了。最低套餐 -- 一年600元。36000元的现金交易流量。最便宜的了。
主类:
AliPay.cs
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;
using System.Text;
using System.Security.Cryptography;
/// <summary>
/// New Interface for AliPay
/// </summary>
namespace Gateway
{
/// <summary>
/// created by sunzhizhi 2006.5.21,sunzhizhi@msn.com。
/// </summary>
public class AliPay
{
public static string GetMD5(string s, string _input_charset)
{
/// <summary>
/// 与ASP兼容的MD5加密算法
/// </summary>
MD5 md5 = new MD5CryptoServiceProvider();
byte[] t = md5.ComputeHash(Encoding.GetEncoding(_input_charset).GetBytes(s));
StringBuilder sb = new StringBuilder(32);
for (int i = 0; i < t.Length; i++)
{
sb.Append(t[i].ToString("x").PadLeft(2, '0'));
}
return sb.ToString();
}
public static string[] BubbleSort(string[] r)
{
/// <summary>
/// 冒泡排序法
/// </summary>
int i, j; //交换标志
string temp;
bool exchange;
for (i = 0; i < r.Length; i++) //最多做R.Length-1趟排序
{
exchange = false; //本趟排序开始前,交换标志应为假
for (j = r.Length - 2; j >= i; j--)
{
if (System.String.CompareOrdinal(r[j + 1], r[j]) < 0) //交换条件
{
temp = r[j + 1];
r[j + 1] = r[j];
r[j] = temp;
exchange = true; //发生了交换,故将交换标志置为真
}
}
if (!exchange) //本趟排序未发生交换,提前终止算法
{
break;
}
}
return r;
}
public string CreatUrl(
string gateway,
string service,
string partner,
string sign_type,
string out_trade_no,
string subject,
string body,
string payment_type,
string total_fee,
string show_url,
string seller_email,
string key,
string return_url,
string _input_charset,
string notify_url,
string logistics_type,
string logistics_fee,
string logistics_payment,
string logistics_type_1,
string logistics_fee_1,
string logistics_payment_1,
string quantity
)
{
/// <summary>
/// created by sunzhizhi 2006.5.21,sunzhizhi@msn.com。
/// </summary>
int i;
//构造数组;
string[] Oristr ={
"service="+service,
"partner=" + partner,
"subject=" + subject,
"body=" + body,
"out_trade_no=" + out_trade_no,
"price=" + total_fee,
"show_url=" + show_url,
"payment_type=" + payment_type,
"seller_email=" + seller_email,
"notify_url=" + notify_url,
"_input_charset="+_input_charset,
"return_url=" + return_url,
"quantity="+quantity,
"logistics_type="+logistics_type,
"logistics_fee="+logistics_fee ,
"logistics_payment="+logistics_payment,
"logistics_type_1="+logistics_type_1,
"logistics_fee_1="+logistics_fee_1,
"logistics_payment_1="+logistics_payment_1
};
//进行排序;
string[] Sortedstr = BubbleSort(Oristr);
//构造待md5摘要字符串 ;
StringBuilder prestr = new StringBuilder();
for (i = 0; i < Sortedstr.Length; i++)
{
if (i == Sortedstr.Length - 1)
{
prestr.Append(Sortedstr[i]);
}
else
{
prestr.Append(Sortedstr[i] + "&");
}
}
prestr.Append(key);
//生成Md5摘要;
string sign = GetMD5(prestr.ToString(), _input_charset);
//构造支付Url;
char[] delimiterChars = { '='};
StringBuilder parameter = new StringBuilder();
parameter.Append(gateway);
for (i = 0; i < Sortedstr.Length; i++)
{
parameter.Append(Sortedstr[i].Split(delimiterChars)[0] + "=" + HttpUtility.UrlEncode(Sortedstr[i].Split(delimiterChars)[1]) + "&");
}
parameter.Append("sign=" + sign + "&sign_type=" + sign_type);
//返回支付Url;
return parameter.ToString();
}
}
}
支付宝上提供源程序 和说明文档
试试第三方支付平台接口使用 其实和银行的接口程序使用方式一样。
说说支付宝接口吧。要收费的。现在没有免费的了。最低套餐 -- 一年600元。36000元的现金交易流量。最便宜的了。
主类:
AliPay.cs
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;
using System.Text;
using System.Security.Cryptography;
/// <summary>
/// New Interface for AliPay
/// </summary>
namespace Gateway
{
/// <summary>
/// created by sunzhizhi 2006.5.21,sunzhizhi@msn.com。
/// </summary>
public class AliPay
{
public static string GetMD5(string s, string _input_charset)
{
/// <summary>
/// 与ASP兼容的MD5加密算法
/// </summary>
MD5 md5 = new MD5CryptoServiceProvider();
byte[] t = md5.ComputeHash(Encoding.GetEncoding(_input_charset).GetBytes(s));
StringBuilder sb = new StringBuilder(32);
for (int i = 0; i < t.Length; i++)
{
sb.Append(t[i].ToString("x").PadLeft(2, '0'));
}
return sb.ToString();
}
public static string[] BubbleSort(string[] r)
{
/// <summary>
/// 冒泡排序法
/// </summary>
int i, j; //交换标志
string temp;
bool exchange;
for (i = 0; i < r.Length; i++) //最多做R.Length-1趟排序
{
exchange = false; //本趟排序开始前,交换标志应为假
for (j = r.Length - 2; j >= i; j--)
{
if (System.String.CompareOrdinal(r[j + 1], r[j]) < 0) //交换条件
{
temp = r[j + 1];
r[j + 1] = r[j];
r[j] = temp;
exchange = true; //发生了交换,故将交换标志置为真
}
}
if (!exchange) //本趟排序未发生交换,提前终止算法
{
break;
}
}
return r;
}
public string CreatUrl(
string gateway,
string service,
string partner,
string sign_type,
string out_trade_no,
string subject,
string body,
string payment_type,
string total_fee,
string show_url,
string seller_email,
string key,
string return_url,
string _input_charset,
string notify_url,
string logistics_type,
string logistics_fee,
string logistics_payment,
string logistics_type_1,
string logistics_fee_1,
string logistics_payment_1,
string quantity
)
{
/// <summary>
/// created by sunzhizhi 2006.5.21,sunzhizhi@msn.com。
/// </summary>
int i;
//构造数组;
string[] Oristr ={
"service="+service,
"partner=" + partner,
"subject=" + subject,
"body=" + body,
"out_trade_no=" + out_trade_no,
"price=" + total_fee,
"show_url=" + show_url,
"payment_type=" + payment_type,
"seller_email=" + seller_email,
"notify_url=" + notify_url,
"_input_charset="+_input_charset,
"return_url=" + return_url,
"quantity="+quantity,
"logistics_type="+logistics_type,
"logistics_fee="+logistics_fee ,
"logistics_payment="+logistics_payment,
"logistics_type_1="+logistics_type_1,
"logistics_fee_1="+logistics_fee_1,
"logistics_payment_1="+logistics_payment_1
};
//进行排序;
string[] Sortedstr = BubbleSort(Oristr);
//构造待md5摘要字符串 ;
StringBuilder prestr = new StringBuilder();
for (i = 0; i < Sortedstr.Length; i++)
{
if (i == Sortedstr.Length - 1)
{
prestr.Append(Sortedstr[i]);
}
else
{
prestr.Append(Sortedstr[i] + "&");
}
}
prestr.Append(key);
//生成Md5摘要;
string sign = GetMD5(prestr.ToString(), _input_charset);
//构造支付Url;
char[] delimiterChars = { '='};
StringBuilder parameter = new StringBuilder();
parameter.Append(gateway);
for (i = 0; i < Sortedstr.Length; i++)
{
parameter.Append(Sortedstr[i].Split(delimiterChars)[0] + "=" + HttpUtility.UrlEncode(Sortedstr[i].Split(delimiterChars)[1]) + "&");
}
parameter.Append("sign=" + sign + "&sign_type=" + sign_type);
//返回支付Url;
return parameter.ToString();
}
}
}
支付宝上提供源程序 和说明文档
广东轻亿云软件
2024-05-14 广告
2024-05-14 广告
作为广东轻亿云软件科技有限公司的一员,我们深知API接口开放平台的重要性。这一平台不仅为开发者们提供了丰富的应用程序编程接口,使他们能够便捷地访问和利用各项功能进行创新开发,还促进了开发者社区与公司产品或服务之间的深度互动。通过API接口开...
点击进入详情页
本回答由广东轻亿云软件提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询