# Webhook / Callback

### Overview

Webhooks are powerful tools used to communicate events between different systems over the web. One common application of webhooks is in payment gateways, where they provide real-time notifications about transaction statuses. This page explains how you can use webhooks to know when a payment is completed in your application.

### Setting Up a Webhook for Payment Notifications

#### Configuring the Webhook URL

Whenever you create a transaction you can specify a custom webhook url for the transaction. This helpful if you manage multiple shops.

#### Handling the Webhook Data

When a payment transaction completes, the payment gateway will send a POST request to your configured webhook URL. This request will include important details about the transaction, such as:

* **status**: Indicates the outcome of the transaction (COMPLETED, FAILED).
* **txn**: A unique identifier for the transaction.
* **amount**: The amount that was requested in the transaction.
* **currency**: The currency used for the transaction.
* **customer\_id**: A unique identifier for the customer involved in the transaction.
* **checkout**: The amount that was requested by you but converted to USD.
* **timestamp**: The exact time when the transaction was processed.
* **signature**: md5(txn|timestamp|webhook\_key)

**Example Code Signature PHP:**

```php
<?php

$receivedWebhook = json_decode(file_get_contents('php://input'));

$webhook_key = 'Your_personal_webhook_key';
$timestamp = $receivedWebhook['timestamp'];
$txn = $receivedWebhook['txn'];

$signature = md5($txn . '|' . $timestamp . '|' . $webhook_key); 

if($signature == $receivedWebhook['signature']){
    // Execute your code on success
}

?>
```

You can find your webhook key here:\
<https://malum.co/merchant/settings/api>

<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.malum.co/transaction-api/webhook-callback.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.
