$rawResponse */ public function __construct( public readonly string $status, public readonly array $rawResponse, public readonly string $txid = '', public readonly int $userid = 0, public readonly ?string $redirectUrl = null, public readonly ?string $errorMessage = null, public readonly ?string $customerMessage = null, public readonly ?string $errorCode = null, public readonly ?ShoppingPayment $shoppingPayment = null, ) {} public function isApproved(): bool { return $this->status === 'APPROVED'; } public function isRedirect(): bool { return $this->status === 'REDIRECT'; } public function isError(): bool { return $this->status === 'ERROR'; } public function isValid(): bool { return $this->status === 'VALID'; } /** @return array */ public function toArray(): array { return $this->rawResponse; } /** * @param array $response */ public static function fromResponse(array $response, ?ShoppingPayment $shoppingPayment = null): self { return new self( status: $response['status'] ?? 'UNKNOWN', rawResponse: $response, txid: (string) ($response['txid'] ?? ''), userid: (int) ($response['userid'] ?? 0), redirectUrl: $response['redirecturl'] ?? null, errorMessage: $response['errormessage'] ?? null, customerMessage: $response['customermessage'] ?? null, errorCode: $response['errorcode'] ?? null, shoppingPayment: $shoppingPayment, ); } }