# Completing order – payment flow

## Basic payment flow

If a validation of checkout is successful, an order will be created. Further processes are based on the selected payment method.

In all cases, customers will be redirected back to the 'Thank you page' informing them their order has been accepted.

When completing the Checkout, there are two types of responses based on the payment method:

* [Direct link to frontstore](#direct-link-to-frontstore)
* [Redirect to payment gateway](#redirect-to-payment-gateway)

### Direct link to frontstore

When using any bank, COD, and cash payments, customers will be redirected directly back to the success URL of your frontstore. There are no more actions needed.

### Redirect to payment gateway

When using card (online) payments or Klarna (a 'buy now, pay later' payment method), after the successful checkout, customers will get a redirect link directly to the payment website.

After redirecting back to the 'Thank you page', you need to make a payment check to our API endpoints, based on the selected payment method. This endpoint will check the status of a payment for you to confirm if it was successful or not.

All required parameters to make this API call will be included in the response URL from the payment gateway.

* [These API endpoints](https://demo.theshop.dev/api-documentation/v1#/cart) are for all cart services.
* [These API endpoints](https://demo.theshop.dev/api-documentation/v1#/payments) are for verifying payment status.

### Unsuccessful payment

There are several reasons why a payment may fail: insufficient funds, incorrect details, technical issues, card expiration, bank restrictions, daily transaction limits, etc.

In this case, after checking with our API endpoint, customer will be informed about the unsuccessful payment and get an e-mail with an advance invoice.

### Successful payment

After the successful payment and checking with our API endpoint, an order in TheShop administration will be marked as paid. Customer will be informed about the successful payment by an e-mail.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wiki.theshop.dev/docs/frontstore/basic-selling-flow/checkout/completing-order-payment-flow.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
