api-server-setup #1

Merged
derek merged 37 commits from api-server-setup into main 2025-07-15 21:17:25 -07:00
5 changed files with 4 additions and 27 deletions
Showing only changes of commit dd7b7e6de6 - Show all commits
@@ -8,7 +8,7 @@ using BoredCareers.Entities;
namespace BoredCareers.Controllers { namespace BoredCareers.Controllers {
[ApiController] [ApiController]
[Route("api/account/[controller]")] [Route("api/account/")]
public class AuthenticationController : MistoxControllerBase { public class AuthenticationController : MistoxControllerBase {
EmailService _emailContext; EmailService _emailContext;
+1 -22
View File
@@ -1,11 +1,10 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using BoredCareers.Controllers.Payment; using BoredCareers.Controllers.Payment;
using BoredCareers.Services.DatabaseService; using BoredCareers.Services.DatabaseService;
using BoredCareers.Entities;
namespace BoredCareers.Controllers { namespace BoredCareers.Controllers {
[ApiController] [ApiController]
[Route("api/payment/[controller]")] [Route("api/payment/")]
public class PaymentController : MistoxControllerBase { public class PaymentController : MistoxControllerBase {
IPayment _paymentService; IPayment _paymentService;
@@ -20,26 +19,6 @@ namespace BoredCareers.Controllers {
// Add new payment plugins here // Add new payment plugins here
} }
[Route("getcheckouttoken")]
[HttpPost]
public async Task<string> GetCheckoutToken() {
string OrderNumber = Guid.NewGuid().ToString().Substring(0, 10);
if (isLoggedIn()) {
Cart[] carts = await _databaseService.GetCart(getLoggedInUserID());
(bool, string) PaymentResponse = await _paymentService.TryGetCheckoutToken(OrderNumber, getLoggedInUserID(), carts);
if (PaymentResponse.Item1) {
// Returns client secret
return PaymentResponse.Item2;
} else {
Console.WriteLine("An error has occured in the payment plugin\n\n");
Console.WriteLine(PaymentResponse.Item2);
Console.WriteLine("\n");
return "An error has occured in the payment plugin";
}
}
return "You must be logged in";
}
[Route("getpublickey")] [Route("getpublickey")]
[HttpPost] [HttpPost]
public IActionResult GetPublicKey() { public IActionResult GetPublicKey() {
@@ -8,7 +8,7 @@ namespace BoredCareers.Controllers.Payment {
public static string _EndpointSecret = ""; public static string _EndpointSecret = "";
public static string _PublicKey = ""; public static string _PublicKey = "";
public Task<(bool, string)> TryGetCheckoutToken(string OrderNumber, int userID, Cart[] cart); public Task<(bool, string)> TryGetCheckoutToken(string OrderNumber, int userID);
public Task ValidatePurchase(string WebHookData, string Headers); public Task ValidatePurchase(string WebHookData, string Headers);
} }
@@ -1,6 +1,5 @@
using BoredCareers.Controllers.Payment; using BoredCareers.Controllers.Payment;
using BoredCareers.Services.DatabaseService; using BoredCareers.Services.DatabaseService;
using BoredCareers.Entities;
namespace BoredCareers.Controllers { namespace BoredCareers.Controllers {
@@ -12,7 +11,7 @@ namespace BoredCareers.Controllers {
_databaseService = databaseService; _databaseService = databaseService;
} }
public async Task<(bool, string)> TryGetCheckoutToken(string OrderNumber, int userID, Cart[] cart) { public async Task<(bool, string)> TryGetCheckoutToken(string OrderNumber, int userID) {
try { try {
// build Recipt and calculate Tax // build Recipt and calculate Tax
var options = new Stripe.Tax.CalculationCreateOptions { var options = new Stripe.Tax.CalculationCreateOptions {
@@ -1,6 +1,5 @@
using BoredCareers.Entities; using BoredCareers.Entities;
using MySql.Data.MySqlClient; using MySql.Data.MySqlClient;
using Stripe.Terminal;
using System.Data; using System.Data;
using System.Data.Common; using System.Data.Common;