diff --git a/.env b/.env index 2f4479a2..5c76d53b 100644 --- a/.env +++ b/.env @@ -142,3 +142,9 @@ CI_ENVIRONMENT = development # curlrequest.shareOptions = true APP_TIMEZONE = 'Asia/Kolkata' + +#-------------------------------------------------------------------- +# Whatsapp Access Token And Instance ID +#-------------------------------------------------------------------- +WAAI_TOKEN = '6568739969f28' +WAAI_INSTANCE = '656876690A9FD' diff --git a/app/Config/Constants.php b/app/Config/Constants.php index 9befb3d6..874daacf 100644 --- a/app/Config/Constants.php +++ b/app/Config/Constants.php @@ -115,8 +115,17 @@ define('order_column', ["invoice_id","wp_api_order_id","invoice_child_id"]); define('order_child','invoiceitems'); define('order_child_column', ["invoice_id","wp_api_line_items_id","customer_id"]); -define('WAAI_TOKEN', '652548474f4e4'); -define('WAAI_INSTANCE', '65254894E4A88'); +// define('WAAI_TOKEN', '652548474f4e4'); +// define('WAAI_INSTANCE', '65254894E4A88'); + +// UAT - for testing Purpose.. +// define('WAAI_TOKEN', '65685e954bcf6'); +// define('WAAI_INSTANCE', '656863C54F90C'); + +// LIVE - Vel given.30th Nov. +// define('WAAI_TOKEN', '6568739969f28'); +// define('WAAI_INSTANCE', '656876690A9FD'); + define('SEND_WAAI_URL', 'https://waai.in/api/send'); define('SEND_WAAI_GROUP_URL', 'https://waai.in/api/send_group'); diff --git a/app/Controllers/Notifications.php b/app/Controllers/Notifications.php index 76004f59..d52c2946 100755 --- a/app/Controllers/Notifications.php +++ b/app/Controllers/Notifications.php @@ -35,9 +35,9 @@ class Notifications extends BaseController if ($request->is('post')) { $records = $request->getVar(); $params = (object) Null; - $this->logger->info("Whatsapp : sending message instance id = " . WAAI_INSTANCE); + + $this->logger->info("Whatsapp : sending message instance id = " . $_ENV['WAAI_INSTANCE'] ." - ". $_ENV['WAAI_TOKEN']); try { - $this->logger->info("Whatsapp : sending message instance id = " . WAAI_INSTANCE); if ($records['categories'] == 'SEND_WAAI_GROUP_URL') { if($records['group_id'] != ""){ $params->group_id = $records['group_id']; } else{ throw new \Exception("Group Id Missing Please Try again.."); } @@ -54,9 +54,10 @@ class Notifications extends BaseController $url = constant($records['categories']); $params->type = $records['type'] == "" ? "text" : $records['type']; - $params->instance_id = WAAI_INSTANCE; - $params->access_token = WAAI_TOKEN; + $params->instance_id = $_ENV['WAAI_INSTANCE']; + $params->access_token = $_ENV['WAAI_TOKEN']; $params->message = $records['description']; + $this->logger->info("Whatsapp : sending message request = " . json_encode($params)); $this->logger->info("Whatsapp : sending message request type b4 = " . gettype($params)); helper('notification'); $notification = new NotificationHelper(); diff --git a/app/Helpers/NotificationHelper.php b/app/Helpers/NotificationHelper.php index d995e9a2..d7c44d63 100644 --- a/app/Helpers/NotificationHelper.php +++ b/app/Helpers/NotificationHelper.php @@ -77,13 +77,15 @@ class NotificationHelper $this->logger->info('Helper : Whatsapp'); $curl = curl_init(); $headers = array('Content-Type:application/json'); + $jsonencoded = json_encode($data, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE); curl_setopt( $curl,CURLOPT_URL, $url); $this->logger->info('Helper : Whatsapp url = '.$url); switch ($method) { case "POST": curl_setopt( $curl,CURLOPT_POST, true ); if ($data) { - curl_setopt( $curl,CURLOPT_POSTFIELDS, json_encode($data)); + $this->logger->info('Helper : Whatsapp jsonencoded = '.$jsonencoded); + curl_setopt( $curl,CURLOPT_POSTFIELDS, $jsonencoded); } break; case "PUT": @@ -123,4 +125,4 @@ class NotificationHelper } } -?> \ No newline at end of file +?> diff --git a/app/Views/notifications_form.php b/app/Views/notifications_form.php index 064b4f04..ac20c904 100644 --- a/app/Views/notifications_form.php +++ b/app/Views/notifications_form.php @@ -146,7 +146,7 @@ -