mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 14:04:26 +01:00
Remove types from BTCPayServer.Client
This commit is contained in:
@@ -1,9 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace BTCPayServer.Client.Models
|
|
||||||
{
|
|
||||||
public class FakePaymentRequest
|
|
||||||
{
|
|
||||||
public Decimal Amount { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -43,6 +43,10 @@ namespace BTCPayServer.Controllers
|
|||||||
{
|
{
|
||||||
public partial class InvoiceController
|
public partial class InvoiceController
|
||||||
{
|
{
|
||||||
|
public class FakePaymentRequest
|
||||||
|
{
|
||||||
|
public Decimal Amount { get; set; }
|
||||||
|
}
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("i/{invoiceId}/test-payment")]
|
[Route("i/{invoiceId}/test-payment")]
|
||||||
[CheatModeRoute]
|
[CheatModeRoute]
|
||||||
@@ -62,33 +66,30 @@ namespace BTCPayServer.Controllers
|
|||||||
|
|
||||||
var bitcoinAddressObj = BitcoinAddress.Create(bitcoinAddressString, network.NBitcoinNetwork);
|
var bitcoinAddressObj = BitcoinAddress.Create(bitcoinAddressString, network.NBitcoinNetwork);
|
||||||
var BtcAmount = request.Amount;
|
var BtcAmount = request.Amount;
|
||||||
|
|
||||||
var FakePaymentResponse = new FakePaymentResponse();
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var paymentMethod = invoice.GetPaymentMethod(paymentMethodId);
|
var paymentMethod = invoice.GetPaymentMethod(paymentMethodId);
|
||||||
var rate = paymentMethod.Rate;
|
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.
|
// 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;
|
var totalDue = invoice.Price;
|
||||||
|
return Ok(new
|
||||||
FakePaymentResponse.AmountRemaining = (totalDue - (BtcAmount * rate)) / rate;
|
{
|
||||||
FakePaymentResponse.SuccessMessage = "Created transaction " + FakePaymentResponse.Txid;
|
Txid = txid,
|
||||||
|
AmountRemaining = (totalDue - (BtcAmount * rate)) / rate,
|
||||||
|
SuccessMessage = "Created transaction " + txid
|
||||||
|
});
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
FakePaymentResponse.ErrorMessage = e.Message;
|
return BadRequest(new
|
||||||
FakePaymentResponse.AmountRemaining = invoice.Price;
|
{
|
||||||
|
ErrorMessage = e.Message,
|
||||||
|
AmountRemaining = invoice.Price
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FakePaymentResponse.Txid != null)
|
|
||||||
{
|
|
||||||
return Ok(FakePaymentResponse);
|
|
||||||
}
|
|
||||||
return BadRequest(FakePaymentResponse);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
|
|||||||
Reference in New Issue
Block a user