mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-01-19 05:33:31 +01:00
add swagger docs
This commit is contained in:
parent
4917f32574
commit
41bebfedc4
61
BTCPayServer.Client/BTCPayServerClient.Invoices.cs
Normal file
61
BTCPayServer.Client/BTCPayServerClient.Invoices.cs
Normal file
@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BTCPayServer.Client.Models;
|
||||
|
||||
namespace BTCPayServer.Client
|
||||
{
|
||||
public partial class BTCPayServerClient
|
||||
{
|
||||
public virtual async Task<IEnumerable<InvoiceData>> GetInvoices(string storeId, bool includeArchived = false,
|
||||
CancellationToken token = default)
|
||||
{
|
||||
var response =
|
||||
await _httpClient.SendAsync(
|
||||
CreateHttpRequest($"api/v1/stores/{storeId}/invoices",
|
||||
new Dictionary<string, object>() {{nameof(includeArchived), includeArchived}}), token);
|
||||
return await HandleResponse<IEnumerable<InvoiceData>>(response);
|
||||
}
|
||||
|
||||
public virtual async Task<InvoiceData> GetInvoice(string storeId, string invoiceId,
|
||||
CancellationToken token = default)
|
||||
{
|
||||
var response = await _httpClient.SendAsync(
|
||||
CreateHttpRequest($"api/v1/stores/{storeId}/invoices/{invoiceId}"), token);
|
||||
return await HandleResponse<InvoiceData>(response);
|
||||
}
|
||||
|
||||
public virtual async Task ArchiveInvoice(string storeId, string invoiceId,
|
||||
CancellationToken token = default)
|
||||
{
|
||||
var response = await _httpClient.SendAsync(
|
||||
CreateHttpRequest($"api/v1/stores/{storeId}/invoices/{invoiceId}",
|
||||
method: HttpMethod.Delete), token);
|
||||
await HandleResponse(response);
|
||||
}
|
||||
|
||||
public virtual async Task<InvoiceData> CreateInvoice(string storeId,
|
||||
CreateInvoiceRequest request, CancellationToken token = default)
|
||||
{
|
||||
if (request == null)
|
||||
throw new ArgumentNullException(nameof(request));
|
||||
var response = await _httpClient.SendAsync(
|
||||
CreateHttpRequest($"api/v1/stores/{storeId}/invoices", bodyPayload: request,
|
||||
method: HttpMethod.Post), token);
|
||||
return await HandleResponse<InvoiceData>(response);
|
||||
}
|
||||
|
||||
public virtual async Task<InvoiceData> UpdateInvoice(string storeId, string invoiceId,
|
||||
UpdateInvoiceRequest request, CancellationToken token = default)
|
||||
{
|
||||
if (request == null)
|
||||
throw new ArgumentNullException(nameof(request));
|
||||
var response = await _httpClient.SendAsync(
|
||||
CreateHttpRequest($"api/v1/stores/{storeId}/invoices/{invoiceId}", bodyPayload: request,
|
||||
method: HttpMethod.Put), token);
|
||||
return await HandleResponse<InvoiceData>(response);
|
||||
}
|
||||
}
|
||||
}
|
@ -10,10 +10,13 @@ namespace BTCPayServer.Client
|
||||
public partial class BTCPayServerClient
|
||||
{
|
||||
public virtual async Task<IEnumerable<PaymentRequestData>> GetPaymentRequests(string storeId,
|
||||
bool includeArchived = false,
|
||||
CancellationToken token = default)
|
||||
{
|
||||
var response =
|
||||
await _httpClient.SendAsync(CreateHttpRequest($"api/v1/stores/{storeId}/payment-requests"), token);
|
||||
await _httpClient.SendAsync(
|
||||
CreateHttpRequest($"api/v1/stores/{storeId}/payment-requests",
|
||||
new Dictionary<string, object>() {{nameof(includeArchived), includeArchived}}), token);
|
||||
return await HandleResponse<IEnumerable<PaymentRequestData>>(response);
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ namespace BTCPayServer.Tests
|
||||
s.Driver.FindElement(By.Id("AddApiKey")).Click();
|
||||
s.Driver.FindElement(By.CssSelector("button[value='btcpay.store.canmodifystoresettings:change-store-mode']")).Click();
|
||||
//there should be a store already by default in the dropdown
|
||||
var dropdown = s.Driver.FindElement(By.Name("PermissionValues[2].SpecificStores[0]"));
|
||||
var dropdown = s.Driver.FindElement(By.Name("PermissionValues[3].SpecificStores[0]"));
|
||||
var option = dropdown.FindElement(By.TagName("option"));
|
||||
var storeId = option.GetAttribute("value");
|
||||
option.Click();
|
||||
|
@ -731,6 +731,97 @@ namespace BTCPayServer.Tests
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Fact(Timeout = TestTimeout)]
|
||||
[Trait("Integration", "Integration")]
|
||||
public async Task InvoiceTests()
|
||||
{
|
||||
using (var tester = ServerTester.Create())
|
||||
{
|
||||
await tester.StartAsync();
|
||||
var user = tester.NewAccount();
|
||||
await user.GrantAccessAsync();
|
||||
await user.MakeAdmin();
|
||||
var client = await user.CreateClient(Policies.Unrestricted);
|
||||
var viewOnly = await user.CreateClient(Policies.CanViewInvoices);
|
||||
|
||||
//create
|
||||
|
||||
//validation errors
|
||||
await AssertValidationError(new[] { nameof(CreateInvoiceRequest.Currency), nameof(CreateInvoiceRequest.Amount), $"{nameof(CreateInvoiceRequest.Checkout)}.{nameof(CreateInvoiceRequest.Checkout.PaymentTolerance)}", $"{nameof(CreateInvoiceRequest.Checkout)}.{nameof(CreateInvoiceRequest.Checkout.PaymentMethods)}[0]" }, async () =>
|
||||
{
|
||||
await client.CreateInvoice(user.StoreId, new CreateInvoiceRequest() { Amount = -1, Checkout = new CreateInvoiceRequest.CheckoutOptions(){ PaymentTolerance = -2, PaymentMethods = new []{"jasaas_sdsad"}}});
|
||||
});
|
||||
|
||||
await AssertHttpError(403, async () =>
|
||||
{
|
||||
await viewOnly.CreateInvoice(user.StoreId,
|
||||
new CreateInvoiceRequest() { Currency = "helloinvalid", Amount = 1 });
|
||||
});
|
||||
await user.RegisterDerivationSchemeAsync("BTC");
|
||||
var newInvoice = await client.CreateInvoice(user.StoreId,
|
||||
new CreateInvoiceRequest() { Currency = "USD", Amount = 1, Metadata = new CreateInvoiceRequest.ProductInformation(){ ItemCode = "testitem"}});
|
||||
|
||||
//list
|
||||
var invoices = await viewOnly.GetInvoices(user.StoreId);
|
||||
|
||||
Assert.NotNull(invoices);
|
||||
Assert.Single(invoices);
|
||||
Assert.Equal(newInvoice.Id, invoices.First().Id);
|
||||
|
||||
//get payment request
|
||||
var invoice = await viewOnly.GetInvoice(user.StoreId, newInvoice.Id);
|
||||
Assert.Equal(newInvoice.Metadata.ItemCode, invoice.Metadata.ItemCode);
|
||||
|
||||
//update
|
||||
await AssertHttpError(403, async () =>
|
||||
{
|
||||
await viewOnly.UpdateInvoice(user.StoreId, invoice.Id, new UpdateInvoiceRequest()
|
||||
{
|
||||
Email = "j@g.com"
|
||||
});
|
||||
});
|
||||
await client.UpdateInvoice(user.StoreId, invoice.Id, new UpdateInvoiceRequest()
|
||||
{
|
||||
Email = "j@g.com"
|
||||
});
|
||||
invoice = await viewOnly.GetInvoice(user.StoreId, newInvoice.Id);
|
||||
Assert.Equal(invoice.Customer.BuyerEmail, "j@g.com");
|
||||
|
||||
await AssertValidationError(new[] { nameof(UpdateInvoiceRequest.Email), nameof(UpdateInvoiceRequest.Archived),nameof(UpdateInvoiceRequest.Status) }, async () =>
|
||||
{
|
||||
await client.UpdateInvoice(user.StoreId, invoice.Id, new UpdateInvoiceRequest()
|
||||
{
|
||||
Email = "j@g2.com",
|
||||
Archived = true,
|
||||
Status = InvoiceStatus.Complete
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
//archive
|
||||
await AssertHttpError(403, async () =>
|
||||
{
|
||||
await viewOnly.ArchiveInvoice(user.StoreId, invoice.Id);
|
||||
});
|
||||
|
||||
await client.ArchiveInvoice(user.StoreId, invoice.Id);
|
||||
Assert.DoesNotContain(invoice.Id,
|
||||
(await client.GetInvoices(user.StoreId)).Select(data => data.Id));
|
||||
|
||||
//unarchive
|
||||
await client.UpdateInvoice(user.StoreId, invoice.Id, new UpdateInvoiceRequest()
|
||||
{
|
||||
Archived = false,
|
||||
});
|
||||
Assert.NotNull(await client.GetInvoice(user.StoreId,invoice.Id));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Fact(Timeout = TestTimeout)]
|
||||
[Trait("Fast", "Fast")]
|
||||
|
@ -34,8 +34,8 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
|
||||
[Authorize(Policy = Policies.CanViewInvoices,
|
||||
AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
|
||||
[HttpGet("~/api/v1/stores/{storeId}/invoices/{invoiceId}")]
|
||||
public async Task<IActionResult> GetInvoices(string storeId)
|
||||
[HttpGet("~/api/v1/stores/{storeId}/invoices")]
|
||||
public async Task<IActionResult> GetInvoices(string storeId, bool includeArchived = false)
|
||||
{
|
||||
var store = HttpContext.GetStoreData();
|
||||
if (store == null)
|
||||
@ -46,7 +46,7 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
var invoices =
|
||||
await _invoiceRepository.GetInvoices(new InvoiceQuery()
|
||||
{
|
||||
StoreId = new[] {store.Id}, IncludeArchived = false
|
||||
StoreId = new[] {store.Id}, IncludeArchived = includeArchived
|
||||
});
|
||||
|
||||
return Ok(invoices.Select(ToModel));
|
||||
@ -104,6 +104,11 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
ModelState.AddModelError(nameof(request.Amount), "The amount should be 0 or more.");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(request.Currency))
|
||||
{
|
||||
ModelState.AddModelError(nameof(request.Currency), "Currency is required");
|
||||
}
|
||||
|
||||
if (request.Checkout.PaymentMethods?.Any() is true)
|
||||
{
|
||||
for (int i = 0; i < request.Checkout.PaymentMethods.Length; i++)
|
||||
@ -139,14 +144,21 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
if (!ModelState.IsValid)
|
||||
return this.CreateValidationError(ModelState);
|
||||
|
||||
var invoice = await _invoiceController.CreateInvoiceCoreRaw(FromModel(request), store,
|
||||
Request.GetAbsoluteUri(""));
|
||||
return Ok(ToModel(invoice));
|
||||
try
|
||||
{
|
||||
var invoice = await _invoiceController.CreateInvoiceCoreRaw(FromModel(request), store,
|
||||
Request.GetAbsoluteUri(""));
|
||||
return Ok(ToModel(invoice));
|
||||
}
|
||||
catch (BitpayHttpException e)
|
||||
{
|
||||
return this.CreateAPIError(null, e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
[Authorize(Policy = Policies.CanModifyStoreSettings,
|
||||
AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
|
||||
[HttpPost("~/api/v1/stores/{storeId}/invoices/{invoiceId}")]
|
||||
[HttpPut("~/api/v1/stores/{storeId}/invoices/{invoiceId}")]
|
||||
public async Task<IActionResult> UpdateInvoice(string storeId, string invoiceId, UpdateInvoiceRequest request)
|
||||
{
|
||||
var store = HttpContext.GetStoreData();
|
||||
@ -242,7 +254,7 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
PaymentMethods =
|
||||
entity.GetPaymentMethods().Select(method => method.GetId().ToString()).ToArray(),
|
||||
RedirectAutomatically = entity.RedirectAutomatically,
|
||||
RedirectUri = entity.RedirectURL.ToString(),
|
||||
RedirectUri = entity.RedirectURL?.ToString(),
|
||||
SpeedPolicy = entity.SpeedPolicy,
|
||||
WebHook = entity.NotificationURL
|
||||
},
|
||||
|
@ -438,7 +438,7 @@ retry:
|
||||
var invoiceData = await context.FindAsync<InvoiceData>(invoiceId).ConfigureAwait(false);
|
||||
if (invoiceData == null || invoiceData.Archived == archived ||
|
||||
(storeId != null &&
|
||||
invoiceData.StoreDataId.Equals(storeId, StringComparison.InvariantCultureIgnoreCase)))
|
||||
!invoiceData.StoreDataId.Equals(storeId, StringComparison.InvariantCultureIgnoreCase)))
|
||||
return;
|
||||
invoiceData.Archived = archived;
|
||||
await context.SaveChangesAsync().ConfigureAwait(false);
|
||||
@ -448,12 +448,13 @@ retry:
|
||||
{
|
||||
using (var context = _ContextFactory.CreateContext())
|
||||
{
|
||||
var invoiceData = await context.FindAsync<Data.InvoiceData>(invoiceId).ConfigureAwait(false);
|
||||
var invoiceData = await GetInvoiceRaw(invoiceId);
|
||||
if (invoiceData == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
context.Attach(invoiceData);
|
||||
string eventName;
|
||||
switch (status)
|
||||
{
|
||||
@ -475,15 +476,23 @@ retry:
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
invoiceData.Status =status.ToString().ToLowerInvariant();
|
||||
|
||||
invoiceData.Status = status.ToString().ToLowerInvariant();
|
||||
invoiceData.ExceptionStatus = InvoiceExceptionStatus.Marked.ToString().ToLowerInvariant();
|
||||
_eventAggregator.Publish(new InvoiceEvent(ToEntity(invoiceData), eventName));
|
||||
await context.SaveChangesAsync().ConfigureAwait(false);
|
||||
await context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public async Task<InvoiceEntity> GetInvoice(string id, bool inludeAddressData = false)
|
||||
{
|
||||
var res = await GetInvoiceRaw(id, inludeAddressData);
|
||||
return res == null ? null : ToEntity(res);
|
||||
}
|
||||
|
||||
private async Task<InvoiceData> GetInvoiceRaw(string id, bool inludeAddressData = false)
|
||||
{
|
||||
using (var context = _ContextFactory.CreateContext())
|
||||
{
|
||||
@ -499,7 +508,7 @@ retry:
|
||||
if (invoice == null)
|
||||
return null;
|
||||
|
||||
return ToEntity(invoice);
|
||||
return invoice;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
@model (InvoiceDetailsModel Invoice, bool ShowAddress)
|
||||
@using BTCPayServer.Client.Models
|
||||
@model (InvoiceDetailsModel Invoice, bool ShowAddress)
|
||||
@{ var invoice = Model.Invoice; }
|
||||
@inject PaymentMethodHandlerDictionary PaymentMethodHandlerDictionary
|
||||
|
||||
|
712
BTCPayServer/wwwroot/swagger/v1/swagger.template.invoices.json
Normal file
712
BTCPayServer/wwwroot/swagger/v1/swagger.template.invoices.json
Normal file
@ -0,0 +1,712 @@
|
||||
{
|
||||
"paths": {
|
||||
"/api/v1/stores/{storeId}/invoices": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Invoices"
|
||||
],
|
||||
"summary": "Get invoices",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "storeId",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"description": "The store to query",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"description": "View information about the existing invoices",
|
||||
"operationId": "Invoices_GetInvoices",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "list of invoices",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/InvoiceDataList"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"API Key": [
|
||||
"btcpay.store.canviewinvoices"
|
||||
],
|
||||
"Basic": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"post": {
|
||||
"tags": [
|
||||
"Invoices"
|
||||
],
|
||||
"summary": "Create a new invoice",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "storeId",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"description": "The store to query",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"description": "Create a new invoice",
|
||||
"operationId": "Invoices_CreateInvoice",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Information about the new invoice",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/InvoiceData"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "A list of errors that occurred when creating the invoice",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ValidationProblemDetails"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "If you are authenticated but forbidden to add new invoices"
|
||||
}
|
||||
},
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/CreateInvoiceRequest"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"API Key": [
|
||||
"btcpay.store.cancreateinvoice"
|
||||
],
|
||||
"Basic": []
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v1/stores/{storeId}/invoices/{invoiceId}": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Invoices"
|
||||
],
|
||||
"summary": "Get invoice",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "storeId",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"description": "The store to fetch",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "invoiceId",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"description": "The invoice to fetch",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"description": "View information about the specified invoice",
|
||||
"operationId": "Invoices_GetInvoice",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "specified invoice",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/InvoiceData"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "If you are authenticated but forbidden to view the specified invoie"
|
||||
},
|
||||
"404": {
|
||||
"description": "The key is not found for this invoice"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"API Key": [
|
||||
"btcpay.store.canviewinvoices"
|
||||
],
|
||||
"Basic": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"delete": {
|
||||
"tags": [
|
||||
"Invoices"
|
||||
],
|
||||
"summary": "Archive invoice",
|
||||
"description": "Archives the specified invoice.",
|
||||
"operationId": "Invoices_ArchiveInvoice",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "storeId",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"description": "The store the invoice belongs to",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "invoiceId",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"description": "The invoice to remove",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "The invoice has been archived"
|
||||
},
|
||||
"400": {
|
||||
"description": "A list of errors that occurred when archiving the invoice",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ValidationProblemDetails"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "If you are authenticated but forbidden to archive the specified invoice"
|
||||
},
|
||||
"404": {
|
||||
"description": "The key is not found for this invoice"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"API Key": [
|
||||
"btcpay.store.canmodifystoresettings"
|
||||
],
|
||||
"Basic": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"put": {
|
||||
"tags": [
|
||||
"Invoices"
|
||||
],
|
||||
"summary": "Update invoice",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "storeId",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"description": "The store to query",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "invoiceId",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"description": "The invoice to update",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"description": "Update an invoice",
|
||||
"operationId": "Invoices_UpdateInvoice",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "The updated invoice",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/InvoiceData"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "A list of errors that occurred when updating the invoice",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ValidationProblemDetails"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "If you are authenticated but forbidden to update the invoice"
|
||||
}
|
||||
},
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/UpdateInvoiceRequest"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"API Key": [
|
||||
"btcpay.store.canmodifystoresettings"
|
||||
],
|
||||
"Basic": []
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"InvoiceDataList": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/InvoiceData"
|
||||
}
|
||||
},
|
||||
"UpdateInvoiceRequest": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"archived": {
|
||||
"type": "boolean",
|
||||
"nullable": true,
|
||||
"description": "Unarchive an invoice. You can only archive from the HTTP DELETE endpoint."
|
||||
},
|
||||
"status": {
|
||||
"nullable": true,
|
||||
"description": "Mark an invoice as completed or invalid.",
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "#/components/schemas/InvoiceStatusMark"
|
||||
}
|
||||
]
|
||||
},
|
||||
"email": {
|
||||
"type": "string",
|
||||
"nullable": true,
|
||||
"description": "Sets the customer email, if it was not set before."
|
||||
}
|
||||
}
|
||||
},
|
||||
"InvoiceStatusMark": {
|
||||
"type": "string",
|
||||
"description": "",
|
||||
"x-enumNames": [
|
||||
"Invalid",
|
||||
"Complete"
|
||||
],
|
||||
"enum": [
|
||||
"Invalid",
|
||||
"Complete"
|
||||
]
|
||||
},
|
||||
"InvoiceStatus": {
|
||||
"type": "string",
|
||||
"description": "",
|
||||
"x-enumNames": [
|
||||
"New",
|
||||
"Paid",
|
||||
"Expired",
|
||||
"Invalid",
|
||||
"Complete",
|
||||
"Confirmed"
|
||||
],
|
||||
"enum": [
|
||||
"New",
|
||||
"Paid",
|
||||
"Expired",
|
||||
"Invalid",
|
||||
"Complete",
|
||||
"Confirmed"
|
||||
]
|
||||
},
|
||||
"InvoiceExceptionStatus": {
|
||||
"type": "string",
|
||||
"description": "",
|
||||
"x-enumNames": [
|
||||
"None",
|
||||
"PaidLate",
|
||||
"PaidPartial",
|
||||
"Marked",
|
||||
"Invalid",
|
||||
"PaidOver"
|
||||
],
|
||||
"enum": [
|
||||
"None",
|
||||
"PaidLate",
|
||||
"PaidPartial",
|
||||
"Marked",
|
||||
"Invalid",
|
||||
"PaidOver"
|
||||
]
|
||||
},
|
||||
"InvoiceData": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/components/schemas/CreateInvoiceRequest"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"nullable": true,
|
||||
"description": "The identifier of the invoice"
|
||||
},
|
||||
"status": {
|
||||
"$ref": "#/components/schemas/InvoiceStatus",
|
||||
"description": "The status of the invoice"
|
||||
},
|
||||
"exceptionStatus": {
|
||||
"$ref": "#/components/schemas/InvoiceExceptionStatus",
|
||||
"description": "a secondary status of the invoice"
|
||||
},
|
||||
"paymentMethodData": {
|
||||
"type": "object",
|
||||
"nullable": false,
|
||||
"additionalProperties": {
|
||||
"$ref": "#/components/schemas/PaymentMethodDataModel"
|
||||
},
|
||||
"description": "Activated payment methods details"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"PaymentMethodDataModel": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"destination": {
|
||||
"type": "string",
|
||||
"nullable": true,
|
||||
"description": "The destination the payment must be made to"
|
||||
},
|
||||
"paymentLink": {
|
||||
"type": "string",
|
||||
"nullable": true,
|
||||
"description": "A payment link that helps pay to the payment destination"
|
||||
},
|
||||
"rate": {
|
||||
"type": "string",
|
||||
"format": "decimal",
|
||||
"description": "The rate between this payment method's currency and the invoice currency"
|
||||
},
|
||||
"paymentMethodPaid": {
|
||||
"type": "string",
|
||||
"format": "decimal",
|
||||
"description": "The amount paid by this payment method"
|
||||
},
|
||||
"totalPaid": {
|
||||
"type": "string",
|
||||
"format": "decimal",
|
||||
"description": "The total amount paid by all payment methods to the invoice, converted to this payment method's currency"
|
||||
},
|
||||
"due": {
|
||||
"type": "string",
|
||||
"format": "decimal",
|
||||
"description": "The total amount left to be paid, converted to this payment method's currency"
|
||||
},
|
||||
"amount": {
|
||||
"type": "string",
|
||||
"format": "decimal",
|
||||
"description": "The invoice amount, converted to this payment method's currency"
|
||||
},
|
||||
"networkFee": {
|
||||
"type": "string",
|
||||
"format": "decimal",
|
||||
"description": "The added merchant fee to pay for network costs of this payment method."
|
||||
},
|
||||
"payments": {
|
||||
"type": "array",
|
||||
"nullable": true,
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/Payment"
|
||||
},
|
||||
"description": "Payments made with this payment method."
|
||||
}
|
||||
}
|
||||
},
|
||||
"Payment": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"nullable": true,
|
||||
"description": "A unique identifier for this payment"
|
||||
},
|
||||
"receivedDate": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"description": "The date the payment was recorded"
|
||||
},
|
||||
"value": {
|
||||
"type": "string",
|
||||
"format": "decimal",
|
||||
"description": "The value of the payment"
|
||||
},
|
||||
"fee": {
|
||||
"type": "string",
|
||||
"format": "decimal",
|
||||
"description": "The fee paid for the payment"
|
||||
},
|
||||
"status": {
|
||||
"$ref": "#/components/schemas/PaymentStatus",
|
||||
"description": "The status of the payment"
|
||||
},
|
||||
"destination": {
|
||||
"type": "string",
|
||||
"nullable": true,
|
||||
"description": "The destination the payment was made to"
|
||||
}
|
||||
}
|
||||
},
|
||||
"PaymentStatus": {
|
||||
"type": "string",
|
||||
"description": "",
|
||||
"x-enumNames": [
|
||||
"Invalid",
|
||||
"AwaitingConfirmation",
|
||||
"AwaitingCompletion",
|
||||
"Complete"
|
||||
],
|
||||
"enum": [
|
||||
"Invalid",
|
||||
"AwaitingConfirmation",
|
||||
"AwaitingCompletion",
|
||||
"Complete"
|
||||
]
|
||||
},
|
||||
"CreateInvoiceRequest": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"amount": {
|
||||
"type": "string",
|
||||
"format": "decimal",
|
||||
"description": "The amount of the invoice"
|
||||
},
|
||||
"currency": {
|
||||
"type": "string",
|
||||
"nullable": true,
|
||||
"description": "The currency the invoice will use"
|
||||
},
|
||||
"metadata": {
|
||||
"nullable": true,
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "#/components/schemas/ProductInformation"
|
||||
}
|
||||
],
|
||||
"description": "Additional information around the invoice"
|
||||
},
|
||||
"customer": {
|
||||
"nullable": true,
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "#/components/schemas/BuyerInformation"
|
||||
}
|
||||
],
|
||||
"description": "Additional information around the entity the invoice is addressed to"
|
||||
},
|
||||
"checkout": {
|
||||
"nullable": true,
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "#/components/schemas/CheckoutOptions"
|
||||
}
|
||||
],
|
||||
"description": "Additional settings to customize the checkout flow"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ProductInformation": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"orderId": {
|
||||
"type": "string",
|
||||
"nullable": true,
|
||||
"description": "Can be used by the merchant to assign their own internal ID to an invoice."
|
||||
},
|
||||
"posData": {
|
||||
"type": "string",
|
||||
"nullable": true,
|
||||
"description": "A passthru variable provided by the merchant and designed to be used by the merchant to correlate the invoice with an order or other object in their system. This passthru variable can be a serialized object, e.g.:"
|
||||
},
|
||||
"itemDesc": {
|
||||
"type": "string",
|
||||
"nullable": true,
|
||||
"description": "Invoice description - will be added as a line item on the checkout page, under the merchant name"
|
||||
},
|
||||
"itemCode": {
|
||||
"type": "string",
|
||||
"nullable": true,
|
||||
"description": "An item code, for a specific product code that is being paid for. Usually used in conjunction with the POS/Crowdfund apps"
|
||||
},
|
||||
"physical": {
|
||||
"type": "boolean",
|
||||
"description": "Whether it was a physical purchase"
|
||||
},
|
||||
"taxIncluded": {
|
||||
"type": "string",
|
||||
"format": "decimal",
|
||||
"nullable": true,
|
||||
"description": "How much tax is included in the invoice amount"
|
||||
}
|
||||
}
|
||||
},
|
||||
"BuyerInformation": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"buyerName": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"buyerEmail": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"buyerCountry": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"buyerZip": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"buyerState": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"buyerCity": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"buyerAddress2": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"buyerAddress1": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"buyerPhone": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"CheckoutOptions": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"speedPolicy": {
|
||||
"nullable": true,
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "#/components/schemas/SpeedPolicy"
|
||||
}
|
||||
],
|
||||
"description": "This is a risk mitigation parameter for the merchant to configure how they want to fulfill orders depending on the number of block confirmations for the transaction made by the consumer on the selected cryptocurrency"
|
||||
},
|
||||
"paymentMethods": {
|
||||
"type": "array",
|
||||
"nullable": true,
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "A specific set of payment methods to use for this invoice"
|
||||
},
|
||||
"redirectAutomatically": {
|
||||
"type": "boolean",
|
||||
"nullable": true,
|
||||
"description": "Whether to redirect to the redirectUri automatically after the invoice has been paid. Default to the store setting (which is `false` by default)"
|
||||
},
|
||||
"redirectUri": {
|
||||
"type": "string",
|
||||
"nullable": true,
|
||||
"description": "This is the URL for a return link that is displayed on the receipt, to return the shopper back to your website after a successful purchase. This could be a page specific to the order, or to their account."
|
||||
},
|
||||
"webHook": {
|
||||
"type": "string",
|
||||
"format": "uri",
|
||||
"nullable": true,
|
||||
"description":"A URL to send webhook notification to. Sent when the status changes or a payment is detected"
|
||||
},
|
||||
"expirationTime": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"nullable": true,
|
||||
"description": "When the invoice expires. By default will use the store settings (which is set to 15 minutes by default)"
|
||||
},
|
||||
"paymentTolerance": {
|
||||
"type": "string",
|
||||
"format": "double",
|
||||
"nullable": true,
|
||||
"minimum": 0,
|
||||
"maximum": 100,
|
||||
"description": "A percentage dtermining whether to count the invoice as paid when the invoice is paid within the specified margin of error"
|
||||
}
|
||||
}
|
||||
},
|
||||
"SpeedPolicy": {
|
||||
"type": "string",
|
||||
"description": "",
|
||||
"x-enumNames": [
|
||||
"HighSpeed",
|
||||
"MediumSpeed",
|
||||
"LowSpeed",
|
||||
"LowMediumSpeed"
|
||||
],
|
||||
"enum": [
|
||||
"HighSpeed",
|
||||
"MediumSpeed",
|
||||
"LowSpeed",
|
||||
"LowMediumSpeed"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"tags": [
|
||||
{
|
||||
"name": "Invoices"
|
||||
}
|
||||
]
|
||||
}
|
@ -122,7 +122,7 @@
|
||||
}
|
||||
],
|
||||
"description": "View information about the specified payment request",
|
||||
"operationId": "PaymentRequests_GetPaymentRequests",
|
||||
"operationId": "PaymentRequests_GetPaymentRequest",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "specified payment request",
|
||||
@ -218,7 +218,7 @@
|
||||
"name": "paymentRequestId",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"description": "The payment request to remove",
|
||||
"description": "The payment request to update",
|
||||
"schema": { "type": "string" }
|
||||
}
|
||||
],
|
||||
|
Loading…
Reference in New Issue
Block a user