# معماری — تسک ۱۵: ماژول پرداخت

## ساختار فایل‌ها
```
src/Module/Payment/
├── Controller/
│   ├── PaymentController.php       ← ایجاد و دریافت پرداخت
│   └── PaymentCallbackController.php ← callback درگاه پرداخت
├── Service/
│   ├── PaymentService.php
│   └── Gateway/
│       ├── PaymentGatewayInterface.php
│       ├── ZarinpalGateway.php      ← درگاه زرین‌پال
│       └── NullGateway.php          ← برای محیط dev
├── Repository/
│   └── PaymentRepository.php
├── Entity/
│   └── Payment.php
├── DTO/
│   ├── Request/
│   │   └── CreatePaymentRequest.php
│   └── Response/
│       └── PaymentResponse.php
└── Voter/
    └── PaymentVoter.php
```

## Entity: Payment
```php
#[ORM\Entity]
#[ORM\Table(name: 'payments')]
class Payment
{
    #[ORM\Id, ORM\GeneratedValue, ORM\Column]
    private int $id;

    #[ORM\Column(type: UuidType::NAME, unique: true)]
    private Uuid $uuid;

    #[ORM\OneToOne(targetEntity: Appointment::class)]
    private Appointment $appointment;

    #[ORM\ManyToOne(targetEntity: User::class)]
    private User $user;

    #[ORM\Column(type: 'integer')]
    private int $amount;  // ریال

    // pending, paid, failed, refunded
    #[ORM\Column(length: 20, default: 'pending')]
    private string $status;

    #[ORM\Column(length: 30, nullable: true)]
    private ?string $paymentMethod;  // online, cash, insurance

    #[ORM\Column(length: 100, nullable: true)]
    private ?string $gatewayToken;  // توکن درگاه

    #[ORM\Column(length: 50, nullable: true)]
    private ?string $referenceCode;  // کد پیگیری

    #[ORM\Column(type: 'datetime_immutable', nullable: true)]
    private ?\DateTimeImmutable $paidAt;

    // TimestampableTrait
}
```
