public function ping($api_key)
 {
     if (empty($api_key)) {
         return false;
     }
     $api = new GetResponseAPI3($api_key);
     $ping = $api->ping();
     if (isset($ping->accountId)) {
         return true;
     } else {
         return false;
     }
 }
 function process()
 {
     global $order;
     if (!$this->enabled) {
         return;
     }
     try {
         $client = new GetResponseAPI3(MODULE_ORDER_TOTAL_GETRESPONSE_API_KEY);
         $result = $client->getCampaigns(array('query' => array('name' => MODULE_ORDER_TOTAL_GETRESPONSE_CAMPAIGN)));
         if (empty($result)) {
             throw new Exception('Missing GetResponse campaign: ' . MODULE_ORDER_TOTAL_GETRESPONSE_CAMPAIGN);
         }
         $customs = $client->getCustomFields();
         foreach ($customs as $custom) {
             if ($custom->name == 'ref') {
                 $refCustomId = $custom->customFieldId;
             }
             if ($custom->name == 'zencart_phone') {
                 $phoneCustomId = $custom->customFieldId;
             }
             if ($custom->name == 'country') {
                 $countryCustomId = $custom->customFieldId;
             }
             if ($custom->name == 'city') {
                 $cityCustomId = $custom->customFieldId;
             }
         }
         if (empty($phoneCustomId)) {
             $response = $client->addCustomField(array('name' => 'zencart_phone', 'type' => 'text', 'hidden' => 'false', 'values' => array()));
             $phoneCustomId = $response->customFieldId;
         }
         $campaignId = reset($result)->campaignId;
         $params = array('email' => $order->customer['email_address'], 'name' => $order->customer['firstname'] . ' ' . $order->customer['lastname'], 'campaign' => array('campaignId' => $campaignId), 'dayOfCycle' => '0', 'customFieldValues' => array(array('customFieldId' => $refCustomId, 'value' => array(STORE_NAME)), array('customFieldId' => $phoneCustomId, 'value' => array($order->customer['telephone'])), array('customFieldId' => $countryCustomId, 'value' => array($order->customer['country']['title'])), array('customFieldId' => $cityCustomId, 'value' => array($order->customer['city']))));
         $result = $client->addContact($params);
     } catch (Exception $e) {
         error_log($e->getMessage());
         return;
     }
 }