New card add
This commit is contained in:
@@ -53,10 +53,14 @@ $routes->post('/digiusers/v1/bvn/verify', 'DigiFiBVN::completeBVNVerif
|
||||
$routes->get('/digiusers/v1/dash', 'Users::userDash');
|
||||
$routes->get('/digiusers/v1/profile', 'Users::userProfile');
|
||||
|
||||
$routes->post('/digiusers/v1/addcard', 'Users::userAddCard');
|
||||
|
||||
$routes->get('/digiusers/v1/employers', 'Employers::approvedEmployersList');
|
||||
|
||||
$routes->post('/digiusers/v1/loan/apply', 'Loan::loanApply');
|
||||
$routes->get('/digiusers/v1/loan/loanlist', 'Loan::loanlist');
|
||||
$routes->get('/digiusers/v1/loan/loanlist', 'Loan::loanlist');
|
||||
|
||||
$routes->get('/digiusers/v1/loan/paymentcard/add', 'Loan::addPaymentCard');
|
||||
|
||||
|
||||
$routes->post('/employment/v1/auth', 'Employment::login');
|
||||
|
||||
@@ -173,4 +173,11 @@ abstract class BaseController extends Controller
|
||||
curl_close($curl);
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function readCustomer($uid){
|
||||
$userUid = trim($uid);
|
||||
$mysql ="SELECT * from customers where uid::text ='".$userUid."'";
|
||||
$query = $this->db->query($mysql);
|
||||
return $query->getRowArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ class DigiFiBVN extends BaseController
|
||||
$sqlM = "SELECT * FROM customers WHERE bvn = '".$data['bvn']."' ";
|
||||
$qu0 = $this->db->query($sqlM);
|
||||
$customer = $qu0->getResultArray();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,61 @@ class Users extends BaseController
|
||||
$this->request = \Config\Services::request();
|
||||
}
|
||||
|
||||
private function assignInternalEmail($id, $uid){
|
||||
$intE = "message+".str_pad($id, 12, "0", STR_PAD_LEFT)."@chiefsoft.com";
|
||||
$mysql = "UPDATE customers SET internal_email='".$intE."' WHERE internal_email IS NULL AND id = $id AND uid = '".$uid."'";
|
||||
$this->db->query($mysql);
|
||||
return $this->readCustomer($uid);
|
||||
}
|
||||
public function userAddCard(){
|
||||
$in = $this->request->getPost();
|
||||
|
||||
$loan_uid = $in["application_uid"];
|
||||
// $userUid = trim($in["uid"]);
|
||||
// $mysql ="SELECT id,internal_email from customers where uid ='"+$userUid+"'";
|
||||
// $query = $this->db->query($mysql);
|
||||
$row = $this->readCustomer($in["uid"]);
|
||||
$userID = 0;
|
||||
$CustomerCode = '';
|
||||
if (count($row)> 0){
|
||||
$userID = $row["id"];
|
||||
if ( $row["internal_email"] == '' ){
|
||||
$row = $this->assignInternalEmail($userID, $in["uid"]);
|
||||
}
|
||||
$userID = $row["id"];
|
||||
$userInternalEmail = $row["internal_email"];
|
||||
$CustomerCode = $row["customer_code"];
|
||||
}
|
||||
|
||||
|
||||
if ( $CustomerCode == ''){
|
||||
|
||||
$in_data = [
|
||||
"email" => $userInternalEmail,
|
||||
];
|
||||
|
||||
$createUserResult = $this->APIcall("POST", "http://10.10.10.48:6334/create-customer", json_encode($in_data));
|
||||
$CustomerCode = $createUserResult["customer_code"];
|
||||
$mysql = "UPDATE customers SET customer_code = '".$CustomerCode."' WHERE id = $userID AND uid = '".$in["uid"]."' ";
|
||||
$this->db->query($mysql);
|
||||
// $CustomerCode = $createUserResult["customer_code"];
|
||||
}
|
||||
|
||||
$in_data = [
|
||||
"email" => $userInternalEmail,
|
||||
"amount" => 500,
|
||||
"plan" => "PLN_qh2dasmlhweqa1l",
|
||||
];
|
||||
$initResult = $this->APIcall("POST", "http://10.10.10.48:6334/initialize-transaction-with-plan", json_encode($in_data));
|
||||
|
||||
$data = [
|
||||
'call_return' => '100',
|
||||
'customer_code' => $createUserResult["customer_code"],
|
||||
'redirect_url' => $initResult['authorization_url'],
|
||||
];
|
||||
// 'init_subscription' => $initResult
|
||||
return $this->respond($data, 200);
|
||||
}
|
||||
public function userDash(){
|
||||
$statusDetail[2] =[
|
||||
"text" => "Pending",
|
||||
|
||||
Reference in New Issue
Block a user