mirror of
https://github.com/juspay/hyperswitch.git
synced 2026-03-13 09:02:06 +08:00
fix(payments): resolve customer ID mismatch in payment method validation and remove todo from generate_pm_vaulting_req_from_update_request (#11400)
This commit is contained in:
@@ -5701,6 +5701,10 @@ impl<'a> pm_types::PaymentMethodUpdateHandler<'a> {
|
||||
payment_method_data,
|
||||
)
|
||||
})
|
||||
.transpose()
|
||||
.change_context(errors::ApiErrorResponse::NotSupported {
|
||||
message: "Payment method type not supported for update".to_string(),
|
||||
})?
|
||||
.ok_or(errors::ApiErrorResponse::MissingRequiredField {
|
||||
field_name: "payment_method_data",
|
||||
})?;
|
||||
|
||||
@@ -553,12 +553,12 @@ pub fn mk_add_card_response_hs(
|
||||
pub fn generate_pm_vaulting_req_from_update_request(
|
||||
pm_create: domain::PaymentMethodVaultingData,
|
||||
pm_update: api::PaymentMethodUpdateData,
|
||||
) -> domain::PaymentMethodVaultingData {
|
||||
) -> CustomResult<domain::PaymentMethodVaultingData, errors::VaultError> {
|
||||
match (pm_create, pm_update) {
|
||||
(
|
||||
domain::PaymentMethodVaultingData::Card(card_create),
|
||||
api::PaymentMethodUpdateData::Card(update_card),
|
||||
) => domain::PaymentMethodVaultingData::Card(api::CardDetail {
|
||||
) => Ok(domain::PaymentMethodVaultingData::Card(api::CardDetail {
|
||||
card_number: card_create.card_number,
|
||||
card_exp_month: card_create.card_exp_month,
|
||||
card_exp_year: card_create.card_exp_year,
|
||||
@@ -571,8 +571,9 @@ pub fn generate_pm_vaulting_req_from_update_request(
|
||||
.or(card_create.card_holder_name),
|
||||
nick_name: update_card.nick_name.or(card_create.nick_name),
|
||||
card_cvc: None,
|
||||
}),
|
||||
_ => todo!(), //todo! - since support for network tokenization is not added PaymentMethodUpdateData. should be handled later.
|
||||
})),
|
||||
_ => Err(errors::VaultError::PaymentMethodNotSupported)
|
||||
.attach_printable("Payment method type not supported for update"),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1225,7 +1225,10 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
|
||||
|
||||
utils::when(
|
||||
pm_info.payment_method.0.customer_id
|
||||
!= req.customer_id.clone().get_required_value("customer_id")?,
|
||||
!= req
|
||||
.get_customer_id()
|
||||
.get_required_value("customer_id")?
|
||||
.clone(),
|
||||
|| {
|
||||
logger::info!("Payment method id does not belong to the customer id provided in the request.");
|
||||
Err(errors::ApiErrorResponse::PaymentMethodNotFound)
|
||||
|
||||
@@ -881,7 +881,10 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
|
||||
|
||||
utils::when(
|
||||
pm_info.payment_method.0.customer_id
|
||||
!= req.customer_id.clone().get_required_value("customer_id")?,
|
||||
!= req
|
||||
.get_customer_id()
|
||||
.get_required_value("customer_id")?
|
||||
.clone(),
|
||||
|| {
|
||||
logger::info!("Payment method id does not belong to the customer id provided in the request.");
|
||||
Err(errors::ApiErrorResponse::PaymentMethodNotFound)
|
||||
|
||||
Reference in New Issue
Block a user