protected function processTransactionBase(CSV_SOAP $sSOAPClient, $szMessageXMLPath, $szGatewayOutputXMLPath, $szTransactionMessageXMLPath, SimpleXMLElement &$sxXmlDocument = null, CSV_GatewayOutput &$goGatewayOutput = null, CSV_GatewayEntryPointList &$lgepGatewayEntryPoints = null)
 {
     $boTransactionSubmitted = false;
     $nOverallRetryCount = 0;
     $nOverallGatewayEntryPointCount = 0;
     $nGatewayEntryPointCount = 0;
     $nErrorMessageCount = 0;
     $rgepCurrentGatewayEntryPoint;
     $nStatusCode;
     $szMessage = null;
     $lszErrorMessages;
     $szString;
     $sbXMLString;
     $szXMLFormatString;
     $nCount = 0;
     $szEntryPointURL;
     $nMetric;
     $gepGatewayEntryPoint = null;
     $ResponseDocument = null;
     $ResponseMethod = null;
     $lgepGatewayEntryPoints = null;
     $goGatewayOutput = null;
     $this->m_szEntryPointUsed = null;
     if ($sSOAPClient == null) {
         return false;
     }
     // populate the merchant details
     if ($this->m_maMerchantAuthentication != null) {
         if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_maMerchantAuthentication->getMerchantID())) {
             $sSOAPClient->addParamAttribute($szMessageXMLPath . '.MerchantAuthentication', 'MerchantID', $this->m_maMerchantAuthentication->getMerchantID());
         }
         if (!CSV_SharedFunctions::isStringNullOrEmpty($this->m_maMerchantAuthentication->getPassword())) {
             $sSOAPClient->addParamAttribute($szMessageXMLPath . '.MerchantAuthentication', 'Password', $this->m_maMerchantAuthentication->getPassword());
         }
     }
     // first need to sort the gateway entry points into the correct usage order
     $number = $this->m_lrgepRequestGatewayEntryPoints->sort('CSV_GatewayTransaction', 'Compare');
     // loop over the overall number of transaction attempts
     while (!$boTransactionSubmitted && $nOverallRetryCount < $this->m_nRetryAttempts) {
         $nOverallGatewayEntryPointCount = 0;
         // loop over the number of gateway entry points in the list
         while (!$boTransactionSubmitted && $nOverallGatewayEntryPointCount < $this->m_lrgepRequestGatewayEntryPoints->getCount()) {
             $rgepCurrentGatewayEntryPoint = $this->m_lrgepRequestGatewayEntryPoints->getAt($nOverallGatewayEntryPointCount);
             // ignore if the metric is "-1" this indicates that the entry point is offline
             if ($rgepCurrentGatewayEntryPoint->getMetric() >= 0) {
                 $nGatewayEntryPointCount = 0;
                 $sSOAPClient->setURL($rgepCurrentGatewayEntryPoint->getEntryPointURL());
                 // loop over the number of times to try this specific entry point
                 while (!$boTransactionSubmitted && $nGatewayEntryPointCount < $rgepCurrentGatewayEntryPoint->getRetryAttempts()) {
                     if ($sSOAPClient->sendRequest($ResponseDocument, $ResponseMethod)) {
                         //getting the valid transaction type document format
                         $sxXmlDocument = $ResponseDocument->{$ResponseMethod};
                         $lszErrorMessages = new CSV_StringList();
                         $nStatusCode = (int) current($ResponseDocument->{$ResponseMethod}->{$szGatewayOutputXMLPath}->StatusCode[0]);
                         // a status code of 50 means that this entry point is not to be used
                         if ($nStatusCode != 50) {
                             $this->m_szEntryPointUsed = $rgepCurrentGatewayEntryPoint->getEntryPointURL();
                             // the transaction was submitted
                             $boTransactionSubmitted = true;
                             if ($ResponseDocument->{$ResponseMethod}->{$szGatewayOutputXMLPath}->Message) {
                                 $szMessage = current($ResponseDocument->{$ResponseMethod}->{$szGatewayOutputXMLPath}->Message[0]);
                             }
                             if ($ResponseDocument->{$ResponseMethod}->{$szGatewayOutputXMLPath}->ErrorMessages) {
                                 foreach ($ResponseDocument->{$ResponseMethod}->{$szGatewayOutputXMLPath}->ErrorMessages->MessageDetail as $key => $value) {
                                     $lszErrorMessages->add(current($value->Detail));
                                 }
                             }
                             $goGatewayOutput = new CSV_GatewayOutput($nStatusCode, $szMessage, $lszErrorMessages);
                             // look to see if there are any gateway entry points
                             $nCount = 0;
                             $nMetric = -1;
                             if ($ResponseDocument->{$ResponseMethod}->{$szTransactionMessageXMLPath}->GatewayEntryPoints) {
                                 if ($ResponseDocument->{$ResponseMethod}->{$szTransactionMessageXMLPath}->GatewayEntryPoints->GatewayEntryPoint) {
                                     $szXMLFormatString = $ResponseDocument->{$ResponseMethod}->{$szTransactionMessageXMLPath}->GatewayEntryPoints->GatewayEntryPoint;
                                     foreach ($szXMLFormatString->attributes() as $key => $value) {
                                         if (is_numeric(current($value))) {
                                             $nMetric = current($value);
                                         } else {
                                             $szEntryPointURL = current($value);
                                         }
                                     }
                                     //$gepGatewayEntryPoint = new CSV_GatewayEntryPoint($szEntryPointURL, $nMetric);
                                     if ($lgepGatewayEntryPoints == null) {
                                         $lgepGatewayEntryPoints = new CSV_GatewayEntryPointList();
                                     }
                                     $lgepGatewayEntryPoints->add($szEntryPointURL, $nMetric);
                                     //$lgepGatewayEntryPoints->add($gepGatewayEntryPoint);
                                 }
                             }
                             $nCount++;
                         }
                     }
                     $nGatewayEntryPointCount++;
                 }
             }
             $nOverallGatewayEntryPointCount++;
         }
         $nOverallRetryCount++;
     }
     $this->m_szLastRequest = $sSOAPClient->getSOAPPacket();
     $this->m_szLastResponse = $sSOAPClient->getLastResponse();
     $this->m_eLastException = $sSOAPClient->getLastException();
     return $boTransactionSubmitted;
 }
Beispiel #2
0
 public static function getStringListFromCharSeparatedString($szString, $cDelimiter)
 {
     $nCount = 0;
     $nLastCount = -1;
     $szSubString;
     $nStringLength;
     $lszStringList;
     if ($szString == null || $szString == "" || (string) $cDelimiter == "") {
         return null;
     }
     $lszStringList = new CSV_StringList();
     $nStringLength = strlen($szString);
     for ($nCount = 0; $nCount < $nStringLength; $nCount++) {
         if ($szString[$nCount] == $cDelimiter) {
             $szSubString = substr($szString, $nLastCount + 1, $nCount - $nLastCount - 1);
             $nLastCount = $nCount;
             $lszStringList->add($szSubString);
             if ($nCount == $nStringLength) {
                 $lszStringList->add('');
             }
         } else {
             if ($nCount == $nStringLength - 1) {
                 $szSubString = substr($szString, $nLastCount + 1, $nCount - $nLastCount);
                 $lszStringList->add($szSubString);
             }
         }
     }
     return $lszStringList;
 }