diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e2b8f6..74f6d1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ All notable changes to `laravel-redsys` will be documented in this file. ## 3.0.0 - 2024-06-02 +- New: Local gateway is refactored to work with Sail, `artisan serve` or any other single threaded server. - New: Improved REST integration with handled responses. - Breaking: Updated database schema to allow different transaction types (refunds for example) with the same order number. diff --git a/src/Controllers/RedsysLocalGatewayController.php b/src/Controllers/RedsysLocalGatewayController.php index 8feb7f9..e7798fc 100644 --- a/src/Controllers/RedsysLocalGatewayController.php +++ b/src/Controllers/RedsysLocalGatewayController.php @@ -4,7 +4,6 @@ use Creagia\Redsys\RedsysResponse; use Illuminate\Http\Request; -use Illuminate\Support\Facades\Http; class RedsysLocalGatewayController { @@ -33,8 +32,13 @@ public function post(Request $request): \Illuminate\Http\RedirectResponse|\Illum ); if (isset($params['DS_MERCHANT_MERCHANTURL'])) { - Http::withoutVerifying() - ->post($params['DS_MERCHANT_MERCHANTURL'], $fakeGateway->getResponse($request->responseCode)); + // https://stackoverflow.com/questions/61703814/guzzle-cannot-send-a-web-request-to-the-same-server + $request = Request::create( + $params['DS_MERCHANT_MERCHANTURL'], + 'POST', + $fakeGateway->getResponse($request->responseCode) + ); + app()->handle($request); } return $authorised @@ -53,7 +57,13 @@ public function rest(Request $request): \Illuminate\Http\JsonResponse ); if (isset($params['DS_MERCHANT_MERCHANTURL'])) { - Http::post($params['DS_MERCHANT_MERCHANTURL'], $fakeGateway->getResponse($request->responseCode)); + // https://stackoverflow.com/questions/61703814/guzzle-cannot-send-a-web-request-to-the-same-server + $request = Request::create( + $params['DS_MERCHANT_MERCHANTURL'], + 'POST', + $fakeGateway->getResponse($request->responseCode) + ); + app()->handle($request); } return response()->json();