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:
parent
2551bde1d3
commit
d108e5f53c
1 changed files with 13 additions and 4 deletions
|
@ -3,7 +3,7 @@ use std::sync::Arc;
|
||||||
|
|
||||||
use anyhow::{Context as _, Result, anyhow};
|
use anyhow::{Context as _, Result, anyhow};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use serde::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
use stripe::{
|
use stripe::{
|
||||||
CancellationDetails, CancellationDetailsReason, CheckoutSession, CheckoutSessionMode,
|
CancellationDetails, CancellationDetailsReason, CheckoutSession, CheckoutSessionMode,
|
||||||
CheckoutSessionPaymentMethodCollection, CreateCheckoutSession, CreateCheckoutSessionLineItems,
|
CheckoutSessionPaymentMethodCollection, CreateCheckoutSession, CreateCheckoutSessionLineItems,
|
||||||
|
@ -213,9 +213,18 @@ impl StripeClient for RealStripeClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn create_meter_event(&self, params: StripeCreateMeterEventParams<'_>) -> Result<()> {
|
async fn create_meter_event(&self, params: StripeCreateMeterEventParams<'_>) -> Result<()> {
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
struct StripeMeterEvent {
|
||||||
|
pub identifier: String,
|
||||||
|
}
|
||||||
|
|
||||||
let identifier = params.identifier;
|
let identifier = params.identifier;
|
||||||
match self.client.post_form("/billing/meter_events", params).await {
|
match self
|
||||||
Ok(event) => Ok(event),
|
.client
|
||||||
|
.post_form::<StripeMeterEvent, _>("/billing/meter_events", params)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(_event) => Ok(()),
|
||||||
Err(stripe::StripeError::Stripe(error)) => {
|
Err(stripe::StripeError::Stripe(error)) => {
|
||||||
if error.http_status == 400
|
if error.http_status == 400
|
||||||
&& error
|
&& error
|
||||||
|
@ -228,7 +237,7 @@ impl StripeClient for RealStripeClient {
|
||||||
Err(anyhow!(stripe::StripeError::Stripe(error)))
|
Err(anyhow!(stripe::StripeError::Stripe(error)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(error) => Err(anyhow!(error)),
|
Err(error) => Err(anyhow!("failed to create meter event: {error:?}")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue