简体   繁体   English

Paypal API响应:安全标题无效

[英]Paypal API Response: Security Header Not Valid

This is the string I am building and sending to Paypal. 这是我正在构建并发送给Paypal的字符串。

        string paypalMessage = "https://api-3t.sandbox.paypal.com/nvp?";

        paypalMessage += "USER=" + USER;
        paypalMessage += "&PWD=" + PWD;
        paypalMessage += "&VERSION=" + VERSION;
        paypalMessage += "&SIGNATURE=" + SIGNATURE;
        paypalMessage += "&METHOD=" + METHOD;
        paypalMessage += "&IPADDRESS=" + IPADDRESS;
        paypalMessage += "&ACCT=" + ACCT;
        paypalMessage += "&EXPDATE=" + EXPDATE;
        paypalMessage += "&CVV2=" + CVV2;
        paypalMessage += "&FIRSTNAME=" + FIRSTNAME;
        paypalMessage += "&LASTNAME=" + LASTNAME;
        paypalMessage += "&STREET=" + STREET;
        paypalMessage += "&CITY=" + CITY;
        paypalMessage += "&STATE=" + STATE;
        paypalMessage += "&COUNTRYCODE=" + COUNTRYCODE;
        paypalMessage += "&ZIP=" + ZIP;
        paypalMessage += "&AMT=" + AMT;

        return paypalMessage;

When I send this to paypal, this is the response I get from Paypal: 当我将其发送给贝宝时,这是我从贝宝得到的回复:

TIMESTAMP=2014%2d05%2d06T19%3a55%3a28Z&CORRELATIONID=e06f3f16478d1&ACK=Failure&VERSION=113%2e0&BUILD=10762035&L_ERRORCODE0=10002&L_SHORTMESSAGE0=Security%20error&L_LONGMESSAGE0=Security%20header%20is%20not%20valid&L_SEVERITYCODE0=Error TIMESTAMP = 2014%2d05%2d06T19%3a55%3a28Z&CORRELATIONID = e06f3f16478d1&ACK = Failure&VERSION = 113%2e0&BUILD = 10762035&L_ERRORCODE0 = 10002&L_SHORTMESSAGE0 = Security%20error&L_LONGMESSAGE0 = Security%20head

What does this "Security Header Is Not Valid" mean? 此“安全标题无效”是什么意思? My google searches tell me its a security thing, but I know USER and PWD are both correct. 我的Google搜索告诉我它是安全的,但是我知道USER和PWD都是正确的。 Signature is what I pulled off of the account after I logged into Paypal Developer website. 签名是我登录Paypal Developer网站后从帐户中提取的东西。 Is this wrong? 错了吗

EDIT: 编辑:

Doing some research while checking for replies, if I'm testing with Sandbox does it mean I need to use a USER/PWD/SIGNATURE from a created Sandbox account that is attached to my actual paypal developer account? 在检查答复的同时做一些研究,如果我正在使用Sandbox进行测试,是否意味着我需要使用从创建的Sandbox帐户使用的USER / PWD / SIGNATURE,该帐户已附加到我的实际Paypal开发者帐户? Would this be all I need to change to work back and forth between sandbox and live? 我要做的就是在沙盒和实时播放之间来回切换吗?

Whenever you receive this message it either means that invalid API Credentials were used. 每当您收到此消息时,都意味着使用了无效的API凭据。 Make certain that no added spaces are in your API credentials and that the full signature was copied. 确保您的API凭据中没有添加的空格,并且已复制完整签名。

The other option is that your endpoints and your credentials are not matching. 另一个选择是您的端点和凭据不匹配。

If you use Sandbox credentials and live endpoints then you will receive this message. 如果您使用沙盒凭据和活动终结点,则会收到此消息。 Same thing if you use live credentials for sandbox endpoints. 如果您将实时凭据用于沙箱端点,则同样。

Here is a link to another Stack Post with the Same Issue 这是另一个具有相同问题的堆栈文章的链接

In the post I have links to the PayPal Developer Documentation. 在帖子中,我具有指向PayPal开发人员文档的链接。 It details going live. 它详细介绍了上线过程。

It doesn't always mean invalid API credential or wrong endpoint 这并不总是意味着无效的API凭证或错误的端点

If you're absolutely sure in this info, check the encoding you're making your request with - it should be UTF-8 without Byte-Order Mark (BOM), eg 如果您对此信息有绝对把握,请检查发出请求的编码-它应该是不带字节序标记(BOM)的UTF-8,例如

var requestEncoding = new UTF8Encoding(false); // UTF-8 without BOM

using (var streamWriter = new StreamWriter(request.GetRequestStream(), requestEncoding))
{
    streamWriter.Write(requestBody);
}

This is not a default value, and it helped me after an hour of checking everything 不是默认值,经过一个小时的检查,它对我有帮助

Of course, make sure all of your parameters are url encoded, too 当然,请确保所有参数也都经过url编码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM