Skip to content
This repository has been archived by the owner on Oct 30, 2020. It is now read-only.

Commit

Permalink
Updates processor to handle invalid transactions. Adds skeleton for r…
Browse files Browse the repository at this point in the history
…esponse class
  • Loading branch information
Craig Paul committed Oct 19, 2016
1 parent 88cf5c0 commit dc72200
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
38 changes: 38 additions & 0 deletions src/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit dc72200

Please sign in to comment.