/**
  * @return Customweb_I18n_Translation
  */
 public static function getInstance()
 {
     if (self::$instance == null) {
         self::$instance = new Customweb_I18n_Translation();
     }
     return self::$instance;
 }
Example #2
0
 private function getSupportElement()
 {
     $control = new Customweb_Form_Control_Html('supportText', Customweb_I18n_Translation::__("If you have any issues with the module please feel free to contact us. See our <a href='https://www.sellxed.com/en/support' target='_blank'>support page</a> for more information."));
     $element = new Customweb_Form_Element(Customweb_I18n_Translation::__("Support"), $control);
     $element->setRequired(false);
     return $element;
 }
 public function getElementGroups()
 {
     $settingHandler = $this->getSettingHandler();
     $formGroups = array();
     foreach ($this->getCheckouts() as $checkout) {
         $checkoutGroup = new Customweb_Form_ElementGroup();
         $checkoutGroup->setTitle($checkout->getName());
         $checkoutGroup->setMachineName($checkout->getMachineName());
         // Single Checkbox
         // @formatter:off
         $element = new Customweb_Form_Element('Active', new Customweb_Form_Control_SingleCheckbox($checkout->getMachineName() . '[active]', 'yes', 'Active', $checkout->isActive()), null, false, !$settingHandler->hasCurrentStoreSetting($checkout->getMachineName() . '_active'));
         $element->setDescription(Customweb_I18n_Translation::__("Check to activate the external checkout."));
         $checkoutGroup->addElement($element);
         // Input Field
         $element = new Customweb_Form_Element('Sort Order', new Customweb_Form_Control_TextInput($checkout->getMachineName() . '[sort_order]', $checkout->getSortOrder()), null, false, !$settingHandler->hasCurrentStoreSetting($checkout->getMachineName() . '_sort_order'));
         $element->setDescription(Customweb_I18n_Translation::__("Set the sort order to show the external checkouts."));
         $checkoutGroup->addElement($element);
         // Minimal Order Total
         $element = new Customweb_Form_Element('Minimal Order Total', new Customweb_Form_Control_TextInput($checkout->getMachineName() . '[minimal_order_total]', $checkout->getMinimalOrderTotal()), null, false, !$settingHandler->hasCurrentStoreSetting($checkout->getMachineName() . '_minimal_order_total'));
         $element->setDescription(Customweb_I18n_Translation::__("Define a minimal order total for this checkout to be available."));
         $checkoutGroup->addElement($element);
         // Maximal Order Total
         $element = new Customweb_Form_Element('Maximal Order Total', new Customweb_Form_Control_TextInput($checkout->getMachineName() . '[maximal_order_total]', $checkout->getMaximalOrderTotal()), null, false, !$settingHandler->hasCurrentStoreSetting($checkout->getMachineName() . '_maximal_order_total'));
         $element->setDescription(Customweb_I18n_Translation::__("Define a maximal order total for this checkout to be available."));
         $checkoutGroup->addElement($element);
         // @formatter:on
         $formGroups[] = $checkoutGroup;
     }
     return $formGroups;
 }
