2020-05-19 19:59:23 +02:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Net.Http;
|
|
|
|
using System.Threading;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using BTCPayServer.Client.Models;
|
|
|
|
|
2024-06-19 15:25:33 +02:00
|
|
|
namespace BTCPayServer.Client;
|
|
|
|
|
|
|
|
public partial class BTCPayServerClient
|
2020-05-19 19:59:23 +02:00
|
|
|
{
|
2024-06-19 15:25:33 +02:00
|
|
|
public virtual async Task<IEnumerable<PaymentRequestData>> GetPaymentRequests(string storeId,
|
|
|
|
bool includeArchived = false,
|
|
|
|
CancellationToken token = default)
|
2020-05-19 19:59:23 +02:00
|
|
|
{
|
2024-06-19 15:25:33 +02:00
|
|
|
return await SendHttpRequest<IEnumerable<PaymentRequestData>>($"api/v1/stores/{storeId}/payment-requests",
|
|
|
|
new Dictionary<string, object> { { nameof(includeArchived), includeArchived } }, HttpMethod.Get, token);
|
|
|
|
}
|
2020-05-19 19:59:23 +02:00
|
|
|
|
2024-06-19 15:25:33 +02:00
|
|
|
public virtual async Task<PaymentRequestData> GetPaymentRequest(string storeId, string paymentRequestId,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
|
|
|
return await SendHttpRequest<PaymentRequestData>($"api/v1/stores/{storeId}/payment-requests/{paymentRequestId}", null, HttpMethod.Get, token);
|
|
|
|
}
|
2020-05-19 19:59:23 +02:00
|
|
|
|
2024-06-19 15:25:33 +02:00
|
|
|
public virtual async Task ArchivePaymentRequest(string storeId, string paymentRequestId,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
|
|
|
await SendHttpRequest($"api/v1/stores/{storeId}/payment-requests/{paymentRequestId}", null, HttpMethod.Delete, token);
|
|
|
|
}
|
2020-05-19 19:59:23 +02:00
|
|
|
|
2024-06-19 15:25:33 +02:00
|
|
|
public virtual async Task<Client.Models.InvoiceData> PayPaymentRequest(string storeId, string paymentRequestId, PayPaymentRequestRequest request, CancellationToken token = default)
|
|
|
|
{
|
|
|
|
if (request == null) throw new ArgumentNullException(nameof(request));
|
|
|
|
if (storeId is null) throw new ArgumentNullException(nameof(storeId));
|
|
|
|
if (paymentRequestId is null) throw new ArgumentNullException(nameof(paymentRequestId));
|
|
|
|
return await SendHttpRequest<InvoiceData>($"api/v1/stores/{storeId}/payment-requests/{paymentRequestId}/pay", request, HttpMethod.Post, token);
|
|
|
|
}
|
2022-11-02 18:41:19 +09:00
|
|
|
|
2024-06-19 15:25:33 +02:00
|
|
|
public virtual async Task<PaymentRequestData> CreatePaymentRequest(string storeId,
|
|
|
|
CreatePaymentRequestRequest request, CancellationToken token = default)
|
|
|
|
{
|
|
|
|
if (request == null) throw new ArgumentNullException(nameof(request));
|
|
|
|
return await SendHttpRequest<PaymentRequestData>($"api/v1/stores/{storeId}/payment-requests", request, HttpMethod.Post, token);
|
|
|
|
}
|
2020-05-19 19:59:23 +02:00
|
|
|
|
2024-06-19 15:25:33 +02:00
|
|
|
public virtual async Task<PaymentRequestData> UpdatePaymentRequest(string storeId, string paymentRequestId,
|
|
|
|
UpdatePaymentRequestRequest request, CancellationToken token = default)
|
|
|
|
{
|
|
|
|
if (request == null) throw new ArgumentNullException(nameof(request));
|
|
|
|
return await SendHttpRequest<PaymentRequestData>($"api/v1/stores/{storeId}/payment-requests/{paymentRequestId}", request, HttpMethod.Put, token);
|
2020-05-19 19:59:23 +02:00
|
|
|
}
|
|
|
|
}
|