Commit 84540c03 by Jansa Jose

payment for mechanics in app

parent 881a8df8
......@@ -2415,6 +2415,20 @@
$this->fail('','','1');
}
public function PayNowApi($transId=''){
if(empty($transId)){
$this->fail('','','1');
}
$mechData = $this->Webservice_model->getMechAmount($transId);
$amount = $mechData['data']['amount'] * 100;
$callback = base_url().'Webservices/verify_payment_api/'.$transId.'/1';
$postdata = array('email' => $mechData['emailId'],
'amount' => $amount,
'reference' => $transId,
'callback_url' => $callback);
$this->payStackPaymentApi($postdata);
}
public function orderPayNowApi($transId=''){
if(empty($transId)){
$this->fail('','','1');
......
......@@ -43,7 +43,7 @@
$postData = json_decode($post, true);
$respArr = array('status'=>'error','message'=>'Required Fields are empty.');
if(!isset($postData['user_name']) || empty($postData['user_name']) ||
!isset($postData['password']) || empty($postData['password'] = md5($postData['password']))){
!isset($postData['password']) || empty($postData['password'] = md5($postData['password'])) || !isset($postData['device_id']) || empty($postData['device_id'])){
echo json_encode($respArr);exit;
}
$respArr = $this->Webservice_mechanic_model->checkMechanicLogin($postData);
......
......@@ -21,12 +21,14 @@ function checkMechanicLogin($userLogData){
$respArr['message'] = "Username or Password is Incorrect";
return $respArr;
}
if($this->db->update('mechanic',array('device_id'=>$userLogData['device_id']),array('mechanic_id'=>$mechData->user_id))){
$authdata = $this->insert_auth($mechData->user_id);
if($authdata){
$mechData->auth_token = $authdata;
$respArr['data'] = $mechData;
$respArr['status'] = 'success';
}
}
return $respArr;
}
......
......@@ -343,7 +343,8 @@ class Webservice_model extends CI_Model {
);
if($this->db->update('bookings',$insert_array,array('booking_id'=>$postData['booking_id']))){
$this->db->insert("mechanic_booking",array('booking_id'=>$postData['booking_id'],'mechanic_id'=>$postData['mechanic_id'],'amount'=>$cost,'status'=>'0'));
$this->db->select("bookings.scheduled_time,bookings.scheduled_date,customer_vehicle.car_model as vehicle_model,customer_vehicle.car_maker as vehicle_make,customer_vehicle.car_model_year as vehicle_year,customer_vehicle.vehicle_data,TRIM(concat(mechanic.first_name,' ',IFNULL(mechanic.last_name,''))) as mechanic_name,mechanic_shop.shop_name as mechanic_shop,mechanic.address,mechanic.phone,admin_users.profile_image as image,bookings.mileage,bookings.issues_selected");
$this->db->select("bookings.scheduled_time,bookings.scheduled_date,customer_vehicle.car_model as vehicle_model,customer_vehicle.car_maker as vehicle_make,customer_vehicle.car_model_year as vehicle_year,customer_vehicle.vehicle_data,TRIM(concat(mechanic.first_name,' ',IFNULL(mechanic.last_name,''))) as mechanic_name,mechanic_shop.shop_name as mechanic_shop,mechanic.address,mechanic.phone,admin_users.profile_image as image,bookings.mileage,bookings.issues_selected,bookings.customer_id");
$this->db->join('customer_vehicle','customer_vehicle.customer_veh_id = bookings.customer_veh_id');
$this->db->join("mechanic_booking","mechanic_booking.booking_id = bookings.booking_id AND mechanic_booking.mechanic_id =".$postData['mechanic_id'],'left');
$this->db->join('mechanic','mechanic_booking.mechanic_id = mechanic.mechanic_id');
......@@ -351,6 +352,9 @@ class Webservice_model extends CI_Model {
$this->db->join('mechanic_shop','mechanic_shop.shop_id = mechanic.shop_id','left');
$mech_data = $this->db->get_where('bookings',array('bookings.booking_id'=>$postData['booking_id']));
if(!empty($mech_data) && !empty($mechanic_data = $mech_data->row_array())){
$this->db->insert('transaction',array('customer_id'=>$mechanic_data['customer_id'],'booking_id'=>$postData['booking_id'],'payment_for'=>'1','datetime'=>date('Y-m-d h:i:s'),'amount'=>$cost));
$mechanic_data['trans_id'] = $this->db->insert_id();
$mech_veh_data = json_decode($mechanic_data['vehicle_data']);
$mechanic_data['engine_no'] = !empty($mech_veh_data->engine)?$mech_veh_data->engine:'';
$mechanic_data['vehicle_trim'] = !empty($mech_veh_data->trim)?$mech_veh_data->trim:'';
......@@ -681,6 +685,10 @@ class Webservice_model extends CI_Model {
$this->db->update('transaction',array('transaction_response'=>json_encode($result),'transaction_reference'=>$result['data']['id'],'status'=>$status),array('bulk_bkng_unqId'=>$bookData->bulk_bkng_unqId));
if($payfor == '2'){
$this->db->query("UPDATE orders JOIN transaction ON transaction.booking_id = orders.order_id SET orders.status = $odr_status WHERE transaction.bulk_bkng_unqId = '".$bookData->bulk_bkng_unqId."'");
}else if($payfor == '1'){
$this->db->query("UPDATE bookings
JOIN transaction ON transaction.booking_id=bookings.booking_id
SET bookings.status = $status WHERE transaction.id = $transId");
}
return 1;
}
......
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