public static function handle_commission_tracking_hook($args)
 {
     /*
      * The args array must have the following 3 details
      * $args['txn_id']
      * $args['amount']
      * $args['aff_id']
      */
     WPAM_Logger::log_debug('handle_commission_tracking_hook() - Txn ID : ' . $args['txn_id'] . ', Amount: ' . $args['amount'] . ', Affiliate ID: ' . $args['aff_id']);
     WPAM_Commission_Tracking::award_commission($args);
 }
 public function handleCheckoutWithRefKey($purchaseLogId, $purchaseAmount, $strRefKey)
 {
     //TODO start - we only need this to block of code to keep backwards compatibility. later when we will directly get affiliate ID from cookie it can be deleted
     $db = new WPAM_Data_DataAccess();
     $binConverter = new WPAM_Util_BinConverter();
     $affiliate = NULL;
     global $wpdb;
     // keeping this block and "($affiliate !== NULL)" seperate to
     // help indicate any problems
     // (purchase log recorded w/o a purchase event)
     if (!empty($strRefKey)) {
         $query = "SELECT * FROM " . WPAM_TRACKING_TOKENS_TBL . " WHERE trackingKey = %s";
         $trackingToken = $wpdb->get_row($wpdb->prepare($query, $strRefKey));
         if ($trackingToken != null) {
             $trackingTokenId = $trackingToken->trackingTokenId;
             $query = "SELECT * FROM " . WPAM_TRACKING_TOKENS_PURCHASE_LOGS_TBL . " WHERE trackingTokenId = %s AND purchaseLogId = %s";
             $ttpl = $wpdb->get_row($wpdb->prepare($query, $trackingTokenId, $purchaseLogId));
             if ($ttpl != null) {
             } else {
                 $table = WPAM_TRACKING_TOKENS_PURCHASE_LOGS_TBL;
                 $data = array();
                 $data['trackingTokenId'] = $trackingTokenId;
                 $data['purchaseLogId'] = $purchaseLogId;
                 $wpdb->insert($table, $data);
                 //this will be handled further down if the affiliate is set and the purchase was successful
                 //$db->getEventRepository()->quickInsert(time(), $strRefKey, 'purchase');
             }
         }
     }
     //TODO end
     $args = array();
     $args['txn_id'] = $purchaseLogId;
     $args['amount'] = $purchaseAmount;
     if (is_numeric($strRefKey)) {
         //$strRefKey contains affiliate ID from the new cookie system (wpam_id)
         $args['aff_id'] = $strRefKey;
     }
     WPAM_Commission_Tracking::award_commission($args);
 }