1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-22 12:15:36 +01:00

Stripe not crediting customer balance after void

This commit is contained in:
Chad Scharf 2020-05-18 12:38:00 -04:00
parent d22992451c
commit d49cc18a41

View File

@ -956,7 +956,25 @@ namespace Bit.Core.Services
return paymentIntentClientSecret;
}
await invoiceService.VoidInvoiceAsync(invoice.Id, new InvoiceVoidOptions());
invoice = await invoiceService.VoidInvoiceAsync(invoice.Id, new InvoiceVoidOptions());
// HACK: Workaround for customer balance credit
if (invoice.StartingBalance < 0)
{
// Customer had a balance applied to this invoice. Since we can't fully trust Stripe to
// credit it back to the customer (even though their docs claim they will), we need to
// check that balance against the current customer balance and determine if it needs to be re-applied
customer = await customerService.GetAsync(subscriber.GatewayCustomerId, customerOptions);
// Assumption: Customer balance should now be $0, otherwise payment would not have failed.
if (customer.Balance == 0)
{
await customerService.UpdateAsync(customer.Id, new CustomerUpdateOptions
{
Balance = invoice.StartingBalance
});
}
}
}
if (e is StripeException strEx &&