2026-02-17 14:01:32 +00:00
|
|
|
<?php
|
|
|
|
|
|
2026-06-23 16:12:23 +02:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2026-02-17 14:01:32 +00:00
|
|
|
namespace App\Lib\Axepta\Objects;
|
|
|
|
|
|
2026-06-23 16:12:23 +02:00
|
|
|
use Illuminate\Support\Facades\Validator;
|
|
|
|
|
|
2026-06-23 16:16:03 +02:00
|
|
|
final readonly class AxeptaOrder
|
2026-02-17 14:01:32 +00:00
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Construct method
|
|
|
|
|
*
|
2026-09-25 16:25:31 +02:00
|
|
|
* @param string $reference Internal system reference order
|
|
|
|
|
* @param int $amount Order amount ex: 10000 = 100$
|
|
|
|
|
* @param string $customerEmail Customer email
|
2026-03-24 17:56:47 +01:00
|
|
|
* @return void
|
2026-02-17 14:01:32 +00:00
|
|
|
*/
|
|
|
|
|
public function __construct(
|
|
|
|
|
public string $reference,
|
|
|
|
|
public int $amount,
|
|
|
|
|
public string $customerEmail
|
2026-03-24 17:56:47 +01:00
|
|
|
) {
|
2026-06-23 16:12:23 +02:00
|
|
|
if (empty(trim($reference))) {
|
|
|
|
|
throw new \DomainException('Reference cannot be empty');
|
|
|
|
|
}
|
|
|
|
|
if ($amount <= 0) {
|
|
|
|
|
throw new \DomainException('Amount cannot be negative');
|
|
|
|
|
}
|
|
|
|
|
if (
|
2026-09-25 16:25:31 +02:00
|
|
|
empty(trim($customerEmail)) || Validator::make(['email' => $customerEmail], ['email' => 'email:rfc'])->fails()
|
2026-06-23 16:12:23 +02:00
|
|
|
) {
|
|
|
|
|
throw new \DomainException('A valid email is required');
|
|
|
|
|
}
|
2026-03-24 17:56:47 +01:00
|
|
|
}
|
|
|
|
|
}
|