1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91:
<?php
namespace Omnipay\VivaPayments\Message;
use Omnipay\Common\Message\AbstractResponse;
use Omnipay\Common\Message\RequestInterface;
class RestResponse extends AbstractResponse
{
protected $statusCode;
public function __construct(RequestInterface $request, $data, $statusCode = 200)
{
parent::__construct($request, $data);
$this->statusCode = $statusCode;
}
public function isRedirect()
{
return false;
}
public function isSuccessful()
{
if ($this->getCode() >= 400) {
return false;
}
if (! empty($this->data['ErrorCode'])) {
return false;
}
if ($this->isRedirect()) {
return false;
}
return true;
}
public function getTransactionReference()
{
if (! empty($this->data['TransactionId'])) {
return $this->data['TransactionId'];
}
if (! empty($this->data['OrderCode'])) {
return $this->data['OrderCode'];
}
return null;
}
public function getMessage()
{
if (isset($this->data['ErrorText'])) {
return $this->data['ErrorText'];
}
if (isset($this->data['Message'])) {
return $this->data['Message'];
}
return null;
}
public function getCode()
{
if (isset($this->data['ErrorCode'])) {
return $this->data['ErrorCode'];
}
return $this->statusCode;
}
}