added notification system for successful payment
This commit is contained in:
32
app/NotifyMe.php
Normal file
32
app/NotifyMe.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
trait NotifyMe
|
||||
{
|
||||
function sendTelegramNotification($message) {
|
||||
$botToken = config('app.notify_tg_bot_token');
|
||||
$chatId = config('app.notify_tg_chat_id');
|
||||
|
||||
if (!$botToken || !$chatId) {
|
||||
\Log::error('Telegram bot token or chat ID not configured');
|
||||
return false;
|
||||
}
|
||||
|
||||
$url = "https://api.telegram.org/bot{$botToken}/sendMessage";
|
||||
|
||||
$data = [
|
||||
'chat_id' => $chatId,
|
||||
'text' => $message,
|
||||
'parse_mode' => 'HTML'
|
||||
];
|
||||
|
||||
try {
|
||||
$response = \Http::post($url, $data);
|
||||
return $response->successful();
|
||||
} catch (\Exception $e) {
|
||||
\Log::error('Failed to send Telegram notification: ' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user