mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-05 09:48:44 +00:00
fix logic bug
This commit is contained in:
1 parent
06023ae11e
commit
e413cc94ad
2 files changed
+11
-6
No files matched your search
+3
@@ -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.
|
||||
|
||||
+8
-6
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user