public IActionResult ExecutePayment(string paymentId, string token, string PayerID) { Payment payment = _PaypalServices.ExecutePayment(paymentId, PayerID); if (payment.state == "approved") { int PackagePlanId = Convert.ToInt32(payment.transactions[0].custom); var plan = packagePlanService.GetPackagePlanById(PackagePlanId); DateTime StartDate = DateTime.Now; DateTime EndDate = DateTime.Now; if (plan.Duration == "Monthly") { EndDate = DateTime.Now.AddMonths(1); } else if (plan.Duration == "Annual") { EndDate = DateTime.Now.AddYears(1); } Business_Subscription model = new Business_Subscription { IdentityUserId = CurrentUserName, PackagePlanId = PackagePlanId, StartDate = StartDate, EndDate = EndDate, PaidAmount = Convert.ToDecimal(payment.transactions[0].amount.total), Currency = payment.transactions[0].amount.currency, PaymentReceived = true, PaymentVia = payment.payer.payment_method, PaymentReceipt = payment.id, PaymentReceivedDate = Convert.ToDateTime(payment.create_time), PaymentNotes = payment.cart + " - " + payment.transactions[0].related_resources[0].sale.payment_mode }; var response = subscriptionService.MapViewModelToBusiness_Subscription(model, CurrentUserName, true); } return(Ok()); }
public async Task <ActionResult> SignUp(BusinessViewModel model) { int paymentID = 0; if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.ContactEmail, Email = model.ContactEmail }; IdentityResult result = null; if (string.IsNullOrEmpty(model.IdentityUserId) || model.Id.Equals("0")) { result = await _userManager.CreateAsync(user, model.Password); if (result.Succeeded) { user = _userManager.FindByEmailAsync(model.ContactEmail).Result; if (user != null) { model.IdentityUserId = user.Email; model.Id = businessService.MapViewModelToSite(model, user.Email, true); var plan = packagePlanService.GetPackagePlanById(model.PackageID); DateTime StartDate = DateTime.Now; DateTime EndDate = DateTime.Now; if (plan.Duration == "Monthly") { EndDate = DateTime.Now.AddMonths(1); } else if (plan.Duration == "Annual") { EndDate = DateTime.Now.AddYears(1); } Business_Subscription models = new Business_Subscription { IdentityUserId = user.Email, PackagePlanId = model.PackageID, StartDate = StartDate, EndDate = EndDate, PaymentReceived = false, }; paymentID = subscriptionService.MapViewModelToBusiness_Subscription(models, user.Id, true); } ViewBag.IsSuccess = result.Succeeded; return(RedirectToAction("Payment", "Home", new { id = paymentID })); } else { return(View("SignUp", model)); } } else { return(View("SignUp", model)); } } else { return(View("SignUp", model)); } }