37 lines
1,013 B
PHP
37 lines
1,013 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Lib\Axepta\Objects;
|
|
|
|
use Illuminate\Support\Facades\Validator;
|
|
|
|
final readonly class AxeptaOrder
|
|
{
|
|
/**
|
|
* Construct method
|
|
*
|
|
* @param string $reference Internal system reference order
|
|
* @param integer $amount Order amount ex: 10000 = 100$
|
|
* @param string $customerEmail Customer email
|
|
* @return void
|
|
*/
|
|
public function __construct(
|
|
public string $reference,
|
|
public int $amount,
|
|
public string $customerEmail
|
|
) {
|
|
if (empty(trim($reference))) {
|
|
throw new \DomainException('Reference cannot be empty');
|
|
}
|
|
if ($amount <= 0) {
|
|
throw new \DomainException('Amount cannot be negative');
|
|
}
|
|
if (
|
|
empty(trim($customerEmail)) ||
|
|
Validator::make(['email' => $customerEmail], ['email' => 'email:rfc'])->fails()
|
|
) {
|
|
throw new \DomainException('A valid email is required');
|
|
}
|
|
}
|
|
}
|