Skip to content

Commit

Permalink
Improve post method response
Browse files Browse the repository at this point in the history
  • Loading branch information
dtorras committed Jun 2, 2024
1 parent 804c574 commit bd00818
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/RedsysRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/Support/PostRequestError.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class PostRequestError
public function __construct(
public string $code,
public ?string $message,
public array $responseParameters = [],
) {
}
}

0 comments on commit bd00818

Please sign in to comment.