src/Entity/Payment/Payment.php line 39
<?php/** This file is part of the Pellipop project.** (c) Mobizel** For the full copyright and license information, please view the LICENSE* file that was distributed with this source code.*/declare(strict_types=1);namespace App\Entity\Payment;use App\Entity\Customer\Customer;use App\Entity\IdentifiableTrait;use App\Entity\Order\Order;use App\Entity\Promotion\PromotionCode;use App\PaymentStates;use App\Repository\Payment\PaymentRepository;use Doctrine\ORM\Mapping as ORM;use Gedmo\Timestampable\Traits\TimestampableEntity;use Payum\Core\Model\CreditCardInterface;use Payum\Core\Model\PaymentInterface;use Sylius\Component\Resource\Annotation\SyliusCrudRoutes;use Sylius\Component\Resource\Model\ResourceInterface;#[ORM\Entity(repositoryClass: PaymentRepository::class)]#[ORM\Table(name: 'app_payment')]#[SyliusCrudRoutes(alias: 'app.payment', path: '/admin/payments', section: 'backend', templates: 'backend/payment', grid: 'app_backend_payment', only: ['index', 'show'], vars: ['all' => ['subheader' => 'app.ui.manage_your_payments',],'index' => ['icon' => 'payment',],])]class Payment implements ResourceInterface, PaymentInterface{use IdentifiableTrait;use TimestampableEntity;#[ORM\Column(type: 'string', length: 100)]private string $number;#[ORM\ManyToOne(targetEntity: Customer::class)]#[ORM\JoinColumn(name: "customer_id", referencedColumnName: "id", onDelete: "CASCADE")]private ?Customer $customer = null;#[ORM\Column(type: 'string', length: 20)]private string $state;#[ORM\Column(type: 'integer')]private int $credits = 0;#[ORM\Column(type: 'string')]private string $description;#[ORM\Column(type: 'integer')]private int $amount = 0;#[ORM\Column(type: 'string', length: 10)]private string $currencyCode;#[ORM\Column(type: 'json')]private array $details;#[ORM\ManyToOne(targetEntity: PromotionCode::class, inversedBy: 'payments')]#[ORM\JoinColumn(nullable: true)]private ?PromotionCode $promotionCode;/** Order paid by this payment when paymentType is order_direct or order_complement. */#[ORM\ManyToOne(targetEntity: Order::class)]#[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')]private ?Order $order = null;/** credit_pack | order_direct | order_complement */#[ORM\Column(type: 'string', length: 30, nullable: true, options: ['default' => 'credit_pack'])]private ?string $paymentType = 'credit_pack';/** Credits to debit from customer when paymentType is order_complement (after Stripe confirms). */#[ORM\Column(type: 'integer', options: ['default' => 0])]private int $creditsToDebit = 0;public function __construct(){$this->details = [];$this->state = PaymentStates::STATE_NEW;}/*** Get the value of customer** @return ?Customer*/public function getCustomer(): ?Customer{return $this->customer;}/*** Set the value of customer** @return self*/public function setCustomer(?Customer $customer): self{$this->customer = $customer;return $this;}/*** Get the value of state** @return string*/public function getState(): string{return $this->state;}/*** Set the value of state** @return self*/public function setState(string $state): self{$this->state = $state;return $this;}/*** Get the value of credits** @return ?int*/public function getCredits(): ?int{return $this->credits;}/*** Set the value of credits** @return self*/public function setCredits(?int $credits): self{$this->credits = $credits;return $this;}public function __toString(): string{return (string) ($this->getNumber() ?? $this->getId());}/*** Get the value of description** @return string*/public function getDescription(){return $this->description;}/*** Set the value of description** @param string $description** @return self*/public function setDescription(string $description): self{$this->description = $description;return $this;}/*** Get the value of amount** @return int*/public function getAmount(){return $this->amount;}/*** Set the value of amount** @param int $amount** @return self*/public function setAmount(int $amount): self{$this->amount = $amount;return $this;}/*** Get the value of currencyCode** @return string*/public function getCurrencyCode(){return $this->currencyCode;}/*** Set the value of currencyCode** @param string $currencyCode** @return self*/public function setCurrencyCode(string $currencyCode): self{$this->currencyCode = $currencyCode;return $this;}/*** Get the value of number** @return array*/public function getDetails(): array{return $this->details;}/*** Set the value of details** @param object $details** @return self*/public function setDetails($details): self{if ($details instanceof \Traversable) {$details = iterator_to_array($details);}$this->details = $details;return $this;}/*** Get the value of number** @return string*/public function getNumber(){return $this->number;}/*** Set the value of number** @param string $number** @return self*/public function setNumber(string $number): self{$this->number = $number;return $this;}/*** Get the value of promotionCode** @return ?PromotionCode*/public function getPromotionCode(): ?PromotionCode{return $this->promotionCode;}/*** Set the value of promotionCode** @param ?PromotionCode $promotionCode** @return self*/public function setPromotionCode(?PromotionCode $promotionCode): self{$this->promotionCode = $promotionCode;return $this;}public function getClientEmail(): string{return $this->getCustomer()->getEmail() ?? '';}public function getClientId(): string{return (string) $this->getCustomer()->getId() ?? '';}public function getTotalAmount(): int{return $this->getAmount();}public function getCreditCard(): CreditCardInterface|null{return null;}public function getPaymentIntent(): ?string{if (isset($this->getDetails()['object']) && $this->getDetails()['object'] === 'payment_intent') {return ((string) $this->getDetails()['id']) ?? null;}return null;}public function getClientSecret(): ?string{if (isset($this->getDetails()['client_secret'])) {return ((string) $this->getDetails()['client_secret']) ?? null;}return null;}public function getOrder(): ?Order{return $this->order;}public function setOrder(?Order $order): self{$this->order = $order;return $this;}public function getPaymentType(): ?string{return $this->paymentType;}public function setPaymentType(?string $paymentType): self{$this->paymentType = $paymentType;return $this;}public function getCreditsToDebit(): int{return $this->creditsToDebit;}public function setCreditsToDebit(int $creditsToDebit): self{$this->creditsToDebit = $creditsToDebit;return $this;}public function isOrderPayment(): bool{return $this->paymentType === 'order_direct' || $this->paymentType === 'order_complement';}}