+ Send QR code to email when new agent register

This commit is contained in:
Djery-Tom 2022-01-19 12:43:19 +01:00
parent ef0e122682
commit 88616dc4ce
3 changed files with 37 additions and 15 deletions

View File

@ -5,7 +5,8 @@
"twilio/sdk": "^6.4", "twilio/sdk": "^6.4",
"guzzlehttp/guzzle": "^7.1", "guzzlehttp/guzzle": "^7.1",
"ext-json": "*", "ext-json": "*",
"ext-mysqli": "*" "ext-mysqli": "*",
"ext-curl": "*"
}, },
"description": "iLink World Mobile Backend" "description": "iLink World Mobile Backend"
} }

View File

@ -439,20 +439,39 @@ class Requester
$ct=($user['category']=='geolocated'?$this->messageText['AGENT_GEO']:($user['category']=='super'?$this->messageText['ADMIN']:$this->messageText['SUPER_ADMIN'])); $ct=($user['category']=='geolocated'?$this->messageText['AGENT_GEO']:($user['category']=='super'?$this->messageText['ADMIN']:$this->messageText['SUPER_ADMIN']));
$message1 =sprintf($this->messageText['MESSAGE_1'],$username,$ct,$phone,$request->password,$code,$validation); $message1 =sprintf($this->messageText['MESSAGE_1'],$username,$ct,$phone,$request->password,$code,$validation);
$message2 = sprintf($this->messageText['MESSAGE_2'],$username,$ct,$phone,$request->password,$code); $message2 = sprintf($this->messageText['MESSAGE_2'],$username,$ct,$phone,$request->password,$code);
$from = "noreply@ilink-app.com";
$headers = "From:" . $from;
$name = "ilink";
$this->messenger->setReceiverMail($user['email']); //Envoyez le mail de bienvenue
$this->messenger->setContact($user['phone']);
$this->messenger->setMessage($user['category']=='super'?$message2:$message1);
$this->messenger->setSubject($subject);
$this->messenger->setHeader($headers);
try{ try{
$this->messenger->sendMail(); /* API URL */
}catch (\Throwable $e){ $url = WALLET_SERVICE_URL.'/notify-new-agent';
$this->write_log($e->getMessage().'\n'.$e->getTraceAsString());; /* Init cURL resource */
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
/* set the content type json */
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type:application/json',
'Authorization:'.WALLET_SERVICE_TOKEN,
));
/* set return type json */
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
$body = new \stdClass();
$body->subject = $subject;
$body->email = $user['email'];
$body->message = $user['category'] == 'super' ? $message2 : $message1;
$body->category = $user['category'];
$body->agent_id = $user['agentId'];
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body));
/* execute request */
curl_exec($ch);
/* close cURL resource */
curl_close($ch);
}catch (Throwable $e){
$this->write_log("Error Notify New Agent ".$request->lastname." : ".$e->getMessage()."\n");
} }
$this->messenger->setContact($user['phone']);
$sms = $this->messenger->sendSms(); $sms = $this->messenger->sendSms();

View File

@ -7,6 +7,8 @@ define("DB_PASSWORD", "vps@2017GA");
#define("DB_DATABASE","iLink_test2"); #define("DB_DATABASE","iLink_test2");
define("DB_DATABASE","iLink_preprod"); define("DB_DATABASE","iLink_preprod");
define("GEOLOCATED_AGENT_ETAT",0); define("GEOLOCATED_AGENT_ETAT",0);
define("NOTIFICATION_SERVICE_URL",'localhost:8083'); define("NOTIFICATION_SERVICE_URL",'http://localhost:8083');
define("NOTIFICATION_SERVICE_KEY",'RfXvPQzQRgwpzQYPnLfWpZzgx4QseHlg') define("NOTIFICATION_SERVICE_KEY",'RfXvPQzQRgwpzQYPnLfWpZzgx4QseHlg');
?> define("WALLET_SERVICE_URL",'http://localhost:8081');
define("WALLET_SERVICE_TOKEN",'fywRtXSwEhHncwXaqn10wa9bJU9a63r2')
?>