<?php session_start(); require 'ParsianGateway.php'; define('Parsian_PIN', 'N7xv862r77428Sey1IUD'); define('CALL_BACK_URL', 'http://safarbooking.ir/pst/'); //address hamin file gozashteh shvad $gateway = new ParsianGateway(Parsian_PIN); if (isset($_POST['act'])) { $act = $_POST['act']; switch ($act) { case 'PinPaymentRequest': $_SESSION['callback'] = $_POST['callback']; $result = $gateway->PinPaymentRequest($_POST['amount'], $_POST['orderid'], CALL_BACK_URL); if ($result) { echo json_encode(array('err' => 1)); } else { echo json_encode(array('err' => 0, 'status' => $result['status'], 'authority' => $result['authority'])); } break; case 'redirect': $gateway->Redirect_GateWay($_POST['au'], $_POST['status']); break; case 'PinPaymentEnquiry': $result = $gateway->PinPaymentEnquiry($_POST['au'], $_POST['status']); echo json_encode(array('status' => $result)); break; } } if (isset($_GET['au'])) { $data = '<form method="GET" action="' . $_SESSION['callback'] . '" id="myForm">';
public function Callback($PSTData, $GETData) { //parsian gateway if (isset($GETData['au'], $GETData['rs'])) { $t = new Transaction(); $trans = $t->get_by_au($GETData['au']); if ($trans && $GETData['rs'] == 0) { $totalamont = $trans['amount']; //var_dump($trans);exit; $u = new user(); $guest = $u->Get_Guest_ID(); //get invoice $invoice = new Invoice(); $invc_num = $invoice->get_by_transID($trans['id']); //var_dump($invc_num);exit; //check tranaction by PaymentEnquiry $gt = new ParsianGateway(Parsian_PIN); //confirm reservation $ctrl = new HotelController(); $refference = $invoice->get_By_id($invc_num); $refference = $refference['refference']; $r = new Request(); $confirm = $r->get_FinalReserve($refid); if ($confirm) { //if (true) { // $confirm = array( // 'voucher' => '101010', // 'Reference' => '202020' // ); //var_dump($confirm);exit; if ($gt->PaymentEnquiry($GETData['au'], $GETData['rs'])) { //if (TRUE) { //add paydoc } else { $app = new AppController(); $app->Erro('در تایید تراکنش خطایی رخ داد '); return FALSE; } //chang inoice status $invoice->submit($invc_num, $confirm['voucher'], $confirm['Reference']); $pd = new Paydoc(); if (isset($_SESSION['user']['id'])) { $current_credit = $u->getcredit($_SESSION['user']['id'], 'IRR'); $remain = $current_credit - $totalamont; if ($pd->Save($_SESSION['user']['id'], -1, $totalamont, $invc_num, 'IRR')) { $u->change_credit($_SESSION['user']['id'], 'IRR', $remain); } } else { $pd->Save($guest, -1, $totalamont, $invc_num, 'IRR'); } $psgr = new passenger(); $rmmm = new InvoiceDetail(); $inv = new Invoice(); $transfer_data = $inv->get_Tranfer_Data($invc_num); //print_r($transfer_data);exit; //$invc_num $variable = array(); $variable['voucher'] = $confirm['voucher']; $variable['invoce_data'] = $invoice->get_By_id($invc_num); $variable['passengers'] = $psgr->getByInvoice($invc_num); $variable['rooms'] = $rmmm->getByInvoice($invc_num); $variable['transfer'] = $transfer_data; if ($variable) { foreach ($variable as $k => $v) { ${$k} = $v; } } $ctrl->ShowReserve_info($confirm); } else { $app = new AppController(); $app->Erro('در تکمیل رزرو خطایی رخ داد '); return FALSE; } //add paydoc } else { if ($GETData['rs'] == 1) { $app = new AppController(); $app->Erro('تراکنش موفق '); } else { $app = new AppController(); $app->Erro('شماره تراکنش اشتباه است'); } return FALSE; } } else { //err for now $app = new AppController(); $app->Erro('شماره تراکنش اشتباه است'); return FALSE; } }
foreach ($_POST['invoice'] as $detail) { $invcdtl = new InvoiceDetail(); $invcdtl->invoice = $invc_num; $invcdtl->room = $detail['id']; $invcdtl->room_title = ''; $invcdtl->adult = 0; $invcdtl->child = 0; $invcdtl->amount = $detail['price']; $invcdtl->save(); } } else { $app = new AppController(); $app->Erro('متاسفانه درتکمیل فرآیند خطایی رخ داد'); } if ($_POST['paymentype'] == 'parsian') { $gt = new ParsianGateway(Parsian_PIN); $st = $gt->PinPaymentRequest($totalamont, time(), Base_URL . '?controller=bank&action=callback'); if ($st && $st['authority'] && $st['status'] == 0) { $trans = new Transaction(); $trans->amount = $totalamont; if (isset($_SESSION['user']['id'])) { $trans->user = $_SESSION['user']['id']; $trans->email = $_SESSION['user']['email']; $trans->name = $_SESSION['user']['name']; $trans->family = $_SESSION['user']['family']; } else { $u = new user(); $trans->user = $u->Get_Guest_ID(); $trans->email = ''; $trans->name = ''; $trans->family = '';