1
0
mirror of https://github.com/bitwarden/server synced 2025-12-31 15:43:16 +00:00
Files
server/src/Billing/Services/IStripeFacade.cs
Conner Turnbull 0171a3150e [AC-2427] update discount logic for complimentary password manager (#3990)
* Refactored the charge succeeded handler a bit

* If refund charge is received, and we don't have a parent transaction stored already, attempt to create one

* Converted else if structure to switch-case

* Moved logic for invoice.upcoming to a private method

* Moved logic for charge.succeeded to a private method

* Moved logic for charge.refunded to a private method

* Moved logic for invoice.payment_succeeded to a private method

* Updated invoice.payment_failed to match the rest

* Updated invoice.created to match the rest with some light refactors

* Added method comment to HandlePaymentMethodAttachedAsync

* Moved logic for customer.updated to a private method

* Updated logger in default case

* Separated customer.subscription.deleted and customer.subscription.updated to be in their own blocks

* Moved logic for customer.subscription.deleted to a private method

* Moved logic for customer.subscription.updated to a private method

* Merged customer sub updated or deleted to switch

* No longer checking if the user has premium before disabling it since the service already checks

* Moved webhook secret parsing logic to private method

* Moved casting of event to specific object down to handler

* Reduced nesting throughout

* When removing secrets manager, now deleting 100% off password manager discount for SM trials

* Added method comment and reduced nesting in RemovePasswordManagerCouponIfRemovingSecretsManagerTrialAsync
2024-04-19 09:15:48 -04:00

93 lines
3.2 KiB
C#

using Stripe;
namespace Bit.Billing.Services;
public interface IStripeFacade
{
Task<Charge> GetCharge(
string chargeId,
ChargeGetOptions chargeGetOptions = null,
RequestOptions requestOptions = null,
CancellationToken cancellationToken = default);
Task<Customer> GetCustomer(
string customerId,
CustomerGetOptions customerGetOptions = null,
RequestOptions requestOptions = null,
CancellationToken cancellationToken = default);
Task<Invoice> GetInvoice(
string invoiceId,
InvoiceGetOptions invoiceGetOptions = null,
RequestOptions requestOptions = null,
CancellationToken cancellationToken = default);
Task<StripeList<Invoice>> ListInvoices(
InvoiceListOptions options = null,
RequestOptions requestOptions = null,
CancellationToken cancellationToken = default);
Task<Invoice> UpdateInvoice(
string invoiceId,
InvoiceUpdateOptions invoiceGetOptions = null,
RequestOptions requestOptions = null,
CancellationToken cancellationToken = default);
Task<Invoice> PayInvoice(
string invoiceId,
InvoicePayOptions options = null,
RequestOptions requestOptions = null,
CancellationToken cancellationToken = default);
Task<Invoice> VoidInvoice(
string invoiceId,
InvoiceVoidOptions options = null,
RequestOptions requestOptions = null,
CancellationToken cancellationToken = default);
Task<PaymentMethod> GetPaymentMethod(
string paymentMethodId,
PaymentMethodGetOptions paymentMethodGetOptions = null,
RequestOptions requestOptions = null,
CancellationToken cancellationToken = default);
Task<StripeList<Subscription>> ListSubscriptions(
SubscriptionListOptions options = null,
RequestOptions requestOptions = null,
CancellationToken cancellationToken = default);
Task<Subscription> GetSubscription(
string subscriptionId,
SubscriptionGetOptions subscriptionGetOptions = null,
RequestOptions requestOptions = null,
CancellationToken cancellationToken = default);
Task<Subscription> UpdateSubscription(
string subscriptionId,
SubscriptionUpdateOptions subscriptionGetOptions = null,
RequestOptions requestOptions = null,
CancellationToken cancellationToken = default);
Task<Subscription> CancelSubscription(
string subscriptionId,
SubscriptionCancelOptions options = null,
RequestOptions requestOptions = null,
CancellationToken cancellationToken = default);
Task<TaxRate> GetTaxRate(
string taxRateId,
TaxRateGetOptions options = null,
RequestOptions requestOptions = null,
CancellationToken cancellationToken = default);
Task<Discount> DeleteCustomerDiscount(
string customerId,
RequestOptions requestOptions = null,
CancellationToken cancellationToken = default);
Task<Discount> DeleteSubscriptionDiscount(
string subscriptionId,
RequestOptions requestOptions = null,
CancellationToken cancellationToken = default);
}