Exemplo n.º 1
0
        public override void LoadData()
        {
            if (ddlHashAlgorithm.Items.Count == 0)
            {
                var values = Enum.GetNames(typeof(OgoneHashAlgorithm));
                foreach (var value in values)
                {
                    var text     = Localization.GetString("HashAlgorithmValue" + value);
                    var listItem = new ListItem(text, value);
                    ddlHashAlgorithm.Items.Add(listItem);
                }
            }
            var settings = new OgoneSettings();

            settings.Merge(HccApp.CurrentStore.Settings.MethodSettingsGet(MethodId));

            txtPaymentServiceProviderId.Text = settings.PaymentServiceProviderId;

            ddlHashAlgorithm.SelectedValue = settings.HashAlgorithm.ToString();
            txtShaInPassPhrase.Text        = settings.ShaInPassPhrase;
            txtShaOutPassPhrase.Text       = settings.ShaOutPassPhrase;
            txtTemplatePage.Text           = settings.TemplatePage;
            chkDebugMode.Checked           = settings.DebugMode;
            chkDeveloperMode.Checked       = settings.DeveloperMode;
        }
Exemplo n.º 2
0
        public ActionResult Index()
        {
            var settings       = new OgoneSettings();
            var methodSettings = HccApp.CurrentStore.Settings.MethodSettingsGet(PaymentMethods.OgoneId);

            settings.Merge(methodSettings);

            var response = GetOgoneResponse();

            if (settings.DebugMode)
            {
                EventLog.LogEvent("Ogone Checkout", Request.RawUrl, EventLogSeverity.Debug);
            }

            var parameters  = GetOgoneHashableParameters();
            var shaSignCalc = OgoneUtils.CalculateShaHash(parameters, settings.HashAlgorithm, settings.ShaOutPassPhrase);

            var model = new CheckoutViewModel();

            model.CurrentOrder = HccApp.OrderServices.CurrentShoppingCart();
            if (shaSignCalc == response.ShaSignature)
            {
                // SHA Signature Match
                if (response.Status == 5 || response.Status == 51 ||
                    response.Status == 9 || response.Status == 91)
                {
                    // Approved
                    SavePaymentInfo(model, response);
                    ProcessOrder(model);
                }
                else
                {
                    // Declined
                    FlashFailure(Localization.GetString("ErrorOccured"));
                }
            }
            else
            {
                // SHA Signature Mismatch
                FlashFailure(Localization.GetString("ShaSignatureMismatch.Text"));
            }

            // Render Error Summary
            foreach (var v in model.Violations)
            {
                FlashFailure(v.ErrorMessage);
            }

            return(View(model));
        }
Exemplo n.º 3
0
        public override void SaveData()
        {
            var settings = new OgoneSettings();

            settings.Merge(HccApp.CurrentStore.Settings.PaymentSettingsGet(GatewayId));

            settings.PaymentServiceProviderId = txtPaymentServiceProviderId.Text.Trim();
            settings.UserId        = txtUserId.Text.Trim();
            settings.Password      = txtPassword.Text.Trim();
            settings.Currency      = ddlCurrency.SelectedValue;
            settings.DebugMode     = chkDebugMode.Checked;
            settings.DeveloperMode = chkDeveloperMode.Checked;

            HccApp.CurrentStore.Settings.PaymentSettingsSet(GatewayId, settings);
            HccApp.AccountServices.Stores.Update(HccApp.CurrentStore);
        }
Exemplo n.º 4
0
        public override void SaveData()
        {
            var settings = new OgoneSettings();

            settings.Merge(HccApp.CurrentStore.Settings.MethodSettingsGet(MethodId));

            settings.PaymentServiceProviderId = txtPaymentServiceProviderId.Text.Trim();
            settings.ShaInPassPhrase          = txtShaInPassPhrase.Text.Trim();
            settings.ShaOutPassPhrase         = txtShaOutPassPhrase.Text.Trim();
            settings.HashAlgorithm            =
                (OgoneHashAlgorithm)Enum.Parse(typeof(OgoneHashAlgorithm), ddlHashAlgorithm.SelectedValue);
            settings.TemplatePage  = txtTemplatePage.Text.Trim();
            settings.DebugMode     = chkDebugMode.Checked;
            settings.DeveloperMode = chkDeveloperMode.Checked;

            HccApp.CurrentStore.Settings.MethodSettingsSet(MethodId, settings);
            HccApp.AccountServices.Stores.Update(HccApp.CurrentStore);
        }
