42 lines
1.1 KiB
PHP
42 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Data;
|
|
|
|
use App\Contracts\OutputDataTransferObject;
|
|
|
|
final readonly class VerifiedCheckoutResponseDTO implements OutputDataTransferObject
|
|
{
|
|
public function __construct(
|
|
public bool $isSuccess,
|
|
public string $message,
|
|
public ?int $amount = null,
|
|
public ?string $transactionId = null,
|
|
public ?string $mode = null
|
|
) {}
|
|
|
|
public static function failure(string $message): VerifiedCheckoutResponseDTO
|
|
{
|
|
return new self(isSuccess: false, message: $message);
|
|
}
|
|
|
|
public static function success(string $message, int $amount, string $transactionId, string $mode): VerifiedCheckoutResponseDTO
|
|
{
|
|
return new self(isSuccess: true, message: $message, amount: $amount, transactionId: $transactionId,
|
|
mode: $mode);
|
|
}
|
|
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function toArray(): array
|
|
{
|
|
return [
|
|
'isSuccess' => $this->isSuccess,
|
|
'message' => $this->message,
|
|
'amount' => $this->amount,
|
|
'transactionId' => $this->transactionId,
|
|
'paymentMethod' => $this->mode,
|
|
];
|
|
}
|
|
}
|