From 377e6ff697a0dbc17fe365798fc387095c41e679 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 17 Jun 2019 08:15:56 -0400 Subject: [PATCH] handle invoice already paid error --- src/Billing/Controllers/StripeController.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Billing/Controllers/StripeController.cs b/src/Billing/Controllers/StripeController.cs index bc9470d1c5..b7012f8e7d 100644 --- a/src/Billing/Controllers/StripeController.cs +++ b/src/Billing/Controllers/StripeController.cs @@ -471,9 +471,9 @@ namespace Bit.Billing.Controllers return false; } + var invoiceService = new InvoiceService(); try { - var invoiceService = new InvoiceService(); await invoiceService.UpdateAsync(invoice.Id, new InvoiceUpdateOptions { Metadata = new Dictionary @@ -488,7 +488,17 @@ namespace Bit.Billing.Controllers catch(Exception e) { await _btGateway.Transaction.RefundAsync(transactionResult.Target.Id); - throw e; + if(e.Message.Contains("Invoice is already paid")) + { + await invoiceService.UpdateAsync(invoice.Id, new InvoiceUpdateOptions + { + Metadata = invoice.Metadata + }); + } + else + { + throw e; + } } return true;