Commit e680e527 by Tobin

dc

parent 3b036b3c
......@@ -320,8 +320,11 @@ class Api extends CI_Controller {
}
public function payNow($auth_token='',$amount=0,$booking_id='',$event_id=''){
$settings = getSettings();
$redUrl = $settings['web_base_url'];
if(empty($auth_token) || empty($amount) || empty($booking_id)){
redirect('https://timeout.sa/staging/failure');
redirect($redUrl.'failure');
}
$payData = array('auth_token'=>$auth_token,'amount'=>$amount,'booking_id'=>$booking_id);
$res = $this->Api_model->payNow($payData);
......@@ -330,187 +333,155 @@ class Api extends CI_Controller {
$this->paymentGateway($amount,$res['transaction_id'],$event_id,$booking_id,$res['custData']);
}
else{
redirect('https://timeout.sa/staging/failure?event_id='.$eventid);
redirect($redUrl.'failure?event_id='.$eventid);
}
}
public function paymentGateway($amount='0',$last_id='0',$event_id='0',$booking_id='0',$custData=array()){
$amount = $amount;
$phone = (isset($custData->phone))?$custData->phone:'';
$email = (isset($custData->email))?$custData->email:'';
$userId = (isset($custData->userId))?$custData->userId:'';
$f_Name = (isset($custData->name))?$custData->name:'';
$l_Name = 'T';
$add1 = 'Mumbai';
$add2 = 'Mumbai';
$city = 'Mumbai';
$state = 'Maharashtra';
$pincode = '123456';
$cardNo = '5111111111111118';
$expMonth = '0';
$expYear = '2022';
$cvv = '100';
$holder = 'Basanta Mahunta';
$cardType = 'MasterCard';
$failureUrl = base_url('Api/paymentFailureUrl');
$successUrl = base_url('Api/paymentSuccessUrl');
$pText = '1111110||11111111|'.$last_id.'|'.$amount.'|'.$successUrl.'|'.$failureUrl.'|INTERNET|DD|01|SAR||1111111111111|'.$f_Name.'|'.$l_Name.'|'.$add1.'|'.$add2.'|'.$city.'|'.$state.'|'.$pincode.'|SA|'.$email.'|'.$phone.'|34|344|34355344||111111111111|'.$f_Name.'|'.$l_Name.'|'.$add1.'|'.$add2.'|'.$city.'|'.$state.'|'.$pincode.'|SA|'.$phone.'|34|344|34355344||11111100000|'.$cardNo.'|'.$expMonth.'|'.$expYear.'|'.$cvv.'|'.$holder.'|'.$cardType.'||1110000|'.$last_id.'|'.$event_id.'|'.$booking_id.'||1000000|'.$userId;
$settings = getSettings();
$iv = $settings['merchant_iv'];
$mId = $settings['merchant_id'];
$mKey = $settings['merchant_key'];
$colabId = $settings['collaborator_id'];
$requestUrl = $settings['payment_gateway_url'];
$size = openssl_cipher_iv_length('AES-256-CBC');
$pad = $size - (strlen($pText) % $size);
$painText = $pText . str_repeat(chr($pad), $pad);
$painText = base64_encode(openssl_encrypt($painText, 'AES-256-CBC', base64_decode($mKey), OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $iv));
$this->load->view('payment/payment',array('rUrl'=>$requestUrl,'mId'=>$mId,'colabId'=>$colabId,
'requestParam'=>$mId.'||'.$colabId.'||'.$painText));
}
public function paymentSuccessUrl(){
$response = '';
$transaction_id = '';
BayanPayPayment();
$BayanPayArray = $this->bayanPayArray('0','0','0','0');
$BayanPayOnlineObject = new BayanPayBitmapPaymentIntegration($BayanPayArray);
if(isset($_REQUEST['responseParameter']) && !empty($_REQUEST['responseParameter']) &&
!empty($response = explode("||",$_REQUEST['responseParameter'])) && !isset($_POST['txnErrMsg'])){
if(isset($_REQUEST['responseParameter']) && $_REQUEST['responseParameter'] != ''){
$response = $BayanPayOnlineObject->decryptData($_REQUEST['responseParameter'],$BayanPayOnlineObject->merchantKey,$BayanPayOnlineObject->iv);
$settings = getSettings();
$iv = $settings['merchant_iv'];
$mKey = $settings['merchant_key'];
$redUrl = $settings['web_base_url'];
$ref_id = explode('|',$response['Transaction_related_information']);
$transaction_id = $ref_id[1];
$last_id = explode('|',$response['Merchant_Information']);
$lastid = $last_id[1];
$eventid = $last_id[2];
$booking_id = $last_id[3];
$this->Api_model->update_payment($response,$transaction_id,$lastid,'1') ;
if(!isset($response[1]) || empty($response[1])){
redirect($redUrl.'failure');
}
redirect('https://timeout.sa/staging/bookingdetails?booking_id='.$booking_id);
$enctext = base64_decode($response[1]);
$padtext = openssl_decrypt($enctext,'AES-256-CBC', base64_decode($mKey),OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $iv);
$pad = ord($padtext{strlen($padtext) - 1});
if($pad > strlen($padtext)){
redirect($redUrl.'failure');
}
if(strspn($padtext, $padtext{strlen($padtext)-1},strlen($padtext)-$pad) != $pad){
redirect($redUrl.'failure');
}
$response = substr($padtext, 0, -1 * $pad);
public function paymentFailureUrl(){
$lastid = '';
$response = '';
$transaction_id = '';
BayanPayPayment();
$BayanPayArray = $this->bayanPayArray('0','0','0','0');
$BayanPayOnlineObject = new BayanPayBitmapPaymentIntegration($BayanPayArray);
if(empty($response) || empty($response = explode("||",$response))){
redirect($redUrl.'failure');
}
if(isset($_REQUEST['responseParameter']) && $_REQUEST['responseParameter'] != ''){
$response = $BayanPayOnlineObject->decryptData($_REQUEST['responseParameter'],$BayanPayOnlineObject->merchantKey,$BayanPayOnlineObject->iv);
$last_id = '';
$eventid = '';
$booking_id = '';
$transaction_id = '';
$ref_id = explode('|',$response['Transaction_related_information']);
$transaction_id = $ref_id[1];
$last_id = explode('|',$response['Merchant_Information']);
$lastid = $last_id[1];
$eventid = $last_id[2];
$booking_id = $last_id[3];
$this->Api_model->update_payment($response,$transaction_id,$lastid,'0');
if(isset($response[2]) && !empty($response[2]) && !empty($data = explode('|',$response[2])) &&
isset($data[1]) && !empty($data[1])){
$transaction_id = $data[1];
}
redirect('https://timeout.sa/staging/failure?event_id='.$eventid);
if(isset($response[4]) && !empty($response[4]) && !empty($data = explode('|',$response[4])) &&
isset($data[1]) && !empty($data[1]) && isset($data[2]) && !empty($data[2]) &&
isset($data[3]) && !empty($data[3])){
$last_id = $data[1];
$eventid = $data[2];
$booking_id = $data[3];
}
if(!empty($transaction_id) && !empty($last_id)){
$this->Api_model->update_payment($response,$transaction_id,$last_id,'1') ;
}
public function paymentGateway($amount='0',$lastid='0',$event_id='0',$booking_id='0',$custData=array()){
BayanPayPayment();
$BayanPayArray = $this->bayanPayArray($amount,$lastid,$event_id,$booking_id,$custData);
// $BayanPayOnlineObject = new BayanPayBitmapPaymentIntegration($BayanPayArray);
if(!empty($booking_id)){
redirect($redUrl.'bookingdetails?booking_id='.$booking_id);
}
}
redirect($redUrl.'failure');
}
$iv = $BayanPayOnlineObject->iv;
$merchantId = $BayanPayOnlineObject->merchantId;
$merchantKey = $BayanPayOnlineObject->merchantKey;
$collaboratorId = $BayanPayOnlineObject->collaboratorId;
$requestParameter = $pText;
public function paymentFailureUrl(){
$settings = getSettings();
$redUrl = $settings['web_base_url'];
$pText = $BayanPayOnlineObject->BayanPostData;
if(empty($_REQUEST['responseParameter'])){
redirect($redUrl.'failure');
}
$size = openssl_cipher_iv_length('AES-256-CBC');
$pad = $size - (strlen($pText) % $size);
$padtext = $pText . str_repeat(chr($pad), $pad);
$pText = base64_encode(openssl_encrypt($padtext, 'AES-256-CBC', base64_decode($merchantKey), OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $iv));
if(isset($_REQUEST['responseParameter']) && !empty($_REQUEST['responseParameter']) &&
!empty($response = explode("||",$_REQUEST['responseParameter']))){
$iv = $settings['merchant_iv'];
$mKey = $settings['merchant_key'];
if($BayanPayOnlineObject->url){
$requestUrl = 'https://payments.bayanpay.sa/direcpay/secure/PaymentTxnServlet';
} else {
$requestUrl = 'https://staging.bayanpay.sa/direcpay/secure/PaymentTxnServlet';
if(!isset($response[1]) || empty($response[1])){
redirect($redUrl.'failure');
}
$this->load->view('payment/payment',array('requestUrl'=>$requestUrl,
'merchantId'=>$merchantId,
'collaboratorId'=>$collaboratorId,
'requestParameter'=>$requestParameter));
$enctext = base64_decode($response[1]);
$padtext = openssl_decrypt($enctext,'AES-256-CBC', base64_decode($mKey),OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $iv);
$pad = ord($padtext{strlen($padtext) - 1});
if($pad > strlen($padtext)){
redirect($redUrl.'failure');
}
if(strspn($padtext, $padtext{strlen($padtext)-1},strlen($padtext)-$pad) != $pad){
redirect($redUrl.'failure');
}
$response = substr($padtext, 0, -1 * $pad);
function baseurl(){
if(isset($_SERVER['HTTPS']))
$protocol = ($_SERVER['HTTPS'] && $_SERVER['HTTPS'] != "off") ? "https" : "http";
else
$protocol = 'http';
return $protocol . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
if(empty($response = explode("||",$response))){
redirect($redUrl.'failure');
}
function bayanPayArray($amount='0',$lastid='',$event_id='',$booking_id='',$custData=array()){
$settings = getSettings();
$last_id = '';
if(isset($response[1]) && !empty($response[1]) && !empty($data = explode('|',$response[1])) &&
isset($data[1]) && !empty($data[1])){
$last_id = $data[1];
$this->Api_model->update_payment($response,'',$last_id,'0');
$BayanPayArray =
array(
'BayanPay_Online_setting' => array(
'merchantKey' => $settings['merchant_key'],
'merchantId' => $settings['merchant_id'],
'collaboratorId' => 'BAYANPAY',
'iv' => '0123456789abcdef',
'url' => false
),
'Block_Existence_Indicator'=> array(
'transactionDataBlock' => true,
'billingDataBlock' => true,
'shippingDataBlock' => true,
'paymentDataBlock' => true,
'merchantDataBlock' => false,
'otherDataBlock' => true,
'DCCDataBlock' => true
),
'Field_Existence_Indicator_Transaction' => array(
'merchantOrderNumber' => time(),
'amount' => $amount,
'successUrl' => base_url('Api/paymentSuccessUrl'),
'failureUrl' => base_url('Api/paymentFailureUrl'),
'transactionMode' => 'INTERNET',
'payModeType' => 'CC',
'transactionType' => '01',
'currency' => 'SAR'
),
'Field_Existence_Indicator_Billing' => array(
'billToFirstName' => (isset($custData->name))?$custData->name:'',
'billToLastName' => '',
'billToStreet1' => '',
'billToStreet2' => '',
'billToCity' => '',
'billToState' => '',
'billtoPostalCode' => '',
'billToCountry' => '',
'billToEmail' => (isset($custData->email))?$custData->email:'',
'billToMobileNumber' => (isset($custData->phone))?$custData->phone:'',
'billToPhoneNumber1' => '',
'billToPhoneNumber2' => '',
'billToPhoneNumber3' => ''
),
'Field_Existence_Indicator_Shipping' => array(
'shipToFirstName' => (isset($custData->name))?$custData->name:'',
'shipToLastName' => '',
'shipToStreet1' => '',
'shipToStreet2' => '',
'shipToCity' => '',
'shipToState' => '',
'shipToPostalCode' => '',
'shipToCountry' => '',
'shipToPhoneNumber1' => '',
'shipToPhoneNumber2' => '',
'shipToPhoneNumber3' => '',
'shipToMobileNumber' => (isset($custData->phone))?$custData->phone:''
),
'Field_Existence_Indicator_Payment' => array(
'cardNumber' => '5123450000000008',
'expMonth' => '07',
'expYear' => '2025',
'CVV' => '100',
'cardHolderName' => 'Test Master',
'cardType' => 'MasterCard',
'custMobileNumber' => '',
'paymentID' => '',
'OTP' => '',
'gatewayID' => '',
'cardToken' => ''
),
'Field_Existence_Indicator_Merchant' => array(
'UDF1' => $lastid,
'UDF2' => $event_id,
'UDF3' => $booking_id
),
'Field_Existence_Indicator_OtherData' => array(
'custID' => (isset($custData->userId))?$custData->userId:'',
'transactionSource' => 'IVR',
'productInfo' => '',
'isUserLoggedIn' => '',
'itemTotal' => '',
'itemCategory' => '',
'ignoreValidationResult'=> 'FALSE'
),
'Field_Existence_Indicator_DCC' => array(
'DCCReferenceNumber' => $lastid.$event_id.$booking_id,
'foreignAmount' => $amount,
'ForeignCurrency' => 'SAR'
)
);
return $BayanPayArray;
$sql = "SELECT BOK.event_id FROM transaction AS TX
INNER JOIN booking AS BOK ON (BOK.bookId=TX.booking_id)
WHERE TX.id='$last_id'";
$trxData = $this->db->query($sql)->row_array();
if(!empty($trxData) && isset($trxData['event_id']) && !empty($trxData['event_id'])){
redirect($redUrl.'failure?event_id='.$trxData['event_id']);
}
}
}
redirect($redUrl.'failure');
}
public function checker_bookingDetails(){
......
......@@ -125,9 +125,9 @@
return $savePath;
}
function BayanPayPayment(){
include 'BayanPayPaymentLibrary.php';
}
// function BayanPayPayment(){
// include 'BayanPayPaymentLibrary.php';
// }
function getCurrency($userId=''){
$CI = & get_instance();
......
......@@ -557,30 +557,30 @@ class Api_model extends CI_Model {
$imgExt = strtolower($imgNameArr[1]);
if($imgExt=='png' || $imgExt=='jpeg' || $imgExt == 'jpg' || $imgExt == 'gif'){
$imgPath = 'assets/uploads/user/CUST_'.$user_id.'.png';
$imgQRPath = 'assets/uploads/user/CUST_QR_'.$user_id.'.png';
$bagImagePath = 'assets/uploads/user/bitmoji_back.png';
$imgPath = 'assets/uploads/user/CUST_'.$user_id.'.'.$imgExt;
// $imgQRPath = 'assets/uploads/user/CUST_QR_'.$user_id.'.png';
// $bagImagePath = 'assets/uploads/user/bitmoji_back.png';
move_uploaded_file($data['file']["tmp_name"],"./".$imgPath);
$imgSrc = imagecreatefrompng($imgPath);
$bagSrc = imagecreatefrompng($bagImagePath);
$bagW = imagesx($bagSrc)/3;
$bagH = imagesy($bagSrc)/3;
$imgW = imagesx($imgSrc);
$imgH = imagesy($imgSrc);
$scale = $imgW/$bagW;
$iWidth = $bagW;
$iHeight = $imgH/$scale;
// $imgSrc = imagecreatefrompng($imgPath);
// $bagSrc = imagecreatefrompng($bagImagePath);
// $bagW = imagesx($bagSrc)/3;
// $bagH = imagesy($bagSrc)/3;
// $imgW = imagesx($imgSrc);
// $imgH = imagesy($imgSrc);
// $scale = $imgW/$bagW;
// $iWidth = $bagW;
// $iHeight = $imgH/$scale;
imagecopyresampled($bagSrc,$imgSrc,$iWidth,$bagH,0,0,$iWidth,$iHeight,$imgW,$imgH);
imagepng($bagSrc,$imgPath);
imagealphablending($imgPath, false);
imagesavealpha($imgPath, true);
// imagecopyresampled($bagSrc,$imgSrc,$iWidth,$bagH,0,0,$iWidth,$iHeight,$imgW,$imgH);
// imagepng($bagSrc,$imgPath);
// imagealphablending($imgPath, false);
// imagesavealpha($imgPath, true);
genQRcode(encode_param($user_id),$imgQRPath,$imgPath);
// genQRcode(encode_param($user_id),$imgQRPath,$imgPath);
$post_data['profile_image'] = $imgPath;
$post_data['profile_image_qr'] = $imgQRPath;
$post_data['profile_image_qr'] = '';//$imgQRPath;
$state=$this->db->where('customer_id',$user_id)->update('customer',$post_data);
if($state){
......@@ -1339,8 +1339,11 @@ class Api_model extends CI_Model {
return $this->db->get()->row();
}
function update_payment($response,$transactionid,$last_id,$status){
function update_payment($response='',$transactionid='',$last_id,$status){
try{
if(empty($last_id)){
return;
}
$this->db->update('transaction',
array('transaction_id'=>$transactionid,
'transaction_response'=>json_encode($response),
......
......@@ -967,23 +967,21 @@ class Webservice_model extends CI_Model {
$this->db->from('users');
$this->db->join('customer','customer.customer_id = users.id');
$num = $this->db->get()->num_rows();
if($num > 0)
{
if($num > 0) {
$res = array('status'=>0,'message'=>'Email address already exist','code'=>'ER32');
return $res;
}
}
if(isset($data['file'])){
$img=$data['file']['name'];
$expbanner = explode('.',$img);
$img_ext = strtolower($expbanner[1]);
$rand = rand(10000,99999);
$encname = time().$rand;
if($img_ext=='png' || $img_ext=='jpeg' || $img_ext == 'jpg' || $img_ext == 'gif'){
$bannername = $encname.'.'.$img_ext;
$imagePath="./assets/uploads/".$bannername;
$post_data['profile_image'] = "assets/uploads/".$bannername;
move_uploaded_file($data['file']["tmp_name"],$imagePath);
$imgName = $data['file']['name'];
$imgNameArr = explode('.',$imgName);
$imgExt = strtolower($imgNameArr[1]);
if($imgExt=='png' || $imgExt=='jpeg' || $imgExt == 'jpg' || $imgExt == 'gif'){
$imgPath = 'assets/uploads/user/CUST_'.$user_id.'.'.$imgExt;
move_uploaded_file($data['file']["tmp_name"],"./".$imgPath);
$post_data['profile_image'] = $imgPath;
$state = $this->db->where('customer_id',$user_id)->update('customer',$post_data);
if($state){
$img_error = 1;
......
......@@ -5,10 +5,10 @@
<body>
<center><h1 style="margin-top: 20%">Please do not refresh this page...</h1></center>
<form action="<?= $requestUrl ?>" method="post" id="BayanPay_online_payment">
<input type="hidden" name="MerchantID" value="<?php echo $merchantId; ?>">
<input type="hidden" name="CollaboratorID" value="<?php echo $collaboratorId; ?>">
<input type="hidden" name="requestParameter" value="<?= $requestParameter ?>">
<form action="<?= $rUrl ?>" method="post" id="BayanPay_online_payment">
<input type="hidden" name="MerchantID" value="<?php echo $mId; ?>">
<input type="hidden" name="CollaboratorID" value="<?php echo $colabId; ?>">
<input type="hidden" name="requestParameter" value="<?= $requestParam ?>">
</form>
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function(event) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment