private static function getAPIRequest($foxyData = array())
 {
     $foxy_domain = FoxyCart::getFoxyCartStoreName() . '.foxycart.com';
     $foxyData["api_token"] = FoxyCart::getStoreKey();
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, "https://" . $foxy_domain . "/api");
     curl_setopt($ch, CURLOPT_POSTFIELDS, $foxyData);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
     curl_setopt($ch, CURLOPT_TIMEOUT, 15);
     // If you get SSL errors, you can uncomment the following, or ask your host to add the appropriate CA bundle
     // curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     $response = trim(curl_exec($ch));
     // The following if block will print any CURL errors you might have
     if ($response == false) {
         //trigger_error("Could not connect to FoxyCart API", E_USER_ERROR);
         SS_Log::log("Could not connect to FoxyCart API: " . $response, SS_Log::ERR);
     }
     curl_close($ch);
     return $response;
 }
 public static function getSecret()
 {
     return FoxyCart::getStoreKey();
 }
 public function sso()
 {
     // GET variables from FoxyCart Request
     $fcsid = $this->request->getVar('fcsid');
     $timestampNew = strtotime('+30 days');
     // get current member if logged in. If not, create a 'fake' user with Customer_ID = 0
     // fake user will redirect to FC checkout, ask customer to log in
     // to do: consider a login/registration form here if not logged in
     if ($Member = Member::currentUser()) {
         $Member = Member::currentUser();
     } else {
         $Member = new Member();
         $Member->Customer_ID = 0;
     }
     $auth_token = sha1($Member->Customer_ID . '|' . $timestampNew . '|' . FoxyCart::getStoreKey());
     $redirect_complete = 'https://' . FoxyCart::getFoxyCartStoreName() . '.foxycart.com/checkout?fc_auth_token=' . $auth_token . '&fcsid=' . $fcsid . '&fc_customer_id=' . $Member->Customer_ID . '&timestamp=' . $timestampNew;
     $this->redirect($redirect_complete);
 }