// GET: MerchantPayments/Create
        // GET: ProfessionalPayments/Create
        public async Task <ActionResult> Create()
        {
            var userId    = User.Identity.GetUserId();
            var merchants = await _db.Merchants.AsNoTracking()
                            .Where(x => x.MerchantId.Equals(userId))
                            .FirstOrDefaultAsync();

            var model = new MerchantPaymentVm
            {
                Amount       = 5000,
                MerchantId   = userId,
                MerchantName = merchants.FullName
            };

            return(View(model));
        }
        public async Task <ActionResult> Create(MerchantPaymentVm model)
        {
            if (ModelState.IsValid)
            {
                var merchantId = User.Identity.GetUserId();

                var merchant = await _db.Merchants.AsNoTracking()
                               .FirstOrDefaultAsync(x => x.MerchantId.Equals(merchantId));

                var testOrLiveSecret = ConfigurationManager.AppSettings["PayStackSecret"];
                var api = new PayStackApi(testOrLiveSecret);
                // Initializing a transaction
                //var response = api.Transactions.Initialize("*****@*****.**", 5000000);
                var transactionInitializaRequest = new TransactionInitializeRequest
                {
                    //Reference = "SwifKampus",
                    AmountInKobo = _query.ConvertToKobo((int)model.Amount),
                    //CallbackUrl = "https://unibenportal.azurewebsites.net/SchoolFeePayments/ConfrimPayment",
                    CallbackUrl = "http://localhost:59969/MerchantPayments/ConfrimPayment",
                    Email       = merchant.Email,
                    Bearer      = "Application fee",

                    CustomFields = new List <CustomField>
                    {
                        new CustomField("merchantid", "merchantid", merchant.MerchantId),
                        new CustomField("amount", "amount", model.Amount.ToString(CultureInfo.InvariantCulture))
                        //new CustomField("sessionid", "sessionid", schoolFeePayment.SessionId.ToString()),
                        //new CustomField("feepaymentid","feepaymentid", schoolFeePayment.FeeCategoryId.ToString())
                        //new CustomField("paymentmode","paymentmode", schoolFeePayment.p)
                    }
                };
                var response = api.Transactions.Initialize(transactionInitializaRequest);

                if (response.Status)
                {
                    //redirect to authorization url
                    return(RedirectPermanent(response.Data.AuthorizationUrl));
                    // return Content("Successful");
                }
                return(Content("An error occurred"));
            }
            //return View(schoolFeePayment);
            return(RedirectToAction("Create"));
        }