mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2026-02-19 05:04:28 +01:00
Greenfield: Create Pull Request payoutMethods is now optional (#6396)
This commit is contained in:
@@ -131,26 +131,20 @@ namespace BTCPayServer.Controllers.Greenfield
|
||||
{
|
||||
ModelState.AddModelError(nameof(request.BOLT11Expiration), $"The BOLT11 expiration should be positive");
|
||||
}
|
||||
PayoutMethodId?[]? payoutMethods = null;
|
||||
if (request.PayoutMethods is { } payoutMethodsStr)
|
||||
|
||||
var supported = _payoutHandlers.GetSupportedPayoutMethods(HttpContext.GetStoreData());
|
||||
request.PayoutMethods ??= supported.Select(s => s.ToString()).ToArray();
|
||||
for (int i = 0; i < request.PayoutMethods.Length; i++)
|
||||
{
|
||||
payoutMethods = payoutMethodsStr.Select(s =>
|
||||
var pmi = request.PayoutMethods[i] is string pm ? PayoutMethodId.TryParse(pm) : null;
|
||||
if (pmi is null || !supported.Contains(pmi))
|
||||
{
|
||||
PayoutMethodId.TryParse(s, out var pmi);
|
||||
return pmi;
|
||||
}).ToArray();
|
||||
var supported = _payoutHandlers.GetSupportedPayoutMethods(HttpContext.GetStoreData());
|
||||
for (int i = 0; i < payoutMethods.Length; i++)
|
||||
{
|
||||
if (!supported.Contains(payoutMethods[i]))
|
||||
{
|
||||
request.AddModelError(paymentRequest => paymentRequest.PayoutMethods[i], "Invalid or unsupported payment method", this);
|
||||
}
|
||||
request.AddModelError(paymentRequest => paymentRequest.PayoutMethods[i], "Invalid or unsupported payment method", this);
|
||||
}
|
||||
}
|
||||
else
|
||||
if (request.PayoutMethods.Length is 0)
|
||||
{
|
||||
ModelState.AddModelError(nameof(request.PayoutMethods), "This field is required");
|
||||
ModelState.AddModelError(nameof(request.PayoutMethods), "At least one payout method is required");
|
||||
}
|
||||
if (!ModelState.IsValid)
|
||||
return this.CreateValidationError(ModelState);
|
||||
|
||||
@@ -112,6 +112,8 @@ namespace BTCPayServer.HostedServices
|
||||
}
|
||||
public Task<string> CreatePullPayment(string storeId, CreatePullPaymentRequest request)
|
||||
{
|
||||
if (request.PayoutMethods.Length == 0)
|
||||
throw new InvalidOperationException("request.PayoutMethods should have at least one payout method");
|
||||
return CreatePullPayment(new CreatePullPayment()
|
||||
{
|
||||
StartsAt = request.StartsAt,
|
||||
|
||||
@@ -225,11 +225,12 @@
|
||||
},
|
||||
"payoutMethods": {
|
||||
"type": "array",
|
||||
"description": "The list of supported payout methods supported by this pull payment. Available options can be queried from the `StorePaymentMethods_GetStorePaymentMethods` endpoint",
|
||||
"description": "The list of supported payout methods supported by this pull payment. Available options can be queried from the `StorePaymentMethods_GetStorePaymentMethods` endpoint. If `null`, all available payout methods will be supported.",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"example": "BTC"
|
||||
}
|
||||
},
|
||||
"nullable": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user