Exemplo n.º 1
0
 function getOrdersForRecurring90()
 {
     $m = Application_Models_MongoDB::mConnect();
     $db = $m->selectDB('meundies');
     $collection = $db->selectCollection('orders');
     $query = $collection->find(array('is_recurring' => '1', 'status' => 'approved', 'interval' => $this->interval));
     foreach ($query as $key => $value) {
         $o = new Evin_Order();
         $o->internal_recur_order_process = 1;
         $o->createOrder($query);
     }
 }
 function createCustomer()
 {
     session_save_path('/tmp');
     ini_set('session.gc_probability', 1);
     if (!isset($_SESSION)) {
         session_start();
     }
     $_SESSION['categories'] = $_POST['categories'];
     $_SESSION['sizes'] = $_POST['sizes'];
     $_SESSION['colors'] = $_POST['colors'];
     $_SESSION['gender'] = $_POST['gender'];
     /*
      * Parameters
      */
     $email = $_REQUEST['email'];
     $password_hash = $this->createPasswordHash($_REQUEST['password']);
     /*
      * Mongo model
      */
     $model = new Application_Models_MongoDB();
     $model->createNewCustomer($email, $password_hash);
     /*
      * Grab newly created customer and return customer object
      * Auto login customer
      */
     $customer_object = $model->getCustomerByEmail($email);
     $_SESSION['user'] = $customer_object;
     return $customer_object;
 }
Exemplo n.º 3
0
 function createProduct()
 {
     $model = new Application_Models_MongoDB();
     $model->product_object = $this;
     $model->createProduct();
 }
Exemplo n.º 4
0
 function createNewCustomer()
 {
     /*
      * Customer Object
      */
     $customer_object = new Evin_Customer();
     /*
      * Subscription ID will be first order ever placed by customer.
      * Customer Cannot have more than 1 subscription ID.
      */
     if ($this->one_off == 1) {
     }
     $customer_object->hash_password = Evin_Utility::createRandomTempPassword($this->email);
     $customer_object->subscription_id = $this->order_id;
     $customer_object->bill_first_name = $this->bill_first_name;
     $customer_object->bill_last_name = $this->bill_last_name;
     $customer_object->bill_address = $this->bill_address;
     $customer_object->bill_city = $this->bill_city;
     $customer_object->bill_state = $this->bill_state;
     $customer_object->bill_zip = $this->bill_zip;
     $customer_object->bill_country = $this->bill_country;
     $customer_object->ship_first_name = $this->ship_first_name;
     $customer_object->ship_last_name = $this->ship_last_name;
     $customer_object->ship_address = $this->ship_address;
     $customer_object->ship_city = $this->ship_city;
     $customer_object->ship_state = $this->ship_state;
     $customer_object->ship_zip = $this->ship_zip;
     $customer_object->ship_country = $this->ship_country;
     $customer_object->cc_type = $this->cc_type;
     $customer_object->cc = $this->cc;
     $customer_object->exp_month = $this->exp_month;
     $customer_object->exp_year = $this->exp_year;
     $customer_object->cvv = $this->cvv;
     $customer_object->cc_type = $this->cc_type;
     $customer_object->phone = $this->phone;
     $customer_object->email = $this->email;
     /*
      * Create Customer Model
      */
     $model = new Application_Models_MongoDB();
     $model->customer_object = $customer_object;
     $model->createCustomer();
 }
 function renderView()
 {
     $model = new Application_Models_MongoDB();
     $stuff = $model->renderViewModel($this->db, $this->collection);
     echo '<table>';
     $create_page = $this->collection . '_create.php';
     $search_page = $this->collection . '_search.php';
     echo "<tr><td><h1 style='text-transform: capitalize'>{$this->title}</h1></td></tr>";
     echo "<tr><td><h3 style='text-transform: capitalize'><a href={$create_page}>Create</a></h3></td><td colspan='50px'><h3 style='text-transform: capitalize'><a href={$search_page}>Search</a> </h3</td></tr>";
     /*
      * render keys or fields
      */
     //print_r($stuff);
     foreach ($stuff as $array) {
         echo '<tr style="font-weight: bolder; text-transform: uppercase">';
         foreach ($array as $key => $value) {
             echo '<td>';
             //Remove underscores from keys
             $clean_key = str_replace('_', ' ', $key);
             echo $clean_key;
             echo '</td>';
         }
         echo '<td></td>';
         echo '<td></td>';
         echo '</tr>';
         echo '<tr><td colspan="100%"><hr/></td></tr>';
         break;
     }
     /*
      * Render data
      */
     $count = 0;
     $sum = 0;
     $edit_page = $this->collection . '_edit.php';
     $delete_page = $this->collection . '_delete.php';
     foreach ($stuff as $array) {
         echo '<tr>';
         foreach ($array as $key => $value) {
             if (isset($this->sum) && $key == $this->sum) {
                 echo '<td style="color: green;">';
                 echo '$' . $value;
                 echo '</td>';
             } else {
                 echo '<td>';
                 echo $value;
                 echo '</td>';
             }
         }
         if (isset($this->sum)) {
             $sum = $array[$this->sum] + $sum;
         }
         $count++;
         echo "<td><a href={$edit_page}?id={$array['_id']}>edit</a></td>";
         echo "<td><a href={$delete_page}?id={$array['_id']}>delete</a></td>";
         echo '</tr>';
     }
     echo "<tr><td colspan='100%'><hr/></td></tr>";
     if (isset($this->sum)) {
         $sum_formatted = number_format($sum, 2);
         $sum_formatted = '| SUM: ' . '$' . $sum_formatted;
     }
     echo "<tr><td style='color: #008000; text-transform: capitalize; font-weight: bold;'>Count: {$count} {$sum_formatted}</td>";
     echo '</table>';
 }
Exemplo n.º 6
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();
     }
 }