// FIXME: Update this file to be null safe and then delete the line below
#nullable disable
using Bit.Core.Billing.Models;
using Bit.Core.Billing.Tax.Models;
using Bit.Core.Entities;
using Bit.Core.Enums;
using Stripe;
namespace Bit.Core.Billing.Services;
public interface ISubscriberService
{
///
/// Cancels a subscriber's subscription while including user-provided feedback via the .
/// If the flag is ,
/// this command sets the subscription's "cancel_at_end_of_period" property to .
/// Otherwise, this command cancels the subscription immediately.
///
/// The subscriber with the subscription to cancel.
/// An DTO containing user-provided feedback on why they are cancelling the subscription.
/// A flag indicating whether to cancel the subscription immediately or at the end of the subscription period.
Task CancelSubscription(
ISubscriber subscriber,
OffboardingSurveyResponse offboardingSurveyResponse,
bool cancelImmediately);
///
/// Creates a Braintree for the provided while attaching the provided .
///
/// The subscriber to create a Braintree customer for.
/// A nonce representing the PayPal payment method the customer will use for payments.
/// The of the created Braintree customer.
Task CreateBraintreeCustomer(
ISubscriber subscriber,
string paymentMethodNonce);
Task CreateStripeCustomer(
ISubscriber subscriber);
///
/// Retrieves a Stripe using the 's property.
///
/// The subscriber to retrieve the Stripe customer for.
/// Optional parameters that can be passed to Stripe to expand or modify the customer.
/// A Stripe .
/// Thrown when the is .
/// This method opts for returning rather than throwing exceptions, making it ideal for surfacing data from API endpoints.
Task GetCustomer(
ISubscriber subscriber,
CustomerGetOptions customerGetOptions = null);
///
/// Retrieves a Stripe using the 's property.
///
/// The subscriber to retrieve the Stripe customer for.
/// Optional parameters that can be passed to Stripe to expand or modify the customer.
/// A Stripe .
/// Thrown when the is .
/// Thrown when the subscriber's is or empty.
/// Thrown when the returned from Stripe's API is null.
Task GetCustomerOrThrow(
ISubscriber subscriber,
CustomerGetOptions customerGetOptions = null);
///
/// Retrieves a masked representation of the subscriber's payment source for presentation to a client.
///
/// The subscriber to retrieve the payment source for.
/// A containing a non-identifiable description of the subscriber's payment source. Example: VISA, *4242, 10/2026
Task GetPaymentSource(
ISubscriber subscriber);
///
/// Retrieves a Stripe using the 's property.
///
/// The subscriber to retrieve the Stripe subscription for.
/// Optional parameters that can be passed to Stripe to expand or modify the subscription.
/// A Stripe .
/// Thrown when the is .
/// This method opts for returning rather than throwing exceptions, making it ideal for surfacing data from API endpoints.
Task GetSubscription(
ISubscriber subscriber,
SubscriptionGetOptions subscriptionGetOptions = null);
///
/// Retrieves a Stripe using the 's property.
///
/// The subscriber to retrieve the Stripe subscription for.
/// Optional parameters that can be passed to Stripe to expand or modify the subscription.
/// A Stripe .
/// Thrown when the is .
/// Thrown when the subscriber's is or empty.
/// Thrown when the returned from Stripe's API is null.
Task GetSubscriptionOrThrow(
ISubscriber subscriber,
SubscriptionGetOptions subscriptionGetOptions = null);
///
/// Attempts to remove a subscriber's saved payment source. If the Stripe representing the
/// contains a valid "btCustomerId" key in its property,
/// this command will attempt to remove the Braintree . Otherwise, it will attempt to remove the
/// Stripe .
///
/// The subscriber to remove the saved payment source for.
Task RemovePaymentSource(ISubscriber subscriber);
///
/// Updates the payment source for the provided using the .
/// The following types are supported: [, , ].
/// For each type, updating the payment source will attempt to establish a new payment source using the token in the . Then, it will
/// remove the exising payment source(s) linked to the subscriber's customer.
///
/// The subscriber to update the payment method for.
/// A DTO representing a tokenized payment method.
Task UpdatePaymentSource(
ISubscriber subscriber,
TokenizedPaymentSource tokenizedPaymentSource);
///
/// Updates the tax information for the provided .
///
/// The to update the tax information for.
/// A representing the 's updated tax information.
Task UpdateTaxInformation(
ISubscriber subscriber,
TaxInformation taxInformation);
///
/// Validates whether the 's exists in the gateway.
/// If the 's is or empty, returns .
///
/// The subscriber whose gateway customer ID should be validated.
/// if the gateway customer ID is valid or empty; if the customer doesn't exist in the gateway.
/// Thrown when the is .
Task IsValidGatewayCustomerIdAsync(ISubscriber subscriber);
///
/// Validates whether the 's exists in the gateway.
/// If the 's is or empty, returns .
///
/// The subscriber whose gateway subscription ID should be validated.
/// if the gateway subscription ID is valid or empty; if the subscription doesn't exist in the gateway.
/// Thrown when the is .
Task IsValidGatewaySubscriptionIdAsync(ISubscriber subscriber);
}