Browse Source

Improvements on Donate scenario

pull/69/head
enisn 5 years ago
parent
commit
ecdbcb5e88
  1. 9
      modules/payment/src/Payment.Domain.Shared/Localization/Payment/en.json
  2. 46
      modules/payment/src/Payment.Web/Pages/Payment/PostCheckout.cshtml
  3. 10
      modules/payment/src/Payment.Web/Pages/Payment/PostCheckout.cshtml.cs
  4. 54
      modules/payment/src/Payment.Web/Pages/Payment/PreCheckout.cshtml
  5. 16
      modules/payment/src/Payment.Web/Pages/Payment/PreCheckout.cshtml.cs
  6. 3
      modules/payment/src/Payment.Web/PaymentWebModule.cs

9
modules/payment/src/Payment.Domain.Shared/Localization/Payment/en.json

@ -1,9 +1,16 @@
{
"culture": "en",
"texts": {
"MyAccount": "My account",
"SamplePageMessage": "A sample page for the Payment module",
"YourPaymentCompletedSuccessfully": "Your payment has been completed successfully!",
"YourPaymentFailed": "Your payment has been failed unfortunetely!"
"YourPaymentFailed": "Your payment has been failed unfortunetely!",
"PaymentRequestIsNotWaiting": "The state isn't 'Waiting', so you can't pay this Payment Request at this time.",
"ProductName": "Product Name",
"Price": "Price",
"Status": "State",
"ProductInformation": "Product Information",
"CompletePayment": "Complete the Payment"
}
}

46
modules/payment/src/Payment.Web/Pages/Payment/PostCheckout.cshtml

@ -7,29 +7,31 @@
PageLayout.Content.Title = L["PaymentResult"] + L["Enum:PaymentRequestState:" + Model.PaymentRequest.State];
}
<abp-card>
<abp-card-header>
<h2>@L["PaymentResult"]</h2>
</abp-card-header>
<main class="static-page container mt-5">
<abp-card class="m-5">
<abp-card-header>
<h2>@L["PaymentResult"]</h2>
</abp-card-header>
<abp-card-body>
<abp-card-body>
@if (Model.PaymentRequest.State == PaymentRequestState.Completed)
{
<abp-alert alert-type="Success" dismissible="false">
<h1><i class="bi-check-circle-fill"></i></h1>
@L["YourPaymentCompletedSuccessfully"]
</abp-alert>
}
else
{
<abp-alert alert-type="Danger" dismissible="false">
<h1><i class="bi-check-circle-fill"></i></h1>
@L["YourPaymentFailed"]
</abp-alert>
@if (Model.PaymentRequest.State == PaymentRequestState.Completed)
{
<abp-alert alert-type="Success" dismissible="false">
<i class="bi-check-circle-fill"></i>
@L["YourPaymentCompletedSuccessfully"]
</abp-alert>
}
else
{
<abp-alert alert-type="Danger" dismissible="false">
<h1><i class="bi-check-circle-fill"></i></h1>
@L["YourPaymentFailed"]
</abp-alert>
<abp-button text="@L["GoBack"]"/>
}
<abp-button href="@Model.GoBackLink" text="@L["GoBack"]" />
}
</abp-card-body>
</abp-card>
</abp-card-body>
</abp-card>
</main>

10
modules/payment/src/Payment.Web/Pages/Payment/PostCheckout.cshtml.cs

