|
|
@@ -285,14 +285,14 @@ func getProjectRoutes(
|
|
|
Router: r,
|
|
|
})
|
|
|
|
|
|
- // GET /api/project/{project_id}/billing/redirect -> billing.NewRedirectBillingHandler
|
|
|
- redirectBillingEndpoint := factory.NewAPIEndpoint(
|
|
|
+ // GET /api/projects/{project_id}/billing/payment_method -> project.NewListBillingHandler
|
|
|
+ listBillingEndpoint := factory.NewAPIEndpoint(
|
|
|
&types.APIRequestMetadata{
|
|
|
Verb: types.APIVerbGet,
|
|
|
Method: types.HTTPVerbGet,
|
|
|
Path: &types.Path{
|
|
|
Parent: basePath,
|
|
|
- RelativePath: relPath + "/billing/redirect",
|
|
|
+ RelativePath: relPath + "/billing/payment_method",
|
|
|
},
|
|
|
Scopes: []types.PermissionScope{
|
|
|
types.UserScope,
|
|
|
@@ -301,25 +301,25 @@ func getProjectRoutes(
|
|
|
},
|
|
|
)
|
|
|
|
|
|
- redirectBillingHandler := billing.NewRedirectBillingHandler(
|
|
|
+ listBillingHandler := billing.NewListBillingHandler(
|
|
|
config,
|
|
|
factory.GetResultWriter(),
|
|
|
)
|
|
|
|
|
|
routes = append(routes, &router.Route{
|
|
|
- Endpoint: redirectBillingEndpoint,
|
|
|
- Handler: redirectBillingHandler,
|
|
|
+ Endpoint: listBillingEndpoint,
|
|
|
+ Handler: listBillingHandler,
|
|
|
Router: r,
|
|
|
})
|
|
|
|
|
|
- // GET /api/projects/{project_id}/billing -> project.NewProjectGetBillingHandler
|
|
|
- getBillingEndpoint := factory.NewAPIEndpoint(
|
|
|
+ // POST /api/projects/{project_id}/billing/payment_method -> project.NewCreateBillingHandler
|
|
|
+ createBillingEndpoint := factory.NewAPIEndpoint(
|
|
|
&types.APIRequestMetadata{
|
|
|
- Verb: types.APIVerbGet,
|
|
|
- Method: types.HTTPVerbGet,
|
|
|
+ Verb: types.APIVerbCreate,
|
|
|
+ Method: types.HTTPVerbPost,
|
|
|
Path: &types.Path{
|
|
|
Parent: basePath,
|
|
|
- RelativePath: relPath + "/billing",
|
|
|
+ RelativePath: relPath + "/billing/payment_method",
|
|
|
},
|
|
|
Scopes: []types.PermissionScope{
|
|
|
types.UserScope,
|
|
|
@@ -328,38 +328,70 @@ func getProjectRoutes(
|
|
|
},
|
|
|
)
|
|
|
|
|
|
- getBillingHandler := project.NewProjectGetBillingHandler(
|
|
|
+ createBillingHandler := billing.NewCreateBillingHandler(
|
|
|
config,
|
|
|
+ factory.GetDecoderValidator(),
|
|
|
factory.GetResultWriter(),
|
|
|
)
|
|
|
|
|
|
routes = append(routes, &router.Route{
|
|
|
- Endpoint: getBillingEndpoint,
|
|
|
- Handler: getBillingHandler,
|
|
|
+ Endpoint: createBillingEndpoint,
|
|
|
+ Handler: createBillingHandler,
|
|
|
Router: r,
|
|
|
})
|
|
|
|
|
|
- // GET /api/billing_webhook -> billing.NewBillingWebhookHandler
|
|
|
- getBillingWebhookEndpoint := factory.NewAPIEndpoint(
|
|
|
+ // DELETE /api/projects/{project_id}/billing/payment_method/{payment_method_id} -> project.NewDeleteBillingHandler
|
|
|
+ deleteBillingEndpoint := factory.NewAPIEndpoint(
|
|
|
+ &types.APIRequestMetadata{
|
|
|
+ Verb: types.APIVerbDelete,
|
|
|
+ Method: types.HTTPVerbDelete,
|
|
|
+ Path: &types.Path{
|
|
|
+ Parent: basePath,
|
|
|
+ RelativePath: fmt.Sprintf("%s/billing/payment_method/{%s}", relPath, types.URLParamPaymentMethodID),
|
|
|
+ },
|
|
|
+ Scopes: []types.PermissionScope{
|
|
|
+ types.UserScope,
|
|
|
+ types.ProjectScope,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ )
|
|
|
+
|
|
|
+ deleteBillingHandler := billing.NewDeleteBillingHandler(
|
|
|
+ config,
|
|
|
+ factory.GetResultWriter(),
|
|
|
+ )
|
|
|
+
|
|
|
+ routes = append(routes, &router.Route{
|
|
|
+ Endpoint: deleteBillingEndpoint,
|
|
|
+ Handler: deleteBillingHandler,
|
|
|
+ Router: r,
|
|
|
+ })
|
|
|
+
|
|
|
+ // POST /api/projects/{project_id}/billing/customer/ -> project.NewGetOrCreateCustomerHandler
|
|
|
+ getOrCreateBillingCustomerEndpoint := factory.NewAPIEndpoint(
|
|
|
&types.APIRequestMetadata{
|
|
|
Verb: types.APIVerbCreate,
|
|
|
Method: types.HTTPVerbPost,
|
|
|
Path: &types.Path{
|
|
|
Parent: basePath,
|
|
|
- RelativePath: "/billing_webhook",
|
|
|
+ RelativePath: relPath + "/billing/customer",
|
|
|
+ },
|
|
|
+ Scopes: []types.PermissionScope{
|
|
|
+ types.UserScope,
|
|
|
+ types.ProjectScope,
|
|
|
},
|
|
|
- Scopes: []types.PermissionScope{},
|
|
|
},
|
|
|
)
|
|
|
|
|
|
- getBillingWebhookHandler := billing.NewBillingWebhookHandler(
|
|
|
+ getOrCreateBillingCustomerHandler := billing.NewCreateBillingCustomerIfNotExists(
|
|
|
config,
|
|
|
factory.GetDecoderValidator(),
|
|
|
+ factory.GetResultWriter(),
|
|
|
)
|
|
|
|
|
|
routes = append(routes, &router.Route{
|
|
|
- Endpoint: getBillingWebhookEndpoint,
|
|
|
- Handler: getBillingWebhookHandler,
|
|
|
+ Endpoint: getOrCreateBillingCustomerEndpoint,
|
|
|
+ Handler: getOrCreateBillingCustomerHandler,
|
|
|
Router: r,
|
|
|
})
|
|
|
|