creagia / laravel-redsys

Integrate your Laravel application with Redsys, the lead payment gateway in Spain.
MIT License
11 stars 3 forks source link

cURL error 28 on localhost #38

Closed jcerdan closed 5 months ago

jcerdan commented 10 months ago

Hi,

I get this error on local environment

cURL error 28: Operation timed out after 30003 milliseconds with 0 bytes received (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for http://localhost:8000/redsys/notification

I'm not using Laravel Sail, but Laravel under php 8.2.13 on local computer.

I have set in .env the value

REDSYS_ENVIRONMENT=local

I'm using this to connect to local gateway (and it works fine)


$redsysRequest = RequestBuilder::newRequest(
                new \Creagia\Redsys\Support\RequestParameters(
                    transactionType: \Creagia\Redsys\Enums\TransactionType::Autorizacion,
                    productDescription: 'products',
                    amountInCents: $cart->amount_total,
                    currency: Currency::EUR,
                    payMethods: \Creagia\Redsys\Enums\PayMethod::Card,
                )
            );
            return $redsysRequest->redirect();
' ' ' 

I have tried several things, but can't get the notification URL to be contacted and so no events are fired.
How could I solve that?

Best regards
dtorras commented 10 months ago

I'm investigating it because I've just found it's the same problem on Laravel Sail and php artisan serve. Both start a single-threaded php process that can't handle multiple requests when notifying the fake Redsys response.

While I work on a solution for artisan serve, you can use it with Laravel Valet or any other nginx/apache server.

jcerdan commented 10 months ago

Ok thanks.

With what you say I have found a workaround with php artisan serve I have started a new server on port 8001 and add the merchantURL to the request:

$redsysRequest = RequestBuilder::newRequest(
                new \Creagia\Redsys\Support\RequestParameters(
                    transactionType: \Creagia\Redsys\Enums\TransactionType::Autorizacion,
                    productDescription: 'products',
                    amountInCents: $cart->amount_total,
                    currency: Currency::EUR,
                    payMethods: \Creagia\Redsys\Enums\PayMethod::Card,
                    merchantUrl: 'http://localhost:8001/redsys/notification'
                )
            );

That makes the notification URL go to port 8001 and the system works fine then. (haven't yet checked that events are fired ok, but I think there should not be any problem)

dtorras commented 5 months ago

Hi, I'm closing this issue because this has been fixed in the latest release. If you need this in v2, I would appreciate a PR porting this solution to the v2 branch. Thanks.