# Webhooks Configuration

[Webhooks](https://sandbox-doc.gitbook.io/ottu-team-sandbox-doc/developer/webhooks) is an HTTP endpoint that is used to receive notifications about events that occur in the Ottu system. For example, if a payment is created, Ottu can send a webhook notification to the merchant's server with the details of the payment. The merchant can then use this information to update their systems. Enhance your Ottu experience with our powerful Webhook Configuration. Take advantage of API payloads, SSL certificate verification options, error notifications, and more.

## [**Webhooks Configuration Walkthrough**](#webhooks-configuration-walkthrough)

To access the Webhook Configuration, navigate to Ottu Dashboard > Administration Panel > Webhook > Webhook Config

<figure><img src="https://content.gitbook.com/content/Tq4lCgHh9X4VXINxI3L9/blobs/3MX76rImb4IMkWrF970Q/webhook.png" alt=""><figcaption></figcaption></figure>

### [General](#general)

<figure><img src="https://content.gitbook.com/content/Tq4lCgHh9X4VXINxI3L9/blobs/RIcwFhrkdwApuTadapLD/webhook%20config.png" alt=""><figcaption></figcaption></figure>

#### **Description of Fields:**

* #### **HMAC key:**&#x20;

  This key is used to [generate signatures](https://sandbox-doc.gitbook.io/ottu-team-sandbox-doc/developer/webhooks/signing-mechanism#signature-generation).
* #### **Ignore SSL:**&#x20;

  If checked, the SSL certificate will not be verified when calling the [webhook URL](https://sandbox-doc.gitbook.io/ottu-team-sandbox-doc/developer/checkout-api#webhook_url-string-optional).
* #### **Notify on Error:**&#x20;

  If checked, an email will be sent if an error occurs while calling the [webhook URL](https://sandbox-doc.gitbook.io/ottu-team-sandbox-doc/developer/checkout-api#webhook_url-string-optional).
* #### **Email List:**&#x20;

  Specify the list of email addresses where the [webhook URL](https://sandbox-doc.gitbook.io/ottu-team-sandbox-doc/developer/checkout-api#webhook_url-string-optional) error notification should be sent.
* #### **Timeout:**&#x20;

  The amount of time that the Ottu server will wait for a response from the merchant server.
* #### **Retries:**&#x20;

  The number of retry attempts the Ottu server will make to resend the request to the merchant server if the first attempt fails. Note that the **Enable retry webhook mechanism** option should be checked to activate this feature.
* #### **Backoff factor:**&#x20;

  The amount of time the Ottu server will wait before retrying the request (i.e., the time between two attempts).

#### [Example:](#example)&#x20;

Imagine a scenario where the merchant’s server experiences **downtime for 30 seconds**. If the **timeout is set to 20 seconds**, the **retries are set to 3**, and the **backoff factor is set to 5 seconds**, then the following will happen:\
Keep in mind that the merchant’s server will take 30 seconds to respond, and the number of attempts is 3.

* **First Try:**

1. Ottu's server will send a request to the merchant's server.
2. Ottu's server will wait 20 seconds for a response (timeout = 20), and this attempt will fail.
3. Then Ottu's server will wait 5 seconds for the backoff factor (backoff factor = 5).

**Note that the first attempt took 25 seconds.**

* **Second Try:**

1. Ottu's server will retry the request, i.e., send another request.
2. After 5 seconds, the merchant's server will respond since the server downtime will be over (30 seconds), and the request will be successful.

* #### **Version:**&#x20;

  The version of the webhook API.
* #### **Enable webhook notifications:**&#x20;

  If checked, webhook notifications will be activated.

{% hint style="info" %}
**Redirect behavior:** The redirect behavior is determined by the [webhook URL](https://sandbox-doc.gitbook.io/ottu-team-sandbox-doc/developer/checkout-api#webhook_url-string-optional) response to payment events and payment operations.

* If the webhook URL returns a status code of 200, the customer will be redirected to the [redirect\_url](https://sandbox-doc.gitbook.io/ottu-team-sandbox-doc/developer/checkout-api#redirect_url-string-optional).

* If the webhook URL returns a status code of 201, the customer will be redirected to the **Ottu payment summary page**.

* If the webhook URL returns any other status code, the customer will be redirected to the **Ottu payment summary page**. \
  In this case, Ottu can send an email notification if the **Enable webhook notifications** option is checked.
  {% endhint %}

* #### **Enable retry webhook mechanism**:

  If checked, Ottu will retry the request if the first attempt fails. See the [example scenario](#example) above for further clarity.

* #### **Operations webhook\_url:**&#x20;

  The URL where transaction data will be disclosed once an operation transaction flow is triggered. See [Operation Notification](https://sandbox-doc.gitbook.io/ottu-team-sandbox-doc/developer/webhooks/operation-notification).

* #### **Enable webhook notifications if transaction initiated from API:**&#x20;

  If checked, [Payment Webhooks](https://sandbox-doc.gitbook.io/ottu-team-sandbox-doc/developer/webhooks/payment-notification) will be activated even if the transaction is created via the API.

### [Webhook Plugin Configs](#webhook-plugin-configs)

In this tab, the merchant can define the desired webhook behavior for specific plugins.

<figure><img src="https://content.gitbook.com/content/Tq4lCgHh9X4VXINxI3L9/blobs/nh1XaIhEFCAHPjAlYsZ8/Webhook%20plugin%20configs.png" alt=""><figcaption></figcaption></figure>

**Description of Fields:**

* #### **Webhook plugin:**&#x20;

  The plugin that the webhook works for. See [Plugins](https://sandbox-doc.gitbook.io/ottu-team-sandbox-doc/user-guide/plugins)
* #### **Webhook URL:**&#x20;

  When a [payment event](https://sandbox-doc.gitbook.io/ottu-team-sandbox-doc/developer/webhooks/payment-notification) or [payment operation](https://sandbox-doc.gitbook.io/ottu-team-sandbox-doc/developer/webhooks/operation-notification) occurs, Ottu sends an HTTP request to this URL to disclose transactional data.
* #### **Enable transaction state webhook notifications:**&#x20;

  If checked, [Payment Notifications](https://sandbox-doc.gitbook.io/ottu-team-sandbox-doc/developer/webhooks/payment-notification) will be sent for the defined [Notification status](#notification-status).
* #### **Notification status:**&#x20;

  Define the transaction status that will trigger the [Payment Webhook,](https://sandbox-doc.gitbook.io/ottu-team-sandbox-doc/developer/webhooks/payment-notification) including `paid`, `failed`, `authorized`, and `canceled`. Review the [payment transaction states](https://sandbox-doc.gitbook.io/ottu-team-sandbox-doc/payment-tracking#states-of-parent-payment-transaction) for more information.
* #### **Delete:**&#x20;

  Deletes the defined plugin webhook configuration.

{% hint style="info" %}
The [**Webhook URL**](#webhook-url) specified in the [webhook plugin configuration](#webhook-plugin-configs) serves as the endpoint for receiving notifications related to both [payments](https://sandbox-doc.gitbook.io/ottu-team-sandbox-doc/developer/webhooks/payment-notification) and [operations](https://sandbox-doc.gitbook.io/ottu-team-sandbox-doc/developer/webhooks/operation-notification). If we provide values for both the [Operation webhook\_url](#operations-webhook_url) and the [Webhook URL](#webhook-url) in the plugin configuration, the system will transmit data to both URLs.
{% endhint %}

## [Summary](#summary)

In Ottu, there are two main webhook URLs used for different notification purposes. These URLs differ based on how they are provided and the reasons for the notifications. Here's a detailed breakdown:

### [Reasons for Notification](#reasons-for-notification)

For more detailed information on the reasons for notifications, you can refer to the respective sections:

* **Payment Notification:** This section covers notifications related to payment completion, payment status updates, and other payment-related events. Please refer to [Payment Notification](https://sandbox-doc.gitbook.io/ottu-team-sandbox-doc/developer/webhooks/payment-notification).
* **Operation Notifications:** This section details notifications for post-transaction activities such as refunds, captures, voids, and other operational events. Please refer to [Operation Notification](https://sandbox-doc.gitbook.io/ottu-team-sandbox-doc/developer/webhooks/operation-notification).

### [Ways of Providing Webhook URLs](#ways-of-providing-webhook-urls)

1. **Payment Webhook URL:**
   * **Checkout API Request Payload:**
     * When creating a [Checkout](https://sandbox-doc.gitbook.io/ottu-team-sandbox-doc/developer/checkout-api) request, you can specify the [webhook\_url](https://sandbox-doc.gitbook.io/ottu-team-sandbox-doc/developer/checkout-api/request-params#webhook_url) directly in the API payload. This [parameter](#enable-webhook-notifications-if-transaction-initiated-from-api) should be checked.
   * **Webhook Plugin Configuration:**
     * You can configure the payment [Webhook URL](#webhook-url) through the [Webhook Plugin Configs](#webhook-plugin-configs) in the Ottu administration dashboard. This URL will receive [payment notifications](https://sandbox-doc.gitbook.io/ottu-team-sandbox-doc/developer/webhooks/payment-notification) for all transactions processed by Ottu. The payment notification should be enabled [here](#enable-transaction-state-webhook-notifications).
2. **Operation Webhook URL:**
   * **Checkout API Request Payload:**
     * Similar to the payment webhook, you can specify the operation [webhook\_url](https://sandbox-doc.gitbook.io/ottu-team-sandbox-doc/developer/checkout-api/request-params#webhook_url) in the Checkout API [request ](https://sandbox-doc.gitbook.io/ottu-team-sandbox-doc/developer/checkout-api/request-params)payload. This URL will be used for both payment and operation notifications (such as refunds, captures, and voids). This [parameter](#enable-webhook-notifications-if-transaction-initiated-from-api) should be checked
   * **Webhook Configuration:**
     * The  [Operations webhook\_url](#operations-webhook_url) can also be configured through the [Webhook Configuration](#general) section in the Ottu dashboard.&#x20;
   * **Webhook Plugin Configuration:**
     * Additionally, you can configure the operation [Webhook URL](#webhook-url) via the [Webhook Plugin Configs](#webhook-plugin-configs).&#x20;

By setting up these webhook URLs correctly, you ensure that your system receives timely and accurate notifications for both payment and operation events, facilitating seamless transaction management and customer service.
