Table of Contents

Class StripeInvoiceApiClient

Namespace
NuvTools.Payment.Stripe.ApiClient.Services
Assembly
NuvTools.Payment.Stripe.ApiClient.dll

Invoices kept by the provider: the ones its subscriptions issue, and the ones the caller issues for what it measured itself. Listing them, serving their PDF, paying one again, and crediting one back.

public class StripeInvoiceApiClient : IPaymentInvoiceClient
Inheritance
StripeInvoiceApiClient
Implements
Inherited Members

Remarks

The provider numbers, renders, charges and retries the invoice. A caller keeps a copy of what it lists and refreshes it from GetInvoiceAsync(string, CancellationToken) when an event about it arrives.

Constructors

StripeInvoiceApiClient(IStripeClient, IHttpClientFactory, ILogger<StripeInvoiceApiClient>)

Invoices kept by the provider: the ones its subscriptions issue, and the ones the caller issues for what it measured itself. Listing them, serving their PDF, paying one again, and crediting one back.

public StripeInvoiceApiClient(IStripeClient client, IHttpClientFactory httpClientFactory, ILogger<StripeInvoiceApiClient> logger)

Parameters

client IStripeClient
httpClientFactory IHttpClientFactory
logger ILogger<StripeInvoiceApiClient>

Remarks

The provider numbers, renders, charges and retries the invoice. A caller keeps a copy of what it lists and refreshes it from GetInvoiceAsync(string, CancellationToken) when an event about it arrives.

Methods

CreateCreditNoteAsync(PaymentCreditNoteRequest, CancellationToken)

Gives back part or all of a paid invoice: a credit note, with the money refunded to the card.

public Task<IResult<PaymentCreditNoteDTO>> CreateCreditNoteAsync(PaymentCreditNoteRequest request, CancellationToken cancellationToken = default)

Parameters

request PaymentCreditNoteRequest

Which invoice, how much, and the key that makes a repeat harmless.

cancellationToken CancellationToken

Cancels the call.

Returns

Task<IResult<PaymentCreditNoteDTO>>

CreateInvoiceAsync(PaymentInvoiceRequest, CancellationToken)

Issues an invoice with the caller's lines and, unless asked otherwise, has the provider charge the customer's default payment method for it straight away.

public Task<IResult<PaymentInvoiceDTO>> CreateInvoiceAsync(PaymentInvoiceRequest request, CancellationToken cancellationToken = default)

Parameters

request PaymentInvoiceRequest

Who owes it, for what, and the key that makes a repeat harmless.

cancellationToken CancellationToken

Cancels the call.

Returns

Task<IResult<PaymentInvoiceDTO>>

Remarks

The charge's outcome arrives by webhook. The invoice returned is as it stood once issued — open, usually, with its first charge on its way.

GetCreditNoteAsync(string, CancellationToken)

A credit note as the provider holds it now.

public Task<IResult<PaymentCreditNoteDTO>> GetCreditNoteAsync(string creditNoteId, CancellationToken cancellationToken = default)

Parameters

creditNoteId string

The provider's identifier for it.

cancellationToken CancellationToken

Cancels the call.

Returns

Task<IResult<PaymentCreditNoteDTO>>

GetCreditNotePdfAsync(string, CancellationToken)

The credit note's PDF, fetched by the server.

public Task<IResult<PaymentDocumentDTO>> GetCreditNotePdfAsync(string creditNoteId, CancellationToken cancellationToken = default)

Parameters

creditNoteId string

The provider's identifier for it.

cancellationToken CancellationToken

Cancels the call.

Returns

Task<IResult<PaymentDocumentDTO>>

GetInvoiceAsync(string, CancellationToken)

An invoice as the provider holds it now.

public Task<IResult<PaymentInvoiceDTO>> GetInvoiceAsync(string invoiceId, CancellationToken cancellationToken = default)

Parameters

invoiceId string

The provider's identifier for it.

cancellationToken CancellationToken

Cancels the call.

Returns

Task<IResult<PaymentInvoiceDTO>>

GetInvoicePdfAsync(string, CancellationToken)

The invoice's PDF, fetched by the server so the provider's link never reaches a browser.

public Task<IResult<PaymentDocumentDTO>> GetInvoicePdfAsync(string invoiceId, CancellationToken cancellationToken = default)

Parameters

invoiceId string

The provider's identifier for it.

cancellationToken CancellationToken

Cancels the call.

Returns

Task<IResult<PaymentDocumentDTO>>

ListInvoicesAsync(string, string?, int, CancellationToken)

A customer's invoices, newest first, drafts left out.

public Task<IResult<PaymentInvoicePageDTO>> ListInvoicesAsync(string customerId, string? startingAfter = null, int limit = 20, CancellationToken cancellationToken = default)

Parameters

customerId string

Whose invoices.

startingAfter string

The last invoice of the previous page, to read the next.

limit int

How many, 1 to 100.

cancellationToken CancellationToken

Cancels the call.

Returns

Task<IResult<PaymentInvoicePageDTO>>

PayInvoiceAsync(string, CancellationToken)

Charges an open invoice again, from the customer's default payment method now.

public Task<IResult<PaymentInvoiceDTO>> PayInvoiceAsync(string invoiceId, CancellationToken cancellationToken = default)

Parameters

invoiceId string

The provider's identifier for it.

cancellationToken CancellationToken

Cancels the call.

Returns

Task<IResult<PaymentInvoiceDTO>>

Remarks

For after the customer replaced a card that was refused.