Skip to content

Commit

Permalink
Fix local gateway for single thread server (#63)
Browse files Browse the repository at this point in the history
* loca-gateway: handle post notification instead of posting an Http request

* Fix styling

* update changelog

---------

Co-authored-by: dtorras <[email protected]>
  • Loading branch information
dtorras and dtorras authored Jun 2, 2024
1 parent b812681 commit 055d424
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
18 changes: 14 additions & 4 deletions src/Controllers/RedsysLocalGatewayController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Creagia\Redsys\RedsysResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;

class RedsysLocalGatewayController
{
Expand Down Expand Up @@ -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
Expand All @@ -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();
Expand Down

0 comments on commit 055d424

Please sign in to comment.