asp.net-web-api - Paypal :IPN 监听器未收到 IPN 消息

标签 asp.net-web-api paypal paypal-ipn paypal-sandbox

我有一个在线交易网站,使用 Paypal 作为支付选项。 Paypal 端的结帐和购物车计算正常,但我没有收到来自 Paypal 沙箱的任何 IPN 消息。写入日志后,我发现参数 formdata 为空。即使检查了 IPN 历史记录,它也显示 IPN 消息的状态为正在重试... IPN 通知 url 也已设置。 下面是监听器代码。

[Route("IPN")]
    public IHttpActionResult IPN(FormDataCollection formData)
    {

        var formVals = new Dictionary<string, string>();
        formVals.Add("cmd", "_notify-validate");

        string response = GetPayPalResponse(formVals, formData);

        if (response.ToUpper().Trim() == "VERIFIED")
        {

            //entry into database

            }
            else
            {

                return InternalServerError();
            }

        return InternalServerError();
    }

string GetPayPalResponse(Dictionary<string, string> formVals, FormDataCollection formData)
    {

        string paypalUrl = GetPayPalURL();
        HttpWebRequest req = (HttpWebRequest)WebRequest.Create(paypalUrl);

        // Set values for the request back
        req.Method = "POST";
        req.ContentType = "application/x-www-form-urlencoded";

        Encoding encoding = Encoding.UTF8;

        StringBuilder sb = new StringBuilder();
        foreach (var entry in formData.ToList())
        {
            sb.AppendFormat("{0}={1}&", entry.Key, encoding.GetString(encoding.GetBytes(entry.Value)));
        }

        string strRequest = sb.ToString();
        strRequest += "cmd=_notify-validate";
        req.ContentLength = strRequest.Length;

        //Send the request to PayPal and get the response
        StreamWriter streamOut = new StreamWriter(req.GetRequestStream());
        streamOut.Write(strRequest);
        streamOut.Close();

        StreamReader streamIn = new StreamReader(req.GetResponse().GetResponseStream());
        string strResponse = streamIn.ReadToEnd();
        streamIn.Close();

        return strResponse;
    }

这之前是有效的,但不知道是什么阻止了它。 作为 paypal 支付网关的新手,我们将不胜感激任何帮助。

最佳答案

从昨天开始,paypal 就出现了一定的问题。我希望这是一个暂时性的问题,它会尽快得到解决。我自己在沙盒方面遇到了问题,但以前也发生过。

关于asp.net-web-api - Paypal :IPN 监听器未收到 IPN 消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38589960/

相关文章:

php - Paypal IPN 监听器总是返回 INVALID,但在 live paypal 中交易成功

javascript - AngularJS 将服务数组变量绑定(bind)到 Controller 范围

c# - ASP.Net Web 应用程序连接到主机 SQL 数据库

php - Paypal 付款后显示状态 'Pending'

android - 跨平台移动订阅(Android + iOS)

paypal - 如果信用卡在定期 paypal 付款时过期,会发生什么情况?

c# - 在 C# 中手动解码 OAuth 不记名 token

c# - 尽管在响应对象上配置了缓存控制 header ,但未在响应中发送

php - 从 DoExpressCheckoutPayment 回复中获取 transactionId

php - 谁能告诉我 paypal 按钮之间的区别