From 41ddc7d0e3bf0e7e48ada127a1489a6d209fb484 Mon Sep 17 00:00:00 2001 From: MarcEricMartel <74071476+MarcEricMartel@users.noreply.github.com> Date: Thu, 8 Dec 2022 18:30:58 -0800 Subject: [PATCH] RIP Charges() (2022-2022) --- .../Controllers/InvoiceController.cs | 47 ------------------- 1 file changed, 47 deletions(-) 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;