SilverStripe\Omnipay\Service\ServiceResponse
Class ServiceResponse.
A response generated by a service. This response holds several answer-related properties, such as
an HTTP Response, the response from the Omnipay gateway and several flags that give information about the
nature of this response
This should be used more of container that gives access to several parts that need to be transmitted
from the service to the application.
Do not implement application logic into service responses.
Synopsis
class ServiceResponse
{
- // constants
- const SERVICE_ERROR = 1;
- const SERVICE_PENDING = 2;
- const SERVICE_NOTIFICATION = 4;
- const SERVICE_CANCELLED = 8;
- // members
- protected AbstractResponse|NotificationInterface $omnipayResponse;
- protected integer $flags = 0;
- protected bool $isAwaitingNotification = false;
- protected Payment $payment;
- protected $targetUrl;
- protected HTTPResponse $httpResponse;
- // methods
- public void __construct()
- public Payment getPayment()
- public bool isRedirect()
- public boolean isError()
- public bool isAwaitingNotification()
- public bool isNotification()
- public bool isCancelled()
- public bool hasFlag()
- public $this addFlag()
- public $this removeFlag()
- public string getTargetUrl()
- public $this setTargetUrl()
- public AbstractResponse|NotificationInterface|null getOmnipayResponse()
- public $this setOmnipayResponse()
- public HTTPResponse redirectOrRespond()
- public HTTPResponse getHttpResponse()
- public $this setHttpResponse()
Constants
Name | Value |
---|---|
SERVICE_ERROR | 1 |
SERVICE_PENDING | 2 |
SERVICE_NOTIFICATION | 4 |
SERVICE_CANCELLED | 8 |
Members
protected
- $flags — int
- $httpResponse — SilverStripe\Control\HTTPResponse
- $isAwaitingNotification — SilverStripe\Omnipay\Service\bool
- $omnipayResponse — SilverStripe\Omnipay\Service\AbstractResponse|NotificationInterface
- $payment — SilverStripe\Omnipay\Model\Payment
- $targetUrl — string
Methods
public
- __construct() — Additional arguments will be treated as state flags
- addFlag() — Add a flag for this response.
- getHttpResponse() — Return the HTTP response given by this gateway.
- getOmnipayResponse() — Get the response given by the omnipay gateway.
- getPayment()
- getTargetUrl() — The target url where this response should redirect to (this will be used to redirect internally, if the response wasn't set specifically)
- hasFlag() — Check if the given flag(s) is set (active)
- isAwaitingNotification() — Whether or not the request is pending and waiting for an async notification.
- isCancelled() — Whether or not the payment was cancelled.
- isError() — Whether or not this response is an error-response.
- isNotification() — Whether or not this is a response to a notification.
- isRedirect() — Whether or not this is an *offsite* redirect.
- redirectOrRespond() — Create a redirect or a response.
- removeFlag() — Remove a flag from this response.
- setHttpResponse() — Set the HTTP response.
- setOmnipayResponse() — Set the response from Omnipay
- setTargetUrl() — Set the target url.