fix: log com delay temporario para logar pagamento
All checks were successful
BCards Deployment Pipeline / Run Tests (push) Successful in 2s
BCards Deployment Pipeline / PR Validation (push) Has been skipped
BCards Deployment Pipeline / Build and Push Image (push) Successful in 15m41s
BCards Deployment Pipeline / Deploy to Production (ARM - OCI) (push) Successful in 1m14s
BCards Deployment Pipeline / Deploy to Staging (x86 - Local) (push) Has been skipped
BCards Deployment Pipeline / Cleanup Old Resources (push) Has been skipped
BCards Deployment Pipeline / Deployment Summary (push) Successful in 0s
All checks were successful
BCards Deployment Pipeline / Run Tests (push) Successful in 2s
BCards Deployment Pipeline / PR Validation (push) Has been skipped
BCards Deployment Pipeline / Build and Push Image (push) Successful in 15m41s
BCards Deployment Pipeline / Deploy to Production (ARM - OCI) (push) Successful in 1m14s
BCards Deployment Pipeline / Deploy to Staging (x86 - Local) (push) Has been skipped
BCards Deployment Pipeline / Cleanup Old Resources (push) Has been skipped
BCards Deployment Pipeline / Deployment Summary (push) Successful in 0s
This commit is contained in:
parent
406c298afb
commit
6042eb59e6
@ -18,6 +18,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Pipeline", "Pipeline", "{3F
|
||||
.gitea\workflows\deploy-bcards.yml = .gitea\workflows\deploy-bcards.yml
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8EC462FD-D22E-90A8-E5CE-7E832BA40C5D}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
Conexoes.txt = Conexoes.txt
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
||||
4
Conexoes.txt
Normal file
4
Conexoes.txt
Normal file
@ -0,0 +1,4 @@
|
||||
bcards
|
||||
ssh ubuntu@141.148.162.114
|
||||
convert-it
|
||||
ssh ubuntu@129.146.116.218
|
||||
@ -50,6 +50,7 @@ public class StripeWebhookController : ControllerBase
|
||||
return BadRequest("Missing Stripe signature");
|
||||
}
|
||||
|
||||
_logger.LogInformation($"Contruir evento Stripe: {json}");
|
||||
var stripeEvent = EventUtility.ConstructEvent(
|
||||
json,
|
||||
stripeSignature,
|
||||
@ -82,21 +83,26 @@ public class StripeWebhookController : ControllerBase
|
||||
break;
|
||||
}
|
||||
|
||||
await Task.Delay(2000); // 2 segundos
|
||||
return Ok();
|
||||
}
|
||||
catch (StripeException ex)
|
||||
{
|
||||
await Task.Delay(2000); // 2 segundos
|
||||
_logger.LogError(ex, "Stripe webhook error");
|
||||
return BadRequest($"Stripe error: {ex.Message}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await Task.Delay(2000); // 2 segundos
|
||||
_logger.LogError(ex, "Webhook processing error");
|
||||
return StatusCode(500, "Internal server error");
|
||||
}
|
||||
}
|
||||
|
||||
private async Task HandlePaymentSucceeded(Event stripeEvent)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (stripeEvent.Data.Object is Invoice invoice)
|
||||
{
|
||||
@ -122,9 +128,21 @@ public class StripeWebhookController : ControllerBase
|
||||
_logger.LogInformation($"Reactivated {userPages.Count} pages for user {subscription.UserId}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogWarning($"Unexpected event type on HandlePaymentSucceeded: {stripeEvent.Type}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error handling payment succeeded event");
|
||||
throw new Exception("Error handling payment succeeded event", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task HandlePaymentFailed(Event stripeEvent)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (stripeEvent.Data.Object is Invoice invoice)
|
||||
{
|
||||
@ -150,9 +168,21 @@ public class StripeWebhookController : ControllerBase
|
||||
_logger.LogInformation($"Set {userPages.Count} pages to pending payment for user {subscription.UserId}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogWarning($"Unexpected event type on HandlePaymentFailed: {stripeEvent.Type}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error handling payment failed event");
|
||||
throw new Exception("Error handling payment failed event", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task HandleSubscriptionDeleted(Event stripeEvent)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (stripeEvent.Data.Object is Subscription stripeSubscription)
|
||||
{
|
||||
@ -177,9 +207,21 @@ public class StripeWebhookController : ControllerBase
|
||||
_logger.LogInformation($"Deactivated {userPages.Count} pages for cancelled subscription {subscription.UserId}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogWarning($"Unexpected event type on HandlePaymentFailed: {stripeEvent.Type}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error handling subscription deleted failed event");
|
||||
throw new Exception("Error handling subscription deleted failed event", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task HandleSubscriptionUpdated(Event stripeEvent)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (stripeEvent.Data.Object is Subscription stripeSubscription)
|
||||
{
|
||||
@ -209,6 +251,16 @@ public class StripeWebhookController : ControllerBase
|
||||
_logger.LogInformation($"Updated subscription for user {subscription.UserId}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogWarning($"Unexpected event type on HandlePaymentFailed: {stripeEvent.Type}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error handling subscription updated failed event");
|
||||
throw new Exception("Error handling subscription updated failed event", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private string MapPriceIdToPlanType(string priceId)
|
||||
|
||||
@ -45,7 +45,6 @@ if (isDevelopment)
|
||||
.WriteTo.Async(a => a.Console(
|
||||
outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] [{Hostname}] {Message:lj} {Properties:j}{NewLine}{Exception}"));
|
||||
|
||||
// Also send to Seq if configured (for local development with Seq)
|
||||
var seqUrl = builder.Configuration["Serilog:SeqUrl"];
|
||||
if (!string.IsNullOrEmpty(seqUrl))
|
||||
{
|
||||
@ -64,7 +63,6 @@ else
|
||||
restrictedToMinimumLevel: LogEventLevel.Error,
|
||||
outputTemplate: "[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level:u3}] [{Hostname}] {Message:lj}{NewLine}{Exception}"));
|
||||
|
||||
// Production: Send detailed logs to Seq
|
||||
var seqUrl = builder.Configuration["Serilog:SeqUrl"];
|
||||
if (!string.IsNullOrEmpty(seqUrl))
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user