Пример #1
0
 public function updateToken($token = '', $user_id = '')
 {
     $params = array('token' => $token, 'last_login' => date('c'), 'ip_address' => $_SERVER['REMOTE_ADDR']);
     $db_ext = new DbExt();
     if ($db_ext->updateData("{{client}}", $params, 'client_id', $user_id)) {
         return true;
     }
     return false;
 }
Пример #2
0
<?php

$db_ext = new DbExt();
$payment_code = Yii::app()->functions->paymentCode("authorize");
$error = '';
$success = '';
$amount_to_pay = 0;
$payment_description = '';
$payment_ref = Yii::app()->functions->generateCode() . "TT" . Yii::app()->functions->getLastIncrement('{{sms_package_trans}}');
$data_get = $_GET;
$data_post = $_POST;
$merchant_default_country = Yii::app()->functions->getOptionAdmin('merchant_default_country');
$package_id = isset($_GET['package_id']) ? $_GET['package_id'] : '';
$mode_autho = Yii::app()->functions->getOptionAdmin('admin_mode_autho');
$autho_api_id = Yii::app()->functions->getOptionAdmin('admin_autho_api_id');
$autho_key = Yii::app()->functions->getOptionAdmin('admin_autho_key');
if (empty($mode_autho) && empty($autho_api_id) && empty($autho_key)) {
    $error = t("Authorize.net is not properly configured");
}
if ($res = Yii::app()->functions->getSMSPackagesById($package_id)) {
    $amount_to_pay = $res['price'];
    if ($res['promo_price'] > 0) {
        $amount_to_pay = $res['promo_price'];
    }
    $amount_to_pay = is_numeric($amount_to_pay) ? normalPrettyPrice($amount_to_pay) : '';
    $amount_to_pay = unPrettyPrice($amount_to_pay);
    $payment_description .= isset($res['title']) ? $res['title'] : '';
    /*dump($amount_to_pay);
    	dump($payment_description);*/
    if (isset($_POST['x_card_num'])) {
        define("AUTHORIZENET_API_LOGIN_ID", $autho_api_id);
Пример #3
0
 public function SMSbankDepositVerification()
 {
     if (isset($this->data['photo'])) {
         $req = array('ref' => t("reference number is required"));
     } else {
         $req = array('branch_code' => t("branch code is required"), 'date_of_deposit' => t("date of deposit is required"), 'time_of_deposit' => t("time of deposit is required"), 'amount' => t("amount is required"));
     }
     $Validator = new Validator();
     $Validator->required($req, $this->data);
     if ($Validator->validate()) {
         $DbExt = new DbExt();
         if ($res = Yii::app()->functions->mercadoGetPayment($this->data['ref'])) {
             $params = array('merchant_id' => $res[0]['merchant_id'], 'branch_code' => $this->data['branch_code'], 'date_of_deposit' => $this->data['date_of_deposit'], 'time_of_deposit' => $this->data['time_of_deposit'], 'amount' => $this->data['amount'], 'scanphoto' => isset($this->data['photo']) ? $this->data['photo'] : '', 'date_created' => date('c'), 'ip_address' => $_SERVER['REMOTE_ADDR'], 'transaction_type' => "sms_purchase");
             if ($DbExt->insertData("{{bank_deposit}}", $params)) {
                 $this->code = 1;
                 $this->msg = Yii::t("default", "Thank you. Your information has been receive please wait 1 or 2 days to verify your payment.");
                 /*send email to admin owner*/
                 $from = 'no-reply@' . $_SERVER['HTTP_HOST'];
                 $subject = Yii::t("default", "New Bank Deposit");
                 $to = Yii::app()->functions->getOptionAdmin('website_contact_email');
                 $tpl = EmailTPL::bankDepositedReceive();
                 if (!empty($to)) {
                     Yii::app()->functions->sendEmail($to, $from, $subject, $tpl);
                 }
             } else {
                 $this->msg = Yii::t("default", "Something went wrong during processing your request. Please try again later.");
             }
         } else {
             $this->msg = Yii::t("default", "Reference number not found");
         }
     } else {
         $this->msg = $Validator->getErrorAsHTML();
     }
 }
Пример #4
0
        $error = Yii::t("default", "Stripe payment is not properly configured on merchant portal.");
    }
} else {
    $error = Yii::t("default", "Sorry but we cannot find what your are looking for.");
}
if (isset($_POST)) {
    if (is_array($_POST) && count($_POST) >= 1) {
        $step2 = true;
        $token = isset($_POST['stripeToken']) ? $_POST['stripeToken'] : '';
        try {
            $customer = Stripe_Customer::create(array('email' => isset($_POST['stripeEmail']) ? $_POST['stripeEmail'] : '', 'card' => $token));
            $charge = Stripe_Charge::create(array('customer' => $customer->id, 'amount' => $amount_to_pay, 'currency' => Yii::app()->functions->adminCurrencyCode()));
            $chargeArray = $charge->__toArray(true);
            /*dump("pay ->".$chargeArray['paid']);
              echo json_encode($chargeArray);*/
            $db_ext = new DbExt();
            $params_logs = array('order_id' => $_GET['id'], 'payment_type' => "stp", 'raw_response' => json_encode($chargeArray), 'date_created' => date('c'), 'ip_address' => $_SERVER['REMOTE_ADDR']);
            $db_ext->insertData("{{payment_order}}", $params_logs);
            $params_update = array('status' => 'paid');
            $db_ext->updateData("{{order}}", $params_update, 'order_id', $_GET['id']);
            header('Location: ' . Yii::app()->request->baseUrl . "/store/receipt/id/" . $_GET['id']);
        } catch (Exception $e) {
            $error = $e;
        }
    }
}
?>
<div class="page-right-sidebar payment-option-page">
  <div class="main">  
  <?php 
