Jump to content

Receive notification after Invoice Paid


ST4R

Recommended Posts

Hi there.

As you know WHMCS sends an invoice payment confirmation to the customer, but the admin doesn't receive anything.

by a little googling I found out there was a hook to do the job but it's not accessible now.

Quote

You can also, WHMCS > Setup > Email Templates > Invoice Messages and add your email address at "Copy to" field in "Invoice Payment Confirmation" and "Credit Card Payment Confirmation".

That won't work for me neither!

I want an customized email notification which includes Client name, Client ID, Invoice ID, Amount Paid not the copy of my client's Payment Confirmation email!

If you got the hook please share it with me and the others or if it's possible please make one and share it!

Thanks.

Edited by ST4R
Link to comment
Share on other sites

You can utilze the Notifications feature in WHMCS to create a notification with the Email Provider to send an email upon Invoice Payment. Here is some HTML for you to use on your email template: 

<h2><a href="{$notification_url}">{$notification_title}</a></h2>
<div>{$notification_message}</div>
{foreach from=$notification_attributes item=$attribute}
<div>
<div>{$attribute.label}: {if $attribute.icon}<img src="{$attribute.icon}" alt="" />{/if}{if $attribute.style}<span class="{$attribute.style}">{/if}{if $attribute.url}<a href="{$attribute.url}">{$attribute.value}</a> {else}{$attribute.value}{/if}{if $attribute.style}</span>{/if}</div>
</div>
{/foreach}<br /><br /><span>Client name: {$client_name}<br />Client ID: {$client_id}<br />Invoice ID: {$invoice_id}<br />Invoice #: {$invoice_number}<br /></span>Amount: {$invoice_last_payment_amount}<br />Transaction #: {$invoice_last_payment_transid}<br />Total Paid: {$invoice_amount_paid}<br />Remaining Balance: {$invoice_balance}<br />Status: {$invoice_status}

This would meet all of your requirements.

Link to comment
Share on other sites

15 hours ago, ST4R said:

by a little googling I found out there was a hook to do the job but it's not accessible now.

you mean the one that even the poster in the thread you link to says doesn't work... :?:

Quote

However after configuring the email info, naming it paid.php as suggested and uploading it to the hook directory.. nothing happens and in the debug log it doesn't show the hook being called either.

a little deeper digging on Google would have found you the original hook code...

https://www.hetnix.com/hetnix/whmcs-hook-receive-notification-after-invoice-paid.xml

https://pastebin.com/4gcdTaK8

<?php
/**
 * WHMCS Invoice Payment Notification
 *
 * Please upload this file to your whmcs includes/hooks folder and name it ipaid.php
 * This code is free and opensource. Feel free to customize it as you need/like
 *
 * @author     HETNiX SRL <office@hetnix.com> 
 * @date   	   17th of July 2015 
 * @version    1.0.0
 * @link       https://www.hetnix.com/
 */


if (!defined("WHMCS"))
    die("This file cannot be accessed directly");

function ipaid_notif($vars) {

    $invoiceid = $vars['invoiceid'];

$qry1=mysql_query("SELECT * FROM tblinvoices WHERE id = $invoiceid") or die(mysql_error());
$strx=mysql_fetch_assoc($qry1);
$clidx=$strx['userid'];
$cldtls=mysql_query("SELECT * FROM tblclients WHERE id = $clidx") or die(mysql_error());
$dox=mysql_fetch_assoc($cldtls);


if ($clidx > 0) {
	
	switch ($strx['paymentmethod']) {

	case 'banktransfer':
		$fnpmth = "Bank Transfer Gateway";
		break;
	case 'paypal':
		$fnpmth = "PayPal Gateway";
		break;


		
	}
	
	$toj="**YOUREMAIL@MAILBOX.COM**"; 
	$subj="Payment received - ".$strx['total']." CURRENCY_CODE - Invoice ".$invoiceid;
	$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";
	$headersj = 'From: **FROMEMAIL@MAILBOX.COM**' . "\r\n" .
    'Reply-To: **REPLYEMAIL@MAILBOX.COM**' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();
	mail($toj, $subj, $bodj, $headersj);
	
}

}

add_hook("InvoicePaid",1,"ipaid_notif");

?>

... the above developer no longer uses WHMCS anyway, so I doubt they've updated their code since then.

15 hours ago, ST4R said:

I want an customized email notification which includes Client name, Client ID, Invoice ID, Amount Paid not the copy of my client's Payment Confirmation email!

and you couldn't edit the existing email template to add these details (three of those above fields are effectively already used - it's only client ID that would be missing) ?

surely the client could have no objection to seeing those details in their own confirmation email... and then all you need to do it bcc it to yourself... that's the simpler solution. :idea:

Link to comment
Share on other sites

On 4/22/2018 at 3:42 PM, brian! said:

and then all you need to do it bcc it to yourself... that's the simpler solution. :idea:

I went through your solution but it will CC the Payment Confirmation mail to my email address and the Client will be able to see my email address.

How to BCC it?

 

Link to comment
Share on other sites

5 hours ago, ST4R said:

I went through your solution but it will CC the Payment Confirmation mail to my email address and the Client will be able to see my email address.

they don't know it already ?

5 hours ago, ST4R said:

How to BCC it?

it was a feature introduced last year, in v7.3 I think, where you can add cc (Copy To) and/or bcc (Blind Copy To) email addresses in individual email templates... :idea:

SmPpAeN.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated