/** * Constructs a new error with the given error code and error message. * @private * * @param code * The error code associated with this error. This should be a * valid integer. * @param message * The error message associated with this error. This is an alphanumeric string. This should not * be null. */ function Error($code, $message) { $this->m_code = ErrorCode::parse($code); $this->m_message = $message; }
/** * Handles a start tag. * @private */ function elementStartHandler($parser, $name, $attrs) { $name = trim($name); array_push($this->m_tagStack, $name); if (empty($attrs)) { return; } if ($this->m_tagStack === array("RESPONSE")) { $this->m_serverName = $attrs["TYPE"]; $this->m_serverVersion = $attrs["VERSION"]; return; } if ($this->m_tagStack === array("RESPONSE", "CARDDETAILS", "ADDITIONALVERIFICATION", "ADDRESS")) { $this->m_addressResponseData = $attrs["RAW"]; return; } if ($this->m_tagStack === array("RESPONSE", "CARDDETAILS", "ADDITIONALVERIFICATION", "CSC")) { $this->m_cscResponseData = $attrs["RAW"]; return; } if ($this->m_tagStack === array("RESPONSE", "CARDDETAILS", "ADDITIONALVERIFICATION", "ZIP")) { $this->m_zipCodeResponseData = $attrs["RAW"]; return; } if ($this->m_tagStack === array("RESPONSE", "RESULT")) { if (!empty($attrs["DUPLICATE"])) { $this->m_duplicate = (bool) $attrs["DUPLICATE"]; } return; } if ($this->m_tagStack === array("RESPONSE", "CARDDETAILS", "ICC")) { $this->m_iccType = $attrs["TYPE"]; return; } if ($this->m_tagStack === array("RESPONSE", "CARDDETAILS", "ICC", "ICCTAG")) { $this->m_iccTags[] = new ICCTag($attrs["TAGID"], null); if (!empty($attrs["TYPE"])) { $this->m_iccTags[count($this->m_iccTags) - 1]->setType(ICCTagValueType::parse($attrs["TYPE"])); } return; } if ($this->m_tagStack === array("RESPONSE", "CARDDETAILS", "EXPIRYDATE")) { $this->m_expiryDateFormat = $attrs["FORMAT"]; return; } if ($this->m_tagStack === array("RESPONSE", "CARDDETAILS", "STARTDATE")) { $this->m_startDateFormat = $attrs["FORMAT"]; return; } if ($this->m_tagStack === array("RESPONSE", "ICCPUBLICKEYS")) { $this->m_iccPublicKeyType = $attrs["TYPE"]; $this->m_iccPublicKeyContent = $attrs["CONTENT"]; $this->m_iccPublicKeyClearExisting = (bool) $attrs["CLEAREXISTING"]; $this->m_iccPublicKeyReplaceExisting = (bool) $attrs["REPLACEEXISTING"]; return; } if ($this->m_tagStack === array("RESPONSE", "ICCPUBLICKEYS", "CERTIFICATIONAUTHORITY")) { $this->m_iccCertificationAuthorities[] = new CertificationAuthority($attrs["DESCRIPTION"], $attrs["RID"]); return; } if ($this->m_tagStack === array("RESPONSE", "ICCPUBLICKEYS", "CERTIFICATIONAUTHORITY", "PUBLICKEY")) { $this->m_iccCertificationAuthorities[count($this->m_iccCertificationAuthorities) - 1]->addPublicKey(new PublicKey($attrs["INDEX"], $attrs["HASH"], $attrs["HASHALGORITHM"])); return; } if ($this->m_tagStack === array("RESPONSE", "ICCPUBLICKEYS", "CERTIFICATIONAUTHORITY", "PUBLICKEY", "VALIDFROM")) { $publicKeys = $this->m_iccCertificationAuthorities[count($this->m_iccCertificationAuthorities) - 1]->getPublicKeys(); $publicKeys[count($publicKeys) - 1]->setValidFromDateFormat($attrs["FORMAT"]); $this->m_iccCertificationAuthorities[count($this->m_iccCertificationAuthorities) - 1]->setPublicKeys($publicKeys); return; } if ($this->m_tagStack === array("RESPONSE", "ICCPUBLICKEYS", "CERTIFICATIONAUTHORITY", "PUBLICKEY", "VALIDTO")) { $publicKeys = $this->m_iccCertificationAuthorities[count($this->m_iccCertificationAuthorities) - 1]->getPublicKeys(); $publicKeys[count($publicKeys) - 1]->setValidToDateFormat($attrs["FORMAT"]); $this->m_iccCertificationAuthorities[count($this->m_iccCertificationAuthorities) - 1]->setPublicKeys($publicKeys); return; } if ($this->m_tagStack === array("RESPONSE", "RESULT", "ERRORS", "ERROR")) { $this->m_lastErrorCode = ErrorCode::parse($attrs["CODE"]); return; } if ($this->m_tagStack === array("RESPONSE", "TRANSACTIONDETAILS", "GEOIP")) { if (!empty($attrs["IsBlackListed"])) { $this->m_originatingIPAddressIsBlackListed = (bool) $attrs["IsBlackListed"]; } if (!empty($attrs["IsKnownProxy"])) { $this->m_originatingIPAddressIsKnownProxy = (bool) $attrs["IsKnownProxy"]; } return; } if ($this->m_tagStack === array("RESPONSE", "TRANSACTIONDETAILS", "GEOIP", "CONTINENT")) { $this->m_originatingIPAddressContinentAlpha2 = $attrs["ALPHA2"]; return; } if ($this->m_tagStack === array("RESPONSE", "TRANSACTIONDETAILS", "GEOIP", "COUNTRY")) { $this->m_originatingIPAddressCountryAlpha2 = $attrs["ALPHA2"]; $this->m_originatingIPAddressCountryCode = $attrs["CODE"]; return; } if ($this->m_tagStack === array("RESPONSE", "TRANSACTIONDETAILS", "GEOIP", "REGION")) { $this->m_originatingIPAddressRegionCode = $attrs["CODE"]; return; } if ($this->m_tagStack === array("RESPONSE", "TRANSACTIONDETAILS", "LOCALDATETIME")) { $this->m_localDateTimeFormat = $attrs["FORMAT"]; return; } /* echo "<pre>"; echo print_r($this->m_tagStack, true); echo print_r($attrs, true); echo "</pre>"; */ // trigger_error("CardEaseXMLResponse: Unexpected response attrs: ".print_r($attrs, true), E_USER_WARNING); // trigger_error("CardEaseXMLResponse: Unexpected response attrs: ".print_r($this->m_tagStack, true), E_USER_ERROR); }