1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-05 10:02:47 -05:00

added credit email notification

This commit is contained in:
Kyle Spearrin
2019-02-22 21:13:34 -05:00
parent 25c8d6d043
commit c5b2a929d2
8 changed files with 60 additions and 2 deletions

View File

@ -258,11 +258,13 @@ namespace Bit.Billing.Controllers
if(ipnTransaction.IsAccountCredit())
{
string billingEmail = null;
if(tx.OrganizationId.HasValue)
{
var org = await _organizationRepository.GetByIdAsync(tx.OrganizationId.Value);
if(org != null)
{
billingEmail = org.BillingEmailAddress();
if(await _paymentService.CreditAccountAsync(org, tx.Amount))
{
await _organizationRepository.ReplaceAsync(org);
@ -274,6 +276,7 @@ namespace Bit.Billing.Controllers
var user = await _userRepository.GetByIdAsync(tx.UserId.Value);
if(user != null)
{
billingEmail = user.BillingEmailAddress();
if(await _paymentService.CreditAccountAsync(user, tx.Amount))
{
await _userRepository.ReplaceAsync(user);
@ -281,7 +284,10 @@ namespace Bit.Billing.Controllers
}
}
// TODO: Send email about credit added?
if(!string.IsNullOrWhiteSpace(billingEmail))
{
await _mailService.SendAddedCreditAsync(billingEmail, tx.Amount);
}
}
}
// Catch foreign key violations because user/org could have been deleted.