Example #4
0
 protected function getSaveButton()
 {
     if ($this->saveButton === null) {
         $this->saveButton = new Customweb_Form_Button();
         $this->saveButton->setMachineName("save")->setTitle(Customweb_I18n_Translation::__("Save"))->setType(Customweb_Form_IButton::TYPE_SUCCESS);
     }
     return $this->saveButton;
 }
 private function getMandateText($mandateReference, $customer)
 {
     $creditorId = $this->getPaymentMethodConfigurationValue('creditor_identifier');
     $merchantName = $this->getPaymentMethodConfigurationValue('mandate_name');
     $date = date('Y-m-d H:i');
     //@formatter:off
     return Customweb_I18n_Translation::__("Gläubiger-Identifikationsnummer: !CREDITOR_ID<br/>\nMandatsreferenz: !MANDATE_REFERENCE<br/>\nDatum: !DATE<br/>\n<br/>\nIch !CUSTOMER ermächtige !MERCHANT_NAME widerruflich, lt. meinen vorherigen Eingaben den oben genannten Betrag und die von mir zukünftig zu entrichtenden Zahlungen bei Fälligkeit von meinem Konto mittels Lastschrift einzuziehen. Zugleich weise ich mein Kreditinstitut an, die von auf mein Konto gezogenen Lastschriften einzulösen.<br/>\n<br/>\nHinweis: Ich kann innerhalb von acht Wochen, beginnend mit dem Belastungsdatum, die Erstattung des belasteten Betrages verlangen. Es gelten dabei die mit meinem Kreditinstitut vereinbarten Bedingungen.<br/>\nHiermit bestätige ich das SEPA-Lastschriftmandat", array('!CREDITOR_ID' => $creditorId, '!CUSTOMER' => $customer, '!MANDATE_REFERENCE' => $mandateReference, '!DATE' => $date, '!MERCHANT_NAME' => $merchantName));
     //@formatter:on
 }
 protected function capture($transaction, $amount, $id)
 {
     $builder = new Customweb_Saferpay_BackendOperation_Adapter_Capture_ParameterBuilder($transaction, $this->getConfiguration(), $this->container);
     $parameters = $builder->buildParameters();
     $parameters['ID'] = $id;
     // No amount must be send in case of refunds.
     unset($parameters['AMOUNT']);
     $this->performPayCompleteAction($parameters, Customweb_I18n_Translation::__('The refund could not be captured.'));
 }
 /**
  * This method validates if the given $orderContext and $paymentContext are valid to be 
  * processed with this payment method. 
  * 
  * Subclasses may override this method, but they should call the parent method.
  * 
  * @param Customweb_Payment_Authorization_IOrderContext $orderContext
  * @param Customweb_Payment_Authorization_IPaymentCustomerContext $paymentContext
  * @throws Exception In case something is not valid.
  */
 public function preValidate(Customweb_Payment_Authorization_IOrderContext $orderContext, Customweb_Payment_Authorization_IPaymentCustomerContext $paymentContext)
 {
     if (!$this->isCountrySupported($orderContext->getBillingCountryIsoCode())) {
         throw new Exception(Customweb_I18n_Translation::__("The payment method !paymentMethodName is not available in your country ('!country').", array('!paymentMethodName' => $this->getPaymentMethodDisplayName(), '!country' => $orderContext->getBillingCountryIsoCode())));
     }
     if (!$this->isCurrencySupported($orderContext->getCurrencyCode())) {
         throw new Exception(Customweb_I18n_Translation::__("The payment method !paymentMethodName does not support the currency '!currency'.", array('!paymentMethodName' => $this->getPaymentMethodDisplayName(), '!currency' => $orderContext->getCurrencyCode())));
     }
     return true;
 }
 public function buildParameters($amount)
 {
     $parameters = array_merge($this->getServiceParameters(), $this->getRefundParameters());
     $refundNumber = count($this->getTransaction()->getRefunds()) + 1;
     $parameters['AMOUNT'] = number_format($amount, 2, '', '');
     $parameters['CURRENCY'] = $this->getTransaction()->getCurrencyCode();
     $parameters['ORDERID'] = Customweb_Util_String::substrUtf8($this->getTransactionAppliedSchema() . '-refund' . $refundNumber, -80);
     $parameters['DESCRIPTION'] = Customweb_I18n_Translation::__("Refunding Transaction '!transactionId'", array('!transactionId' => $this->getTransaction()->getExternalTransactionId()));
     return $parameters;
 }
 public function cancel(Customweb_Payment_Authorization_ITransaction $transaction)
 {
     if (!$transaction instanceof Customweb_Saferpay_Authorization_Transaction) {
         throw new Exception("The given transaction is not instanceof Customweb_Saferpay_Authorization_Transaction.");
     }
     $transaction->cancelDry();
     $builder = new Customweb_Saferpay_BackendOperation_Adapter_Cancel_ParameterBuilder($transaction, $this->getConfiguration(), $this->container);
     $parameters = $builder->buildParameters();
     $this->performPayCompleteAction($parameters, Customweb_I18n_Translation::__('Transaction could not be canceled.'));
     $transaction->cancel();
 }
 public function extractPaymentInformation(array $parameters)
 {
     $substitutes = array('POB_ACCOUNTHOLDER' => Customweb_I18n_Translation::__('Account Holder'), 'POB_ACCOUNTNUMBER' => Customweb_I18n_Translation::__('Account Number'), 'POB_BANKCODE' => Customweb_I18n_Translation::__('Bank Code'), 'POB_BANKNAME' => Customweb_I18n_Translation::__('Bank Name'), 'POB_PAYERNOTE' => Customweb_I18n_Translation::__('Payment Note'));
     $information = array();
     foreach ($parameters as $key => $value) {
         if (array_key_exists($key, $substitutes)) {
             $information[] = array('label' => $substitutes[$key], 'value' => $value);
         }
     }
     return $information;
 }
