diff --git a/GrossesMitaines/GrossesMitainesAPI/Controllers/InvoiceController.cs b/GrossesMitaines/GrossesMitainesAPI/Controllers/InvoiceController.cs index 43f8342..ba0225c 100644 --- a/GrossesMitaines/GrossesMitainesAPI/Controllers/InvoiceController.cs +++ b/GrossesMitaines/GrossesMitainesAPI/Controllers/InvoiceController.cs @@ -48,53 +48,6 @@ public class InvoiceController : Controller { #endregion #region API Methods - [HttpPost("Payment")] - public IActionResult Charges([FromBody] ChargeReturnModel model) { - StripeConfiguration.ApiKey = _stripeOptions.Value.SecretKey; - InvoiceModel inv; - ChargesModel chr; - - try { - inv = _context.Invoices.First(x => x.Id == model.Invoice); - } catch { - return BadRequest("Numéro de commande invalide."); - } - - chr = new() { - Token = model.Token, - AmountInCents = model.AmountInCents, - Name = model.Name, - Phone = model.Phone, - Email = model.Email, - Description = model.Description, - CurrencyCode = model.CurrencyCode - }; - - inv.Payment = chr; - - var options = new ChargeCreateOptions { - Amount = model.AmountInCents, - Description = model.Description, - Source = model.Token, - Currency = model.CurrencyCode, - }; - var service = new ChargeService(); - Charge charge = service.Create(options); - - if (charge.FailureMessage is not null && charge.FailureMessage != "") - return Json(charge.ToJson()); - - try { - _context.Invoices.Update(inv); - _context.SaveChanges(); - } catch (Exception ex) { - _logger.LogError(20, ex.Message); - return BadRequest(ex.Message); - } - - return Json(charge.ToJson()); - } - [HttpGet] public ActionResult> Get(bool? all = false) { IList roles;