/**
  * This method processes the response from the secure card data service that
  * should get us a card alias to use further on.
  *
  * @param Customweb_Saferpay_Authorization_Transaction $transaction
  * @param array $parameters
  */
 protected function processScdResponse(Customweb_Saferpay_Authorization_Transaction $transaction, $parameters)
 {
     if ($transaction->isUseExistingAlias()) {
         $transaction->setCardRefId($transaction->getTransactionContext()->getAlias()->getCardRefId());
         $transaction->setOwnerName($parameters[Customweb_Saferpay_Method_PaymentMethodWrapper::FORM_KEY_OWNER_NAME]);
         if ($this->getPaymentMethodWrapper($transaction->getTransactionContext()->getOrderContext())->is3DSecureSupported()) {
             $transaction->setCardExpiryDate($parameters['sfpCardExpiryMonth'], $parameters['sfpCardExpiryYear']);
             if (!$this->getConfiguration()->isUseMotoAccountForAlias()) {
                 return $this->request3DSecure($transaction, $parameters);
             }
         }
         return $this->requestAuthorization($transaction);
     } else {
         $parameters = $this->parseRequestParameters($parameters);
         if ($parameters['RESULT'] == 0) {
             $transaction->setCardRefId($parameters['CARDREFID']);
             $transaction->setTruncatedPAN($parameters['CARDMASK']);
             $transaction->setOwnerName($parameters[Customweb_Saferpay_Method_PaymentMethodWrapper::FORM_KEY_OWNER_NAME]);
             if ($this->getPaymentMethodWrapper($transaction->getTransactionContext()->getOrderContext())->is3DSecureSupported()) {
                 $transaction->setCardExpiryDate($parameters['EXPIRYMONTH'], $parameters['EXPIRYYEAR']);
                 return $this->request3DSecure($transaction, $parameters);
             }
             return $this->requestAuthorization($transaction);
         } else {
             $userMessage = Customweb_Saferpay_Util::getUserErrorMessage($parameters['DESCRIPTION']);
             $backendMessage = Customweb_I18n_Translation::__("Server responded '!response'", array('!response' => $parameters['DESCRIPTION']));
             $transaction->setAuthorizationFailed(new Customweb_Payment_Authorization_ErrorMessage($userMessage, $backendMessage));
             $this->redirect(null, $transaction, $this->getFailedUrl($transaction));
         }
     }
 }
 /**
  * Copy important data from the initial transaction to the new transaction.
  * 
  * @param Customweb_Saferpay_Authorization_Transaction $initialTransaction
  * @param Customweb_Saferpay_Authorization_Transaction $recurringTransaction
  */
 protected function useInitialTransactionData(Customweb_Saferpay_Authorization_Transaction $initialTransaction, Customweb_Saferpay_Authorization_Transaction $recurringTransaction)
 {
     $recurringTransaction->setCardRefId($initialTransaction->getCardRefId());
     $recurringTransaction->setCardExpiryDate($initialTransaction->getCardExpiryMonth(), $initialTransaction->getCardExpiryYear());
     $recurringTransaction->setOwnerName($initialTransaction->getOwnerName());
     $recurringTransaction->setTruncatedPAN($initialTransaction->getTruncatedPAN());
     $recurringTransaction->setMpiSessionId(null);
 }