# Exception Handling

## 1. Order Status is Not Final

If a final order status cannot be attained within the checkout session and the order status remains "PENDING," Optty employs an asynchronous process. This process will either continue to poll the APM's API or listen for order status updates from the APM until a final status (successful, canceled, or declined) is received.

To handle this exception, merchants should implement a listener that can asynchronously receive the final order status event from Optty. This listener will then trigger an action to update the order status in the merchant system and customer checkout, reflecting the final payment update for the order.

{% hint style="info" %}
This exception can also occur for refunds, please refer to the REFUND\_CALLBACK on [Notification Handling](/universal-integration-features/notification-handling.md)
{% endhint %}

The diagram below illustrates this scenario.

<figure><img src="/files/ytcSKTm3yyHjNMHzV9Wu" alt=""><figcaption></figcaption></figure>

## 2. Communication of Status Update to Customer Fails

This exception often arises when a merchant attempts to inform the customer of their payment outcome during the checkout session after a redirect, but this fails because the customer exits the journey after the payment is complete. This usually happens if the customer closes their browser before the process concludes or if there are network issues between the merchant and the customer.

Should the customer prematurely end the checkout session before a final order status is received from the APM, the asynchronous process detailed in "exception 1" should be used to communicate the final status.

To manage this exception, merchants ought to update the customer on the final payment status of their order via email or another asynchronous messaging tool.

<figure><img src="/files/sGBXnsDw18T0vQcEH97a" alt=""><figcaption></figcaption></figure>

\
\ <br>


---

# 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://docs.optty.com/universal-integration-features/exception-handling.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.
