From bd008184c67f5d51c2144328712be6c5b3e60637 Mon Sep 17 00:00:00 2001 From: David Torras Date: Sun, 2 Jun 2024 18:08:31 +0200 Subject: [PATCH] Improve post method response --- src/RedsysRequest.php | 7 +++---- src/Support/PostRequestError.php | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/RedsysRequest.php b/src/RedsysRequest.php index 206db49..3e95e17 100644 --- a/src/RedsysRequest.php +++ b/src/RedsysRequest.php @@ -97,12 +97,10 @@ public function getRedirectFormHtml(): string } /** - * @throws DeniedRedsysPaymentResponseException - * @throws ErrorRedsysResponseException * @throws GuzzleException * @throws InvalidRedsysResponseException */ - public function sendPostRequest(): NotificationParameters|PostRequestError + public function sendPostRequest(): RedsysResponse|PostRequestError { $client = new Client(); $this->parameters->directPayment = DirectPayment::True; @@ -121,11 +119,12 @@ public function sendPostRequest(): NotificationParameters|PostRequestError try { $redsysResponse->setParametersFromResponse($responseContents); - return $redsysResponse->checkResponse(); + return $redsysResponse; } catch (RedsysCodeException $exception) { return new PostRequestError( code: $exception->redsysCode, message: $exception->getMessage(), + responseParameters: $responseContents, ); } } diff --git a/src/Support/PostRequestError.php b/src/Support/PostRequestError.php index 6601a45..b925e21 100644 --- a/src/Support/PostRequestError.php +++ b/src/Support/PostRequestError.php @@ -7,6 +7,7 @@ class PostRequestError public function __construct( public string $code, public ?string $message, + public array $responseParameters = [], ) { } }