mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-03-12 02:08:32 +01:00
parent
2fd8c831c0
commit
e3e65878aa
4 changed files with 17 additions and 13 deletions
|
@ -968,25 +968,28 @@ namespace BTCPayServer.Tests
|
||||||
|
|
||||||
|
|
||||||
//update
|
//update
|
||||||
invoice = await viewOnly.GetInvoice(user.StoreId, newInvoice.Id);
|
newInvoice = await client.CreateInvoice(user.StoreId,
|
||||||
|
new CreateInvoiceRequest() { Currency = "USD", Amount = 1 });
|
||||||
await AssertValidationError(new[] { nameof(MarkInvoiceStatusRequest.Status) }, async () =>
|
await client.MarkInvoiceStatus(user.StoreId, newInvoice.Id, new MarkInvoiceStatusRequest()
|
||||||
{
|
|
||||||
await client.MarkInvoiceStatus(user.StoreId, invoice.Id, new MarkInvoiceStatusRequest()
|
|
||||||
{
|
{
|
||||||
Status = InvoiceStatus.Settled
|
Status = InvoiceStatus.Settled
|
||||||
});
|
});
|
||||||
|
newInvoice = await client.CreateInvoice(user.StoreId,
|
||||||
|
new CreateInvoiceRequest() { Currency = "USD", Amount = 1 });
|
||||||
|
await client.MarkInvoiceStatus(user.StoreId, newInvoice.Id, new MarkInvoiceStatusRequest()
|
||||||
|
{
|
||||||
|
Status = InvoiceStatus.Invalid
|
||||||
});
|
});
|
||||||
|
|
||||||
await AssertHttpError(403, async () =>
|
await AssertHttpError(403, async () =>
|
||||||
{
|
{
|
||||||
await viewOnly.UpdateInvoice(user.StoreId, newInvoice.Id,
|
await viewOnly.UpdateInvoice(user.StoreId, invoice.Id,
|
||||||
new UpdateInvoiceRequest()
|
new UpdateInvoiceRequest()
|
||||||
{
|
{
|
||||||
Metadata = JObject.Parse("{\"itemCode\": \"updated\", newstuff: [1,2,3,4,5]}")
|
Metadata = JObject.Parse("{\"itemCode\": \"updated\", newstuff: [1,2,3,4,5]}")
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
invoice = await client.UpdateInvoice(user.StoreId, newInvoice.Id,
|
invoice = await client.UpdateInvoice(user.StoreId, invoice.Id,
|
||||||
new UpdateInvoiceRequest()
|
new UpdateInvoiceRequest()
|
||||||
{
|
{
|
||||||
Metadata = JObject.Parse("{\"itemCode\": \"updated\", newstuff: [1,2,3,4,5]}")
|
Metadata = JObject.Parse("{\"itemCode\": \"updated\", newstuff: [1,2,3,4,5]}")
|
||||||
|
@ -996,7 +999,7 @@ namespace BTCPayServer.Tests
|
||||||
Assert.Equal(15,((JArray) invoice.Metadata["newstuff"]).Values<int>().Sum());
|
Assert.Equal(15,((JArray) invoice.Metadata["newstuff"]).Values<int>().Sum());
|
||||||
|
|
||||||
//also test the the metadata actually got saved
|
//also test the the metadata actually got saved
|
||||||
invoice = await client.GetInvoice(user.StoreId, newInvoice.Id);
|
invoice = await client.GetInvoice(user.StoreId, invoice.Id);
|
||||||
Assert.Equal("updated",invoice.Metadata["itemCode"].Value<string>());
|
Assert.Equal("updated",invoice.Metadata["itemCode"].Value<string>());
|
||||||
Assert.Equal(15,((JArray) invoice.Metadata["newstuff"]).Values<int>().Sum());
|
Assert.Equal(15,((JArray) invoice.Metadata["newstuff"]).Values<int>().Sum());
|
||||||
|
|
||||||
|
|
|
@ -212,7 +212,7 @@ namespace BTCPayServer.Controllers.GreenField
|
||||||
if (!await _invoiceRepository.MarkInvoiceStatus(invoice.Id, request.Status))
|
if (!await _invoiceRepository.MarkInvoiceStatus(invoice.Id, request.Status))
|
||||||
{
|
{
|
||||||
ModelState.AddModelError(nameof(request.Status),
|
ModelState.AddModelError(nameof(request.Status),
|
||||||
"Status can only be marked to invalid or complete within certain conditions.");
|
"Status can only be marked to invalid or settled within certain conditions.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
|
|
|
@ -665,6 +665,7 @@ namespace BTCPayServer.Services.Invoices
|
||||||
public bool CanMarkComplete()
|
public bool CanMarkComplete()
|
||||||
{
|
{
|
||||||
return (Status == InvoiceStatusLegacy.Paid) ||
|
return (Status == InvoiceStatusLegacy.Paid) ||
|
||||||
|
(Status == InvoiceStatusLegacy.New) ||
|
||||||
((Status == InvoiceStatusLegacy.New || Status == InvoiceStatusLegacy.Expired) && ExceptionStatus == InvoiceExceptionStatus.PaidPartial) ||
|
((Status == InvoiceStatusLegacy.New || Status == InvoiceStatusLegacy.Expired) && ExceptionStatus == InvoiceExceptionStatus.PaidPartial) ||
|
||||||
((Status == InvoiceStatusLegacy.New || Status == InvoiceStatusLegacy.Expired) && ExceptionStatus == InvoiceExceptionStatus.PaidLate) ||
|
((Status == InvoiceStatusLegacy.New || Status == InvoiceStatusLegacy.Expired) && ExceptionStatus == InvoiceExceptionStatus.PaidLate) ||
|
||||||
(Status != InvoiceStatusLegacy.Complete && ExceptionStatus == InvoiceExceptionStatus.Marked) ||
|
(Status != InvoiceStatusLegacy.Complete && ExceptionStatus == InvoiceExceptionStatus.Marked) ||
|
||||||
|
|
|
@ -433,7 +433,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Mark an invoice as invalid or completed.",
|
"description": "Mark an invoice as invalid or settled.",
|
||||||
"operationId": "Invoices_MarkInvoiceStatus",
|
"operationId": "Invoices_MarkInvoiceStatus",
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
|
|
Loading…
Add table
Reference in a new issue