Php Paypal Masspay API Masspay输入解析错误

Php Paypal Masspay API Masspay输入解析错误,php,paypal,masspay,Php,Paypal,Masspay,我正在php中使用Paypal MassPay API 我的代码工作正常,但现在我得到了这个错误 MassPay failed: Array ( [TIMESTAMP] => 2014/07/06T17%3a27%3a04Z [CORRELATIONID] => 5d6bf81231859 [ACK] => Failure [VERSION] => 51%2e0 [BUILD] => 11753088 [L_ERRORCODE0] => 10314

我正在php中使用Paypal MassPay API

我的代码工作正常,但现在我得到了这个错误

MassPay failed: 
Array ( [TIMESTAMP] => 2014/07/06T17%3a27%3a04Z 
[CORRELATIONID] => 5d6bf81231859 
[ACK] => Failure 
[VERSION] => 51%2e0 
[BUILD] => 11753088 
[L_ERRORCODE0] => 10314 
[L_SHORTMESSAGE0] => Masspay input parse error 
[L_LONGMESSAGE0] =>The input to the masspay server is incorrect e Please make sure that you are using a correctly formatted input e 
[L_SEVERITYCODE0] => Error 
有人知道我现在为什么会犯这个错误吗?如果需要,我可以提供代码

这是主要课程:

Paypal_class.php

<?php

  class Paypal {

        public function __construct($username, $password, $signature) {
            $this->username = urlencode($username);
            $this->password = urlencode($password);
            $this->signature = urlencode($signature);
            $this->version = urlencode("51.0");
            $this->api = "https://api-3t.paypal.com/nvp";

            //The functions can be modified but need to be urlencoded
            $this->type = urlencode("EmailAddress");
            $this->currency = urlencode("USD");
            $this->subject = urlencode("Instant Paypal Payment");
        }

        public function pay($email, $amount, $note="Instant Payment") {
            $string = "&EMAILSUBJECT=".$this->subject."&RECEIVERTYPE=".$this->type."&CURRENCYCODE=".$this->currency;
            $string .= "&L_EMAIL0=".urlencode($email)."&L_Amt0=".urlencode($amount)."&L_NOTE0=".urlencode($note);

            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $this->api);
            curl_setopt($ch, CURLOPT_VERBOSE, 1);
            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);

            $request = "METHOD=MassPay&VERSION=".$this->version."&PWD=".$this->password."&USER=".$this->username."&SIGNATURE=".$this->signature."$string";

            curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
            $httpResponse = curl_exec($ch);
            if(!$httpResponse) {
                exit("MassPay failed: ".curl_error($ch).'('.curl_errno($ch).')');
            }

            $httpResponseArray = explode("&", $httpResponse);
            $httpParsedResponse = array();
            foreach ($httpResponseArray as $i => $value) {
                $tempArray = explode("=", $value);
                if(sizeof($tempArray) > 1) {
                    $httpParsedResponse[$tempArray[0]] = $tempArray[1];
                }
            }

            if((0 == sizeof($httpParsedResponse)) || !array_key_exists('ACK', $httpParsedResponse)) {
                exit("Invalid HTTP Response for POST request($request) to ".$this->api);
            }

            return $httpParsedResponse;
        }

    }
?>
使用example.php文件调用此类:

<?php

    require "paypal_class.php";
    $paypal = new Paypal("example.com", "xyz, "abc");

    $send_payment = $paypal->pay("abc@gmail.com", ".001", "Thanks for an amazing service");

    if("SUCCESS" == strtoupper($send_payment["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($send_payment["ACK"])) {
        exit('MassPay Completed Successfully: '.print_r($send_payment, true));
    } else {
        exit('MassPay failed: ' . print_r($send_payment, true));
    }
?>

谢谢,我能解决我的问题了。我将发送的金额从0.001更改为0.01,此代码有效。
可能是Paypal MassPay API不处理小数点后两位数以上的金额。

似乎在告诉您您的请求不正确。需要查看请求帮助的示例。谢谢!我在向这个问题添加代码,我不是要代码的示例,而是要从代码生成的原始API请求的示例。基本上,您从$request获得的最终值实际上传递到CURL中。贝宝显然不喜欢它收到的东西,所以我们需要看看它有什么问题。