2

我创建了一个 Paypal 批量支付应用程序,但它响应“资金不足”错误。

代码如下:

            <?php
            $environment = 'sandbox';   // or 'beta-sandbox' or 'live'

            function PPHttpPost($methodName_, $nvpStr_) {
                global $environment;


                $API_UserName = urlencode('myusername-facilitator_api1.gmail.com');
                $API_Password = urlencode('1363173069');
                $API_Signature = urlencode('AIocgW-6xeVUBXWE8pFoChIyO4ClAMlqzb9NjIHfm7tgCjquZayeYDUC');
                $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');

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

                // Turn 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 API operation, version, and API signature in the request.
                $nvpreq = "METHOD=$methodName_&VERSION=$version&PWD=$API_Password&USER=$API_UserName&SIGNATURE=$API_Signature$nvpStr_";
                //print_r($nvpreq);exit;
                // Set the request as a POST FIELD for curl.
                curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);

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

                if(!$httpResponse) {
                    exit("$methodName_ failed: ".curl_error($ch).'('.curl_errno($ch).')');
                }

                // Extract the response details.
                $httpResponseAr = explode("&", $httpResponse);

                $httpParsedResponseAr = array();
                foreach ($httpResponseAr as $i => $value) {
                    $tmpAr = explode("=", $value);
                    if(sizeof($tmpAr) > 1) {
                        $httpParsedResponseAr[$tmpAr[0]] = $tmpAr[1];
                    }
                }

                if((0 == sizeof($httpParsedResponseAr)) || !array_key_exists('ACK', $httpParsedResponseAr)) {
                    exit("Invalid HTTP Response for POST request($nvpreq) to $API_Endpoint.");
                }

                return $httpParsedResponseAr;
            }

            // Set request-specific fields.
            $emailSubject =urlencode('example_email_subject');
            $receiverType = urlencode('EmailAddress');
            $currency = urlencode('USD');                           // or other currency ('GBP', 'EUR', 'JPY', 'CAD', 'AUD')

            // Add request-specific fields to the request string.
            $nvpStr="&EMAILSUBJECT=$emailSubject&RECEIVERTYPE=$receiverType&CURRENCYCODE=$currency";

            $receiversArray = array();

            for($i = 0; $i < 3; $i++) {
                $receiverData = array(  'receiverEmail' => "bhavin.radidya@gmailcom",
                                        'amount' => "10",
                                        'uniqueID' => "13",
                                        'note' => "test Payment");
                $receiversArray[$i] = $receiverData;
            }

            foreach($receiversArray as $i => $receiverData) {
                $receiverEmail = urlencode($receiverData['receiverEmail']);
                $amount = urlencode($receiverData['amount']);
                $uniqueID = urlencode($receiverData['uniqueID']);
                $note = urlencode($receiverData['note']);
                $nvpStr .= "&L_EMAIL$i=$receiverEmail&L_Amt$i=$amount&L_UNIQUEID$i=$uniqueID&L_NOTE$i=$note";
            }

            // Execute the API operation; see the PPHttpPost function above.
            $httpParsedResponseAr = PPHttpPost('MassPay', $nvpStr);

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

我已经正确配置了所有参数,但它仍然返回此错误响应。我必须在 PayPal 帐户上调整设置吗?

4

3 回答 3

1

我遇到了与上面相同的问题。这是我解决问题的方法。

第 1 步:进入相应的沙盒账户并检查账户余额的资金选项卡。(如果您有 0 美元,您可以轻松创建一个新用户并分配足够的余额作为余额,例如 $10K)

第 2 步:将 API 凭证切换到具有足够余额的新用户。现在再次调用 API。

这个 API 请求也给了我不足的资金,因为我在我的帐户中添加了 10K SGD,并且在进行 API 调用时我进行了 20 美元的交易。

因此,请检查您的货币和该货币的相应余额。

于 2014-12-29T17:40:48.133 回答
0

您发送的帐户(通常与 API 调用者相同)需要有足够的余额才能发送大量付款。

我看到您使用的是默认的“促进者”帐户;这个通常仅用于测试 REST API。

继续通过应用程序 > 沙盒帐户创建一个测试帐户,并为其提供 1 万美元的丰厚余额。那应该解决它。

于 2014-01-06T20:01:30.430 回答
0

导致此问题的另一种情况可能对某人有帮助:

我的发送账户似乎只能使用英镑进行大宗支付,而且我是以美元发送的(必须是它的设置方式)。有趣的是,同一个帐户可以使用 REST API 接受美元付款,这就是为什么我花了一段时间才弄清楚的原因。

于 2015-06-17T14:15:17.110 回答