mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 06:24:24 +01:00
Normalize greenfield responses for 404s (#3220)
This commit is contained in:
@@ -42,14 +42,14 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
|
||||
[Authorize(Policy = Policies.CanViewPaymentRequests, AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
|
||||
[HttpGet("~/api/v1/stores/{storeId}/payment-requests/{paymentRequestId}")]
|
||||
public async Task<ActionResult<Client.Models.PaymentRequestData>> GetPaymentRequest(string storeId, string paymentRequestId)
|
||||
public async Task<IActionResult> GetPaymentRequest(string storeId, string paymentRequestId)
|
||||
{
|
||||
var pr = await _paymentRequestRepository.FindPaymentRequests(
|
||||
new PaymentRequestQuery() { StoreId = storeId, Ids = new[] { paymentRequestId } });
|
||||
|
||||
if (pr.Total == 0)
|
||||
{
|
||||
return NotFound();
|
||||
return PaymentRequestNotFound();
|
||||
}
|
||||
|
||||
return Ok(FromModel(pr.Items.First()));
|
||||
@@ -58,13 +58,13 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
[Authorize(Policy = Policies.CanModifyPaymentRequests,
|
||||
AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
|
||||
[HttpDelete("~/api/v1/stores/{storeId}/payment-requests/{paymentRequestId}")]
|
||||
public async Task<ActionResult> ArchivePaymentRequest(string storeId, string paymentRequestId)
|
||||
public async Task<IActionResult> ArchivePaymentRequest(string storeId, string paymentRequestId)
|
||||
{
|
||||
var pr = await _paymentRequestRepository.FindPaymentRequests(
|
||||
new PaymentRequestQuery() { StoreId = storeId, Ids = new[] { paymentRequestId }, IncludeArchived = false });
|
||||
if (pr.Total == 0)
|
||||
{
|
||||
return NotFound();
|
||||
return PaymentRequestNotFound();
|
||||
}
|
||||
|
||||
var updatedPr = pr.Items.First();
|
||||
@@ -112,7 +112,7 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
new PaymentRequestQuery() { StoreId = storeId, Ids = new[] { paymentRequestId } });
|
||||
if (pr.Total == 0)
|
||||
{
|
||||
return NotFound();
|
||||
return PaymentRequestNotFound();
|
||||
}
|
||||
|
||||
var updatedPr = pr.Items.First();
|
||||
@@ -164,5 +164,10 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
CustomCSSLink = blob.CustomCSSLink
|
||||
};
|
||||
}
|
||||
|
||||
private IActionResult PaymentRequestNotFound()
|
||||
{
|
||||
return this.CreateAPIError(404, "payment-request-not-found", "The payment request was not found");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user