From ba9000c88c005eb7732462cdd28234da9acfb7c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Thu, 7 Oct 2021 16:47:08 +0300 Subject: [PATCH] Added checkout page --- .../IPaymentRequestAppService.cs | 5 ++- .../PaymentRequestAppService.cs | 12 +++++-- .../Payment.Web/Pages/Payment/Checkout.cshtml | 34 +++++++++++++++++++ .../Pages/Payment/Checkout.cshtml.cs | 32 +++++++++++++++++ .../Payment.Web/Pages/Payment/Index.cshtml | 17 ---------- .../Payment.Web/Pages/Payment/Index.cshtml.cs | 9 ----- 6 files changed, 80 insertions(+), 29 deletions(-) create mode 100644 modules/payment/src/Payment.Web/Pages/Payment/Checkout.cshtml create mode 100644 modules/payment/src/Payment.Web/Pages/Payment/Checkout.cshtml.cs delete mode 100644 modules/payment/src/Payment.Web/Pages/Payment/Index.cshtml delete mode 100644 modules/payment/src/Payment.Web/Pages/Payment/Index.cshtml.cs diff --git a/modules/payment/src/Payment.Application.Contracts/PaymentRequests/IPaymentRequestAppService.cs b/modules/payment/src/Payment.Application.Contracts/PaymentRequests/IPaymentRequestAppService.cs index 0467c6d..b2ddaac 100644 --- a/modules/payment/src/Payment.Application.Contracts/PaymentRequests/IPaymentRequestAppService.cs +++ b/modules/payment/src/Payment.Application.Contracts/PaymentRequests/IPaymentRequestAppService.cs @@ -1,10 +1,13 @@ -using System.Threading.Tasks; +using System; +using System.Threading.Tasks; using Volo.Abp.Application.Services; namespace Payment.PaymentRequests { public interface IPaymentRequestAppService : IApplicationService { + Task GetAsync(Guid id); + Task CreateAsync(PaymentRequestCreationDto input); } } \ No newline at end of file diff --git a/modules/payment/src/Payment.Application/PaymentRequests/PaymentRequestAppService.cs b/modules/payment/src/Payment.Application/PaymentRequests/PaymentRequestAppService.cs index bfe3504..9f4cc6e 100644 --- a/modules/payment/src/Payment.Application/PaymentRequests/PaymentRequestAppService.cs +++ b/modules/payment/src/Payment.Application/PaymentRequests/PaymentRequestAppService.cs @@ -1,4 +1,5 @@ -using System.Threading.Tasks; +using System; +using System.Threading.Tasks; namespace Payment.PaymentRequests { @@ -10,7 +11,14 @@ namespace Payment.PaymentRequests { _paymentRequestRepository = paymentRequestRepository; } - + + public async Task GetAsync(Guid id) + { + var paymentRequest = await _paymentRequestRepository.GetAsync(id); + + return ObjectMapper.Map(paymentRequest); + } + public async Task CreateAsync(PaymentRequestCreationDto input) { var paymentRequest = new PaymentRequest( diff --git a/modules/payment/src/Payment.Web/Pages/Payment/Checkout.cshtml b/modules/payment/src/Payment.Web/Pages/Payment/Checkout.cshtml new file mode 100644 index 0000000..f1f30e4 --- /dev/null +++ b/modules/payment/src/Payment.Web/Pages/Payment/Checkout.cshtml @@ -0,0 +1,34 @@ +@page +@using Microsoft.Extensions.Localization +@using Payment.Localization +@using Payment.Web.Pages.Payment +@model Payment.Web.Pages.Payment.CheckoutPageModel +@inject IStringLocalizer L + +@section scripts { + + + +} + +

Checkout

+ + + +

Product Information

+
+ +
    +
  • Product name: @Model.PaymentRequest.ProductName
  • +
  • Amount: @Model.PaymentRequest.Amount
  • +
+
+
+ + + +
+ Complete the payment +
+
+
\ No newline at end of file diff --git a/modules/payment/src/Payment.Web/Pages/Payment/Checkout.cshtml.cs b/modules/payment/src/Payment.Web/Pages/Payment/Checkout.cshtml.cs new file mode 100644 index 0000000..732d2b2 --- /dev/null +++ b/modules/payment/src/Payment.Web/Pages/Payment/Checkout.cshtml.cs @@ -0,0 +1,32 @@ +using System; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Payment.PaymentRequests; + +namespace Payment.Web.Pages.Payment +{ + public class CheckoutPageModel : PaymentPageModel + { + [BindProperty(SupportsGet = true)] + public Guid PaymentRequestId { get; set; } + + public PaymentRequestDto PaymentRequest { get; set; } + + private readonly IPaymentRequestAppService _paymentRequestAppService; + + public CheckoutPageModel(IPaymentRequestAppService paymentRequestAppService) + { + _paymentRequestAppService = paymentRequestAppService; + } + + public async Task OnGetAsync() + { + PaymentRequest = await _paymentRequestAppService.GetAsync(PaymentRequestId); + } + + public async Task OnPostAsync() + { + PaymentRequest = await _paymentRequestAppService.GetAsync(PaymentRequestId); + } + } +} \ No newline at end of file diff --git a/modules/payment/src/Payment.Web/Pages/Payment/Index.cshtml b/modules/payment/src/Payment.Web/Pages/Payment/Index.cshtml deleted file mode 100644 index 80d5365..0000000 --- a/modules/payment/src/Payment.Web/Pages/Payment/Index.cshtml +++ /dev/null @@ -1,17 +0,0 @@ -@page -@using Microsoft.Extensions.Localization -@using Payment.Localization -@using Payment.Web.Pages.Payment -@model Payment.Web.Pages.Payment.IndexModel -@inject IStringLocalizer L - -@section scripts { - - - -} - -@{ -} -

Payment

-

@L["SamplePageMessage"]

diff --git a/modules/payment/src/Payment.Web/Pages/Payment/Index.cshtml.cs b/modules/payment/src/Payment.Web/Pages/Payment/Index.cshtml.cs deleted file mode 100644 index d57c76c..0000000 --- a/modules/payment/src/Payment.Web/Pages/Payment/Index.cshtml.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Payment.Web.Pages.Payment -{ - public class IndexModel : PaymentPageModel - { - public void OnGet() - { - } - } -} \ No newline at end of file