diff --git a/crates/service/plugins/billing_artcraft/src/endpoints/webhook/stripe_artcraft_webhook_handler.rs b/crates/service/plugins/billing_artcraft/src/endpoints/webhook/stripe_artcraft_webhook_handler.rs index fe9d49e61c..26d3aa8b8f 100644 --- a/crates/service/plugins/billing_artcraft/src/endpoints/webhook/stripe_artcraft_webhook_handler.rs +++ b/crates/service/plugins/billing_artcraft/src/endpoints/webhook/stripe_artcraft_webhook_handler.rs @@ -27,6 +27,7 @@ use sqlx::pool::PoolConnection; use sqlx::{MySql, MySqlConnection, MySqlPool}; use std::sync::Arc; use stripe_webhook::{Event, EventObject, Webhook}; +use crate::endpoints::webhook::webhook_event_handlers::customer_subscription::customer_subscription_updated_handler::customer_subscription_updated_handler; #[derive(Serialize)] pub struct StripeArtcraftWebhookSuccessResponse { @@ -227,7 +228,7 @@ async fn handle_webhook_payload( EventObject::CustomerSubscriptionDeleted(subscription) => { webhook_summary = customer_subscription_deleted_handler( &subscription, - internal_subscription_product_lookup.get_ref(), + server_environment, &mysql_pool).await?; } diff --git a/crates/service/plugins/billing_artcraft/src/endpoints/webhook/webhook_event_handlers/customer_subscription/common.rs b/crates/service/plugins/billing_artcraft/src/endpoints/webhook/webhook_event_handlers/customer_subscription/common.rs deleted file mode 100644 index 965be186bc..0000000000 --- a/crates/service/plugins/billing_artcraft/src/endpoints/webhook/webhook_event_handlers/customer_subscription/common.rs +++ /dev/null @@ -1,8 +0,0 @@ - -/// Subscription categories are used to namespace subscriptions. -/// Integrations should always provide a default even if this isn't used. -pub const UNKNOWN_SUBSCRIPTION_NAMESPACE: &str = "unknown"; - -/// The integrated system has internal unique string key identifiers for -/// each subscription plan. -pub const UNKNOWN_SUBSCRIPTION_PRODUCT_SLUG: &str = "unknown"; diff --git a/crates/service/plugins/billing_artcraft/src/endpoints/webhook/webhook_event_handlers/customer_subscription/customer_subscription_created_handler.rs b/crates/service/plugins/billing_artcraft/src/endpoints/webhook/webhook_event_handlers/customer_subscription/customer_subscription_created_handler.rs index 2c738a14e1..b5fba140c5 100644 --- a/crates/service/plugins/billing_artcraft/src/endpoints/webhook/webhook_event_handlers/customer_subscription/customer_subscription_created_handler.rs +++ b/crates/service/plugins/billing_artcraft/src/endpoints/webhook/webhook_event_handlers/customer_subscription/customer_subscription_created_handler.rs @@ -20,7 +20,6 @@ use stripe_shared::Subscription; pub async fn customer_subscription_created_handler( subscription: &Subscription, server_environment: ServerEnvironment, - //internal_subscription_product_lookup: &dyn InternalSubscriptionProductLookup, mysql_pool: &MySqlPool, ) -> Result { diff --git a/crates/service/plugins/billing_artcraft/src/endpoints/webhook/webhook_event_handlers/customer_subscription/customer_subscription_deleted_handler.rs b/crates/service/plugins/billing_artcraft/src/endpoints/webhook/webhook_event_handlers/customer_subscription/customer_subscription_deleted_handler.rs index 1ba206eaaa..be5d2268e0 100644 --- a/crates/service/plugins/billing_artcraft/src/endpoints/webhook/webhook_event_handlers/customer_subscription/customer_subscription_deleted_handler.rs +++ b/crates/service/plugins/billing_artcraft/src/endpoints/webhook/webhook_event_handlers/customer_subscription/customer_subscription_deleted_handler.rs @@ -37,20 +37,6 @@ pub async fn customer_subscription_deleted_handler( should_ignore_retry: false, }; - //let maybe_internal_subscription_product = - // internal_subscription_product_lookup.lookup_internal_product_from_stripe_product_id(&summary.stripe_product_id) - // .map_err(|err| { - // let reason = format!("Error mapping to internal product: {:?}", err); - // error!("{}", reason); - // StripeWebhookError::ServerError(reason) // NB: This was probably *our* fault. - // })?; - //let mut subscription_namespace = UNKNOWN_SUBSCRIPTION_NAMESPACE; - //let mut subscription_product_slug = UNKNOWN_SUBSCRIPTION_PRODUCT_SLUG; - //if let Some(ref internal_product) = maybe_internal_subscription_product { - // subscription_namespace = &internal_product.subscription_category; - // subscription_product_slug = &internal_product.subscription_product_key; - //} - let maybe_product = get_artcraft_product_by_stripe_id_and_env( &summary.stripe_product_id, server_environment); diff --git a/crates/service/plugins/billing_artcraft/src/endpoints/webhook/webhook_event_handlers/customer_subscription/customer_subscription_updated_handler.rs b/crates/service/plugins/billing_artcraft/src/endpoints/webhook/webhook_event_handlers/customer_subscription/customer_subscription_updated_handler.rs index 701211429d..5eacf2d55b 100644 --- a/crates/service/plugins/billing_artcraft/src/endpoints/webhook/webhook_event_handlers/customer_subscription/customer_subscription_updated_handler.rs +++ b/crates/service/plugins/billing_artcraft/src/endpoints/webhook/webhook_event_handlers/customer_subscription/customer_subscription_updated_handler.rs @@ -16,7 +16,6 @@ use stripe_shared::Subscription; /// Handle event type: 'customer.subscription.updated' pub async fn customer_subscription_updated_handler( subscription: &Subscription, - //internal_subscription_product_lookup: &dyn InternalSubscriptionProductLookup, server_environment: ServerEnvironment, mysql_pool: &MySqlPool, ) -> Result { @@ -38,20 +37,6 @@ pub async fn customer_subscription_updated_handler( let mut should_process_update = true; - //let maybe_internal_subscription_product = - // internal_subscription_product_lookup.lookup_internal_product_from_stripe_product_id(&summary.stripe_product_id) - // .map_err(|err| { - // let reason = format!("Error mapping to internal product: {:?}", err); - // error!("{}", reason); - // StripeArtcraftWebhookError::ServerError(reason) // NB: This was probably *our* fault. - // })?; - //let mut subscription_namespace = UNKNOWN_SUBSCRIPTION_NAMESPACE; - //let mut subscription_product_slug = UNKNOWN_SUBSCRIPTION_PRODUCT_SLUG; - //if let Some(ref internal_product) = maybe_internal_subscription_product { - // subscription_namespace = &internal_product.subscription_category; - // subscription_product_slug = &internal_product.subscription_product_key; - //} - let maybe_product = get_artcraft_product_by_stripe_id_and_env( &summary.stripe_product_id, server_environment); diff --git a/crates/service/plugins/billing_artcraft/src/endpoints/webhook/webhook_event_handlers/customer_subscription/mod.rs b/crates/service/plugins/billing_artcraft/src/endpoints/webhook/webhook_event_handlers/customer_subscription/mod.rs index 5bee8b26e9..6c146c2c42 100644 --- a/crates/service/plugins/billing_artcraft/src/endpoints/webhook/webhook_event_handlers/customer_subscription/mod.rs +++ b/crates/service/plugins/billing_artcraft/src/endpoints/webhook/webhook_event_handlers/customer_subscription/mod.rs @@ -1,5 +1,4 @@ pub mod calculate_subscription_end_date; -pub mod common; pub mod customer_subscription_created_handler; pub mod customer_subscription_deleted_handler; pub mod customer_subscription_updated_handler;