public IHttpActionResult GetAvailablePaymentMethods([FromUri] UserPaymentModel requestModel) { if (requestModel == null || !ModelState.IsValid) { return(Json(new { Success = false, Message = "Invalid data supplied" })); } ; //first check if the customer has an address, otherwise first address form will be shown var currentUser = ApplicationContext.Current.CurrentUser; var battleId = requestModel.BattleId; var battleType = requestModel.BattleType; var purchaseType = requestModel.PurchaseType; //TODO: Remove comment when picture battles are ready var battle = _videoBattleService.Get(battleId); // Model.BattleType == BattleType.Video ? _videoBattleService.GetById(Model.BattleId) : null; var responseModel = new UserPaymentPublicModel { IsAmountVariable = purchaseType == PurchaseType.SponsorPass || battle.CanVoterIncreaseVotingCharge, MinimumPaymentAmount = purchaseType == PurchaseType.SponsorPass ? battle.MinimumSponsorshipAmount : battle.MinimumVotingCharge, PurchaseType = requestModel.PurchaseType }; //if purchase type is sponsor and customer is already a sponsor, he should not have a minimum amount criteria if (purchaseType == PurchaseType.SponsorPass) { var alreadySponsor = _sponsorService.Get(x => x.BattleId == battleId && x.BattleType == battleType, null).Any(); if (alreadySponsor) { responseModel.MinimumPaymentAmount = 1; } } //get available credits responseModel.AvailableCredits = _creditService.GetAvailableCreditsCount(currentUser.Id, null); //set the usable credits now responseModel.UsableCredits = _creditService.GetUsableCreditsCount(currentUser.Id); //let's get the payment methods for the logged in user var paymentMethods = _paymentMethodService.GetCustomerPaymentMethods(currentUser.Id); foreach (var pm in paymentMethods) { responseModel.UserPaymentMethods.Add(new System.Web.Mvc.SelectListItem() { Text = pm.NameOnCard + " (" + pm.CardNumberMasked + ")", Value = pm.Id.ToString() }); } if (battle.VideoBattleStatus == BattleStatus.Complete) { return(Json(new { Success = false, Message = "Battle completed" })); } //battle should not be complete before payment form can be opened return(Json(new { Success = true, AvailablePaymentMethods = responseModel })); }