theviewer1985 Posted November 7, 2016 Share Posted November 7, 2016 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 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 7, 2016 Share Posted November 7, 2016 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! 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 receiveI 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. 0 Quote Link to comment Share on other sites More sharing options...
theviewer1985 Posted November 8, 2016 Author Share Posted November 8, 2016 or it doesn't exist, and you're left wondering why! 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 0 Quote Link to comment Share on other sites More sharing options...
vbatra Posted November 10, 2016 Share Posted November 10, 2016 (edited) 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 November 10, 2016 by vbatra typo 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.