mirror of
https://github.com/bitwarden/server.git
synced 2024-11-22 12:15:36 +01:00
[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
This commit is contained in:
parent
19a7aa500d
commit
0171a3150e
File diff suppressed because it is too large
Load Diff
@ -79,4 +79,14 @@ public interface IStripeFacade
|
||||
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);
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ public class StripeFacade : IStripeFacade
|
||||
private readonly PaymentMethodService _paymentMethodService = new();
|
||||
private readonly SubscriptionService _subscriptionService = new();
|
||||
private readonly TaxRateService _taxRateService = new();
|
||||
private readonly DiscountService _discountService = new();
|
||||
|
||||
public async Task<Charge> GetCharge(
|
||||
string chargeId,
|
||||
@ -96,4 +97,16 @@ public class StripeFacade : IStripeFacade
|
||||
RequestOptions requestOptions = null,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
await _taxRateService.GetAsync(taxRateId, options, requestOptions, cancellationToken);
|
||||
|
||||
public async Task<Discount> DeleteCustomerDiscount(
|
||||
string customerId,
|
||||
RequestOptions requestOptions = null,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
await _discountService.DeleteCustomerDiscountAsync(customerId, requestOptions, cancellationToken);
|
||||
|
||||
public async Task<Discount> DeleteSubscriptionDiscount(
|
||||
string subscriptionId,
|
||||
RequestOptions requestOptions = null,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
await _discountService.DeleteSubscriptionDiscountAsync(subscriptionId, requestOptions, cancellationToken);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user