RIP Charges() (2022-2022)

This commit is contained in:
MarcEricMartel 2022-12-08 18:30:58 -08:00
parent 08e81224c7
commit 41ddc7d0e3

View File

@ -48,53 +48,6 @@ public class InvoiceController : Controller {
#endregion #endregion
#region API Methods #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] [HttpGet]
public ActionResult<List<InvoiceModel>> Get(bool? all = false) { public ActionResult<List<InvoiceModel>> Get(bool? all = false) {
IList<string> roles; IList<string> roles;