CheckoutFinland / psp-api

5 stars 5 forks source link

Is there a reliable way of polling payment status? #37

Closed niklasmannila closed 4 years ago

niklasmannila commented 5 years ago

The current documentation states that the GET endpoint has not yet been implemented but it does reply with a object that has a 'state'-attribute. I need to be able to check that a payment has failed or succeeded so that I can do some own handling for the item that is waiting for payment. It seems that the GET endpoint is currently replying with the legacy api payment statuses (integer ranging from -10 to 10). I could simply interpret the status using the old documentation but I am afraid that the format of the reply and/or status will change once you get it implemented officially.

Is there some way that I can check if a payment is in 'ok' or 'fail' state? I am already handling it in the callback (which responds with 'ok' and 'fail' as status) but I would like to have some other way of checking it at a later point if for example our server isn't responding at the time of the callback.

vesse commented 5 years ago

Yes the status endpoint has unfortunately been pending for a while but I do have some good news - it is the next thing we'll be working with and will be published in about two weeks. Would be great you can live with the current one till then. Starting next week the callback polling will retry with intervals which should further help with payment registration in case your server isn't responding.

niklasmannila commented 5 years ago

Thank you for the quick reply! That is truly good news :) I can live with it till then, we will go to production sometime before the end of this year so I will have good time to study the new status endpoint.

Also fantastic news about the polling with retry intervals. A slight follow-up question to that. The document states that it might reply with 'pending' or 'delayed' as well. Does that mean that it would initially send the 'pending' status to the callback and then once the status resolves to either 'ok' or 'fail' it would send that status to the callback at a later point?

It would be great if you could list those payment types that could cause the 'delayed' state since it is mentioned that it might take several days to complete. We can not allow that payment method for our use case since we need to verify the payment within 15 minutes from the start of the transaction.

niklasmannila commented 5 years ago

The company I work at were in contact with the good people of Checkout Finland and we got some answers to these questions in case someone is interested.

Currently the "Collector" providers are the only ones that can take long and cause the 'delayed' state. Also "Jousto" was mentioned as a provider that might not respond immediately either. If the payment is delayed it will ping the updated status to the 'callbackUrls' if provided.

vesse commented 5 years ago

@niklasmannila I was a little bit too optimistic with the schedule but the updated status API is now finally live. And sorry for not replying to your questions, need to update my notification settings.

loueranta commented 4 years ago

The updated GET endpoint documentation can be found here: https://checkoutfinland.github.io/psp-api/#/?id=get