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
This commit is contained in:
Marshall Bowers 2025-06-03 11:23:38 -04:00 committed by GitHub
parent 2551bde1d3
commit d108e5f53c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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::<StripeMeterEvent, _>("/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:?}")),
}
}