Versión 2.6.9 con modificaciones para devolver mas campos en la respuesta a una creación de referencia de OXXO, como tal son los campos de oxxo_reference, error, failDescription, clientID, clientFullName, amount
This commit is contained in:
parent
2819804ad8
commit
59aac17968
1195
data/plugin.log
1195
data/plugin.log
File diff suppressed because one or more lines are too long
@ -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.6.8",
|
"version": "2.6.9",
|
||||||
"unmsVersionCompliancy": {
|
"unmsVersionCompliancy": {
|
||||||
"min": "2.1.0",
|
"min": "2.1.0",
|
||||||
"max": null
|
"max": null
|
||||||
|
|||||||
@ -55,11 +55,17 @@ abstract class AbstractOxxoOperationsFacade
|
|||||||
* Creates a PaymentIntent for OXXO in Stripe for a Customer
|
* Creates a PaymentIntent for OXXO in Stripe for a Customer
|
||||||
* @param array $event_json
|
* @param array $event_json
|
||||||
* @param int|null $amount
|
* @param int|null $amount
|
||||||
* @return string
|
* @return array
|
||||||
|
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||||
|
* @throws \Stripe\Exception\ApiErrorException
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function createOxxoPaymentIntent($event_json, $amount = null): string
|
public function createOxxoPaymentIntent($event_json, $amount = null): array
|
||||||
{
|
{
|
||||||
|
//declarar un array asociativo de strings pero no asignarle nada aun
|
||||||
|
$arrayOxxoPayment = array();
|
||||||
|
|
||||||
|
|
||||||
$this->logger->info("Creando referencia del cliente para OXXO: " . PHP_EOL);
|
$this->logger->info("Creando referencia del cliente para OXXO: " . PHP_EOL);
|
||||||
$configManager = \Ubnt\UcrmPluginSdk\Service\PluginConfigManager::create();
|
$configManager = \Ubnt\UcrmPluginSdk\Service\PluginConfigManager::create();
|
||||||
$config = $configManager->loadConfig();
|
$config = $configManager->loadConfig();
|
||||||
@ -88,13 +94,45 @@ abstract class AbstractOxxoOperationsFacade
|
|||||||
try {
|
try {
|
||||||
$response = $clientGuzzleHttp->request('GET', "clients/" . $clientID);
|
$response = $clientGuzzleHttp->request('GET', "clients/" . $clientID);
|
||||||
$arrayClientCRM = json_decode($response->getBody()->getContents(), true);
|
$arrayClientCRM = json_decode($response->getBody()->getContents(), true);
|
||||||
|
//$this->logger->info("Valor de arrayClientCRM: " . print_r($arrayClientCRM, true) . PHP_EOL);
|
||||||
|
$clientFullName = $arrayClientCRM['firstName'] . ' ' . $arrayClientCRM['lastName'];
|
||||||
} catch (RequestException $e) {
|
} catch (RequestException $e) {
|
||||||
if ($e->getCode() === 404) {
|
if ($e->getCode() === 404) {
|
||||||
$this->logger->error("Cliente no encontrado en CRM: " . $clientID . PHP_EOL);
|
$this->logger->error("Cliente no encontrado en CRM: " . $clientID . PHP_EOL);
|
||||||
return 'errorGetClientNotFound';
|
//devolver un array con los campos del codigo error, descripción de la falla, clientID, clientFullName y amount
|
||||||
|
$arrayOxxoPayment['oxxo_reference'] = '';
|
||||||
|
$arrayOxxoPayment['url'] = '';
|
||||||
|
$arrayOxxoPayment['error'] = 'errorGetClientNotFound';
|
||||||
|
$arrayOxxoPayment['failDescription'] = 'Cliente no encontrado en CRM: ' . $clientID;
|
||||||
|
$arrayOxxoPayment['clientID'] = $clientID;
|
||||||
|
$arrayOxxoPayment['clientFullName'] = $clientFullName;
|
||||||
|
$arrayOxxoPayment['amount'] = $amount;
|
||||||
|
return $arrayOxxoPayment;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
//timeout
|
||||||
|
if ($e->getCode() === 408) {
|
||||||
|
$this->logger->error("Timeout al obtener el cliente en CRM: " . $clientID . PHP_EOL);
|
||||||
|
//devolver un array con los campos del codigo error, descripción de la falla, clientID y amount
|
||||||
|
$arrayOxxoPayment['oxxo_reference'] = '';
|
||||||
|
$arrayOxxoPayment['error'] = 'errorTimeoutGetClient';
|
||||||
|
$arrayOxxoPayment['failDescription'] = 'Timeout al obtener el cliente en CRM: ' . $clientID;
|
||||||
|
$arrayOxxoPayment['clientID'] = $clientID;
|
||||||
|
$arrayOxxoPayment['clientFullName'] = $clientFullName;
|
||||||
|
$arrayOxxoPayment['amount'] = $amount;
|
||||||
|
return $arrayOxxoPayment;
|
||||||
}
|
}
|
||||||
$this->logger->error("Error al obtener el cliente en CRM (Error {$e->getCode()}): " . $e->getMessage() . PHP_EOL);
|
$this->logger->error("Error al obtener el cliente en CRM (Error {$e->getCode()}): " . $e->getMessage() . PHP_EOL);
|
||||||
return 'errorGetClient';
|
//devolver un array con los campos del codigo error, descripción de la falla, clientID y amount
|
||||||
|
$arrayOxxoPayment['oxxo_reference'] = '';
|
||||||
|
$arrayOxxoPayment['error'] = 'errorGetClient';
|
||||||
|
$arrayOxxoPayment['failDescription'] = 'Error al obtener el cliente en CRM: ' . $clientID;
|
||||||
|
$arrayOxxoPayment['clientID'] = $clientID;
|
||||||
|
$arrayOxxoPayment['clientFullName'] = $clientFullName;
|
||||||
|
$arrayOxxoPayment['amount'] = $amount;
|
||||||
|
return $arrayOxxoPayment;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtener email del cliente
|
// Obtener email del cliente
|
||||||
@ -119,7 +157,14 @@ abstract class AbstractOxxoOperationsFacade
|
|||||||
$this->logger->info("Stripe Customer ID obtenido: " . $stripeCustomerId . PHP_EOL);
|
$this->logger->info("Stripe Customer ID obtenido: " . $stripeCustomerId . PHP_EOL);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->logger->error("Error al obtener el Customer ID de Stripe (Error {$e->getCode()}): " . $e->getMessage() . PHP_EOL);
|
$this->logger->error("Error al obtener el Customer ID de Stripe (Error {$e->getCode()}): " . $e->getMessage() . PHP_EOL);
|
||||||
return 'errorGetCustomerStripe';
|
//devolver un array con los campos del codigo error, descripción de la falla, clientID y amount
|
||||||
|
$arrayOxxoPayment['oxxo_reference'] = '';
|
||||||
|
$arrayOxxoPayment['error'] = 'errorGetCustomerStripe';
|
||||||
|
$arrayOxxoPayment['failDescription'] = 'Error al obtener el Customer ID de Stripe: ' . $clientID;
|
||||||
|
$arrayOxxoPayment['clientID'] = $clientID;
|
||||||
|
$arrayOxxoPayment['clientFullName'] = $clientFullName;
|
||||||
|
$arrayOxxoPayment['amount'] = $amount;
|
||||||
|
return $arrayOxxoPayment;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($amount === null) {
|
if ($amount === null) {
|
||||||
@ -164,13 +209,40 @@ abstract class AbstractOxxoOperationsFacade
|
|||||||
|
|
||||||
} catch (\Stripe\Exception\ApiConnectionException $e) {
|
} catch (\Stripe\Exception\ApiConnectionException $e) {
|
||||||
$this->logger->error("Error de conexión con Stripe (Error {$e->getCode()}): " . $e->getMessage() . PHP_EOL);
|
$this->logger->error("Error de conexión con Stripe (Error {$e->getCode()}): " . $e->getMessage() . PHP_EOL);
|
||||||
return 'errorTimeoutCreatePaymentIntent';
|
//devolver un array con los campos del codigo error, descripción de la falla, clientID y amount
|
||||||
|
$arrayOxxoPayment['oxxo_reference'] = '';
|
||||||
|
$arrayOxxoPayment['url'] = '';
|
||||||
|
$arrayOxxoPayment['error'] = 'errorConnectionStripe';
|
||||||
|
$arrayOxxoPayment['failDescription'] = 'Error de conexión con Stripe: ' . $clientID;
|
||||||
|
$arrayOxxoPayment['clientID'] = $clientID;
|
||||||
|
$arrayOxxoPayment['clientFullName'] = $clientFullName;
|
||||||
|
$arrayOxxoPayment['amount'] = $amount;
|
||||||
|
return $arrayOxxoPayment;
|
||||||
|
|
||||||
} catch (\Stripe\Exception\ApiErrorException $e) {
|
} catch (\Stripe\Exception\ApiErrorException $e) {
|
||||||
$this->logger->error("Error de la API de Stripe: " . $e->getMessage() . PHP_EOL);
|
$this->logger->error("Error de la API de Stripe: " . $e->getMessage() . PHP_EOL);
|
||||||
return 'errorCreatePaymentIntent';
|
//devolver un array con los campos del codigo error, descripción de la falla, clientID y amount
|
||||||
|
$arrayOxxoPayment['oxxo_reference'] = '';
|
||||||
|
$arrayOxxoPayment['url'] = '';
|
||||||
|
$arrayOxxoPayment['error'] = 'errorApiStripe';
|
||||||
|
$arrayOxxoPayment['failDescription'] = 'Error de la API de Stripe: ' . $clientID;
|
||||||
|
$arrayOxxoPayment['clientID'] = $clientID;
|
||||||
|
$arrayOxxoPayment['clientFullName'] = $clientFullName;
|
||||||
|
$arrayOxxoPayment['amount'] = $amount;
|
||||||
|
return $arrayOxxoPayment;
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->logger->error("Error inesperado al crear PaymentIntent (Error {$e->getCode()}): " . $e->getMessage() . PHP_EOL);
|
$this->logger->error("Error inesperado al crear PaymentIntent (Error {$e->getCode()}): " . $e->getMessage() . PHP_EOL);
|
||||||
return 'errorCreatePaymentIntent';
|
//devolver un array con los campos del codigo error, descripción de la falla, clientID y amount
|
||||||
|
$arrayOxxoPayment['oxxo_reference'] = '';
|
||||||
|
$arrayOxxoPayment['url'] = '';
|
||||||
|
$arrayOxxoPayment['error'] = 'errorCreatePaymentIntent';
|
||||||
|
$arrayOxxoPayment['failDescription'] = 'Error inesperado al crear PaymentIntent: ' . $clientID;
|
||||||
|
$arrayOxxoPayment['clientID'] = $clientID;
|
||||||
|
$arrayOxxoPayment['amount'] = $amount;
|
||||||
|
$arrayOxxoPayment['clientFullName'] = $clientFullName;
|
||||||
|
return $arrayOxxoPayment;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -178,8 +250,17 @@ abstract class AbstractOxxoOperationsFacade
|
|||||||
$lastName = isset($arrayClientCRM['lastName']) ? trim($arrayClientCRM['lastName']) : '';
|
$lastName = isset($arrayClientCRM['lastName']) ? trim($arrayClientCRM['lastName']) : '';
|
||||||
|
|
||||||
if (strlen($firstName) < 2 || strlen($lastName) < 2) {
|
if (strlen($firstName) < 2 || strlen($lastName) < 2) {
|
||||||
$this->logger->error("Nombre/apellido inválido: $firstName $lastName" . PHP_EOL);
|
$this->logger->error("Nombre/apellido inválido: ' . $firstName . ' ' . $lastName" . PHP_EOL);
|
||||||
return 'errorNombreApellidoInvalido';
|
//devolver un array con los campos del codigo error, descripción de la falla, clientID y amount
|
||||||
|
$arrayOxxoPayment['oxxo_reference'] = '';
|
||||||
|
$arrayOxxoPayment['url'] = '';
|
||||||
|
$arrayOxxoPayment['error'] = 'errorNombreApellidoInvalido';
|
||||||
|
$arrayOxxoPayment['failDescription'] = "Nombre/apellido inválido: ' . $firstName . ' ' . $lastName";
|
||||||
|
$arrayOxxoPayment['clientID'] = $clientID;
|
||||||
|
$arrayOxxoPayment['clientFullName'] = $clientFullName;
|
||||||
|
$arrayOxxoPayment['amount'] = $amount;
|
||||||
|
return $arrayOxxoPayment;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$responsePaymentMethod = $guzzleClient->post('https://api.stripe.com/v1/payment_methods', [
|
$responsePaymentMethod = $guzzleClient->post('https://api.stripe.com/v1/payment_methods', [
|
||||||
@ -206,7 +287,15 @@ abstract class AbstractOxxoOperationsFacade
|
|||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->logger->error("Error al confirmar PaymentIntent: " . $e->getMessage() . PHP_EOL);
|
$this->logger->error("Error al confirmar PaymentIntent: " . $e->getMessage() . PHP_EOL);
|
||||||
return 'errorConfirmPaymentIntent';
|
//devolver un array con los campos del codigo error, descripción de la falla, clientID y amount
|
||||||
|
$arrayOxxoPayment['oxxo_reference'] = '';
|
||||||
|
$arrayOxxoPayment['url'] = '';
|
||||||
|
$arrayOxxoPayment['error'] = 'errorConfirmPaymentIntent';
|
||||||
|
$arrayOxxoPayment['failDescription'] = 'Error al confirmar PaymentIntent: ' . $e->getMessage();
|
||||||
|
$arrayOxxoPayment['clientID'] = $clientID;
|
||||||
|
$arrayOxxoPayment['clientFullName'] = $clientFullName;
|
||||||
|
$arrayOxxoPayment['amount'] = $amount;
|
||||||
|
return $arrayOxxoPayment;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($paymentIntentConfirm['next_action']) && isset($paymentIntentConfirm['next_action']['oxxo_display_details'])) {
|
if (!empty($paymentIntentConfirm['next_action']) && isset($paymentIntentConfirm['next_action']['oxxo_display_details'])) {
|
||||||
@ -216,16 +305,41 @@ abstract class AbstractOxxoOperationsFacade
|
|||||||
|
|
||||||
$this->logger->info("Referencia OXXO: " . $oxxo_reference . PHP_EOL);
|
$this->logger->info("Referencia OXXO: " . $oxxo_reference . PHP_EOL);
|
||||||
$this->logger->info("URL del recibo: " . $oxxo_receipt_url . PHP_EOL);
|
$this->logger->info("URL del recibo: " . $oxxo_receipt_url . PHP_EOL);
|
||||||
|
//devolver un array con los campos de url de oxxo, descripción de la falla, clientID y amount
|
||||||
return $oxxo_receipt_url;
|
$arrayOxxoPayment['oxxo_reference'] = $oxxo_reference;
|
||||||
|
$arrayOxxoPayment['url'] = $oxxo_receipt_url;
|
||||||
|
$arrayOxxoPayment['clientID'] = $clientID;
|
||||||
|
$arrayOxxoPayment['clientFullName'] = $clientFullName;
|
||||||
|
$arrayOxxoPayment['amount'] = $amount;
|
||||||
|
$arrayOxxoPayment['failDescription'] = '';
|
||||||
|
$arrayOxxoPayment['error'] = '';
|
||||||
|
$this->logger->info("Referencia OXXO creada correctamente." . PHP_EOL);
|
||||||
|
return $arrayOxxoPayment;
|
||||||
} else {
|
} else {
|
||||||
$this->logger->info("El PaymentIntent no tiene detalles de OXXO disponibles. Estado: " . $paymentIntentConfirm['status'] . PHP_EOL);
|
$this->logger->info("El PaymentIntent no tiene detalles de OXXO disponibles. Estado: " . $paymentIntentConfirm['status'] . PHP_EOL);
|
||||||
return 'errorPaymentIntentWithoutOxxoDetails';
|
//devolver un array con los campos del codigo error, descripción de la falla, clientID y amount
|
||||||
|
$arrayOxxoPayment['oxxo_reference'] = '';
|
||||||
|
$arrayOxxoPayment['url'] = '';
|
||||||
|
$arrayOxxoPayment['error'] = 'errorPaymentIntentWithoutOxxoDetails';
|
||||||
|
$arrayOxxoPayment['failDescription'] = 'El PaymentIntent no tiene detalles de OXXO disponibles. Estado: ' . $paymentIntentConfirm['status'];
|
||||||
|
$arrayOxxoPayment['clientID'] = $clientID;
|
||||||
|
$arrayOxxoPayment['clientFullName'] = $clientFullName;
|
||||||
|
$arrayOxxoPayment['amount'] = $amount;
|
||||||
|
return $arrayOxxoPayment;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$this->logger->info("Este cliente no tiene adeudos." . PHP_EOL);
|
$this->logger->info("Este cliente no tiene adeudos." . PHP_EOL);
|
||||||
return 'noAdeudo';
|
//devolver un array con los campos del codigo error, descripción de la falla, clientID y amount
|
||||||
|
$arrayOxxoPayment['oxxo_reference'] = '';
|
||||||
|
$arrayOxxoPayment['url'] = '';
|
||||||
|
$arrayOxxoPayment['error'] = 'errorsinadeudo';
|
||||||
|
$arrayOxxoPayment['failDescription'] = 'Este cliente no tiene adeudos.';
|
||||||
|
$arrayOxxoPayment['clientID'] = $clientID;
|
||||||
|
$arrayOxxoPayment['clientFullName'] = $clientFullName;
|
||||||
|
$arrayOxxoPayment['amount'] = $amount;
|
||||||
|
return $arrayOxxoPayment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -921,8 +921,17 @@ class ClientCallBellAPI
|
|||||||
'Authorization: Bearer ' . $this->CallBellAPIToken,
|
'Authorization: Bearer ' . $this->CallBellAPIToken,
|
||||||
'Content-Type: application/json',
|
'Content-Type: application/json',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$ch2 = curl_init();
|
||||||
|
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
curl_setopt($ch2, CURLOPT_CUSTOMREQUEST, 'PATCH');
|
||||||
|
curl_setopt($ch2, CURLOPT_HTTPHEADER, [
|
||||||
|
'Authorization: Bearer ' . $this->CallBellAPIToken,
|
||||||
|
'Content-Type: application/json',
|
||||||
|
]);
|
||||||
$UrlChatCallBell = 'https://api.callbell.eu/v1/contacts/' . $uuid;
|
$UrlChatCallBell = 'https://api.callbell.eu/v1/contacts/' . $uuid;
|
||||||
curl_setopt($ch, CURLOPT_URL, $UrlChatCallBell);
|
curl_setopt($ch, CURLOPT_URL, $UrlChatCallBell);
|
||||||
|
curl_setopt($ch2, CURLOPT_URL, $UrlChatCallBell);
|
||||||
$nombre_cliente = sprintf("%s %s", $notificationData->clientData['firstName'], $notificationData->clientData['lastName']);
|
$nombre_cliente = sprintf("%s %s", $notificationData->clientData['firstName'], $notificationData->clientData['lastName']);
|
||||||
$log->appendLog("Nombre del cliente que se va a actualizar: " . $nombre_cliente . PHP_EOL);
|
$log->appendLog("Nombre del cliente que se va a actualizar: " . $nombre_cliente . PHP_EOL);
|
||||||
$log->appendLog("UUID: " . $uuid . PHP_EOL);
|
$log->appendLog("UUID: " . $uuid . PHP_EOL);
|
||||||
@ -1010,7 +1019,7 @@ class ClientCallBellAPI
|
|||||||
$resumenClienteJSON = '{' .
|
$resumenClienteJSON = '{' .
|
||||||
'"Cliente": "' . $notificationData->clientData['id'] . '",' .
|
'"Cliente": "' . $notificationData->clientData['id'] . '",' .
|
||||||
'"Domicilio": "' .
|
'"Domicilio": "' .
|
||||||
(($notificationData->clientData['fullAddress'] == null) ? 'Sin domicilio' : '' . $notificationData->clientData['fullAddress']) . '",' .
|
//(($notificationData->clientData['fullAddress'] == null) ? 'Sin domicilio' : '' . $notificationData->clientData['fullAddress']) . '",' .
|
||||||
'"Nombre": "' . sprintf("%s %s", $notificationData->clientData['firstName'], $notificationData->clientData['lastName']) . '",' .
|
'"Nombre": "' . sprintf("%s %s", $notificationData->clientData['firstName'], $notificationData->clientData['lastName']) . '",' .
|
||||||
'"URL": "https://sistema.siip.mx/crm/client/' . $notificationData->clientId . '",' .
|
'"URL": "https://sistema.siip.mx/crm/client/' . $notificationData->clientId . '",' .
|
||||||
'"Saldo Actual": "' . $saldoTexto . '",' .
|
'"Saldo Actual": "' . $saldoTexto . '",' .
|
||||||
@ -1048,7 +1057,18 @@ class ClientCallBellAPI
|
|||||||
"Antena/Sectorial" => $antenaSectorial
|
"Antena/Sectorial" => $antenaSectorial
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$log->appendLog("JSON con los datos a actualizar: " . json_encode($data_CRM) . PHP_EOL);
|
$log->appendLog("JSON con los datos a actualizar: " . json_encode($data_CRM) . PHP_EOL);
|
||||||
|
|
||||||
|
|
||||||
|
$data_CRM2 = array(
|
||||||
|
"custom_fields" => array(
|
||||||
|
"Resumen" => $resumenClienteJSON,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$log->appendLog("JSON con los datos a actualizar del resumen: " . $resumenClienteJSON . PHP_EOL);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
$response_getContactCallBell['custom_fields']['Cliente'] != $data_CRM['custom_fields']['Cliente']
|
$response_getContactCallBell['custom_fields']['Cliente'] != $data_CRM['custom_fields']['Cliente']
|
||||||
|| $response_getContactCallBell['custom_fields']['Domicilio'] != $data_CRM['custom_fields']['Domicilio']
|
|| $response_getContactCallBell['custom_fields']['Domicilio'] != $data_CRM['custom_fields']['Domicilio']
|
||||||
@ -1062,9 +1082,13 @@ class ClientCallBellAPI
|
|||||||
|
|
||||||
) {
|
) {
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data_CRM));
|
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data_CRM));
|
||||||
|
curl_setopt($ch2, CURLOPT_POSTFIELDS, json_encode($data_CRM2));
|
||||||
$response = curl_exec($ch);
|
$response = curl_exec($ch);
|
||||||
$log->appendLog("Response Patch CallBell: " . $response . PHP_EOL);
|
$log->appendLog("Response Patch CallBell: " . $response . PHP_EOL);
|
||||||
|
$response2 = curl_exec($ch2);
|
||||||
|
$log->appendLog("Response 2 Patch CallBell: " . $response2 . PHP_EOL);
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
|
curl_close($ch2);
|
||||||
|
|
||||||
// if($fileNameComprobante != null){
|
// if($fileNameComprobante != null){
|
||||||
// sleep(3);
|
// sleep(3);
|
||||||
|
|||||||
@ -156,8 +156,10 @@ class Plugin
|
|||||||
// sleep(2);
|
// sleep(2);
|
||||||
// }
|
// }
|
||||||
$responseOxxo = $this->pluginOxxoNotifierFacade->createOxxoPaymentIntent($jsonData, $jsonData['amount']);
|
$responseOxxo = $this->pluginOxxoNotifierFacade->createOxxoPaymentIntent($jsonData, $jsonData['amount']);
|
||||||
|
$this->logger->info('Referencia personalizada, Valor de la respuesta: ' . json_encode($responseOxxo) . PHP_EOL);
|
||||||
|
//El array asociativo $responseOxxo es un array asosiativo con los siguientes campos: oxxo_reference, error, failDescription, clientID, amount
|
||||||
$intentos++;
|
$intentos++;
|
||||||
} while (strpos($responseOxxo, 'https') !== 0 && $intentos < 3); //Mientras la url no contenga https y el número de intentos sea menor a 3
|
} while (strpos($responseOxxo['url'], 'https') !== 0 && $intentos < 3); //Mientras la url no contenga https y el número de intentos sea menor a 3
|
||||||
} else {
|
} else {
|
||||||
$intentos = 0;
|
$intentos = 0;
|
||||||
do {
|
do {
|
||||||
@ -165,28 +167,39 @@ class Plugin
|
|||||||
// sleep(2);
|
// sleep(2);
|
||||||
// }
|
// }
|
||||||
$responseOxxo = $this->pluginOxxoNotifierFacade->createOxxoPaymentIntent($jsonData);
|
$responseOxxo = $this->pluginOxxoNotifierFacade->createOxxoPaymentIntent($jsonData);
|
||||||
|
//El array asociativo $responseOxxo es un array asosiativo con los siguientes campos: oxxo_reference, error, failDescription, clientID, amount
|
||||||
$intentos++;
|
$intentos++;
|
||||||
} while (strpos($responseOxxo, 'https') !== 0 && $intentos < 3); //Mientras la url no contenga https y el número de intentos sea menor a 3
|
} while (strpos($responseOxxo['url'], 'https') !== 0 && $intentos < 3); //Mientras la url no contenga https y el número de intentos sea menor a 3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//El array asociativo $responseOxxo es un array asosiativo con los siguientes campos: oxxo_reference, error, failDescription, clientID, amount
|
||||||
//Si la respuesta no contiene https, se genera un error
|
//Si la respuesta no contiene https, se genera un error
|
||||||
if (strpos($responseOxxo, 'https') !== 0) {
|
if (strpos($responseOxxo['url'], 'https') !== 0) {
|
||||||
$this->logger->error('Error al crear la referencia de OXXO: ' . $responseOxxo);
|
//this->logger->error('Error al crear la referencia de OXXO: ' . $responseOxxo);
|
||||||
//crear una variable $response con un json con el error y otra clave con la url vacia por ejemplo {"error":"Error al crear la referencia de OXXO","url":""}
|
//crear un json con variable $response que contenga las claves y valores del array $responseOxxo los cuales son: oxxo_reference, error, failDescription, clientID, clientFullName amount
|
||||||
|
|
||||||
$response = '{' .
|
$response = '{' .
|
||||||
'"error": "' . $responseOxxo . '",' .
|
'"url":' . $responseOxxo['url'] . ',' .
|
||||||
'"url": ""' .
|
'"error": "' . $responseOxxo['error'] . '",' .
|
||||||
|
'"failDescription": "' . $responseOxxo['failDescription'] . '",' .
|
||||||
|
'"clientID": "' . $responseOxxo['clientID'] . '",' .
|
||||||
|
'"clientFullName": "' . $responseOxxo['clientFullName'] . '",' .
|
||||||
|
'"amount": "' . $responseOxxo['amount'] . '",' .
|
||||||
'}';
|
'}';
|
||||||
|
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
echo $response;
|
echo $response;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
//crear una variable $response con un json con el error en blanco y otra clave url con el dato {"error":"","url":"https://stripe.voucher.com/voucher/1234567890"}
|
//crear un json con variable $response que contenga las claves y valores del array $responseOxxo los cuales son: oxxo_reference, error, failDescription, clientID, clientFullName, amount
|
||||||
|
|
||||||
$response = '{' .
|
$response = '{' .
|
||||||
'"error": "",' .
|
'"url": "' . $responseOxxo['url'] . '",' .
|
||||||
'"url": "' . $responseOxxo . '"' .
|
'"oxxo_reference": "' . $responseOxxo['oxxo_reference'] . '",' .
|
||||||
|
'"error": "' . $responseOxxo['error'] . '",' .
|
||||||
|
'"failDescription": "' . $responseOxxo['failDescription'] . '",' .
|
||||||
|
'"clientID": "' . $responseOxxo['clientID'] . '",' .
|
||||||
|
'"clientFullName": "' . $responseOxxo['clientFullName'] . '",' .
|
||||||
|
'"amount": "' . $responseOxxo['amount'] . '"' .
|
||||||
'}';
|
'}';
|
||||||
|
|
||||||
$this->logger->debug('Reponse que se envía a CallBell: ' . $response);
|
$this->logger->debug('Reponse que se envía a CallBell: ' . $response);
|
||||||
|
|||||||
337
vendor/composer/autoload_classmap.php
vendored
337
vendor/composer/autoload_classmap.php
vendored
File diff suppressed because it is too large
Load Diff
337
vendor/composer/autoload_static.php
vendored
337
vendor/composer/autoload_static.php
vendored
File diff suppressed because it is too large
Load Diff
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' => 'cd74cafedaf76be5fca5f3f67b1b6c8306b1eef2',
|
'reference' => '2819804ad8010155a47b3c266d2745e531d79f68',
|
||||||
'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' => 'cd74cafedaf76be5fca5f3f67b1b6c8306b1eef2',
|
'reference' => '2819804ad8010155a47b3c266d2745e531d79f68',
|
||||||
'dev_requirement' => false,
|
'dev_requirement' => false,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user