From 0d9a882f3f15d7d08cea823063041bb848c8bc73 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Thu, 27 Oct 2022 04:36:43 -0400 Subject: [PATCH] Refactor stripe component modules --- .../billing/src/default_routes.rs | 6 ++-- .../http_endpoints/checkout/create/mod.rs | 4 +++ .../stripe_create_checkout_session_error.rs | 0 ...pe_create_checkout_session_json_handler.rs | 4 +-- ...reate_checkout_session_redirect_handler.rs | 4 +-- .../stripe_create_checkout_session_shared.rs | 2 +- .../src/stripe/http_endpoints/checkout/mod.rs | 7 ++--- .../billing/src/stripe/http_endpoints/mod.rs | 2 +- .../src/stripe/http_endpoints/webhook/mod.rs | 2 ++ .../{ => webhook}/stripe_webhook_handler.rs | 30 +++++++++---------- .../charge/charge_succeeded_handler.rs | 4 +-- .../webhook_event_handlers/charge/mod.rs | 1 + .../checkout_session_completed_handler.rs | 10 +++---- .../checkout_session/mod.rs | 1 + .../customer/customer_created_handler.rs | 4 +-- .../customer/customer_deleted_handler.rs | 4 +-- .../customer/customer_updated_handler.rs | 4 +-- .../webhook_event_handlers/customer/mod.rs | 3 ++ .../calculate_subscription_end_date.rs | 2 +- .../customer_subscription/common.rs | 0 .../customer_subscription_created_handler.rs | 10 +++---- .../customer_subscription_deleted_handler.rs | 10 +++---- .../customer_subscription_updated_handler.rs | 10 +++---- .../customer_subscription/mod.rs | 0 .../subscription_event_extractor.rs | 2 +- .../invoice/invoice_paid_handler.rs | 4 +-- .../invoice/invoice_payment_failed.rs | 4 +-- .../invoice_payment_succeeded_handler.rs | 4 +-- .../invoice/invoice_updated_handler.rs | 4 +-- .../webhook_event_handlers/invoice/mod.rs | 4 +++ .../webhook/webhook_event_handlers/mod.rs | 9 ++++++ .../payment_intent/mod.rs | 1 + .../payment_intent_succeeded_handler.rs | 4 +-- .../stripe_webhook_error.rs | 0 .../stripe_webhook_summary.rs | 0 .../billing/src/stripe/mod.rs | 1 - .../webhook_event_handlers/charge/mod.rs | 1 - .../checkout_session/mod.rs | 1 - .../webhook_event_handlers/customer/mod.rs | 3 -- .../webhook_event_handlers/invoice/mod.rs | 4 --- .../src/stripe/webhook_event_handlers/mod.rs | 9 ------ .../payment_intent/mod.rs | 1 - 42 files changed, 91 insertions(+), 89 deletions(-) create mode 100644 crates/component_subsystem/billing/src/stripe/http_endpoints/checkout/create/mod.rs rename crates/component_subsystem/billing/src/stripe/http_endpoints/checkout/{ => create}/stripe_create_checkout_session_error.rs (100%) rename crates/component_subsystem/billing/src/stripe/http_endpoints/checkout/{ => create}/stripe_create_checkout_session_json_handler.rs (90%) rename crates/component_subsystem/billing/src/stripe/http_endpoints/checkout/{ => create}/stripe_create_checkout_session_redirect_handler.rs (87%) rename crates/component_subsystem/billing/src/stripe/http_endpoints/checkout/{ => create}/stripe_create_checkout_session_shared.rs (98%) create mode 100644 crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/mod.rs rename crates/component_subsystem/billing/src/stripe/http_endpoints/{ => webhook}/stripe_webhook_handler.rs (85%) rename crates/component_subsystem/billing/src/stripe/{ => http_endpoints/webhook}/webhook_event_handlers/charge/charge_succeeded_handler.rs (82%) create mode 100644 crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/charge/mod.rs rename crates/component_subsystem/billing/src/stripe/{ => http_endpoints/webhook}/webhook_event_handlers/checkout_session/checkout_session_completed_handler.rs (87%) create mode 100644 crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/checkout_session/mod.rs rename crates/component_subsystem/billing/src/stripe/{ => http_endpoints/webhook}/webhook_event_handlers/customer/customer_created_handler.rs (79%) rename crates/component_subsystem/billing/src/stripe/{ => http_endpoints/webhook}/webhook_event_handlers/customer/customer_deleted_handler.rs (79%) rename crates/component_subsystem/billing/src/stripe/{ => http_endpoints/webhook}/webhook_event_handlers/customer/customer_updated_handler.rs (79%) create mode 100644 crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/customer/mod.rs rename crates/component_subsystem/billing/src/stripe/{ => http_endpoints/webhook}/webhook_event_handlers/customer_subscription/calculate_subscription_end_date.rs (89%) rename crates/component_subsystem/billing/src/stripe/{ => http_endpoints/webhook}/webhook_event_handlers/customer_subscription/common.rs (100%) rename crates/component_subsystem/billing/src/stripe/{ => http_endpoints/webhook}/webhook_event_handlers/customer_subscription/customer_subscription_created_handler.rs (85%) rename crates/component_subsystem/billing/src/stripe/{ => http_endpoints/webhook}/webhook_event_handlers/customer_subscription/customer_subscription_deleted_handler.rs (86%) rename crates/component_subsystem/billing/src/stripe/{ => http_endpoints/webhook}/webhook_event_handlers/customer_subscription/customer_subscription_updated_handler.rs (85%) rename crates/component_subsystem/billing/src/stripe/{ => http_endpoints/webhook}/webhook_event_handlers/customer_subscription/mod.rs (100%) rename crates/component_subsystem/billing/src/stripe/{ => http_endpoints/webhook}/webhook_event_handlers/customer_subscription/subscription_event_extractor.rs (100%) rename crates/component_subsystem/billing/src/stripe/{ => http_endpoints/webhook}/webhook_event_handlers/invoice/invoice_paid_handler.rs (97%) rename crates/component_subsystem/billing/src/stripe/{ => http_endpoints/webhook}/webhook_event_handlers/invoice/invoice_payment_failed.rs (82%) rename crates/component_subsystem/billing/src/stripe/{ => http_endpoints/webhook}/webhook_event_handlers/invoice/invoice_payment_succeeded_handler.rs (82%) rename crates/component_subsystem/billing/src/stripe/{ => http_endpoints/webhook}/webhook_event_handlers/invoice/invoice_updated_handler.rs (85%) create mode 100644 crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/invoice/mod.rs create mode 100644 crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/mod.rs create mode 100644 crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/payment_intent/mod.rs rename crates/component_subsystem/billing/src/stripe/{ => http_endpoints/webhook}/webhook_event_handlers/payment_intent/payment_intent_succeeded_handler.rs (83%) rename crates/component_subsystem/billing/src/stripe/{ => http_endpoints/webhook}/webhook_event_handlers/stripe_webhook_error.rs (100%) rename crates/component_subsystem/billing/src/stripe/{ => http_endpoints/webhook}/webhook_event_handlers/stripe_webhook_summary.rs (100%) delete mode 100644 crates/component_subsystem/billing/src/stripe/webhook_event_handlers/charge/mod.rs delete mode 100644 crates/component_subsystem/billing/src/stripe/webhook_event_handlers/checkout_session/mod.rs delete mode 100644 crates/component_subsystem/billing/src/stripe/webhook_event_handlers/customer/mod.rs delete mode 100644 crates/component_subsystem/billing/src/stripe/webhook_event_handlers/invoice/mod.rs delete mode 100644 crates/component_subsystem/billing/src/stripe/webhook_event_handlers/mod.rs delete mode 100644 crates/component_subsystem/billing/src/stripe/webhook_event_handlers/payment_intent/mod.rs diff --git a/crates/component_subsystem/billing/src/default_routes.rs b/crates/component_subsystem/billing/src/default_routes.rs index 0fd2737dcd..38b5a02c0a 100644 --- a/crates/component_subsystem/billing/src/default_routes.rs +++ b/crates/component_subsystem/billing/src/default_routes.rs @@ -4,10 +4,10 @@ use actix_web::body::MessageBody; use actix_web::dev::{ServiceRequest, ServiceResponse, ServiceFactory}; use actix_web::error::Error; use actix_web::{App, web, HttpResponse}; +use crate::stripe::http_endpoints::checkout::create::stripe_create_checkout_session_json_handler::stripe_create_checkout_session_json_handler; +use crate::stripe::http_endpoints::checkout::create::stripe_create_checkout_session_redirect_handler::stripe_create_checkout_session_redirect_handler; use crate::stripe::http_endpoints::checkout::stripe_checkout_success_handler::stripe_checkout_success_handler; -use crate::stripe::http_endpoints::checkout::stripe_create_checkout_session_json_handler::stripe_create_checkout_session_json_handler; -use crate::stripe::http_endpoints::checkout::stripe_create_checkout_session_redirect_handler::stripe_create_checkout_session_redirect_handler; -use crate::stripe::http_endpoints::stripe_webhook_handler::stripe_webhook_handler; +use crate::stripe::http_endpoints::webhook::stripe_webhook_handler::stripe_webhook_handler; pub fn add_suggested_stripe_billing_routes (app: App) -> App where diff --git a/crates/component_subsystem/billing/src/stripe/http_endpoints/checkout/create/mod.rs b/crates/component_subsystem/billing/src/stripe/http_endpoints/checkout/create/mod.rs new file mode 100644 index 0000000000..393432e834 --- /dev/null +++ b/crates/component_subsystem/billing/src/stripe/http_endpoints/checkout/create/mod.rs @@ -0,0 +1,4 @@ +pub mod stripe_create_checkout_session_error; +pub mod stripe_create_checkout_session_json_handler; +pub mod stripe_create_checkout_session_redirect_handler; +pub mod stripe_create_checkout_session_shared; diff --git a/crates/component_subsystem/billing/src/stripe/http_endpoints/checkout/stripe_create_checkout_session_error.rs b/crates/component_subsystem/billing/src/stripe/http_endpoints/checkout/create/stripe_create_checkout_session_error.rs similarity index 100% rename from crates/component_subsystem/billing/src/stripe/http_endpoints/checkout/stripe_create_checkout_session_error.rs rename to crates/component_subsystem/billing/src/stripe/http_endpoints/checkout/create/stripe_create_checkout_session_error.rs diff --git a/crates/component_subsystem/billing/src/stripe/http_endpoints/checkout/stripe_create_checkout_session_json_handler.rs b/crates/component_subsystem/billing/src/stripe/http_endpoints/checkout/create/stripe_create_checkout_session_json_handler.rs similarity index 90% rename from crates/component_subsystem/billing/src/stripe/http_endpoints/checkout/stripe_create_checkout_session_json_handler.rs rename to crates/component_subsystem/billing/src/stripe/http_endpoints/checkout/create/stripe_create_checkout_session_json_handler.rs index dd4fcffe39..26636c1458 100644 --- a/crates/component_subsystem/billing/src/stripe/http_endpoints/checkout/stripe_create_checkout_session_json_handler.rs +++ b/crates/component_subsystem/billing/src/stripe/http_endpoints/checkout/create/stripe_create_checkout_session_json_handler.rs @@ -4,8 +4,8 @@ use actix_web::http::{header, StatusCode}; use actix_web::web::{Path, Query}; use actix_web::{web, HttpResponse, HttpRequest}; use chrono::{DateTime, Utc}; -use crate::stripe::http_endpoints::checkout::stripe_create_checkout_session_error::CreateCheckoutSessionError; -use crate::stripe::http_endpoints::checkout::stripe_create_checkout_session_shared::stripe_create_checkout_session_shared; +use crate::stripe::http_endpoints::checkout::create::stripe_create_checkout_session_error::CreateCheckoutSessionError; +use crate::stripe::http_endpoints::checkout::create::stripe_create_checkout_session_shared::stripe_create_checkout_session_shared; use crate::stripe::stripe_config::StripeConfig; use crate::stripe::traits::internal_product_to_stripe_lookup::InternalProductToStripeLookup; use crate::stripe::traits::internal_user_lookup::{InternalUserLookup, UserMetadata}; diff --git a/crates/component_subsystem/billing/src/stripe/http_endpoints/checkout/stripe_create_checkout_session_redirect_handler.rs b/crates/component_subsystem/billing/src/stripe/http_endpoints/checkout/create/stripe_create_checkout_session_redirect_handler.rs similarity index 87% rename from crates/component_subsystem/billing/src/stripe/http_endpoints/checkout/stripe_create_checkout_session_redirect_handler.rs rename to crates/component_subsystem/billing/src/stripe/http_endpoints/checkout/create/stripe_create_checkout_session_redirect_handler.rs index 77fac39a3a..4cb8b0c021 100644 --- a/crates/component_subsystem/billing/src/stripe/http_endpoints/checkout/stripe_create_checkout_session_redirect_handler.rs +++ b/crates/component_subsystem/billing/src/stripe/http_endpoints/checkout/create/stripe_create_checkout_session_redirect_handler.rs @@ -4,8 +4,8 @@ use actix_web::http::{header, StatusCode}; use actix_web::web::{Path, Query}; use actix_web::{web, HttpResponse, HttpRequest}; use chrono::{DateTime, Utc}; -use crate::stripe::http_endpoints::checkout::stripe_create_checkout_session_error::CreateCheckoutSessionError; -use crate::stripe::http_endpoints::checkout::stripe_create_checkout_session_shared::stripe_create_checkout_session_shared; +use crate::stripe::http_endpoints::checkout::create::stripe_create_checkout_session_error::CreateCheckoutSessionError; +use crate::stripe::http_endpoints::checkout::create::stripe_create_checkout_session_shared::stripe_create_checkout_session_shared; use crate::stripe::stripe_config::StripeConfig; use crate::stripe::traits::internal_product_to_stripe_lookup::InternalProductToStripeLookup; use crate::stripe::traits::internal_user_lookup::InternalUserLookup; diff --git a/crates/component_subsystem/billing/src/stripe/http_endpoints/checkout/stripe_create_checkout_session_shared.rs b/crates/component_subsystem/billing/src/stripe/http_endpoints/checkout/create/stripe_create_checkout_session_shared.rs similarity index 98% rename from crates/component_subsystem/billing/src/stripe/http_endpoints/checkout/stripe_create_checkout_session_shared.rs rename to crates/component_subsystem/billing/src/stripe/http_endpoints/checkout/create/stripe_create_checkout_session_shared.rs index fa262b3663..00af7901a6 100644 --- a/crates/component_subsystem/billing/src/stripe/http_endpoints/checkout/stripe_create_checkout_session_shared.rs +++ b/crates/component_subsystem/billing/src/stripe/http_endpoints/checkout/create/stripe_create_checkout_session_shared.rs @@ -2,7 +2,7 @@ use actix_web::{HttpRequest, web}; use anyhow::anyhow; use container_common::anyhow_result::AnyhowResult; use crate::stripe::helpers::common_metadata_keys::{METADATA_EMAIL, METADATA_USER_TOKEN, METADATA_USERNAME}; -use crate::stripe::http_endpoints::checkout::stripe_create_checkout_session_error::CreateCheckoutSessionError; +use crate::stripe::http_endpoints::checkout::create::stripe_create_checkout_session_error::CreateCheckoutSessionError; use crate::stripe::stripe_config::StripeConfig; use crate::stripe::traits::internal_product_to_stripe_lookup::{InternalProductToStripeLookup, StripeProduct}; use crate::stripe::traits::internal_user_lookup::{InternalUserLookup, UserMetadata}; diff --git a/crates/component_subsystem/billing/src/stripe/http_endpoints/checkout/mod.rs b/crates/component_subsystem/billing/src/stripe/http_endpoints/checkout/mod.rs index e714cc72d1..cde4a2bf7f 100644 --- a/crates/component_subsystem/billing/src/stripe/http_endpoints/checkout/mod.rs +++ b/crates/component_subsystem/billing/src/stripe/http_endpoints/checkout/mod.rs @@ -1,5 +1,2 @@ -pub mod stripe_checkout_success_handler; -pub mod stripe_create_checkout_session_error; -pub mod stripe_create_checkout_session_json_handler; -pub mod stripe_create_checkout_session_redirect_handler; -pub mod stripe_create_checkout_session_shared; +pub mod create; +pub mod stripe_checkout_success_handler; \ No newline at end of file diff --git a/crates/component_subsystem/billing/src/stripe/http_endpoints/mod.rs b/crates/component_subsystem/billing/src/stripe/http_endpoints/mod.rs index 55c1150986..6259af6223 100644 --- a/crates/component_subsystem/billing/src/stripe/http_endpoints/mod.rs +++ b/crates/component_subsystem/billing/src/stripe/http_endpoints/mod.rs @@ -1,2 +1,2 @@ pub mod checkout; -pub mod stripe_webhook_handler; +pub mod webhook; diff --git a/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/mod.rs b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/mod.rs new file mode 100644 index 0000000000..243fe97d48 --- /dev/null +++ b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/mod.rs @@ -0,0 +1,2 @@ +pub mod stripe_webhook_handler; +pub(crate) mod webhook_event_handlers; diff --git a/crates/component_subsystem/billing/src/stripe/http_endpoints/stripe_webhook_handler.rs b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/stripe_webhook_handler.rs similarity index 85% rename from crates/component_subsystem/billing/src/stripe/http_endpoints/stripe_webhook_handler.rs rename to crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/stripe_webhook_handler.rs index 712858f290..8cbfe82d22 100644 --- a/crates/component_subsystem/billing/src/stripe/http_endpoints/stripe_webhook_handler.rs +++ b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/stripe_webhook_handler.rs @@ -5,23 +5,23 @@ use actix_web::web::{Bytes, Path}; use actix_web::{web, HttpResponse, HttpRequest}; use chrono::{DateTime, NaiveDateTime, Utc}; use crate::stripe::helpers::verify_stripe_webhook_ip_address::verify_stripe_webhook_ip_address; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::charge::charge_succeeded_handler::charge_succeeded_handler; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::checkout_session::checkout_session_completed_handler::checkout_session_completed_handler; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::customer::customer_created_handler::customer_created_handler; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::customer::customer_deleted_handler::customer_deleted_handler; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::customer::customer_updated_handler::customer_updated_handler; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::customer_subscription::customer_subscription_created_handler::customer_subscription_created_handler; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::customer_subscription::customer_subscription_deleted_handler::customer_subscription_deleted_handler; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::customer_subscription::customer_subscription_updated_handler::customer_subscription_updated_handler; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::invoice::invoice_paid_handler::invoice_paid_handler; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::invoice::invoice_payment_failed::invoice_payment_failed_handler; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::invoice::invoice_payment_succeeded_handler::invoice_payment_succeeded_handler; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::invoice::invoice_updated_handler::invoice_updated_handler; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::payment_intent::payment_intent_succeeded_handler::payment_intent_succeeded_handler; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::stripe_webhook_error::StripeWebhookError; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::stripe_webhook_summary::StripeWebhookSummary; use crate::stripe::stripe_config::StripeConfig; use crate::stripe::traits::internal_subscription_product_lookup::InternalSubscriptionProductLookup; -use crate::stripe::webhook_event_handlers::charge::charge_succeeded_handler::charge_succeeded_handler; -use crate::stripe::webhook_event_handlers::checkout_session::checkout_session_completed_handler::checkout_session_completed_handler; -use crate::stripe::webhook_event_handlers::customer::customer_created_handler::customer_created_handler; -use crate::stripe::webhook_event_handlers::customer::customer_deleted_handler::customer_deleted_handler; -use crate::stripe::webhook_event_handlers::customer::customer_updated_handler::customer_updated_handler; -use crate::stripe::webhook_event_handlers::customer_subscription::customer_subscription_created_handler::customer_subscription_created_handler; -use crate::stripe::webhook_event_handlers::customer_subscription::customer_subscription_deleted_handler::customer_subscription_deleted_handler; -use crate::stripe::webhook_event_handlers::customer_subscription::customer_subscription_updated_handler::customer_subscription_updated_handler; -use crate::stripe::webhook_event_handlers::invoice::invoice_paid_handler::invoice_paid_handler; -use crate::stripe::webhook_event_handlers::invoice::invoice_payment_failed::invoice_payment_failed_handler; -use crate::stripe::webhook_event_handlers::invoice::invoice_payment_succeeded_handler::invoice_payment_succeeded_handler; -use crate::stripe::webhook_event_handlers::invoice::invoice_updated_handler::invoice_updated_handler; -use crate::stripe::webhook_event_handlers::payment_intent::payment_intent_succeeded_handler::payment_intent_succeeded_handler; -use crate::stripe::webhook_event_handlers::stripe_webhook_error::StripeWebhookError; -use crate::stripe::webhook_event_handlers::stripe_webhook_summary::StripeWebhookSummary; use database_queries::queries::billing::stripe::get_stripe_webhook_event_log_by_id::get_stripe_webhook_event_log_by_id; use database_queries::queries::billing::stripe::insert_stripe_webhook_event_log::InsertStripeWebhookEventLog; use http_server_common::request::get_request_header_optional::get_request_header_optional; diff --git a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/charge/charge_succeeded_handler.rs b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/charge/charge_succeeded_handler.rs similarity index 82% rename from crates/component_subsystem/billing/src/stripe/webhook_event_handlers/charge/charge_succeeded_handler.rs rename to crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/charge/charge_succeeded_handler.rs index 85a47bd311..2633406049 100644 --- a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/charge/charge_succeeded_handler.rs +++ b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/charge/charge_succeeded_handler.rs @@ -1,8 +1,8 @@ use container_common::anyhow_result::AnyhowResult; use crate::stripe::helpers::common_metadata_keys::METADATA_USER_TOKEN; use crate::stripe::helpers::expand_customer_id::expand_customer_id; -use crate::stripe::webhook_event_handlers::stripe_webhook_error::StripeWebhookError; -use crate::stripe::webhook_event_handlers::stripe_webhook_summary::StripeWebhookSummary; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::stripe_webhook_error::StripeWebhookError; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::stripe_webhook_summary::StripeWebhookSummary; use log::error; use stripe::{Charge, Invoice, PaymentIntent}; diff --git a/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/charge/mod.rs b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/charge/mod.rs new file mode 100644 index 0000000000..688ad14f1c --- /dev/null +++ b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/charge/mod.rs @@ -0,0 +1 @@ +pub(crate) mod charge_succeeded_handler; \ No newline at end of file diff --git a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/checkout_session/checkout_session_completed_handler.rs b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/checkout_session/checkout_session_completed_handler.rs similarity index 87% rename from crates/component_subsystem/billing/src/stripe/webhook_event_handlers/checkout_session/checkout_session_completed_handler.rs rename to crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/checkout_session/checkout_session_completed_handler.rs index ff2598dcf7..244ca4160c 100644 --- a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/checkout_session/checkout_session_completed_handler.rs +++ b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/checkout_session/checkout_session_completed_handler.rs @@ -1,10 +1,10 @@ -use log::{error, warn}; use container_common::anyhow_result::AnyhowResult; -use crate::stripe::helpers::expand_customer_id::expand_customer_id; -use stripe::CheckoutSession; use crate::stripe::helpers::common_metadata_keys::METADATA_USER_TOKEN; -use crate::stripe::webhook_event_handlers::stripe_webhook_error::StripeWebhookError; -use crate::stripe::webhook_event_handlers::stripe_webhook_summary::StripeWebhookSummary; +use crate::stripe::helpers::expand_customer_id::expand_customer_id; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::stripe_webhook_error::StripeWebhookError; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::stripe_webhook_summary::StripeWebhookSummary; +use log::{error, warn}; +use stripe::CheckoutSession; // After the subscription signup succeeds, the customer returns to your website at the success_url, // which initiates a checkout.session.completed webhooks. When you receive a checkout.session.completed diff --git a/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/checkout_session/mod.rs b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/checkout_session/mod.rs new file mode 100644 index 0000000000..524729c738 --- /dev/null +++ b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/checkout_session/mod.rs @@ -0,0 +1 @@ +pub(crate) mod checkout_session_completed_handler; \ No newline at end of file diff --git a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/customer/customer_created_handler.rs b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/customer/customer_created_handler.rs similarity index 79% rename from crates/component_subsystem/billing/src/stripe/webhook_event_handlers/customer/customer_created_handler.rs rename to crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/customer/customer_created_handler.rs index b7c045b1c1..d974b10d3a 100644 --- a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/customer/customer_created_handler.rs +++ b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/customer/customer_created_handler.rs @@ -1,7 +1,7 @@ use container_common::anyhow_result::AnyhowResult; use crate::stripe::helpers::common_metadata_keys::METADATA_USER_TOKEN; -use crate::stripe::webhook_event_handlers::stripe_webhook_error::StripeWebhookError; -use crate::stripe::webhook_event_handlers::stripe_webhook_summary::StripeWebhookSummary; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::stripe_webhook_error::StripeWebhookError; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::stripe_webhook_summary::StripeWebhookSummary; use log::error; use stripe::Customer; diff --git a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/customer/customer_deleted_handler.rs b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/customer/customer_deleted_handler.rs similarity index 79% rename from crates/component_subsystem/billing/src/stripe/webhook_event_handlers/customer/customer_deleted_handler.rs rename to crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/customer/customer_deleted_handler.rs index 374f79783a..a7c2038113 100644 --- a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/customer/customer_deleted_handler.rs +++ b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/customer/customer_deleted_handler.rs @@ -1,7 +1,7 @@ use container_common::anyhow_result::AnyhowResult; use crate::stripe::helpers::common_metadata_keys::METADATA_USER_TOKEN; -use crate::stripe::webhook_event_handlers::stripe_webhook_error::StripeWebhookError; -use crate::stripe::webhook_event_handlers::stripe_webhook_summary::StripeWebhookSummary; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::stripe_webhook_error::StripeWebhookError; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::stripe_webhook_summary::StripeWebhookSummary; use log::warn; use stripe::Customer; diff --git a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/customer/customer_updated_handler.rs b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/customer/customer_updated_handler.rs similarity index 79% rename from crates/component_subsystem/billing/src/stripe/webhook_event_handlers/customer/customer_updated_handler.rs rename to crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/customer/customer_updated_handler.rs index fb5082a20c..d2af9a11ec 100644 --- a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/customer/customer_updated_handler.rs +++ b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/customer/customer_updated_handler.rs @@ -1,7 +1,7 @@ use container_common::anyhow_result::AnyhowResult; use crate::stripe::helpers::common_metadata_keys::METADATA_USER_TOKEN; -use crate::stripe::webhook_event_handlers::stripe_webhook_error::StripeWebhookError; -use crate::stripe::webhook_event_handlers::stripe_webhook_summary::StripeWebhookSummary; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::stripe_webhook_error::StripeWebhookError; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::stripe_webhook_summary::StripeWebhookSummary; use log::warn; use stripe::Customer; diff --git a/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/customer/mod.rs b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/customer/mod.rs new file mode 100644 index 0000000000..f10c065e63 --- /dev/null +++ b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/customer/mod.rs @@ -0,0 +1,3 @@ +pub(crate) mod customer_created_handler; +pub(crate) mod customer_deleted_handler; +pub(crate) mod customer_updated_handler; diff --git a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/customer_subscription/calculate_subscription_end_date.rs b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/customer_subscription/calculate_subscription_end_date.rs similarity index 89% rename from crates/component_subsystem/billing/src/stripe/webhook_event_handlers/customer_subscription/calculate_subscription_end_date.rs rename to crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/customer_subscription/calculate_subscription_end_date.rs index cc6001a112..9ece48adb2 100644 --- a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/customer_subscription/calculate_subscription_end_date.rs +++ b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/customer_subscription/calculate_subscription_end_date.rs @@ -1,5 +1,5 @@ use chrono::{Duration, NaiveDateTime, Utc}; -use crate::stripe::webhook_event_handlers::customer_subscription::subscription_event_extractor::SubscriptionSummary; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::customer_subscription::subscription_event_extractor::SubscriptionSummary; use once_cell::sync::Lazy; use reusable_types::stripe::stripe_subscription_status::StripeSubscriptionStatus; use std::ops::{Add, Sub}; diff --git a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/customer_subscription/common.rs b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/customer_subscription/common.rs similarity index 100% rename from crates/component_subsystem/billing/src/stripe/webhook_event_handlers/customer_subscription/common.rs rename to crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/customer_subscription/common.rs diff --git a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/customer_subscription/customer_subscription_created_handler.rs b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/customer_subscription/customer_subscription_created_handler.rs similarity index 85% rename from crates/component_subsystem/billing/src/stripe/webhook_event_handlers/customer_subscription/customer_subscription_created_handler.rs rename to crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/customer_subscription/customer_subscription_created_handler.rs index 982e301a20..e8a991edc6 100644 --- a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/customer_subscription/customer_subscription_created_handler.rs +++ b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/customer_subscription/customer_subscription_created_handler.rs @@ -1,9 +1,9 @@ +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::customer_subscription::calculate_subscription_end_date::calculate_subscription_end_date; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::customer_subscription::common::{UNKNOWN_SUBSCRIPTION_CATEGORY, UNKNOWN_SUBSCRIPTION_PRODUCT_KEY}; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::customer_subscription::subscription_event_extractor::subscription_summary_extractor; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::stripe_webhook_error::StripeWebhookError; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::stripe_webhook_summary::StripeWebhookSummary; use crate::stripe::traits::internal_subscription_product_lookup::InternalSubscriptionProductLookup; -use crate::stripe::webhook_event_handlers::customer_subscription::calculate_subscription_end_date::calculate_subscription_end_date; -use crate::stripe::webhook_event_handlers::customer_subscription::common::{UNKNOWN_SUBSCRIPTION_CATEGORY, UNKNOWN_SUBSCRIPTION_PRODUCT_KEY}; -use crate::stripe::webhook_event_handlers::customer_subscription::subscription_event_extractor::subscription_summary_extractor; -use crate::stripe::webhook_event_handlers::stripe_webhook_error::StripeWebhookError; -use crate::stripe::webhook_event_handlers::stripe_webhook_summary::StripeWebhookSummary; use database_queries::queries::billing::subscriptions::get_subscription_by_stripe_id::get_subscription_by_stripe_id; use database_queries::queries::billing::subscriptions::upsert_subscription_by_stripe_id::UpsertSubscriptionByStripeId; use log::{error, warn}; diff --git a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/customer_subscription/customer_subscription_deleted_handler.rs b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/customer_subscription/customer_subscription_deleted_handler.rs similarity index 86% rename from crates/component_subsystem/billing/src/stripe/webhook_event_handlers/customer_subscription/customer_subscription_deleted_handler.rs rename to crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/customer_subscription/customer_subscription_deleted_handler.rs index dc9f0c585e..e4f364988a 100644 --- a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/customer_subscription/customer_subscription_deleted_handler.rs +++ b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/customer_subscription/customer_subscription_deleted_handler.rs @@ -1,9 +1,9 @@ +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::customer_subscription::calculate_subscription_end_date::calculate_subscription_end_date; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::customer_subscription::common::{UNKNOWN_SUBSCRIPTION_CATEGORY, UNKNOWN_SUBSCRIPTION_PRODUCT_KEY}; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::customer_subscription::subscription_event_extractor::subscription_summary_extractor; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::stripe_webhook_error::StripeWebhookError; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::stripe_webhook_summary::StripeWebhookSummary; use crate::stripe::traits::internal_subscription_product_lookup::InternalSubscriptionProductLookup; -use crate::stripe::webhook_event_handlers::customer_subscription::calculate_subscription_end_date::calculate_subscription_end_date; -use crate::stripe::webhook_event_handlers::customer_subscription::common::{UNKNOWN_SUBSCRIPTION_CATEGORY, UNKNOWN_SUBSCRIPTION_PRODUCT_KEY}; -use crate::stripe::webhook_event_handlers::customer_subscription::subscription_event_extractor::subscription_summary_extractor; -use crate::stripe::webhook_event_handlers::stripe_webhook_error::StripeWebhookError; -use crate::stripe::webhook_event_handlers::stripe_webhook_summary::StripeWebhookSummary; use database_queries::queries::billing::subscriptions::get_subscription_by_stripe_id::get_subscription_by_stripe_id; use database_queries::queries::billing::subscriptions::upsert_subscription_by_stripe_id::UpsertSubscriptionByStripeId; use log::{error, warn}; diff --git a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/customer_subscription/customer_subscription_updated_handler.rs b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/customer_subscription/customer_subscription_updated_handler.rs similarity index 85% rename from crates/component_subsystem/billing/src/stripe/webhook_event_handlers/customer_subscription/customer_subscription_updated_handler.rs rename to crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/customer_subscription/customer_subscription_updated_handler.rs index 9fdc4a42cf..77b0e69c6f 100644 --- a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/customer_subscription/customer_subscription_updated_handler.rs +++ b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/customer_subscription/customer_subscription_updated_handler.rs @@ -1,9 +1,9 @@ +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::customer_subscription::calculate_subscription_end_date::calculate_subscription_end_date; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::customer_subscription::common::{UNKNOWN_SUBSCRIPTION_CATEGORY, UNKNOWN_SUBSCRIPTION_PRODUCT_KEY}; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::customer_subscription::subscription_event_extractor::subscription_summary_extractor; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::stripe_webhook_error::StripeWebhookError; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::stripe_webhook_summary::StripeWebhookSummary; use crate::stripe::traits::internal_subscription_product_lookup::InternalSubscriptionProductLookup; -use crate::stripe::webhook_event_handlers::customer_subscription::calculate_subscription_end_date::calculate_subscription_end_date; -use crate::stripe::webhook_event_handlers::customer_subscription::common::{UNKNOWN_SUBSCRIPTION_CATEGORY, UNKNOWN_SUBSCRIPTION_PRODUCT_KEY}; -use crate::stripe::webhook_event_handlers::customer_subscription::subscription_event_extractor::subscription_summary_extractor; -use crate::stripe::webhook_event_handlers::stripe_webhook_error::StripeWebhookError; -use crate::stripe::webhook_event_handlers::stripe_webhook_summary::StripeWebhookSummary; use database_queries::queries::billing::subscriptions::get_subscription_by_stripe_id::get_subscription_by_stripe_id; use database_queries::queries::billing::subscriptions::upsert_subscription_by_stripe_id::UpsertSubscriptionByStripeId; use log::{error, warn}; diff --git a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/customer_subscription/mod.rs b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/customer_subscription/mod.rs similarity index 100% rename from crates/component_subsystem/billing/src/stripe/webhook_event_handlers/customer_subscription/mod.rs rename to crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/customer_subscription/mod.rs diff --git a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/customer_subscription/subscription_event_extractor.rs b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/customer_subscription/subscription_event_extractor.rs similarity index 100% rename from crates/component_subsystem/billing/src/stripe/webhook_event_handlers/customer_subscription/subscription_event_extractor.rs rename to crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/customer_subscription/subscription_event_extractor.rs index 55159a17b2..b7a545de8a 100644 --- a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/customer_subscription/subscription_event_extractor.rs +++ b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/customer_subscription/subscription_event_extractor.rs @@ -2,13 +2,13 @@ use anyhow::anyhow; use chrono::{DateTime, NaiveDateTime, Utc}; use container_common::anyhow_result::AnyhowResult; use crate::stripe::helpers::common_metadata_keys::METADATA_USER_TOKEN; +use crate::stripe::helpers::enums::recurring_interval_to_reusable_type::recurring_interval_to_reusable_type; use crate::stripe::helpers::enums::subscription_status_to_reusable_type::subscription_status_to_reusable_type; use crate::stripe::helpers::expand_customer_id::expand_customer_id; use crate::stripe::helpers::expand_product_id::expand_product_id; use reusable_types::stripe::stripe_recurring_interval::StripeRecurringInterval; use reusable_types::stripe::stripe_subscription_status::StripeSubscriptionStatus; use stripe::{Price, RecurringInterval, Subscription, SubscriptionInterval, SubscriptionStatus}; -use crate::stripe::helpers::enums::recurring_interval_to_reusable_type::recurring_interval_to_reusable_type; #[derive(Clone, Debug)] pub struct SubscriptionSummary { diff --git a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/invoice/invoice_paid_handler.rs b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/invoice/invoice_paid_handler.rs similarity index 97% rename from crates/component_subsystem/billing/src/stripe/webhook_event_handlers/invoice/invoice_paid_handler.rs rename to crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/invoice/invoice_paid_handler.rs index a24037ddf6..75094314cc 100644 --- a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/invoice/invoice_paid_handler.rs +++ b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/invoice/invoice_paid_handler.rs @@ -4,10 +4,10 @@ use crate::stripe::helpers::common_metadata_keys::METADATA_USER_TOKEN; use crate::stripe::helpers::expand_customer_id::expand_customer_id; use crate::stripe::helpers::expand_product_id::expand_product_id; use crate::stripe::helpers::expand_subscription_id::expand_subscription_id; -use crate::stripe::webhook_event_handlers::stripe_webhook_error::StripeWebhookError; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::stripe_webhook_error::StripeWebhookError; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::stripe_webhook_summary::StripeWebhookSummary; use log::error; use stripe::{Invoice, InvoiceLineItemType, InvoiceStatus, SubscriptionInterval}; -use crate::stripe::webhook_event_handlers::stripe_webhook_summary::StripeWebhookSummary; /// If we determine a subscription needs update, this is the struct we produce. /// This should be easily unit testable. diff --git a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/invoice/invoice_payment_failed.rs b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/invoice/invoice_payment_failed.rs similarity index 82% rename from crates/component_subsystem/billing/src/stripe/webhook_event_handlers/invoice/invoice_payment_failed.rs rename to crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/invoice/invoice_payment_failed.rs index 203ce31e0d..6bb1daa5c0 100644 --- a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/invoice/invoice_payment_failed.rs +++ b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/invoice/invoice_payment_failed.rs @@ -1,8 +1,8 @@ use container_common::anyhow_result::AnyhowResult; use crate::stripe::helpers::common_metadata_keys::METADATA_USER_TOKEN; use crate::stripe::helpers::expand_customer_id::expand_customer_id; -use crate::stripe::webhook_event_handlers::stripe_webhook_error::StripeWebhookError; -use crate::stripe::webhook_event_handlers::stripe_webhook_summary::StripeWebhookSummary; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::stripe_webhook_error::StripeWebhookError; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::stripe_webhook_summary::StripeWebhookSummary; use log::warn; use stripe::Invoice; diff --git a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/invoice/invoice_payment_succeeded_handler.rs b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/invoice/invoice_payment_succeeded_handler.rs similarity index 82% rename from crates/component_subsystem/billing/src/stripe/webhook_event_handlers/invoice/invoice_payment_succeeded_handler.rs rename to crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/invoice/invoice_payment_succeeded_handler.rs index de5add6f31..1266d7edc2 100644 --- a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/invoice/invoice_payment_succeeded_handler.rs +++ b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/invoice/invoice_payment_succeeded_handler.rs @@ -1,8 +1,8 @@ use container_common::anyhow_result::AnyhowResult; use crate::stripe::helpers::common_metadata_keys::METADATA_USER_TOKEN; use crate::stripe::helpers::expand_customer_id::expand_customer_id; -use crate::stripe::webhook_event_handlers::stripe_webhook_error::StripeWebhookError; -use crate::stripe::webhook_event_handlers::stripe_webhook_summary::StripeWebhookSummary; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::stripe_webhook_error::StripeWebhookError; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::stripe_webhook_summary::StripeWebhookSummary; use log::warn; use stripe::Invoice; diff --git a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/invoice/invoice_updated_handler.rs b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/invoice/invoice_updated_handler.rs similarity index 85% rename from crates/component_subsystem/billing/src/stripe/webhook_event_handlers/invoice/invoice_updated_handler.rs rename to crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/invoice/invoice_updated_handler.rs index 17539ae33e..cbba7bfab0 100644 --- a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/invoice/invoice_updated_handler.rs +++ b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/invoice/invoice_updated_handler.rs @@ -1,10 +1,10 @@ use container_common::anyhow_result::AnyhowResult; use crate::stripe::helpers::common_metadata_keys::METADATA_USER_TOKEN; use crate::stripe::helpers::expand_customer_id::expand_customer_id; -use crate::stripe::webhook_event_handlers::stripe_webhook_error::StripeWebhookError; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::stripe_webhook_error::StripeWebhookError; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::stripe_webhook_summary::StripeWebhookSummary; use log::warn; use stripe::Invoice; -use crate::stripe::webhook_event_handlers::stripe_webhook_summary::StripeWebhookSummary; // Handle event type: 'invoice.updated' // Sent when a payment succeeds or fails. diff --git a/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/invoice/mod.rs b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/invoice/mod.rs new file mode 100644 index 0000000000..7da8481afc --- /dev/null +++ b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/invoice/mod.rs @@ -0,0 +1,4 @@ +pub(crate) mod invoice_paid_handler; +pub(crate) mod invoice_payment_failed; +pub(crate) mod invoice_payment_succeeded_handler; +pub(crate) mod invoice_updated_handler; diff --git a/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/mod.rs b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/mod.rs new file mode 100644 index 0000000000..6d4cee33c3 --- /dev/null +++ b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/mod.rs @@ -0,0 +1,9 @@ +pub mod stripe_webhook_error; + +pub(crate) mod charge; +pub(crate) mod checkout_session; +pub(crate) mod customer; +pub(crate) mod customer_subscription; +pub(crate) mod invoice; +pub(crate) mod payment_intent; +pub(crate) mod stripe_webhook_summary; diff --git a/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/payment_intent/mod.rs b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/payment_intent/mod.rs new file mode 100644 index 0000000000..273aa88b9d --- /dev/null +++ b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/payment_intent/mod.rs @@ -0,0 +1 @@ +pub(crate) mod payment_intent_succeeded_handler; \ No newline at end of file diff --git a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/payment_intent/payment_intent_succeeded_handler.rs b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/payment_intent/payment_intent_succeeded_handler.rs similarity index 83% rename from crates/component_subsystem/billing/src/stripe/webhook_event_handlers/payment_intent/payment_intent_succeeded_handler.rs rename to crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/payment_intent/payment_intent_succeeded_handler.rs index fae0cf7463..fb4a67ff22 100644 --- a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/payment_intent/payment_intent_succeeded_handler.rs +++ b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/payment_intent/payment_intent_succeeded_handler.rs @@ -1,8 +1,8 @@ use container_common::anyhow_result::AnyhowResult; use crate::stripe::helpers::common_metadata_keys::METADATA_USER_TOKEN; use crate::stripe::helpers::expand_customer_id::expand_customer_id; -use crate::stripe::webhook_event_handlers::stripe_webhook_error::StripeWebhookError; -use crate::stripe::webhook_event_handlers::stripe_webhook_summary::StripeWebhookSummary; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::stripe_webhook_error::StripeWebhookError; +use crate::stripe::http_endpoints::webhook::webhook_event_handlers::stripe_webhook_summary::StripeWebhookSummary; use log::warn; use stripe::{Invoice, PaymentIntent}; diff --git a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/stripe_webhook_error.rs b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/stripe_webhook_error.rs similarity index 100% rename from crates/component_subsystem/billing/src/stripe/webhook_event_handlers/stripe_webhook_error.rs rename to crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/stripe_webhook_error.rs diff --git a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/stripe_webhook_summary.rs b/crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/stripe_webhook_summary.rs similarity index 100% rename from crates/component_subsystem/billing/src/stripe/webhook_event_handlers/stripe_webhook_summary.rs rename to crates/component_subsystem/billing/src/stripe/http_endpoints/webhook/webhook_event_handlers/stripe_webhook_summary.rs diff --git a/crates/component_subsystem/billing/src/stripe/mod.rs b/crates/component_subsystem/billing/src/stripe/mod.rs index 57416ca294..2dcf5e33b8 100644 --- a/crates/component_subsystem/billing/src/stripe/mod.rs +++ b/crates/component_subsystem/billing/src/stripe/mod.rs @@ -3,4 +3,3 @@ pub mod http_endpoints; pub mod stripe_config; pub mod traits; -pub (crate) mod webhook_event_handlers; diff --git a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/charge/mod.rs b/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/charge/mod.rs deleted file mode 100644 index 890b59f3c8..0000000000 --- a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/charge/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub (crate) mod charge_succeeded_handler; \ No newline at end of file diff --git a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/checkout_session/mod.rs b/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/checkout_session/mod.rs deleted file mode 100644 index cd65a66a86..0000000000 --- a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/checkout_session/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub (crate) mod checkout_session_completed_handler; \ No newline at end of file diff --git a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/customer/mod.rs b/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/customer/mod.rs deleted file mode 100644 index a052e3fd17..0000000000 --- a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/customer/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub (crate) mod customer_created_handler; -pub (crate) mod customer_deleted_handler; -pub (crate) mod customer_updated_handler; diff --git a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/invoice/mod.rs b/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/invoice/mod.rs deleted file mode 100644 index 45e6b69660..0000000000 --- a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/invoice/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub (crate) mod invoice_paid_handler; -pub (crate) mod invoice_payment_failed; -pub (crate) mod invoice_payment_succeeded_handler; -pub (crate) mod invoice_updated_handler; diff --git a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/mod.rs b/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/mod.rs deleted file mode 100644 index 6575643431..0000000000 --- a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/mod.rs +++ /dev/null @@ -1,9 +0,0 @@ -pub mod stripe_webhook_error; - -pub (crate) mod charge; -pub (crate) mod checkout_session; -pub (crate) mod customer; -pub (crate) mod customer_subscription; -pub (crate) mod invoice; -pub (crate) mod payment_intent; -pub (crate) mod stripe_webhook_summary; diff --git a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/payment_intent/mod.rs b/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/payment_intent/mod.rs deleted file mode 100644 index b99953f9c5..0000000000 --- a/crates/component_subsystem/billing/src/stripe/webhook_event_handlers/payment_intent/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub (crate) mod payment_intent_succeeded_handler; \ No newline at end of file