function currency_converter($convertable_amount, $convert_currency_from) { /* author: angshuman baruah subject : currency_converter - stage 1 year : 2016 */ $to_crncy_geo = currency_code(); $from_currency = $convert_currency_from; // as per php get $to_currency = $to_crncy_geo; $amount = $convertable_amount; $results = converCurrency($from_currency, $to_currency, $amount); $regularExpression = '#\\<span class=bld\\>(.+?)\\<\\/span\\>#s'; preg_match($regularExpression, $results, $finalData); $pre_final_x = $finalData[0]; $pre_final = str_replace($to_currency, "", $pre_final_x); $before_final = str_replace(" ", "", $pre_final); return $before_final; }
<?php /* author: angshuman baruah subject : Country-wise-Currency-Converter ver 1 year : 2016 Please give feedback to this email angshuman0baruah@gmail.com */ include "currency_converter.php"; $amount = "10"; $from_currency = "USD"; $convertable_amount = currency_converter($amount, $from_currency); // jst only call this function for currency convert $currency_code = currency_code(); // get currency code $client_ip = current_location_ip(); // get client IP $client_country = client_country(); // get client country with code echo $convertable_amount . " " . $currency_code . " for" . $client_country . " with Client IP : " . $client_ip;
function chk_avail_hotel($user, $pass, $param) { $hotel_id = isset($param->hotel_id) ? $param->hotel_id : 0; $check_in = isset($param->check_in) ? $param->check_in : 0; $check_out = isset($param->check_out) ? $param->check_out : 0; $rooms = isset($param->rooms) ? $param->rooms : 1; $passengers = isset($param->passengers) ? $param->passengers : 1; // print_r($passengers); // echo $hotel_id."\n\r"; if ($hotel_id == 0 || $check_in == '' || $check_out == '') { $return['err']['code'] = 2002; $return['err']['code'] = 20061; $return['err']['msg'] = "HOTEL ID IS FAIL"; return json_encode($return); } global $db_hotel; $avails = array(); $passengers = json_decode($passengers, TRUE); // print_r($passengers); for ($room = 1; $room <= $rooms; $room++) { $query = "SELECT * FROM `hot_room_type` where (`capa_adult`+`capa_extra`) >= " . $passengers[$room]['adult'] . " AND hotels_id={$hotel_id} "; // $query = "SELECT * FROM `hot_room_type` where (`capa_adult`+`capa_extra`) >= $adult "; // echo '<hr>'.$query.'<hr>'; $query = $db_hotel->query($query); $return = array(); $numDays = date_diff(date_create_from_format('Y-m-d', $check_out), date_create_from_format('Y-m-d', $check_in)); $numDays = $numDays->d; $days = array(); for ($i = 0; $i < $numDays; $i++) { $d = date_create_from_format('Y-m-d', $check_in); date_add($d, DateInterval::createFromDateString($i . ' days')); array_push($days, $d->format('Y-m-d')); } // print_r($days); if ($query == true) { while ($room_avail = $query->fetch_assoc()) { $wh = array(); $pri = array(); foreach ($days as $date) { $wh[] = "(SELECT `has_avail_ondate`('" . $room_avail['id'] . "','" . $date . "')) >=1 "; $pri[] = "(SELECT `has_avail_ondate`('" . $room_avail['id'] . "','" . $date . "'))"; } $wh = implode(" AND ", $wh); $pri = implode(" + ", $pri); $qavail = NULL; $qavail = "SELECT `currency_id`,({$pri}) as price FROM hotel_avail WHERE {$wh} LIMIT 1 "; $qavail = $db_hotel->query($qavail); if ($qavail->num_rows > 0) { $avail = $qavail->fetch_assoc(); // echo $avail['price']."\n\r"; if ($avail['price'] != 0) { $cur = "SELECT `currency_id` FROM hotel_avail WHERE room_type_id=" . $room_avail['id'] . " LIMIT 1 "; $cur = $db_hotel->query($cur); $cur = $cur->fetch_assoc(); $cur = $cur['currency_id']; if ($cur) { $avails[$room][$room_avail['id']] = array("name" => $room_avail['name'], "en_name" => $room_avail['en_name'], "capa_adult" => $room_avail['capa_adult'], "price" => $avail['price'], "currency" => currency_code($cur)); } } } } } // echo 'ROOM :: '.$room."\n\r\n"; // echo 'ROOM :: '; // print_r($avails[$room]); // echo "\n\r\n"; if (!isset($avails[$room]) || count($avails[$room]) == 0) { $return['err']['code'] = 2021; $return['err']['ecode'] = 20062; $return['err']['msg'] = "NOT AVAIL"; return json_encode($return); } // print_r($avails); } //$db_hotel->close(); return json_encode($avails); }
/** * Payment process * * @access public * @return void */ function process() { $currency = currency_code(); $cc_owner = $this->ci->input->post('cc_owner'); $cc_type = $this->ci->input->post('cc_type'); $cc_number_nh_dns = $this->ci->input->post('cc_number_nh-dns'); $cc_starts_month = $this->ci->input->post('cc_starts_month'); $cc_starts_year = $this->ci->input->post('cc_starts_year'); $cc_expires_month = $this->ci->input->post('cc_expires_month'); $cc_expires_year = $this->ci->input->post('cc_expires_year'); $cc_cvc_nh_dns = $this->ci->input->post('cc_cvc_nh-dns'); $cc_issue_nh_dns = $this->ci->input->post('cc_issue_nh-dns'); if (isset($cc_owner) && !empty($cc_owner) && isset($cc_type) && isset($this->cc_types[$cc_type]) && isset($cc_number_nh_dns) && !empty($cc_number_nh_dns)) { $params = array('USER' => $this->config['MODULE_PAYMENT_PAYPAL_DIRECT_API_USERNAME'], 'PWD' => $this->config['MODULE_PAYMENT_PAYPAL_DIRECT_API_PASSWORD'], 'VERSION' => '3.2', 'SIGNATURE' => $this->config['MODULE_PAYMENT_PAYPAL_DIRECT_API_SIGNATURE'], 'METHOD' => 'DoDirectPayment', 'PAYMENTACTION' => $this->config['MODULE_PAYMENT_PAYPAL_DIRECT_METHOD'] == 'Sale' ? 'Sale' : 'Authorization', 'IPADDRESS' => get_ip_address(), 'AMT' => currencies_format_raw($this->ci->shopping_cart->get_total() - $this->ci->shopping_cart->get_shipping_method('cost'), $currency), 'CREDITCARDTYPE' => $cc_type, 'ACCT' => $cc_number_nh_dns, 'STARTDATE' => $cc_starts_month . $cc_starts_year, 'EXPDATE' => $cc_expires_month . $cc_expires_year, 'CVV2' => $cc_cvc_nh_dns, 'FIRSTNAME' => substr($cc_owner, 0, strpos($cc_owner, ' ')), 'LASTNAME' => substr($cc_owner, strpos($cc_owner, ' ') + 1), 'STREET' => $this->ci->shopping_cart->get_billing_address('street_address'), 'CITY' => $this->ci->shopping_cart->get_billing_address('city'), 'STATE' => $this->ci->shopping_cart->get_billing_address('state'), 'COUNTRYCODE' => $this->ci->shopping_cart->get_billing_address('country_iso_code_2'), 'ZIP' => $this->ci->shopping_cart->get_billing_address('postcode'), 'EMAIL' => $this->ci->customer->get_email_address(), 'PHONENUM' => $this->ci->shopping_cart->get_billing_address('telephone_number'), 'CURRENCYCODE' => $currency, 'BUTTONSOURCE' => 'tomatcart'); if ($cc_type == 'SWITCH' || $cc_type == 'SOLO') { $params['ISSUENUMBER'] = $cc_issue_nh_dns; } if ($this->ci->shopping_cart->has_shipping_address()) { $params['SHIPTONAME'] = $this->ci->shopping_cart->get_shipping_address('firstname') . ' ' . $this->ci->shopping_cart->get_shipping_address('lastname'); $params['SHIPTOSTREET'] = $this->ci->shopping_cart->get_shipping_address('street_address'); $params['SHIPTOCITY'] = $this->ci->shopping_cart->get_shipping_address('city'); $params['SHIPTOSTATE'] = $this->ci->shopping_cart->get_shipping_address('zone_code'); $params['SHIPTOCOUNTRYCODE'] = $this->ci->shopping_cart->get_shipping_address('country_iso_code_2'); $params['SHIPTOZIP'] = $this->ci->shopping_cart->get_shipping_address('postcode'); } $post_string = ''; foreach ($params as $key => $value) { $post_string .= $key . '=' . urlencode(trim($value)) . '&'; } $post_string = substr($post_string, 0, -1); $response = $this->send_transaction_to_gateway($this->api_url, $post_string); $response_array = array(); parse_str($response, $response_array); if ($response_array['ACK'] != 'Success' && $response_array['ACK'] != 'SuccessWithWarning') { $this->ci->message_stack->add_session('checkout', stripslashes($response_array['L_LONGMESSAGE0']), 'error'); redirect('checkout/index/index/orderConfirmationForm'); } else { $this->ci->load->library('order'); $orders_id = $this->ci->order->create_order(); //update order order status $comments = 'PayPal Website Payments Pro (US) Direct Payments [' . 'ACK: ' . $response_array['ACK'] . '; TransactionID: ' . $response_array['TRANSACTIONID'] . ';' . ']'; $this->ci->order->process($orders_id, ORDERS_STATUS_PAID, $comments); } } else { $this->ci->message_stack->add_session('checkout', lang('payment_paypal_direct_error_all_fields_required'), 'error'); redirect('checkout/index/index/orderConfirmationForm'); } }