PayPal Express Checkout返回 - 安全标头无效

时间:2011-11-23 00:02:47

标签: asp.net c#-4.0 paypal

这可能已被问过一千次......但我确信我拥有所有端点和凭据。它昨天正在运作。

Security error:
Error no: 10002
Error message: Security header is not valid

现在我正在测试沙盒服务器。

每当我在浏览器中尝试testURL时,我会得到ACK =带有令牌的成功,但是当它运行代码时,我得到“安全标头无效”错误。

几个小时前它正在工作,但由于某种原因,我现在一直收到同样的错误。

使用沙箱帐户中的user / pwd和签名

https://api-3t.sandbox.paypal.com/nvp
USER=xxxxxxxxxxxxxxxxxxxx
PWD=XXXXXXXXXXXXX
SIGNATURE=XXXXXXXXXXXXXXXXXXXXXXXXXXXXX

我有以下测试代码:

        String testURL = "https://api-3t.sandbox.paypal.com/nvp?USER=xxxxxxxxxxxxxxxxxxxx&PWD=XXXXXXXXXXXXX&SIGNATURE=XXXXXXXXXXXXXXXXXXXXXXXXXXXXX&VERSION=84.0-2276209&PAYMENTREQUEST_0_PAYMENTACTION=Sale&PAYMENTREQUEST_0_AMT=15&RETURNURL=https%3a%2f%2fdomain.com%2fCheckout.aspx&CANCELURL=https%3a%2f%2fdomain.com%2fCheckout.aspx&METHOD=SetExpressCheckout";

        HttpWebRequest req = (HttpWebRequest)WebRequest.Create(testURL);
        req.Method = "POST";
        req.ContentType = "application/x-www-form-urlencoded";


        //Send the request to PayPal and get the response
        StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);
        streamOut.Write(testURL);
        streamOut.Close();
        // get resposne
        StreamReader streamIn = new StreamReader(req.GetResponse().GetResponseStream());
        string strResponse = HttpUtility.UrlDecode(streamIn.ReadToEnd());
        streamIn.Close();

代码发送时HTTPREsponse

TIMESTAMP=2011-11-22T23:25:34Z&CORRELATIONID=392047cb78388&ACK=Failure&VERSION=84.000000&BUILD=2271164&L_ERRORCODE0=10002&L_SHORTMESSAGE0=Security error&L_LONGMESSAGE0=Security header is not valid&L_SEVERITYCODE0=Error

HttpResponse 如果我只是在浏览器中复制粘贴testURL

TOKEN=EC%2d4JW15968AV8121546&TIMESTAMP=2011%2d11%2d22T22%3a59%3a27Z&CORRELATIONID=c790299fd9ac7&ACK=Success&VERSION=84%2e000000&BUILD=2271164

我已经尝试过不对UrlEncode测试网址中的变量...同样的问题

提前致谢

1 个答案:

答案 0 :(得分:0)

好吧,这可能是Paypal方面的一个错误。

如果我从

更改testUrl

String testURL =“https://api-3t.sandbox.paypal.com/nvp?USER=XXX&PWD=YYY&SIGNATURE=ZZZ&VERSION=.......&METHOD=SetExpressCheckout” ;

String testURL =“https://api-3t.sandbox.paypal.com/nvp?&x=y&USER=XXX&PWD=YYY&SIGNATURE=ZZZ&VERSION = .......&安培; METHOD = SetExpressCheckout“;

它有效

使用随机的第一个查询字符串变量查看粗体部分。 PayPal似乎忽略了从代码隐藏发送时的第一个查询字符串参数(如果之前没有x = y,则为user = xxx)。

相关问题