mirror of
https://github.com/anikeen-com/id.git
synced 2026-11-06 15:48:36 +00:00
Bill elapsed periods on app subscription checkout
This commit is contained in:
3 files changed
+136
-4
No files matched your search
@@ -3,6 +3,7 @@
|
||||
namespace Anikeen\Id\Exceptions;
|
||||
|
||||
use Anikeen\Id\Result;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
@@ -44,6 +45,24 @@ class ApiException extends ResourceException
|
||||
return new static(sprintf('Anikeen ID is not reachable: %s', $previous->getMessage()), 0, null, $previous);
|
||||
}
|
||||
|
||||
/**
|
||||
* The JSON body of Anikeen ID's error response, null without one. Some errors carry details,
|
||||
* e.g. `net_amount` of "elapsed_amount_exceeded".
|
||||
*/
|
||||
public function body(): ?object
|
||||
{
|
||||
$previous = $this->getPrevious();
|
||||
$response = $previous !== null && method_exists($previous, 'getResponse') ? $previous->getResponse() : null;
|
||||
|
||||
if (!$response instanceof ResponseInterface) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$body = json_decode((string) $response->getBody());
|
||||
|
||||
return is_object($body) ? $body : null;
|
||||
}
|
||||
|
||||
public function isNotFound(): bool
|
||||
{
|
||||
return $this->status === 404;
|
||||
|
||||
Reference in new issue
Block a user