mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 06:24:24 +01:00
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using BTCPayServer.Abstractions.Extensions;
|
using BTCPayServer.Abstractions.Extensions;
|
||||||
@@ -14,6 +15,7 @@ using BTCPayServer.Services.Rates;
|
|||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using NBitcoin;
|
||||||
|
|
||||||
namespace BTCPayServer.Controllers
|
namespace BTCPayServer.Controllers
|
||||||
{
|
{
|
||||||
@@ -90,8 +92,7 @@ namespace BTCPayServer.Controllers
|
|||||||
return View(nameof(ViewPullPayment), vm);
|
return View(nameof(ViewPullPayment), vm);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Route("pull-payments/{pullPaymentId}/claim")]
|
[HttpPost("pull-payments/{pullPaymentId}/claim")]
|
||||||
[HttpPost]
|
|
||||||
public async Task<IActionResult> ClaimPullPayment(string pullPaymentId, ViewPullPaymentModel vm)
|
public async Task<IActionResult> ClaimPullPayment(string pullPaymentId, ViewPullPaymentModel vm)
|
||||||
{
|
{
|
||||||
using var ctx = _dbContextFactory.CreateContext();
|
using var ctx = _dbContextFactory.CreateContext();
|
||||||
@@ -122,10 +123,16 @@ namespace BTCPayServer.Controllers
|
|||||||
{
|
{
|
||||||
ModelState.AddModelError(nameof(vm.ClaimedAmount), "Amount is required");
|
ModelState.AddModelError(nameof(vm.ClaimedAmount), "Amount is required");
|
||||||
}
|
}
|
||||||
else if (vm.ClaimedAmount != 0 && destination.destination.Amount != null && vm.ClaimedAmount != destination.destination.Amount)
|
else
|
||||||
{
|
{
|
||||||
ModelState.AddModelError(nameof(vm.ClaimedAmount),
|
var amount = ppBlob.Currency == "SATS" ? new Money(vm.ClaimedAmount, MoneyUnit.Satoshi).ToUnit(MoneyUnit.BTC) : vm.ClaimedAmount;
|
||||||
$"Amount is implied in destination ({destination.destination.Amount}) that does not match the payout amount provided {vm.ClaimedAmount})");
|
if (destination.destination.Amount != null && amount != destination.destination.Amount)
|
||||||
|
{
|
||||||
|
var implied = _currencyNameTable.DisplayFormatCurrency(destination.destination.Amount.Value, paymentMethodId.CryptoCode);
|
||||||
|
var provided = _currencyNameTable.DisplayFormatCurrency(vm.ClaimedAmount, ppBlob.Currency);
|
||||||
|
ModelState.AddModelError(nameof(vm.ClaimedAmount),
|
||||||
|
$"Amount implied in destination ({implied}) does not match the payout amount provided ({provided}).");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
using NBitcoin;
|
|
||||||
|
|
||||||
namespace BTCPayServer.Data
|
namespace BTCPayServer.Data
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user