diff --git a/src/Server/Controllers/PaymentMethods/IPayment.cs b/src/Server/Controllers/PaymentMethods/IPayment.cs index 5be09a3..73196d3 100644 --- a/src/Server/Controllers/PaymentMethods/IPayment.cs +++ b/src/Server/Controllers/PaymentMethods/IPayment.cs @@ -8,7 +8,6 @@ namespace BoredCareers.Controllers.Payment { public static string _EndpointSecret = ""; public static string _PublicKey = ""; - public Task<(bool, string)> TryGetCheckoutToken(string OrderNumber, int userID); public Task ValidatePurchase(string WebHookData, string Headers); } diff --git a/src/Server/Controllers/PaymentMethods/StripeIntents.cs b/src/Server/Controllers/PaymentMethods/StripeIntents.cs index f6110da..fca5a5e 100644 --- a/src/Server/Controllers/PaymentMethods/StripeIntents.cs +++ b/src/Server/Controllers/PaymentMethods/StripeIntents.cs @@ -11,72 +11,6 @@ namespace BoredCareers.Controllers { _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() { "line_items" }, - LineItems = new List() - }; - - List prods = new List(); - - // 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 { - { "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) { Stripe.Event e = Stripe.EventUtility.ConstructEvent( WebHookData, Headers, IPayment._EndpointSecret ); 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 - 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 { Console.WriteLine("Unhandled event type: {0}", e.Type); }