#27 added more info to transaction + callback from stripe

This commit is contained in:
Dominic Villemure
2024-05-09 18:00:42 -04:00
parent 5980eb7f0f
commit 4f97f8ad25
13 changed files with 770 additions and 22 deletions

View File

@@ -1,13 +1,20 @@
using Stripe;
using Stripe.Checkout;
using Hutopy.Application.Common.Interfaces;
using Microsoft.AspNetCore.Http;
using Hutopy.Application.Common.Models;
using Hutopy.Application.Stripe.Commands;
namespace Hutopy.Infrastructure.Stripe;
public class StripeService : IStripeService
{
public StripeService()
const string EndpointSecret = "";
private readonly IHttpContextAccessor _httpContextAccessor;
public StripeService(IHttpContextAccessor httpContextAccessor)
{
_httpContextAccessor = httpContextAccessor;
StripeConfiguration.ApiKey = "";
}
@@ -31,7 +38,7 @@ public class StripeService : IStripeService
],
Mode = "payment",
UiMode = "embedded",
ReturnUrl = "https://zealous-bay-08204590f.5.azurestaticapps.net/paymentcompleted",
ReturnUrl = "https://hutopy.ca/paymentcompleted",
};
var service = new SessionService();
@@ -39,4 +46,27 @@ public class StripeService : IStripeService
return session.ClientSecret;
}
public Result ValidateTransaction(ConfirmStripeTransactionCommand request)
{
try
{
if (request.Data.Object.Status is "succeeded")
{
return new Result(true, new List<string>());
}
return new Result(false, new List<string>());
}
catch (StripeException e)
{
Console.WriteLine("Error: {0}", e.Message);
return new Result(false, new List<string>{e.Message});
}
catch (Exception e)
{
return new Result(false, new List<string>{e.Message});
}
}
}