Skip to content

Commit

Permalink
fix(core): Update pm details in Psync response (#6011)
Browse files Browse the repository at this point in the history
  • Loading branch information
prasunna09 authored Sep 24, 2024
1 parent a94cf25 commit cbeddb3
Showing 1 changed file with 11 additions and 30 deletions.
41 changes: 11 additions & 30 deletions crates/router/src/core/payments/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -778,37 +778,18 @@ where
.as_ref()
.map(ToString::to_string)
.unwrap_or("".to_owned());
let additional_payment_method_data: Option<api_models::payments::AdditionalPaymentData> =
match payment_data.get_payment_method_data(){
Some(payment_method_data) => match payment_method_data{
hyperswitch_domain_models::payment_method_data::PaymentMethodData::Card(_) |
hyperswitch_domain_models::payment_method_data::PaymentMethodData::CardRedirect(_) |
hyperswitch_domain_models::payment_method_data::PaymentMethodData::Wallet(_) |
hyperswitch_domain_models::payment_method_data::PaymentMethodData::PayLater(_) |
hyperswitch_domain_models::payment_method_data::PaymentMethodData::BankRedirect(_) |
hyperswitch_domain_models::payment_method_data::PaymentMethodData::BankDebit(_) |
hyperswitch_domain_models::payment_method_data::PaymentMethodData::BankTransfer(_) |
hyperswitch_domain_models::payment_method_data::PaymentMethodData::Crypto(_) |
hyperswitch_domain_models::payment_method_data::PaymentMethodData::MandatePayment |
hyperswitch_domain_models::payment_method_data::PaymentMethodData::Reward |
hyperswitch_domain_models::payment_method_data::PaymentMethodData::RealTimePayment(_) |
hyperswitch_domain_models::payment_method_data::PaymentMethodData::Upi(_) |
hyperswitch_domain_models::payment_method_data::PaymentMethodData::Voucher(_) |
hyperswitch_domain_models::payment_method_data::PaymentMethodData::GiftCard(_) |
hyperswitch_domain_models::payment_method_data::PaymentMethodData::CardToken(_) |
hyperswitch_domain_models::payment_method_data::PaymentMethodData::OpenBanking(_) => {payment_attempt
.payment_method_data
.clone()
.map(|data| data.parse_value("payment_method_data"))
.transpose()
.change_context(errors::ApiErrorResponse::InvalidDataValue {
field_name: "payment_method_data",
})?},
hyperswitch_domain_models::payment_method_data::PaymentMethodData::NetworkToken(_) => None,
}
None => None

};
let additional_payment_method_data: Option<api_models::payments::AdditionalPaymentData> =
payment_attempt
.payment_method_data
.clone()
.and_then(|data| match data {
serde_json::Value::Null => None, // This is to handle the case when the payment_method_data is null
_ => Some(data.parse_value("AdditionalPaymentData")),
})
.transpose()
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to parse the AdditionalPaymentData from payment_attempt.payment_method_data")?;

let surcharge_details =
payment_attempt
Expand Down

0 comments on commit cbeddb3

Please sign in to comment.