【问题标题】:Paypal API - GetVerifiedStatus - Invalid requestPaypal API - GetVerifiedStatus - 无效请求
【发布时间】:2013-07-25 09:20:12
【问题描述】:

我正在尝试将 Paypal API 集成到我的 PHP 应用程序中。我使用 cURL 调用远程方法 GetVerifiedStatus,但收到错误 580023 - Invalid Request.

我的要求:

 'requestEnvelope.errorLanguage=en_US&requestEnvelope.detailLevel=ReturnAll&emailAddress=email%40address.com&firstName=John&lastName=Doe&matchCriteria=NAME'

转换为 JSON 后的响应:

{
        "responseEnvelope.timestamp":"2013-07-25T05:36:26.695-07:00",
        "responseEnvelope.ack":"Failure",
        "responseEnvelope.correlationId":"e540c8c04a5b4",
        "responseEnvelope.build":"6679946",
        "error(0).errorId":"580023",
        "error(0).domain":"PLATFORM",
        "error(0).subdomain":"Application",
        "error(0).severity":"Error",
        "error(0).category":"Application",
        "error(0).message":"Cannot determine PayPal Account status"

}

cURL 代码

function hash_call_account($methodName, $nvpStr)
    {
        //declaring of global variables

        $this->API_Endpoint_Adaptive_Account .= "/" . $methodName;

        //setting the curl parameters.
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL,$this->API_Endpoint_Adaptive_Account);
        curl_setopt($ch, CURLOPT_VERBOSE, 1);

        //turning off the server and peer verification(TrustManager Concept).
        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 HTTP Headers
        curl_setopt($ch, CURLOPT_HTTPHEADER,  array(
            'X-PAYPAL-REQUEST-DATA-FORMAT: NV',
            'X-PAYPAL-RESPONSE-DATA-FORMAT: NV',
            'X-PAYPAL-SECURITY-USERID: ' . $this->API_UserName,
            'X-PAYPAL-SECURITY-PASSWORD: ' .$this->API_Password,
            'X-PAYPAL-SECURITY-SIGNATURE: ' . $this->API_Signature,
            'X-PAYPAL-APPLICATION-ID: ' . $this->API_AppID
        ));

        //if USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled.
        //Set proxy name to PROXY_HOST and port number to PROXY_PORT in constants.php 
        if($this->USE_PROXY)
            curl_setopt ($ch, CURLOPT_PROXY, $this->PROXY_HOST. ":" . $this->PROXY_PORT); 

        // RequestEnvelope fields
        $detailLevel    = urlencode("ReturnAll");   // See DetailLevelCode in the WSDL for valid enumerations
        $errorLanguage  = urlencode("en_US");       // This should be the standard RFC 3066 language identification tag, e.g., en_US

        // NVPRequest for submitting to server
        $nvpreq = "requestEnvelope.errorLanguage=$errorLanguage&requestEnvelope.detailLevel=$detailLevel";
        $nvpreq .= "&$nvpStr";
        //echo $nvpreq; die;
        //setting the nvpreq as POST FIELD to curl
        curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);

        //getting response from server
        $response = curl_exec($ch);

        //converting NVPResponse to an Associative Array
        $nvpResArray=$this->deformatNVP($response);
        $nvpReqArray=$this->deformatNVP($nvpreq);
        $_SESSION['nvpReqArray']=$nvpReqArray;

        if (curl_errno($ch)) 
        {
            // moving to display page to display curl errors
              $_SESSION['curl_error_no']=curl_errno($ch) ;
              $_SESSION['curl_error_msg']=curl_error($ch);

              //Execute the Error handling module to display errors. 
        } 
        else 
        {
             //closing the curl
            curl_close($ch);
        }

        return $nvpResArray;
    }

配置:

Configure::write('ParallelPayPalAPI.URL', 'https://svcs.sandbox.paypal.com/AdaptivePayments');
Configure::write('ParallelPayPalAPI.AdaptiveAccountURL', 'https://svcs.sandbox.paypal.com/AdaptiveAccounts');
Configure::write('ParallelPayPalAPI.api_username', user);
Configure::write('ParallelPayPalAPI.api_password', password);
Configure::write('ParallelPayPalAPI.api_signature', signature);
Configure::write('ParallelPayPalAPI.business', business);
Configure::write('ParallelPayPalAPI.PaymentDetailUrl', 'https://svcs.sandbox.paypal.com/AdaptivePayments/PaymentDetails');
Configure::write('ParallelPayPalAPI.AppID', AppId);

可能是 API 版本的问题? NVP请求有问题吗?

【问题讨论】:

    标签: php paypal


    【解决方案1】:

    我遇到了同样的问题并联系了贝宝技术支持,解决方案很简单,错误 580023 是当名称与贝宝帐户的电子邮件不匹配时的正常行为。这是令人困惑的,因为与响应消息所暗示的相反,请求根本没有错。因此,对于您的示例,如果您遇到同样的问题,那么您只需将 John Doe 更改为与您尝试匹配的贝宝电子邮件相关联的用户的名字和姓氏。

    我使用 paypal MTS 的成绩单:

    “您收到的错误是预期的。为了获得已验证或未验证的响应,您提供的姓名必须与您提供的电子邮件地址相匹配。”

    【讨论】:

      【解决方案2】:

      试试这个

      curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); 
      

      而不是

      curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
      

      【讨论】:

        【解决方案3】:

        Paypal Docs

        580023  Invalid Request.
        

        错误代码表明这是一个无效请求,所以这是您发送的问题,您能提供您的实际请求吗?

        【讨论】:

        • 我在我的问题中提供了它:'requestEnvelope.errorLanguage=en_US&requestEnvelope.detailLevel=ReturnAll&emailAddress=email%40address.com&firstName=John&lastName=Doe&matchCriteria=NAME'
        • 代码+配置已发布
        猜你喜欢
        • 2015-08-08
        • 2019-01-13
        • 2014-09-27
        • 2011-12-12
        • 2013-12-13
        • 1970-01-01
        • 2015-04-29
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多