Fixed payment namespacing
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using MistoxWebsite.Shared;
|
||||
using MistoxWebsite.Server.Entities;
|
||||
|
||||
namespace MistoxWebsite.Server.Controllers.Payment {
|
||||
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using MistoxWebsite.Server.Controllers.Payment;
|
||||
using MistoxWebsite.Server.Services.DatabaseService;
|
||||
using MistoxWebsite.Shared;
|
||||
using Stripe;
|
||||
using Stripe.Tax;
|
||||
using MistoxWebsite.Server.Entities;
|
||||
|
||||
namespace MistoxWebsite.Server.Controllers {
|
||||
|
||||
@@ -17,16 +12,16 @@ namespace MistoxWebsite.Server.Controllers {
|
||||
_databaseService = databaseService;
|
||||
}
|
||||
|
||||
public async Task<(bool, string)> Purchase(string OrderNumber, Shared.Account user, List<Cart> cart) {
|
||||
public async Task<(bool, string)> Purchase(string OrderNumber, Account user, List<Cart> cart) {
|
||||
try {
|
||||
// build Recipt and calculate Tax
|
||||
var options = new CalculationCreateOptions {
|
||||
var options = new Stripe.Tax.CalculationCreateOptions {
|
||||
Currency = "usd",
|
||||
CustomerDetails = new CalculationCustomerDetailsOptions {
|
||||
CustomerDetails = new Stripe.Tax.CalculationCustomerDetailsOptions {
|
||||
AddressSource = "billing",
|
||||
},
|
||||
Expand = new List<string>() { "line_items" },
|
||||
LineItems = new List<CalculationLineItemOptions>()
|
||||
LineItems = new List<Stripe.Tax.CalculationLineItemOptions>()
|
||||
};
|
||||
|
||||
List<int> prods = new List<int>();
|
||||
@@ -34,12 +29,12 @@ namespace MistoxWebsite.Server.Controllers {
|
||||
// Add items to receipt
|
||||
int subtotal = 0;
|
||||
foreach (Cart items in cart) {
|
||||
Shared.Product? product = await _databaseService.GetProduct(items.ProductID);
|
||||
Product? product = await _databaseService.GetProduct(items.ProductID);
|
||||
if (product != null) {
|
||||
prods.Add(product.ID);
|
||||
if (product != null) {
|
||||
subtotal += product.Cost;
|
||||
options.LineItems.Add(new CalculationLineItemOptions {
|
||||
options.LineItems.Add(new Stripe.Tax.CalculationLineItemOptions {
|
||||
Amount = product.Cost,
|
||||
TaxCode = "txcd_10201000", // Tax code for downloadable digital games
|
||||
Quantity = 1,
|
||||
@@ -51,8 +46,8 @@ namespace MistoxWebsite.Server.Controllers {
|
||||
|
||||
}
|
||||
|
||||
var service = new CalculationService();
|
||||
Calculation result = service.Create(options);
|
||||
var service = new Stripe.Tax.CalculationService();
|
||||
Stripe.Tax.Calculation result = service.Create(options);
|
||||
|
||||
string csv = "";
|
||||
foreach (int cur in prods) {
|
||||
@@ -60,7 +55,7 @@ namespace MistoxWebsite.Server.Controllers {
|
||||
}
|
||||
|
||||
// Crate Payment Intent
|
||||
PaymentIntentCreateOptions paymentIntent = new PaymentIntentCreateOptions() {
|
||||
Stripe.PaymentIntentCreateOptions paymentIntent = new Stripe.PaymentIntentCreateOptions() {
|
||||
Amount = result.AmountTotal,
|
||||
Currency = "usd",
|
||||
Metadata = new Dictionary<string, string> {
|
||||
@@ -73,8 +68,8 @@ namespace MistoxWebsite.Server.Controllers {
|
||||
StatementDescriptor = "Mistox.Net #" + OrderNumber
|
||||
};
|
||||
|
||||
PaymentIntentService intentService = new PaymentIntentService();
|
||||
PaymentIntent x = await intentService.CreateAsync(paymentIntent);
|
||||
Stripe.PaymentIntentService intentService = new Stripe.PaymentIntentService();
|
||||
Stripe.PaymentIntent x = await intentService.CreateAsync(paymentIntent);
|
||||
|
||||
return (true, x.ClientSecret);
|
||||
} catch(Exception e) {
|
||||
|
||||
Reference in New Issue
Block a user