Table of Contents

Interface IPaymentSubscriptionClient

Namespace
NuvTools.Payment.Contracts
Assembly
NuvTools.Payment.dll

Recurring billing run by the provider: starting a subscription, letting the customer manage it, and reading where it stands.

public interface IPaymentSubscriptionClient

Remarks

The provider owns the cycle — renewals, retries, invoices, proration — and reports changes by webhook. A caller keeps a copy of what it needs to decide on access and refreshes it from GetSubscriptionAsync(string, CancellationToken) when an event arrives, rather than trusting the order events arrive in.

Both pages are hosted by the provider, so no card reaches the caller.

Methods

CancelSubscriptionAsync(string, CancellationToken)

Ends a subscription at the end of the period already paid for; it renews no more.

Task<IResult<PaymentSubscriptionDTO>> CancelSubscriptionAsync(string subscriptionId, CancellationToken cancellationToken = default)

Parameters

subscriptionId string

The provider's identifier for it.

cancellationToken CancellationToken

Cancels the call.

Returns

Task<IResult<PaymentSubscriptionDTO>>

CreateCheckoutPageAsync(SubscriptionCheckoutRequest, CancellationToken)

A provider-hosted page that starts a subscription, and the address to send the customer to.

Task<IResult<string>> CreateCheckoutPageAsync(SubscriptionCheckoutRequest request, CancellationToken cancellationToken = default)

Parameters

request SubscriptionCheckoutRequest

Who pays, for which price, and where to return to.

cancellationToken CancellationToken

Cancels the call.

Returns

Task<IResult<string>>

Remarks

The subscription is reported by a webhook rather than by the return address, which the customer may never reach.

CreateManagementPageAsync(string, string, CancellationToken)

A provider-hosted page where the customer changes their payment method, reads their invoices and changes or cancels their subscriptions, and the address to send them to.

Task<IResult<string>> CreateManagementPageAsync(string customerId, string returnUrl, CancellationToken cancellationToken = default)

Parameters

customerId string

Whose subscriptions.

returnUrl string

Where the customer returns when they are done.

cancellationToken CancellationToken

Cancels the call.

Returns

Task<IResult<string>>

CreateSubscriptionAsync(SubscriptionRequest, CancellationToken)

Starts a subscription charged to a payment method the customer already saved — no provider page.

Task<IResult<PaymentSubscriptionStartDTO>> CreateSubscriptionAsync(SubscriptionRequest request, CancellationToken cancellationToken = default)

Parameters

request SubscriptionRequest

Who pays, for which price, from which saved method.

cancellationToken CancellationToken

Cancels the call.

Returns

Task<IResult<PaymentSubscriptionStartDTO>>

Remarks

The first invoice is charged at once. A card that wants its owner to confirm leaves the subscription incomplete, with a client secret for the caller's own page to confirm with; the outcome then arrives by webhook like every later one.

GetSubscriptionAsync(string, CancellationToken)

A subscription as the provider holds it now.

Task<IResult<PaymentSubscriptionDTO>> GetSubscriptionAsync(string subscriptionId, CancellationToken cancellationToken = default)

Parameters

subscriptionId string

The provider's identifier for it.

cancellationToken CancellationToken

Cancels the call.

Returns

Task<IResult<PaymentSubscriptionDTO>>

ResumeSubscriptionAsync(string, CancellationToken)

Undoes CancelSubscriptionAsync(string, CancellationToken) while the period is still running: it renews again.

Task<IResult<PaymentSubscriptionDTO>> ResumeSubscriptionAsync(string subscriptionId, CancellationToken cancellationToken = default)

Parameters

subscriptionId string

The provider's identifier for it.

cancellationToken CancellationToken

Cancels the call.

Returns

Task<IResult<PaymentSubscriptionDTO>>

SetItemQuantityAsync(string, string, long, string?, CancellationToken)

Sets how many units of a price a subscription is charged for — the seats of a per-seat price — adding the price when the subscription does not carry it yet and taking it off at zero.

Task<IResult<PaymentSubscriptionDTO>> SetItemQuantityAsync(string subscriptionId, string priceLookupKey, long quantity, string? idempotencyKey = null, CancellationToken cancellationToken = default)

Parameters

subscriptionId string

The provider's identifier for the subscription.

priceLookupKey string

The lookup key of the price whose quantity is set.

quantity long

The new quantity; zero takes the price off the subscription.

idempotencyKey string

Makes a retried request apply once.

cancellationToken CancellationToken

Cancels the call.

Returns

Task<IResult<PaymentSubscriptionDTO>>

Remarks

The quantity is absolute, never a difference, so a call repeated after a failure leaves the same count. The change is prorated over the period already running, and the subscription is returned as it stands afterwards.