THT Community

Full Version: Na'ven's Coupons - Coupon System/Invoice Upgrade - AutoMod Module
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
NOTICE:
This module comes PREINSTALLED with THT 1.3.5 Reworked! PLEASE do not install it on 1.3.5 Reworked. You don't need to.

Module: Coupon System
Module Version: 1.0
For THT Version: 1.3 Reworked
Author: Na'ven Enigma
Website: http://thelifemaster.com

PATCHES
Invoice Total Fix - 3/28/2012 - This module fixes the issue where the invoice reports an invorrect amount do to a mathamatical error. It also fixes the total post count when the user and admin have not visited their invoice area.

DESCRIPTION:
This module will allow you to add coupons to THT to be used during the order process and the invoice payment process as well. The system is designed to give you as much control over your codes as possible. Below is a list of things you can set a coupon to do.

1.) You can make coupons only work during the order process and/or you can have them work on the invoice payment process.
2.) You can make the coupon good for just the bill its being used on, or it can be used for the rest of the lifetime on the account, or a set period of months.
3.) You can set a coupon expiration date so no one can enter the coupon code for use after that date or you can have it never expire. (You can still delete it from the system.)
4.) If you delete a coupon, you have the option of keeping iton the system for those who have already entered it.
5.) If you edit a coupon, you can opt to change it for the people who are using it currently, or just for a future date.
6.) You can make a coupon available to only one user by entering their current username.
7.) You can select what packages the coupon may be used on or allow it to be used on all of them.
8.) You can set it to discount the dollar amount or the number of posts. You can also set these as a percentage.
9.) You can set how many times you want each coupon to be used or set it to unlimited.
10.) The invoicing system got an overhaul and now users can add/remove coupons and pay less than the balance due.
11.) The new invoicing system lays the ground work for a more expansive invoicing system, such as future mods for different payment methods.
12.) The invoicing system now handles chargebacks and refunds and other negative value transactions in such a way that it subtracts the amount from the invoice instead of marking it as paid.
13.) You can now set the grace period for P2H users so they can have a period of time before they get suspended for not posting the monthly amount.
14.) Admins can add credits and charges to accounts and those show in both the admin and client's transactions list for paid and P2H users.
15.) Admins can make payment arrangements for paid accounts. (P2H requires a credit added for the full amount before the end of the month and then removed the next month to avoid cron suspending them.)
16.) Admins can remove invoices and can see which invoices are orphaned.


PREREQUISITES:
1.) AutoMod: http://thehostingtool.com/forum/thread-1754.html
2.) Bug Fix - Paid Cron: http://thehostingtool.com/forum/thread-1757.html
3.) THT SDK: http://thehostingtool.com/forum/thread-1758.html



Note: This module is the reason I couldn't release AutoMod right away and therefore no other mods could be released. I wanted to wait until I could test AutoMod with a full featured extensive production module. Sorry about the wait! =)


Small tweak:
In includes/paypal/paypal.class.php:

FIND:
PHP Code:
return false;  //If we return it as false, the set paid won't execute. 

And remove it. This was in there before I added further code and I forgot to remove it. The bit below it handles whether or not it should be set to paid by checking if the amount paid is sufficient. I'll update the module for download as well. Only 2 people downloaded this so far.
Great Mod, thank you very much.
You're welcome. =)
Hello,

This module failed to install for me, it was getting a few errors in includes/paypal/paypal.class.php that it couldn't find specific lines of code, I check the paypal script myself and the code are there and don't understand why it's failing :/

Best Regards
Here are more details regarding the issue:

Error: Could not find the following code in the file.
PHP Code:
} else {
         
// Post the data back to paypal
         
fputs($fp"POST /cgi-bin/webscr HTTP/1.0\r\n");
         
fputs($fp"Content-Type: application/x-www-form-urlencoded\r\n");
         
fputs($fp"Content-Length: ".strlen($post_string)."\r\n\r\n");
         
fputs($fp$post_string "\r\n\r\n");

         
// loop through the response from the server and append to variable
         
while(!feof($fp)) {
            
$this->ipn_response .= fgets($fp1024);
         }

         
fclose($fp); // close connection

      


Error: Could not find the following code in the file.
PHP Code:
if (eregi("VERIFIED",$this->ipn_response)) {

         
// Valid IPN transaction.
         
$this->log_ipn_results(true);
         return 
true

Error: Could not find the following code in the file.
PHP Code:
if (!$this->ipn_log) return;  // is logging turned off?

      // Timestamp
      
$text '['.date('m/d/Y g:i A').'] - '

Error: Could not find the following code in the file.
PHP Code:
$query3 $db->query("SELECT * FROM `<PRE>invoices` WHERE `uid` = '{$uid}' LIMIT 1"); 

Error: Could not find the following code in the file.
PHP Code:
$monthly $array["additional"];
                                        
// monthly=50,add=Add Package
                                        
$monthly explode(","$monthly);
                                        
$monthly explode("="$monthly[0]);
                                        
$amount $monthly[1]; 

Error: Could not find the following code in the file.
PHP Code:
$due time()+intval($db->config("suspensiondays")*24*60*60); 

Undecided Huh
Hello,

Some of the patch/mod code was already included in class_invoice.php and class_server.php. I only needed to make minor modifications to those files. However, paypal.class.php had to include all modifications by hand.
Odd. What version of THT are you using? Sometimes white space will mess things up. I changed to using Notepad++ for writing mod XML code to avoid Winsyntax changing the spacing and trimming white space and whatnot.
(04-03-2012, 03:36 AM)LightworkerNaven Wrote: [ -> ]Odd. What version of THT are you using? Sometimes white space will mess things up. I changed to using Notepad++ for writing mod XML code to avoid Winsyntax changing the spacing and trimming white space and whatnot.

The latest you have for download, I believe 1.3.5
Hmm, interesting, I just noticed that 1.3.5 apparently includes all the fixes out of the box... I'm trying a fresh install and see :/
Sorry. I didn't get your messages until now. Yes, 1.3.5 has all of my modules already installed. You could just uninstall the modules and then do the upgrade in the installer. This way you don't loose all of your work.
I was testing locally, so it's not a big problem to start all over Smile
Hi
Can I find out how users are notified if they have made ​​a coupon with a discount for a specific amount?