diff --git a/BookingMicroservice/Controllers/BookingController.cs b/BookingMicroservice/Controllers/BookingController.cs index c9cfa21b771a693df821fc79d07e8b0868e305b0..9d8953ad4e996aeb86348b3dd7c7b5733a30d34f 100644 --- a/BookingMicroservice/Controllers/BookingController.cs +++ b/BookingMicroservice/Controllers/BookingController.cs @@ -142,8 +142,9 @@ namespace BookingMicroservice.Controllers } } + [Authorize] [HttpPost("create-payment-intent")] - public ActionResult CreatePaymentIntent([FromBody] PaymentIntentCreateRequest request) + public async Task<IActionResult> CreatePaymentIntent([FromBody] PaymentIntentCreateRequest request) { var paymentIntentService = new PaymentIntentService(); var paymentIntent = paymentIntentService.Create(new PaymentIntentCreateOptions diff --git a/GatewayAPI/Clients/BookingService/BookingServiceClient.cs b/GatewayAPI/Clients/BookingService/BookingServiceClient.cs index be1534f6625a2bd965338ee04da172178c0d95c1..d6b89c3445e2d285487c769c02ba61203b16d7f1 100644 --- a/GatewayAPI/Clients/BookingService/BookingServiceClient.cs +++ b/GatewayAPI/Clients/BookingService/BookingServiceClient.cs @@ -57,6 +57,10 @@ namespace GatewayAPI.Clients.BookingService return httpClient.GetAsync($"{API_PATH}/history"); } + public Task<HttpResponseMessage> CreatePaymentIntent(PaymentIntentCreateRequest request) + { + return httpClient.PostAsJsonAsync($"{API_PATH}/create-payment-intent", request); + } } } diff --git a/GatewayAPI/Clients/BookingService/IBookingServiceClient.cs b/GatewayAPI/Clients/BookingService/IBookingServiceClient.cs index be2db11631d06c73ce80fe82ada5f986c71129a9..669bf30e87fcc17b1cbf16422b1b38256c5d30e9 100644 --- a/GatewayAPI/Clients/BookingService/IBookingServiceClient.cs +++ b/GatewayAPI/Clients/BookingService/IBookingServiceClient.cs @@ -10,5 +10,6 @@ namespace GatewayAPI.Clients.BookingService Task<HttpResponseMessage> UpdateBookingAsync(int bookindId, BookingUpdate bookingModel); Task<HttpResponseMessage> GetUpcomingFlightBookingsAsync(); Task<HttpResponseMessage> GetPreviousFlightBookingsAsync(); + Task<HttpResponseMessage> CreatePaymentIntent(PaymentIntentCreateRequest request); } } diff --git a/GatewayAPI/Controllers/BookingController.cs b/GatewayAPI/Controllers/BookingController.cs index b6ce381f4239cc4f86ae459d3bdc98b757d63e12..857ce7a08774623c9b7fd5293ac50e1aa985fc4b 100644 --- a/GatewayAPI/Controllers/BookingController.cs +++ b/GatewayAPI/Controllers/BookingController.cs @@ -57,5 +57,12 @@ namespace GatewayAPI.Controllers HttpResponseMessage response = await bookingServiceClient.GetPreviousFlightBookingsAsync(); return new HttpResponseMessageResult(response); } + + [HttpPost("create-payment-intent")] + public async Task<IActionResult> CreatePaymentIntent([FromBody] PaymentIntentCreateRequest request) + { + HttpResponseMessage response = await bookingServiceClient.CreatePaymentIntent(request); + return new HttpResponseMessageResult(response); + } } } diff --git a/GatewayAPI/Models/PaymentIntentCreateRequest.cs b/GatewayAPI/Models/PaymentIntentCreateRequest.cs new file mode 100644 index 0000000000000000000000000000000000000000..6ebf13a12857fddbd5647b47f4607bb266aa866c --- /dev/null +++ b/GatewayAPI/Models/PaymentIntentCreateRequest.cs @@ -0,0 +1,13 @@ +namespace GatewayAPI.Models +{ + public class PaymentIntentCreateRequest + { + public List<Item> Items { get; set; } + } + + public class Item + { + public int Price { get; set; } + } + +} \ No newline at end of file