> For the complete documentation index, see [llms.txt](https://docs.malum.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.malum.co/transaction-api/webhook-callback.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.malum.co/transaction-api/webhook-callback.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
