7e73d675d7
- Add strategyName property to ISeatBillingStrategy interface and all implementations - Log which strategy handled the invoice.upcoming webhook (not just whether it applied) - Always log strategy result (not just when applied=true) for better observability - Rename highWaterMarkApplied to strategyApplied since applied covers multiple strategies Co-Authored-By: unknown <> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
20 lines
733 B
TypeScript
20 lines
733 B
TypeScript
import type { IBillingProviderService } from "../billingProvider/IBillingProviderService";
|
|
import type { SeatChangeContext } from "./ISeatBillingStrategy";
|
|
import { BaseSeatBillingStrategy } from "./ISeatBillingStrategy";
|
|
|
|
export class ImmediateUpdateStrategy extends BaseSeatBillingStrategy {
|
|
readonly strategyName = "ImmediateUpdate";
|
|
|
|
constructor(private readonly billingProviderService: IBillingProviderService) {
|
|
super();
|
|
}
|
|
|
|
async onSeatChange(context: SeatChangeContext): Promise<void> {
|
|
await this.billingProviderService.handleSubscriptionUpdate({
|
|
subscriptionId: context.subscriptionId,
|
|
subscriptionItemId: context.subscriptionItemId,
|
|
membershipCount: context.membershipCount,
|
|
});
|
|
}
|
|
}
|