@@ -13,12 +13,12 @@ import (
1313 "github.com/shopspring/decimal"
1414 "github.com/stripe/stripe-go/v81"
1515 "github.com/zeebo/errs"
16+ "go.uber.org/zap"
1617
1718 "storj.io/common/currency"
1819 "storj.io/common/storj"
1920 "storj.io/common/uuid"
2021 "storj.io/storj/satellite/accounting"
21- "storj.io/storj/satellite/entitlements"
2222 "storj.io/storj/satellite/payments"
2323 "storj.io/storj/satellite/payments/coinpayments"
2424)
@@ -634,23 +634,26 @@ func (accounts *accounts) GetProjectUsagePriceModel(partner string) payments.Pro
634634
635635// GetPartnerPlacementPriceModel returns the productID and related usage price model for a partner and placement,
636636// if there is none defined for the project ID.
637- func (accounts * accounts ) GetPartnerPlacementPriceModel (ctx context.Context , projectPublicID uuid.UUID , partner string , placement storj.PlacementConstraint ) (_ int32 , _ payments.ProductUsagePriceModel , _ error ) {
637+ func (accounts * accounts ) GetPartnerPlacementPriceModel (ctx context.Context , projectPublicID uuid.UUID , partner string , placement storj.PlacementConstraint ) (_ int32 , _ payments.ProductUsagePriceModel ) {
638638 if accounts .service .config .EntitlementsEnabled {
639639 feats , err := accounts .service .entitlements .Projects ().GetByPublicID (ctx , projectPublicID )
640640 if err != nil {
641- if ! entitlements . ErrNotFound . Has ( err ) {
642- return 0 , payments. ProductUsagePriceModel {}, err
643- }
641+ accounts . service . log . Error (
642+ "could not get pricing entitlements for project, falling back to defaults" ,
643+ zap . String ( "partner" , partner ), zap . Int ( "placement" , int ( placement )), zap . Error ( err ))
644644 }
645645 for productID , placementConstraints := range feats .ProductPlacementMappings {
646646 for _ , pC := range placementConstraints {
647647 if pC != placement {
648648 continue
649649 }
650650 if price , ok := accounts .service .pricingConfig .ProductPriceMap [productID ]; ok {
651- return productID , price , nil
651+ return productID , price
652652 }
653- return 0 , payments.ProductUsagePriceModel {}, ErrPricingNotfound .New ("pricing not found for product %d" , productID )
653+ accounts .service .log .Info (
654+ "no product definition for product and partner, falling back to defaults" ,
655+ zap .String ("partner" , partner ), zap .Int ("placement" , int (placement )))
656+ // fall through to global pricing
654657 }
655658 }
656659 }
@@ -660,17 +663,17 @@ func (accounts *accounts) GetPartnerPlacementPriceModel(ctx context.Context, pro
660663 productID , _ = accounts .service .pricingConfig .PlacementProductMap .GetProductByPlacement (int (placement ))
661664 }
662665 if price , ok := accounts .service .pricingConfig .ProductPriceMap [productID ]; ok {
663- return productID , price , nil
666+ return productID , price
664667 }
665- return 0 , payments.ProductUsagePriceModel {}, ErrPricingNotfound .New ("pricing not found for partner %s and placement %d" , partner , placement )
666- }
667668
668- // GetProductName returns the product name for a given product ID.
669- func (accounts * accounts ) GetProductName (productID int32 ) (string , error ) {
670- if price , ok := accounts .service .pricingConfig .ProductPriceMap [productID ]; ok {
671- return price .ProductName , nil
669+ accounts .service .log .Info (
670+ "no product definition for product and partner, falling back to defaults" ,
671+ zap .String ("partner" , partner ), zap .Int ("placement" , int (placement )))
672+
673+ // fall back to default pricing for partner
674+ return 0 , payments.ProductUsagePriceModel {
675+ ProjectUsagePriceModel : accounts .GetProjectUsagePriceModel (partner ),
672676 }
673- return "" , ErrPricingNotfound .New ("pricing not found for product %d" , productID )
674677}
675678
676679// GetPartnerNames returns the partners relevant to billing.
0 commit comments