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

Commit

Permalink
Changes receipt reading methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig Paul committed Oct 25, 2016
1 parent df1adb4 commit f2958c7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ public static function create(Transaction $transaction)
/**
* Retrieve the transaction's receipt if it is available.
*
* @return \SimpleXMLElement|\SimpleXMLElement[]|null
* @return \CraigPaul\Moneris\Receipt|null
*/
public function receipt()
{
if (!is_null($response = $this->transaction->response)) {
return $response->receipt;
return new Receipt($response->receipt);
}

return null;
Expand All @@ -132,17 +132,17 @@ public function validate()
$receipt = $this->receipt();
$gateway = $this->transaction->gateway;

if ($receipt->ReceiptId === 'Global Error Receipt') {
if ($receipt->read('id') === 'Global Error Receipt') {
$this->status = Response::GLOBAL_ERROR_RECEIPT;
$this->successful = false;

return $this;
}

$code = (int)$receipt->ResponseCode;
$code = (int)$receipt->read('code');

if ($code >= 50 || $code === 0) {
switch ($receipt->ResponseCode) {
switch ($receipt->read('code')) {
case '050':
case '074':
case 'null':
Expand Down Expand Up @@ -192,7 +192,7 @@ public function validate()
return $this;
}

$code = isset($receipt->AvsResultCode) ? (string)$receipt->AvsResultCode : false;
$code = $receipt->read('avs_result') ?? false;

if ($gateway->avs && $code && $code !== 'null' && !in_array($code, $gateway->avsCodes)) {
switch ($code) {
Expand Down Expand Up @@ -224,7 +224,7 @@ public function validate()
return $this;
}

$code = isset($receipt->CvdResultCode) ? (string)$receipt->CvdResultCode : null;
$code = $receipt->read('cvd_result') ?? null;

if ($gateway->avs && !is_null($code) && $code !== 'null' && !in_array($code{1}, $gateway->cvdCodes)) {
$this->status = Response::CVD;
Expand Down

0 comments on commit f2958c7

Please sign in to comment.