diff --git a/src/Processor.php b/src/Processor.php index 04c6af5..4b7ba44 100644 --- a/src/Processor.php +++ b/src/Processor.php @@ -4,8 +4,24 @@ class Processor { + /** + * Determine if the request is valid. If so, process the + * transaction via the Moneris API. + * + * @param \CraigPaul\Moneris\Transaction $transaction + * + * @return \CraigPaul\Moneris\Response + */ public static function process(Transaction $transaction) { - return new Response(); + if ($transaction->invalid()) { + $response = new Response($transaction); + $response->status = Response::INVALID_TRANSACTION_DATA; + $response->successful = false; + + return $response; + } + + return new Response($transaction); } } \ No newline at end of file diff --git a/src/Response.php b/src/Response.php index fc770d3..a240c80 100644 --- a/src/Response.php +++ b/src/Response.php @@ -2,7 +2,45 @@ namespace CraigPaul\Moneris; +/** + * CraigPaul\Moneris\Response + * + * @property null|int $status + * @property bool $successful + * @property \CraigPaul\Moneris\Transaction $transaction + */ class Response { + use Gettable, Settable; + const INVALID_TRANSACTION_DATA = 0; + + /** + * The status code. + * + * @var null|int + */ + protected $status = null; + + /** + * Determines whether the response was successful. + * + * @var bool + */ + protected $successful = true; + + /** + * @var \CraigPaul\Moneris\Transaction + */ + protected $transaction; + + /** + * Create a new Response instance. + * + * @param \CraigPaul\Moneris\Transaction $transaction + */ + public function __construct(Transaction $transaction) + { + $this->transaction = $transaction; + } } \ No newline at end of file