Example #11
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);
 }
 public function getMotoAccountId()
 {
     if ($this->isTestMode()) {
         $accountId = $this->getTestAccountId();
     } else {
         $accountId = $this->getConfigurationValue('moto_account_id');
     }
     $accountId = trim($accountId);
     if (empty($accountId)) {
         throw new Exception(Customweb_I18n_Translation::__("The given MoTo account id is empty. Please check the Saferpay settings."));
     }
     return $accountId;
 }
Example #13
0
 public static function generateMandateId($schema)
 {
     $variables = array('{day}' => date('d'), '{month}' => date('m'), '{year}' => date('Y'), '{random}' => strtoupper(Customweb_Util_Rand::getRandomString('20')));
     $result = $schema;
     foreach ($variables as $variableName => $variableValue) {
         if (strstr($schema, $variableName) === false) {
             throw new Exception(Customweb_I18n_Translation::__("The SEPA mandate schema does not contain the tag '!tag'. This tag is required.", array('!tag' => $variableName)));
         }
         $result = str_replace($variableName, $variableValue, $result);
     }
     // Remove unallowed chars, cut of to accepted length
     return self::sanitizeMandateId($result);
 }
 public function partialCapture(Customweb_Payment_Authorization_ITransaction $transaction, $items, $close)
 {
     if (!$transaction instanceof Customweb_Saferpay_Authorization_Transaction) {
         throw new Exception("The given transaction is not instanceof Customweb_Saferpay_Authorization_Transaction.");
     }
     $amount = Customweb_Util_Invoice::getTotalAmountIncludingTax($items);
     // Check the transaction state
     $transaction->partialCaptureByLineItemsDry($items, true);
     $builder = new Customweb_Saferpay_BackendOperation_Adapter_Capture_ParameterBuilder($transaction, $this->getConfiguration(), $this->container);
     $builder->setAmount($amount);
     $parameters = $builder->buildParameters();
     $this->performPayCompleteAction($parameters, Customweb_I18n_Translation::__('The transaction could not be captured.'));
     $transaction->partialCaptureByLineItems($items, true);
 }
