Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): Update pm details in Psync response #6011

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading