asp.net - 使用 Asp.net 的 Paypal Mass Payment API(不接收来自 paypal 的响应)

标签 asp.net paypal httpwebresponse

enter image description here我使用 MassPaymentAPI 创建了 MassPayment 但我在此方法中遇到错误

方法输入:::

url="https://api.sandbox.paypal.com/nvp"
postdata="METHOD=MassPay&EMAILSUBJECT=You+have+money!&RECEIVERTYPE=EmailAddress&CURRENCYCODE=USD&L_EMAIL0=bhaumik50%40gmail.com&L_Amt0=1.00&L_UNIQUEID0=&L_NOTE0=&USER=rserasiya_api1.gmail.com&PWD=OneIsTheLonliestNumber&VERSION=1&SOURCE=1" ;
timeout= "3600" ;
X509certificate = "Certifcate Description"


public static string HttpPost(string url, string postData, int timeout, X509Certificate x509)

{

    HttpWebRequest objRequest = (HttpWebRequest) WebRequest.Create(url);

    objRequest.Timeout = timeout;

    objRequest.Method = "POST";

    objRequest.ContentLength = postData.Length;

    if (null != x509)

    {

        objRequest.ClientCertificates.Add(x509);

    }

    using (StreamWriter myWriter = new StreamWriter(objRequest.GetRequestStream()))

    {
        myWriter.Write(postData);

    }

    using (WebResponse response = objRequest.GetResponse())

    {

        using (StreamReader sr = new StreamReader(response.GetResponseStream()))

        {
            return sr.ReadToEnd();
        }
    }
}

在这种方法中,我使用 StreamWriter 对象成功发送了请求,但我没有收到来自 paypal 站点的响应,所以我该怎么办?请回复..

我的错误是:基础连接已关闭:连接意外关闭。

我放了抛出错误和浏览器错误的方法的图像。

请给我你的建议 enter image description here

最佳答案

您的代码中的问题出在您使用的 Api url 中

url="https://api.sandbox.paypal.com/nvp" 

当你应该使用

url="https://api-3t.sandbox.paypal.com/nvp"

关于asp.net - 使用 Asp.net 的 Paypal Mass Payment API(不接收来自 paypal 的响应),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15501669/

相关文章:

asp.net - XMLHTTPrequest 的经典 ASP 错误

c# - HttpWebResponse 剥离换行符

c# - HttpWebResponse:关闭流

asp.net - ASP.Net 中的 WF 和并行性需要指导

asp.net - 无法获取asp.net中只读文本框的值

asp.net - 将 VS 项目迁移到网站

php - 找不到 Paypal OAuthTokenCredential

api - Paypal - PayFlow Pro,使用 'Transaction Id' 获取交易细节

ruby-on-rails - Ruby on Rails 如何构建支付模型来处理 Paypal REST SDK

c# - 使用 HttpWebRequest.GetResponse() 抓取屏幕时出现错误 "The remote server returned an error: (403) Forbidden"