コード例 #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));
        }
コード例 #2
0
        private void SavePaymentInfo(CheckoutViewModel model)
        {
            var orderTransaction = new OrderTransaction
            {
                Success  = true,
                MethodId = MyPaymentMethod.Id(),
                OrderId  = model.CurrentOrder.bvin,
                Amount   = model.CurrentOrder.TotalGrandAfterStoreCredits(HccApp.OrderServices),
                Action   = ActionType.ThirdPartyPayMethodCharge,
                RefNum1  = string.Empty,
                RefNum2  = string.Empty
            };

            HccApp.OrderServices.AddPaymentTransactionToOrder(model.CurrentOrder, orderTransaction, HccApp);
        }