public static function donation_button_mailchimp_handler($posted)
 {
     if (!isset($posted) || empty($posted)) {
         return;
     }
     $debug = get_option('log_enable_mailchimp') == 'yes' ? 'yes' : 'no';
     if ('yes' == $debug) {
         $log = new Donation_Button_Logger();
     }
     $apikey = get_option('mailchimp_api_key');
     $listId = get_option('mailchimp_lists');
     $first_name = isset($posted['first_name']) ? $posted['first_name'] : '';
     $last_name = isset($posted['last_name']) ? $posted['last_name'] : '';
     $payer_email = isset($posted['payer_email']) ? $posted['payer_email'] : $posted['receiver_email'];
     $merge_vars = array('FNAME' => $first_name, 'LNAME' => $last_name);
     if (isset($apikey) && !empty($apikey)) {
         if (isset($listId) && !empty($listId)) {
             include_once 'class-donation-button-mcapi.php';
             $api = new Donation_Button_MailChimp_MCAPI($apikey);
             try {
                 $retval = $api->listSubscribe($listId, $payer_email, $merge_vars, $email_type = 'html');
                 if ('yes' == $debug) {
                     if ("true" == $retval) {
                         $log->add('MailChimp', $payer_email . ' Successfully Add Contact in Mailchimp');
                     } else {
                         $log->add('MailChimp', $payer_email . ' in Mailchimp');
                     }
                 }
             } catch (Mailchimp_Error $e) {
                 if ('yes' == $debug) {
                     $log->add('MailChimp', print_r($e, true));
                 }
             }
         } else {
             if ('yes' == $debug) {
                 $log->add('MailChimp', 'MailChimp List Id is Empty.');
             }
         }
     } else {
         if ('yes' == $debug) {
             $log->add('MailChimp', 'MailChimp Api Key is Empty.');
         }
     }
 }
 public static function donation_buttons_angelleye_get_mailchimp_lists($apikey)
 {
     $mailchimp_lists = array();
     $enable_mailchimp = get_option('enable_mailchimp');
     if (isset($enable_mailchimp) && $enable_mailchimp == 'yes') {
         $mailchimp_lists = unserialize(get_transient('mailchimp_mailinglist'));
         $mailchimp_debug_log = get_option('log_enable_mailchimp') == 'yes' ? 'yes' : 'no';
         $log = new Donation_Button_Logger();
         if (empty($mailchimp_lists) || get_option('donation_buttons_force_refresh') == 'yes') {
             include_once DBP_PLUGIN_DIR . '/includes/class-donation-button-mcapi.php';
             $mailchimp_api_key = get_option('mailchimp_api_key');
             $apikey = isset($mailchimp_api_key) ? $mailchimp_api_key : '';
             $api = new Donation_Button_MailChimp_MCAPI($apikey);
             $retval = $api->lists();
             if ($api->errorCode) {
                 unset($mailchimp_lists);
                 $mailchimp_lists['false'] = __("Unable to load MailChimp lists, check your API Key.", 'doation-button');
                 if ('yes' == $mailchimp_debug_log) {
                     $log->add('MailChimp', 'Unable to load MailChimp lists, check your API Key.');
                 }
             } else {
                 unset($mailchimp_lists);
                 if ($retval['total'] == 0) {
                     if ('yes' == $mailchimp_debug_log) {
                         $log->add('MailChimp', 'You have not created any lists at MailChimp.');
                     }
                     $mailchimp_lists['false'] = __("You have not created any lists at MailChimp", 'doation-button');
                     return $mailchimp_lists;
                 }
                 foreach ($retval['data'] as $list) {
                     $mailchimp_lists[$list['id']] = $list['name'];
                 }
                 if ('yes' == $mailchimp_debug_log) {
                     $log->add('MailChimp', 'MailChimp Get List Success..');
                 }
                 set_transient('mailchimp_mailinglist', serialize($mailchimp_lists), 86400);
                 update_option('donation_buttons_force_refresh', 'no');
             }
         }
     }
     return $mailchimp_lists;
 }