public IActionResult PayButton()
        {
            var store = StoreData;

            var storeBlob = store.GetStoreBlob();

            if (!storeBlob.AnyoneCanInvoice)
            {
                return(View("PayButtonEnable", null));
            }

            var appUrl = HttpContext.Request.GetAbsoluteRoot().WithTrailingSlash();
            var model  = new PayButtonViewModel
            {
                Price             = 10,
                Currency          = DEFAULT_CURRENCY,
                ButtonSize        = 2,
                UrlRoot           = appUrl,
                PayButtonImageUrl = appUrl + "img/paybutton/pay.svg",
                StoreId           = store.Id,
                ButtonType        = 0,
                Min  = 1,
                Max  = 20,
                Step = 1
            };

            return(View(model));
        }
Beispiel #2
0
        public async Task <IActionResult> PayButton()
        {
            var store     = GetCurrentStore;
            var storeBlob = store.GetStoreBlob();

            if (!storeBlob.AnyoneCanInvoice)
            {
                return(View("PayButton/Enable", null));
            }

            var apps = await _appService.GetAllApps(_userManager.GetUserId(User), false, store.Id);

            var appUrl = HttpContext.Request.GetAbsoluteRoot().WithTrailingSlash();
            var model  = new PayButtonViewModel
            {
                Price                = null,
                Currency             = storeBlob.DefaultCurrency,
                DefaultPaymentMethod = string.Empty,
                PaymentMethods       = _storesController.GetEnabledPaymentMethodChoices(store),
                ButtonSize           = 2,
                UrlRoot              = appUrl,
                PayButtonImageUrl    = appUrl + "img/paybutton/pay.svg",
                StoreId              = store.Id,
                ButtonType           = 0,
                Min  = 1,
                Max  = 20,
                Step = "1",
                Apps = apps
            };

            return(View("PayButton/PayButton", model));
        }
        public async Task <IActionResult> PayButtonHandle(string storeId, [FromForm] PayButtonViewModel model)
        {
            var store = StoreData;

            // TODO: extract validation to model
            if (model.Price <= 0)
            {
                ModelState.AddModelError("Price", "Price must be greater than 0");
            }

            if (!ModelState.IsValid)
            {
                return(View());
            }

            var invoice = await _InvoiceController.CreateInvoiceCore(new NBitpayClient.Invoice()
            {
                Price             = model.Price,
                Currency          = model.Currency,
                ItemDesc          = model.CheckoutDesc,
                OrderId           = model.OrderId,
                BuyerEmail        = model.NotifyEmail,
                NotificationURL   = model.ServerIpn,
                RedirectURL       = model.BrowserRedirect,
                FullNotifications = true
            }, store, HttpContext.Request.GetAbsoluteRoot());

            return(Redirect(invoice.Data.Url));
        }
        public async Task <IActionResult> PayButtonHandle([FromForm] PayButtonViewModel model, CancellationToken cancellationToken)
        {
            var store = await _StoreRepository.FindStore(model.StoreId);

            if (store == null)
            {
                ModelState.AddModelError("Store", "Invalid store");
            }
            else
            {
                var storeBlob = store.GetStoreBlob();
                if (!storeBlob.AnyoneCanInvoice)
                {
                    ModelState.AddModelError("Store", "Store has not enabled Pay Button");
                }
            }

            if (model == null || model.Price <= 0)
            {
                ModelState.AddModelError("Price", "Price must be greater than 0");
            }

            if (!ModelState.IsValid)
            {
                return(View());
            }

            var invoice = await _InvoiceController.CreateInvoiceCore(new CreateInvoiceRequest()
            {
                Price             = model.Price,
                Currency          = model.Currency,
                ItemDesc          = model.CheckoutDesc,
                OrderId           = model.OrderId,
                NotificationEmail = model.NotifyEmail,
                NotificationURL   = model.ServerIpn,
                RedirectURL       = model.BrowserRedirect,
                FullNotifications = true
            }, store, HttpContext.Request.GetAbsoluteRoot(), cancellationToken : cancellationToken);

            if (string.IsNullOrEmpty(model.CheckoutQueryString))
            {
                return(Redirect(invoice.Data.Url));
            }

            var additionalParamValues = HttpUtility.ParseQueryString(model.CheckoutQueryString);
            var uriBuilder            = new UriBuilder(invoice.Data.Url);
            var paramValues           = HttpUtility.ParseQueryString(uriBuilder.Query);

            paramValues.Add(additionalParamValues);
            uriBuilder.Query = paramValues.ToString();
            return(Redirect(uriBuilder.Uri.AbsoluteUri));
        }
        public IActionResult PayButton()
        {
            var store = StoreData;

            var appUrl = HttpContext.Request.GetAbsoluteRoot().WithTrailingSlash();
            var model  = new PayButtonViewModel
            {
                Price             = 10,
                Currency          = DEFAULT_CURRENCY,
                ButtonSize        = 2,
                UrlRoot           = appUrl,
                PayButtonImageUrl = appUrl + "img/paybutton/pay.png",
                StoreId           = store.Id
            };

            return(View(model));
        }
