- Implementado servicio backend [PaymentIntentService](cci:2://file:///home/unms/data/ucrm/ucrm/data/plugins/siip-stripe-payment_intents/src/PaymentIntentService.php:8:0-152:1) para manejar interacciones con API de UCRM y Stripe. - Creado frontend moderno y responsivo en HTML/JS dentro de [public.php](cci:7://file:///home/unms/data/ucrm/ucrm/data/plugins/siip-stripe-payment_intents/public.php:0:0-0:0). - Agregada búsqueda con autocompletado para clientes. - Agregada validación para Stripe Customer ID y monto mínimo. - Integrada la creación de Payment Intents de Stripe para fondos tipo `customer_balance`. - Agregada documentación (README.md, CHANGELOG.md) y limpieza de archivos legado.
70 lines
1.6 KiB
PHP
70 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace Stripe\Service;
|
|
|
|
/**
|
|
* Abstract base class for all service factories used to expose service
|
|
* instances through {@link \Stripe\StripeClient}.
|
|
*
|
|
* Service factories serve two purposes:
|
|
*
|
|
* 1. Expose properties for all services through the `__get()` magic method.
|
|
* 2. Lazily initialize each service instance the first time the property for
|
|
* a given service is used.
|
|
*/
|
|
abstract class AbstractServiceFactory
|
|
{
|
|
/** @var \Stripe\StripeClientInterface */
|
|
private $client;
|
|
|
|
/** @var array<string, AbstractService|AbstractServiceFactory> */
|
|
private $services;
|
|
|
|
/**
|
|
* @param \Stripe\StripeClientInterface $client
|
|
*/
|
|
public function __construct($client)
|
|
{
|
|
$this->client = $client;
|
|
$this->services = [];
|
|
}
|
|
|
|
/**
|
|
* @param string $name
|
|
*
|
|
* @return null|string
|
|
*/
|
|
abstract protected function getServiceClass($name);
|
|
|
|
/**
|
|
* @param string $name
|
|
*
|
|
* @return null|AbstractService|AbstractServiceFactory
|
|
*/
|
|
public function __get($name)
|
|
{
|
|
return $this->getService($name);
|
|
}
|
|
|
|
/**
|
|
* @param string $name
|
|
*
|
|
* @return null|AbstractService|AbstractServiceFactory
|
|
*/
|
|
public function getService($name)
|
|
{
|
|
$serviceClass = $this->getServiceClass($name);
|
|
if (null !== $serviceClass) {
|
|
if (!\array_key_exists($name, $this->services)) {
|
|
$this->services[$name] = new $serviceClass($this->client);
|
|
}
|
|
|
|
return $this->services[$name];
|
|
}
|
|
|
|
\trigger_error('Undefined property: ' . static::class . '::$' . $name);
|
|
|
|
return null;
|
|
}
|
|
}
|