public function edd_on_complete_purchase($payment_id)
 {
     WPAM_Logger::log_debug('Easy Digital Downlaods Integration - complete purchase hook triggered for Order ID: ' . $payment_id . '. Checking if affiliate commission needs to be awarded.');
     $payment_meta = edd_get_payment_meta($payment_id);
     $strRefKey = "";
     if (isset($payment_meta['wpam_refkey']) && !empty($payment_meta['wpam_refkey'])) {
         $strRefKey = $payment_meta['wpam_refkey'];
         WPAM_Logger::log_debug('Easy Digital Downlaods Integration - This purchase was referred by an affiliate, refkey: ' . $strRefKey);
     } else {
         WPAM_Logger::log_debug('Easy Digital Downlaods Integration - refkey not found in the payment_meta. This purchase was not referred by an affiliate');
         return;
     }
     $purchaseAmount = edd_get_payment_amount($payment_id);
     WPAM_Logger::log_debug('Easy Digital Downlaods Integration - Awarding commission for Order ID: ' . $payment_id . '. Purchase amt: ' . $purchaseAmount);
     $requestTracker = new WPAM_Tracking_RequestTracker();
     $requestTracker->handleCheckoutWithRefKey($payment_id, $purchaseAmount, $strRefKey);
 }
 public function wpspcProcessTransaction($ipn_data)
 {
     $custom_data = $ipn_data['custom'];
     WPAM_Logger::log_debug('Simple WP Cart Integration - IPN processed hook fired. Custom field value: ' . $custom_data);
     $custom_values = array();
     parse_str($custom_data, $custom_values);
     if (isset($custom_values['wpam_tracking']) && !empty($custom_values['wpam_tracking'])) {
         $tracking_value = $custom_values['wpam_tracking'];
         WPAM_Logger::log_debug('Simple WP Cart Integration - Tracking data present. Need to track affiliate commission. Tracking value: ' . $tracking_value);
         $purchaseLogId = $ipn_data['txn_id'];
         $purchaseAmount = $ipn_data['mc_gross'];
         //TODO - later calculate sub-total only
         $strRefKey = $tracking_value;
         $requestTracker = new WPAM_Tracking_RequestTracker();
         $requestTracker->handleCheckoutWithRefKey($purchaseLogId, $purchaseAmount, $strRefKey);
         WPAM_Logger::log_debug('Simple WP Cart Integration - Commission tracked for transaction ID: ' . $purchaseLogId . '. Purchase amt: ' . $purchaseAmount);
     }
 }