Hot fix para arreglar el error que no permitía generar pagos por referencia

This commit is contained in:
server 2025-02-06 23:48:51 +00:00
parent eafc867742
commit e1e3f409c9
7 changed files with 143 additions and 2888 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 106 KiB

After

Width:  |  Height:  |  Size: 104 KiB

File diff suppressed because one or more lines are too long

View File

@ -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",
"description": "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",
"url": "https://siip.mx/",
"version": "2.6.3",
"version": "2.6.4",
"unmsVersionCompliancy": {
"min": "2.1.0",
"max": null

View File

@ -57,24 +57,43 @@ abstract class AbstractStripeOperationsFacade
*/
public function createPaymentIntent($event_json)
{
$this->logger->info("Evento recibido: " . json_encode($event_json) . PHP_EOL);
$configManager = \Ubnt\UcrmPluginSdk\Service\PluginConfigManager::create();
$config = $configManager->loadConfig();
$StripeToken = $config['tokenstripe'];
$stripe = new \Stripe\StripeClient($StripeToken); //Token de clave privada para la API de Stripe
$customerId = $event_json->data->object->customer;
$amount = $event_json->data->object->net_amount;
$stripeQuery = $stripe->customers->retrieve($customerId, []);
$UCRM_clientID = $stripeQuery['metadata']['ucrm_client_id'];
$this->ucrmApi = UcrmApi::create();
$currentUserAdmin = $this->ucrmApi->get('users/admins', []);
//$this->logger->info("User Admin ID: " . json_encode($currentUserAdmin) . PHP_EOL);
// Asegurarse de que 'customer' esté presente en la estructura del evento
if (!isset($event_json['data']['object']['customer'])) {
$this->logger->info("Error: Invalid event structure. Customer ID not found." . PHP_EOL);
return;
}
$customerId = $event_json['data']['object']['customer'];
if (is_null($customerId)) {
$this->logger->info("Error: Customer ID is null." . PHP_EOL);
return;
}
// Validar que net_amount está presente
if (!isset($event_json['data']['object']['net_amount'])) {
$this->logger->info("Error: net_amount not found in event data." . PHP_EOL);
return;
}
$amount = $event_json['data']['object']['net_amount'];
try {
// Obtener información del cliente desde Stripe
$stripeQuery = $stripe->customers->retrieve($customerId, []);
$UCRM_clientID = $stripeQuery['metadata']['ucrm_client_id'];
// Obtener información del administrador actual
$this->ucrmApi = UcrmApi::create();
$currentUserAdmin = $this->ucrmApi->get('users/admins', []);
// Crear PaymentIntent
$paymentIntent = $stripe->paymentIntents->create([
'amount' => $amount,
'currency' => 'mxn',
@ -99,12 +118,12 @@ abstract class AbstractStripeOperationsFacade
$this->logger->info("PaymentIntent creado: " . $paymentIntent->id . PHP_EOL);
} catch (\Stripe\Exception\ApiErrorException $e) {
$this->logger->info("Error creando PaymentIntent: " . $e->getMessage() . PHP_EOL);
}
}
/*
* Creates the Stripe Customer
*/

View File

@ -119,7 +119,7 @@ class Plugin
return;
}
$jsonData = @json_decode($userInput, true, 10);
$jsonData = @json_decode($userInput, true, 50);
if (!isset($jsonData['uuid'])) {
$this->logger->info('No UUID found in the webhook data');

View File

@ -5,7 +5,7 @@
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'reference' => '12d19c46de49ae1f0c937e9ebe2aa371b0b76379',
'reference' => 'eafc8677421ac4e40512369b77241db03a88a091',
'name' => 'ucrm-plugins/sms-twilio',
'dev' => false,
),
@ -307,7 +307,7 @@
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'reference' => '12d19c46de49ae1f0c937e9ebe2aa371b0b76379',
'reference' => 'eafc8677421ac4e40512369b77241db03a88a091',
'dev_requirement' => false,
),
),