diff --git a/src/EventHub.Web/Pages/Donate.cshtml b/src/EventHub.Web/Pages/Donate.cshtml new file mode 100644 index 0000000..efba79d --- /dev/null +++ b/src/EventHub.Web/Pages/Donate.cshtml @@ -0,0 +1,32 @@ +@page +@using EventHub.Localization +@using EventHub.Web.Pages +@using Microsoft.Extensions.Localization + +@model DonateModel +@inject IStringLocalizer L + +
+
+ + + + @L["Donation"] + + + + + @L["DonationDescription"] + +
+ + + +
+ + + + +
+
+
\ No newline at end of file diff --git a/src/EventHub.Web/Pages/Donate.cshtml.cs b/src/EventHub.Web/Pages/Donate.cshtml.cs new file mode 100644 index 0000000..0668afd --- /dev/null +++ b/src/EventHub.Web/Pages/Donate.cshtml.cs @@ -0,0 +1,42 @@ +using Microsoft.AspNetCore.Http.Metadata; +using Microsoft.AspNetCore.Mvc; +using Payment.PaymentRequests; +using Payment.Web.PaymentRequest; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp.Users; + +namespace EventHub.Web.Pages +{ + public class DonateModel : EventHubPageModel + { + private readonly IPaymentRequestAppService _paymentRequestAppService; + private readonly IPaymentUrlBuilder _paymentUrlBuilder; + + public DonateModel( + IPaymentRequestAppService paymentRequestAppService, + IPaymentUrlBuilder paymentUrlBuilder) + { + _paymentRequestAppService = paymentRequestAppService; + _paymentUrlBuilder = paymentUrlBuilder; + } + + public decimal Amount { get; set; } = 5; + + public async Task OnPostAsync() + { + var paymentRequest = await _paymentRequestAppService.CreateAsync(new PaymentRequestCreationDto + { + CustomerId = CurrentUser.IsAuthenticated ? CurrentUser.Id.ToString() : Request.HttpContext.Connection.Id, + Price = Amount, + ProductId = "eventhub.donation", + ProductName = $"EventHub Donation | " + CurrentUser.UserName ?? Request.HttpContext.Connection.Id, + }); + + return Redirect(_paymentUrlBuilder.BuildCheckoutUrl(paymentRequest.Id).AbsoluteUri); + } + } +} diff --git a/src/EventHub.Web/Pages/Index.cshtml b/src/EventHub.Web/Pages/Index.cshtml index 881f098..d0b9c48 100644 --- a/src/EventHub.Web/Pages/Index.cshtml +++ b/src/EventHub.Web/Pages/Index.cshtml @@ -41,6 +41,7 @@

Join Now + Donate