Example #1
0
 /**
  * Fetches a list of transaction which can be used as alias transactions for the given order context.
  * 
  * @param Customweb_Payment_Authorization_IOrderContext $orderContext
  * @return Customweb_Payment_Entity_AbstractTransaction[]
  */
 public function getAliasTransactions(Customweb_Payment_Authorization_IOrderContext $orderContext)
 {
     $customerId = $orderContext->getCustomerId();
     if ($customerId === null) {
         return array();
     }
     $transactions = $this->manager->search($this->transactionClassName, 'customerId = >customerId AND paymentMachineName = >paymentMethodName AND aliasActive = "y" AND aliasForDisplay IS NOT NULL AND aliasForDisplay != ""', 'createdOn DESC', array('>customerId' => $customerId, '>paymentMethodName' => $orderContext->getPaymentMethod()->getPaymentMethodName()));
     $result = array();
     foreach ($transactions as $transaction) {
         /* @var $transaction Customweb_Payment_Entity_AbstractTransaction */
         if (!isset($result[$transaction->getAliasForDisplay()])) {
             $result[$transaction->getAliasForDisplay()] = $transaction;
         }
     }
     return $result;
 }
 /**
  * This method tries to instanciated an adapter for the given authorization method. If the authorization method
  * is not supported for the given context the next one in the stack is tried.
  *
  * @param string $currentMethod
  * @param array $supportedMethod
  * @param Customweb_Payment_Authorization_IOrderContext $context
  * @throws Exception In case no adapter matches the given parameters.
  */
 private function getAdapterByOrderContextInner($currentMethod, array $supportedMethod, Customweb_Payment_Authorization_IOrderContext $context)
 {
     if (count($supportedMethod) <= 0) {
         throw new Exception(Customweb_I18n_Translation::__("No authorization method found for payment method !method.", array('!method' => $context->getPaymentMethod()->getPaymentMethodName())));
     }
     $adapter = $this->getAuthorizationAdapterByName($currentMethod);
     if ($adapter->isAuthorizationMethodSupported($context)) {
         return $adapter;
     } else {
         $applicableMethods = array();
         foreach ($supportedMethod as $methodName) {
             if ($methodName == $currentMethod) {
                 break;
             }
             $applicableMethods[] = $methodName;
         }
         return $this->getAdapterByOrderContextInner(end($applicableMethods), $applicableMethods, $context);
     }
 }
 public static function getWrapper(Customweb_Payment_Authorization_IOrderContext $orderContext)
 {
     $wrapper = self::getWrapperFromPaymentMethod($orderContext->getPaymentMethod());
     $wrapper->setOrderContext($orderContext);
     return $wrapper;
 }
Example #4
0
 public function getVisibleFormFields(Customweb_Payment_Authorization_IOrderContext $orderContext, $aliasTransaction, $failedTransaction, $paymentCustomerContext)
 {
     $adapter = $this->getAdapterInstanceByPaymentMethod($orderContext->getPaymentMethod());
     return $adapter->getVisibleFormFields($orderContext, $aliasTransaction, $failedTransaction, $paymentCustomerContext);
 }
 public function isDeferredCapturingSupported(Customweb_Payment_Authorization_IOrderContext $orderContext, Customweb_Payment_Authorization_IPaymentCustomerContext $paymentContext)
 {
     // TODO: Move this into a dedicated authorization adpater
     return $orderContext->getPaymentMethod()->existsPaymentMethodConfigurationValue('capturing');
 }