From d108e5f53c465651062c5956e89c8222eddb3361 Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Tue, 3 Jun 2025 11:23:38 -0400 Subject: [PATCH] collab: Fix deserialization of create meter event response (#31982) This PR fixes the deserialization of the create meter event response from the Stripe API. Release Notes: - N/A --- .../src/stripe_client/real_stripe_client.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/crates/collab/src/stripe_client/real_stripe_client.rs b/crates/collab/src/stripe_client/real_stripe_client.rs index a7fc77e7a0..db9c6d9eca 100644 --- a/crates/collab/src/stripe_client/real_stripe_client.rs +++ b/crates/collab/src/stripe_client/real_stripe_client.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use anyhow::{Context as _, Result, anyhow}; use async_trait::async_trait; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use stripe::{ CancellationDetails, CancellationDetailsReason, CheckoutSession, CheckoutSessionMode, CheckoutSessionPaymentMethodCollection, CreateCheckoutSession, CreateCheckoutSessionLineItems, @@ -213,9 +213,18 @@ impl StripeClient for RealStripeClient { } async fn create_meter_event(&self, params: StripeCreateMeterEventParams<'_>) -> Result<()> { + #[derive(Deserialize)] + struct StripeMeterEvent { + pub identifier: String, + } + let identifier = params.identifier; - match self.client.post_form("/billing/meter_events", params).await { - Ok(event) => Ok(event), + match self + .client + .post_form::("/billing/meter_events", params) + .await + { + Ok(_event) => Ok(()), Err(stripe::StripeError::Stripe(error)) => { if error.http_status == 400 && error @@ -228,7 +237,7 @@ impl StripeClient for RealStripeClient { Err(anyhow!(stripe::StripeError::Stripe(error))) } } - Err(error) => Err(anyhow!(error)), + Err(error) => Err(anyhow!("failed to create meter event: {error:?}")), } }