public function actionSignup()
 {
     if (!Yii::app()->user->isGuest) {
         Yii::app()->request->redirect(basePath('app/gallery'));
     }
     $countryModel = new OldLuCountries();
     $provinceModel = new OldLuProvstates();
     $countryResults = $countryModel->findAll();
     $provincesResults = $provinceModel->findAll();
     $countries = array();
     $provinces = array();
     foreach ($countryResults as $key => $result) {
         $countries[$key] = $result->attributes;
     }
     foreach ($provincesResults as $key => $result) {
         $provinces[$key] = $result->attributes;
     }
     $this->layout = 'main';
     $errors = $this->_getSignUpErrors();
     $data = $this->_getSignUpData();
     $this->render('SignUp', array('errors' => $errors, 'data' => $data, 'countries' => $countries, 'provinces' => $provinces));
 }
 public function getCountries()
 {
     $countryModel = new OldLuCountries();
     $countryResults = $countryModel->findAll();
     $countries = array();
     foreach ($countryResults as $key => $result) {
         $countries[$key] = $result->attributes;
     }
     return $countries;
 }
Esempio n. 3
0
 public static function SendRequest($pp_nvpstr, $userData)
 {
     set_time_limit(1000);
     ini_set('display_errors', 'On');
     $testflag = PayPalHelper::testflag;
     // Set up your API credentials, PayPal end point, and API version.
     if ($testflag) {
         //SANDBOX
         $pp_apiendpoint = "https://api-3t.sandbox.paypal.com/nvp";
         //$pp_nvpstr = $pp_nvpstr."&USER=selpro_1353406222_biz_api1.gmail.com&PWD=1353406266&SIGNATURE=AFcWxV21C7fd0v3bYYYRCpSSRl31A3EBHtTfV8lKwx45fvW2eMcJeim9&VERSION=60.0";	//API Signature: paypalproseller@createmethod.com
         //$pp_nvpstr = $pp_nvpstr."&USER=pro_sk_1359442731_biz_api1.createmethod.com&PWD=1359442797&SIGNATURE=AwiT0IXmzf7bDbash.EkFRUJAK5uAOJfRXjtrgH1-MykaZbUOcJ5BjA8&VERSION=60.0";	//API Signature: sunni@createmethod.com
         $pp_nvpstr = $pp_nvpstr . "&USER=sharedkey.test_api1.createmethod.com&PWD=1386645751&SIGNATURE=AFcWxV21C7fd0v3bYYYRCpSSRl31A5wmiz6FEGRIQ-f9Kr.e2KsqxoO-&VERSION=60.0";
         //API Signature: sharedkey.test@createmethod.com
         $domain = "http://createmethod.ca/sharedkey/";
     } else {
         //LIVE
         $pp_apiendpoint = "https://api-3t.paypal.com/nvp";
         $pp_nvpstr = $pp_nvpstr . "&USER=chris2thrall_api1.gmail.com&PWD=S7M4RXSP3NCBMX6Z&SIGNATURE=AXJTRBNIuY.F1LnvfgK2BtuvvH-dAjViO4DiGx.z.6lveIvnJekgClTv&VERSION=60.0";
         $domain = "http://www.sharedkey.com/";
     }
     try {
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $pp_apiendpoint);
         curl_setopt($ch, CURLOPT_VERBOSE, TRUE);
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
         curl_setopt($ch, CURLOPT_POST, TRUE);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $pp_nvpstr);
         curl_setopt($ch, CURLOPT_TIMEOUT, 320);
         $resp = curl_exec($ch);
         curl_close($ch);
     } catch (Exception $e) {
         die($e->getMessage());
     }
     PayPalHelper::writeLog($pp_nvpstr);
     if (!$resp) {
         die("PayPal cURL error: " . curl_error($ch) . " (" . curl_errno($ch) . "). Please contact <a href='mailto:support@sharedkey.com?subject=PayPal cURL error: " . curl_error($ch) . " (" . curl_errno($ch) . ")'>support@sharedkey.com</a> for technical assistance.");
     }
     $resp_arr = explode("&", $resp);
     $parsedresp_arr = array();
     foreach ($resp_arr as $i => $value) {
         $temp_arr = explode("=", $value);
         if (sizeof($temp_arr) > 1) {
             $parsedresp_arr[$temp_arr[0]] = urldecode($temp_arr[1]);
         }
     }
     PayPalHelper::writeLog($resp);
     //        if ((0 == sizeof($parsedresp_arr)) || !array_key_exists('ACK', $parsedresp_arr)) {
     //            die("PayPal response error: Invalid HTTP Response for POST request to ".$pp_apiendpoint.". Please contact <a href='mailto:support@sharedkey.com?subject=PayPal response error: Invalid HTTP Response for POST request to ".$pp_apiendpoint."'>support@sharedkey.com</a> for technical assistance.");
     //        }
     if ("SUCCESS" == strtoupper($parsedresp_arr['ACK']) || "SUCCESSWITHWARNING" == strtoupper($parsedresp_arr['ACK'])) {
         $transaction = new Transaction();
         $transaction->userid = $userData['id'];
         // Yii::app()->user->getState('id');
         $transaction->username = $userData['firstname'] . ' ' . $userData['lastname'];
         //Yii::app()->user->getState('firstname').' '.Yii::app()->user->getState('lastname');
         $transaction->propertyid = $userData['property_id'];
         //Yii::app()->user->getState('propertyId');
         $transaction->pp_PROFILEID = $parsedresp_arr['PROFILEID'];
         $profileStatus = isset($parsedresp_arr['PROFILESTATUS']) ? $parsedresp_arr['PROFILESTATUS'] : 'CANCELED';
         $transaction->PROFILESTATUS = $profileStatus;
         $transaction->ACK = $parsedresp_arr['ACK'];
         $transaction->CORRELATIONID = $parsedresp_arr['CORRELATIONID'];
         $transaction->VERSION = $parsedresp_arr['VERSION'];
         $transaction->BUILD = $parsedresp_arr['BUILD'];
         $transaction->edt = date('Y-m-d H:i:s');
         if (!$transaction->save()) {
             if ($testflag) {
                 var_dump($userData['id']);
                 //Yii::app()->user->getState('id'));
             }
             echo "Error. Query failed due to: ";
             var_dump($transaction->getErrors());
             die;
         }
         $nowDate = new DateTime();
         $nowDate->setTimestamp(strtotime(PayPalHelper::testflag ? '+2 day' : '+1 year'));
         $countryModel = new OldLuCountries();
         $countryResults = $countryModel->findByAttributes(array('countrycode' => array_key_exists('PP_COUNTRYCODE', $userData) ? $userData['PP_COUNTRYCODE'] : 'US'));
         $property = Properties::model()->findByPk($userData['property_id']);
         $property->adminCountry = $countryResults->countryname;
         $property->renewalDate = $nowDate->format("Y-m-d H:i:s");
         $property->save();
         $date = $nowDate->format('l jS \\of F Y');
         //email customer
         if (!YII::app()->user->getState("addPropertyEmailed") == true) {
             $porpertyName = $property->property_name;
             $body = Yii::app()->controller->renderFile(Yii::getPathOfAlias('application.modules.site.views.emails.renew_success') . ".php", array('fullname' => $userData['firstname'] . ' ' . $userData['lastname'], 'propName' => $porpertyName, 'reneweDate' => $date), true);
             // if($profileStatus == 'ActiveProfile'){
             MailHelper::send($body, "SharedKey.com - Subscription Confirmed", array($userData['email']));
             // }
         }
         YII::app()->user->setState("addPropertyEmailed", null);
     }
     return $parsedresp_arr;
 }