Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

fix(stripe): partial capture issue when fully captured on redirection flow like card3ds , eps bank redirect (#8956)

Nithin N2309c5311cb9
diff --git a/crates/hyperswitch_connectors/src/connectors/stripe/transformers.rs b/crates/hyperswitch_connectors/src/connectors/stripe/transformers.rs
index 71448ef817..9a25bced2f 100644
--- a/crates/hyperswitch_connectors/src/connectors/stripe/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/stripe/transformers.rs
@@ -46,8 +46,12 @@ use url::Url;
use crate::{
constants::headers::STRIPE_COMPATIBLE_CONNECT_ACCOUNT,
- utils::{convert_uppercase, ApplePay, RouterData as OtherRouterData},
+ utils::{
+ convert_uppercase, deserialize_zero_minor_amount_as_none, ApplePay,
+ RouterData as OtherRouterData,
+ },
};
+
#[cfg(feature = "payouts")]
pub mod connect;
#[cfg(feature = "payouts")]
@@ -2397,6 +2401,8 @@ pub struct PaymentIntentResponse {
pub id: String,
pub object: String,
pub amount: MinorUnit,
+ #[serde(default, deserialize_with = "deserialize_zero_minor_amount_as_none")]
+ // stripe gives amount_captured as 0 for payment intents instead of 0
pub amount_received: Option<MinorUnit>,
pub amount_capturable: Option<MinorUnit>,
pub currency: String,
@@ -2813,10 +2819,12 @@ where
Ok(Self {
status,
- // client_secret: Some(item.response.client_secret.clone().as_str()),
- // description: item.response.description.map(|x| x.as_str()),
- // statement_descriptor_suffix: item.response.statement_descriptor_suffix.map(|x| x.as_str()),
- // three_ds_form,
+ /* Commented out fields:
+ client_secret: Some(item.response.client_secret.clone().as_str()),
+ description: item.response.description.map(|x| x.as_str()),
+ statement_descriptor_suffix: item.response.statement_descriptor_suffix.map(|x| x.as_str()),
+ three_ds_form,
+ */
response,
amount_captured: item
.response
diff --git a/crates/hyperswitch_connectors/src/utils.rs b/crates/hyperswitch_connectors/src/utils.rs
index d082114a57..af00270bb6 100644
--- a/crates/hyperswitch_connectors/src/utils.rs
+++ b/crates/hyperswitch_connectors/src/utils.rs
@@ -6662,3 +6662,16 @@ impl XmlSerializer {
Ok(xml_bytes)
}
}
+
+pub fn deserialize_zero_minor_amount_as_none<'de, D>(
+ deserializer: D,
+) -> Result<Option<MinorUnit>, D::Error>
+where
+ D: serde::de::Deserializer<'de>,
+{
+ let amount = Option::<MinorUnit>::deserialize(deserializer)?;
+ match amount {
+ Some(value) if value.get_amount_as_i64() == 0 => Ok(None),
+ _ => Ok(amount),
+ }
+}