|
@@ -24,7 +24,7 @@ func NewListCustomerInvoicesHandler(
|
|
|
writer shared.ResultWriter,
|
|
writer shared.ResultWriter,
|
|
|
) *ListCustomerInvoicesHandler {
|
|
) *ListCustomerInvoicesHandler {
|
|
|
return &ListCustomerInvoicesHandler{
|
|
return &ListCustomerInvoicesHandler{
|
|
|
- PorterHandlerReadWriter: handlers.NewDefaultPorterHandler(config, decoderValidator, writer),
|
|
|
|
|
|
|
+ PorterHandlerReadWriter: handlers.NewDefaultPorterHandler(config, nil, writer),
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -35,24 +35,22 @@ func (c *ListCustomerInvoicesHandler) ServeHTTP(w http.ResponseWriter, r *http.R
|
|
|
proj, _ := ctx.Value(types.ProjectScope).(*models.Project)
|
|
proj, _ := ctx.Value(types.ProjectScope).(*models.Project)
|
|
|
|
|
|
|
|
telemetry.WithAttributes(span,
|
|
telemetry.WithAttributes(span,
|
|
|
- telemetry.AttributeKV{Key: "billing-config-exists", Value: c.Config().BillingManager.StripeConfigLoaded},
|
|
|
|
|
- telemetry.AttributeKV{Key: "billing-enabled", Value: proj.GetFeatureFlag(models.BillingEnabled, c.Config().LaunchDarklyClient)},
|
|
|
|
|
|
|
+ telemetry.AttributeKV{Key: "lago-config-exists", Value: c.Config().BillingManager.LagoConfigLoaded},
|
|
|
|
|
+ telemetry.AttributeKV{Key: "lago-enabled", Value: proj.GetFeatureFlag(models.LagoEnabled, c.Config().LaunchDarklyClient)},
|
|
|
telemetry.AttributeKV{Key: "porter-cloud-enabled", Value: proj.EnableSandbox},
|
|
telemetry.AttributeKV{Key: "porter-cloud-enabled", Value: proj.EnableSandbox},
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
- if !c.Config().BillingManager.StripeConfigLoaded || !proj.GetFeatureFlag(models.BillingEnabled, c.Config().LaunchDarklyClient) {
|
|
|
|
|
|
|
+ if !c.Config().BillingManager.LagoConfigLoaded || !proj.GetFeatureFlag(models.LagoEnabled, c.Config().LaunchDarklyClient) {
|
|
|
c.WriteResult(w, r, "")
|
|
c.WriteResult(w, r, "")
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- req := &types.ListCustomerInvoicesRequest{}
|
|
|
|
|
-
|
|
|
|
|
- if ok := c.DecodeAndValidate(w, r, req); !ok {
|
|
|
|
|
- err := telemetry.Error(ctx, span, nil, "error decoding list customer usage request")
|
|
|
|
|
- c.HandleAPIError(w, r, apierrors.NewErrPassThroughToClient(err, http.StatusBadRequest))
|
|
|
|
|
|
|
+ invoices, err := c.Config().BillingManager.LagoClient.ListCustomerFinalizedInvoices(ctx, proj.ID, proj.EnableSandbox)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ err = telemetry.Error(ctx, span, err, "error listing invoices")
|
|
|
|
|
+ c.HandleAPIError(w, r, apierrors.NewErrPassThroughToClient(err, http.StatusInternalServerError))
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // Write the response to the frontend
|
|
|
|
|
- c.WriteResult(w, r, "invoices")
|
|
|
|
|
|
|
+ c.WriteResult(w, r, invoices)
|
|
|
}
|
|
}
|