Versión 2.8.2 Rutina de envio de mensajes con plantillas de utilidad refactorizado, además tipo de pago 'applied_to_payment' en en analisis de webhooks de Stripe
This commit is contained in:
parent
e34b3ec0f8
commit
e899945ca3
15
README.md
15
README.md
@ -2,6 +2,21 @@
|
|||||||
|
|
||||||
Este plugin sincroniza los clientes del sitema UISP CRM con los contactos de WhatsApp en CallBell, además procesa pagos de Stripe como las trasferencias bancarias y genera referencias de pago vía OXXO, además envía comprobantes de pago en formato imagen PNG o texto vía Whatsapp a los clientes
|
Este plugin sincroniza los clientes del sitema UISP CRM con los contactos de WhatsApp en CallBell, además procesa pagos de Stripe como las trasferencias bancarias y genera referencias de pago vía OXXO, además envía comprobantes de pago en formato imagen PNG o texto vía Whatsapp a los clientes
|
||||||
|
|
||||||
|
## REGISTRO DE CAMBIOS
|
||||||
|
|
||||||
|
# VERSIÓN 2.8.2
|
||||||
|
|
||||||
|
## 🟡 Bugs Resueltos
|
||||||
|
* 1️⃣ No se enviaban las notificaciones de las tareas al instalador. Se cambió la plantilla de CallBell o WhatsApp con 3 variables en lugar de 8
|
||||||
|
* 2️⃣ Se agregó un nuevo tipo de pago ("applied_to_payment") en las propiedades de los Webhooks recibidos mediante Stripe por concepto de transferencias bancarias. Ya que sólo se revisaba el tipo de pago "funded" y eso hacía que no enviara los comprobantes de pago a los clientes para todos los casos.
|
||||||
|
|
||||||
|
## REGISTRO DE CAMBIOS
|
||||||
|
# VERSIÓN 2.8.1
|
||||||
|
|
||||||
|
## 🟡 Bugs Resueltos
|
||||||
|
* 1️⃣ No se enviaban las notificaciones de las tareas al instalador.
|
||||||
|
|
||||||
|
|
||||||
# VERSIÓN 2.8.0
|
# VERSIÓN 2.8.0
|
||||||
|
|
||||||
## 🟢 Novedades
|
## 🟢 Novedades
|
||||||
|
|||||||
1634
data/plugin.log
1634
data/plugin.log
File diff suppressed because it is too large
Load Diff
@ -5,7 +5,7 @@
|
|||||||
"displayName": "SIIP - Procesador de Pagos en línea con Stripe, Oxxo y Transferencia, Sincronizador de CallBell y Envío de Notificaciones y comprobantes vía WhatsApp",
|
"displayName": "SIIP - Procesador de Pagos en línea con Stripe, Oxxo y Transferencia, Sincronizador de CallBell y Envío de Notificaciones y comprobantes vía WhatsApp",
|
||||||
"description": "Este plugin sincroniza los clientes del sistema UISP CRM con los contactos de WhatsApp en CallBell, además procesa pagos de Stripe como las trasferencias bancarias y genera referencias de pago vía OXXO, además envía comprobantes de pago en formato imagen PNG o texto vía Whatsapp a los clientes",
|
"description": "Este plugin sincroniza los clientes del sistema UISP CRM con los contactos de WhatsApp en CallBell, además procesa pagos de Stripe como las trasferencias bancarias y genera referencias de pago vía OXXO, además envía comprobantes de pago en formato imagen PNG o texto vía Whatsapp a los clientes",
|
||||||
"url": "https://siip.mx/",
|
"url": "https://siip.mx/",
|
||||||
"version": "2.8.0",
|
"version": "2.8.2",
|
||||||
"unmsVersionCompliancy": {
|
"unmsVersionCompliancy": {
|
||||||
"min": "2.1.0",
|
"min": "2.1.0",
|
||||||
"max": null
|
"max": null
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare (strict_types = 1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace SmsNotifier\Facade;
|
namespace SmsNotifier\Facade;
|
||||||
|
|
||||||
@ -251,19 +251,64 @@ abstract class AbstractMessageNotifierFacade
|
|||||||
// Crear un objeto DateTime a partir de la fecha
|
// Crear un objeto DateTime a partir de la fecha
|
||||||
$date = new DateTime($dateString);
|
$date = new DateTime($dateString);
|
||||||
|
|
||||||
|
|
||||||
|
// concaternar emoji de reloj de la hora que más se asemeje a la hora del evento, por ejemplo si la hora es 8:00 am o pm se concatena el emoji de reloj de las 8:00 am o pm como: 🕗
|
||||||
|
$hour = $date->format('h');
|
||||||
|
$clockEmoji = "🕐"; // Emoji por defecto
|
||||||
|
// Determinar el emoji del reloj según la hora
|
||||||
|
switch ($hour) {
|
||||||
|
case '01':
|
||||||
|
$clockEmoji = "🕐";
|
||||||
|
break;
|
||||||
|
case '02':
|
||||||
|
$clockEmoji = "🕑";
|
||||||
|
break;
|
||||||
|
case '03':
|
||||||
|
$clockEmoji = "🕒";
|
||||||
|
break;
|
||||||
|
case '04':
|
||||||
|
$clockEmoji = "🕓";
|
||||||
|
break;
|
||||||
|
case '05':
|
||||||
|
$clockEmoji = "🕔";
|
||||||
|
break;
|
||||||
|
case '06':
|
||||||
|
$clockEmoji = "🕕";
|
||||||
|
break;
|
||||||
|
case '07':
|
||||||
|
$clockEmoji = "🕖";
|
||||||
|
break;
|
||||||
|
case '08':
|
||||||
|
$clockEmoji = "🕗";
|
||||||
|
break;
|
||||||
|
case '09':
|
||||||
|
$clockEmoji = "🕘";
|
||||||
|
break;
|
||||||
|
case '10':
|
||||||
|
$clockEmoji = "🕙";
|
||||||
|
break;
|
||||||
|
case '11':
|
||||||
|
$clockEmoji = "🕚";
|
||||||
|
break;
|
||||||
|
case '12':
|
||||||
|
$clockEmoji = "🕛";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Formatear la fecha al formato deseado: día/mes/año a las hora:minuto am/pm aproximadamente
|
// Formatear la fecha al formato deseado: día/mes/año a las hora:minuto am/pm aproximadamente
|
||||||
$formattedDate = "*" . $date->format('d/m/Y') . "* a las *" . $date->format('h:i A') . "* aproximadamente";
|
$formattedDate = "*" . $date->format('d/m/Y') . "* a las $clockEmoji *" . $date->format('h:i A') . "* aproximadamente";
|
||||||
|
|
||||||
|
|
||||||
// $this->logger->debug('Valor de $formattedDate en verifyJobActionToDo: ' . $formattedDate . PHP_EOL);
|
// $this->logger->debug('Valor de $formattedDate en verifyJobActionToDo: ' . $formattedDate . PHP_EOL);
|
||||||
} else {
|
} else {
|
||||||
$this->logger->error('La fecha no está disponible en el JSON' . PHP_EOL);
|
$this->logger->error('La fecha no está disponible en el JSON' . PHP_EOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// $this->logger->debug('Valor de $installersData en verifyJobActionToDo: ' . $installersData . PHP_EOL);
|
$this->logger->debug('Valor de $installersData en verifyJobActionToDo: ' . $installersData . PHP_EOL);
|
||||||
|
|
||||||
$this->ucrmApi = UcrmApi::create();
|
$this->ucrmApi = UcrmApi::create();
|
||||||
$usersInstallers = $this->ucrmApi->get('users/admins/' . $installerId, []);
|
$usersInstallers = $this->ucrmApi->get('users/admins/' . $installerId, []);
|
||||||
// $this->logger->debug('Valor de $usersInstallers en verifyJobActionToDo: ' . json_encode($usersInstallers) . PHP_EOL);
|
$this->logger->debug('Valor de $usersInstallers en verifyJobActionToDo: ' . json_encode($usersInstallers) . PHP_EOL);
|
||||||
|
|
||||||
// Inicializar la variable para el nombre completo
|
// Inicializar la variable para el nombre completo
|
||||||
$installerFullName = '';
|
$installerFullName = '';
|
||||||
@ -276,7 +321,7 @@ abstract class AbstractMessageNotifierFacade
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Verificar si el nodo "instaladores" existe
|
// Verificar si el nodo "instaladores" existe
|
||||||
if (! isset($jsonInstallersData['instaladores'])) {
|
if (!isset($jsonInstallersData['instaladores'])) {
|
||||||
$this->logger->error('El nodo "instaladores" no existe en el JSON');
|
$this->logger->error('El nodo "instaladores" no existe en el JSON');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -295,7 +340,7 @@ abstract class AbstractMessageNotifierFacade
|
|||||||
if (empty($installerWhatsApp)) {
|
if (empty($installerWhatsApp)) {
|
||||||
$this->logger->warning('No se encontró un número de WhatsApp para el instalador con ID 1019');
|
$this->logger->warning('No se encontró un número de WhatsApp para el instalador con ID 1019');
|
||||||
} else {
|
} else {
|
||||||
// $this->logger->debug('Número de WhatsApp del Instalador: ' . $installerWhatsApp . PHP_EOL);
|
$this->logger->debug('Número de WhatsApp del Instalador: ' . $installerWhatsApp . PHP_EOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->ucrmApi = UcrmApi::create();
|
$this->ucrmApi = UcrmApi::create();
|
||||||
@ -305,7 +350,7 @@ abstract class AbstractMessageNotifierFacade
|
|||||||
$firstName = $usersInstallers['firstName'] ?? '';
|
$firstName = $usersInstallers['firstName'] ?? '';
|
||||||
$lastName = $usersInstallers['lastName'] ?? '';
|
$lastName = $usersInstallers['lastName'] ?? '';
|
||||||
$installerFullName = trim("$firstName $lastName");
|
$installerFullName = trim("$firstName $lastName");
|
||||||
// $this->logger->debug('Valor de $installerFullName: ' . $installerFullName . PHP_EOL);
|
$this->logger->debug('Valor de $installerFullName: ' . $installerFullName . PHP_EOL);
|
||||||
|
|
||||||
$baseUri = 'https://' . $IPServer . '/crm/api/v1.0/';
|
$baseUri = 'https://' . $IPServer . '/crm/api/v1.0/';
|
||||||
|
|
||||||
@ -356,11 +401,11 @@ abstract class AbstractMessageNotifierFacade
|
|||||||
|
|
||||||
// Convertir el array de teléfonos en una cadena separada por comas
|
// Convertir el array de teléfonos en una cadena separada por comas
|
||||||
$clientAllPhonesString = implode(',', $arrayAllPhones);
|
$clientAllPhonesString = implode(',', $arrayAllPhones);
|
||||||
// $this->logger->debug('Valor de $clientAllPhonesString en verifyJobActionToDo: ' . $clientAllPhonesString . PHP_EOL);
|
$this->logger->debug('Valor de $clientAllPhonesString en verifyJobActionToDo: ' . $clientAllPhonesString . PHP_EOL);
|
||||||
|
|
||||||
// Dividir los números en un array
|
// Dividir los números en un array
|
||||||
$arrayNumeros = explode(',', $clientAllPhonesString);
|
$arrayNumeros = explode(',', $clientAllPhonesString);
|
||||||
// $this->logger->debug('Valor de $arrayNumeros en verifyJobActionToDo: ' . json_encode($arrayNumeros) . PHP_EOL);
|
$this->logger->debug('Valor de $arrayNumeros en verifyJobActionToDo: ' . json_encode($arrayNumeros) . PHP_EOL);
|
||||||
|
|
||||||
// Procesar cada número
|
// Procesar cada número
|
||||||
$resultados = [];
|
$resultados = [];
|
||||||
@ -378,7 +423,7 @@ abstract class AbstractMessageNotifierFacade
|
|||||||
$resultados[] = $numeroValidado; // Mantener el número sin cambios
|
$resultados[] = $numeroValidado; // Mantener el número sin cambios
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// $this->logger->debug('Valor de $resultados en verifyJobActionToDo: ' . json_encode($resultados) . PHP_EOL);
|
$this->logger->debug('Valor de $resultados en verifyJobActionToDo: ' . json_encode($resultados) . PHP_EOL);
|
||||||
|
|
||||||
// Convertir el array de resultados en una cadena separada por comas
|
// Convertir el array de resultados en una cadena separada por comas
|
||||||
$resultadoFinalNumerosCliente = implode(', ', $resultados);
|
$resultadoFinalNumerosCliente = implode(', ', $resultados);
|
||||||
@ -524,8 +569,8 @@ abstract class AbstractMessageNotifierFacade
|
|||||||
$result = $client_callbell_api->sendJobNotificationWhatsAppToInstaller(
|
$result = $client_callbell_api->sendJobNotificationWhatsAppToInstaller(
|
||||||
$this->validarNumeroTelefono((string) $previousInstallerWhatsApp),
|
$this->validarNumeroTelefono((string) $previousInstallerWhatsApp),
|
||||||
$jsonPreviousInstallerJobNotificationData,
|
$jsonPreviousInstallerJobNotificationData,
|
||||||
false,
|
$reprogramming,
|
||||||
true,
|
$changeInstaller,
|
||||||
''
|
''
|
||||||
|
|
||||||
);
|
);
|
||||||
@ -599,8 +644,8 @@ abstract class AbstractMessageNotifierFacade
|
|||||||
$result = $client_callbell_api->sendJobNotificationWhatsAppToInstaller(
|
$result = $client_callbell_api->sendJobNotificationWhatsAppToInstaller(
|
||||||
$this->validarNumeroTelefono((string) $installerWhatsApp),
|
$this->validarNumeroTelefono((string) $installerWhatsApp),
|
||||||
$jsonInstallerJobNotificationData,
|
$jsonInstallerJobNotificationData,
|
||||||
false,
|
$reprogramming,
|
||||||
false,
|
$changeInstaller,
|
||||||
$this->getVaultCredentials($arrayClientCRM['id'])
|
$this->getVaultCredentials($arrayClientCRM['id'])
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -699,11 +744,11 @@ abstract class AbstractMessageNotifierFacade
|
|||||||
$maxAttempts = 3;
|
$maxAttempts = 3;
|
||||||
$result = false;
|
$result = false;
|
||||||
|
|
||||||
while ($attempts < $maxAttempts && ! $result) {
|
while ($attempts < $maxAttempts && !$result) {
|
||||||
$attempts++;
|
$attempts++;
|
||||||
$result = $client_callbell_api->sendTextPaymentNotificationWhatsApp($clientPhoneNumber, $notificationData);
|
$result = $client_callbell_api->sendTextPaymentNotificationWhatsApp($clientPhoneNumber, $notificationData);
|
||||||
|
|
||||||
if (! $result) {
|
if (!$result) {
|
||||||
$this->logger->warning("Intento $attempts fallido para enviar notificación de texto al cliente con número $clientPhoneNumber." . PHP_EOL);
|
$this->logger->warning("Intento $attempts fallido para enviar notificación de texto al cliente con número $clientPhoneNumber." . PHP_EOL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -723,11 +768,11 @@ abstract class AbstractMessageNotifierFacade
|
|||||||
$maxAttempts = 3;
|
$maxAttempts = 3;
|
||||||
$result = false;
|
$result = false;
|
||||||
|
|
||||||
while ($attempts < $maxAttempts && ! $result) {
|
while ($attempts < $maxAttempts && !$result) {
|
||||||
$attempts++;
|
$attempts++;
|
||||||
$result = $client_callbell_api->sendPaymentNotificationWhatsApp($clientPhoneNumber, $notificationData);
|
$result = $client_callbell_api->sendPaymentNotificationWhatsApp($clientPhoneNumber, $notificationData);
|
||||||
|
|
||||||
if (! $result) {
|
if (!$result) {
|
||||||
$this->logger->warning("Intento $attempts fallido para enviar notificación al cliente con número $clientPhoneNumber." . PHP_EOL);
|
$this->logger->warning("Intento $attempts fallido para enviar notificación al cliente con número $clientPhoneNumber." . PHP_EOL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1159,7 +1204,7 @@ abstract class AbstractMessageNotifierFacade
|
|||||||
if (filter_var($dataToSearch, FILTER_VALIDATE_IP)) {
|
if (filter_var($dataToSearch, FILTER_VALIDATE_IP)) {
|
||||||
// La variable es una dirección IP válida
|
// La variable es una dirección IP válida
|
||||||
// $logger->appendLog('Consulta por dirección IP: ' . $dataToSearch);
|
// $logger->appendLog('Consulta por dirección IP: ' . $dataToSearch);
|
||||||
print('Consulta por dirección IP: ' . $dataToSearch . PHP_EOL);
|
print ('Consulta por dirección IP: ' . $dataToSearch . PHP_EOL);
|
||||||
|
|
||||||
$IpAddressClientId = filter_var($dataToSearch, FILTER_VALIDATE_IP);
|
$IpAddressClientId = filter_var($dataToSearch, FILTER_VALIDATE_IP);
|
||||||
|
|
||||||
@ -1287,7 +1332,7 @@ abstract class AbstractMessageNotifierFacade
|
|||||||
} else if (preg_match('/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/', $dataToSearch)) {
|
} else if (preg_match('/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/', $dataToSearch)) {
|
||||||
// La variable es una dirección MAC válida
|
// La variable es una dirección MAC válida
|
||||||
// $logger->appendLog('Consulta por dirección MAC: ' . $dataToSearch);
|
// $logger->appendLog('Consulta por dirección MAC: ' . $dataToSearch);
|
||||||
print('Consulta por dirección MAC: ' . $dataToSearch . PHP_EOL);
|
print ('Consulta por dirección MAC: ' . $dataToSearch . PHP_EOL);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// //para mandarla al endpoint de dispositivos por MAC se necesita convertir la cadena de la direccion mac en un formato como el siguiente ejemplo: para la dirección mac 60:22:32:c8:b2:c3 quedaría como 60%3A22%3A32%3Ac8%3Ab2%3Ac3
|
// //para mandarla al endpoint de dispositivos por MAC se necesita convertir la cadena de la direccion mac en un formato como el siguiente ejemplo: para la dirección mac 60:22:32:c8:b2:c3 quedaría como 60%3A22%3A32%3Ac8%3Ab2%3Ac3
|
||||||
|
|||||||
@ -63,7 +63,8 @@ class ClientCallBellAPI
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function updateContact($client_uuid)
|
public function updateContact($client_uuid)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public function printPrueba($clientWhatsAppNumber, $notificationData)
|
public function printPrueba($clientWhatsAppNumber, $notificationData)
|
||||||
{
|
{
|
||||||
@ -134,33 +135,48 @@ class ClientCallBellAPI
|
|||||||
'Content-Type: application/json',
|
'Content-Type: application/json',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$campo1 = sprintf(' *%s*', $jobNotificationData['clientFullName']);
|
$campo1 = '👤 ' . sprintf(' *%s*', $jobNotificationData['clientFullName']);
|
||||||
$campo2 = sprintf('*#%s*', $jobNotificationData['jobId']);
|
if ($changeInstaller && !$reprogramming) {
|
||||||
$campo3 = sprintf('%s', $jobNotificationData['date']);
|
$campo2 = sprintf('se ha hecho un cambio de técnico 👷🏻♂️🔄 para su visita con el folio *#️⃣%s*', $jobNotificationData['jobId']);
|
||||||
$campo4 = sprintf('*%s*', $jobNotificationData['installerName']);
|
} else {
|
||||||
|
$campo2 = sprintf('*#️⃣%s*', $jobNotificationData['jobId']);
|
||||||
|
}
|
||||||
|
$campo3 = '🗓️ ' . sprintf('%s', $jobNotificationData['date']);
|
||||||
|
if ($changeInstaller && $reprogramming) {
|
||||||
|
$campo4 = 'Además se ha hecho un cambio de técnico por el siguiente 👷🏻♂️➡️ ' . sprintf('*%s*', $jobNotificationData['installerName']);
|
||||||
|
} else {
|
||||||
|
$campo4 = '👷🏻♂️➡️ ' . sprintf('*%s*', $jobNotificationData['installerName']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$campo5 = "asegúrese de que alguien esté presente en el domicilio 🏠 para permitir el acceso y confirme su disponibilidad.";
|
||||||
|
|
||||||
$log->appendLog("DEBUG: Valores antes de la estructura IF - Reprogramming: " . var_export($reprogramming, true) . ", ChangeInstaller: " . var_export($changeInstaller, true) . PHP_EOL);
|
$log->appendLog("DEBUG: Valores antes de la estructura IF - Reprogramming: " . var_export($reprogramming, true) . ", ChangeInstaller: " . var_export($changeInstaller, true) . PHP_EOL);
|
||||||
|
|
||||||
if ($reprogramming && ! $changeInstaller) {
|
if ($reprogramming && !$changeInstaller) {
|
||||||
|
//{{1}}, se ha reprogramado su visita técnica con el folio {{2}}
|
||||||
|
|
||||||
|
$campo3 = '🗓️➡️ ' . sprintf('%s', $jobNotificationData['date']);
|
||||||
|
$campo1_combinado = "Estimado cliente $campo1 se ha reprogramado su visita técnica con folio $campo2";
|
||||||
|
|
||||||
// Case: true, false
|
// Case: true, false
|
||||||
//Enviar notificación de reprogramación al cliente
|
//Enviar notificación de reprogramación al cliente
|
||||||
$log->appendLog("Enviando notificación de reprogramación al cliente, valor de reprogramming $reprogramming y valor de changeInstaller $changeInstaller " . PHP_EOL);
|
$log->appendLog("Enviando notificación de reprogramación al cliente, valor de reprogramming $reprogramming y valor de changeInstaller $changeInstaller " . PHP_EOL);
|
||||||
$curl_string = "{\n \"to\": \"$clientWhatsAppNumber\",\n \"from\": \"whatsapp\",\n \"type\": \"text\",\n \"content\": {\n \"text\": \"S/M\"\n },\n \"template_values\": [\"$campo1\", \"$campo2\", \"$campo3\", \"$campo4\"],\n \"template_uuid\": \"323631bf578e43fb8a0095f55978aae8\",\n \"optin_contact\": true\n }";
|
$curl_string = "{\n \"to\": \"$clientWhatsAppNumber\",\n \"from\": \"whatsapp\",\n \"type\": \"text\",\n \"content\": {\n \"text\": \"S/M\"\n },\n \"template_values\": [\"$campo1_combinado\", \"$campo3\", \"$campo4\", \"$campo5\"],\n \"template_uuid\": \"715eed9d6f2d4d90853f25e296202e00\",\n \"optin_contact\": true\n }";
|
||||||
} else if (! $reprogramming && $changeInstaller) {
|
} else if (!$reprogramming && $changeInstaller) {
|
||||||
// Case: false, true
|
// Case: false, true
|
||||||
//Enviar notificación de cambio de instalador
|
//Enviar notificación de cambio de instalador
|
||||||
$log->appendLog("Enviando notificación de cambio de instalador al cliente, valor de reprogramming $reprogramming y valor de changeInstaller $changeInstaller " . PHP_EOL);
|
$log->appendLog("Enviando notificación de cambio de instalador al cliente, valor de reprogramming $reprogramming y valor de changeInstaller $changeInstaller " . PHP_EOL);
|
||||||
$curl_string = "{\n \"to\": \"$clientWhatsAppNumber\",\n \"from\": \"whatsapp\",\n \"type\": \"text\",\n \"content\": {\n \"text\": \"S/M\"\n },\n \"template_values\": [\"$campo1\", \"$campo2\", \"$campo3\", \"$campo4\"],\n \"template_uuid\": \"c59c3ce2c9c6439b941b0d42d1435605\",\n \"optin_contact\": true\n }";
|
$curl_string = "{\n \"to\": \"$clientWhatsAppNumber\",\n \"from\": \"whatsapp\",\n \"type\": \"text\",\n \"content\": {\n \"text\": \"S/M\"\n },\n \"template_values\": [\"$campo1\", \"$campo2\", \"$campo3\", \"$campo4\", \"$campo5\"],\n \"template_uuid\": \"d684e6fa2ba24593a86c98be1815831d\",\n \"optin_contact\": true\n }";
|
||||||
} else if (! $reprogramming && ! $changeInstaller) { // <--- Ahora este else if está correctamente encadenado
|
} else if (!$reprogramming && !$changeInstaller) { // <--- Ahora este else if está correctamente encadenado
|
||||||
// Case: false, false
|
// Case: false, false
|
||||||
//Enviar notificación normal de visita técnica al cliente
|
//Enviar notificación normal de visita técnica al cliente
|
||||||
$log->appendLog("Enviando notificación normal de visita técnica al cliente, valor de reprogramming $reprogramming y valor de changeInstaller $changeInstaller " . PHP_EOL);
|
$log->appendLog("Enviando notificación normal de visita técnica al cliente, valor de reprogramming $reprogramming y valor de changeInstaller $changeInstaller " . PHP_EOL);
|
||||||
$curl_string = "{\n \"to\": \"$clientWhatsAppNumber\",\n \"from\": \"whatsapp\",\n \"type\": \"text\",\n \"content\": {\n \"text\": \"S/M\"\n },\n \"template_values\": [\"$campo1\", \"$campo2\", \"$campo3\", \"$campo4\"],\n \"template_uuid\": \"c0ef8228b50a4d9690a2e87bc11e9ab3\",\n \"optin_contact\": true\n }";
|
$curl_string = "{\n \"to\": \"$clientWhatsAppNumber\",\n \"from\": \"whatsapp\",\n \"type\": \"text\",\n \"content\": {\n \"text\": \"S/M\"\n },\n \"template_values\": [\"$campo1\", \"$campo2\", \"$campo3\", \"$campo4\", \"$campo5\"],\n \"template_uuid\": \"07cfbc6e394044608485b530a27177d0\",\n \"optin_contact\": true\n }";
|
||||||
}else if ($reprogramming && $changeInstaller) { // <--- Ahora este else if está correctamente encadenado
|
} else if ($reprogramming && $changeInstaller) { // <--- Ahora este else if está correctamente encadenado
|
||||||
// Case: true, true
|
// Case: true, true
|
||||||
//Enviar notificación de cambio de instalador y reprogramación al cliente
|
//Enviar notificación de cambio de instalador y reprogramación al cliente
|
||||||
$log->appendLog("Enviando notificación de cambio de instalador y reprogramación al cliente, valor de reprogramming $reprogramming y valor de changeInstaller $changeInstaller " . PHP_EOL);
|
$log->appendLog("Enviando notificación de cambio de instalador y reprogramación al cliente, valor de reprogramming $reprogramming y valor de changeInstaller $changeInstaller " . PHP_EOL);
|
||||||
$curl_string = "{\n \"to\": \"$clientWhatsAppNumber\",\n \"from\": \"whatsapp\",\n \"type\": \"text\",\n \"content\": {\n \"text\": \"S/M\"\n },\n \"template_values\": [\"$campo1\", \"$campo2\", \"$campo3\", \"$campo4\"],\n \"template_uuid\": \"99e2629a3be2421687037c001222bfe4\",\n \"optin_contact\": true\n }";
|
$curl_string = "{\n \"to\": \"$clientWhatsAppNumber\",\n \"from\": \"whatsapp\",\n \"type\": \"text\",\n \"content\": {\n \"text\": \"S/M\"\n },\n \"template_values\": [\"$campo1\", \"$campo2\", \"$campo3\", \"$campo4\", \"$campo5\"],\n \"template_uuid\": \"145885d15323414f978f1e3f249c2ae1\",\n \"optin_contact\": true\n }";
|
||||||
} else {
|
} else {
|
||||||
// Case: true, true (la única combinación restante con booleanos)
|
// Case: true, true (la única combinación restante con booleanos)
|
||||||
$log->appendLog("No se encontró una opción válida para enviar la notificación (reprogramming y changeInstaller son true)." . PHP_EOL);
|
$log->appendLog("No se encontró una opción válida para enviar la notificación (reprogramming y changeInstaller son true)." . PHP_EOL);
|
||||||
@ -227,39 +243,60 @@ class ClientCallBellAPI
|
|||||||
'Content-Type: application/json',
|
'Content-Type: application/json',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$campo1 = $jobInstallerNotificationData['installerName'];
|
$campo1 = '👷🏻♂️ ' . $jobInstallerNotificationData['installerName'];
|
||||||
if ($changeInstaller) {
|
if (!$reprogramming && $changeInstaller) {
|
||||||
$campo2 = $jobInstallerNotificationData['subjectOfChange'];
|
$campo2 = $jobInstallerNotificationData['subjectOfChange'];
|
||||||
$campo3 = sprintf("#%s", $jobInstallerNotificationData['jobId']);
|
$campo3 = sprintf("#️⃣%s", $jobInstallerNotificationData['jobId']);
|
||||||
$campo4 = $jobInstallerNotificationData['clientFullName'];
|
$campo4 = '👤 *Cliente:* ' . $jobInstallerNotificationData['clientFullName'];
|
||||||
$campo5 = $jobInstallerNotificationData['additionalChangeData'];
|
$campo5 = $jobInstallerNotificationData['additionalChangeData'];
|
||||||
} else {
|
} else {
|
||||||
$campo2 = sprintf("#%s", $jobInstallerNotificationData['jobId']);
|
$campo2 = sprintf("#️⃣%s", $jobInstallerNotificationData['jobId']);
|
||||||
$campo3 = $jobInstallerNotificationData['clientFullName'];
|
$campo3 = '👤 *' . $jobInstallerNotificationData['clientFullName'] . '*';
|
||||||
// $campo4 = $jobInstallerNotificationData['clientAddress'];
|
// $campo4 = $jobInstallerNotificationData['clientAddress'];
|
||||||
$campo4 = $jobInstallerNotificationData['clientWhatsApp'];
|
$campo4 = '☎️ ' . $jobInstallerNotificationData['clientWhatsApp'];
|
||||||
$campo5 = $jobInstallerNotificationData['date'];
|
$campo5 = '🗓️ ' . $jobInstallerNotificationData['date'];
|
||||||
$campo6 = $jobInstallerNotificationData['jobDescription'];
|
$campo6 = '🛠️ ' . $jobInstallerNotificationData['jobDescription'];
|
||||||
$campo7 = $jobInstallerNotificationData['gmapsLocation'];
|
$campo7 = '📌 ' . $jobInstallerNotificationData['gmapsLocation'];
|
||||||
$campo8 = $passwordAntenaCliente;
|
$campo8 = '🔐 ' . $passwordAntenaCliente;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($reprogramming && ! $changeInstaller) {
|
if ($reprogramming && !$changeInstaller) {
|
||||||
|
$jobId = sprintf("#️⃣ *%s*", $jobInstallerNotificationData['jobId']);
|
||||||
|
$clientFullName = sprintf("👤 *%s*", $jobInstallerNotificationData['clientFullName']);
|
||||||
|
$date = sprintf("🗓️➡️ %s", $jobInstallerNotificationData['date']);
|
||||||
|
$installerName = sprintf("👷🏻♂️ *%s*", $jobInstallerNotificationData['installerName']);
|
||||||
|
|
||||||
|
$campo1_combinado = "$installerName se reprogramó una tarea con el folio $jobId para el cliente $clientFullName, la nueva fecha será el $date";
|
||||||
|
$campo2 = $jobInstallerNotificationData['clientWhatsApp'];
|
||||||
|
$campo3 = $jobInstallerNotificationData['gmapsLocation'];
|
||||||
|
$campo4 = $passwordAntenaCliente;
|
||||||
|
|
||||||
//Enviar notificación de reprogramación
|
//Enviar notificación de reprogramación
|
||||||
$log->appendLog("Enviando notificación de reprogramación al instalador, valor de reprogramming $reprogramming y valor de changeInstaller $changeInstaller " . PHP_EOL);
|
$log->appendLog("Enviando notificación de reprogramación al instalador, valor de reprogramming $reprogramming y valor de changeInstaller $changeInstaller " . PHP_EOL);
|
||||||
$curl_string = "{\n \"to\": \"$installerWhatsAppNumber\",\n \"from\": \"whatsapp\",\n \"type\": \"text\",\n \"content\": {\n \"text\": \"S/M\"\n },\n \"template_values\": [\"$campo1\", \"$campo2\", \"$campo3\", \"$campo4\", \"$campo5\", \"$campo6\", \"$campo7\", \"$campo8\"],\n \"template_uuid\": \"7eb4d8e27cf740779dd6777fad7ffaf4\",\n \"optin_contact\": true\n }";
|
$curl_string = "{\n \"to\": \"$installerWhatsAppNumber\",\n \"from\": \"whatsapp\",\n \"type\": \"text\",\n \"content\": {\n \"text\": \"S/M\"\n },\n \"template_values\": [\"$campo1_combinado\", \"$campo2\", \"$campo3\", \"$campo4\"],\n \"template_uuid\": \"88eeb6420a214fd8870dd28d741021c4\",\n \"optin_contact\": true\n }";
|
||||||
} else if (! $reprogramming && $changeInstaller) {
|
} else if (!$reprogramming && $changeInstaller) {
|
||||||
//Enviar notificación de cambio de instalador
|
//Enviar notificación de cambio de instalador
|
||||||
$log->appendLog("Enviando notificación de cambio de instalador al instalador anterior, valor de reprogramming $reprogramming y valor de changeInstaller $changeInstaller " . PHP_EOL);
|
$log->appendLog("Enviando notificación de cambio de instalador al instalador anterior, valor de reprogramming $reprogramming y valor de changeInstaller $changeInstaller " . PHP_EOL);
|
||||||
$curl_string = "{\n \"to\": \"$installerWhatsAppNumber\",\n \"from\": \"whatsapp\",\n \"type\": \"text\",\n \"content\": {\n \"text\": \"S/M\"\n },\n \"template_values\": [\"$campo1\", \"$campo2\", \"$campo3\", \"$campo4\", \"$campo5\"],\n \"template_uuid\": \"e1aa2b0fd3884595918f4ac2676acd29\",\n \"optin_contact\": true\n }";
|
$curl_string = "{\n \"to\": \"$installerWhatsAppNumber\",\n \"from\": \"whatsapp\",\n \"type\": \"text\",\n \"content\": {\n \"text\": \"S/M\"\n },\n \"template_values\": [\"$campo1\", \"$campo2\", \"$campo3\", \"$campo4\", \"$campo5\"],\n \"template_uuid\": \"e1aa2b0fd3884595918f4ac2676acd29\",\n \"optin_contact\": true\n }";
|
||||||
}else if ($reprogramming && $changeInstaller) {
|
} else if ($reprogramming && $changeInstaller) {
|
||||||
//Enviar notificación de cambio de instalador
|
//Enviar notificación de cambio de instalador
|
||||||
$log->appendLog("Enviando notificación de cambio de instalador al instalador y notificación de reprogramación al instalador, valor de reprogramming $reprogramming y valor de changeInstaller $changeInstaller " . PHP_EOL);
|
$log->appendLog("Enviando notificación de cambio de instalador al instalador y notificación de reprogramación al instalador, valor de reprogramming $reprogramming y valor de changeInstaller $changeInstaller " . PHP_EOL);
|
||||||
$curl_string = "{\n \"to\": \"$installerWhatsAppNumber\",\n \"from\": \"whatsapp\",\n \"type\": \"text\",\n \"content\": {\n \"text\": \"S/M\"\n },\n \"template_values\": [\"$campo1\", \"$campo2\", \"$campo3\", \"$campo4\", \"$campo5\"],\n \"template_uuid\": \"e1aa2b0fd3884595918f4ac2676acd29\",\n \"optin_contact\": true\n }";
|
$curl_string = "{\n \"to\": \"$installerWhatsAppNumber\",\n \"from\": \"whatsapp\",\n \"type\": \"text\",\n \"content\": {\n \"text\": \"S/M\"\n },\n \"template_values\": [\"$campo1\", \"$campo2\", \"$campo3\", \"$campo4\", \"$campo5\"],\n \"template_uuid\": \"e1aa2b0fd3884595918f4ac2676acd29\",\n \"optin_contact\": true\n }";
|
||||||
} else if (! $reprogramming && ! $changeInstaller) {
|
} else if (!$reprogramming && !$changeInstaller) {
|
||||||
//Enviar notificación normal de asignación de tarea
|
|
||||||
$log->appendLog("Enviando notificación normal de asignación de tarea al instalador, valor de reprogramming $reprogramming y valor de changeInstaller $changeInstaller " . PHP_EOL);
|
//combinar el campo3, campo4, campo5, campo6, campo7 y campo8 en un solo campo con saltos de línea
|
||||||
$curl_string = "{\n \"to\": \"$installerWhatsAppNumber\",\n \"from\": \"whatsapp\",\n \"type\": \"text\",\n \"content\": {\n \"text\": \"S/M\"\n },\n \"template_values\": [\"$campo1\", \"$campo2\", \"$campo3\", \"$campo4\", \"$campo5\", \"$campo6\", \"$campo7\", \"$campo8\"],\n \"template_uuid\": \"670bedde35b3416f8c1a27f995ebe350\",\n \"optin_contact\": true\n }";
|
$jobId = sprintf("#️⃣ *%s*", $jobInstallerNotificationData['jobId']);
|
||||||
|
$clientFullName = sprintf("👤 *%s*", $jobInstallerNotificationData['clientFullName']);
|
||||||
|
$date = sprintf("🗓️ %s", $jobInstallerNotificationData['date']);
|
||||||
|
$installerName = sprintf("👷🏻♂️ *%s*", $jobInstallerNotificationData['installerName']);
|
||||||
|
|
||||||
|
$campo1_combinado = "$installerName se te ha asignado una tarea con folio $jobId para el cliente $clientFullName, para el $date";
|
||||||
|
$campo2 = $jobInstallerNotificationData['clientWhatsApp'];
|
||||||
|
$campo3 = $jobInstallerNotificationData['gmapsLocation'];
|
||||||
|
$campo4 = $passwordAntenaCliente;
|
||||||
|
|
||||||
|
$log->appendLog("Enviando notificación normal de tarea al instalador, valor de reprogramming $reprogramming y valor de changeInstaller $changeInstaller " . PHP_EOL);
|
||||||
|
$curl_string = "{\n \"to\": \"$installerWhatsAppNumber\",\n \"from\": \"whatsapp\",\n \"type\": \"text\",\n \"content\": {\n \"text\": \"S/M\"\n },\n \"template_values\": [\"$campo1_combinado\", \"$campo2\", \"$campo3\", \"$campo4\"],\n \"template_uuid\": \"88eeb6420a214fd8870dd28d741021c4\",\n \"optin_contact\": true\n }";
|
||||||
}
|
}
|
||||||
|
|
||||||
$log->appendLog("La cadena CURL que se envia es: " . $curl_string);
|
$log->appendLog("La cadena CURL que se envia es: " . $curl_string);
|
||||||
@ -369,7 +406,7 @@ class ClientCallBellAPI
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! file_exists($rutaArchivo)) {
|
if (!file_exists($rutaArchivo)) {
|
||||||
$log->appendLog("El archivo PDF no existe: $rutaArchivo" . PHP_EOL);
|
$log->appendLog("El archivo PDF no existe: $rutaArchivo" . PHP_EOL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -596,7 +633,7 @@ class ClientCallBellAPI
|
|||||||
|
|
||||||
$log->appendLog("payment covers" . json_encode($notificationData->paymentData['paymentCovers']) . PHP_EOL);
|
$log->appendLog("payment covers" . json_encode($notificationData->paymentData['paymentCovers']) . PHP_EOL);
|
||||||
|
|
||||||
if (! empty($notificationData->paymentData['paymentCovers'])) {
|
if (!empty($notificationData->paymentData['paymentCovers'])) {
|
||||||
$log->appendLog('Datos del payment covers:' . PHP_EOL);
|
$log->appendLog('Datos del payment covers:' . PHP_EOL);
|
||||||
|
|
||||||
$invoiceIds = ''; // Variable para almacenar los invoiceId
|
$invoiceIds = ''; // Variable para almacenar los invoiceId
|
||||||
@ -1272,7 +1309,7 @@ class ClientCallBellAPI
|
|||||||
$log = PluginLogManager::create(); //Initialize Logger
|
$log = PluginLogManager::create(); //Initialize Logger
|
||||||
$directory = __DIR__ . '/../../comprobantes/';
|
$directory = __DIR__ . '/../../comprobantes/';
|
||||||
// Verificar si el directorio existe
|
// Verificar si el directorio existe
|
||||||
if (! is_dir($directory)) {
|
if (!is_dir($directory)) {
|
||||||
$log->appendLog('El directorio no existe.');
|
$log->appendLog('El directorio no existe.');
|
||||||
die("El directorio no existe.");
|
die("El directorio no existe.");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -129,7 +129,7 @@ class Plugin
|
|||||||
switch ($jsonData['type']) {
|
switch ($jsonData['type']) {
|
||||||
case 'customer_cash_balance_transaction.created':
|
case 'customer_cash_balance_transaction.created':
|
||||||
$this->logger->info('Evento de transfencia al cliente encontrado: ' . json_encode($jsonData) . PHP_EOL);
|
$this->logger->info('Evento de transfencia al cliente encontrado: ' . json_encode($jsonData) . PHP_EOL);
|
||||||
if ($jsonData['data']['object']['type'] === 'funded') {
|
if ($jsonData['data']['object']['type'] === 'funded' || $jsonData['data']['object']['type'] === 'applied_to_payment') {
|
||||||
$this->pluginNotifierFacade->createPaymentIntent($jsonData);
|
$this->pluginNotifierFacade->createPaymentIntent($jsonData);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
4
vendor/composer/installed.php
vendored
4
vendor/composer/installed.php
vendored
@ -5,7 +5,7 @@
|
|||||||
'type' => 'library',
|
'type' => 'library',
|
||||||
'install_path' => __DIR__ . '/../../',
|
'install_path' => __DIR__ . '/../../',
|
||||||
'aliases' => array(),
|
'aliases' => array(),
|
||||||
'reference' => '7cb26fe7358fc5b3d7671f2db68235f6bb07ef3f',
|
'reference' => 'e34b3ec0f84e1274c6c6bbed67f8aacd933f0807',
|
||||||
'name' => 'ucrm-plugins/sms-twilio',
|
'name' => 'ucrm-plugins/sms-twilio',
|
||||||
'dev' => false,
|
'dev' => false,
|
||||||
),
|
),
|
||||||
@ -307,7 +307,7 @@
|
|||||||
'type' => 'library',
|
'type' => 'library',
|
||||||
'install_path' => __DIR__ . '/../../',
|
'install_path' => __DIR__ . '/../../',
|
||||||
'aliases' => array(),
|
'aliases' => array(),
|
||||||
'reference' => '7cb26fe7358fc5b3d7671f2db68235f6bb07ef3f',
|
'reference' => 'e34b3ec0f84e1274c6c6bbed67f8aacd933f0807',
|
||||||
'dev_requirement' => false,
|
'dev_requirement' => false,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user