public static function donation_button_getresponse_handler($posted)
 {
     if (!isset($posted) || empty($posted)) {
         return;
     }
     $debug = get_option('log_enable_Getrsponse') == 'yes' ? 'yes' : 'no';
     if ('yes' == $debug) {
         $log = new Donation_Button_Logger();
     }
     $apikey = get_option('getresponse_api_key');
     $campaigns = get_option('getresponse_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);
     $name = $first_name . ' ' . $last_name;
     if (isset($apikey) && !empty($apikey) && (isset($campaigns) && !empty($campaigns))) {
         include_once DBP_PLUGIN_DIR_PATH . 'admin/partials/lib/getresponse/getresponse.php';
         try {
             $api = new Donation_Button_Getesponse_API($apikey);
             $retval = $api->addContact($campaigns, $name, $payer_email);
             if ('yes' == $debug) {
                 if ($retval) {
                     $log->add('Getresponse', $payer_email . ' Successfully Add Contact in Getresponse');
                 } else {
                     $log->add('Getresponse', $payer_email . ' Contact already added to target campaign in Getresponse');
                 }
             }
         } catch (Exception $e) {
             if ('yes' == $debug) {
                 $log->add('Getresponse', print_r($e, true));
             }
         }
     } else {
         $log->add('Getresponse', 'Getresponse Api Key is Empty.');
     }
 }
 public static function donation_button_get_getresponse_lists($apikey)
 {
     $getresponse_lists = array();
     $enable_getresponse = get_option('enable_getresponse');
     if (isset($enable_getresponse) && $enable_getresponse == 'yes') {
         $getresponse_debug = get_option('log_enable_Getrsponse') == 'yes' ? 'yes' : 'no';
         $log = new Donation_Button_Logger();
         if (isset($apikey) && !empty($apikey)) {
             $getresponse_lists = unserialize(get_transient('donation_button_getresponse_list'));
             if (empty($getresponse_lists) || get_option('donation_button_getresponse_force_refresh') == 'yes') {
                 include_once DBP_PLUGIN_DIR_PATH . 'admin/partials/lib/getresponse/getresponse.php';
                 $api = new Donation_Button_Getesponse_API($apikey);
                 $campaigns = $api->getCampaigns();
                 $campaigns = (array) $campaigns;
                 if (count($campaigns) > 0 and is_array($campaigns)) {
                     unset($getresponse_lists);
                     foreach ($campaigns as $list_id => $list) {
                         $list = (array) $list;
                         $getresponse_lists[$list_id] = $list['name'];
                     }
                     delete_transient('donation_button_getresponse_list');
                     set_transient('donation_button_getresponse_list', serialize($getresponse_lists), 86400);
                     if ('yes' == $getresponse_debug) {
                         $log->add('Getresponse', 'Getresponse Get List Success..');
                     }
                     update_option('donation_button_getresponse_force_refresh', 'no');
                 } else {
                     unset($getresponse_lists);
                     $getresponse_lists = array();
                     $getresponse_lists['false'] = __("Unable to load Getresponse lists, check your API Key.", 'autoresponder');
                     if ('yes' == $getresponse_debug) {
                         $log->add('Getresponse', 'Unable to load Getresponse lists, check your API Key.');
                     }
                 }
             }
         } else {
             $getresponse_lists['false'] = __("API Key is empty.", 'autoresponder');
             if ('yes' == $getresponse_debug) {
                 $log->add('Getresponse', 'API Key is empty.');
             }
         }
     }
     return $getresponse_lists;
 }