FleetCart/Modules/Payment/GatewayResponse.php

32 lines
611 B
PHP
Raw Permalink Normal View History

2023-06-11 12:14:03 +00:00
<?php
namespace Modules\Payment;
use JsonSerializable;
abstract class GatewayResponse implements JsonSerializable
{
abstract public function getOrderId();
public function toArray()
{
$data = ['orderId' => $this->getOrderId()];
if ($this instanceof ShouldRedirect) {
$data['redirectUrl'] = $this->getRedirectUrl();
}
return $data;
}
public function jsonSerialize()
{
return $this->toArray();
}
public function __toString()
{
return json_encode($this->jsonSerialize());
}
}