Hot fix para arreglar el error que no permitía generar pagos por referencia
This commit is contained in:
parent
eafc867742
commit
e1e3f409c9
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 106 KiB After Width: | Height: | Size: 104 KiB |
2984
data/plugin.log
2984
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 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",
|
"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/",
|
"url": "https://siip.mx/",
|
||||||
"version": "2.6.3",
|
"version": "2.6.4",
|
||||||
"unmsVersionCompliancy": {
|
"unmsVersionCompliancy": {
|
||||||
"min": "2.1.0",
|
"min": "2.1.0",
|
||||||
"max": null
|
"max": null
|
||||||
|
|||||||
@ -57,24 +57,43 @@ abstract class AbstractStripeOperationsFacade
|
|||||||
*/
|
*/
|
||||||
public function createPaymentIntent($event_json)
|
public function createPaymentIntent($event_json)
|
||||||
{
|
{
|
||||||
|
$this->logger->info("Evento recibido: " . json_encode($event_json) . PHP_EOL);
|
||||||
|
|
||||||
$configManager = \Ubnt\UcrmPluginSdk\Service\PluginConfigManager::create();
|
$configManager = \Ubnt\UcrmPluginSdk\Service\PluginConfigManager::create();
|
||||||
$config = $configManager->loadConfig();
|
$config = $configManager->loadConfig();
|
||||||
$StripeToken = $config['tokenstripe'];
|
$StripeToken = $config['tokenstripe'];
|
||||||
$stripe = new \Stripe\StripeClient($StripeToken); //Token de clave privada para la API de Stripe
|
$stripe = new \Stripe\StripeClient($StripeToken); //Token de clave privada para la API de Stripe
|
||||||
|
|
||||||
$customerId = $event_json->data->object->customer;
|
// Asegurarse de que 'customer' esté presente en la estructura del evento
|
||||||
$amount = $event_json->data->object->net_amount;
|
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, []);
|
$stripeQuery = $stripe->customers->retrieve($customerId, []);
|
||||||
$UCRM_clientID = $stripeQuery['metadata']['ucrm_client_id'];
|
$UCRM_clientID = $stripeQuery['metadata']['ucrm_client_id'];
|
||||||
|
|
||||||
|
// Obtener información del administrador actual
|
||||||
$this->ucrmApi = UcrmApi::create();
|
$this->ucrmApi = UcrmApi::create();
|
||||||
$currentUserAdmin = $this->ucrmApi->get('users/admins', []);
|
$currentUserAdmin = $this->ucrmApi->get('users/admins', []);
|
||||||
//$this->logger->info("User Admin ID: " . json_encode($currentUserAdmin) . PHP_EOL);
|
|
||||||
|
|
||||||
|
// Crear PaymentIntent
|
||||||
|
|
||||||
|
|
||||||
try {
|
|
||||||
$paymentIntent = $stripe->paymentIntents->create([
|
$paymentIntent = $stripe->paymentIntents->create([
|
||||||
'amount' => $amount,
|
'amount' => $amount,
|
||||||
'currency' => 'mxn',
|
'currency' => 'mxn',
|
||||||
@ -99,12 +118,12 @@ abstract class AbstractStripeOperationsFacade
|
|||||||
|
|
||||||
$this->logger->info("PaymentIntent creado: " . $paymentIntent->id . PHP_EOL);
|
$this->logger->info("PaymentIntent creado: " . $paymentIntent->id . PHP_EOL);
|
||||||
|
|
||||||
|
|
||||||
} catch (\Stripe\Exception\ApiErrorException $e) {
|
} catch (\Stripe\Exception\ApiErrorException $e) {
|
||||||
$this->logger->info("Error creando PaymentIntent: " . $e->getMessage() . PHP_EOL);
|
$this->logger->info("Error creando PaymentIntent: " . $e->getMessage() . PHP_EOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Creates the Stripe Customer
|
* Creates the Stripe Customer
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -119,7 +119,7 @@ class Plugin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$jsonData = @json_decode($userInput, true, 10);
|
$jsonData = @json_decode($userInput, true, 50);
|
||||||
|
|
||||||
if (!isset($jsonData['uuid'])) {
|
if (!isset($jsonData['uuid'])) {
|
||||||
$this->logger->info('No UUID found in the webhook data');
|
$this->logger->info('No UUID found in the webhook data');
|
||||||
|
|||||||
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' => '12d19c46de49ae1f0c937e9ebe2aa371b0b76379',
|
'reference' => 'eafc8677421ac4e40512369b77241db03a88a091',
|
||||||
'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' => '12d19c46de49ae1f0c937e9ebe2aa371b0b76379',
|
'reference' => 'eafc8677421ac4e40512369b77241db03a88a091',
|
||||||
'dev_requirement' => false,
|
'dev_requirement' => false,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user