Example #1
0
 function chargeCard()
 {
     try {
         print_r('<pre>');
         //@todo decrypt CC info for payment process
         $crypt = new Evin_Crypt();
         $cc = $crypt->decode($this->cc);
         $p = new Evin_Authorize('4bvC73F7', '427De3sVrs378S2N');
         $p->setTransaction($cc, $this->exp_month . $this->exp_year, $this->grand_total);
         $p->setParameter('x_email', $this->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", false);
         // false for testing
         $p->setParameter("x_first_name", $this->bill_first_name);
         $p->setParameter("x_last_name", $this->bill_last_name);
         $p->setParameter("x_address", $this->bill_address);
         $p->setParameter("x_city", $this->bill_city);
         $p->setParameter("x_state", $this->bill_state);
         $p->setParameter("x_zip", $this->bill_zip);
         $p->setParameter("x_phone", $this->phone);
         $p->setParameter("x_ship_to_first_name", $this->ship_first_name);
         $p->setParameter("x_ship_to_last_name", $this->ship_last_name);
         $p->setParameter("x_ship_to_address", $this->ship_address);
         $p->setParameter("x_ship_to_city", $this->ship_city);
         $p->setParameter("x_ship_to_state", $this->ship_state);
         $p->setParameter("x_ship_to_zip", $this->ship_zip);
         $p->setParameter("x_description", 'Order Id: ' . $this->order_id);
         $p->setParameter("x_tax", $this->tax_amount);
         //$p->setParameter("")
         $p->process();
         if ($p->isApproved()) {
             $this->order_status = 'Approved';
         } else {
             $this->order_status = 'Declined';
         }
         /*
          * Prepare gateway response object to append into order object under property payment_service_response
          */
         $explode = explode('|', $p->response);
         $this->payment_service_response = $explode;
         print_r($p);
     } catch (Exception $e) {
         echo $e->getMessage();
     }
     return $this;
 }
Example #2
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();
     }
 }