public function processAuthorization(Customweb_Payment_Authorization_ITransaction $transaction, array $parameters) { if (!$transaction instanceof Customweb_Saferpay_Authorization_Transaction) { throw new Customweb_Core_Exception_CastException('Customweb_Saferpay_Authorization_Transaction'); } if ($transaction->isUseExistingAlias()) { $hiddenAdapter = new Customweb_Saferpay_Authorization_Hidden_Adapter($this->getConfiguration()->getConfigurationAdapter(), $this->getContainer()); $result = $hiddenAdapter->processAuthorization($transaction, $parameters); if ($transaction->getAuthorizationMethod() == Customweb_Payment_Authorization_Iframe_IAdapter::AUTHORIZATION_METHOD_NAME) { if ($result == 'redirect:' . $transaction->getSuccessUrl() || $result == 'redirect:' . $transaction->getFailedUrl()) { return 'redirect:' . Customweb_Util_Url::appendParameters($transaction->getTransactionContext()->getIframeBreakOutUrl(), $transaction->getTransactionContext()->getCustomParameters()); } } return $result; } if (!isset($parameters['DATA']) || empty($parameters['DATA'])) { return Customweb_Core_Http_Response::_("NO DATA parameter provided.")->setStatusCode(500); } if (!$this->validateCustomParameters($transaction, $parameters)) { $reason = Customweb_I18n_Translation::__("Custom parameters have been altered. Fraud possible, aborting."); $transaction->setAuthorizationFailed($reason); return 'redirect:' . $this->getFailedUrl($transaction); } try { $parameters = $this->parseRequestParameters($parameters); } catch (Exception $e) { $transaction->setAuthorizationParameters($parameters); $transaction->setAuthorizationFailed($e->getMessage()); return 'redirect:' . $this->getFailedUrl($transaction); } $transaction->setPaymentInformation($this->getPaymentMethodWrapper($transaction->getTransactionContext()->getOrderContext())->extractPaymentInformation($parameters)); if ($this->validateParameters($transaction, $parameters)) { // Check transaction state $transaction->authorizeDry(); if (isset($parameters['PAYMENTMETHOD']) && !empty($parameters['PAYMENTMETHOD'])) { $paymentMachineName = Customweb_Saferpay_Method_PaymentMethodWrapper::getPaymentMethodMachineNameByPaymentMethodId($parameters['PAYMENTMETHOD']); $transaction->setEffectivePaymentMethodMachineName($paymentMachineName); } $transaction->setPaymentId($parameters['ID']); if (isset($parameters['ECI']) && $parameters['ECI'] != 0) { $transaction->setState3DSecure(Customweb_Payment_Authorization_DefaultTransaction::STATE_3D_SECURE_SUCCESS); } if ($this->getConfiguration()->isMarkLiabilityShiftTransactions()) { if ((!isset($parameters['ECI']) || $parameters['ECI'] == 0) && !$this->getPaymentMethodWrapper($transaction->getTransactionContext()->getOrderContext())->isEciMeaningless()) { $transaction->setAuthorizationUncertain(); } } if (isset($parameters['CARDREFID'])) { $transaction->setCardRefId($parameters['CARDREFID']); } if (isset($parameters['CARDMASK'])) { $transaction->setTruncatedPAN($parameters['CARDMASK']); $transaction->setAliasForDisplay($parameters['CARDMASK']); $this->setAliasAddress($transaction); $parameters['PAN'] = $parameters['CARDMASK']; } if (isset($parameters[Customweb_Saferpay_Method_PaymentMethodWrapper::FORM_KEY_OWNER_NAME])) { $transaction->setOwnerName($parameters[Customweb_Saferpay_Method_PaymentMethodWrapper::FORM_KEY_OWNER_NAME]); } // $transaction->setOwnerName($parameters[Customweb_Saferpay_Method_PaymentMethodWrapper::FORM_KEY_OWNER_NAME]); if (isset($parameters['EXPIRYMONTH']) && isset($parameters['EXPIRYYEAR'])) { $transaction->setCardExpiryDate($parameters['EXPIRYMONTH'], $parameters['EXPIRYYEAR']); } $transaction->authorize(Customweb_I18n_Translation::__('Customer sucessfully returned from the Saferpay payment page.')); if ($transaction->getTransactionContext()->getCapturingMode() == null) { $capturingMode = $this->getPaymentMethodWrapper($transaction->getTransactionContext()->getOrderContext())->getPaymentMethodConfigurationValue('capturing'); } else { $capturingMode = $transaction->getTransactionContext()->getCapturingMode(); } $transaction->setAuthorizationParameters($parameters); if (!$transaction->isAuthorizationUncertain() && $capturingMode == Customweb_Payment_Authorization_ITransactionContext::CAPTURING_MODE_DIRECT) { $this->captureTransaction($transaction); } } else { $transaction->setAuthorizationParameters($parameters); $transaction->setAuthorizationFailed(Customweb_I18n_Translation::__('Possible fraud detected. Parameters send from Saferpay were not correct.')); } return $this->finalizeAuthorizationRequest($transaction); }