ASP.Net/C# - PayPal接口文档 - lee576的专栏 - CSDN博客

来源:百度文库 编辑:神马文学网 时间:2024/04/29 15:03:40
//Post back to either sandbox or live
string strSandbox = "https://www.sandbox.paypal.com/cgi-bin/webscr";
string strLive = "https://www.paypal.com/cgi-bin/webscr";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(strSandbox);// Set values for the request back
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
byte[] param = Request.BinaryRead(HttpContext.Current.Request.ContentLength);
string strRequest = Encoding.ASCII.GetString(param);
strRequest += "&cmd=_notify-validate";
req.ContentLength = strRequest.Length;//for proxy
//WebProxy proxy = new WebProxy(new Uri("http://url:port#"));
//req.Proxy = proxy;//Send the request to PayPal and get the response
StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);
streamOut.Write(strRequest);
streamOut.Close();
StreamReader streamIn = new StreamReader(req.GetResponse().GetResponseStream());
string strResponse = streamIn.ReadToEnd();
streamIn.Close();if (strResponse == "VERIFIED")
{
// check the payment_status is Completed
// check that txn_id has not been previously processed
// check that receiver_email is your Primary PayPal email
// check that payment_amount/payment_currency are correct
// process payment
}
else if (strResponse == "INVALID")
{
// log for manual investigation
}
else
{
//log response/ipn data for manual investigation
}
}
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/lee576/archive/2008/11/05/3229666.aspx
ASP.Net/C# - PayPal接口文档 - lee576的专栏 - CSDN博客 PayPal Sandbox 在线支付开发测试环境 - lee576的专栏 - CSDN博... asp.net 数据缓存机制 - cnkiminzhuhu的专栏 - CSDN博客 ASP.NET常用语句1--20条,(很实用的) - 老张的专栏 - CSDN博客 asp.net常用的第三方控件 - shuanghusun的专栏 - CSDN博客 C#的内存管理知识 - dz_huanbao的专栏 - CSDN博客 软件设计_接口_中间层 - hongjiqin的专栏 - CSDN博客 JPEG 简易文档 V2.11 - dd167的专栏 - CSDN博客 c#泛型和反射的设计应用(一) - yutao051的专栏 - CSDN博客 C#实现启用、禁用本地网络的三种方式 - dsd999的专栏 - CSDN博客 C#实现启用、禁用本地网络的三种方式 - dsd999的专栏 - CSDN博客 C#操作xml之xpath语法 - ismycxp的专栏 - CSDN博客 在C#中使用COM+实现事务控制 - zgqtxwd的专栏 - CSDN博客 详细解析Java中抽象类和接口的区别 - fpy_061625的专栏 - CSDN博客 C#重载和重写的区别 - C#编程 - Asp.net C# 学习与研究 word文档如何自动生成目录 - 张磊的专栏 - CSDN博客 word文档如何自动生成目录 - 张磊的专栏 - CSDN博客 word文档如何自动生成目录 - 张磊的专栏 - CSDN博客. ASP.NET页面间数据传递的方法讲解|.net(C# vb asp) baozhengw的专栏 - CSDN博客 漫谈.NET开发中的字符串编码 - bitfan(数字世界一凡人)的专栏 - CSDN博客 C#接口的定义 C#接口的定义 ASP.NET下MVC设计模式的实现-微软开发专栏-ASP.NET-天极网