From d6fe9186f8845933d86c3867b362a825e4623148 Mon Sep 17 00:00:00 2001 From: enisn Date: Mon, 25 Oct 2021 08:57:11 +0300 Subject: [PATCH] Create PaymentRequestController.cs --- .../Controllers/PaymentRequestController.cs | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 services/payment/src/EShopOnAbp.PaymentService.HttpApi/Controllers/PaymentRequestController.cs diff --git a/services/payment/src/EShopOnAbp.PaymentService.HttpApi/Controllers/PaymentRequestController.cs b/services/payment/src/EShopOnAbp.PaymentService.HttpApi/Controllers/PaymentRequestController.cs new file mode 100644 index 00000000..7325ed28 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.HttpApi/Controllers/PaymentRequestController.cs @@ -0,0 +1,50 @@ +using EShopOnAbp.PaymentService.PaymentRequests; +using Microsoft.AspNetCore.Mvc; +using System.IO; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp; + +namespace EShopOnAbp.PaymentService.Controllers +{ + [RemoteService(Name = PaymentServiceRemoteServiceConsts.RemoteServiceName)] + [Area("payment")] + [Route("api/payment/requests")] + public class PaymentRequestController : PaymentServiceController, IPaymentRequestAppService + { + protected IPaymentRequestAppService PaymentRequestAppService { get; } + + public PaymentRequestController(IPaymentRequestAppService paymentRequestAppService) + { + PaymentRequestAppService = paymentRequestAppService; + } + + [HttpPost("complete")] + public Task CompleteAsync(string token) + { + return PaymentRequestAppService.CompleteAsync(token); + } + + [HttpPost] + public Task CreateAsync(PaymentRequestCreationDto input) + { + return PaymentRequestAppService.CreateAsync(input); + } + + [HttpPost] + [Route("webhook")] + public async Task HandleWebhookAsync(string payload) + { + var bytes = await Request.Body.GetAllBytesAsync(); + payload = Encoding.UTF8.GetString(bytes); + + return await PaymentRequestAppService.HandleWebhookAsync(payload); + } + + [HttpPost("start")] + public Task StartAsync(PaymentRequestStartDto input) + { + return PaymentRequestAppService.StartAsync(input); + } + } +}