Example #15
0
 public static function handlePendingTransaction(Customweb_Payment_Authorization_DefaultTransaction $transaction, $timeout, $interval)
 {
     $transaction->setUpdateExecutionDate(null);
     if (!$transaction->isAuthorized() && !$transaction->isAuthorizationFailed()) {
         $diff = time() - $transaction->getCreatedOn()->getTimestamp();
         if ($diff > $timeout) {
             $transaction->setAuthorizationFailed(Customweb_I18n_Translation::__("The customer does not finish the payment with in the timeout."));
         } else {
             $date = new DateTime();
             $date->setTimestamp(time() + $interval);
             $transaction->setUpdateExecutionDate($date);
         }
     }
 }
 /**
  * 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 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)));
     }
 }
 /**
  * @Action("index")
  */
 public function process(Customweb_Core_Http_IRequest $request)
 {
     $transaction = $this->loadTransaction($request);
     $parameters = $request->getParameters();
     if (!isset($parameters[self::HASH_PARAMETER])) {
         throw new Exception('Security Hash not set');
     }
     $transaction->checkSecuritySignature($this->getControllerName() . 'index', $parameters[self::HASH_PARAMETER]);
     $templateContext = new Customweb_Mvc_Template_RenderContext();
     $templateContext->setSecurityPolicy(new Customweb_Mvc_Template_SecurityPolicy());
     $templateContext->setTemplate('delayedNotification');
     $templateContext->addVariable('script', $this->getPollingJs($transaction));
     $templateContext->addVariable('text', Customweb_I18n_Translation::__('Dear customer, it appears to us that your payment was successful, but we are still waiting for confirmation. You can wait on this page and we will redirect you after we received the confirmation. Or you can close this window and we will send out an order confirmation email.'));
     $templateRenderer = $this->getTemplateRenderer();
     $content = $templateRenderer->render($templateContext);
     $layoutContext = new Customweb_Mvc_Layout_RenderContext();
     $layoutContext->setMainContent($content);
     $layoutContext->setTitle(Customweb_I18n_Translation::__('Awaiting confirmation'));
     return $this->getLayoutRenderer()->render($layoutContext);
 }
 protected function getCustomizationParameters()
 {
     $parameters = array();
     $description = $this->getConfiguration()->getPaymentDescription($this->getOrderContext()->getLanguage());
     if (empty($description)) {
         $description = Customweb_I18n_Translation::__("Your order description");
     }
     $parameters['DESCRIPTION'] = Customweb_Saferpay_Util::removeWrongEscaptedChars($description);
     if (strlen($this->getConfiguration()->getPaymentPageConfiguration()) > 0) {
         $parameters['VTCONFIG'] = $this->getConfiguration()->getPaymentPageConfiguration();
     }
     $parameters['DELIVERY'] = 'no';
     $parameters['LANGID'] = Customweb_Saferpay_Util::getCleanLanguageCode($this->getOrderContext()->getLanguage());
     if ($this->getTransactionContext()->getAlias() == 'new' || $this->getTransactionContext()->getAlias() == null && $this->getTransactionContext()->createRecurringAlias()) {
         $parameters['CARDREFID'] = "new";
     }
     if ($this->getTransactionContext()->getAlias() != null && $this->getTransactionContext()->getAlias() != 'new') {
         $parameters['CARDREFID'] = $this->getTransactionContext()->getAlias()->getCardRefId();
     }
     return array_merge($parameters, $this->getSupportedPaymentMethods());
 }
 /**
  * This method creates an element to select the date of birth
  * @param string $fieldName The field name of the date of birth element
  */
 public static function getDateOfBirthElement($dayFieldName, $monthFieldName, $yearFieldName, $defaultDay = '', $defaultMonth = '', $defaultYear = '')
 {
     $days = array('none' => Customweb_I18n_Translation::__('Day'), '01' => '01', '02' => '02', '03' => '03', '04' => '04', '05' => '05', '06' => '06', '07' => '07', '08' => '08', '09' => '09', '10' => '10', '11' => '11', '12' => '12', '13' => '13', '14' => '14', '15' => '15', '16' => '16', '17' => '17', '18' => '18', '19' => '19', '20' => '20', '21' => '21', '22' => '22', '23' => '23', '24' => '24', '25' => '25', '26' => '26', '27' => '27', '28' => '28', '29' => '29', '30' => '30', '31' => '31');
     $months = array('none' => Customweb_I18n_Translation::__('Month'), '01' => '01', '02' => '02', '03' => '03', '04' => '04', '05' => '05', '06' => '06', '07' => '07', '08' => '08', '09' => '09', '10' => '10', '11' => '11', '12' => '12');
     $years = array('none' => Customweb_I18n_Translation::__('Year'));
     $current = intval(date('Y'));
     for ($i = 0; $i < 130; $i++) {
         $years[$current] = $current;
         $current--;
     }
     $dayControl = new Customweb_Form_Control_Select($dayFieldName, $days, $defaultDay);
     $dayControl->addValidator(new Customweb_Form_Validator_NotEmpty($dayControl, Customweb_I18n_Translation::__("Please select the day on which you were born.")));
     $monthControl = new Customweb_Form_Control_Select($monthFieldName, $months, $defaultMonth);
     $monthControl->addValidator(new Customweb_Form_Validator_NotEmpty($monthControl, Customweb_I18n_Translation::__("Please select the month in which you were born.")));
     $yearControl = new Customweb_Form_Control_Select($yearFieldName, $years, $defaultYear);
     $yearControl->addValidator(new Customweb_Form_Validator_NotEmpty($yearControl, Customweb_I18n_Translation::__("Please select the year in which you were born.")));
     $yearControl->addValidator(new Customweb_Saferpay_Method_ValidateDateOfBirth($yearControl, 'dob-day', 'dob-month', 'dob-year'));
     $control = new Customweb_Form_Control_MultiControl('dayOfBirth', array($dayControl, $monthControl, $yearControl));
     $element = new Customweb_Form_Element(Customweb_I18n_Translation::__('Date of birth'), $control, Customweb_I18n_Translation::__('Select your date of birth.'));
     $element->setElementIntention(Customweb_Form_Intention_Factory::getDateOfBirthIntention());
     return $element;
 }
 /**
  * Generates basic labels from the transaction properties.
  *
  * @return array
  */
 protected function getBasicLabels()
 {
     $labels = array();
     $labels['cancel_id'] = array('label' => Customweb_I18n_Translation::__('Cancel ID'), 'value' => $this->getCancelId());
     $labels['cancel_date'] = array('label' => Customweb_I18n_Translation::__('Date'), 'value' => $this->getCancelDate()->format('Y-m-d H:i:s'));
     $labels['cancel_status'] = array('label' => Customweb_I18n_Translation::__('Cancel status'), 'description' => Customweb_I18n_Translation::__("If the status is 'Pending' it is unclear whether the transaction will be cancelled successfully."));
     if ($this->getStatus() == self::STATUS_SUCCEED) {
         $labels['cancel_status']['value'] = Customweb_I18n_Translation::__('Success');
     } elseif ($this->getStatus() == self::STATUS_PENDING) {
         $labels['cancel_status']['value'] = Customweb_I18n_Translation::__('Pending');
     } else {
         $labels['cancel_status']['value'] = Customweb_I18n_Translation::__('Failed');
     }
     return $labels;
 }
 /**
  * This methdo returns the options list for the select control for
  * the year control.
  *
  * @return array
  * @throws Exception
  */
 protected function getExpiryYearOptions()
 {
     $years = array('none' => Customweb_I18n_Translation::__('Year'));
     $current = intval(date('Y'));
     for ($i = 0; $i < 15; $i++) {
         if ($this->getExpiryYearNumberOfDigits() == 4) {
             $years[$current] = $current;
         } else {
             if ($this->getExpiryYearNumberOfDigits() == 2) {
                 $years[substr($current, 2, 2)] = $current;
             } else {
                 throw new Exception("Invalid number of digits defined for the expiration element.");
             }
         }
         $current++;
     }
     return $years;
 }
