支付宝接口源代码
来源:互联网 发布:卡西·阿弗莱克 知乎 编辑:程序博客网 时间:2024/03/29 15:11
支付宝接口源代码(刚完成,应该是目前最好的了)
支付宝的接口调用很不方便,刚做好一个封装,实现了虚拟交易和实物交易。
解决方案中有三个项目以及NDoc生成的文档,简单的序列图:CommonAliPay,封装的支付宝接口。
TestAli,asp.net的测试项目
TestCommonAliPay,Nunit的测试项目。
源代码下载地址:http://www.cnblogs.com/Files/bluewater/CommonAliPay.rar
调用方法:
1、引入CommonAliPay.dll
2、实现支付宝服务接口的方法调用方式:
上面是通用的调用方式。 解决方案中有三个项目以及NDoc生成的文档,简单的序列图:CommonAliPay,封装的支付宝接口。
TestAli,asp.net的测试项目
TestCommonAliPay,Nunit的测试项目。
源代码下载地址:http://www.cnblogs.com/Files/bluewater/CommonAliPay.rar
调用方法:
1、引入CommonAliPay.dll
2、实现支付宝服务接口的方法调用方式:
AliPay ap = new AliPay();
string key = "";//填写自己的key
string partner = "";//填写自己的Partner
StandardGoods bp = new StandardGoods("trade_create_by_buyer", partner, key, "MD5", "卡2",
Guid.NewGuid().ToString(), 2.551m, 1, "hao_ding2000@yahoo.com.cn", "hao_ding2000@yahoo.com.cn",
"EMS", 25.00m, "BUYER_PAY", "1");
bp.Notify_Url = "http://203.86.79.185/ali/notify.aspx";
ap.CreateStandardTrade("https://www.alipay.com/cooperate/gateway.do", bp, this);
string key = "";//填写自己的key
string partner = "";//填写自己的Partner
StandardGoods bp = new StandardGoods("trade_create_by_buyer", partner, key, "MD5", "卡2",
Guid.NewGuid().ToString(), 2.551m, 1, "hao_ding2000@yahoo.com.cn", "hao_ding2000@yahoo.com.cn",
"EMS", 25.00m, "BUYER_PAY", "1");
bp.Notify_Url = "http://203.86.79.185/ali/notify.aspx";
ap.CreateStandardTrade("https://www.alipay.com/cooperate/gateway.do", bp, this);
下面是只支持虚拟货物的方式:
string key = "";//填写自己的key
string partner = "";//填写自己的Partner
AliPay ap = new AliPay();
DigitalGoods bp = new DigitalGoods("create_digital_goods_trade_p", partner, key, "MD5", "卡2",
Guid.NewGuid().ToString(), 2.551m, 1, "hao_ding2000@yahoo.com.cn", "hao_ding2000@yahoo.com.cn");
bp.Notify_Url = "http://203.86.79.185/ali/notify.aspx";
ap.CreateDigitalTrade("https://www.alipay.com/cooperate/gateway.do", bp, this);
string partner = "";//填写自己的Partner
AliPay ap = new AliPay();
DigitalGoods bp = new DigitalGoods("create_digital_goods_trade_p", partner, key, "MD5", "卡2",
Guid.NewGuid().ToString(), 2.551m, 1, "hao_ding2000@yahoo.com.cn", "hao_ding2000@yahoo.com.cn");
bp.Notify_Url = "http://203.86.79.185/ali/notify.aspx";
ap.CreateDigitalTrade("https://www.alipay.com/cooperate/gateway.do", bp, this);
3、实现支付宝通知接口方法的调用(支持虚拟和实物):
protected void Page_Load(object sender, EventArgs e)
{
string key = "";//填写自己的key
string partner = "";//填写自己的Partner
AliPay ap = new AliPay();
string notifyid = Request.Form["notify_id"];
Verify v = new Verify("notify_verify", partner, notifyid);
ap.WaitSellerSendGoods += new AliPay.ProcessNotifyEventHandler(ap_WaitSellerSendGoods);
ap.WaitBuyerPay += new AliPay.ProcessNotifyEventHandler(ap_WaitBuyerPay);
ap.ProcessNotify(this, "https://www.alipay.com/cooperate/gateway.do", key, v, "utf-8");
}
void ap_WaitBuyerPay(object sender, NotifyEventArgs e)
{
// //加入自己的处理逻辑
Log4net.log.Error("wait buyer pay fire");
}
private void ap_WaitSellerSendGoods(object sender, NotifyEventArgs e)
{
//加入自己的处理逻辑
Log4net.log.Error("WaitSellerSendGoods fire");
}
{
string key = "";//填写自己的key
string partner = "";//填写自己的Partner
AliPay ap = new AliPay();
string notifyid = Request.Form["notify_id"];
Verify v = new Verify("notify_verify", partner, notifyid);
ap.WaitSellerSendGoods += new AliPay.ProcessNotifyEventHandler(ap_WaitSellerSendGoods);
ap.WaitBuyerPay += new AliPay.ProcessNotifyEventHandler(ap_WaitBuyerPay);
ap.ProcessNotify(this, "https://www.alipay.com/cooperate/gateway.do", key, v, "utf-8");
}
void ap_WaitBuyerPay(object sender, NotifyEventArgs e)
{
// //加入自己的处理逻辑
Log4net.log.Error("wait buyer pay fire");
}
private void ap_WaitSellerSendGoods(object sender, NotifyEventArgs e)
{
//加入自己的处理逻辑
Log4net.log.Error("WaitSellerSendGoods fire");
}
支付宝的交易状态都被定义成了类似名称的事件。
http://www.cnblogs.com/Files/bluewater/CommonAliPay.rar
因为时间很紧,有些地方还不完善,大家提出意见,有时间我会修改的
网上赠与服务集成技术文档V1.35.pdf
http://www.chenjiliang.com/Article/ArticleAttach/84/2123/apply_alipay_donate_service.zip
- 支付宝接口源代码
- 支付宝接口源代码
- 支付宝接口源代码
- 支付宝接口源代码
- codeigniter版支付宝接口源代码v0.1
- 支付宝支付接口
- 支付宝在线支付接口
- 连接支付宝支付接口
- 支付宝支付接口详解
- 支付宝支付接口流程
- 对接支付宝支付接口
- 支付宝支付接口 APP
- 支付宝接口源代码(刚完成,应该是目前最好的了)
- 支付宝接口源代码(刚完成,应该是目前最好的了)
- 支付宝接口(刚完成,应该是目前最好的了,含源代码) 收到研究下
- 银联支付接口+支付宝接口统一支付功能
- 支付宝接口faq
- 支付宝接口
- 什么是视频分配器 编码器
- 《武林外传》之(二) 佟掌柜的三板斧
- [转]关于内存地址的个人理解和操作原理
- VBA语法概述
- 《struts2权威指南》学习笔记之struts2 ajax标签
- 支付宝接口源代码
- Asp 生成随机字符串13位
- 深入分析Oracle字符集(转载)
- 打开Excel文件能否去掉提示框?
- JSP的一些标签【继续补充】
- Serveriable服务器变量使用
- 偷听北京--无意而真实的片段(8)
- Cookies 使用总结【待补充】
- WEB服务器安装教程:如何在WINDOWS XP下安装IIS