1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-05 21:18:13 -05:00

[PM-5872] Credit load intermittently fails (#5424)

This commit is contained in:
Jonas Hendrickx 2025-03-05 16:22:16 +01:00 committed by GitHub
parent 267f306c85
commit 10756ca35e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 5 deletions

View File

@ -0,0 +1,7 @@
namespace Bit.Billing.Constants;
public static class BitPayInvoiceStatus
{
public const string Confirmed = "confirmed";
public const string Complete = "complete";
}

View File

@ -0,0 +1,6 @@
namespace Bit.Billing.Constants;
public static class BitPayNotificationCode
{
public const string InvoiceConfirmed = "invoice_confirmed";
}

View File

@ -1,4 +1,5 @@
using System.Globalization; using System.Globalization;
using Bit.Billing.Constants;
using Bit.Billing.Models; using Bit.Billing.Models;
using Bit.Core.AdminConsole.Repositories; using Bit.Core.AdminConsole.Repositories;
using Bit.Core.Billing.Services; using Bit.Core.Billing.Services;
@ -65,7 +66,7 @@ public class BitPayController : Controller
return new BadRequestResult(); return new BadRequestResult();
} }
if (model.Event.Name != "invoice_confirmed") if (model.Event.Name != BitPayNotificationCode.InvoiceConfirmed)
{ {
// Only processing confirmed invoice events for now. // Only processing confirmed invoice events for now.
return new OkResult(); return new OkResult();
@ -75,20 +76,20 @@ public class BitPayController : Controller
if (invoice == null) if (invoice == null)
{ {
// Request forged...? // Request forged...?
_logger.LogWarning("Invoice not found. #" + model.Data.Id); _logger.LogWarning("Invoice not found. #{InvoiceId}", model.Data.Id);
return new BadRequestResult(); return new BadRequestResult();
} }
if (invoice.Status != "confirmed" && invoice.Status != "completed") if (invoice.Status != BitPayInvoiceStatus.Confirmed && invoice.Status != BitPayInvoiceStatus.Complete)
{ {
_logger.LogWarning("Invoice status of '" + invoice.Status + "' is not acceptable. #" + invoice.Id); _logger.LogWarning("Invoice status of '{InvoiceStatus}' is not acceptable. #{InvoiceId}", invoice.Status, invoice.Id);
return new BadRequestResult(); return new BadRequestResult();
} }
if (invoice.Currency != "USD") if (invoice.Currency != "USD")
{ {
// Only process USD payments // Only process USD payments
_logger.LogWarning("Non USD payment received. #" + invoice.Id); _logger.LogWarning("Non USD payment received. #{InvoiceId}", invoice.Id);
return new OkResult(); return new OkResult();
} }