33 lines
805 B
PHP
33 lines
805 B
PHP
<?php
|
|
|
|
namespace App\Data;
|
|
|
|
use App\Contracts\OutputDataTransferObject;
|
|
use App\Enums\StripePaymentMode;
|
|
|
|
final readonly class StripeSessionDataDTO implements OutputDataTransferObject
|
|
{
|
|
/**
|
|
* @param StripeLineItemDTO[] $lineItems
|
|
*/
|
|
public function __construct(
|
|
public array $lineItems,
|
|
public StripePaymentMode $mode,
|
|
public string $successUrl,
|
|
public string $cancelUrl
|
|
) {}
|
|
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function toArray(): array
|
|
{
|
|
return [
|
|
'line_items' => array_map(fn (StripeLineItemDTO $dto) => $dto->toArray(), $this->lineItems),
|
|
'mode' => $this->mode->value,
|
|
'success_url' => $this->successUrl,
|
|
'cancel_url' => $this->cancelUrl,
|
|
];
|
|
}
|
|
}
|