FleetCart/Modules/Payment/GatewayResponse.php
2023-12-03 14:07:47 +00:00

35 lines
617 B
PHP

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