From 0033aab03e6943ad1edb1131e3a43f90eb30e81e Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Mon, 11 Oct 2021 18:01:32 +0900 Subject: [PATCH] Remove types from BTCPayServer.Client --- .../Models/FakePaymentRequest.cs | 9 ------ .../Models/FakePaymentResponse.cs | 12 ------- .../Controllers/InvoiceController.Testing.cs | 31 ++++++++++--------- 3 files changed, 16 insertions(+), 36 deletions(-) delete mode 100644 BTCPayServer.Client/Models/FakePaymentRequest.cs delete mode 100644 BTCPayServer.Client/Models/FakePaymentResponse.cs diff --git a/BTCPayServer.Client/Models/FakePaymentRequest.cs b/BTCPayServer.Client/Models/FakePaymentRequest.cs deleted file mode 100644 index bc15033c1..000000000 --- a/BTCPayServer.Client/Models/FakePaymentRequest.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; - -namespace BTCPayServer.Client.Models -{ - public class FakePaymentRequest - { - public Decimal Amount { get; set; } - } -} diff --git a/BTCPayServer.Client/Models/FakePaymentResponse.cs b/BTCPayServer.Client/Models/FakePaymentResponse.cs deleted file mode 100644 index 55c20b10d..000000000 --- a/BTCPayServer.Client/Models/FakePaymentResponse.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; - -namespace BTCPayServer.Client.Models -{ - public class FakePaymentResponse - { - public Decimal AmountRemaining { get; set; } - public String Txid { get; set; } - public String SuccessMessage { get; set; } - public String ErrorMessage { get; set; } - } -} diff --git a/BTCPayServer/Controllers/InvoiceController.Testing.cs b/BTCPayServer/Controllers/InvoiceController.Testing.cs index 86f51d463..097e2bf24 100644 --- a/BTCPayServer/Controllers/InvoiceController.Testing.cs +++ b/BTCPayServer/Controllers/InvoiceController.Testing.cs @@ -43,6 +43,10 @@ namespace BTCPayServer.Controllers { public partial class InvoiceController { + public class FakePaymentRequest + { + public Decimal Amount { get; set; } + } [HttpPost] [Route("i/{invoiceId}/test-payment")] [CheatModeRoute] @@ -62,33 +66,30 @@ namespace BTCPayServer.Controllers var bitcoinAddressObj = BitcoinAddress.Create(bitcoinAddressString, network.NBitcoinNetwork); var BtcAmount = request.Amount; - - var FakePaymentResponse = new FakePaymentResponse(); - try { var paymentMethod = invoice.GetPaymentMethod(paymentMethodId); var rate = paymentMethod.Rate; - FakePaymentResponse.Txid = cheater.CashCow.SendToAddress(bitcoinAddressObj, new Money(BtcAmount, MoneyUnit.BTC)).ToString(); + var txid = cheater.CashCow.SendToAddress(bitcoinAddressObj, new Money(BtcAmount, MoneyUnit.BTC)).ToString(); // TODO The value of totalDue is wrong. How can we get the real total due? invoice.Price is only correct if this is the 2nd payment, not for a 3rd or 4th payment. var totalDue = invoice.Price; - - FakePaymentResponse.AmountRemaining = (totalDue - (BtcAmount * rate)) / rate; - FakePaymentResponse.SuccessMessage = "Created transaction " + FakePaymentResponse.Txid; + return Ok(new + { + Txid = txid, + AmountRemaining = (totalDue - (BtcAmount * rate)) / rate, + SuccessMessage = "Created transaction " + txid + }); } catch (Exception e) { - FakePaymentResponse.ErrorMessage = e.Message; - FakePaymentResponse.AmountRemaining = invoice.Price; + return BadRequest(new + { + ErrorMessage = e.Message, + AmountRemaining = invoice.Price + }); } - - if (FakePaymentResponse.Txid != null) - { - return Ok(FakePaymentResponse); - } - return BadRequest(FakePaymentResponse); } [HttpPost]