public function declinedAction() { $producturrency = new Admin_Model_DbTable_Countries(); $modelAuthor = new Publisher_Model_DbTable_Publishers(); $tempObj = new Model_DbTable_Checkout(); $creditHistoryObj = new User_Model_DbTable_Chistory(); $transactionHistoryObj = new User_Model_DbTable_Transactionhistory(); $productPrice = new Publisher_Model_DbTable_BookPrices(); $modelImage = new Publisher_Model_DbTable_BookImages(); $modelStore = new Admin_Model_DbTable_Countries(); $productPrice = new Publisher_Model_DbTable_BookPrices(); $this->modelBooks = new Publisher_Model_DbTable_Books(); $response = $_POST['xmlmsg']; $xml_string = $_POST['xmlmsg']; $parsedxml = simplexml_load_string(stripslashes($response)); $formDataTransDeclined = array(); foreach ($parsedxml as $RESPONSENODE) { if ($RESPONSENODE->getName() == 'OrderID') { $orderId = $RESPONSENODE; $orderIdForPurchase = $RESPONSENODE; } if ($RESPONSENODE->getName() == 'TransactionType') { $transactionType = $RESPONSENODE; } if ($RESPONSENODE->getName() == 'PAN') { $pan = $RESPONSENODE; } if ($RESPONSENODE->getName() == 'PurchaseAmountScr') { $purchaseAmount = $RESPONSENODE; } if ($RESPONSENODE->getName() == 'TranDateTime') { $tranDateTime = $RESPONSENODE; } if ($RESPONSENODE->getName() == 'ResponseCode') { $responseCode = $RESPONSENODE; } if ($RESPONSENODE->getName() == 'ResponseDescription') { $responseDescription = $RESPONSENODE; } if ($RESPONSENODE->getName() == 'OrderStatusScr') { $orderStatus = $RESPONSENODE; } if ($RESPONSENODE->getName() == 'ApprovalCode') { $approvalCode = $RESPONSENODE; } if ($RESPONSENODE->getName() == 'MerchantTranID') { $merchantTranId = $RESPONSENODE; } if ($RESPONSENODE->getName() == 'OrderDescription') { $orderDescription = $RESPONSENODE; } if ($RESPONSENODE->getName() == 'ApprovalCodeScr') { $approvalCodeScr = $RESPONSENODE; } if ($RESPONSENODE->getName() == 'CurrencyScr') { $currency = $RESPONSENODE; } if ($RESPONSENODE->getName() == 'ThreeDSVerificaion') { $threeDsVerification = $RESPONSENODE; } if ($RESPONSENODE->getName() == 'Brand') { $brandname = $RESPONSENODE; } if ($RESPONSENODE->getName() == 'Name') { $card_holder_name = $RESPONSENODE; } if ($RESPONSENODE->getName() == 'ThreeDSStatus') { $ThreeDSStatus = $RESPONSENODE; } if ($RESPONSENODE->getName() == 'MerchantTranID') { $MerchantTranID = $RESPONSENODE; } } $formDataTransDeclined = array("orderId" => $orderId, "transactionType" => $transactionType, "pan" => $pan, "purchaseAmount" => $purchaseAmount, "tranDateTime" => $tranDateTime, "responseCode" => $responseCode, "responseDescription" => $responseDescription, "orderStatus" => $orderStatus, "approvalCode" => $approvalCode, "approvalCode" => $approvalCode, "merchantTranId" => $merchantTranId, "orderDescription" => $orderDescription, "approvalCodeScr" => $approvalCodeScr, "currency" => $currency, "brand" => $brandname, "card_holder_name" => $card_holder_name, "ThreeDSStatus" => $ThreeDSStatus, "threeDsVerification" => $threeDsVerification, "transaction_xml" => $xml_string); //$dataTrans = array("orderId"=>) $inserted_id = $transactionHistoryObj->insert($formDataTransDeclined); ############## update table ########################### if ($orderStatus == 'DECLINED') { $orderSt = 2; } else { $orderSt = 0; } $tempTransactionUpdate = array("payment_status" => $orderSt, "transaction_id" => $inserted_id); //$tempObj->update($tempTransactionUpdate,'user_id="'.$user_id.'"'); $creditHistoryObj->update($tempTransactionUpdate, "order_id='" . $orderId . "'"); $modelSubscription = new Publisher_Model_DbTable_Subscriptions(); ########################################################## $tempData = $tempObj->fetchAll("order_id='" . $orderIdForPurchase . "' and is_purchase!='1'"); $order_details = "<table cellpadding='1'><tr><td colspan='3'>Your reference Id</td></tr><tr><td colspan='3'>Order Id:" . $orderId . "</td></tr><tr><td colspan='3'>Transaction ID:" . $inserted_id . "</td></tr><tr><td>Item</td><td>Price</td><td>Subscription Details</td><td>Subscription Details</td><td>Number of Issues</td><td>Start Date</td><td>End Date</td><td>Quantity</td></tr>"; $modelSubscription = new Publisher_Model_DbTable_Subscriptions(); foreach ($tempData as $dataDet) { $productPriceInfo = $productPrice->getPriceByStoreId($dataDet['product_id'], $dataDet['store_id']); $subscription_data = $modelSubscription->fetchAll('id="' . $dataDet['subscription_type'] . '"'); if ($dataDet['group_id'] > 0) { $price = $productPriceInfo['group_price']; } else { $price = $productPriceInfo['price']; } $getCurrencyName = $producturrency->getCurrencyCode($dataDet['store_id']); $product_details = $this->modelBooks->fetchRow("id='" . $dataDet['product_id'] . "'"); $getBrandInfo = $this->modelBooks->getBrandInfo($product_details['title']); if (!empty($getBrandInfo) && is_numeric($this->{$product_details}['title'])) { $titleBrand = $getBrandInfo['brand']; } else { $titleBrand = $product_details['title']; } if (!empty($product_details['parent_brand_id']) && $product_details['cat_id'] != '3') { $productInfo = $this->modelBooks->fetchRow('id="' . $product_details['parent_brand_id'] . '"'); $getParentBrandInfo = $this->modelBooks->getBrandInfo($productInfo->title); if (!empty($getParentBrandInfo)) { $titleBrand = $getParentBrandInfo['brand'] . " - " . $titleBrand; } else { } } $subscription_data = $modelSubscription->fetchAll('id="' . $dataDet['subscription_type'] . '"'); $todaysdate = date('Y-m-d H:i:s'); if ($dataDet['subscription_name'] == 'Weekly') { $date = new DateTime($todaysdate); $date->modify("+7 day"); $end_date = $date->format("Y-m-d H:i:s"); } else { if ($dataDet['subscription_name'] == 'Monthly') { $date = new DateTime($todaysdate); $date->modify("+30 day"); $end_date = $date->format("Y-m-d H:i:s"); } else { if ($dataDet['subscription_name'] == 'Quarterly') { $date = new DateTime($todaysdate); $date->modify("+90 day"); $end_date = $date->format("Y-m-d H:i:s"); } else { if ($dataDet['subscription_name'] == 'Half Yearly') { $date = new DateTime($todaysdate); $date->modify("+182 day"); $end_date = $date->format("Y-m-d H:i:s"); } else { if ($dataDet['subscription_name'] == 'Yearly') { $date = new DateTime($todaysdate); $date->modify("+365 day"); $end_date = $date->format("Y-m-d H:i:s"); } } } } } if (count($subscription_data) > 0) { /*if($dataDet['group_id']!='' && $dataDet['group_id']!=0) { $price_to_show = $subscription_data[0]->group_price_sub; } else { $price_to_show = $subscription_data[0]->individual_price; }*/ $price_to_show = $dataDet['subscription_price']; $subtype = $dataDet['subscription_name']; $subscription_issues = $dataDet['subscription_issues']; $todaysdate = $todaysdate; $end_date = $end_date; } else { $price_to_show = $price; $subtype = "N/A"; $subscription_issues = "N/A"; $todaysdate = "N/A"; $end_date = "N/A"; } if ($dataDet['user_type'] == "1") { $finalsubprice = $price_to_show * $dataDet['quntity']; } else { $finalsubprice = $price_to_show; } $quntity_price = $dataDet['quntity'] * $price_to_show; $price_quan = $producturrency->currencyconverter($getCurrencyName, "NGN", $quntity_price); $price_in = $producturrency->currencyconverter($getCurrencyName, "NGN", $price_to_show); $total_price = $total_price + $price_quan; //if($dataDet['is_purchase']!='1') //{ $order_details .= "<tr>\n\t\t\t\t\t\t\t\t\t<td>" . $titleBrand . "</td>\n\t\t\t\t\t\t\t\t\t<td>" . $price_in . "</td>\n\t\t\t\t\t\t\t\t\t<td>" . $subtype . "</td>\n\t\t\t\t\t\t\t\t\t<td>" . $subscription_issues . "</td>\n\t\t\t\t\t\t\t\t\t<td>" . $todaysdate . "</td>\n\t\t\t\t\t\t\t\t\t<td>" . $end_date . "</td>\n\t\t\t\t\t\t\t\t\t<td>" . $dataDet['quntity'] . "</td>\n\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td colspan='3' align='left'>Sub Total: ₦" . $price_quan . "</td></tr>"; //} //if($dataDet['is_purchase']!='1') //{ //$quntity_price = $dataDet['quntity']*$price; //$order_details.= "<tr><td>".$titleBrand."</td><td>".$producturrency->currencyconverter($getCurrencyName,"NGN",$price)."</td><td>".$dataDet['quntity']."</td></tr><tr><td colspan='3' align='left'>Sub Total: ₦".@mumber_format($producturrency->currencyconverter($getCurrencyName,"NGN",$quntity_price),2)."</td></tr>"; //} } $order_details .= "<tr><td colspan='3'>Total Price:" . @number_format($producturrency->currencyconverter($getCurrencyName, "NGN", $total_price), 2) . "</td>"; $order_details .= "</table>"; ########################################### mail action ############################ $userCompanyObj = new Company_Model_DbTable_Companies(); $storage_company = new Zend_Auth_Storage_Session('company_type'); $company_data = $storage_company->read(); $storage = new Zend_Auth_Storage_Session('account_type'); $data = $storage->read(); if ($data->id) { $user_id = $data->id; } elseif ($company_data->id) { $user_id = $company_data->id; } $user_details = $userCompanyObj->fetchRow("id='" . $user_id . "'"); $mailhost = SMTP_SERVER; $mailconfig = array('ssl' => SMTP_SSL, 'port' => SMTP_PORT, 'auth' => SMTP_AUTH, 'username' => SMTP_USERNAME, 'password' => SMTP_PASSWORD); $transport = new Zend_Mail_Transport_Smtp($mailhost, $mailconfig); Zend_Mail::setDefaultTransport($transport); $message = '<!DOCTYPE html> <html> <head> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta charset="utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1.0"> <title>Evendor</title> </head> <body style="font-family: \'Calibri\', arial;"> <div id="container" style="width:80%; margin:0 auto;"> <header id="heder"> <div style="padding:15px 0px; background:#000000;"><a href="' . $this->view->serverUrl() . $this->view->baseUrl() . '/" target="_blank"><img src="' . $this->view->serverUrl() . $this->view->baseUrl() . '/public/css/default/images/logo.png" style="border:none;" alt="E-Vendor"></a></div> </header> <div style="background:#656565; padding:15px; min-height:200px;"> <aside> Hi ' . $user_details['first_name'] . ' ' . $user_details['last_name'] . ',<br/> Your order has been Declined.Please check your order details.<br/><br/> ' . $order_details . '<br/>Transaction message:' . $responseDescription . ' <br/>Masked PAN:' . $pan . '<br/>Card Holder Name:' . $card_holder_name . ' <br/>Transaction Date & Time:' . $tranDateTime . '<br/> <br/>Transactions reference number(MerchantTranID):' . $MerchantTranID . '<br/> <br/>Transaction Amount:₦' . $purchaseAmount . '<br/> <br/>Transaction Currency:' . $currency . '<br/> <br/>Authorization Code:' . $approvalCodeScr . '<br/> <br/>Merchant Name:Evendor<br/> <br/>Site Url:' . $this->view->serverUrl() . $this->view->baseUrl() . '<br/> <br/><br/><br/> Thank You<br/> Evendor </aside> </div> <div style="background:#000000; text-align:center; color:#FFFFFF; font-size:14px; padding:15px;"> <br> © Copyright ' . date("Y") . ' All Rights Reserved By Electronic Vendor Ltd. </div> </div> </body> </html>'; $mail = new Zend_Mail(); $mail->addTo($user_details['user_email']); $mail->setSubject("Order Declined message"); $mail->setBodyHtml($message); $mail->setFrom(SETFROM, SETNAME); $mail->send(); $tempObj->delete('order_id="' . $orderIdForPurchase . '"'); $this->_redirect('/checkout/displayorder/orderid/' . $orderIdForPurchase); }
function displayorderAction() { ########################## data ########################### $orderIdForPurchase = $this->_getParam('orderid'); $producturrency = new Admin_Model_DbTable_Countries(); $modelAuthor = new Publisher_Model_DbTable_Publishers(); $tempObj = new Model_DbTable_Checkout(); $creditHistoryObj = new User_Model_DbTable_Chistory(); $transactionHistoryObj = new User_Model_DbTable_Transactionhistory(); $productPrice = new Publisher_Model_DbTable_BookPrices(); $modelImage = new Publisher_Model_DbTable_BookImages(); $modelStore = new Admin_Model_DbTable_Countries(); $productPrice = new Publisher_Model_DbTable_BookPrices(); $modelSubscription = new Publisher_Model_DbTable_Subscriptions(); $this->modelBooks = new Publisher_Model_DbTable_Books(); $UsersubObj = new Model_DbTable_Usersubscription(); $storage_company = new Zend_Auth_Storage_Session('company_type'); $company_data = $storage_company->read(); $storage = new Zend_Auth_Storage_Session('account_type'); $userCompanyObj = new Company_Model_DbTable_Companies(); $data = $storage->read(); $useremails = ""; if ($data->id) { $user_id = $data->id; } elseif ($company_data->id) { $user_id = $company_data->id; } if ($company_data->account_type == '1') { $groupObj = new Company_Model_DbTable_Groups(); $groupList = $groupObj->getGroupList($company_data->id); } $datahistory = "<div class='display-order'><div class='top_heading'>\t\t\t\t\n\t\t \t<div class='item'>Item(s)</div>\n\t\t\t\t<div class='prices'>Subscribed Users</div>\n\t\t <div class='prices'>Subscription Type</div>\n\t\t <div class='prices'>Price</div>"; if ($company_data->account_type == '1') { $datahistory .= "<div class='quantity'>Qty</div>"; } else { $datahistory .= "<div class='quantity'> </div>"; } $datahistory .= "<div class='total'>Total</div>\n\t\t </div>"; $orderData = $creditHistoryObj->fetchAll("order_id='" . $orderIdForPurchase . "'"); $dataDet = ''; foreach ($orderData as $dataDet) { $price = $dataDet['price']; $subscription_data = $modelSubscription->fetchAll('id="' . $dataDet['subscription_type'] . '"'); $product_details = $this->modelBooks->fetchRow("id='" . $dataDet['bookid'] . "'"); $transaction_details = $transactionHistoryObj->fetchRow("id='" . $dataDet['transaction_id'] . "'"); $catInfo = $this->modelBooks->getCategoryInfo($product_details['cat_id']); $getCurrencyName = $producturrency->getCurrencyCode($dataDet['store_id']); $authorInfo = $modelAuthor->getInfoByPublisherId($product_details['publisher_id']); $imageInfo = $modelImage->getImageInfoByProductId($product_details['id']); $total_price = $total_price + $producturrency->currencyconverter($getCurrencyName, "NGN", $dataDet['quantity'] * $price); if ($dataDet['payment_status'] == 1) { $orderStatus = 'Approved'; } elseif ($dataDet['payment_status'] == 2) { $orderStatus = 'Declined'; } else { $orderStatus = 'Pending'; } if (count($subscription_data) > 0) { $subtype = $subscription_data[0]->subscription_type; } else { $subtype = "N/A"; } if ($company_data->account_type == '1') { $subscriptiondatavalues = $UsersubObj->fetchAll('order_id=' . $orderIdForPurchase . ' and product_id=' . $dataDet['bookid'] . ' and active_date IS NULL'); foreach ($subscriptiondatavalues as $userdata) { $user_details = $userCompanyObj->fetchRow("id='" . $userdata['user_id'] . "'"); $useremails .= $user_details['user_email'] . '<br/>'; } $useremails = rtrim($useremails, '<br/>'); } else { $user_details = $userCompanyObj->fetchRow("id='" . $user_id . "'"); $useremails = $user_details['user_email']; } $datahistory .= '<div class="cart_detail"> <div class="item_content"> <img src="' . $this->view->serverUrl() . $this->view->baseUrl() . '/' . USER_UPLOAD_DIR . 'thumb1_' . $imageInfo['image_name'] . '" width="140" height="175" alt=""> <h5>' . stripslashes($dataDet['book_name']) . '</h5>'; if ($authorInfo['first_name'] != '') { $datahistory .= '<span><em>by: </em> ' . stripslashes($authorInfo['first_name'] . ' ' . $authorInfo['last_name']) . '</span>'; } $datahistory .= '<span><em>Category: </em> ' . stripslashes($catInfo['category_name']) . '</span> <span><em>publisher:</em> ' . stripslashes($authorInfo['publisher']) . '</span> </div> <div class="space_content">' . $useremails . '</div> <div class="prices_content">' . $subtype . '</div> <div class="prices_content">₦' . $producturrency->currencyconverter($getCurrencyName, "NGN", $price) . '</div> <div style="float: left;padding: 5% 0;text-align: center;width: 70px;"> <div class="">'; if ($dataDet['group_id'] != 0) { $datahistory .= '<div >' . $dataDet['quantity'] . '</div>'; } $datahistory .= '</div> </div> <div class="total_content">₦' . @number_format($producturrency->currencyconverter($getCurrencyName, "NGN", $dataDet['quantity'] * $price), 2) . '</div> </div>'; if ($company_data->account_type == '1') { $finalsubprice = $finalsubprice + $dataDet['quantity'] * $price; } else { $finalsubprice = $finalsubprice + $price; } } $datahistory .= '<div class="shipping_total"> <div class="row"> <div class="lt">Subtotal</div> <div class="rt">₦' . @number_format($total_price, 2) . '</div> </div> <div class="row" style="border:none;"> <div class="lt">Tax</div> <div class="rt">₦' . '00.00</div> </div> <div class="row subtotal"> <div class="lt">Total</div> <div class="rt">₦' . @number_format($total_price, 2) . '</div> </div> <div class="row subtotal"> <div class="lt">Order Id</div> <div class="rt">' . $orderIdForPurchase . '</div> </div> <div class="row subtotal"> <div class="lt">Payment Status</div> <div class="rt">' . $orderStatus . '</div> </div> </div></div>'; $this->view->datahistory = $datahistory; $this->view->orderId = $orderIdForPurchase; $this->view->transactionId = $orderData[0]['transaction_id']; $this->view->orderStatus = $orderStatus; $this->view->responseDescription = $transaction_details['responseDescription']; }