Adyen/adyen-php-api-library

Getting curl timeout on success calls with runTenderSync() on send POS terminal a payment

VictorMetzler opened this issue · 20 comments

You would call it something like:

$adyen = (new Client())->getAdyenClient();
(new PosPayment($adyen))->runTenderAsync($request_body);

See https://docs.adyen.com/point-of-sale/basic-tapi-integration/make-a-payment on what to put in the request body

Originally posted by @gjghendriks in #429 (comment)

Hi there, I can now send a payment to POS terminal, but some new things came out.

When I call the indicated method ( runTenderSync, not async, becouse I need the return of te call as indicated on https://docs.adyen.com/point-of-sale/basic-tapi-integration/make-a-payment#payment-response ), I get a timeout of your curl call, this happens every time I got a success call, all rejected calls is ok:

"Could not connect to Adyen (https://terminal-api-live.adyen.com/sync). Please check your internet connection and try again. (Network error [errno 28]: Operation timed out after 8001 milliseconds with 0 bytes received)"

How can I increase curl's wait time or is this something that needs to be fixed on your side?

Another thing, how can I indicate in JSON the properties of the payment, where is it an Debit or Credit and the number of installmnets ?

My example:

{
"SaleToPOIRequest": {
"MessageHeader": {
"ProtocolVersion": "3.0",
"MessageClass": "Service",
"MessageCategory": "Payment",
"MessageType": "Request",
"ServiceID": "U19T999P22",
"SaleID": "0304232",
"POIID": "V240mPlus-XXXXXXXXX"
},
"PaymentRequest": {
"SaleData": {
"SaleTransactionID": {
"TransactionID": "PP|1|1|0",
"TimeStamp": "2023-04-03T16:10:52+03:00"
}
},
"PaymentTransaction": {
"AmountsReq": {
"Currency": "BRL",
"RequestedAmount": 1
}
}
}
}
}

Hi @VictorMetzler,

Thanks for reaching out to us with this issue. Glad to hear you've been able to figure out the payment to a POS terminal with this library. The timeout on the curlclient you can set in the Config object that you pass along to the client. This line shows you the key in the config that you can set the timeout. The standard is 13 seconds (int value).

For instalments I recommend taking a look at this docs page (assuming you're using Brazilian instalments).

Best, Jilling
Adyen

Hi there, even passing timeout to 30 seconds, I got timeout on success calls:

"Could not connect to Adyen (https://terminal-api-live.adyen.com/sync). Please check your internet connection and try again.
(Network error [errno 28]: Operation timed out after 30001 milliseconds with 0 bytes received)"

try {
$service = new \Adyen\Service\PosPayment($this->adyen);
$service->getClient()->setTimeout(30);
$vReturnBody = $service->runTenderSync($params);
} catch (\Adyen\AdyenException $e) { <-- Just to ask, I'm not sure if this is right
don't fall here
} catch ( Exception $e) {
falls here
}

I'm testing with:

class Client
{
const LIB_VERSION = "14.0.1";

Hi @VictorMetzler,

Did you try making a call with your request in Postman or just using curl? This way you can verify the request you're trying to send has the right format and there is not something wrong with the setup using this library.

I just noticed as well that you're sending requests to the live endpoint? Is this by design? You can set the environment in the client.

Best, Jilling
Adyen

Hi @jillingk ,

I'm using adyen PHP SDK to make the request, the SDK uses CURL.

Only when an success call is made ( I know that because the information is received in the POS terminal) I get an timeout:

$vReturnBody = $service->runTenderSync($params);

I've put an JSON example in the comment above, can you help me ?

And yes, I'm in live endpoint, no problem for me.

Hi @VictorMetzler,

My bad, I did not mean the actually PHP client but instead the bash client curl [options…] <URL>. It was more a suggestion to double check that the actually json request you're sending is right.

Can you try it using the test endpoint first? A live endpoint requires a special setup, of which I'm not sure you have the permissions for. You can get your API test credentials here.

Best, Jilling
Adyen

Hi @jillingk ,

Thanks in advance for the replays.

I already use the live endpoints to all communication with Adyen, and the PHP SDK, just stumble with this particular problem.

If requires a special setup indicate please wich so I can perheaps ask to our company contact here in Brazil or configurate myself in Adyen admin page, but, again, the call works, only gets a timeout on success not returning the success JSON.

Is any other company utilizing this PHP SDK endpoit ? This works for everybody but me ? Ca you test with my abouve JSON example ? Have you seen my inner code PHP question for Adyen try exception part ?

Hi @VictorMetzler,

So you already followed these steps, and received live credentials? Why not just test it in our test environment first?

As for your request it looks fine to me tbh. As long as you follow the documentation there it's also all good. Tomorrow I can check out your request and test it myself, but I would still recommend you testing it yourself as well with postman or any other helpful tool outside of this library to double check that you have the right setup etc.

Hi @jillingk ,

Have you tried yourself to see the problem ?

Hello,

Still having the same problem, did you manage to test it?

Hi @VictorMetzler,

I've finally gotten around to testing it myself, and this request worked for me! Here is the code I used to get it working

$client = new Client();
        $client->setApplicationName("My Test Terminal API App");
        $client->setEnvironment(Environment::TEST);
        $client->setXApiKey("Your_API_Key");

        // initialize service
        $service = new PosPayment($client);

        //Construct request
        $transactionType = TransactionType::NORMAL;
        $serviceID = date("dHis");
        $timeStamper = date("Y-m-d") . "T" . date("H:i:s+00:00");

        $json = '{
                    "SaleToPOIRequest": {
                        "MessageHeader": {
                            "MessageType": "Request",
                            "MessageClass": "Service",
                            "MessageCategory": "Payment",
                            "SaleID": "PosTestLibrary",
                            "POIID": "Your POS machine code",
                            "ProtocolVersion": "3.0",
                            "ServiceID": "' . $serviceID . '"
                        },
                        "PaymentRequest": {
                            "SaleData": {
                                "SaleTransactionID": {
                                    "TransactionID": "POSauth",
                                    "TimeStamp": "' . $timeStamper . '"
                                },
                                "TokenRequestedType": "Customer",
                                "SaleReferenceID": "SalesRefABC"
                            },
                            "PaymentTransaction": {
                                "AmountsReq": {
                                    "Currency": "EUR",
                                    "RequestedAmount": ' . 14.91 . '
                                }
                            },
                            "PaymentData": {
                                "PaymentType": "' . $transactionType . '"
                            }
                        }
                    }
                }
            ';

        $params = json_decode($json, true); //Create associative array for passing along
        try {
            $result = $service->runTenderSync($params);
            print($result);
        } catch (\Exception $e) {
            print($e);
        }

In addition to this I also just tested the Async version of it which seems to work fine for me as well. Let me know if you're able to use this example to get your IPP integration working. If not I'll be happy to help you along.

Hello @jillingk ,

Thanks for trying, but, in the TEST environment it works fine, my problem, as said before, is in the LIVE environment, still getting timeout on success calls with no return data . . .

And one more thing, I have no POIID assign on Test environment, so, can't make sure that the request is a successful one, always returning "EventDetails": "message=Unknown+POIID+V240mPlus-999999999"

Hi @VictorMetzler,

Glad to hear that you test environment is working at least. For LIVE, can you try setting the region in the config? This docs page mentions that you need to set the region to the geographical closest location, for you that would be the US I think. Here you see that based on region a different live URL is used. You can set this region in the config object, through this param setter. Maybe this will do the trick.

For test environment you should be able to setup your pos machine the same way you did for live. You could always reach out to our CA/IPP support in case you're struggling to find out how.

Let me know if setting the region works for you!

Best, Jilling
Adyen

Hello, tested with regions 'eu', 'us', 'au' and getting same result, nothing on success calls.

Have you tried allowing the adyen IP in your firewall? https://docs.adyen.com/point-of-sale/design-your-integration/choose-your-architecture/cloud#configure-network

What about a call to this endpoint to check if you're terminal is connected well? You can do this using the library as well. That link also contains some more trouble shooting for disconnected terminals, I would recommend to look at that.

Since you keep getting timeouts I'm starting to think nothing is wrong with your code but instead maybe your terminal setup. Perhaps it would be smart as well if you or your point of contact reaches out to our support team to double check that the setup is correct.

@jillingk, thanks for your thots and help, I'll see if my firewall has those settings and test again, hopefully that is the problem.

So, I'v disabled the wifi and tested with the terminal 3g internal chip internet, same problem.

Just to ask, have you tried and successfully get an success JSON returning message ? even in test environment ? because to do that you have to have a terminal on the test merchant account...

I mean, if you initiate a payment you would get a payment prompt on your terminal and you would only get a response once your payment is completed. So let's say I initiate a payment, I get a prompt on my terminal, I pay with my test card (or penny test with a real card and low amount) and then I get indeed a success response with details about the payment. This is something I tested yesterday in the TEST environment (which is in some sense identical to LIVE) with a v400m terminal

So, that's the problem, you nailed :p

I'm waiting for a response without actually paying, assuming that I'll get an response just for the OK of the terminal receiving the payment packege to process, like it is in the asynchronous communication, that's what's deceived's me ...

Really sorry for wasting your time like that, hope if I ever came here with another "actual problem" you can again help me as you kindly had.

Hi @VictorMetzler,

Amazing! Glad that you were able to fix this.

Also don't worry about wasting my time, I learned something here as well as I hadn't used the POS setup in this library yet :)

If throughout this process you run into any other problem, you're always welcome to let us know here!

Best, Jilling
Adyen