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 94be00159c..b6be10813b 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 @@ -175,12 +175,15 @@ async fn process_enriched_event( ) -> Result<(), StripeArtcraftWebhookError> { if let Some(billing_action) = &artcraft_event.maybe_billing_action { + info!("Billing action being taken for event type: {}", &stripe_event_type); // This is where we fulfill the purchase, subscription, non-payment, etc.! // TODO: Maybe grab the primary key of the impacted entity? transactionally_fulfill_artcraft_billing_action( billing_action, transaction, ).await?; + } else { + info!("No billing action to take for event type: {}", &stripe_event_type); } // NB: These records are uniquely keyed by ID, so this only happens once. diff --git a/crates/service/plugins/billing_artcraft/src/endpoints/webhook/webhook_event_enrichment/payment_intent/payment_intent_succeeded_extractor.rs b/crates/service/plugins/billing_artcraft/src/endpoints/webhook/webhook_event_enrichment/payment_intent/payment_intent_succeeded_extractor.rs index 64c7f484f4..4a3f5c3e18 100644 --- a/crates/service/plugins/billing_artcraft/src/endpoints/webhook/webhook_event_enrichment/payment_intent/payment_intent_succeeded_extractor.rs +++ b/crates/service/plugins/billing_artcraft/src/endpoints/webhook/webhook_event_enrichment/payment_intent/payment_intent_succeeded_extractor.rs @@ -82,7 +82,7 @@ pub async fn payment_intent_succeeded_extractor( StripeArtcraftWebhookError::ServerError("error looking up purchase".to_string()) })?; - if !purchase.has_invoice { + if purchase.has_invoice { // Subscription purchase. Let `invoice.paid` event handle this instead. info!("payment_intent.success - has an invoice (eg. subscription) - letting another webhook handler take this."); @@ -95,10 +95,7 @@ pub async fn payment_intent_succeeded_extractor( } let credits_pack = match get_artcraft_product_by_stripe_id_and_env(&purchase.product_id, server_environment) { - None => { - error!("Could not find product for ID: {}", &purchase.product_id); - return Err(StripeArtcraftWebhookError::ServerError("unknown product".to_string())); - } + Some(StripeArtcraftGenericProductInfo::CreditsPack(credits_pack)) => credits_pack, Some(StripeArtcraftGenericProductInfo::Subscription(_subscription)) => { info!("Do not handle subscriptions as one-off payments: {}", purchase.product_id); event_log_summary.should_ignore_retry = true; @@ -108,9 +105,14 @@ pub async fn payment_intent_succeeded_extractor( webhook_event_log_summary: event_log_summary, }); } - Some(StripeArtcraftGenericProductInfo::CreditsPack(credits_pack)) => credits_pack, + None => { + error!("Could not find product for ID: {}", &purchase.product_id); + return Err(StripeArtcraftWebhookError::ServerError("unknown product".to_string())); + } }; + info!("Payment intent is a wallet credits purchase."); + Ok(EnrichedWebhookEvent { maybe_billing_action: Some(ArtcraftBillingAction::WalletCreditsPurchase(WalletCreditsPurchaseEvent { owner_user_token: user_token,