diff --git a/includes/hooks/WHMCS-Discord-Notifications.php b/includes/hooks/WHMCS-Discord-Notifications.php new file mode 100644 index 0000000..67c4d0a --- /dev/null +++ b/includes/hooks/WHMCS-Discord-Notifications.php @@ -0,0 +1,287 @@ + $discordGroupID, + } + 'username' => $companyName, + 'embeds' => array( + array( + 'title' => $vars['subject'], + 'url' => $whmcsAdminURL . 'supporttickets.php?action=view&id=' . $vars['ticketid'], + 'timestamp' => date(DateTime::ISO8601), + 'description' => '', + 'color' => '5653183', + 'author' => array( + 'name' => 'New Support Ticket', + ), + 'fields' => array( + array( + 'name' => 'Priority', + 'value' => $vars['priority'], + 'inline' => true, + ), + array( + 'name' => 'Department', + 'value' => $vars['deptname'], + 'inline' => true, + ), + array( + 'name' => 'Ticket ID', + 'value' => $vars['ticketid'], + 'inline' => true, + ) + ), + ) + ), + ); + $dataString = json_encode($dataPacket); + $curl = curl_init(); + curl_setopt($curl, CURLOPT_URL, $discordWebHookURL); + curl_setopt($curl, CURLOPT_POST, 1); + curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($curl, CURLOPT_POSTFIELDS, $dataString); + $output = curl_exec($curl); + $output = json_decode($output, true); + if (curl_getinfo($curl, CURLINFO_HTTP_CODE) != 204) { + echo "Failed " . curl_getinfo($curl, CURLINFO_HTTP_CODE) . "

"; + print_r($output); + } + curl_close($curl); + }); + + add_hook('TicketUserReply', 1, function($vars) { + $dataPacket = array( + if (isset($discordGroupID)) { + 'content' => $discordGroupID, + } + 'username' => $companyName, + 'embeds' => array( + array( + 'title' => $vars['subject'], + 'url' => $whmcsAdminURL . 'supporttickets.php?action=view&id=' . $vars['ticketid'], + 'timestamp' => date(DateTime::ISO8601), + 'description' => '', + 'color' => '5653183', + 'author' => array( + 'name' => 'New Ticket Reply', + ), + 'fields' => array( + array( + 'name' => 'Priority', + 'value' => $vars['priority'], + 'inline' => true, + ), + array( + 'name' => 'Department', + 'value' => $vars['deptname'], + 'inline' => true, + ), + array( + 'name' => 'Ticket ID', + 'value' => $vars['ticketid'], + 'inline' => true, + ) + ), + ) + ), + ); + $dataString = json_encode($dataPacket); + $curl = curl_init(); + curl_setopt($curl, CURLOPT_URL, $discordWebHookURL); + curl_setopt($curl, CURLOPT_POST, 1); + curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($curl, CURLOPT_POSTFIELDS, $dataString); + $output = curl_exec($curl); + $output = json_decode($output, true); + if (curl_getinfo($curl, CURLINFO_HTTP_CODE) != 204) { + echo "Failed " . curl_getinfo($curl, CURLINFO_HTTP_CODE) . "

"; + print_r($output); + } + curl_close($curl); + }); + + add_hook('PendingOrder', 1, function($vars) { + $dataPacket = array( + if (isset($discordGroupID)) { + 'content' => $discordGroupID, + } + 'username' => $companyName, + 'embeds' => array( + array( + 'url' => $whmcsAdminURL . 'orders.php?action=view&id=' . $vars['orderid'], + 'timestamp' => date(DateTime::ISO8601), + 'description' => '', + 'color' => '5653183', + 'author' => array( + 'name' => 'New Pending Order', + ), + ) + ), + ); + $dataString = json_encode($dataPacket); + $curl = curl_init(); + curl_setopt($curl, CURLOPT_URL, $discordWebHookURL); + curl_setopt($curl, CURLOPT_POST, 1); + curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($curl, CURLOPT_POSTFIELDS, $dataString); + $output = curl_exec($curl); + $output = json_decode($output, true); + if (curl_getinfo($curl, CURLINFO_HTTP_CODE) != 204) { + echo "Failed " . curl_getinfo($curl, CURLINFO_HTTP_CODE) . "

"; + print_r($output); + } + curl_close($curl); + }); + + add_hook('AcceptOrder', 1, function($vars) { + $dataPacket = array( + if (isset($discordGroupID)) { + 'content' => $discordGroupID, + } + 'username' => $companyName, + 'embeds' => array( + array( + 'url' => $whmcsAdminURL . 'orders.php?action=view&id=' . $vars['orderid'], + 'timestamp' => date(DateTime::ISO8601), + 'description' => '', + 'color' => '5653183', + 'author' => array( + 'name' => 'New Accepted Order', + ), + ) + ), + ); + $dataString = json_encode($dataPacket); + $curl = curl_init(); + curl_setopt($curl, CURLOPT_URL, $discordWebHookURL); + curl_setopt($curl, CURLOPT_POST, 1); + curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($curl, CURLOPT_POSTFIELDS, $dataString); + $output = curl_exec($curl); + $output = json_decode($output, true); + if (curl_getinfo($curl, CURLINFO_HTTP_CODE) != 204) { + echo "Failed " . curl_getinfo($curl, CURLINFO_HTTP_CODE) . "

"; + print_r($output); + } + curl_close($curl); + }); + + add_hook('FraudOrder', 1, function($vars) { + $dataPacket = array( + if (isset($discordGroupID)) { + 'content' => $discordGroupID, + } + 'username' => $companyName, + 'embeds' => array( + array( + 'url' => $whmcsAdminURL . 'orders.php?action=view&id=' . $vars['orderid'], + 'timestamp' => date(DateTime::ISO8601), + 'description' => '', + 'color' => '5653183', + 'author' => array( + 'name' => 'Order Marked As Fraud', + ), + ) + ), + ); + $dataString = json_encode($dataPacket); + $curl = curl_init(); + curl_setopt($curl, CURLOPT_URL, $discordWebHookURL); + curl_setopt($curl, CURLOPT_POST, 1); + curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($curl, CURLOPT_POSTFIELDS, $dataString); + $output = curl_exec($curl); + $output = json_decode($output, true); + if (curl_getinfo($curl, CURLINFO_HTTP_CODE) != 204) { + echo "Failed " . curl_getinfo($curl, CURLINFO_HTTP_CODE) . "

"; + print_r($output); + } + curl_close($curl); + }); + + add_hook('CancellationRequest', 1, function($vars) { + $dataPacket = array( + if (isset($discordGroupID)) { + 'content' => $discordGroupID, + } + 'username' => $companyName, + 'embeds' => array( + array( + 'url' => $whmcsAdminURL . 'cancelrequests.php', + 'timestamp' => date(DateTime::ISO8601), + 'description' => $vars['reason'], + 'color' => '5653183', + 'author' => array( + 'name' => 'New Cancellation Request', + ), + 'fields' => array( + array( + 'name' => 'Product ID', + 'value' => $vars['relid'], + 'inline' => true, + ), + array( + 'name' => 'Cancellation Type', + 'value' => $vars['type'], + 'inline' => true, + ), + array( + 'name' => 'User ID', + 'value' => $vars['userid'], + 'inline' => true, + ) + ), + ) + ), + ); + $dataString = json_encode($dataPacket); + $curl = curl_init(); + curl_setopt($curl, CURLOPT_URL, $discordWebHookURL); + curl_setopt($curl, CURLOPT_POST, 1); + curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($curl, CURLOPT_POSTFIELDS, $dataString); + $output = curl_exec($curl); + $output = json_decode($output, true); + if (curl_getinfo($curl, CURLINFO_HTTP_CODE) != 204) { + echo "Failed " . curl_getinfo($curl, CURLINFO_HTTP_CODE) . "

"; + print_r($output); + } + curl_close($curl); + }); +?> \ No newline at end of file