From 81ffd49bef2ca4b7d18adf60cdfeec2448b00732 Mon Sep 17 00:00:00 2001 From: Kai Jellinghaus Date: Wed, 22 Feb 2023 19:15:10 +0100 Subject: [PATCH] Remove Stripe (#1217) --- backend/windmill-api/Cargo.toml | 4 ++-- backend/windmill-api/src/workspaces.rs | 28 ++++++++++++++++++++------ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/backend/windmill-api/Cargo.toml b/backend/windmill-api/Cargo.toml index ebd4234817..c39f4efc46 100644 --- a/backend/windmill-api/Cargo.toml +++ b/backend/windmill-api/Cargo.toml @@ -9,7 +9,7 @@ name = "windmill_api" path = "src/lib.rs" [features] -enterprise = ["windmill-queue/enterprise"] +enterprise = ["windmill-queue/enterprise", "async-stripe"] [dependencies] windmill-queue.workspace = true @@ -65,7 +65,7 @@ hmac.workspace = true cookie.workspace = true sha2.workspace = true urlencoding.workspace = true -async-stripe.workspace = true +async-stripe = { workspace = true, optional = true } lazy_static.workspace = true prometheus.workspace = true async_zip.workspace = true diff --git a/backend/windmill-api/src/workspaces.rs b/backend/windmill-api/src/workspaces.rs index bbc48903a7..3385ace51c 100644 --- a/backend/windmill-api/src/workspaces.rs +++ b/backend/windmill-api/src/workspaces.rs @@ -6,8 +6,11 @@ * LICENSE-AGPL for a copy of the license. */ +#[cfg(enterprise)] use std::str::FromStr; +#[cfg(enterprise)] +use crate::BASE_URL; use crate::{ apps::AppWithLastVersion, db::{UserDB, DB}, @@ -15,16 +18,19 @@ use crate::{ resources::{Resource, ResourceType}, users::{Authed, WorkspaceInvite, NEW_USER_WEBHOOK}, utils::require_super_admin, - BASE_URL, HTTP_CLIENT, + HTTP_CLIENT, }; +#[cfg(enterprise)] +use axum::response::Redirect; use axum::{ body::StreamBody, extract::{Extension, Path, Query}, headers, - response::{IntoResponse, Redirect}, + response::IntoResponse, routing::{delete, get, post}, Json, Router, }; +#[cfg(enterprise)] use stripe::CustomerId; use windmill_audit::{audit_log, ActionKind}; use windmill_common::{ @@ -43,7 +49,7 @@ use tokio::fs::File; use tokio_util::io::ReaderStream; pub fn workspaced_service() -> Router { - Router::new() + let router = Router::new() .route("/list_pending_invites", get(list_pending_invites)) .route("/update", post(edit_workspace)) .route("/archive", post(archive_workspace)) @@ -55,9 +61,16 @@ pub fn workspaced_service() -> Router { .route("/edit_webhook", post(edit_webhook)) .route("/edit_auto_invite", post(edit_auto_invite)) .route("/tarball", get(tarball_workspace)) - .route("/premium_info", get(premium_info)) - .route("/checkout", get(stripe_checkout)) - .route("/billing_portal", get(stripe_portal)) + .route("/premium_info", get(premium_info)); + + #[cfg(enterprise)] + let router = { + router + .route("/checkout", get(stripe_checkout)) + .route("/billing_portal", get(stripe_portal)); + }; + + router } pub fn global_service() -> Router { Router::new() @@ -217,11 +230,13 @@ async fn premium_info( Ok(Json(row)) } +#[cfg(enterprise)] #[derive(Deserialize)] struct PlanQuery { plan: String, } +#[cfg(enterprise)] async fn stripe_checkout( authed: Authed, Path(w_id): Path, @@ -287,6 +302,7 @@ async fn stripe_checkout( } } +#[cfg(enterprise)] async fn stripe_portal( authed: Authed, Path(w_id): Path,