贝宝无效响应IPN然而 [英] INVALID paypal ipn response however

查看:119
本文介绍了贝宝无效响应IPN然而的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用沙盒模式。我在链接到我的沙箱企业帐户沙盒模式已IPN的URL到我的网站现在启用一个购买按钮。 IPN的实现是完全一样的样品code此处的 https://cms.paypal.com/cms_content/GB/en_GB/files/developer/IPN_ASP_NET_C.txt

I am using sandbox mode. I have a buy now button in sandbox mode linked to my sandbox business account which has ipn enabled with the url to my site. The ipn implementation is exactly the same as the sample code here: https://cms.paypal.com/cms_content/GB/en_GB/files/developer/IPN_ASP_NET_C.txt

我按一下按钮,并使用沙箱的个人账户是成功进行购买。它显示了与code 200在企业的账户发送IPN的历史,但在我的网站上的IPN页面上的反应是无效的。

I click the button and make a purchase using a sandbox personal account which is successful. it shows up as sent with code 200 in the business accounts ipn history but on the ipn page on my site the response is invalid.

目前已为天现在..不能弄明白:(

Been at this for days now.. cant figure it out :(

推荐答案

下面是我用什么 https://ASPSecurityKit.net

    private void ProcessPayment(bool test)
    {
        try
        {
           string callbackResponse = null;
            string content = null;
            string callbackUrl = test ? "https://www.sandbox.paypal.com/cgi-bin/webscr"
            : "https://www.paypal.com/cgi-bin/webscr";

            var req = (HttpWebRequest) WebRequest.Create(callbackUrl);
            req.Method = "POST";
            req.ContentType = "application/x-www-form-urlencoded";
            content = Encoding.ASCII.GetString(
                Request.BinaryRead(HttpContext.Request.ContentLength)
                );
            content += "&cmd=_notify-validate";
            req.ContentLength = content.Length;
                                                using (var streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII))
            {
                streamOut.Write(content);
            }
            using (var streamIn = new StreamReader(req.GetResponse().GetResponseStream()))
            {
            callbackResponse = streamIn.ReadToEnd();
            }


            if (callbackResponse.Equals("VERIFIED", StringComparison.OrdinalIgnoreCase))
            {
                // Now validate whether gross_amount is ok, receiver_email is your business acount mail id and so on.
            }
        }
        catch (Exception ex)
        {
            // Logger.Log(ex); // Uncomment this line if you have a logger
        }
    }

请注意:我是否储存或了验证无效的数据库中的所有事务。这逻辑是 ASPSecurityKit.net 特定所以我省略了这里。

Note: I store all transactions in the database whether varified or invalid. That logic is ASPSecurityKit.net specific hence I have omitted that here.

这篇关于贝宝无效响应IPN然而的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