Advertisement
Guest User

HETNiX.COM - WHMCS Hook: Receive notification after Invoice

a guest
Jul 17th, 2015
1,179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.63 KB | None | 0 0
  1. <?php
  2. /**
  3.  * WHMCS Invoice Payment Notification
  4.  *
  5.  * Please upload this file to your whmcs includes/hooks folder and name it ipaid.php
  6.  * This code is free and opensource. Feel free to customize it as you need/like
  7.  *
  8.  * @author     HETNiX SRL <office@hetnix.com>
  9.  * @date       17th of July 2015
  10.  * @version    1.0.0
  11.  * @link       https://www.hetnix.com/
  12.  */
  13.  
  14.  
  15. if (!defined("WHMCS"))
  16.     die("This file cannot be accessed directly");
  17.  
  18. function ipaid_notif($vars) {
  19.  
  20.     $invoiceid = $vars['invoiceid'];
  21.  
  22. $qry1=mysql_query("SELECT * FROM tblinvoices WHERE id = $invoiceid") or die(mysql_error());
  23. $strx=mysql_fetch_assoc($qry1);
  24. $clidx=$strx['userid'];
  25. $cldtls=mysql_query("SELECT * FROM tblclients WHERE id = $clidx") or die(mysql_error());
  26. $dox=mysql_fetch_assoc($cldtls);
  27.  
  28.  
  29. if ($clidx > 0) {
  30.    
  31.     switch ($strx['paymentmethod']) {
  32.  
  33.     case 'banktransfer':
  34.         $fnpmth = "Bank Transfer Gateway";
  35.         break;
  36.     case 'paypal':
  37.         $fnpmth = "PayPal Gateway";
  38.         break;
  39.  
  40.  
  41.        
  42.     }
  43.    
  44.     $toj="**YOUREMAIL@MAILBOX.COM**";
  45.     $subj="Payment received - ".$strx['total']." CURRENCY_CODE - Invoice ".$invoiceid;
  46.     $bodj="Invoice ".$invoiceid." received a payment today of ".$strx['total']." CURRENCY_CODE\nDetails: ".$dox['firstname']." ".$dox['lastname']." paid invoice using ".$fnpmth." today.\n\nView Invoice: http://www.yourdomain.com/whmcs/admin/invoices.php?action=edit&id=".$invoiceid."\n";
  47.     $headersj = 'From: **FROMEMAIL@MAILBOX.COM**' . "\r\n" .
  48.     'Reply-To: **REPLYEMAIL@MAILBOX.COM**' . "\r\n" .
  49.     'X-Mailer: PHP/' . phpversion();
  50.     mail($toj, $subj, $bodj, $headersj);
  51.    
  52. }
  53.  
  54. }
  55.  
  56. add_hook("InvoicePaid",1,"ipaid_notif");
  57.  
  58. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement