Skip to content

Commit

Permalink
fix(connector): use enum to deserializa latest_charge in stripe
Browse files Browse the repository at this point in the history
  • Loading branch information
hrithikesh026 committed Oct 4, 2023
1 parent d177b4d commit 1dd1bbf
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions crates/router/src/connector/stripe/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2125,7 +2125,13 @@ pub struct PaymentIntentSyncResponse {
#[serde(flatten)]
payment_intent_fields: PaymentIntentResponse,
pub last_payment_error: Option<LastPaymentError>,
pub latest_charge: Option<StripeCharge>,
pub latest_charge: Option<StripeChargeEnum>,
}

#[derive(Deserialize, Debug, Clone)]
pub enum StripeChargeEnum {
ChargeId(String),
ChargeObject(StripeCharge),
}

#[derive(Deserialize, Clone, Debug)]
Expand Down Expand Up @@ -2414,19 +2420,21 @@ impl<F, T>
types::MandateReference::foreign_from((
item.response.payment_method_options.clone(),
match item.response.latest_charge.clone() {
Some(charge) => match charge.payment_method_details {
Some(StripePaymentMethodDetailsResponse::Bancontact { bancontact }) => {
bancontact.attached_payment_method.unwrap_or(pm)
}
Some(StripePaymentMethodDetailsResponse::Ideal { ideal }) => {
ideal.attached_payment_method.unwrap_or(pm)
Some(StripeChargeEnum::ChargeObject(charge)) => {
match charge.payment_method_details {
Some(StripePaymentMethodDetailsResponse::Bancontact { bancontact }) => {
bancontact.attached_payment_method.unwrap_or(pm)
}
Some(StripePaymentMethodDetailsResponse::Ideal { ideal }) => {
ideal.attached_payment_method.unwrap_or(pm)
}
Some(StripePaymentMethodDetailsResponse::Sofort { sofort }) => {
sofort.attached_payment_method.unwrap_or(pm)
}
_ => pm,
}
Some(StripePaymentMethodDetailsResponse::Sofort { sofort }) => {
sofort.attached_payment_method.unwrap_or(pm)
}
_ => pm,
},
None => pm,
}
_ => pm,
},
))
});
Expand Down

0 comments on commit 1dd1bbf

Please sign in to comment.