public function onBeforeSave(Customweb_Database_Entity_IManager $manager)
 {
     if ($this->getContextId() === null) {
         $this->setCreatedOn(new DateTime());
     }
     $this->setUpdatedOn(new DateTime());
     if (is_object($this->paymentMethod)) {
         $this->paymentMethodMachineName = $this->paymentMethod->getPaymentMethodName();
     }
 }
 public static function getWrapperFromPaymentMethod(Customweb_Payment_Authorization_IPaymentMethod $method)
 {
     $paymentMethodName = $method->getPaymentMethodName();
     switch (strtolower($paymentMethodName)) {
         case 'mastercard':
         case 'visa':
         case 'americanexpress':
         case 'diners':
         case 'jcb':
         case 'saferpaytestcard':
         case 'laser':
         case 'lasercard':
         case 'bonuscard':
         case 'maestro':
         case 'myone':
         case 'creditcard':
             return new Customweb_Saferpay_Method_CreditCardWrapper($method);
         case 'postfinanceefinance':
         case 'postfinancecard':
         case 'paypal':
         case 'ideal':
         case 'clickandbuy':
         case 'eps':
             return new Customweb_Saferpay_Method_DefaultWrapper($method);
         case 'openinvoice':
             return new Customweb_Saferpay_Method_BillpayOpenInvoice($method);
         case 'mpass':
         case 'giropay':
         case 'directebanking':
             return new Customweb_Saferpay_Method_OnlineBankingWrapper($method);
         case 'directdebits':
             if ($method->getPaymentMethodConfigurationValue('provider') == 'billpay') {
                 return new Customweb_Saferpay_Method_BillpayDirectDebits($method);
             } else {
                 return new Customweb_Saferpay_Method_DirectDebitWrapper($method);
             }
             break;
         case 'masterpass':
             return new Customweb_Saferpay_Method_Masterpass($method);
         default:
             throw new Exception(Customweb_I18n_Translation::__("No method wrapper found for payment method '!method'.", array('!method' => $paymentMethodName)));
     }
 }
 protected function _beforeSave()
 {
     parent::_beforeSave();
     if ($this->isObjectNew()) {
         $this->setCreatedOn(date("Y-m-d H:i:s"));
     }
     $this->setUpdatedOn(date("Y-m-d H:i:s"));
     $this->setData('invoice_items', Mage::helper('SaferpayCw')->serialize($this->invoiceItems));
     $this->setData('shipping_address', Mage::helper('SaferpayCw')->serialize($this->shippingAddress));
     $this->setData('billing_address', Mage::helper('SaferpayCw')->serialize($this->billingAddress));
     $this->setData('provider_data', Mage::helper('SaferpayCw')->serialize($this->providerData));
     if (is_object($this->paymentMethod)) {
         $this->setData('payment_method_machine_name', $this->paymentMethod->getPaymentMethodName());
     }
 }
Beispiel #4
0
 /**
  * Sets the mandate id on the customer context.
  * 
  * @param Customweb_Payment_Authorization_IPaymentCustomerContext $context
  * @param string $id
  * @return void
  */
 public static function setMandateIdIntoCustomerContext(Customweb_Payment_Authorization_IPaymentCustomerContext $context, $id, Customweb_Payment_Authorization_IPaymentMethod $paymentMethod)
 {
     $methodKey = strtolower($paymentMethod->getPaymentMethodName());
     $map = array(self::CUSTOMER_CONTEXT_KEY => array($methodKey => $id));
     $context->updateMap($map);
 }
Beispiel #5
0
 public function existsPaymentMethodConfigurationValue($key, $languageCode = null)
 {
     return $this->_paymentMethod->existsPaymentMethodConfigurationValue($key, $languageCode = null);
 }
 /**
  * @param Customweb_Payment_Authorization_IPaymentMethod $paymentMethod
  * @throws Exception
  * @return Customweb_Payment_Authorization_IAdapter
  */
 protected function getAdapterInstanceByPaymentMethod(Customweb_Payment_Authorization_IPaymentMethod $paymentMethod)
 {
     $configuredAuthorizationMethod = $paymentMethod->getPaymentMethodConfigurationValue('authorizationMethod');
     $adapter = null;
     switch (strtolower($configuredAuthorizationMethod)) {
         // In case the server mode is choosen, we stick to the hidden, for simplicity.
         case strtolower(Customweb_Saferpay_Authorization_Server_Adapter::AUTHORIZATION_METHOD_NAME):
         case strtolower(Customweb_Saferpay_Authorization_Hidden_Adapter::AUTHORIZATION_METHOD_NAME):
             $adapter = new Customweb_Saferpay_Authorization_Hidden_Adapter($this->getConfigurationAdapter(), $this->container);
             break;
         case strtolower(Customweb_Saferpay_Authorization_PaymentPage_Adapter::AUTHORIZATION_METHOD_NAME):
             $adapter = new Customweb_Saferpay_Authorization_PaymentPage_Adapter($this->getConfigurationAdapter(), $this->container);
             break;
         default:
             throw new Exception(Customweb_I18n_Translation::__("Could not find an adapter for the authoriztion method !methodName.", array('!methodName' => $configuredAuthorizationMethod)));
     }
     $adapter->setIsMoto(true);
     return $adapter;
 }
 /**
  * This method returns the keys for accessing the map with the classes.
  * 
  * @param Customweb_Payment_Authorization_IPaymentMethod $method
  * @param unknown $authorizationMethodName
  * @return string[]
  */
 protected final function getKeys(Customweb_Payment_Authorization_IPaymentMethod $method, $authorizationMethodName)
 {
     $paymentMethodKey = strtolower($method->getPaymentMethodName());
     if ($authorizationMethodName === null) {
         $authorizationMethodName = '*';
     }
     $authorizationMethodNameKey = strtolower($authorizationMethodName);
     $processorKey = null;
     if ($method->existsPaymentMethodConfigurationValue('processor')) {
         $processorKey = $method->getPaymentMethodConfigurationValue('processor');
     }
     if ($processorKey === null) {
         $processorKey = $this->getDefaultOperator($method, $authorizationMethodName);
     }
     if ($processorKey === null) {
         $processorKey = '*';
     }
     $processorKey = strtolower($processorKey);
     return array('paymentMethodKey' => $paymentMethodKey, 'authorizationMethodNameKey' => $authorizationMethodNameKey, 'processorKey' => $processorKey);
 }