Example #1
0
 public function getFormActionUrl(Customweb_Payment_Authorization_ITransaction $transaction)
 {
     if ($transaction->isUseExistingAlias()) {
         return $this->container->getBean('Customweb_Payment_Endpoint_IAdapter')->getUrl("process", 'index', array('cw_transaction_id' => $transaction->getExternalTransactionId()));
     } else {
         $builder = new Customweb_Saferpay_Authorization_Hidden_ParameterBuilder($transaction, $this->getConfiguration(), $this->container);
         $parameters = $builder->buildRegisterCardParameters();
         $requestUrl = Customweb_Saferpay_Util::addParametersToUrl($this->getCreatePayInitUrl(), $parameters);
         return Customweb_Saferpay_Util::sendRequest($requestUrl);
     }
 }
Example #2
0
 private function getFormActionUrl(Customweb_Payment_Authorization_ITransaction $transaction)
 {
     $builder = new Customweb_Saferpay_Authorization_Hidden_ParameterBuilder($transaction, $this->getConfiguration(), $this->container);
     $parameters = $builder->buildRegisterCardParameters();
     $requestUrl = Customweb_Saferpay_Util::addParametersToUrl($this->getCreatePayInitUrl(), $parameters);
     return Customweb_Saferpay_Util::sendRequest($requestUrl);
 }
 /**
  * This method issues an autorization request for the transaction.
  * If the capturing mode is "Direct" the transaction gets captured after
  * a sucessfull authorization.
  *
  * @param Customweb_Saferpay_Authorization_Transaction $transaction
  */
 protected function requestAuthorization(Customweb_Saferpay_Authorization_Transaction $transaction, array $additionalParameters = array())
 {
     if (!isset($additionalParameters['CVC'])) {
         $isAliasWithAddressCheck = $transaction->isUseExistingAlias() && $this->getConfiguration()->getCardVerificationMode() != 'cvc';
         $isCreditCard = $this->getPaymentMethodWrapperFromPaymentMethod($transaction->getPaymentMethod()) instanceof Customweb_Saferpay_Method_CreditCardWrapper;
         $isMoto = strtolower($transaction->getAuthorizationMethod()) == strtolower(Customweb_Payment_Authorization_Moto_IAdapter::AUTHORIZATION_METHOD_NAME);
         $isRecurring = strtolower($transaction->getAuthorizationMethod()) == strtolower(Customweb_Payment_Authorization_Recurring_IAdapter::AUTHORIZATION_METHOD_NAME);
         if (!$isAliasWithAddressCheck && !$isMoto && !$isRecurring && $isCreditCard) {
             $message = Customweb_I18n_Translation::__("No CVC provided.");
             $transaction->setAuthorizationFailed($message);
             $this->redirect(null, $transaction, $this->getFailedUrl($transaction));
             return;
         }
     }
     // 		&& !isset($additionalParameters['IBAN'])
     $builder = new Customweb_Saferpay_Authorization_Hidden_ParameterBuilder($transaction, $this->getConfiguration(), $this->container);
     $sendParameters = $builder->buildParameters($additionalParameters);
     $requestUrl = Customweb_Saferpay_Util::addParametersToUrl($this->getExecuteUrl(), $sendParameters);
     $response = Customweb_Saferpay_Util::sendRequest($requestUrl);
     $parameters = $this->getXmlParameters($response);
     $transaction->resetKey();
     if ($parameters['RESULT'] == 0 && $this->isTransactionValidState($transaction)) {
         $transaction->setPaymentId($parameters['ID']);
         $transaction->setAuthorizationParameters($parameters);
         $transaction->authorize();
         if (isset($parameters['ECI']) && $parameters['ECI'] != self::ECI_NO_LIABILITY_SHIFT) {
             $transaction->setState3DSecure(Customweb_Saferpay_Authorization_Transaction::STATE_3D_SECURE_SUCCESS);
         }
         if ($this->getConfiguration()->isMarkLiabilityShiftTransactions() && $transaction->getAuthorizationMethod() != Customweb_Payment_Authorization_Recurring_IAdapter::AUTHORIZATION_METHOD_NAME && !$transaction->isUseExistingAlias() && !$transaction->isMoto()) {
             if ((!isset($parameters['ECI']) || $parameters['ECI'] == self::ECI_NO_LIABILITY_SHIFT) && !$this->getPaymentMethodWrapper($transaction->getTransactionContext()->getOrderContext())->isEciMeaningless()) {
                 $transaction->setAuthorizationUncertain();
             }
         }
         // In case the shop system request a new alias, we mark this transaction as a alias source.
         $transactionContext = $transaction->getTransactionContext();
         if (!($transactionContext instanceof Customweb_Payment_Authorization_Recurring_ITransactionContext && $transactionContext->getInitialTransaction() != null)) {
             if ($transaction->getTransactionContext()->getAlias() !== null || $transaction->getTransactionContext()->createRecurringAlias()) {
                 if ($transaction->getTransactionContext()->getAlias() != 'new' && !isset($parameters['PAN'])) {
                     $transaction->setAliasForDisplay($transaction->getTransactionContext()->getAlias()->getAliasForDisplay());
                     $transaction->addAuthorizationParameters(array('PAN' => $transaction->getTransactionContext()->getAlias()->getAliasForDisplay()));
                 } else {
                     if (isset($parameters['PAN'])) {
                         $transaction->setAliasForDisplay($parameters['PAN']);
                     } else {
                         if (isset($parameters['IBAN'])) {
                             $transaction->setAliasForDisplay(Customweb_Saferpay_Util::maskIban($parameters['IBAN']));
                         } else {
                             throw new Exception('PAN or IBAN must be set, none given.');
                         }
                     }
                 }
                 $this->setAliasAddress($transaction);
             }
         }
         if ($transaction->getTransactionContext()->getCapturingMode() == null) {
             $capturingMode = $this->getPaymentMethodWrapper($transaction->getTransactionContext()->getOrderContext())->getPaymentMethodConfigurationValue('capturing');
         } else {
             $capturingMode = $transaction->getTransactionContext()->getCapturingMode();
         }
         if (!$transaction->isAuthorizationUncertain() && $capturingMode == Customweb_Payment_Authorization_ITransactionContext::CAPTURING_MODE_DIRECT) {
             $this->captureTransaction($transaction);
         }
         $this->redirect(null, $transaction, $this->getSuccessUrl($transaction));
     } else {
         $userMessage = Customweb_Saferpay_Util::getUserErrorMessage($parameters['AUTHMESSAGE']);
         $backendMessage = Customweb_I18n_Translation::__("Saferpay authorization responded with : !result '!authmessage'", array('!result' => $parameters['RESULT'], '!authmessage' => $parameters['AUTHMESSAGE']));
         $transaction->setAuthorizationFailed(new Customweb_Payment_Authorization_ErrorMessage($userMessage, $backendMessage));
         $this->redirect(null, $transaction, $this->getFailedUrl($transaction));
     }
 }