mirror of
https://github.com/bitwarden/server.git
synced 2025-04-20 12:38:15 -05:00
catch sql FK violations on webhook tx creation
This commit is contained in:
parent
22c049c9c5
commit
1dc22f61d1
@ -4,6 +4,7 @@ using Bit.Core.Repositories;
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using System.Data.SqlClient;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -63,6 +64,8 @@ namespace Bit.Billing.Controllers
|
|||||||
{
|
{
|
||||||
var ids = sale.GetIdsFromCustom();
|
var ids = sale.GetIdsFromCustom();
|
||||||
if(ids.Item1.HasValue || ids.Item2.HasValue)
|
if(ids.Item1.HasValue || ids.Item2.HasValue)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
await _transactionRepository.CreateAsync(new Core.Models.Table.Transaction
|
await _transactionRepository.CreateAsync(new Core.Models.Table.Transaction
|
||||||
{
|
{
|
||||||
@ -77,6 +80,9 @@ namespace Bit.Billing.Controllers
|
|||||||
Details = sale.Id
|
Details = sale.Id
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// Catch foreign key violations because user/org could have been deleted.
|
||||||
|
catch(SqlException e) when(e.Number == 547) { }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(body.Contains("\"PAYMENT.SALE.REFUNDED\""))
|
else if(body.Contains("\"PAYMENT.SALE.REFUNDED\""))
|
||||||
|
@ -9,6 +9,7 @@ using Microsoft.Extensions.Options;
|
|||||||
using Stripe;
|
using Stripe;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Data.SqlClient;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -227,8 +228,13 @@ namespace Bit.Billing.Controllers
|
|||||||
return new OkResult();
|
return new OkResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
await _transactionRepository.CreateAsync(tx);
|
await _transactionRepository.CreateAsync(tx);
|
||||||
}
|
}
|
||||||
|
// Catch foreign key violations because user/org could have been deleted.
|
||||||
|
catch(SqlException e) when(e.Number == 547) { }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(parsedEvent.Type.Equals("charge.refunded"))
|
else if(parsedEvent.Type.Equals("charge.refunded"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user