Example #1
0
 function setProperties()
 {
     $this->product_id = Evin_Utility::genRandomString();
     $this->product_name = $_REQUEST['name'];
     $this->product_description = $_REQUEST['description'];
     $this->product_price = $_REQUEST['price'];
     $this->product_color = $_REQUEST['color'];
     $this->product_size = $_REQUEST['size'];
     $this->product_sku = $_REQUEST['sku'];
     $this->product_gender = $_REQUEST['gender'];
     $this->product_category = $_REQUEST['category'];
     $this->product_date = new MongoTimestamp();
 }
Example #2
0
 function setSanitizeRequestData()
 {
     //$this->offer_id = $this->lower_case($this->db_sanitize($_REQUEST['offer_id']));
     $this->bill_first_name = $this->lower_case($this->db_sanitize($_REQUEST['bill_first_name']));
     $this->bill_last_name = $this->lower_case($this->db_sanitize($_REQUEST['bill_last_name']));
     $this->bill_address = $this->lower_case($this->db_sanitize($_REQUEST['bill_address']));
     $this->bill_city = $this->lower_case($this->db_sanitize($_REQUEST['bill_city']));
     $this->bill_state = $this->lower_case($this->db_sanitize($_REQUEST['bill_state']));
     $this->bill_zip = $this->lower_case($this->db_sanitize($_REQUEST['bill_zip']));
     $this->bill_country = $this->upper_case($this->db_sanitize($_REQUEST['bill_country']));
     $this->same_as_billing = $this->db_sanitize($_REQUEST['same_as_billing']);
     if ($this->same_as_billing != 1) {
         $this->ship_first_name = $this->lower_case($this->db_sanitize($_REQUEST['ship_first_name']));
         $this->ship_last_name = $this->lower_case($this->db_sanitize($_REQUEST['ship_last_name']));
         $this->ship_address = $this->lower_case($this->db_sanitize($_REQUEST['ship_address']));
         $this->ship_city = $this->lower_case($this->db_sanitize($_REQUEST['ship_city']));
         $this->ship_state = $this->lower_case($this->db_sanitize($_REQUEST['ship_state']));
         $this->ship_zip = $this->lower_case($this->db_sanitize($_REQUEST['ship_zip']));
         $this->ship_country = $this->upper_case($this->db_sanitize($_REQUEST['ship_country']));
     } else {
         $this->ship_first_name = $this->lower_case($this->db_sanitize($_REQUEST['bill_first_name']));
         $this->ship_last_name = $this->lower_case($this->db_sanitize($_REQUEST['bill_last_name']));
         $this->ship_address = $this->lower_case($this->db_sanitize($_REQUEST['bill_address']));
         $this->ship_city = $this->lower_case($this->db_sanitize($_REQUEST['bill_city']));
         $this->ship_state = $this->lower_case($this->db_sanitize($_REQUEST['bill_state']));
         $this->ship_zip = $this->lower_case($this->db_sanitize($_REQUEST['bill_zip']));
         $this->ship_country = $this->upper_case($this->db_sanitize($_REQUEST['bill_country']));
     }
     $this->notes = $this->lower_case($this->db_sanitize($_REQUEST['n']));
     $this->phone = $this->phone_normalize($this->db_sanitize($_REQUEST['phone']));
     $this->email = $this->db_sanitize($_REQUEST['email']);
     $this->order_ip = $_SERVER['SERVER_ADDR'];
     $this->browser = $_SERVER['HTTP_USER_AGENT'];
     $this->browser_language = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
     $this->request_time = $_SERVER['REQUEST_TIME'];
     if (!isset($_SERVER['HTTP_REFERER'])) {
         $this->referral_url = '';
     } else {
         $this->referral_url = $_SERVER['HTTP_REFERER'];
     }
     if (!isset($_SERVER['aff_id'])) {
         $this->referral_url = '';
     } else {
         $this->aff_id = $this->db_sanitize($_REQUEST['aff_id']);
     }
     $this->currency = $this->db_sanitize($_REQUEST['curr']);
     /*
      * Credit Card Data setting and encryption.
      */
     $encrypt = new Evin_Crypt();
     $this->cc = $encrypt->encode($_REQUEST['cc']);
     $this->cc_type = $this->db_sanitize($_REQUEST['cc_type']);
     $this->cvv = $encrypt->encode($_REQUEST['cvv']);
     $this->exp_month = $this->db_sanitize($_REQUEST['exp_month']);
     $this->exp_year = $this->db_sanitize($_REQUEST['exp_year']);
     /*
      * Recurring rules (Next billing day logic)
      */
     if ($_REQUEST['is_recurring'] == 1) {
         $this->is_recurring = (int) $this->db_sanitize($_REQUEST['is_recurring']);
         $this->is_recurring_active = 1;
         try {
             // 30 interval handler
             if ($this->recurring_interval == 30) {
                 if (date('d') > 20) {
                     $next_next_month = date("m", strtotime("+2 months"));
                     $day = '06';
                     //6th of every month is billing for recurring orders of the previous month between 1-20 after 20th next billing cycle.
                     //If this month is december the next month will have different year. This handles that
                     if (date('m') == 12) {
                         $year = date("y", strtotime("+1 year"));
                     } else {
                         $year = date('y');
                     }
                     $this->next_billing_date = $next_next_month . $day . $year;
                 } else {
                     $next_month = date("m", strtotime("+1 months"));
                     $day = '06';
                     //6th of every month is billing for recurring orders of the previous month between 1-20 after 20th next billing cycle.
                     //If this month is december the next month will have different year. This handles that
                     if (date('m') == 12) {
                         $year = date("y", strtotime("+1 year"));
                     } else {
                         $year = date('y');
                     }
                     $this->next_billing_date = $next_month . $day . $year;
                 }
             } elseif ($this->recurring_interval == 90) {
                 //Q1 - Jan 6th
                 //Q2 - April 6th
                 //Q3 - July 6th
                 //Q4 - October 6th
                 // 90 intervals there is no trailing courtesy rule
                 if (date('m') == 1 || date('m') == 2 || date('m') == 3) {
                     $this->next_billing_date = '0406' . date('y');
                 } elseif (date('m') == 4 || date('m') == 5 || date('m') == 6) {
                     $this->next_billing_date = '0706' . date('y');
                 } elseif (date('m') == 7 || date('m') == 8 || date('m') == 9) {
                     $this->next_billing_date = '1006' . date('y');
                 } elseif (date('m') == 10 || date('m') == 11 || date('m') == 12) {
                     $next_year = date("y", strtotime("+1 year"));
                     $this->next_billing_date = '0106' . $next_year;
                 }
             }
         } catch (Exception $e) {
             echo $e->getMessage();
         }
         echo '<h3>NEXT BILL DATE</h3>';
         echo $this->next_billing_date;
         echo '<br/>';
         echo $year_from_now = strtotime("050612 +1 year");
         echo "<br/>" . ($print = date('m-d-y', $year_from_now));
         echo '<br/>';
         echo '<br/>';
     }
     /*
      * Product IDS process and summation
      */
     //-------qty----------
     $this->qty = $this->db_sanitize($_REQUEST['qty']);
     $arrayed_qty = explode(',', $this->qty);
     //qty initial iteration value
     $qty_i = 0;
     //-----------------
     $this->product_object = $product_object = array();
     $this->product_ids = $this->db_sanitize($_REQUEST['product_ids']);
     $arrayed_ids = explode(',', $this->product_ids);
     // product sum initial value
     $product_sum = 0.0;
     foreach ($arrayed_ids as $sku) {
         $qty = $arrayed_qty[$qty_i];
         $model = new Application_Models_MongoDB();
         $model->sku = $sku;
         $p_object = $model->getProductBySKU();
         array_push($p_object, $product_object);
         $product_sum = $p_object['price'] * $qty + $product_sum;
         print_r($p_object);
         $this->product_object = $product_object;
         $qty_i++;
     }
     echo $product_sum = number_format($product_sum, 2);
     /*
      * Product IDS process and summation end
      */
     $this->recurring_interval = $this->db_sanitize($_REQUEST['recurring_interval']);
     $this->shipping = $this->db_sanitize($_REQUEST['shipping']);
     // $this->amount = $this->db_sanitize($_REQUEST['amount']);
     if ($this->bill_state == 'ca') {
         $this->tax_amount = $product_sum * $this->tax;
         $this->grand_total = number_format($product_sum + $this->shipping + $this->tax_amount, 2);
     } else {
         $this->grand_total = $product_sum + $this->shipping;
     }
     //Discount
     if ($this->is_discount == 1) {
         $this->grand_total - $this->is_discount_value;
     }
     //Promo Code
     if ($this->is_promo_code == 1) {
         $this->grand_total - $this->is_promo_value;
     }
     if ($this->is_upsell == 1) {
         $this->product_ids = ',' . $this->upsell_product_ids;
     }
     $this->payment_service = $this->db_sanitize($_REQUEST['payment_service']);
     $this->timestamp = new MongoTimestamp();
     $this->php_timestamp = time();
     $this->php_date = date('dmy');
     $this->date = new MongoDate();
     //$this->internal_recur_order_process = $this->db_sanitize($_REQUEST['internal_recur_order_process']);
     //Set geo properties
     $geo = new Evin_Geo();
     $geo->address = $this->bill_zip;
     $geo->requestGeo();
     //set
     $this->loc = array('lon' => $geo->lon, 'lat' => $geo->lat);
     //$this->lon = $geo->lon;
     //$this->lat = $geo->lat;
     /*
      * Date Time Assignment
      */
     $d = date('mdy');
     $t = time();
     /*
      * Create Order ID
      */
     $this->order_id = 'M' . strtoupper(Evin_Utility::genRandomString());
     /*
      * Set PHP time
      *
      */
     $this->php_date = $d;
     $this->one_off = $_REQUEST['one_off'];
     return $this;
 }
