Skip to main content

Checking the payment status in the payment gateway system via the REST API

Using a payment status query you can check the status of any payment belonging to the merchant's business account at any time.

💡 GoPay tip:
A payment status query has to be authorised using a token. The token for a payment status query can be created in scope=payment-create. You will find more information about the process of obtaining a token in the article payment gateway integration procedure.

A payment status query can be made via an API request.

The response to the request is an object describing the parameters and the state of the given payment.

A payment can have various states, see the REST API documentation.


​

When to query the payment status

We recommend querying the payment status as standard in two situations.

Return to the merchant outlet (return_url) after the payment is made.

  • As part of the redirect to return_url we pass the merchant outlet the GET parameter ?id= in the URL, which contains the id of the payment the return is coming from.

  • Using the id you look up the order in the database and make a payment status query.

  • According to the status obtained, you display the relevant information to the customer or update the status in the database.

After receiving an HTTP notification.

  • Whenever the payment state changes on a payment of the given business account (except for the states CREATED and PAYMENT_METHOD_CHOSEN), we send an asynchronous HTTP notification to the notification URL passed when creating the payment.

  • The notification has the same format as the redirect to return_url, i.e. the parameter ?id=<payment id>.

  • Using the payment id it is advisable to look up the order the payment belongs to, make a payment status query, compare it with the status in the database and, if necessary, update the status in the database.

The expected value for the merchant outlet receiving the HTTP notification is the status HTTP 200. If the merchant outlet returns any other status, the payment gateway system considers the HTTP notification undelivered and tries to send it again repeatedly (with a finite number of at most 20 delivery attempts).

The payment status query can be made at any time, as the merchant outlet needs. Never make the query in a loop, however.

For correct information about all payment states it is sufficient to check the status after the return to return_url and after notification_url is invoked.


​

Related articles

Did this answer your question?