if (!empty($error)) {
Пример #5
0
<form class="uk-form uk-form-horizontal forms" id="forms">
<?php 
echo CHtml::hiddenField('action', 'bookATableMerchant');
echo CHtml::hiddenField('id', isset($_GET['id']) ? $_GET['id'] : "");
if (!isset($_GET['id'])) {
    echo CHtml::hiddenField("redirect", Yii::app()->request->baseUrl . "/merchant/tablebooking/Do/Add");
}
?>

<?php 
$data = '';
if (isset($_GET['id'])) {
    $data = Yii::app()->functions->getBooking($_GET['id']);
    if ($data['viewed'] != 2) {
        $db_ext = new DbExt();
        $params = array('viewed' => 2);
        $db_ext->updateData("{{bookingtable}}", $params, 'booking_id', $data['booking_id']);
    }
}
?>
  
      <div class="uk-form-row">
		  <label class="uk-form-label"><?php 
echo Yii::t("default", "Number Of Guests");
?>
</label>
		  <?php 
echo CHtml::textField('number_guest', isset($data['number_guest']) ? $data['number_guest'] : '', array('class' => 'numeric_only', 'data-validation' => "required"));
?>
	 </div>
        Stripe::setApiKey($stripe['secret_key']);
    } else {
        $error = Yii::t("default", "Stripe payment is not properly configured on admin portal.");
    }
} else {
    $error = Yii::t("default", "Sorry but we cannot find what your are looking for.");
}
if (isset($_POST)) {
    if (is_array($_POST) && count($_POST) >= 1) {
        $step2 = true;
        $token = isset($_POST['stripeToken']) ? $_POST['stripeToken'] : '';
        try {
            $customer = Stripe_Customer::create(array('email' => isset($_POST['stripeEmail']) ? $_POST['stripeEmail'] : '', 'card' => $token));
            $charge = Stripe_Charge::create(array('customer' => $customer->id, 'amount' => $amount_to_pay, 'currency' => Yii::app()->functions->adminCurrencyCode()));
            $chargeArray = $charge->__toArray(true);
            $db_ext = new DbExt();
            $params_logs = array('package_id' => $data['package_id'], 'merchant_id' => $data['merchant_id'], 'price' => $data['package_price'], 'payment_type' => $payment_code, 'membership_expired' => $data['membership_expired'], 'date_created' => date('c'), 'ip_address' => $_SERVER['REMOTE_ADDR'], 'PAYPALFULLRESPONSE' => json_encode($chargeArray));
            if (isset($_GET['renew'])) {
                $membership_info = Yii::app()->functions->upgradeMembership($data['merchant_id'], $package_id);
                $params_logs['membership_expired'] = $membership_info['membership_expired'];
                $params_update = array('package_id' => $package_id, 'package_price' => $membership_info['package_price'], 'membership_expired' => $membership_info['membership_expired'], 'status' => 'active');
                $db_ext->updateData("{{merchant}}", $params_update, 'merchant_id', $data['merchant_id']);
            }
            $db_ext->insertData("{{package_trans}}", $params_logs);
            $db_ext->updateData("{{merchant}}", array('payment_steps' => 3, 'membership_purchase_date' => date('c')), 'merchant_id', $data['merchant_id']);
            if (isset($_GET['renew'])) {
                header('Location: ' . Yii::app()->request->baseUrl . "/store/renewSuccesful");
            } else {
                header('Location: ' . Yii::app()->request->baseUrl . "/store/merchantSignup/Do/step4/token/{$my_token}");
            }
        } catch (Exception $e) {
Пример #7
0
 public function actionFaxPostBack()
 {
     $data = $_REQUEST;
     dump($data);
     if ($res = Yii::app()->functions->getFaxJobId($data['jobid'])) {
         dump($res);
         $record_id = $res['id'];
         $params = array('status' => $data['shortstatus'], 'api_raw_response' => $data['longstatus'], 'date_postback' => date('c'));
         dump($params);
         $db_ext = new DbExt();
         $db_ext->updateData("{{fax_broadcast}}", $params, 'jobid', $data['jobid']);
     }
 }
Пример #8
0
<?php

$db_ext = new DbExt();
$data_get = $_GET;
$error = '';
$success = '';
$amount_to_pay = 0;
$token = isset($_GET['token']) ? $_GET['token'] : '';
$back_url = Yii::app()->request->baseUrl . "/store/merchantSignup/Do/step3/token/" . $token;
$mtid = Yii::app()->functions->getOptionAdmin('admin_sanbox_sisow_secret_key');
$mtkey = Yii::app()->functions->getOptionAdmin('admin_sandbox_sisow_pub_key');
$mtshopid = Yii::app()->functions->getOptionAdmin('admin_sandbox_sisow_shopid');
$mode = Yii::app()->functions->getOptionAdmin('admin_sisow_mode');
$payment_description = '';
$payment_ref = Yii::app()->functions->generateCode() . "TT" . Yii::app()->functions->getLastIncrement('{{package_trans}}');
$my_token = isset($_GET['token']) ? $_GET['token'] : '';
$package_id = isset($_GET['package_id']) ? $_GET['package_id'] : '';
$extra_params = '';
if (isset($_GET['renew'])) {
    $extra_params = "/renew/1/package_id/" . $package_id;
}
if ($res = Yii::app()->functions->getMerchantByToken($my_token)) {
    if (isset($_GET['renew'])) {
        if ($new_info = Yii::app()->functions->getPackagesById($package_id)) {
            $res['package_name'] = $new_info['title'];
            $res['package_price'] = $new_info['price'];
            if ($new_info['promo_price'] > 0) {
                $res['package_price'] = $new_info['promo_price'];
            }
        }
    }
Пример #9
0
 public function actionIndex()
 {
     $db_ext = new DbExt();
     $error = '';
     $package_id = isset($_GET['package_id']) ? $_GET['package_id'] : '';
     $amount_to_pay = 0;
     $back_url = Yii::app()->request->baseUrl . "/merchant/purchasesms";
     $payment_ref = Yii::app()->functions->generateCode() . "TT" . Yii::app()->functions->getLastIncrement('{{sms_package_trans}}');
     $package_id = isset($_GET['package_id']) ? $_GET['package_id'] : '';
     $merchant_id = Yii::app()->functions->getMerchantID();
     if ($res = Yii::app()->functions->getSMSPackagesById($package_id)) {
         $amount_to_pay = $res['price'];
         if ($res['promo_price'] > 0) {
             $amount_to_pay = $res['promo_price'];
         }
         $amount_to_pay = is_numeric($amount_to_pay) ? normalPrettyPrice($amount_to_pay) : '';
         $payment_description .= isset($res['title']) ? $res['title'] : '';
         /*dump($payment_description);
         		dump($amount_to_pay);
         		dump($payment_ref);*/
         $amount_to_pay = number_format($amount_to_pay, 2, '.', '');
         $cancel_url = Yii::app()->getBaseUrl(true) . "/merchant/purchasesms";
         $accepturl = Yii::app()->getBaseUrl(true) . "/merchant/pysinit/?type=purchaseSMScredit&package_id=" . $package_id . "&mode=accept&mtid={$merchant_id}";
         $callback = Yii::app()->getBaseUrl(true) . "/paysera/?type=purchaseSMScredit&package_id=" . $package_id . "&mode=callback&mtid={$merchant_id}";
         $country = Yii::app()->functions->getOptionAdmin('admin_paysera_country');
         $mode = Yii::app()->functions->getOptionAdmin('admin_paysera_mode');
         $lang = Yii::app()->functions->getOptionAdmin('admin_paysera_lang');
         $currency = Yii::app()->functions->adminCurrencyCode();
         $projectid = Yii::app()->functions->getOptionAdmin('admin_paysera_project_id');
         $password = Yii::app()->functions->getOptionAdmin('admin_paysera_password');
         if (isset($_GET['mode'])) {
             if ($_GET['mode'] == "accept") {
                 $payment_code = Yii::app()->functions->paymentCode("paysera");
                 $params = array('merchant_id' => $_GET['mtid'], 'sms_package_id' => $package_id, 'payment_type' => $payment_code, 'package_price' => $amount_to_pay, 'sms_limit' => isset($res['sms_limit']) ? $res['sms_limit'] : '', 'date_created' => date('c'), 'ip_address' => $_SERVER['REMOTE_ADDR'], 'payment_gateway_response' => json_encode($_GET));
                 $db_ext->insertData("{{sms_package_trans}}", $params);
                 header('Location: ' . Yii::app()->request->baseUrl . "/merchant/smsReceipt/id/" . Yii::app()->db->getLastInsertID());
                 die;
             }
             try {
                 $response = WebToPay::checkResponse($_GET, array('projectid' => $projectid, 'sign_password' => $password));
                 if (is_array($response) && count($response) >= 1) {
                     if ($response['status'] == 0) {
                         die("payment has no been executed");
                     }
                     if ($response['status'] == 3) {
                         die("additional payment information");
                     }
                     $stmt = "SELECT * FROM\r\n\t\t            \t{{sms_package_trans}}\r\n\t\t            \tWHERE\r\n\t\t            \tmerchant_id ='" . $_GET['mtid'] . "'\r\n\t\t            \tAND\r\n\t\t            \tsms_package_id='" . $_GET['package_id'] . "'\r\n\t\t            \tORDER BY id DESC\r\n\t\t            \tLIMIT 0,1\r\n\t\t            \t";
                     if ($res2 = $db_ext->rst($stmt)) {
                         $current_id = $res2[0]['id'];
                         $params_update = array('status' => "paid");
                         $db_ext->updateData("{{sms_package_trans}}", $params_update, 'id', $current_id);
                     }
                     echo 'OK';
                     die;
                 } else {
                     $error = t("ERROR: api returns empty");
                 }
             } catch (WebToPayException $e) {
                 $error = t("ERROR: Something went wrong") . ". " . $e;
             }
         } else {
             echo 'init';
         }
     } else {
         $error = Yii::t("default", "Failed. Cannot process payment");
     }
     if (!empty($error)) {
         //$this->render('error',array('message'=>$error));
         echo $error;
     }
     //$this->createLogs('');
 }
Пример #10
0
 public function actionEpayBg()
 {
     $db_ext = new DbExt();
     $data = $_GET;
     $msg = '';
     $error_receiver = '';
     if ($data['mode'] == "receiver") {
         $mode = Yii::app()->functions->getOptionAdmin('admin_mode_epaybg');
         if ($mode == "sandbox") {
             $min = Yii::app()->functions->getOptionAdmin('admin_sandbox_epaybg_min');
             $secret = Yii::app()->functions->getOptionAdmin('admin_sandbox_epaybg_secret');
         } else {
             $min = Yii::app()->functions->getOptionAdmin('admin_live_epaybg_min');
             $secret = Yii::app()->functions->getOptionAdmin('admin_live_epaybg_secret');
         }
         /*dump($min);
         		dump($secret);*/
         $EpayBg = new EpayBg();
         $ENCODED = $data['encoded'];
         $CHECKSUM = $data['checksum'];
         $hmac = $EpayBg->hmac('sha1', $ENCODED, $secret);
         /*dump("Check");
           dump($CHECKSUM);
           dump($hmac);*/
         //if ($hmac == $CHECKSUM) {
         $data_info = base64_decode($ENCODED);
         $lines_arr = split("\n", $data_info);
         $info_data = '';
         //dump($lines_arr);
         if (is_array($lines_arr) && count($lines_arr) >= 1) {
             foreach ($lines_arr as $line) {
                 if (!empty($line)) {
                     $payment_info = explode(":", $line);
                     $invoice_number = str_replace("INVOICE=", '', $payment_info[0]);
                     $status = str_replace("STATUS=", '', $payment_info[1]);
                     if (preg_match("/PAID/i", $payment_info[1])) {
                         $info_data .= "INVOICE={$invoice_number}:STATUS=OK\n";
                         Yii::app()->functions->epayBgUpdateTransaction($invoice_number, $status);
                     } else {
                         $info_data .= "INVOICE={$invoice_number}:STATUS=ERR\n";
                         Yii::app()->functions->epayBgUpdateTransaction($invoice_number, $status);
                     }
                 }
             }
             echo $info_data;
             Yii::app()->functions->createLogs($info_data, "epaybg");
             die;
         } else {
             $error_receiver = "ERR=Not valid CHECKSUM\n";
         }
         /*} else {
           	$error_receiver="ERR=Not valid CHECKSUM\n";
           }*/
         if (!empty($error_receiver)) {
             echo $error_receiver;
             Yii::app()->functions->createLogs($error_receiver, "epaybg");
         } else {
             Yii::app()->functions->createLogs("none response", "epaybg");
         }
         die;
     } elseif ($data['mode'] == "cancel") {
         $msg = t("Transaction has been cancelled");
     } elseif ($data['mode'] == "accept") {
         if ($trans_info = Yii::app()->functions->barclayGetTokenTransaction($data['token'])) {
             //dump($trans_info);
             switch ($data['mode']) {
                 case "accept":
                     if ($trans_info['transaction_type'] == "order") {
                         $params_update = array('status' => "pending", 'date_modified' => date('c'));
                         $db_ext->updateData("{{order}}", $params_update, 'order_id', $data['token']);
                         header('Location: ' . websiteUrl() . "/store/receipt/id/" . $data['token']);
                     } else {
                         if ($token_details = Yii::app()->functions->getMerchantByToken($data['token'])) {
                             $db_ext->updateData("{{merchant}}", array('payment_steps' => 3, 'membership_purchase_date' => date('c')), 'merchant_id', $token_details['merchant_id']);
                             header('Location: ' . websiteUrl() . "/store/merchantSignup/Do/thankyou2/token/" . $data['token']);
                         } else {
                             $msg = t("Token not found");
                         }
                     }
                     break;
                 case "cancel":
                     if ($trans_info['transaction_type'] == "order") {
                         header('Location: ' . websiteUrl() . "/store/");
                     } else {
                         header('Location: ' . websiteUrl() . "/store/merchantSignup/Do/step3/token/" . $data['token']);
                     }
                     break;
             }
         } else {
             $msg = t("Transaction information not found");
         }
     }
     if (!empty($msg)) {
         $this->render('error', array('message' => $msg));
     }
 }
Пример #11
0
 public function getCookingTranslation($name = '', $mt_id = '')
 {
     $DbExt = new DbExt();
     $stmt = "SELECT * FROM\r\n\t\t\t{{cooking_ref}}\r\n\t\t\tWHERE\r\n\t\t\tcooking_name=" . $this->q($name) . "\r\n\t\t\tAND \r\n\t\t\tmerchant_id=" . $this->q($mt_id) . "\r\n\t\t\tLIMIT 0,1\t\t\t\r\n\t\t";
     if ($res = $DbExt->rst($stmt)) {
         $res = $res[0];
         $t['cooking_name_trans'] = !empty($res['cooking_name_trans']) ? json_decode($res['cooking_name_trans'], true) : '';
         return $t;
     }
     return false;
 }
Пример #12
0
 public function alterTable($table = '', $new_field = '')
 {
     $DbExt = new DbExt();
     $prefix = Yii::app()->db->tablePrefix;
     $existing_field = '';
     if ($res = Yii::app()->functions->checkTableStructure($table)) {
         foreach ($res as $val) {
             $existing_field[$val['Field']] = $val['Field'];
         }
         foreach ($new_field as $key_new => $val_new) {
             if (!in_array($key_new, $existing_field)) {
                 echo "Creating field {$key_new} <br/>";
                 $stmt_alter = "ALTER TABLE " . $prefix . "{$table} ADD {$key_new} " . $new_field[$key_new];
                 dump($stmt_alter);
                 if ($DbExt->qry($stmt_alter)) {
                     echo "(Done)<br/>";
                 } else {
                     echo "(Failed)<br/>";
                 }
             } else {
                 echo "Field {$key_new} already exist<br/>";
             }
         }
     }
 }
Пример #13
0
<p class="right uk-text-muted"><a href="<?php 
echo baseUrl() . "/merchant-sample.csv";
?>
" target="_blank"><?php 
echo t("click here");
?>
</a> <?php 
echo t("for sample csv format");
?>
</p>
<div class="clear"></div>

<div class="csv-processing-wrap">
<?php 
$db_ext = new DbExt();
$msg = '';
$error = '';
if (isset($_POST) && $_SERVER['REQUEST_METHOD'] == 'POST') {
    $filename = $_FILES['file']['name'];
    if (preg_match("/.csv/i", $filename)) {
        ini_set('auto_detect_line_endings', TRUE);
        $handle = fopen($_FILES['file']['tmp_name'], "r");
        $x = 1;
        while (($data = @fgetcsv($handle)) !== FALSE) {
            echo "<p class=\"non-indent uk-text-primary\">" . t("Processing line") . " ({$x})<br/></p>";
            if (count($data) >= 11) {
                $params = array('restaurant_name' => $data[0], 'restaurant_phone' => $data[1], 'contact_name' => $data[2], 'contact_phone' => $data[3], 'contact_email' => $data[4], 'country_code' => $data[5], 'street' => $data[6], 'city' => $data[7], 'state' => $data[8], 'post_code' => $data[9], 'status' => $data[10], 'username' => $data[4], 'password' => md5(isset($data[11]) ? $data[11] : Yii::app()->functions->generateCode()), 'restaurant_slug' => Yii::app()->functions->createSlug($data[0]), 'date_created' => date('c'), 'ip_address' => $_SERVER['REMOTE_ADDR']);
                echo "<p class=\"indent uk-text-primary\">" . t("Saving merchant") . "...</p>";
                if (!Yii::app()->functions->isMerchantExist($data[4])) {
                    if ($db_ext->insertData("{{merchant}}", $params)) {
Пример #14
0
 public function AdminUpdateCustomerReviews()
 {
     $db_ext = new DbExt();
     if (isset($this->data['id'])) {
         $params = array('review' => $this->data['review'], 'status' => $this->data['status'], 'rating' => $this->data['rating'], 'ip_address' => $_SERVER['REMOTE_ADDR']);
         if ($db_ext->updateData("{{review}}", $params, 'id', $this->data['id'])) {
             $this->code = 1;
             $this->msg = Yii::t("default", "Successful");
         } else {
             $this->msg = Yii::t("default", "ERROR: cannot update");
         }
     } else {
         $this->msg = "";
     }
 }