| 123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace App\Data\Pagarme\Response\PagarmeOrderResponseData\PagarmeOrderChargeResponseData;
- final readonly class PagarmeOrderTransactionResponseData
- {
- public function __construct(
- public ?string $id,
- public ?string $status,
- public ?int $amount,
- public ?string $createdAt,
- public ?string $acquirerMessage,
- public array $gatewayResponse,
- ) {}
- public static function fromArray(array $payload): self
- {
- return new self(
- id: $payload['id'] ?? null,
- status: $payload['status'] ?? null,
- amount: isset($payload['amount']) ? (int) $payload['amount'] : null,
- createdAt: $payload['created_at'] ?? null,
- acquirerMessage: $payload['acquirer_message'] ?? null,
- gatewayResponse: $payload['gateway_response'] ?? [],
- );
- }
- public function toArray(): array
- {
- return [
- 'id' => $this->id,
- 'status' => $this->status,
- 'amount' => $this->amount,
- 'created_at' => $this->createdAt,
- 'acquirer_message' => $this->acquirerMessage,
- 'gateway_response' => $this->gatewayResponse,
- ];
- }
- }
|