public function renderOrderPrintSlip() { $o = StoreOrder::getByID($this->post('oID')); if (Filesystem::exists(DIR_BASE . "/application/elements/order_slip.php")) { View::element("order_slip", array('order' => $o)); } else { View::element("order_slip", array('order' => $o), "vivid_store"); } }
public function view() { $customer = new StoreCustomer(); $order = StoreOrder::getByID($customer->getLastOrderID()); if (is_object($order)) { $this->set("order", $order); } else { $this->redirect("/cart"); } $this->requireAsset('javascript', 'vivid-store'); $this->requireAsset('css', 'vivid-store'); }
public function view() { $customer = new StoreCustomer(); if ($customer->getLastOrderID()) { $order = StoreOrder::getByID($customer->getLastOrderID()); } if (is_object($order)) { $this->set("order", $order); } else { $this->redirect("/cart"); } $this->requireAsset('javascript', 'jquery'); $js = \Concrete\Package\VividStore\Controller::returnHeaderJS(); $this->addFooterItem($js); $this->requireAsset('javascript', 'vivid-store'); $this->requireAsset('css', 'vivid-store'); }
public function getOrder() { return StoreOrder::getByID($this->getOrderID()); }
public function remove($oID) { StoreOrder::getByID($oID)->remove(); $this->redirect('/dashboard/store/orders/removed'); }
public static function validateCompletion() { // Read POST data // reading posted data directly from $_POST causes serialization // issues with array data in POST. Reading raw POST data from input stream instead. $raw_post_data = file_get_contents('php://input'); $raw_post_array = explode('&', $raw_post_data); $myPost = array(); foreach ($raw_post_array as $keyval) { $keyval = explode('=', $keyval); if (count($keyval) == 2) { $myPost[$keyval[0]] = urldecode($keyval[1]); } } // read the post from PayPal system and add 'cmd' $req = 'cmd=_notify-validate'; if (function_exists('get_magic_quotes_gpc')) { $get_magic_quotes_exists = true; } foreach ($myPost as $key => $value) { if ($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) { $value = urlencode(stripslashes($value)); } else { $value = urlencode($value); } $req .= "&{$key}={$value}"; } // Post IPN data back to PayPal to validate the IPN data is genuine // Without this step anyone can fake IPN data if (Config::get('vividstore.paypalTestMode') == true) { $paypal_url = "https://www.sandbox.paypal.com/cgi-bin/webscr"; } else { $paypal_url = "https://www.paypal.com/cgi-bin/webscr"; } $ch = curl_init($paypal_url); if ($ch == false) { return false; } curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $req); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_FORBID_REUSE, 1); if (DEBUG == true) { curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLINFO_HEADER_OUT, 1); } // CONFIG: Optional proxy configuration //curl_setopt($ch, CURLOPT_PROXY, $proxy); //curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1); // Set TCP timeout to 30 seconds curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close')); // CONFIG: Please download 'cacert.pem' from "http://curl.haxx.se/docs/caextract.html" and set the directory path // of the certificate as shown below. Ensure the file is readable by the webserver. // This is mandatory for some environments. //$cert = __DIR__ . "./cacert.pem"; //curl_setopt($ch, CURLOPT_CAINFO, $cert); $res = curl_exec($ch); if (curl_errno($ch) != 0) { // cURL error Log::addEntry("Can't connect to PayPal to validate IPN message: " . curl_error($ch)); curl_close($ch); exit; } else { //if we want to log more stuff //Log::addEntry("HTTP request of validation request:". curl_getinfo($ch, CURLINFO_HEADER_OUT) ." for IPN payload: $req"); //Log::addEntry("HTTP response of validation request: $res"); curl_close($ch); } // Inspect IPN validation result and act accordingly // Split response headers and payload, a better way for strcmp $tokens = explode("\r\n\r\n", trim($res)); $res = trim(end($tokens)); if (strcmp($res, "VERIFIED") == 0) { $order = StoreOrder::getByID($_POST['invoice']); $order->completeOrder($_POST['txn_id']); $order->updateStatus(StoreOrderStatus::getStartingStatus()->getHandle()); } elseif (strcmp($res, "INVALID") == 0) { // log for manual investigation // Add business logic here which deals with invalid IPN messages Log::addEntry("Invalid IPN: {$req}"); } }
public function getOrderItems() { $orders = $this->getResults(); $orderItems = array(); $db = Database::get(); foreach ($orders as $order) { $oID = $order->getOrderID(); $OrderOrderItems = $db->GetAll("SELECT * FROM VividStoreOrderItems WHERE oID=?", $oID); foreach ($OrderOrderItems as $oi) { $oi = StoreOrder::getByID($oi['oiID']); $orderItems[] = $oi; } } return $orderItems; }
public function add($data, $oID, $tax = 0, $taxIncluded = 0, $taxName = '') { $db = Database::connection(); $product = StoreProduct::getByID($data['product']['pID']); $productName = $product->getProductName(); $productPrice = $product->getActivePrice(); $sku = $product->getProductSKU(); $qty = $data['product']['qty']; $inStock = $product->getProductQty(); $newStock = $inStock - $qty; $variation = $product->getVariation(); if ($variation) { if (!$variation->isUnlimited()) { $product->updateProductQty($newStock); } } elseif (!$product->isUnlimited()) { $product->updateProductQty($newStock); } $order = StoreOrder::getByID($oID); $orderItem = new self(); $orderItem->setProductName($productName); $orderItem->setSKU($sku); $orderItem->setPricePaid($productPrice); $orderItem->setTax($tax); $orderItem->setTaxIncluded($taxIncluded); $orderItem->setTaxName($taxName); $orderItem->setQty($qty); $orderItem->setOrder($order); if ($product) { $orderItem->setProductID($product->getID()); } $orderItem->save(); foreach ($data['productAttributes'] as $optionGroup => $selectedOption) { $optionGroupID = str_replace("pog", "", $optionGroup); $optionGroupName = self::getProductOptionGroupNameByID($optionGroupID); $optionValue = self::getProductOptionValueByID($selectedOption); $orderItemOption = new StoreOrderItemOption(); $orderItemOption->setOrderItemOptionKey($optionGroupName); $orderItemOption->setOrderItemOptionValue($optionValue); $orderItemOption->setOrderItem($orderItem); $orderItemOption->save(); } return $orderItem; }
public function getResult($queryRow) { return StoreOrder::getByID($queryRow['oID']); }