diff --git a/billing/entitlement/service.go b/billing/entitlement/service.go index e74351c4e..56f2de14e 100644 --- a/billing/entitlement/service.go +++ b/billing/entitlement/service.go @@ -2,7 +2,6 @@ package entitlement import ( "context" - "errors" "github.com/raystack/frontier/billing/plan" @@ -48,8 +47,8 @@ func NewEntitlementService(subscriptionService SubscriptionService, } } -// Check checks if the customer has access to the feature or product -func (s *Service) Check(ctx context.Context, customerID, featureOrProductID string) (bool, error) { +// Check checks if the customer has access to the feature +func (s *Service) Check(ctx context.Context, customerID, featureID string) (bool, error) { // get all subscriptions for the customer subs, err := s.subscriptionService.List(ctx, subscription.Filter{ CustomerID: customerID, @@ -59,7 +58,7 @@ func (s *Service) Check(ctx context.Context, customerID, featureOrProductID stri } // get the feature - feature, err := s.productService.GetFeatureByID(ctx, featureOrProductID) + feature, err := s.productService.GetFeatureByID(ctx, featureID) if err != nil { return false, err } @@ -72,15 +71,6 @@ func (s *Service) Check(ctx context.Context, customerID, featureOrProductID stri return false, err } - // could be product ID as well - asProduct, err := s.productService.GetByID(ctx, featureOrProductID) - if err != nil && !errors.Is(err, product.ErrProductNotFound) { - return false, err - } - if asProduct.ID != "" { - products = append(products, asProduct) - } - // check if the product is in any of the subscriptions for _, sub := range subs { if !sub.IsActive() { diff --git a/billing/entitlement/service_test.go b/billing/entitlement/service_test.go index ff76dd603..e26a1691b 100644 --- a/billing/entitlement/service_test.go +++ b/billing/entitlement/service_test.go @@ -234,7 +234,6 @@ func TestService_Check(t *testing.T) { PlanIDs: []string{"plan1"}, }, }, nil) - mockProduct.EXPECT().GetByID(ctx, "feature2").Return(product.Product{}, nil) return s }, @@ -269,7 +268,6 @@ func TestService_Check(t *testing.T) { PlanIDs: []string{"plan2"}, }, }, nil) - mockProduct.EXPECT().GetByID(ctx, "feature3").Return(product.Product{}, nil) return s },