Skip to content

Commit

Permalink
fix: add filter for providerID on invoice repo, and remove unnecessar…
Browse files Browse the repository at this point in the history
…y invoice sync event
  • Loading branch information
anujk14 committed Aug 29, 2024
1 parent b61d9b9 commit f396e01
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/event/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func (p *Service) BillingWebhook(ctx context.Context, payload ProviderWebhookEve
if err != nil {
stdLogger.Error("error syncing customer", zap.Error(err), zap.String("provider_id", providerID))
}
case "invoice.payment_succeeded", "customer.subscription.created",
case "customer.subscription.created",
"customer.subscription.updated", "customer.subscription.deleted":
// trigger subscriptions sync
deDupKey := fmt.Sprintf("subscription-%s-%d", providerID, currentExecutionUnit)
Expand Down
5 changes: 5 additions & 0 deletions internal/store/postgres/billing_subscription_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,11 @@ func (r BillingSubscriptionRepository) List(ctx context.Context, filter subscrip
"customer_id": filter.CustomerID,
})
}
if filter.ProviderID != "" {
stmt = stmt.Where(goqu.Ex{
"provider_id": filter.ProviderID,
})
}
if filter.PlanID != "" {
stmt = stmt.Where(goqu.Ex{
"plan_id": filter.PlanID,
Expand Down

0 comments on commit f396e01

Please sign in to comment.