Example #3
0
 function createRecurOrder()
 {
     try {
         $model = new Application_Models_MongoDB();
         $model->order_id = $this->order_id;
         $obj = $model->getOrderById();
         //Set object to send to mongoDB
         $this->bill_first_name = $obj['bill_first_name'];
         $this->bill_last_name = $obj['bill_last_name'];
         $this->bill_first_name = $obj['bill_first_name'];
         $this->bill_address = $obj['bill_address'];
         $this->bill_city = $obj['bill_city'];
         $this->bill_state = $obj['bill_state'];
         $this->bill_zip = $obj['bill_zip'];
         $this->bill_country = $obj['bill_country'];
         $this->same_as_billing = $obj['same_as_billing'];
         $this->ship_first_name = $obj['ship_first_name'];
         $this->ship_last_name = $obj['ship_first_name'];
         $this->ship_address = $obj['ship_address'];
         $this->ship_city = $obj['ship_address'];
         $this->ship_state = $obj['ship_state'];
         $this->ship_zip = $obj['ship_zip'];
         $this->ship_country = $obj['ship_country'];
         $this->phone = $obj['phone'];
         $this->email = $obj['email'];
         $this->cc_type = $obj['cc_type'];
         $this->cc = $obj['cc'];
         $this->cvv = $obj['cvv'];
         $this->exp_month = $obj['exp_month'];
         $this->exp_year = $obj['exp_year'];
         $this->amount = $obj['amount'];
         $this->tax = $obj['tax'];
         $this->tax_amount = $obj['tax_amount'];
         $this->grand_total = $obj['grand_total'];
         $this->shipping = $obj['shipping'];
         $this->product_ids = $obj['product_ids'];
         $this->notes = $obj['notes'];
         $this->order_ip = $obj['order_ip'];
         $this->is_recurring = 1;
         $this->recurring_interval = $obj['recurring_interval'];
         $this->is_parent_order = 0;
         $this->parent_order_id = $obj['order_id'];
         $this->preceding_order_id = $model->order_id;
         $this->order_type = 'recur';
         $this->is_recurring_active = $obj['order_ip'];
         $this->referral_url = $obj['referral_url'];
         $this->aff_id = $obj['aff_id'];
         $this->browser = $obj['browser'];
         $this->browser = $obj['browser_language'];
         $this->currency = $obj['currency'];
         $this->request_time = $_SERVER['REQUEST_TIME'];
         $this->payment_service = $obj['payment_service'];
         $this->order_ip = $obj['order_ip'];
         /*
          * Create New Order ID
          */
         $this->order_id = 'MR' . strtoupper(Evin_Utility::genRandomString());
         $this->is_discount = $obj['is_discount'];
         $this->is_discount_value = $obj['is_discount_value'];
         $this->is_promo_code = $obj['is_promo_code'];
         $this->is_promo_value = $obj['is_promo_value'];
         $this->is_upsell = $obj['is_upsell'];
         $this->upsell_product_ids = $obj['upsell_product_ids'];
         $this->date = new MongoDate();
         $this->php_date = date('mdy');
         $this->timestamp = new MongoTimestamp();
         $this->php_timestamp = time();
         $this->loc = array('lon' => $obj['long'], 'lat' => $obj['lat']);
         //$this->lon = $obj['long'];
         //$this->lat = $obj['lat'];
         $p = new Evin_Authorize('4bvC73F7', '427De3sVrs378S2N');
         /*
          * @todo decrypt cc
          */
         $p->setTransaction($obj['cc'], $obj['exp_month'] . $obj['exp_year'], $obj['grand_total']);
         $p->setParameter('x_email', $obj['email']);
         $p->setParameter("x_duplicate_window", 180);
         $p->setParameter("x_cust_id", $this->email);
         //$p->setParameter("x_transaction_id", 'wrwrw');
         $p->setParameter("x_customer_ip", $_SERVER['REMOTE_ADDR']);
         $p->setParameter("x_email_customer", true);
         // false for testing
         $p->setParameter("x_first_name", $obj['bill_first_name']);
         $p->setParameter("x_last_name", $obj['bill_last_name']);
         $p->setParameter("x_address", $obj['bill_address']);
         $p->setParameter("x_city", $obj['bill_city']);
         $p->setParameter("x_state", $obj['bill_state']);
         $p->setParameter("x_zip", $obj['bill_zip']);
         $p->setParameter("x_phone", $obj['bill_country']);
         $p->setParameter("x_ship_to_first_name", $obj['ship_first_name']);
         $p->setParameter("x_ship_to_last_name", $obj['ship_last_name']);
         $p->setParameter("x_ship_to_address", $obj['ship_address']);
         $p->setParameter("x_ship_to_city", $obj['ship_city']);
         $p->setParameter("x_ship_to_state", $obj['ship_state']);
         $p->setParameter("x_ship_to_zip", $obj['ship_zip']);
         $p->setParameter("x_description", 'Order Id: re,' . $obj['order_id']);
         $p->setParameter("x_tax", $obj['tax_amount']);
         //$p->setParameter("")
         $p->process();
         if ($p->isApproved()) {
             $this->order_status = 'Approved';
             $this->is_recurring_active = 1;
         } else {
             $this->order_status = 'Declined';
             $this->is_recurring_active = 0;
         }
         $explode = explode('|', $p->response);
         $this->payment_service_response = $explode;
         print_r($p);
         //todo save into mongoDB
         $m = new Mongo();
         $db = $m->selectDB('meundies');
         $collection = $db->selectCollection('orders');
         $collection->insert($this);
         return $obj;
         //$p = new Evin_Authorize();
         //$charge $p->chargeCreditCard();
     } catch (Exception $e) {
         echo $e->getMessage();
     }
 }