src/Entity/CabeceraLinkdepago.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Controller\Admin\StatusTrait;
  4. use App\Repository\CabeceraLinkdepagoRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7.  * @ORM\Entity(repositoryClass=CabeceraLinkdepagoRepository::class)
  8.  * @ORM\HasLifecycleCallbacks()
  9.  */
  10. class CabeceraLinkdepago
  11. {
  12.     use StatusTrait;
  13.     use Timestamp;
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue
  17.      * @ORM\Column(type="integer")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @ORM\ManyToOne(targetEntity=Cabecera::class, inversedBy="CabeceraLinkdepago")
  22.      */
  23.     private $Cabecera;
  24.     /**
  25.      * @ORM\Column(type="string", length=255)
  26.      */
  27.     private $Estado;
  28.     /**
  29.      * @ORM\Column(type="json", nullable=true)
  30.      */
  31.     private $Linkdepago = [];
  32.     /**
  33.      * @ORM\Column(type="string", length=255, nullable=true)
  34.      */
  35.     private $comentario;
  36.     public function getId(): ?int
  37.     {
  38.         return $this->id;
  39.     }
  40.     public function getCabecera(): ?Cabecera
  41.     {
  42.         return $this->Cabecera;
  43.     }
  44.     public function setCabecera(?Cabecera $Cabecera): self
  45.     {
  46.         $this->Cabecera $Cabecera;
  47.         return $this;
  48.     }
  49.     public function getEstado(): ?string
  50.     {
  51.         return $this->Estado;
  52.     }
  53.     public function setEstado(string $Estado): self
  54.     {
  55.         $this->Estado $Estado;
  56.         return $this;
  57.     }
  58.     public function getLinkdepago(): ?array
  59.     {
  60.         return $this->Linkdepago;
  61.     }
  62.     public function setLinkdepago(array $Linkdepago): self
  63.     {
  64.         $this->Linkdepago $Linkdepago;
  65.         return $this;
  66.     }
  67.     public function getComentario(): ?string
  68.     {
  69.         return $this->comentario;
  70.     }
  71.     public function setComentario(string $comentario): self
  72.     {
  73.         $this->comentario $comentario;
  74.         return $this;
  75.     }
  76.     public function getGlobalpayId(): ?string
  77.     {
  78.         return $this->Linkdepago['transaction']['id'] ?? null;
  79.     }
  80.     public function getGlobalpayLtpId(): ?string
  81.     {
  82.         return $this->Linkdepago['transaction']['ltp_id'] ?? null;
  83.     }
  84.     public function getGlobalpayStatus(): ?string
  85.     {
  86.         // Asegúrate de reemplazar 'parametroEspecifico' con la clave real que buscas.
  87.         return $this->Linkdepago['transaction']['status'] ?? null;
  88.     }
  89.     public function getGlobalpayComment(): ?string
  90.     {
  91.         return $this->Linkdepago['transaction']['message'] ?? null;
  92.     }
  93.     public function getGlobalpayStatusName(): ?string
  94.     {
  95.         // Obtiene el número de estado
  96.         $status $this->getGlobalpayStatus();
  97.         return $this->mapStatusNumberToName($status);
  98.     }
  99.     public function getGlobalpayDate(): ?\DateTime
  100.     {
  101.         $date $this->Linkdepago['transaction']['date'] ?? null;
  102.         if ($date === null) {
  103.             return null;
  104.         }
  105.         // Usar \DateTime::createFromFormat para manejar el formato de fecha específico
  106.         $dateTime \DateTime::createFromFormat('d/m/Y H:i:s'$date);
  107.         if ($dateTime === false) {
  108.             throw new \Exception("Failed to parse date string: " $date);
  109.         }
  110.          // Restar 5 horas a la fecha y hora
  111.         $dateTime->modify('-5 hours');
  112.         return $dateTime;
  113.     }
  114.     public function getBadgeColor(): ?string
  115.     {
  116.         return $this->getBadgeColorForStatus($this->getGlobalpayStatus());
  117.     }
  118. }