Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
jonashendrickx committed Oct 11, 2024
1 parent ae82074 commit 58cf8b1
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions src/Api/Billing/Controllers/StripeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,23 @@ public async Task<IResult> CalculateAsync([FromBody] CalculateTaxRequestModel re
},
}
};
var taxCalculation = await stripeAdapter.CalculateTaxAsync(options);
var response = new CalculateTaxResponseModel
try
{
SalesTaxRate = taxCalculation.TaxBreakdown.Any()
? decimal.Parse(taxCalculation.TaxBreakdown.Single().TaxRateDetails.PercentageDecimal) / 100
: 0,
SalesTaxAmount = Convert.ToDecimal(taxCalculation.TaxAmountExclusive) / 100,
TaxableAmount = Convert.ToDecimal(requestBody.Amount),
TotalAmount = Convert.ToDecimal(taxCalculation.AmountTotal) / 100,
};
return TypedResults.Ok(response);
var taxCalculation = await stripeAdapter.CalculateTaxAsync(options);
var response = new CalculateTaxResponseModel
{
SalesTaxRate = taxCalculation.TaxBreakdown.Any()
? decimal.Parse(taxCalculation.TaxBreakdown.Single().TaxRateDetails.PercentageDecimal) / 100
: 0,
SalesTaxAmount = Convert.ToDecimal(taxCalculation.TaxAmountExclusive) / 100,
TaxableAmount = Convert.ToDecimal(requestBody.Amount),
TotalAmount = Convert.ToDecimal(taxCalculation.AmountTotal) / 100,
};
return TypedResults.Ok(response);
}
catch (StripeException e)
{
return TypedResults.BadRequest(e.Message);
}
}
}

0 comments on commit 58cf8b1

Please sign in to comment.