【问题标题】:PayPal "Security header is not valid" error. What to do with this?PayPal“安全标头无效”错误。该怎么办?
【发布时间】:2023-03-03 13:08:01
【问题描述】:

我正在使用 PayPal 的 DoDirectPayment API 进行支付集成。我收到如下错误消息。


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

这是我的代码,

    $environment = 'sandbox';
    // Set up your API credentials, PayPal end point, and API version.
    $API_UserName = urlencode('xxxxxxxx');
    $API_Password = urlencode('xxxxxxxx');
    $API_Signature = urlencode('xxxxxxxxxxxxxxxxxxxxxxxxxxx');
    $API_Endpoint = "https://api-3t.paypal.com/nvp";
    if("sandbox" === $environment || "beta-sandbox" === $environment) {
        $API_Endpoint = "https://api-3t.$environment.paypal.com/nvp";
    }
    $version = urlencode('51.0');

    // setting the curl parameters.
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);

    // Set the curl parameters.
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);

    // Set the API operation, version, and API signature in the request.
    $nvpreq = "METHOD=$methodName_&VERSION=$version&PWD=$API_Password&USER=$API_UserName&SIGNATURE=$API_Signature$nvpStr_";

    // Set the request as a POST FIELD for curl.
    curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);

    // Get response from the server.
    $httpResponse = curl_exec($ch);

请帮我解决这个问题。

谢谢。

【问题讨论】:

    标签: security paypal payment-gateway


    【解决方案1】:

    请务必仔细检查您的 API 端点和版本:

    https://developer.paypal.com/webapps/developer/docs/classic/api/endpoints/

    【讨论】:

    • 链接已从网站中删除
    【解决方案2】:

    我的问题是由于 api 凭据不正确而发生的。即使输入了正确的沙盒 api 用户名、密码和 api 密钥,我仍然得到同样的错误。我重新创建了我的测试帐户,再次将它们输入到我的应用程序中,重新启动服务器,它就可以工作了。

    这里有一个来自 x.com 的链接,讨论了类似的问题:paypal security header issue

    【讨论】:

      【解决方案3】:

      您应该更改您的 Endpoint api.sandbox.paypal.com,它对我有用 首先您登录到帐户发送箱并签入标签应用程序

      【讨论】:

        【解决方案4】:

        user2230647 是对的。如果您想在沙盒模式下进行测试,您需要拥有以下所有参数的沙盒信息:

        'api_endpoint'  => 'https://api-3t.sandbox.paypal.com/nvp', 
        'api_username'  => 'example_api1.email.com', 
        'api_password'  => 'your_password', 
        'api_signature' => 'your_signature', 
        

        【讨论】:

          【解决方案5】:
          1. 转到https://developer.paypal.com/developer/accounts

          2. 登录

          3. 创建企业帐户

          4. 点击企业账户,点击profile,点击API Credentials,使用https://api-3t.sandbox.paypal.com/nvp访问api

          【讨论】:

            猜你喜欢
            • 2014-04-05
            • 2014-06-15
            • 2016-06-28
            • 2020-05-19
            • 2015-07-01
            • 2016-07-15
            • 2014-06-18
            • 2014-06-23
            • 2014-06-09
            相关资源
            最近更新 更多