コード例 #1
0
 /**
  * Called when iframe/pp fails, as PSP does not send a notification
  * @Action("fail")
  */
 public function fail(Customweb_Payment_Authorization_ITransaction $transaction, Customweb_Core_Http_IRequest $request)
 {
     if (!$transaction instanceof Customweb_Saferpay_Authorization_Transaction) {
         throw new Customweb_Core_Exception_CastException('Customweb_Saferpay_Authorization_Transaction');
     }
     if (!$transaction->isAuthorizationFailed() && !$transaction->isAuthorized()) {
         $message = new Customweb_Payment_Authorization_ErrorMessage(Customweb_I18n_Translation::__("The payment could not be processed."), Customweb_I18n_Translation::__("The payment failed."));
         $transaction->setAuthorizationFailed($message);
     }
     $url = $this->getAdapterFactory()->getAuthorizationAdapterByName($transaction->getAuthorizationMethod())->getFailedUrl($transaction);
     return Customweb_Core_Http_Response::redirect($url);
 }
コード例 #2
0
 public function authenticate(Customweb_Payment_ExternalCheckout_IContext $context, $emailAddress, $successUrl)
 {
     if (!$context instanceof Customweb_SaferpayCw_Model_ExternalCheckoutContext) {
         throw new Customweb_Core_Exception_CastException('Customweb_SaferpayCw_Model_ExternalCheckoutContext');
     }
     if ($context->getBillingAddress() === null) {
         throw new Exception("The authenticate method can not be called before the billing address is set on the context.");
     }
     $this->redirectOnEmptyBasket();
     $quote = $context->getQuote();
     if (Mage::getSingleton('customer/session')->isLoggedIn()) {
         $context->updateFromQuote($quote);
         $context->save();
         return Customweb_Core_Http_Response::redirect($successUrl);
     }
     if ($quote->isAllowedGuestCheckout() && Mage::getStoreConfig('saferpaycw/general/external_checkout_account_creation') == 'skip_selection') {
         Mage::helper('SaferpayCw/externalCheckout')->validateCustomerData($quote, array('email' => $emailAddress, 'firstname' => $context->getBillingAddress()->getFirstName(), 'lastname' => $context->getBillingAddress()->getLastName()), 'guest');
         $quote->collectTotals();
         $quote->save();
         $context->setRegisterMethod('guest');
         $context->updateFromQuote($quote);
         $context->save();
         return Customweb_Core_Http_Response::redirect($successUrl);
     }
     $context->setAuthenticationEmailAddress($emailAddress);
     $context->setAuthenticationSuccessUrl($successUrl);
     $context->save();
     return Customweb_Core_Http_Response::redirect(Mage::getUrl('SaferpayCw/Externalcheckout/login', array('_secure' => true)));
 }