public static function getTransactionOutputMessage(SimpleXMLElement $sxXmlDocument, GatewayEntryPointList $lgepGatewayEntryPoints = null) { $szCrossReference = null; $crAddressNumericCheckResult = null; $crPostCodeCheckResult = null; $crThreeDSecureAuthenticationCheckResult = null; $crCV2CheckResult = null; $szAddressNumericCheckResult = null; $szPostCodeCheckResult = null; $szThreeDSecureAuthenticationCheckResult = null; $szCV2CheckResult = null; $nAmountReceived = null; $szPaREQ = null; $szACSURL = null; $nTempValue; $ctdCardTypeData = null; $tdsodThreeDSecureOutputData = null; $lgvCustomVariables = null; $nCount = 0; $sbString; $szXMLFormatString; $szName; $szValue; $gvGenericVariable; $nCount = 0; $szCardTypeData; $tomTransactionOutputMessage = null; if (!$sxXmlDocument->TransactionOutputData) { return null; } if ($sxXmlDocument->TransactionOutputData->attributes()) { foreach ($sxXmlDocument->TransactionOutputData->attributes() as $key => $value) { $szCrossReference = current($value); } } else { $szCrossReference = null; } if ($sxXmlDocument->TransactionOutputData->AuthCode) { $szAuthCode = current($sxXmlDocument->TransactionOutputData->AuthCode[0]); } else { $szAuthCode = null; } if ($sxXmlDocument->TransactionOutputData->AddressNumericCheckResult) { $crAddressNumericCheckResult = new NullableCHECK_RESULT(current($sxXmlDocument->TransactionOutputData->AddressNumericCheckResult[0])); } else { $crAddressNumericCheckResult = new NullableCHECK_RESULT(null); } if ($sxXmlDocument->TransactionOutputData->PostCodeCheckResult) { $crPostCodeCheckResult = new NullableCHECK_RESULT(current($sxXmlDocument->TransactionOutputData->PostCodeCheckResult[0])); } else { $crPostCodeCheckResult = new NullableCHECK_RESULT(null); } if ($sxXmlDocument->TransactionOutputData->ThreeDSecureAuthenticationCheckResult) { $crThreeDSecureAuthenticationCheckResult = new NullableCHECK_RESULT(current($sxXmlDocument->TransactionOutputData->ThreeDSecureAuthenticationCheckResult[0])); } else { $crThreeDSecureAuthenticationCheckResult = new NullableCHECK_RESULT(null); } if ($sxXmlDocument->TransactionOutputData->CV2CheckResult) { $crCV2CheckResult = new NullableCHECK_RESULT(current($sxXmlDocument->TransactionOutputData->CV2CheckResult[0])); } else { $crCV2CheckResult = new NullableCHECK_RESULT(null); } if ($sxXmlDocument->TransactionOutputData->CardTypeData) { $ctdCardTypeData = self::getCardTypeData($sxXmlDocument->TransactionOutputData->CardTypeData); } else { $ctdCardTypeData = null; } if ($sxXmlDocument->TransactionOutputData->AmountReceived) { $nAmountReceived = new NullableInt(current($sxXmlDocument->TransactionOutputData->AmountReceived[0])); } else { $nAmountReceived = new NullableInt(null); } if ($sxXmlDocument->TransactionOutputData->ThreeDSecureOutputData) { $szPaREQ = current($sxXmlDocument->TransactionOutputData->ThreeDSecureOutputData->PaREQ[0]); $szACSURL = current($sxXmlDocument->TransactionOutputData->ThreeDSecureOutputData->ACSURL[0]); } else { $szPaREQ = null; $szACSURL = null; } if (!SharedFunctions::isStringNullOrEmpty($szACSURL) && !SharedFunctions::isStringNullOrEmpty($szPaREQ)) { $tdsodThreeDSecureOutputData = new ThreeDSecureOutputData($szPaREQ, $szACSURL); } if ($sxXmlDocument->TransactionOutputData->CustomVariables->GenericVariable) { if ($lgvCustomVariables == null) { $lgvCustomVariables = new GenericVariableList(); } for ($nCount = 0; $nCount < count($sxXmlDocument->TransactionOutputData->CustomVariables->GenericVariable); $nCount++) { $szName = current($sxXmlDocument->TransactionOutputData->CustomVariables->GenericVariable[$nCount]->Name[0]); $szValue = current($sxXmlDocument->TransactionOutputData->CustomVariables->GenericVariable[$nCount]->Value[0]); $gvGenericVariable = new GenericVariable($szName, $szValue); $lgvCustomVariables->add($gvGenericVariable); } } else { $lgvCustomVariables = null; } $tomTransactionOutputMessage = new TransactionOutputMessage($szCrossReference, $szAuthCode, $crAddressNumericCheckResult, $crPostCodeCheckResult, $crThreeDSecureAuthenticationCheckResult, $crCV2CheckResult, $ctdCardTypeData, $nAmountReceived, $tdsodThreeDSecureOutputData, $lgvCustomVariables, $lgepGatewayEntryPoints); return $tomTransactionOutputMessage; }
public static function getPaymentMessageGatewayOutput($GatewayOutput, GatewayOutput $goGatewayOutput = null) { $nPreviousStatusCode = null; $szPreviousMessage = null; $ptdPreviousTransactionResult = null; $pmgoPaymentMessageGatewayOutput = null; $boAuthorisationAttempted = null; if ($GatewayOutput->attributes()) { try { $szAuthorisationAttempted = current($GatewayOutput->attributes()->AuthorisationAttempted); if (strtolower($boAuthorisationAttempted) == 'false') { $boAuthorisationAttempted = new NullableBool(false); } elseif (strtolower($boAuthorisationAttempted) == 'true') { $boAuthorisationAttempted = new NullableBool(true); } else { throw new Exception('Return value must be true or false'); } } catch (Exception $e) { $boAuthorisationAttempted = null; } } //check to see if there is any previous transaction data if ($GatewayOutput->PreviousTransactionResult->StatusCode) { $nPreviousStatusCode = new NullableInt(current($GatewayOutput->PreviousTransactionResult->StatusCode[0])); } if ($GatewayOutput->PreviousTransactionResult->Message) { $szPreviousMessage = current($GatewayOutput->PreviousTransactionResult->Message[0]); } if ($nPreviousStatusCode != null && !SharedFunctions::isStringNullOrEmpty($szPreviousMessage)) { $ptdPreviousTransactionResult = new PreviousTransactionResult($nPreviousStatusCode, $szPreviousMessage); } $pmgoPaymentMessageGatewayOutput = new PaymentMessageGatewayOutput($goGatewayOutput->getStatusCode(), $goGatewayOutput->getMessage(), $boAuthorisationAttempted, $ptdPreviousTransactionResult, $goGatewayOutput->getErrorMessages()); return $pmgoPaymentMessageGatewayOutput; }
public function addParam2(SOAPParameter $spSOAPParam, $boOverWriteValue) { $lszHierarchicalNames; $nCurrentIndex = 0; $szTagNameToFind; $szString; $nCount = 0; $nCount2 = 0; $lspParamList; $spWorkingSOAPParam; $spNewSOAPParam; $boFound = false; $lspaAttributeList; $spaAttribute; $spaNewAttribute; $spaSOAPParamAttributeList; // need to check the name of the incoming item to see if it is a // complex soap parameter $lszHierarchicalNames = new StringList(); $lszHierarchicalNames = SharedFunctions::getStringListFromCharSeparatedString($spSOAPParam->getName(), '.'); if ($lszHierarchicalNames->getCount() == 1) { $this->m_lspSOAPParamList->add($spSOAPParam); } else { $lspParamList = $this->m_lspSOAPParamList; //complex for ($nCount = 0; $nCount < $lszHierarchicalNames->getCount(); $nCount++) { // get the current tag name $szString = (string) $lszHierarchicalNames->getAt($nCount); //continuework $szTagNameToFind = SharedFunctions::getArrayNameAndIndex($szString, $nCurrentIndex); // first thing is to try to find the tag in the list if ($boFound || $nCount == 0) { // try to find this tag name in the list $spWorkingSOAPParam = Functions::isSOAPParamInParamList($lspParamList, $szTagNameToFind, $nCurrentIndex); if ($spWorkingSOAPParam == null) { $boFound = false; } else { $boFound = true; // is this the last item in the hierarchy? if ($nCount == $lszHierarchicalNames->getCount() - 1) { if ($boOverWriteValue) { // change the value $spWorkingSOAPParam->setValue($spSOAPParam->getValue()); } // add the attributes to the list for ($nCount2 = 0; $nCount2 < $spSOAPParam->getSOAPParamAttributeList()->getCount(); $nCount2++) { //$spaAttribute = $spaSOAPParamAttributeList[$nCount2]; $spaAttribute = $spSOAPParam->getSOAPParamAttributeList()->getAt($nCount2); if ($spaAttribute != null) { $spaNewAttribute = new SOAPParamAttribute($spaAttribute->getName(), $spaAttribute->getValue()); $spWorkingSOAPParam->getSOAPParamAttributeList()->add($spaNewAttribute); } } } $lspParamList = $spWorkingSOAPParam->getSOAPParamList(); } } if (!$boFound) { // is this the last tag? if ($nCount == $lszHierarchicalNames->getCount() - 1) { $lspaAttributeList = new SOAPParamAttributeList(); for ($nCount2 = 0; $nCount2 < $spSOAPParam->getSOAPParamAttributeList()->getCount(); $nCount2++) { $spaSOAPParamAttributeList = $spSOAPParam->getSOAPParamAttributeList(); $spaAttribute = $spaSOAPParamAttributeList->getAt($nCount2); if ($spaAttribute != null) { $spaNewAttribute = new SOAPParamAttribute($spaAttribute->getName(), $spaAttribute->getValue()); $lspaAttributeList->add($spaNewAttribute); } } $spNewSOAPParam = new SOAPParameter($szTagNameToFind, $spSOAPParam->getValue(), $lspaAttributeList); $lspParamList->add($spNewSOAPParam); } else { $spNewSOAPParam = new SOAPParameter($szTagNameToFind, '', null); $lspParamList->add($spNewSOAPParam); $lspParamList = $spNewSOAPParam->getSOAPParamList(); } } } } $this->m_boPacketBuilt = false; }
public static function getValue($szXMLVariable, $xtlTagList, &$szValue) { $boReturnValue = false; $lszHierarchicalNames; $szXMLTagName; $szLastXMLTagName; $nCount = 0; $xtCurrentTag = null; $xaXmlAttribute = null; $lXmlTagAttributeList; if (xtlTagList == null) { $szValue = null; return false; } $lszHierarchicalNames = new StringList(); $szValue = null; $lszHierarchicalNames = SharedFunctions::getStringListFromCharSeparatedString($szXMLVariable, '.'); if (count($lszHierarchicalNames) == 1) { $szXMLTagName = $lszHierarchicalNames->getAt(0); $xtCurrentTag = SharedFunctions::GetNamedTagInTagList($szXMLTagName, $xtlTagList); if ($xtCurrentTag != null) { $lXmlTagAttributeList = $xtCurrentTag->getAttributes(); $xaXmlAttribute = $lXmlTagAttributeList->getAt($szXMLTagName); if ($xaXmlAttribute != null) { $szValue = $xaXmlAttribute->getValue(); $boReturnValue = true; } else { $szValue = $xtCurrentTag->getContent(); $boReturnValue = true; } } } else { if (count($lszHierarchicalNames) > 1) { $szXMLTagName = $lszHierarchicalNames->getAt(0); $szLastXMLTagName = $lszHierarchicalNames->getAt($lszHierarchicalNames->getCount() - 1); // need to remove the last variable from the passed name for ($nCount = 1; $nCount < $lszHierarchicalNames->getCount() - 1; $nCount++) { $szXMLTagName .= "." . $lszHierarchicalNames->getAt($nCount); } $xtCurrentTag = SharedFunctions::getNamedTagInTagList($szXMLTagName, $xtlTagList); // first check the attributes of this tag if ($xtCurrentTag != null) { $lXmlTagAttributeList = $xtCurrentTag->getAttributes(); $xaXmlAttribute = $lXmlTagAttributeList->getXmlAttributeForAttributeName($szLastXMLTagName); if ($xaXmlAttribute != null) { $szValue = $xaXmlAttribute->getValue(); $boReturnValue = true; } else { // check to see if it's actually a tag $xtCurrentTag = SharedFunctions::getNamedTagInTagList($szLastXMLTagName, $xtCurrentTag->getChildTags()); if ($xtCurrentTag != null) { $szValue = SharedFunctions::replaceEntitiesInStringWithChars($xtCurrentTag->getContent()); $boReturnValue = true; } } } } } return $boReturnValue; }