public function callbackGateway() { $result = $_POST['Result']; $requestId = $_POST['RequestId']; $followCode = $_POST['FollowCode']; $payment = Cshop::app()->getDb()->prepare(QueryBuilder::getInstance()->select()->from('payment')->where('reference = ?')); $payment->execute(array($requestId)); $amount = round($payment['amout']); if ($payment['status'] == Application::STATUS_PENDING) { if ($result == 0) { if ($_POST[Amount] != $payment['amout']) { $message = 'در اطلاعات پرداختي مغايرت وجود دارد'; } else { $backResult = file("http://www.sharjiran.net/asan_pardakht/CheckPay2.php?FollowCode={$followCode}&RequestId={$requestId}"); if ($backResult[0] == 0 && (int) $backResult[1] == (int) $payment['amout'] && $backResult[2] == trim($this->AccountNumber)) { return $payment; } else { $message = 'تراكنش موفقيت آميز نبود'; } } } else { if ($result == -1) { $message = 'در اتصال به درگاه بانك مشكلي پيش آمده يا اينكه اطلاعات پرداختي شما نامعتبر بوده است. '; } } } else { $message = 'سفارش قبلا پرداخت شده است.'; } throw new Exception($message); }
public function callbackGateway() { $au = $_GET['au']; $ref_id = $_GET['order_id']; if (strlen($au) > 4) { $payment = Cshop::app()->getDb()->prepare(QueryBuilder::getInstance()->select()->from('payment')->where('reference = ?')); $payment->execute(array($au)); $payment = $payment->fetch(); $merchantID = $this->merchant; $amount = round($payment['amount'] / 10); $client = new nusoap_client('http://jahanpay.com/webservice?wsdl', 'wsdl'); $res = $client->call("verification", array($merchantID, $amount, $au)); if ($payment['status'] == Application::STATUS_PENDING) { if (!empty($res) and $res == 1) { return $payment; } else { $message = 'پرداخت توسط جهان پی انجام نشده است .'; } } else { $message = 'سفارش قبلا پرداخت شده است.'; } } else { $message = 'شماره یکتا اشتباه است.'; } throw new Exception($message); }
public function callbackGateway() { global $db, $get; $Status = $_POST['status']; $Refnumber = $_POST['refnumber']; $Resnumber = $_POST['resnumber']; if ($Status == 100) { $ParspalPin = trim($this->merchant); $pass = $this->pass; $payment = Cshop::app()->getDb()->prepare(QueryBuilder::getInstance()->select()->from('payment')->where('reference = ?')); $payment->execute(array($Resnumber)); $payment = $payment->fetch(); $amount = round($payment['amount'] / 10); $soapclient = new nusoap_client('http://merchant.parspal.com/WebService.asmx?wsdl', 'wsdl'); $params = array('MerchantID' => $ParspalPin, 'Password' => $pass, 'Price' => $amount, 'RefNum' => $Refnumber); $res = $soapclient->call('verifyPayment', $params); $Status = $res['verifyPaymentResult']['ResultStatus']; if (strtolower($Status) == 'success') { return $payment; } else { $message = 'پرداخت ناموفق است. خطا'; } } else { $message = 'پرداخت ناموفق است. خطا'; } throw new Exception($message); }
public function callbackGateway() { $merchantID = $this->merchantID; $au = preg_replace('/[^a-z0-9]/', '', $_GET['au']); $ref_id = $_GET['order_id']; if (strlen($au) > 4) { $payment = Cshop::app()->getDb()->prepare(QueryBuilder::getInstance()->select()->from('payment')->where('id = ?')); $payment->execute(array($au)); $payment = $payment->fetch(); $amount = round($payment['amount'] / 10); $client = new nusoap_client('https://www.sibapal.com/payment/wsdl?wsdl', 'wsdl'); $res = $client->call("verify", array($merchantID, $amount, $au)); if ($payment['status'] == Application::STATUS_PENDING) { if (!empty($res) and $res == 1) { return $payment; } else { $message = 'پرداخت توسط سیباپال انجام نشده است .'; } } else { $message = 'سفارش قبلا پرداخت شده است.'; } } else { $message = 'شماره یکتا اشتباه است.'; } throw new Exception($message); }
public function callbackGateway() { if ($_POST['status'] != '1') { $message = 'پرداخت با موفقيت انجام نشده است.'; throw new Exception($message); } $refID = $_POST['refnum']; $resCode = $_POST['resnum']; $id = $this->merchantID; $payment = Cshop::app()->getDb()->prepare(QueryBuilder::getInstance()->select()->from('payment')->where('id = ?')); $payment->execute(array($resCode)); $payment = $payment->fetch(); if ($payment['status'] == Application::STATUS_PENDING) { $amount = $payment['amount']; $url = 'http://bazpardakht.com/webservice/verify.php'; $fields = array('id' => urlencode($id), 'resnum' => urlencode($resCode), 'refnum' => urlencode($refID), 'amount' => urlencode($amount / 10)); //url-ify the data for the POST $fields_string = ""; foreach ($fields as $key => $value) { $fields_string .= $key . '=' . $value . '&'; } rtrim($fields_string, '&'); //open connection $ch = curl_init($url); //set the url, number of POST vars, POST data curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, count($fields)); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //execute post $result = curl_exec($ch); curl_close($ch); $result = intval($result); $pay = false; if ($result <= 0) { $pay = false; } elseif ($result == '1') { $pay = true; } /////////////////// if ($pay) { return $payment; } else { $message = 'خطا در پرداخت'; } } else { $message = 'این سفارش قبلا پرداخت شده است.'; } throw new Exception($message); }
public function callbackGateway() { $api = $this->pin; $url = 'http://payline.ir/payment-test/gateway-result-second'; $trans_id = $_POST['trans_id']; $id_get = $_POST['id_get']; $result = $this->get($url, $api, $trans_id, $id_get); if ($result == 1) { $payment = Cshop::app()->getDb()->prepare(QueryBuilder::getInstance()->select()->from('payment')->where('reference = ?')); $payment->execute(array($id_get)); $payment = $payment->fetch(); if ($payment) { return $payment; } else { $message = 'اطلاعات پرداخت کامل نیست.'; } } else { $message = 'پرداخت موفقيت آميز نبود'; } throw new Exception($message); }
public function callbackGateway() { $Authority = $_GET['Authority']; $ref_id = $_GET['refID']; if ($_GET['Status'] == 'OK') { $payment = Cshop::app()->getDb()->prepare(QueryBuilder::getInstance()->select()->from('payment')->where('reference = ?')); $payment->execute(array($Authority)); $amount = round($payment['amout'] / 10); $client = new nusoap_client('https://de.zarinpal.com/pg/services/WebGate/wsdl', 'wsdl'); $res = $client->call("PaymentVerification", array(array('MerchantID' => $this->merchant, 'Authority' => $Authority, 'Amount' => $amount))); if ($payment[payment_status] == Application::STATUS_PENDING) { if ($res['Status'] == 100) { return $payment; } else { $message = 'پرداخت توسط زرینپال تایید نشد.' . $res['Status']; } } else { $message = 'سفارش قبلا پرداخت شده است.'; } } else { $message = 'شماره یکتا اشتباه است.'; } throw new Exception($message); }
public function callbackGateway() { $au = $_SESSION['siba_au']; $order_id = $_SESSION['invoice_id']; $pin = $this->merchantID; $payment = Cshop::app()->getDb()->prepare(QueryBuilder::getInstance()->select()->from('payment')->where('reference = ?')); $payment->execute(array($au)); $payment = $payment->fetch(); $amount = round($payment['amount'] / 10); $bank_return = $_POST + $_GET; $res = $this->verify($pin, $amount, $au, $order_id, $bank_return); if ($payment['status'] == Application::STATUS_PENDING) { if (empty($res)) { $message = 'خطا در اتصال به سرور !'; } elseif ($res['result'] == 1) { return $payment; } else { $message = 'پرداخت انجام نشده است . <br /> شرح خطا : ' . urldecode($res['msg']); } } else { $message = 'سفارش قبلا پرداخت شده است.'; } throw new Exception($message); }
public function init() { $this->_templatepath = Cshop::$templatepath; $this->db = Cshop::app()->getDb(); $this->user = new User(); }
public function actionViewPayment() { $message = $this->user->message(); if (!isset($_GET['id'])) { Cshop::app()->redirect('payment.php'); } $sql = $this->db->prepare(QueryBuilder::getInstance()->select()->from('payment')->where('payment.id=?')); $sql->execute(array($_GET['id'])); $payment = $sql->fetch(); if (!$payment) { Cshop::app()->redirect('payment.php'); } $sql = CShop::app()->getDb()->prepare(QueryBuilder::getInstance()->select('input.*,value')->from('payment_meta')->leftJoin('input')->on('inputid = input.id')->where('paymentid = ?')); $sql->execute(array($payment['id'])); $payment['input'] = array(); while ($row = $sql->fetch()) { $row['data'] = unserialize($row['data']); $payment['input'][$row['id']] = $row; } $sql = $this->db->prepare(QueryBuilder::getInstance()->select('item.*,value.fieldid,value,field.name AS fieldname,field.type,product.name,product.description')->from('item')->leftJoin('product')->on('product.id = item.productid')->leftJoin('value')->on('item.id = itemid')->leftJoin('field')->on('fieldid = field.id')->where('paymentid = ?')); $sql->execute(array($_GET['id'])); $items = array(); while ($item = $sql->fetch()) { $items[$item['id']][] = $item; } CShop::app()->getEventHandler()->attach(Application::EVENT_MENU, function (&$menu) { $menu['خرید ها']['مشاهده خرید'] = CShop::$baseurl . '/admin/' . 'viewpayment.php?id=' . $_GET['id']; }); $this->render('admin/paymentview', array('message' => $message, 'payment' => $payment, 'items' => $items)); }
/** * * @param Controller $controller */ public function actionEditVoucher($controller) { $message = $controller->getUser()->message(); if (!isset($_GET['vid'])) { Cshop::app()->redirect(self::getActionLink('voucher', $this->id)); } $vouchers = CShop::app()->getDb()->prepare(QueryBuilder::getInstance()->select()->from('voucher')->where('id = ?')); $vouchers->execute(array($_GET['vid'])); $vouchers = $vouchers->fetch(); if (!$vouchers) { Cshop::app()->redirect(self::getActionLink('voucher', $this->id)); } CShop::app()->getEventHandler()->attach(Application::EVENT_MENU, function (&$menu) { $menu['کد تخفیف']['ویرایش کد تخفیف'] = $_SERVER['REQUEST_URI']; }); if (isset($_POST['save'])) { $voucher = $_POST['voucher']; //validate try { if (empty($voucher['code'])) { throw new Exception('لطفا یک کد انتخاب کنید'); } if ($voucher['time'] != -1) { $time = time() + 24 * 60 * 60 * $voucher['time']; } else { $time = $voucher['time']; } $sql = CShop::app()->getDb()->prepare(QueryBuilder::getInstance()->update('voucher')->set('code=?,time=?,maxuse=?,value=?,productid=?')->where('id=?')); $sql->execute(array($voucher['code'], $time, $voucher['maxuse'], $voucher['value'], $voucher['productid'], $_GET['vid'])); $message['content'] = 'تغییرات با موفقیت ذخیره شد'; $message['type'] = 'success'; $controller->getUser()->message($message); CShop::app()->redirect($_SERVER['REQUEST_URI']); } catch (Exception $e) { $message['content'] = $e->getMessage(); } } else { $voucher = $vouchers; if ($voucher['time'] != -1) { $voucher['time'] = round(($voucher['time'] - time()) / (60 * 60 * 24), 2); $voucher['time'] = $voucher['time'] > 0 ? $voucher['time'] : 0; } } $content = '<div class="title">ویرایش کد تخفیف</div> <div class="content"> <form action="" method="post"> <div class="formrow"> <div class="label"><label for="code">کد</label></div> <div class="input"><input type="text" name="voucher[code]" id="code" value="' . $voucher['code'] . '"></div> </div> <div class="formrow"> <div class="label"><label for="time">تعداد روز استفاده ( -1 برای بینهایت )</label></div> <div class="input"><input type="text" name="voucher[time]" id="time" value="' . $voucher['time'] . '"></div> </div> <div class="formrow"> <div class="label"><label for="maxuse">تعداد استفاده( -1 برای بینهایت )</label></div> <div class="input"><input type="text" name="voucher[maxuse]" id="maxuse" value="' . $voucher['maxuse'] . '"></div> </div> <div class="formrow"> <div class="label"><label for="value">ارزش ( بدون % )</label></div> <div class="input"><input type="text" name="voucher[value]" id="value" value="' . $voucher['value'] . '"></div> </div> <div class="formrow wide"> <div class="label"><label for="productid">محصول (-1 برای همه)</label></div> <div class="input"><input type="text" name="voucher[productid]" id="productid" value="' . $voucher['productid'] . '"></div> </div> <div class="formrow"> <input type="submit" value="ذخیره" name="save"> </div> </form> </div>'; $controller->renderWithContent($content, array('message' => $message)); }
/** * * @param Controller $controller */ public function actionEditPage($controller) { $message = $controller->getUser()->message(); if (!isset($_GET['pid'])) { Cshop::app()->redirect(self::getActionLink('page', $this->id)); } $pages = CShop::app()->getDb()->prepare(QueryBuilder::getInstance()->select()->from('page')->where('id = ?')); $pages->execute(array($_GET['pid'])); $pages = $pages->fetch(); if (!$pages) { Cshop::app()->redirect(self::getActionLink('page', $this->id)); } CShop::app()->getEventHandler()->attach(Application::EVENT_MENU, function (&$menu) { $menu['مدیریت صفحه ها']['ویرایش صفحه'] = $_SERVER['REQUEST_URI']; }); if (isset($_POST['save'])) { $page = $_POST['page']; //validate try { if (empty($page['name'])) { throw new Exception('لطفا یک عنوان مناسب انتخاب کنید'); } $sql = CShop::app()->getDb()->prepare(QueryBuilder::getInstance()->update('page')->set('name=?,type=?,content=?')->where('id=?')); $sql->execute(array($page['name'], $page['type'], $page['content'], $pages['id'])); $message['content'] = 'تغییرات با موفقیت ذخیره شد'; $message['type'] = 'success'; $controller->getUser()->message($message); CShop::app()->redirect($_SERVER['REQUEST_URI']); } catch (Exception $e) { $message['content'] = $e->getMessage(); } } else { $page = $pages; } $content = '<div class="title">ویراش صفحه</div> مقادیر نوع می تواند به صورت زیر باشد <br> 0:مقدار محتوی به صورت لینک خواهد شد <br> 1:مقدار محتوی با قالب فروشگاه نمایش داده خواهد شد <br> 2:مقدار محتوی بدون قالب فروشگاه نمایش داده خواهد شد <div class="content"> <form action="" method="post"> <div class="formrow"> <div class="label"><label for="name">نام</label></div> <div class="input"><input type="text" name="page[name]" id="name" value="' . $page['name'] . '"></div> </div> <div class="formrow"> <div class="label"><label for="name">نوع</label></div> <div class="input"><input type="text" name="page[type]" id="name" value="' . $page['type'] . '"></div> </div> <div class="formrow wide"> <div class="label"><label for="content">محتوی</label></div> <div class="input"><textarea name="page[content]" id="content">' . $page['content'] . '</textarea></div> </div> <div class="formrow"> <input type="submit" value="ذخیره" name="save"> </div> </form> </div>'; $controller->renderWithContent($content, array('message' => $message)); }