mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-19 09:54:30 +01:00
Auto approve refunds (#3682)
This commit is contained in:
parent
86e53552c0
commit
382fe5cd47
@ -224,7 +224,7 @@ namespace BTCPayServer.Controllers
|
||||
[Authorize(Policy = Policies.CanModifyStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Cookie)]
|
||||
public async Task<IActionResult> Refund(string invoiceId, RefundModel model, CancellationToken cancellationToken)
|
||||
{
|
||||
using var ctx = _dbContextFactory.CreateContext();
|
||||
await using var ctx = _dbContextFactory.CreateContext();
|
||||
|
||||
var invoice = GetCurrentInvoice();
|
||||
if (invoice == null)
|
||||
@ -288,21 +288,25 @@ namespace BTCPayServer.Controllers
|
||||
Name = $"Refund {invoice.Id}",
|
||||
PaymentMethodIds = new[] { paymentMethodId },
|
||||
StoreId = invoice.StoreId,
|
||||
BOLT11Expiration = store.GetStoreBlob().RefundBOLT11Expiration
|
||||
BOLT11Expiration = store.GetStoreBlob().RefundBOLT11Expiration,
|
||||
//AutoApproveClaims = true
|
||||
};
|
||||
switch (model.SelectedRefundOption)
|
||||
{
|
||||
case "RateThen":
|
||||
createPullPayment.Currency = paymentMethodId.CryptoCode;
|
||||
createPullPayment.Amount = model.CryptoAmountThen;
|
||||
createPullPayment.AutoApproveClaims = true;
|
||||
break;
|
||||
case "CurrentRate":
|
||||
createPullPayment.Currency = paymentMethodId.CryptoCode;
|
||||
createPullPayment.Amount = model.CryptoAmountNow;
|
||||
createPullPayment.AutoApproveClaims = true;
|
||||
break;
|
||||
case "Fiat":
|
||||
createPullPayment.Currency = invoice.Currency;
|
||||
createPullPayment.Amount = model.FiatAmount;
|
||||
createPullPayment.AutoApproveClaims = false;
|
||||
break;
|
||||
case "Custom":
|
||||
model.Title = "How much to refund?";
|
||||
@ -348,10 +352,11 @@ namespace BTCPayServer.Controllers
|
||||
createPullPayment = new CreatePullPayment
|
||||
{
|
||||
Name = $"Refund {invoice.Id}",
|
||||
PaymentMethodIds = new[] { paymentMethodId },
|
||||
PaymentMethodIds = new[] {paymentMethodId},
|
||||
StoreId = invoice.StoreId,
|
||||
Currency = model.CustomCurrency,
|
||||
Amount = model.CustomAmount
|
||||
Amount = model.CustomAmount,
|
||||
AutoApproveClaims = paymentMethodId.CryptoCode == model.CustomCurrency
|
||||
};
|
||||
break;
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user