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); + } + } +}