From dd8250900895daf911230db10177e40a98530f9f Mon Sep 17 00:00:00 2001 From: Deon George Date: Sat, 13 May 2023 21:58:49 +1000 Subject: [PATCH] Add get an individual payment --- src/API.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/API.php b/src/API.php index c235a5f..1942a38 100644 --- a/src/API.php +++ b/src/API.php @@ -8,7 +8,7 @@ use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Log; use Intuit\Exceptions\{ConnectionIssueException,InvalidQueryResultException}; -use Intuit\Models\{ProviderToken}; +use Intuit\Models\{ProviderToken,Payment}; use Intuit\Response\{Customer,Invoice,ListList}; final class API @@ -289,6 +289,26 @@ final class API return new ListList($this->execute('query',$parameters),$key); } + /** + * Get a specific payment record + * + * @param int $id + * @param array $parameters + * @return Payment + * @throws \Exception + */ + public function getPayment(int $id,array $parameters=[]): Payment + { + Log::debug(sprintf('%s:Get a specific payment [%d]',static::LOGKEY,$id)); + + $x = $this->execute('payment/'.$id,$parameters); + + if (! $x->Payment) + throw new InvalidQueryResultException(sprintf('%s:Query response malformed',self::LOGKEY)); + + return new Payment((array)$x->Payment); + } + /** * Get a list of our payments *