New card add
This commit is contained in:
@@ -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