Files
WrenchBoradWeb/www/application/controllers/Paymnt.php
T
2022-03-07 14:00:31 -05:00

108 lines
3.7 KiB
PHP

<?php
class Paymnt extends Users_Controller {
public function index() {
$data = $this->getSessionArray();
if (!isset($_SESSION['username']) or $_SESSION['username'] == '') {
redirect(home);
} else {
}
}
public function paymus() {
$data = $this->getSessionArray();
$data['card_table_result'] = $this->cardListData(4)['card_table_result'];
$this->RenderUserPage('users/view_startpaymus', $data);
}
private function cardListData($limit){
$data = array();
$mysql = "SELECT * FROM creditcard WHERE member_id = " . $_SESSION['member_id'] . " AND status =3 AND active =1 ORDER BY id DESC limit ".$limit;
$query = $this->db->query($mysql);
$data['card_table_result'] = $query->result();
return $data;
}
public function newcc(){
$data = $this->getSessionArray();
if ($_POST) {
$this->load->model('cardpay_model');
$cd = array();
$cd['cardnumber'] = $this->input->post('cardnumber');
$cd['exp_month'] = $this->input->post('exp_month');
$cd['exp_year'] = $this->input->post('exp_year');
$cd['cvc'] = $this->input->post('cvc');
$cd['description']= $this->input->post('description');
$amount = rand(5555,9999);
$cardTestResult= $this->cardpay_model->verifyCardData($cd);
//var_dump($cardTestResult);
//var_dump($cd);
if ( $cardTestResult['error_status'] == false) // no error
{
$member_id = $_SESSION['member_id'];
$email ="support@wrenchboard.com";
$cardData=array(
"action" => WRENCHBOARD_USER_ADNEWCC,
"cardnumber" => $cd['cardnumber'],
"exp_month" => $cd['exp_month'],
"exp_year" => $cd['exp_year'],
"cvc" => $cd['cvc'],
"amount" => $amount ,
"email" => $email,
"description" => $cd['description'],
"member_id" => $member_id,
"paymenttype" => 100
);
$out=array();
$this->load->model('backend_model');
$res = $this->backend_model->wrenchboard_api($cardData, $out);
// var_dump($res);
// exit();
$out['order_id'] = $res;
if ($res > 0 && isset($out) && isset($out['confirmation']) && $out['confirmation']!='') {
// we are good
$this->session->set_flashdata('reciept_data', $out);
redirect("paymnt/cardreciepts");
} else {
// not good
$this->session->set_flashdata('reciept_data', $out);
redirect("paymnt/cardreciepts");
}
} // no error(s) from card test PHP model
else{
$data['card_test_result'] = $cardTestResult;
$data['card_table_result'] = $this->cardListData(4)['card_table_result'];
$this->RenderUserPage('users/view_startpaymus', $data); // return back to card page
}
}
else
{
return $this->paymus();
}
}
public function cardreciepts(){
$data = array_merge($this->getSessionArray(), $this->session->flashdata('reciept_data'));
if (!isset($data['confirmation'])){
redirect("dash");
}
$this->RenderUserPage('users/view_payreciepts', $data); // return back to card page
}
}