@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using Payment.PaymentRequests;
using Payment.Web.PaymentRequest;
using System;
using System.Threading.Tasks;
@ -13,15 +14,20 @@ namespace Payment.Web.Pages.Payment
public PaymentRequestDto PaymentRequest { get; protected set; }
public string GoBackLink { get; set; }
private readonly IPaymentRequestAppService _paymentRequestAppService;
private readonly PaymentWebOptions _paymentWebOptions;
private readonly IPaymentUrlBuilder _paymentUrlBuilder;
public PostCheckoutPageModel(
IPaymentRequestAppService appService,
IOptions<PaymentWebOptions> paymentWebOptions)
IOptions<PaymentWebOptions> paymentWebOptions,
IPaymentUrlBuilder paymentUrlBuilder)
{
_paymentRequestAppService = appService;
_paymentWebOptions = paymentWebOptions.Value;
_paymentUrlBuilder = paymentUrlBuilder;
}
public async Task<IActionResult> OnGetAsync()
@ -33,6 +39,8 @@ namespace Payment.Web.Pages.Payment
PaymentRequest = await _paymentRequestAppService.CompleteAsync(Token);
GoBackLink = _paymentUrlBuilder.BuildReturnUrl(PaymentRequest.Id).AbsoluteUri;
if (PaymentRequest.State == PaymentRequestState.Completed
&& !_paymentWebOptions.PaymentSuccessfulCallbackUrl.IsNullOrWhiteSpace())
{

54
modules/payment/src/Payment.Web/Pages/Payment/PreCheckout.cshtml

@ -1,32 +1,38 @@
@page
@using Payment.Web.Pages.Payment
@using Payment.PaymentRequests
@inherits Payment.Web.Pages.PaymentPageBase
@model Payment.Web.Pages.Payment.PreCheckoutPageModel
@section scripts {
<abp-script-bundle name="@typeof(PreCheckoutPageModel).FullName">
<abp-script src="/client-proxies/Payment-proxy.js" />
</abp-script-bundle>
<abp-script-bundle name="@typeof(PreCheckoutPageModel).FullName">
<abp-script src="/client-proxies/Payment-proxy.js" />
</abp-script-bundle>
}
<h1>Checkout</h1>
<abp-card>
<abp-card-header>
<h2>Product Information</h2>
</abp-card-header>
<abp-card-body>
<ul>
<li>Product name: @Model.PaymentRequest.ProductName</li>
<li>Amount: @Model.PaymentRequest.Price</li>
</ul>
</abp-card-body>
</abp-card>
<abp-card>
<abp-card-body>
<form method="post">
<abp-button type="submit" button-type="Primary">Complete the payment</abp-button>
</form>
</abp-card-body>
</abp-card>
<main class="static-page container mt-5">
<abp-card class="m-5">
<abp-card-header>
<h2>@L["ProductInformation"]</h2>
</abp-card-header>
<abp-card-body>
<ul>
<li>@L["ProductName"]: @Model.PaymentRequest.ProductName</li>
<li>@L["Price"]: @Model.PaymentRequest.Price @Model.PaymentRequest.Currency</li>
<li>@L["State"]: @Model.PaymentRequest.State</li>
</ul>
</abp-card-body>
<abp-card-footer>
<form method="post">
@if (Model.PaymentRequest.State != PaymentRequestState.Waiting)
{
<abp-alert alert-type="Warning">@L["PaymentRequestIsNotWaiting"]</abp-alert>
}
else
{
<abp-button type="submit" button-type="Primary">@L["CompletePayment"]</abp-button>
}
</form>
</abp-card-footer>
</abp-card>
</main>

16
modules/payment/src/Payment.Web/Pages/Payment/PreCheckout.cshtml.cs

@ -3,6 +3,7 @@ using Payment.PaymentRequests;
using Payment.Web.PaymentRequest;
using System;
using System.Threading.Tasks;
using Volo.Abp;
namespace Payment.Web.Pages.Payment
{
@ -21,19 +22,28 @@ namespace Payment.Web.Pages.Payment
IPaymentUrlBuilder paymentUrlBuilder)
{
_paymentRequestAppService = paymentRequestAppService;
this._paymentUrlBuilder = paymentUrlBuilder;
_paymentUrlBuilder = paymentUrlBuilder;
}
public async Task OnGetAsync()
public async Task<IActionResult> OnGetAsync()
{
PaymentRequest = await _paymentRequestAppService.GetAsync(PaymentRequestId);
return Page();
}
public async Task OnPostAsync()
{
PaymentRequest = await _paymentRequestAppService.GetAsync(PaymentRequestId);
if (PaymentRequest.CreationTime.AddMinutes(15) >= Clock.Now)
{
throw new UserFriendlyException("Payment requiest is timed out.");
}
var result = await _paymentRequestAppService.StartPaymentAsync(new StartPaymentDto
{
PaymentRequestId = PaymentRequestId,
PaymentRequestId = PaymentRequest.Id,
ReturnUrl = _paymentUrlBuilder.BuildReturnUrl(PaymentRequestId).AbsoluteUri,
CancelUrl = _paymentUrlBuilder.BuildCheckoutUrl(PaymentRequestId).AbsoluteUri
});

3
modules/payment/src/Payment.Web/PaymentWebModule.cs

@ -2,14 +2,13 @@
using Microsoft.Extensions.DependencyInjection;
using Payment.Localization;
using Payment.Web.Menus;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc.Localization;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
using Volo.Abp.AutoMapper;
using Volo.Abp.Modularity;
using Volo.Abp.UI.Navigation;
using Volo.Abp.VirtualFileSystem;
using Payment.Permissions;
using Volo.Abp.AspNetCore.Mvc;
namespace Payment.Web
{

Loading…
Cancel
Save