Skip to content

Commit

Permalink
Added error reason to PayrexxException for refund endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Ueli Kramer committed Oct 6, 2022
1 parent f511648 commit 4141a1f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/Payrexx/Communicator.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,11 @@ public function performApiRequest($method, \Payrexx\Models\Base $model)
if (!isset($response['body']['message'])) {
throw new \Payrexx\PayrexxException('Payrexx PHP: Configuration is wrong! Check instance name and API secret', $response['info']['http_code']);
}
throw new \Payrexx\PayrexxException($response['body']['message'], $response['info']['http_code']);
$exception = new \Payrexx\PayrexxException($response['body']['message'], $response['info']['http_code']);
if (!empty($response['body']['reason'])) {
$exception->setReason($response['body']['reason']);
}
throw $exception;
}

$data = $response['body']['data'];
Expand Down
12 changes: 12 additions & 0 deletions lib/Payrexx/PayrexxException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* @copyright 2014 Payrexx AG
* @since v1.0
*/

namespace Payrexx;

/**
Expand All @@ -13,4 +14,15 @@
*/
class PayrexxException extends \Exception
{
private $reason = '';

public function getReason()
{
return $this->reason;
}

public function setReason($reason = '')
{
$this->reason = $reason;
}
}

0 comments on commit 4141a1f

Please sign in to comment.