4 +--------------------------------------------------------------------+
6 +--------------------------------------------------------------------+
7 | This file is a part of CiviCRM. |
9 | CiviCRM is free software; you can copy, modify, and distribute it |
10 | under the terms of the GNU Affero General Public License |
11 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | CiviCRM is distributed in the hope that it will be useful, but |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
16 | See the GNU Affero General Public License for more details. |
18 | You should have received a copy of the GNU Affero General Public |
19 | License and the CiviCRM Licensing Exception along |
20 | with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
28 * Licensed to CiviCRM under the Academic Free License version 3.0
29 * Written & Contributed by Dolphin Software P/L - March 2008
31 * 'eWAY_GatewayResponse.php' - Loosley based on the standard supplied eWay sample code 'GatewayResponse.php'
33 * The 'simplexml_load_string' has been removed as it was causing major issues
34 * with Drupal V5.7 / CiviCRM 1.9 installtion's Home page.
35 * Filling the Home page with "Warning: session_start() [function.session-start]: Node no longer exists in ..." messages
37 * Found web reference indicating 'simplexml_load_string' was a probable cause.
38 * As soon as 'simplexml_load_string' was removed the problem fixed itself.
40 * Additionally the '$txStatus' var has been set as a string rather than a boolean.
41 * This is because the returned $params['trxn_result_code'] is in fact a string and not a boolean.
43 class GatewayResponse
{
45 public $txTransactionNumber = "";
46 public $txInvoiceReference = "";
47 public $txOption1 = "";
48 public $txOption2 = "";
49 public $txOption3 = "";
50 public $txStatus = "";
51 public $txAuthCode = "";
53 public $txBeagleScore = "";
55 public function __construct() {
59 public function ProcessResponse($Xml) {
60 //$xtr = simplexml_load_string($Xml) or die ("Unable to load XML string!");
62 //$this->txError = $xtr->ewayTrxnError;
63 //$this->txStatus = $xtr->ewayTrxnStatus;
64 //$this->txTransactionNumber = $xtr->ewayTrxnNumber;
65 //$this->txOption1 = $xtr->ewayTrxnOption1;
66 //$this->txOption2 = $xtr->ewayTrxnOption2;
67 //$this->txOption3 = $xtr->ewayTrxnOption3;
68 //$this->txAmount = $xtr->ewayReturnAmount;
69 //$this->txAuthCode = $xtr->ewayAuthCode;
70 //$this->txInvoiceReference = $xtr->ewayTrxnReference;
72 $this->txError
= self
::GetNodeValue("ewayTrxnError", $Xml);
73 $this->txStatus
= self
::GetNodeValue("ewayTrxnStatus", $Xml);
74 $this->txTransactionNumber
= self
::GetNodeValue("ewayTrxnNumber", $Xml);
75 $this->txOption1
= self
::GetNodeValue("ewayTrxnOption1", $Xml);
76 $this->txOption2
= self
::GetNodeValue("ewayTrxnOption2", $Xml);
77 $this->txOption3
= self
::GetNodeValue("ewayTrxnOption3", $Xml);
78 $amount = self
::GetNodeValue("ewayReturnAmount", $Xml);
79 $this->txAuthCode
= self
::GetNodeValue("ewayAuthCode", $Xml);
80 $this->txInvoiceReference
= self
::GetNodeValue("ewayTrxnReference", $Xml);
81 $this->txBeagleScore
= self
::GetNodeValue("ewayBeagleScore", $Xml);
82 $this->txAmount
= (int) $amount;
86 * Simple function to use in place of the 'simplexml_load_string' call.
88 * It returns the NodeValue for a given NodeName
89 * or returns and empty string.
91 public function GetNodeValue($NodeName, &$strXML) {
92 $OpeningNodeName = "<" . $NodeName . ">";
93 $ClosingNodeName = "</" . $NodeName . ">";
95 $pos1 = stripos($strXML, $OpeningNodeName);
96 $pos2 = stripos($strXML, $ClosingNodeName);
98 if (($pos1 === FALSE) ||
($pos2 === FALSE)) {
102 $pos1 +
= strlen($OpeningNodeName);
103 $len = $pos2 - $pos1;
105 $return = substr($strXML, $pos1, $len);
110 public function TransactionNumber() {
111 return $this->txTransactionNumber
;
114 public function InvoiceReference() {
115 return $this->txInvoiceReference
;
118 public function Option1() {
119 return $this->txOption1
;
122 public function Option2() {
123 return $this->txOption2
;
126 public function Option3() {
127 return $this->txOption3
;
130 public function AuthorisationCode() {
131 return $this->txAuthCode
;
134 public function Error() {
135 return $this->txError
;
138 public function Amount() {
139 return $this->txAmount
;
142 public function Status() {
143 return $this->txStatus
;
146 public function BeagleScore () {
147 return $this->txBeagleScore
;