public async Task <PaymentResult> MakePayment(StripeTokenViewModel model)
        {
            PurchaseCost pc = await _context.PurchaseCosts.Where(p => p.Id == model.purchaseType).SingleOrDefaultAsync();

            if (pc == null)
            {
                return(new PaymentResult(false, "Purchase type not found."));
            }

            try
            {
                await new StripeChargeService().CreateAsync(new StripeChargeCreateOptions()
                {
                    Amount      = (int)Math.Ceiling((pc.Price * 100)),
                    Currency    = "gbp",
                    Description = await _practicesService.GetCurrentUserPracticeName() + " bought " + pc.Quantity * model.purchaseQty + " x " + pc.PurchaseType.ToString(),
                    SourceTokenOrExistingSourceId = model.stripeToken
                });
            }
            catch (StripeException StEx)
            {
                return(new PaymentResult(false, StEx.Message));
            }

            return(new PaymentResult(true));
        }
        public async Task <IActionResult> Purchase(StripeTokenViewModel model)
        {
            PaymentResult result = await _clientRelationsService.MakePayment(model);

            if (result.Success)
            {
                await _practicesService.AddMessagePurchaseToPractice(model.purchaseType, model.purchaseQty);

                return(RedirectToAction("PurchaseSuccess"));
            }
            else
            {
                return(RedirectToAction("PurchaseFailure"));
            }
        }