Exemplo n.º 5
0
        public override void LoadData()
        {
            if (ddlCurrency.Items.Count == 0)
            {
                ddlCurrency.Items.Add(new ListItem(Localization.GetString("CurrencyEmptyValue"), string.Empty));
                ddlCurrency.AppendDataBoundItems = true;
                ddlCurrency.DataTextField        = "CurrencyEnglishName";
                ddlCurrency.DataValueField       = "ISOCurrencySymbol";
                ddlCurrency.DataSource           = Currency.GetCurrencyList();
                ddlCurrency.DataBind();
            }
            var settings = new OgoneSettings();

            settings.Merge(HccApp.CurrentStore.Settings.PaymentSettingsGet(GatewayId));

            txtPaymentServiceProviderId.Text = settings.PaymentServiceProviderId;
            txtUserId.Text            = settings.UserId;
            txtPassword.Text          = settings.Password;
            ddlCurrency.SelectedValue = settings.Currency;
            chkDebugMode.Checked      = settings.DebugMode;
            chkDeveloperMode.Checked  = settings.DeveloperMode;
        }
Exemplo n.º 6
0
        public override bool ProcessCheckout(OrderTaskContext context)
        {
            if (context.HccApp.CurrentRequestContext.RoutingContext.HttpContext != null)
            {
                try
                {
                    var settings       = new OgoneSettings();
                    var methodSettings = context.HccApp.CurrentStore.Settings.MethodSettingsGet(PaymentMethodId);
                    settings.Merge(methodSettings);

                    var order = context.Order;

                    var decimalAmount = order.TotalGrandAfterStoreCredits(context.HccApp.OrderServices);
                    var intAmount     = (int)(decimalAmount * 100);

                    var parameters = new NameValueCollection();
                    parameters.Add("PSPID", settings.PaymentServiceProviderId);
                    // We can't use order.bvin here because Ogone won't allow us try to pay failed order again
                    parameters.Add("ORDERID", "order" + DateTime.UtcNow.Ticks);
                    parameters.Add("AMOUNT", intAmount.ToString());
                    var regionInfo = new RegionInfo(context.HccApp.CurrentStore.Settings.CurrencyCultureCode);
                    parameters.Add("CURRENCY", regionInfo.ISOCurrencySymbol);
                    var language = CultureInfo.CurrentCulture.Name.Replace("-", "_");
                    parameters.Add("LANGUAGE", language);
                    parameters.Add("EMAIL", order.UserEmail);

                    var address = order.BillingAddress;
                    parameters.Add("CN", string.Join(" ", address.FirstName, address.LastName));
                    parameters.Add("OWNERADDRESS", string.Join(", ", address.Line2, address.Line1));
                    parameters.Add("OWNERZIP", address.PostalCode);
                    parameters.Add("OWNERTOWN", address.City);
                    parameters.Add("OWNERCTY", address.CountryDisplayName);
                    parameters.Add("OWNERTELNO", address.Phone);

                    parameters.Add("OPERATION", "SAL");
                    if (!string.IsNullOrWhiteSpace(settings.TemplatePage))
                    {
                        parameters.Add("TP", settings.TemplatePage);
                    }

                    var returnUrl = HccUrlBuilder.RouteHccUrl(HccRoute.ThirdPartyPayment);
                    var cancelUrl = HccUrlBuilder.RouteHccUrl(HccRoute.Checkout);
                    parameters.Add("ACCEPTURL", returnUrl);
                    parameters.Add("DECLINEURL", returnUrl);
                    parameters.Add("EXCEPTIONURL", returnUrl);
                    parameters.Add("CANCELURL", cancelUrl);

                    var shaSign = OgoneUtils.CalculateShaHash(parameters, settings.HashAlgorithm,
                                                              settings.ShaInPassPhrase);
                    parameters.Add("SHASIGN", shaSign);

                    HttpContextBase httpContext = new HccHttpContextWrapper(HttpContext.Current);

                    var url       = settings.DeveloperMode ? DevelopmentUTF8Url : ProductionUTF8Url;
                    var urlParams = Url.BuldQueryString(parameters);

                    if (settings.DebugMode)
                    {
                        EventLog.LogEvent("Ogone Checkout", urlParams, EventLogSeverity.Debug);
                    }

                    var urlTemplate = "{0}?{1}";
                    httpContext.Response.Redirect(string.Format(urlTemplate, url, urlParams), true);
                }
                catch (Exception ex)
                {
                    EventLog.LogEvent("Ogone Checkout", "Exception occurred during call to Ogone: " + ex,
                                      EventLogSeverity.Error);
                    context.Errors.Add(new WorkflowMessage("Ogone Checkout Error",
                                                           GlobalLocalization.GetString("OgoneCheckoutError"), true));
                    return(false);
                }
            }

            return(false);
        }