/**
  * Remove an order from MailChimp if the payment was refunded
  *
  * @return bool
  */
 public function delete_ecommerce360_purchase($payment_id, $new_status, $old_status)
 {
     if ('publish' != $old_status && 'revoked' != $old_status) {
         return;
     }
     if ('refunded' != $new_status) {
         return;
     }
     // Make sure an API key has been entered
     if (empty($this->key)) {
         return FALSE;
     }
     // Send to MailChimp
     $options = array('CURLOPT_FOLLOWLOCATION' => false);
     $mailchimp = new EDD_MailChimp_API($this->key, $options);
     try {
         $result = $mailchimp->call('ecomm/order-del', array('store_id' => self::_edd_ec360_get_store_id(), 'order_id' => $payment_id));
         edd_insert_payment_note($payment_id, __('Order details have been removed from MailChimp successfully', 'eddmc'));
         return TRUE;
     } catch (Exception $e) {
         edd_insert_payment_note($payment_id, __('MailChimp Ecommerce360 Error: ', 'eddmc') . $e->getMessage());
         return FALSE;
     }
 }
 /**
  * Subscribe an email to a list
  */
 public function subscribe_email($user_info = array(), $list_id = false, $opt_in_overridde = false)
 {
     global $edd_options;
     // Make sure an API key has been entered
     if (empty($edd_options['eddmc_api'])) {
         return false;
     }
     // Retrieve the global list ID if none is provided
     if (!$list_id) {
         $list_id = !empty($edd_options['eddmc_list']) ? $edd_options['eddmc_list'] : false;
         if (!$list_id) {
             return false;
         }
     }
     if (!class_exists('EDD_MailChimp_API')) {
         require_once EDD_MAILCHIMP_PATH . '/includes/MailChimp.class.php';
     }
     $api = new EDD_MailChimp_API(trim($edd_options['eddmc_api']));
     $opt_in = isset($edd_options['eddmc_double_opt_in']) && !$opt_in_overridde;
     $merge_vars = array('FNAME' => $user_info['first_name'], 'LNAME' => $user_info['last_name']);
     if (strpos($list_id, '|') != FALSE) {
         $parts = explode('|', $list_id);
         $list_id = $parts[0];
         $grouping_id = $parts[1];
         $group_name = $parts[2];
         $groupings = array(array('id' => $grouping_id, 'groups' => array($group_name)));
         $merge_vars['groupings'] = $groupings;
     }
     $result = $api->call('lists/subscribe', apply_filters('edd_mc_subscribe_vars', array('id' => $list_id, 'email' => array('email' => $user_info['email']), 'merge_vars' => $merge_vars, 'double_optin' => $opt_in, 'update_existing' => true, 'replace_interests' => false, 'send_welcome' => false)));
     if ($result) {
         return true;
     }
     return false;
 }