Example #23
0
 protected function createAlias($transaction, $parameters)
 {
     $url = $this->getFormActionUrl($transaction);
     $response = Customweb_Saferpay_Util::sendFormData($url, $parameters);
     if (isset($response['location'])) {
         $transaction->setTransactionState(Customweb_Saferpay_Authorization_Transaction::STATE_ALIAS_EXISTS);
         $transaction->setNextRedirectUrl($response['location']);
     } else {
         $reason = Customweb_I18n_Translation::__("Server responded with unexpected headers '!response'", array('!response' => print_r($response, true)));
         $transaction->setAuthorizationFailed($reason);
         $this->redirect(null, $transaction, $this->getFailedUrl($transaction));
     }
 }
Example #24
0
 public static function getUserErrorMessage($originalMessage)
 {
     if (strpos($originalMessage, 'No CardType found for CustomerId') === 0 || $originalMessage == 'Invalid PAN.' || $originalMessage == 'unknown card type') {
         return Customweb_I18n_Translation::__('Invalid credit card data: The given card number is not valid.');
     } elseif ($originalMessage == 'wrong CVC' || $originalMessage == 'authorization failed (5): Authorisation refused') {
         return Customweb_I18n_Translation::__('Invalid credit card data: Please check your credit card data.');
     } elseif ($originalMessage == 'Account Data expired.') {
         return Customweb_I18n_Translation::__('Invalid credit card data: The expiration date has to be in the future.');
     } elseif (strpos($originalMessage, 'authorization failed (12): Invalid transaction') === 0) {
         return Customweb_I18n_Translation::__('The payment failed because either the card number, the CVC or the expiry date was invalid.');
     }
     return $originalMessage;
 }
