Jump to content

Admin emails when payment is declined (and other reasons)


theviewer1985

Recommended Posts

Hi guys

 

I feel like this is so obvious and basic, that it already exists and I can't find the option.

 

I simply want to receive an email from WHMCS (to the admin email) when a payment is declined, or service suspended. Basically I feel like there should be / is an area somewhere where there are plenty of check boxes where you select what type of emails you want to receive

 

I receive new order emails, failed order setup emails.... but its equally important to know when a service is suspended, about to be suspended, payment declined...

 

Is there such area?

 

Thanks

Link to comment
Share on other sites

I feel like this is so obvious and basic, that it already exists and I can't find the option.

or it doesn't exist, and you're left wondering why! :twisted:

 

I simply want to receive an email from WHMCS (to the admin email) when a payment is declined, or service suspended. Basically I feel like there should be / is an area somewhere where there are plenty of check boxes where you select what type of emails you want to receive

I receive new order emails, failed order setup emails.... but its equally important to know when a service is suspended, about to be suspended, payment declined...

Is there such area?

in a word, no.

 

for something like this, you basically have three options.

 

1. the cron emails and/or the activity log - these can be a mine of information about what WHMCS is doing.

2. email templates - if the client receives an email notifying them (e.g service suspension, payment declined etc), then you can either add your email address as a cc to that specific template, or add your email address to general settings -> mail -> bcc messages to receive a copy of all emails sent to clients by WHMCS.

3. using a hook to send an email when triggered by a specific event.

 

of the options, 2) is probably the simplest to use if such an email is sent to the client.

Link to comment
Share on other sites

or it doesn't exist, and you're left wondering why! :twisted:

 

 

in a word, no.

 

for something like this, you basically have three options.

 

1. the cron emails and/or the activity log - these can be a mine of information about what WHMCS is doing.

2. email templates - if the client receives an email notifying them (e.g service suspension, payment declined etc), then you can either add your email address as a cc to that specific template, or add your email address to general settings -> mail -> bcc messages to receive a copy of all emails sent to clients by WHMCS.

3. using a hook to send an email when triggered by a specific event.

 

of the options, 2) is probably the simplest to use if such an email is sent to the client.

 

Yes your right.... option 2 is the simplest and actually extremely obvious now you have said it to me. I should have thought of it myself

 

Thanks!:-D

Link to comment
Share on other sites

Sharing the code we use to create tickets on failed payments:

 

<?php
//error_reporting(E_ALL);
//ini_set('display_errors', '1');
if (!defined("WHMCS"))
   die("This file cannot be accessed directly"); 

function new_ticket_failed_transaction($vars) { 

//if you have multiple gateways
if($vars['gateway']=="Authorize.net"){
  $data = explode("\n",json_decode(json_encode($vars['data']),true));

  $result = ucfirst($vars['result']);
  }
  elseif($vars['gateway']=="Another Gateway"){
  $data = explode("\n",json_decode(json_encode($vars['data']),true));
  $result = ucfirst($vars['result']);
  }

  if ($result!="Success"){
  preg_match_all('!\d+!', $data['1'], $user);
  $user=implode('',$user[0]);



require_once("/home/username/public_html/support/includes/dbfunctions.php"); 
require_once("/home/username/public_html/support/includes/functions.php"); 
require_once("/home/username/public_html/support/includes/clientareafunctions.php");
// Set Vars for API
$command = 'OpenTicket';
$postdata = array(
   //'username' => 'xxxx',
   //'password' => 'xxxxxxxxx',
   'action' => 'OpenTicket',
   'clientid' => $user,
'deptid' => '2',
   'subject' => 'Credit Card Payment Failed',
   'message' => $vars['data'],
   'priority' => 'High',
   'customfields' => '',
   'responsetype' => 'json',
   'noemail' => 'false',
);
$adminuser = 'whmcs-admin';

// Call API
$results = localAPI($command, $postdata, $adminuser);
//if ($results['result']!="success") echo "An Error Occurred: ".$results['result'];
//print_r($vars[result]);

}

}
add_hook("LogTransaction",1,"new_ticket_failed_transaction"); 
?>

 

this code can further be modified to send an email to admins with a pre-selected email template

Edited by vbatra
typo
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