public RequestDocumentCreation(IOrderGroupCalculator orderGroupCalculator, ILineItemCalculator lineItemCalculator, DataCashConfiguration dataCashConfiguration)
        {
            _orderGroupCalculator = orderGroupCalculator;
            _lineItemCalculator   = lineItemCalculator;

            _dataCashConfiguration = dataCashConfiguration;
        }
Esempio n. 2
0
        private void BindParameterData(string parameterName, TextBox parameterControl)
        {
            var parameterByName = DataCashConfiguration.GetParameterValueByName(_paymentMethodDto, parameterName);

            if (parameterByName != null)
            {
                parameterControl.Text = parameterByName;
            }
        }
        public ActionResult Index()
        {
            if (PageEditing.PageIsInEditMode)
            {
                return(new EmptyResult());
            }

            var currentCart = _orderRepository.LoadCart <ICart>(PrincipalInfo.CurrentPrincipal.GetContactId(), Cart.DefaultName);

            if (!currentCart.Forms.Any() || !currentCart.GetFirstForm().Payments.Any())
            {
                throw new PaymentException(PaymentException.ErrorType.ProviderError, "", Utilities.Translate("GenericError"));
            }

            // Get DataCash payment by PaymentMethodName, instead of get the first payment in the list.
            var dataCashPaymentMethod = DataCashConfiguration.GetDataCashPaymentMethod().PaymentMethod.Rows[0] as Mediachase.Commerce.Orders.Dto.PaymentMethodDto.PaymentMethodRow;
            var paymentMethodId       = dataCashPaymentMethod != null ? dataCashPaymentMethod.PaymentMethodId : Guid.Empty;

            var payment = currentCart.GetFirstForm().Payments.FirstOrDefault(c => c.PaymentMethodId.Equals(paymentMethodId));

            if (payment == null)
            {
                throw new PaymentException(PaymentException.ErrorType.ProviderError, "", Utilities.Translate("PaymentNotSpecified"));
            }

            string merchantRef = payment.Properties[DataCashPaymentGateway.DataCashMerchantReferencePropertyName] as string;

            if (string.IsNullOrEmpty(merchantRef))
            {
                throw new PaymentException(PaymentException.ErrorType.ProviderError, "", Utilities.Translate("GenericError"));
            }

            // Redirect customer to receipt page
            var acceptUrl = Utilities.GetUrlFromStartPageReferenceProperty("DataCashPaymentLandingPage");
            var cancelUrl = Utilities.GetUrlFromStartPageReferenceProperty("CheckoutPage"); // get link to Checkout page

            cancelUrl = UriUtil.AddQueryString(cancelUrl, "success", "false");
            cancelUrl = UriUtil.AddQueryString(cancelUrl, "paymentmethod", "DataCash");

            var    gateway = new DataCashPaymentGateway();
            string redirectUrl;

            if (string.Equals(Request.QueryString["accept"], "true") && Utilities.GetSHA256Key(merchantRef + "accepted") == Request.QueryString["hash"])
            {
                redirectUrl = gateway.ProcessSuccessfulTransaction(currentCart, payment, acceptUrl, cancelUrl);
            }
            else
            {
                redirectUrl = gateway.ProcessUnsuccessfulTransaction(cancelUrl, Utilities.Translate("GenericError"));
            }

            return(Redirect(redirectUrl));
        }
Esempio n. 4
0
        public DataCashPaymentMethod(IOrderGroupFactory orderGroupFactory)
        {
            _orderGroupFactory = orderGroupFactory;
            _paymentMethod     = DataCashConfiguration.GetDataCashPaymentMethod()?.PaymentMethod?.FirstOrDefault();

            if (_paymentMethod == null)
            {
                return;
            }

            PaymentMethodId = _paymentMethod.PaymentMethodId;
            SystemKeyword   = _paymentMethod.SystemKeyword;
            Name            = _paymentMethod.Name;
            Description     = _paymentMethod.Description;
        }
Esempio n. 5
0
        private void UpdateParameter(string parameterName, string value, Guid paymentMethodId)
        {
            var parameterRow = DataCashConfiguration.GetParameterByName(_paymentMethodDto, parameterName);

            if (parameterRow != null)
            {
                parameterRow.Value = value;
            }
            else
            {
                var row = _paymentMethodDto.PaymentMethodParameter.NewPaymentMethodParameterRow();
                row.PaymentMethodId = paymentMethodId;
                row.Parameter       = parameterName;
                row.Value           = value;
                _paymentMethodDto.PaymentMethodParameter.Rows.Add(row);
            }
        }
        public DataCashPaymentGateway(
            IOrderRepository orderRepository,
            IInventoryProcessor inventoryProcessor,
            IOrderNumberGenerator orderNumberGenerator,
            IFeatureSwitch featureSwitch,
            LocalizationService localizationService,
            DataCashConfiguration dataCashConfiguration,
            RequestDocumentCreation requestDocumentCreation)
        {
            _orderRepository      = orderRepository;
            _inventoryProcessor   = inventoryProcessor;
            _orderNumberGenerator = orderNumberGenerator;
            _localizationService  = localizationService;
            _featureSwitch        = featureSwitch;

            _dataCashConfiguration   = dataCashConfiguration;
            _requestDocumentCreation = requestDocumentCreation;
        }
Esempio n. 7
0
        private void BindData()
        {
            if (_paymentMethodDto?.PaymentMethodParameter == null)
            {
                Visible = false;
                return;
            }

            BindParameterData(DataCashConfiguration.HostAddressParameter, HostAddress);
            BindParameterData(DataCashConfiguration.UserIdParameter, APIUser);
            BindParameterData(DataCashConfiguration.PasswordParameter, Password);
            BindParameterData(DataCashConfiguration.PathToLogFileParameter, LogFilePath);
            BindParameterData(DataCashConfiguration.TimeOutParameter, TimeOut);
            BindParameterData(DataCashConfiguration.ProxyParameter, Proxy);
            BindParameterData(DataCashConfiguration.PaymentPageIdParameter, PaymentPageId);

            var selectedValue = DataCashConfiguration.GetParameterValueByName(_paymentMethodDto, DataCashConfiguration.LoggingLevelParameter);

            LoggingLevel.SelectedValue = string.IsNullOrEmpty(selectedValue) ? "5" : selectedValue;
        }