Remove enough from payment service to compile

This commit is contained in:
2025-07-15 21:09:20 -07:00
parent 9e13317ca3
commit d18dcbff5c
2 changed files with 0 additions and 82 deletions
@@ -8,7 +8,6 @@ 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);
public Task ValidatePurchase(string WebHookData, string Headers); public Task ValidatePurchase(string WebHookData, string Headers);
} }
@@ -11,72 +11,6 @@ namespace BoredCareers.Controllers {
_databaseService = databaseService; _databaseService = databaseService;
} }
public async Task<(bool, string)> TryGetCheckoutToken(string OrderNumber, int userID) {
try {
// build Recipt and calculate Tax
var options = new Stripe.Tax.CalculationCreateOptions {
Currency = "usd",
CustomerDetails = new Stripe.Tax.CalculationCustomerDetailsOptions {
AddressSource = "billing",
},
Expand = new List<string>() { "line_items" },
LineItems = new List<Stripe.Tax.CalculationLineItemOptions>()
};
List<int> prods = new List<int>();
// Add items to receipt
int subtotal = 0;
foreach (Cart items in cart) {
Product? product = await _databaseService.GetProduct(items.ProductID);
if (product != null) {
prods.Add(product.ID);
if (product != null) {
subtotal += product.Cost;
options.LineItems.Add(new Stripe.Tax.CalculationLineItemOptions {
Amount = product.Cost,
TaxCode = "txcd_10201000", // Tax code for downloadable digital games
Quantity = 1,
Reference = product.Name,
TaxBehavior = "exclusive"
});
}
}
}
var service = new Stripe.Tax.CalculationService();
Stripe.Tax.Calculation result = service.Create(options);
string csv = "";
foreach (int cur in prods) {
csv = csv + cur + ",";
}
// Crate Payment Intent
Stripe.PaymentIntentCreateOptions paymentIntent = new Stripe.PaymentIntentCreateOptions() {
Amount = result.AmountTotal,
Currency = "usd",
Metadata = new Dictionary<string, string> {
{ "ordernumber", OrderNumber },
{ "user", userID.ToString() },
{ "products", csv },
{ "subtotal", subtotal.ToString() },
{ "total", result.AmountTotal.ToString() }
},
StatementDescriptor = "Mistox.Net #" + OrderNumber
};
Stripe.PaymentIntentService intentService = new Stripe.PaymentIntentService();
Stripe.PaymentIntent x = await intentService.CreateAsync(paymentIntent);
return (true, x.ClientSecret);
} catch (Exception e) {
return (false, e.ToString());
}
}
public async Task ValidatePurchase(string WebHookData, string Headers) { public async Task ValidatePurchase(string WebHookData, string Headers) {
Stripe.Event e = Stripe.EventUtility.ConstructEvent( WebHookData, Headers, IPayment._EndpointSecret ); Stripe.Event e = Stripe.EventUtility.ConstructEvent( WebHookData, Headers, IPayment._EndpointSecret );
if (e.Type == "payment_intent.succeeded") { if (e.Type == "payment_intent.succeeded") {
@@ -113,22 +47,7 @@ namespace BoredCareers.Controllers {
} }
} }
// Clear the cart
await _databaseService.ClearCart(userID);
// Add data to misox receipt // Add data to misox receipt
for (int i = 0; i < productIDs.Count; i++) {
int product = productIDs[i];
await _databaseService.NewReceipt(new Receipt {
AccountID = userID,
ProductID = product,
ReceiptID = orderNumber,
Time = DateTime.Now,
TaxAmount = total - subtotal,
TotalCost = total,
LineItem = i
});
}
} else { } else {
Console.WriteLine("Unhandled event type: {0}", e.Type); Console.WriteLine("Unhandled event type: {0}", e.Type);
} }