refactor(connector): [Stripe] add stripe-api-version in API-headers (#4109)

This commit is contained in:
Swangi Kumari
2024-03-15 17:59:02 +05:30
committed by GitHub
parent fc81f90f61
commit ed6fdad737
2 changed files with 16 additions and 4 deletions

View File

@ -7,6 +7,7 @@ use diesel_models::enums;
use error_stack::{IntoReport, ResultExt}; use error_stack::{IntoReport, ResultExt};
use masking::PeekInterface; use masking::PeekInterface;
use router_env::{instrument, tracing}; use router_env::{instrument, tracing};
use stripe::auth_headers;
use self::transformers as stripe; use self::transformers as stripe;
use super::utils::{self as connector_utils, RefundsRequestData}; use super::utils::{self as connector_utils, RefundsRequestData};
@ -55,10 +56,16 @@ impl ConnectorCommon for Stripe {
let auth: stripe::StripeAuthType = auth_type let auth: stripe::StripeAuthType = auth_type
.try_into() .try_into()
.change_context(errors::ConnectorError::FailedToObtainAuthType)?; .change_context(errors::ConnectorError::FailedToObtainAuthType)?;
Ok(vec![( Ok(vec![
(
headers::AUTHORIZATION.to_string(), headers::AUTHORIZATION.to_string(),
format!("Bearer {}", auth.api_key.peek()).into_masked(), format!("Bearer {}", auth.api_key.peek()).into_masked(),
)]) ),
(
auth_headers::STRIPE_API_VERSION.to_string(),
auth_headers::STRIPE_VERSION.to_string().into_masked(),
),
])
} }
} }

View File

@ -32,6 +32,11 @@ use crate::{
utils::OptionExt, utils::OptionExt,
}; };
pub mod auth_headers {
pub const STRIPE_API_VERSION: &str = "stripe-version";
pub const STRIPE_VERSION: &str = "2023-10-16";
}
pub struct StripeAuthType { pub struct StripeAuthType {
pub(super) api_key: Secret<String>, pub(super) api_key: Secret<String>,
} }