diff --git a/src/Gateway.php b/src/Gateway.php index bc45852..a9bebb4 100644 --- a/src/Gateway.php +++ b/src/Gateway.php @@ -290,4 +290,22 @@ public function fetchTransaction(array $parameters = array()) { return $this->createRequest('\Omnipay\Braintree\Message\FindRequest', $parameters); } + + /** + * Find transactions by criteria + * + * Example usage: + * + * $collections = $brainTree->findTransactions(['customerId' => '12345678']); + * + * The parameter key has to one of the static methods from \Braintree\TransactionSearch + * @see https://developers.braintreepayments.com/reference/request/transaction/search/php + * + * @param array $parameters + * @return mixed|\Omnipay\Common\Message\AbstractRequest + */ + public function findTransactions(array $parameters = array()) + { + return $this->createRequest('\Omnipay\Braintree\Message\FindTransactions', $parameters); + } } diff --git a/src/Message/FindTransactions.php b/src/Message/FindTransactions.php new file mode 100644 index 0000000..92254ab --- /dev/null +++ b/src/Message/FindTransactions.php @@ -0,0 +1,30 @@ +getParameters(); + + $data = array(); + + foreach ($parameters as $parameterName => $value) { + if (method_exists('Braintree_TransactionSearch', $parameterName)) { + $search = call_user_func("\Braintree_TransactionSearch::$parameterName"); + $data[] = $search->is($value); + } + } + return $data; + } + + public function sendData($data) + { + $response = $this->braintree->transaction()->search($data); + + return $this->createResponse($response); + } +}