> ## Documentation Index
> Fetch the complete documentation index at: https://payblis.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# IPN & Notify

> The Callback & IPN section describes how Payblis notifies your server and redirects your customers after a payment attempt. It includes server-to-server IPN notifications and redirection to success (urlOK) or failure (urlKO) URLs, ensuring real-time transaction updates and seamless user experience.

Payblis provides three types of callbacks:

* **Success URL (urlOK)**: Customer redirection after successful payment
* **Failure URL (urlKO)**: Customer redirection after failed payment
* **IPN URL (ipnURL)**: Server-to-server notification

## IPN Security

All IPN notifications are signed with HMAC-SHA256. Verify the signature in the X-Payblis-Signature header or in JSON response.

<Note>
  Important Delete Signature before vérification.
</Note>

```php PHP Implementation theme={null}
// Get the signature from the header
$signature = $_SERVER['X-Payblis-Signature'] ?? '';

// Get the raw POST data
$payload = file_get_contents('php://input');

// Calculate the expected signature
$expectedSignature = hash_hmac('sha256', $payload, $your_secret_key);

// Compare signatures
if (!hash_equals($expectedSignature, $signature)) {
    http_response_code(400);
    die('Invalid signature');
}

// Process the IPN data
$data = json_decode($payload, true);
```

## IPN Example

```c payment.success theme={null}
{
    "event": "payment.success",
    "merchant_reference": "Order-xxxxxxx",
    "transaction_id": "PAYBxxxxxxx",
    "amount": "14.17",
    "status": "SUCCESS"
    "signature": "6d6c157467d30f54ef4cff0e2a4a3434ef8274cdca77c4bfa228af3d62847492"
}
```

```mdx payment.failed theme={null}
{
    "event": "payment.failed",
    "merchant_reference": "1098",
    "transaction_id": "PAYB-FAILED-6818766989175",
    "amount": "10",
    "status": "FAILED"
    "signature": "6d6c157467d30f54ef4cff0e2a4a3434ef8274cdca77c4bfa228af3d62847492"
}
```
