2022-05-30 13:25:27 -07:00
|
|
|
using API.Errors;
|
2022-05-27 15:40:30 -07:00
|
|
|
using Core.Entities;
|
|
|
|
using Core.Interfaces;
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
|
|
namespace API.Controllers
|
|
|
|
{
|
|
|
|
public class PaymentsController : BaseApiController
|
|
|
|
{
|
|
|
|
private readonly IPaymentService _paymentService;
|
|
|
|
public PaymentsController(IPaymentService paymentService)
|
|
|
|
{
|
|
|
|
_paymentService = paymentService;
|
|
|
|
}
|
|
|
|
|
|
|
|
[Authorize]
|
|
|
|
[HttpPost("{basketId}")]
|
|
|
|
public async Task<ActionResult<CustomerBasket>> CreateOrUpdatePaymentIntent(string basketId)
|
|
|
|
{
|
2022-05-30 13:25:27 -07:00
|
|
|
var basket = await _paymentService.CreateOrUpdatePaymentIntent(basketId);
|
|
|
|
if(basket == null) return BadRequest(new ApiResponse(400, "Problem with your basket"));
|
|
|
|
return basket;
|
2022-05-27 15:40:30 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|