Example #1
0
 public function postUpdatestatus()
 {
     if (Order::where('order_id', '=', $_POST['ordrid'])->update(array('status' => $_POST['status']))) {
         $msg = $_POST['status'] == 'neworder' ? 'initiated' : $_POST['status'];
         $username = "******";
         $password = "******";
         $url = "http://smslane.com/vendorsms/pushsms.aspx?user="******"&password="******"&msisdn=91" . $_POST['phone'] . "&sid=WebSms&msg=Your order has been " . $msg . "&fl=1";
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         $resp = curl_exec($ch);
         $vendor_id = Order::where('order_id', '=', $_POST['ordrid'])->get(array('vendor_id'))->toArray();
         $vendor_email = User::getemail($vendor_id[0]['vendor_id']);
         Mail::send('emails.orderstatus', array('msg' => $msg), function ($message) use($vendor_email) {
             $message->from('*****@*****.**', 'Funfest');
             $message->subject('RE: Order status updated');
             $message->to($vendor_email);
         });
         $response = array('success' => true);
     } else {
         $response = array('success' => false);
     }
     return json_encode($response);
 }
Example #2
0
 public function postPaymentsuccess()
 {
     $order_info = (array) json_decode($_COOKIE['orderdetails']);
     $order_id = $order_info['txnid'];
     $product_id = implode(',', $order_info['product_id']);
     $product_quantity = implode(',', $order_info['product_quantity']);
     $product_vendor_id = implode(',', $order_info['product_vendor_id']);
     $shipping_det = (array) $order_info['shipping'];
     $billing_det = (array) $order_info['billing'];
     if (isset($order_info['addon_vendor_id'])) {
         $add_on_id = implode(',', $order_info['addon_id']);
     }
     // Saving to order table
     $order = new Order();
     $order->order_id = $order_id;
     $order->user_id = $order_info['user_id'];
     $order->product_id = $product_id;
     if (isset($add_on_id)) {
         $order->add_on_id = $add_on_id;
     }
     $order->vendor_id = $order_info['udf2'] == 'cake' ? User::cakegetid($product_vendor_id) : $product_vendor_id;
     $order->name = $shipping_det['first_name'] . " " . $shipping_det['last_name'];
     $order->contact = $shipping_det['mobile'];
     $order->shipping_address = $shipping_det['address'] . " " . $shipping_det['address2'];
     $order->shipping_city = $shipping_det['scity'];
     $order->shipping_zip = $shipping_det['zip_code'];
     $order->shipping_state = $shipping_det['state'];
     $order->price = $order_info['subtotal'];
     $order->disc_code = $order_info['coupon'];
     $order->status = 'neworder';
     $order->type = $order_info['udf2'];
     $order->user_message = $order_info['personalmessage'];
     $order->delivery_date = $order_info['delivery_date'];
     $order->payment_clearance = 'uncleared';
     $order->quantity = $product_quantity;
     // Saving to order master table
     $ordermaster = new Ordermaster();
     $ordermaster->order_id = $order_id;
     $ordermaster->transaction_id = 0;
     $ordermaster->payment_method = 'others';
     $ordermaster->name = $shipping_det['first_name'] . " " . $shipping_det['last_name'];
     $ordermaster->contact = $shipping_det['mobile'];
     $ordermaster->billing_address = $billing_det['address'] . " " . $billing_det['address2'];
     $ordermaster->billing_city = $billing_det['bcity'];
     $ordermaster->billing_zip = $billing_det['zip_code'];
     $ordermaster->billing_state = $billing_det['state'];
     $ordermaster->bill_value = $order_info['subtotal'];
     $ordermaster->status = 'uncleared';
     $ordermaster->email = $billing_det['email'];
     $ordermaster->process = 'new';
     //  Saving order details
     if ($order->save() && $ordermaster->save()) {
         // Set for Rating
         $det = Cart::contents();
         $vendor_id = $order_info['udf2'] == 'cake' ? User::cakegetid($product_vendor_id) : $product_vendor_id;
         if (Auth::check()) {
             $user_id = Auth::user()->id;
         } else {
             $user_id = uniqid();
         }
         $ordrid = $order_info['txnid'];
         foreach ($det as $item) {
             $vendor_id = $item->vendor_id;
         }
         if ($vendor_id != "") {
             setcookie("ratevendor[vendor_id]", $vendor_id, time() + 60 * 60 * 24 * 30, '/');
             setcookie("ratevendor[user_id]", $user_id, time() + 60 * 60 * 24 * 30, '/');
             setcookie("ratevendor[ordrid]", $ordrid, time() + 60 * 60 * 24 * 30, '/');
         }
         // Set for Rating
         $products = Cart::contents();
         $total = Cart::total();
         Cart::destroy();
         $billing_det = (array) $order_info['billing'];
         // Notify user for successfull payment
         Mail::send('emails.orderconfirm', array('details_for_order' => $order_info, 'products' => $products, 'total' => $total), function ($message) use($order_info, $billing_det) {
             $message->from('*****@*****.**', 'Funfest');
             $message->subject('RE: Order successful, Funfest order no. ' . $order_info['txnid']);
             $message->to($billing_det['email']);
         });
         $vendor_email = User::getemail($vendor_id);
         $vendor_email = "*****@*****.**";
         if ($vendor_email != "") {
             Mail::send('emails.vendornotify', array('details_for_order' => $order_info, 'products' => $products, 'total' => $total), function ($message) use($order_info, $billing_det, $vendor_email) {
                 $message->from('*****@*****.**', 'Funfest');
                 $message->subject('RE: Order successful, Funfest order no. ' . $order_info['txnid']);
                 $message->to($vendor_email);
                 //->cc('*****@*****.**');
             });
         } else {
             Mail::send('emails.vendornotify', array('details_for_order' => $order_info, 'products' => $products, 'total' => $total), function ($message) use($billing_det) {
                 $message->from('*****@*****.**', 'Funfest');
                 $message->subject('RE: Order for cake (vendor email was null).');
                 $message->to('*****@*****.**');
             });
         }
         // Send messgae to user
         $username = "******";
         $password = "******";
         $url = "http://smslane.com/vendorsms/pushsms.aspx?user="******"&password="******"&msisdn=91" . $order_info['phone'] . "&sid=WebSms&msg=Your order has been placed successfully. Your order id is " . $order_info['txnid'] . "&fl=1";
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         $response = curl_exec($ch);
         // Send messgae to vendor
         $vendor_rmn = User::getrmn($product_vendor_id);
         if ($vendor_rmn != "") {
             $username = "******";
             $password = "******";
             $url = "http://smslane.com/vendorsms/pushsms.aspx?user="******"&password="******"&msisdn=91" . $vendor_rmn . "&sid=WebSms&msg=You received a new order, order id " . $order_info['txnid'] . ". Please login to the website to get the details.&fl=1";
             $ch = curl_init();
             curl_setopt($ch, CURLOPT_URL, $url);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
             $response = curl_exec($ch);
         }
         Ordermaster::where('order_id', '=', $_POST['txnid'])->update(array('transaction_id' => $_POST['mihpayid'], 'bank_transaction_id' => $_POST['bank_ref_num'], 'status' => 'cleared', 'process' => 'initiate'));
         Order::where('order_id', '=', $_POST['txnid'])->update(array('status' => 'neworder', 'process' => 'initiate', 'payment_clearance' => 'cleared'));
         return View::make('/home/thankyou')->with('purchase_data', $_POST)->with('message', "The transaction was successful, your order is on it's way.");
     }
 }