D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
tattooscyy
/
test
/
app
/
Libs
/
OnlinePayments
/
Sdk
/
Filename :
DeclinedRefundException.php
back
Copy
<?php /* * This file was automatically generated. */ namespace App\Libs\OnlinePayments\Sdk; use App\Libs\OnlinePayments\Sdk\Domain\RefundErrorResponse; use App\Libs\OnlinePayments\Sdk\Domain\RefundResponse; use App\Libs\Sdk\Domain\DataObject; /** * Class DeclinedRefundException * * @package OnlinePayments\Sdk */ class DeclinedRefundException extends ResponseException { /** * @param int $httpStatusCode * @param DataObject $response * @param string|null $message */ public function __construct(int $httpStatusCode, DataObject $response, ?string $message = null) { if (is_null($message)) { $message = DeclinedRefundException::buildMessage($response); } parent::__construct($httpStatusCode, $response, $message); } private static function buildMessage(DataObject $response): string { if ($response instanceof RefundErrorResponse && $response->refundResult != null) { $refundResult = $response->refundResult; return "declined refund '$refundResult->id' with status '$refundResult->status'"; } return 'the payment platform returned a declined refund response'; } /** * @return RefundResponse */ public function getRefundResponse() { $responseVariables = get_object_vars($this->getResponse()); if (!array_key_exists('refundResult', $responseVariables)) { return new RefundResponse(); } $refundResult = $responseVariables['refundResult']; if (!($refundResult instanceof RefundResponse)) { return new RefundResponse(); } return $refundResult; } }