2014-01-06 33 views
2

我創建了一個PayPal羣發支付應用程序,但它的迴應是「資金不足」錯誤。下面paypal masspay:回覆資金不足

代碼給出:

  <?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' => "[email protected]", 
             '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賬戶上進行調整的設置?

回答

0

您發送的帳戶(通常與API調用者相同)需要有足夠的資金餘額才能發送大量付款。

我看到你正在使用默認的'服務商'帳戶;這通常只用於測試REST API。

繼續操作,通過應用程序>沙箱帳戶創建一個測試帳戶,並給它一個10k美元的慷慨餘額。這應該整理出來。

+0

謝謝!期待你的答覆。 我已經創建了另一個企業帳戶,但它不提供API憑據。 –

0

我有和上面相同的問題。以下是我如何解決問題。

第1步: 轉到相應的沙箱帳戶,並檢查帳戶餘額的資助標籤。 (如果您有0美元,您可以輕鬆創建新用戶並分配足夠的餘額,例如$ 10K)

第2步: 將API憑據切換到具有足夠餘額的新用戶。現在再次調用API。

此API請求也給我資金不足,因​​爲我在帳戶中添加了10K SGD,並在進行API調用時製作了20USD交易。

因此請檢查您的貨幣和相應的貨幣餘額。

0

導致此問題的另一個方案中,可能是幫助別人:

我發送帳戶似乎只與GBP工作的質量支付和我在USD發送(必須是它的設置方式) 。有趣的是,因爲同一賬戶可以使用REST API接受美元付款,這就是爲什麼我花了一段時間才弄清楚。