mirror of https://github.com/abpframework/eventhub
3 changed files with 75 additions and 0 deletions
@ -0,0 +1,32 @@ |
|||
@page |
|||
@using EventHub.Localization |
|||
@using EventHub.Web.Pages |
|||
@using Microsoft.Extensions.Localization |
|||
|
|||
@model DonateModel |
|||
@inject IStringLocalizer<EventHubResource> L |
|||
|
|||
<main class="static-page container mt-5"> |
|||
<form method="post"> |
|||
<abp-card> |
|||
<abp-card-header> |
|||
<abp-card-title> |
|||
@L["Donation"] |
|||
</abp-card-title> |
|||
</abp-card-header> |
|||
|
|||
<abp-card-body> |
|||
@L["DonationDescription"] |
|||
|
|||
<hr /> |
|||
|
|||
<abp-input asp-for="Amount" /> |
|||
|
|||
</abp-card-body> |
|||
|
|||
<abp-card-footer> |
|||
<abp-button type="submit" size="Block" button-type="Outline_Primary" text="@L["Donate"]" /> |
|||
</abp-card-footer> |
|||
</abp-card> |
|||
</form> |
|||
</main> |
|||
@ -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<IActionResult> 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); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue