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): PMD Not Getting Populated for Saved Card Transactions #6497

Merged
Show file tree
Hide file tree
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
11 changes: 10 additions & 1 deletion crates/router/src/connector/paybox/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,16 @@ impl TryFrom<&PayboxRouterData<&types::PaymentsCompleteAuthorizeRouterData>> for
|data| Some(data.clone()),
),
customer_id: match item.router_data.request.is_mandate_payment() {
true => Some(Secret::new(item.router_data.payment_id.clone())),
true => {
let reference_id = item
.router_data
.connector_mandate_request_reference_id
.clone()
.ok_or_else(|| errors::ConnectorError::MissingRequiredField {
field_name: "connector_mandate_request_reference_id",
})?;
Some(Secret::new(reference_id))
}
false => None,
},
})
Expand Down
70 changes: 35 additions & 35 deletions crates/router/src/core/payments/operations/payment_confirm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -576,41 +576,6 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa
payment_method_info,
} = mandate_details;

let additional_pm_data_from_locker = if let Some(ref pm) = payment_method_info {
let card_detail_from_locker: Option<api::CardDetailFromLocker> = pm
.payment_method_data
.clone()
.map(|x| x.into_inner().expose())
.and_then(|v| {
v.parse_value("PaymentMethodsData")
.map_err(|err| {
router_env::logger::info!(
"PaymentMethodsData deserialization failed: {:?}",
err
)
})
.ok()
})
.and_then(|pmd| match pmd {
PaymentMethodsData::Card(crd) => Some(api::CardDetailFromLocker::from(crd)),
_ => None,
});
card_detail_from_locker.map(|card_details| {
let additional_data = card_details.into();
api_models::payments::AdditionalPaymentData::Card(Box::new(additional_data))
})
} else {
None
};
payment_attempt.payment_method_data = additional_pm_data_from_locker
.as_ref()
.map(Encode::encode_to_value)
.transpose()
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to encode additional pm data")?;

payment_attempt.payment_method = payment_method.or(payment_attempt.payment_method);

payment_attempt.payment_method_type = payment_method_type
.or(payment_attempt.payment_method_type)
.or(payment_method_info
Expand Down Expand Up @@ -650,6 +615,41 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa
} else {
(None, payment_method_info)
};
let additional_pm_data_from_locker = if let Some(ref pm) = payment_method_info {
let card_detail_from_locker: Option<api::CardDetailFromLocker> = pm
.payment_method_data
.clone()
.map(|x| x.into_inner().expose())
.and_then(|v| {
v.parse_value("PaymentMethodsData")
.map_err(|err| {
router_env::logger::info!(
"PaymentMethodsData deserialization failed: {:?}",
err
)
})
.ok()
})
.and_then(|pmd| match pmd {
PaymentMethodsData::Card(crd) => Some(api::CardDetailFromLocker::from(crd)),
_ => None,
});
card_detail_from_locker.map(|card_details| {
let additional_data = card_details.into();
api_models::payments::AdditionalPaymentData::Card(Box::new(additional_data))
})
} else {
None
};
payment_attempt.payment_method_data = additional_pm_data_from_locker
.as_ref()
.map(Encode::encode_to_value)
.transpose()
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to encode additional pm data")?;

payment_attempt.payment_method = payment_method.or(payment_attempt.payment_method);

// The operation merges mandate data from both request and payment_attempt
let setup_mandate = mandate_data.map(|mut sm| {
sm.mandate_type = payment_attempt.mandate_details.clone().or(sm.mandate_type);
Expand Down
Loading