public async Task <IActionResult> Promote(PromoteBindingModel input) { if (!ModelState.IsValid) { return(Redirect($"/Advertisement/Promote?id={input.Id}")); } StripeConfiguration.ApiKey = configuration["Stripe:SecretKey"]; var prices = new Dictionary <string, int>() { { "1", 200 }, { "7", 600 }, { "14", 1000 }, { "30", 2000 } }; var service = new PaymentIntentService(); var options = new PaymentIntentCreateOptions { //amount is in cents Amount = prices[input.PromotedDays], Currency = "usd", // Verify your integration in this guide by including this parameter Metadata = new Dictionary <String, String>() { { "integration_check", "accept_a_payment" } } }; var payment = service.Create(options); await advertisementService.PromoteByIdAsync(input.Id, int.Parse(input.PromotedDays)); return(Redirect($"/User/Profile?page=1")); }
public async Task <IActionResult> Promote(PromoteBindingModel input) { if (!ModelState.IsValid) { return(RedirectToAction("All")); } var days = int.Parse(input.Days); var ad = await advertisementService.GetByIdAsync(input.Id); await advertisementService.PromoteByIdAsync(ad.Id, days); var notificationText = $"Your ad has been promoted for {days} days by admin - '{ad.Name}'"; var actionLink = $"/Advertisement/Details?id={ad.Id}"; var notification = await notificationService.CreateNotificationAsync(notificationText, actionLink); await notificationService.AssignNotificationToUserAsync(notification.Id, ad.UserId); return(RedirectToAction("All")); }