mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-23 06:35:13 +01:00
* Make Invoice Create Faster And Fix Gap Limit Issue This make address reserve only when user "activate" paymet method in ui. optional setting in store checkout ui. * Fix swagger documentation around Lazy payment methods * fix changed code signature * Add missing GreenField API for activate feature * Fix checkout experience styling for activate feature * Fix issue with Checkout activate button * Make lightning also work with activation * Make sure PreparePaymentModel is still called on payment handlers even when unactivated * Make payment link return empty if not activated * Add activate payment method method to client and add test * remove debugger * add e2e test * Rearranging lazy payments position in UI to be near dependent Unified QR code * fix rebase conflicts * Make lazy payment method mode activate on UI load. Co-authored-by: Kukks <evilkukka@gmail.com> Co-authored-by: rockstardev <rockstardev@users.noreply.github.com> Co-authored-by: Andrew Camilleri <kukks@btcpayserver.org>
97 lines
4.7 KiB
C#
97 lines
4.7 KiB
C#
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<InvoicePaymentMethodDataModel[]> GetInvoicePaymentMethods(string storeId, string invoiceId,
|
|
CancellationToken token = default)
|
|
{
|
|
var response = await _httpClient.SendAsync(
|
|
CreateHttpRequest($"api/v1/stores/{storeId}/invoices/{invoiceId}/payment-methods"), token);
|
|
return await HandleResponse<InvoicePaymentMethodDataModel[]>(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);
|
|
}
|
|
|
|
public virtual async Task<InvoiceData> MarkInvoiceStatus(string storeId, string invoiceId,
|
|
MarkInvoiceStatusRequest request, CancellationToken token = default)
|
|
{
|
|
if (request == null)
|
|
throw new ArgumentNullException(nameof(request));
|
|
if (request.Status!= InvoiceStatus.Settled && request.Status!= InvoiceStatus.Invalid)
|
|
throw new ArgumentOutOfRangeException(nameof(request.Status), "Status can only be Invalid or Complete");
|
|
var response = await _httpClient.SendAsync(
|
|
CreateHttpRequest($"api/v1/stores/{storeId}/invoices/{invoiceId}/status", bodyPayload: request,
|
|
method: HttpMethod.Post), token);
|
|
return await HandleResponse<InvoiceData>(response);
|
|
}
|
|
|
|
public virtual async Task<InvoiceData> UnarchiveInvoice(string storeId, string invoiceId, CancellationToken token = default)
|
|
{
|
|
var response = await _httpClient.SendAsync(
|
|
CreateHttpRequest($"api/v1/stores/{storeId}/invoices/{invoiceId}/unarchive",
|
|
method: HttpMethod.Post), token);
|
|
return await HandleResponse<InvoiceData>(response);
|
|
}
|
|
|
|
public virtual async Task ActivateInvoicePaymentMethod(string storeId, string invoiceId, string paymentMethod, CancellationToken token = default)
|
|
{
|
|
var response = await _httpClient.SendAsync(
|
|
CreateHttpRequest($"api/v1/stores/{storeId}/invoices/{invoiceId}/payment-methods/{paymentMethod}/activate",
|
|
method: HttpMethod.Post), token);
|
|
await HandleResponse(response);
|
|
}
|
|
}
|
|
}
|