Example #25
0
 /**
  * This method produces a list of line item which are cleaned up. This means the amounts of the line items are rounded 
  * correctly. The line items only contains items with unique SKUs. If there is a difference between the expected sum and 
  * the actual sum an adjustment line item will be added. 
  * 
  * @param array $originalLineItems The line items to clean.
  * @param float $expectedSum The sum which should be met with this line items.
  * @param string $currencyCode The currency to use when the amounts are rounded.
  */
 public static function cleanupLineItems(array $originalLineItems, $expectedSum, $currencyCode)
 {
     $expectedSum = Customweb_Util_Currency::roundAmount($expectedSum, $currencyCode);
     $result = array();
     foreach ($originalLineItems as $lineItem) {
         $type = $lineItem->getType();
         $amount = $lineItem->getAmountIncludingTax();
         if ($type == Customweb_Payment_Authorization_IInvoiceItem::TYPE_DISCOUNT && $amount < 0) {
             $type = Customweb_Payment_Authorization_IInvoiceItem::TYPE_FEE;
             $amount = $amount * -1;
         }
         $result[] = new Customweb_Payment_Authorization_DefaultInvoiceItem($lineItem->getSku(), $lineItem->getName(), $lineItem->getTaxRate(), Customweb_Util_Currency::roundAmount($amount, $currencyCode), $lineItem->getQuantity(), $type, $lineItem->getOriginalSku());
     }
     $realSum = self::getTotalAmountIncludingTax($result);
     $diff = Customweb_Util_Currency::compareAmount($realSum, $expectedSum, $currencyCode);
     if ($diff > 0) {
         $amountDifferenceWithTax = $realSum - $expectedSum;
         $result[] = new Customweb_Payment_Authorization_DefaultInvoiceItem('rounding-adjustment', Customweb_I18n_Translation::__("Rounding Adjustment")->toString(), 0, Customweb_Util_Currency::roundAmount($amountDifferenceWithTax, $currencyCode), 1, Customweb_Payment_Authorization_IInvoiceItem::TYPE_DISCOUNT);
     } else {
         if ($diff < 0) {
             $amountDifferenceWithTax = $expectedSum - $realSum;
             $result[] = new Customweb_Payment_Authorization_DefaultInvoiceItem('rounding-adjustment', Customweb_I18n_Translation::__("Rounding Adjustment")->toString(), 0, Customweb_Util_Currency::roundAmount($amountDifferenceWithTax, $currencyCode), 1, Customweb_Payment_Authorization_IInvoiceItem::TYPE_FEE);
         }
     }
     return self::ensureUniqueSku($result);
 }
 public function getTransactionSpecificLabels()
 {
     $labels = array();
     $params = $this->getAuthorizationParameters();
     if (isset($params['PAN']) && !isset($params['IBAN'])) {
         $labels['cardnumber'] = array('label' => Customweb_I18n_Translation::__('Card Number'), 'value' => $params['PAN']);
     }
     if (isset($params['IBAN'])) {
         $labels['iban'] = array('label' => Customweb_I18n_Translation::__('IBAN'), 'value' => $params['IBAN']);
     }
     if ($this->cardExpiryMonth !== null) {
         $labels['card_expiry'] = array('label' => Customweb_I18n_Translation::__('Card Expiry Date'), 'value' => $this->getCardExpiryMonth() . '/' . $this->getCardExpiryYear());
     }
     if (isset($params['PROVIDERNAME'])) {
         $labels['card_type'] = array('label' => Customweb_I18n_Translation::__('Card Type'), 'value' => $params['PROVIDERNAME']);
     }
     if ($this->isMoto()) {
         $labels['moto'] = array('label' => Customweb_I18n_Translation::__('Mail Order / Telephone Order (MoTo)'), 'value' => Customweb_I18n_Translation::__('Yes'));
     }
     $cardRefId = $this->getCardRefId();
     if (!empty($cardRefId)) {
         $labels['card_ref_id'] = array('label' => Customweb_I18n_Translation::__('Card Reference ID'), 'value' => $cardRefId);
     }
     $labels['authorization_method'] = array('label' => Customweb_I18n_Translation::__('Authorization Method'), 'value' => $this->getAuthorizationMethod());
     if ($this->getEffectivePaymentMethodMachineName() !== null) {
         $labels['effective_method'] = array('label' => Customweb_I18n_Translation::__('Effective Payment Method Name'), 'value' => $this->getEffectivePaymentMethodMachineName(), 'description' => Customweb_I18n_Translation::__('In some cases the customer switch the payment method or select a more specific one. This label shows the effective one.'));
     }
     return $labels;
 }
