This commit is contained in:
Brandon Thomas committed 2025-09-12 01:00:03 -04:00
1 parent b12c81dc37
commit 72228345d0
6 files changed
+2 -40

No files matched your search

@@ -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?;
}
@@ -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";
@@ -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<StripeArtcraftWebhookSummary, StripeArtcraftWebhookError> {
@@ -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);
@@ -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<StripeArtcraftWebhookSummary, StripeArtcraftWebhookError> {
@@ -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);
@@ -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;