fix logic bug

This commit is contained in:
Brandon Thomas committed 2025-09-12 01:00:04 -04:00
1 parent 06023ae11e
commit e413cc94ad
2 files changed
+11 -6

No files matched your search

@@ -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.
@@ -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,