mirror of
https://github.com/anikeen-com/id.git
synced 2026-11-02 21:59:33 +00:00
Support third-party checkout confirmation
Orders and subscriptions created by untrusted apps are confirmed by the user on Anikeen ID. confirmationUrl($returnUrl) on Order and Subscription builds the link with the return URL; checking out such a draft throws ConfirmationRequiredException carrying the same URL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0fce38f48a
commit
f20a12e6da
8 files changed
+174
No files matched your search
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Anikeen\Id\Resources;
|
||||
|
||||
use Anikeen\Id\Exceptions\ConfirmationRequiredException;
|
||||
use Anikeen\Id\Exceptions\ResourceException;
|
||||
use Anikeen\Id\Result;
|
||||
use JsonSerializable;
|
||||
@@ -19,6 +20,14 @@ abstract class BaseResource implements JsonSerializable
|
||||
$this->result = $callable();
|
||||
|
||||
if (!$this->result->success()) {
|
||||
if (($this->result->data->error ?? null) === 'confirmation_required') {
|
||||
throw new ConfirmationRequiredException(
|
||||
$this->result->data->message ?? 'The user has to confirm this on Anikeen ID.',
|
||||
$this->result->response->getStatusCode(),
|
||||
$this->result->data->confirmation_url ?? null,
|
||||
);
|
||||
}
|
||||
|
||||
throw new ResourceException(sprintf('%s for resource [%s]', rtrim($this->result->data->message, '.'), get_called_class()), $this->result->response->getStatusCode());
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user