Example #1
0
        public ActionResult Index()
        {
            // Here you can parse response from payment provider if you used hosted pay page scenario

            var settings       = new MyPaymentMethodSettings();
            var methodSettings = HccApp.CurrentStore.Settings.MethodSettingsGet(MyPaymentMethod.Id());

            settings.Merge(methodSettings);

            var model = new CheckoutViewModel {
                CurrentOrder = HccApp.OrderServices.CurrentShoppingCart()
            };

            var paymentSuccess = true; // this have to be determined from service response

            if (paymentSuccess)
            {
                SavePaymentInfo(model);
                ProcessOrder(model);
            }
            else
            {
                FlashFailure(Localization.GetString("ErrorOccured"));
            }

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

            return(View(model));
        }
Example #2
0
        public override bool ProcessCheckout(OrderTaskContext context)
        {
            if (context.HccApp.CurrentRequestContext.RoutingContext.HttpContext != null)
            {
                try
                {
                    var settings       = new MyPaymentMethodSettings();
                    var methodSettings = context.HccApp.CurrentStore.Settings.MethodSettingsGet(PaymentMethodId);
                    settings.Merge(methodSettings);

                    // Here you can do custom processing of your payment.

                    // It can be direct post to payment service or redirection to hosted payment page
                    // In either case you have to end up on HccUrlBuilder.RouteHccUrl(HccRoute.ThirdPartyPayment) page
                    // So either you have to do such redirect here on your own
                    // or make sure that third party hosted pay page will make it in case of successfull or failed payment

                    HttpContextBase httpContext = new HccHttpContextWrapper(HttpContext.Current);
                    httpContext.Response.Redirect(HccUrlBuilder.RouteHccUrl(HccRoute.ThirdPartyPayment));
                }
                catch (Exception ex)
                {
                    EventLog.LogEvent("My Custom Checkout", "Exception occurred during call to Moneris: " + ex,
                                      EventLogSeverity.Error);
                    context.Errors.Add(new WorkflowMessage("My Custom Checkout Error",
                                                           GlobalLocalization.GetString("MonerisCheckoutError"), true));
                    return(false);
                }
            }

            return(false);
        }
Example #3
0
        public override void LoadData()
        {
            var settings = new MyPaymentMethodSettings();

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

            txtUserName.Text = settings.UserName;
            txtPassword.Text = settings.Password;
        }
Example #4
0
        public override void SaveData()
        {
            var settings = new MyPaymentMethodSettings();

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

            settings.UserName = txtUserName.Text.Trim();
            settings.Password = txtPassword.Text.Trim();

            HccApp.CurrentStore.Settings.MethodSettingsSet(MethodId, settings);
            HccApp.AccountServices.Stores.Update(HccApp.CurrentStore);
        }