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

check to make sure not already refunded

This commit is contained in:
Kyle Spearrin
2019-02-01 23:29:12 -05:00
parent 4ade9a229b
commit fb3cdba99e
2 changed files with 52 additions and 42 deletions

View File

@ -94,28 +94,32 @@ namespace Bit.Billing.Controllers
return new BadRequestResult();
}
saleTransaction.RefundedAmount = refund.TotalRefundedAmount.ValueAmount;
if(saleTransaction.RefundedAmount == saleTransaction.Amount)
if(!saleTransaction.Refunded.GetValueOrDefault() &&
saleTransaction.RefundedAmount.GetValueOrDefault() < refund.TotalRefundedAmount.ValueAmount)
{
saleTransaction.Refunded = true;
}
await _transactionRepository.ReplaceAsync(saleTransaction);
var ids = refund.GetIdsFromCustom();
if(ids.Item1.HasValue || ids.Item2.HasValue)
{
await _transactionRepository.CreateAsync(new Core.Models.Table.Transaction
saleTransaction.RefundedAmount = refund.TotalRefundedAmount.ValueAmount;
if(saleTransaction.RefundedAmount == saleTransaction.Amount)
{
Amount = refund.Amount.TotalAmount,
CreationDate = refund.CreateTime,
OrganizationId = ids.Item1,
UserId = ids.Item2,
Type = TransactionType.Refund,
Gateway = GatewayType.PayPal,
GatewayId = refund.Id,
PaymentMethodType = PaymentMethodType.PayPal,
Details = refund.Id
});
saleTransaction.Refunded = true;
}
await _transactionRepository.ReplaceAsync(saleTransaction);
var ids = refund.GetIdsFromCustom();
if(ids.Item1.HasValue || ids.Item2.HasValue)
{
await _transactionRepository.CreateAsync(new Core.Models.Table.Transaction
{
Amount = refund.Amount.TotalAmount,
CreationDate = refund.CreateTime,
OrganizationId = ids.Item1,
UserId = ids.Item2,
Type = TransactionType.Refund,
Gateway = GatewayType.PayPal,
GatewayId = refund.Id,
PaymentMethodType = PaymentMethodType.PayPal,
Details = refund.Id
});
}
}
}
}