Example #27
0
 public function processAuthorization(Customweb_Payment_Authorization_ITransaction $transaction, array $parameters)
 {
     // Check if the CVC field is filled in in case of a alias transaction.
     if ($transaction->getTransactionState() == Customweb_Saferpay_Authorization_Transaction::STATE_INITIAL && $transaction->isUseExistingAlias() && !$this->isCardVerificationPossible($transaction->getTransactionContext()->getAlias(), $transaction->getTransactionContext()->getOrderContext(), $transaction->getPaymentCustomerContext(), $parameters)) {
         $message = Customweb_I18n_Translation::__("The CVC field is required.");
         $transaction->setAuthorizationFailed($message);
     }
     if (!$this->validateCustomParameters($transaction, $parameters)) {
         $reason = Customweb_I18n_Translation::__("Custom parameters have been altered. Fraud possible, aborting.");
         $transaction->setAuthorizationFailed($reason);
     }
     if ($transaction->isAuthorizationFailed()) {
         $this->redirect(null, $transaction, $this->getFailedUrl($transaction));
     } elseif ($transaction->isAuthorized()) {
         $this->redirect(null, $transaction, $this->getSuccessUrl($transaction));
     } else {
         switch ($transaction->getTransactionState()) {
             case Customweb_Saferpay_Authorization_Transaction::STATE_INITIAL:
                 $this->processScdResponse($transaction, $parameters);
                 break;
             case Customweb_Saferpay_Authorization_Transaction::STATE_3D_SECURE:
                 if (!isset($parameters['DATA']) || empty($parameters['DATA'])) {
                     return Customweb_Core_Http_Response::_("NO DATA parameter provided.")->setStatusCode(500);
                 }
                 $parameters = array_merge($parameters, $this->parseRequestParameters($parameters));
                 $this->process3DSecureResponse($transaction, $parameters);
                 break;
             default:
                 $this->redirect(null, $transaction, $this->getFailedUrl($transaction));
         }
     }
     return $this->finalizeAuthorizationRequest($transaction);
 }
Example #28
0
 public function registerTranslationResolver(Varien_Event_Observer $observer)
 {
     Customweb_I18n_Translation::getInstance()->addResolver(new Customweb_SaferpayCw_Model_TranslationResolver());
 }
 public function toString()
 {
     return Customweb_I18n_Translation::getInstance()->translate($this->string, $this->arguments);
 }
Example #30
0
 /**
  * @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;
 }