# Пример обработчика на PHP

```php
<?php
$secret = 'secret_webhook_payoff'; // Секретный ключ для проверки подлинности уведомления из настроек аккаунта

if($_SERVER['REQUEST_METHOD'] !== 'POST') {
	die("wrong request method");
}

if(!in_array(@$_POST['status'], ['cancel', 'success'])) {
	die("wrong status");
}

function getIP() {
	$ip = $_SERVER['REMOTE_ADDR'];
		
	if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
		$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
	}
		
	if(isset($_SERVER['HTTP_X_REAL_IP'])) {
		$ip = $_SERVER['HTTP_X_REAL_IP'];
	}
	
	if(isset($_SERVER['HTTP_CF_CONNECTING_IP'])) {
		$ip = $_SERVER['HTTP_CF_CONNECTING_IP'];
	}

	$explode = explode(',', $ip);
		
	if(count($explode) > 1) {
		$ip = $explode[0];
	}
	
	return trim($ip);
}
	
// Проверка на IP адрес сервиса (по желанию)
$ctx = stream_context_create([
	'http' => [
		'timeout' => 10
    	]
]);

$ips = json_decode(file_get_contents('https://aaio.io/api/public/ips', false, $ctx));
if (isset($ips->list) && !in_array(getIP(), $ips->list)) {
	die("hacking attempt");
}
// Конец проверки на IP адрес сервиса

$sign = hash('sha256', implode(':', [$_POST['id'], $secret, $_POST['amount_down']]));

if (!hash_equals($_POST['sign'], $sign)) {
	die("wrong sign");
}

// Код который необходимо выполнить на Вашей стороне

die('OK');
```


---

# 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://wiki.aaio.so/vyvod-sredstv/opoveshenie-o-vypolnenii-libo-otmene-vyvoda/primer-obrabotchika-na-php.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.
