<?php
namespace Wits\PaymentBundle\Entity;
use App\Entity\Order;
use Doctrine\ORM\Mapping as ORM;
use Wits\PaymentBundle\Entity\Enum\PaymentStateEnum;
/**
* @ORM\Table
* @ORM\Entity(repositoryClass="Wits\PaymentBundle\Repository\PaymentRepository")
*/
class Payment
{
const STATE_PENDING = 'pending';
const STATE_CONFIRMED = 'confirmed';
const STATE_CANCELED = 'canceled';
/**
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*
* @var integer $id
*/
protected int $id;
/**
* @ORM\Column(name="stripe_pi", type="string", length=255)
*/
private string $paymentIntent;
/**
* @ORM\Column(name="stripe_session", type="string", length=100, unique=true, nullable=true)
*/
private ?string $sessionId;
/**
* @ORM\Column(type="string", length=255)
*/
private string $state = self::STATE_PENDING;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $clientEmail=null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $clientId=null;
/**
* @ORM\Column(precision=10, scale=2)
*/
private float $totalAmount;
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $informations=null;
/**
* @ORM\ManyToOne(targetEntity=Order::class, inversedBy="payments")
*/
private ?Order $order;
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
public function getLabel(): string
{
return '#'.$this->id;
}
/**
* @param int $id
*/
public function setId(int $id): void
{
$this->id = $id;
}
public function getClientEmail(): ?string
{
return $this->clientEmail;
}
/**
* @param mixed $clientEmail
*/
public function setClientEmail($clientEmail): void
{
$this->clientEmail = $clientEmail;
}
public function getTotalAmount(): float
{
return $this->totalAmount;
}
public function setTotalAmount($totalAmount): void
{
$this->totalAmount = $totalAmount;
}
public function getState(): string
{
return $this->state;
}
public function getStateLabel(): string
{
return PaymentStateEnum::getStateName($this->state);
}
public function isConfirmed(): bool
{
return $this->state === self::STATE_CONFIRMED;
}
public function isPending(): bool
{
return $this->state === self::STATE_PENDING;
}
public function setState($state): void
{
$this->state = $state;
}
public function getPaymentIntent(): string
{
return $this->paymentIntent;
}
public function setPaymentIntent($paymentIntent): void
{
$this->paymentIntent = $paymentIntent;
}
public function getSessionId(): ?string
{
return $this->sessionId;
}
public function setSessionId($sessionId): void
{
$this->sessionId = $sessionId;
}
public function getClientId(): string
{
return $this->clientId;
}
public function setClientId($clientId): void
{
$this->clientId = $clientId;
}
public function getInformations(): ?string
{
return $this->informations;
}
public function setInformations(string $informations): void
{
$this->informations = $informations;
}
public function getOrder(): ?Order
{
return $this->order;
}
public function setOrder(?Order $order): void
{
$this->order = $order;
}
}