data->{$name} ?? null; } public function __isset(string $name): bool { return isset($this->data->{$name}); } public function id(): string { return $this->data->id; } /** * open, billed or voided (the STATUS_* constants). */ public function status(): string { return $this->data->status; } /** * Its bill is still open: the charge can be voided. */ public function isOpen(): bool { return $this->status() === self::STATUS_OPEN; } /** * Its bill was closed (paid, waiting for payment or cancelled): only a refund of the order by * Anikeen credits it. */ public function isBilled(): bool { return $this->status() === self::STATUS_BILLED; } public function isVoided(): bool { return $this->status() === self::STATUS_VOIDED; } /** * Net, e.g. "8.00". */ public function netAmount(): string { return $this->data->net_amount; } /** * Gross, what the charge added to the bill, e.g. "9.52". */ public function grossAmount(): string { return $this->data->gross_amount; } /** * The monthly bill (order) the charge is on, null once its line is gone (voided). */ public function orderId(): ?string { return $this->data->order_id ?? null; } /** * @return array */ public function metadata(): array { return (array) ($this->data->metadata ?? []); } public function occurredAt(): ?DateTimeImmutable { return isset($this->data->occurred_at) ? new DateTimeImmutable($this->data->occurred_at) : null; } public function toArray(): array { return (array) $this->data; } public function jsonSerialize(): array { return $this->toArray(); } }