- schedule(subscription) → DunningSchedule (retry dates + suspension date) - retry(invoice) → PaymentResult - suspend(subscription) → void - notify(subscription, stage) → void (event-driven per dunning stage) - recover(subscription) → void (clears dunning after payment) Data/DunningSchedule.php + Data/PaymentResult.php as readonly DTOs. Pest tests _Good/_Bad/_Ugly per AX-10 for all 5 methods. pint/pest skipped (vendor binaries missing in sandbox). Co-authored-by: Codex <noreply@openai.com> Closes tasks.lthn.sh/view.php?id=860
35 lines
774 B
PHP
35 lines
774 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Core\Mod\Commerce\Data;
|
|
|
|
use Carbon\Carbon;
|
|
|
|
/**
|
|
* Failed-payment retry and suspension dates for a subscription.
|
|
*/
|
|
readonly class DunningSchedule
|
|
{
|
|
/**
|
|
* @param array<int, Carbon> $retryDates
|
|
*/
|
|
public function __construct(
|
|
public array $retryDates,
|
|
public Carbon $suspensionDate,
|
|
) {}
|
|
|
|
/**
|
|
* @return array{retry_dates: array<int, string>, suspension_date: string}
|
|
*/
|
|
public function toArray(): array
|
|
{
|
|
return [
|
|
'retry_dates' => array_map(
|
|
fn (Carbon $date): string => $date->toISOString(),
|
|
$this->retryDates
|
|
),
|
|
'suspension_date' => $this->suspensionDate->toISOString(),
|
|
];
|
|
}
|
|
}
|