Beispiel #6
0
        public async Task <IActionResult> PayButtonHandle([FromForm] PayButtonViewModel model)
        {
            var store = await _StoreRepository.FindStore(model.StoreId);

            if (store == null)
            {
                ModelState.AddModelError("Store", "Invalid store");
            }
            else
            {
                var storeBlob = store.GetStoreBlob();
                if (!storeBlob.AnyoneCanInvoice)
                {
                    ModelState.AddModelError("Store", "Store has not enabled Pay Button");
                }
            }

            if (model == null || model.Price <= 0)
            {
                ModelState.AddModelError("Price", "Price must be greater than 0");
            }

            if (!ModelState.IsValid)
            {
                return(View());
            }

            var invoice = await _InvoiceController.CreateInvoiceCore(new NBitpayClient.Invoice()
            {
                Price             = model.Price,
                Currency          = model.Currency,
                ItemDesc          = model.CheckoutDesc,
                OrderId           = model.OrderId,
                NotificationEmail = model.NotifyEmail,
                NotificationURL   = model.ServerIpn,
                RedirectURL       = model.BrowserRedirect,
                FullNotifications = true
            }, store, HttpContext.Request.GetAbsoluteRoot());

            return(Redirect(invoice.Data.Url));
        }
        public async Task <IActionResult> PayButtonHandle([FromForm] PayButtonViewModel model, CancellationToken cancellationToken)
        {
            var store = await _StoreRepository.FindStore(model.StoreId);

            if (store == null)
            {
                ModelState.AddModelError("Store", "Invalid store");
            }
            else
            {
                var storeBlob = store.GetStoreBlob();
                if (!storeBlob.AnyoneCanInvoice)
                {
                    ModelState.AddModelError("Store", "La tienda no ha habilitado el botón de pago");
                }
            }

            if (model == null || model.Price <= 0)
            {
                ModelState.AddModelError("Price", "El precio debe ser mayor que 0");
            }

            if (!ModelState.IsValid)
            {
                return(View());
            }

            var invoice = await _InvoiceController.CreateInvoiceCore(new CreateInvoiceRequest()
            {
                Price             = model.Price,
                Currency          = model.Currency,
                ItemDesc          = model.CheckoutDesc,
                OrderId           = model.OrderId,
                NotificationEmail = model.NotifyEmail,
                NotificationURL   = model.ServerIpn,
                RedirectURL       = model.BrowserRedirect,
                FullNotifications = true
            }, store, HttpContext.Request.GetAbsoluteRoot(), cancellationToken : cancellationToken);

            return(Redirect(invoice.Data.Url));
        }
Beispiel #8
0
 public async Task <IActionResult> PayButtonHandle(PayButtonViewModel model)
 {
     return(await PayButtonHandle(model, CancellationToken.None));
 }