Skip to content

Commit

Permalink
Fix parameters to transaction search and add error detail
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Waters committed Jun 25, 2015
1 parent 05a9f13 commit ba3cd44
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/PaypalPHP/Managers/TransactionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
namespace PaypalPHP\Managers;
use PaypalPHP\Exceptions\TransactionSearchException;
use PaypalPHP\Helpers\UrlHelper;
use PaypalPHP\Responses\TransactionSearchResponse;

/**
Expand Down Expand Up @@ -46,7 +47,7 @@ public function transactionSearch(array $searchParameters)
$url .= "?METHOD=TransactionSearch&VERSION=114.0";
$url .= "&USER=" . $this->_config["username"];
$url .= "&PWD=" . $this->_config["password"];
$url .= "&SIGNATURE=" . $this->_config["signature"] . "&";
$url .= "&SIGNATURE=" . $this->_config["signature"];
if(count($searchParameters) == 0)
{
throw new TransactionSearchException("At least one search parameter must be specified");
Expand All @@ -58,7 +59,7 @@ public function transactionSearch(array $searchParameters)
{
throw new TransactionSearchException("$parameter is not a valid search parameter");
}
$url .= $parameter . "=" . urlencode($value);
$url .= "&" . $parameter . "=" . urlencode($value);
}
curl_setopt($localClient, CURLOPT_URL, $url);
$rawResponse = curl_exec($localClient);
Expand All @@ -75,7 +76,9 @@ public function transactionSearch(array $searchParameters)
$key = strtolower($responseValues[0]);
if($key == "ack" && $responseValues[1] != "Success")
{
throw new TransactionSearchException("Could not perform search: $rawResponse");
$error = new \stdClass();
UrlHelper::urlToObject($rawResponse, $error);
throw new TransactionSearchException("Could not perform search: " . $error->l_shortmessage0 . "(" . $error->l_longmessage0 . ")");
}
$matches = array();
if(preg_match($filter, $key, $matches))
Expand Down

0 comments on commit ba3cd44

Please sign in to comment.