mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-28 04:04:55 +08:00
fix(core): fix mandate_details to store some value only if mandate_data struct is present (#3525)
This commit is contained in:
@ -1823,7 +1823,6 @@ pub async fn list_payment_methods(
|
|||||||
} else {
|
} else {
|
||||||
api_surcharge_decision_configs::MerchantSurchargeConfigs::default()
|
api_surcharge_decision_configs::MerchantSurchargeConfigs::default()
|
||||||
};
|
};
|
||||||
print!("PAMT{:?}", payment_attempt);
|
|
||||||
Ok(services::ApplicationResponse::Json(
|
Ok(services::ApplicationResponse::Json(
|
||||||
api::PaymentMethodListResponse {
|
api::PaymentMethodListResponse {
|
||||||
redirect_url: merchant_account.return_url,
|
redirect_url: merchant_account.return_url,
|
||||||
@ -2070,13 +2069,30 @@ pub async fn filter_payment_methods(
|
|||||||
})?;
|
})?;
|
||||||
let filter7 = payment_attempt
|
let filter7 = payment_attempt
|
||||||
.and_then(|attempt| attempt.mandate_details.as_ref())
|
.and_then(|attempt| attempt.mandate_details.as_ref())
|
||||||
.map(|_mandate_details| {
|
.map(|mandate_details| {
|
||||||
filter_pm_based_on_supported_payments_for_mandate(
|
let (mandate_type_present, update_mandate_id_present) =
|
||||||
supported_payment_methods_for_mandate,
|
match mandate_details {
|
||||||
&payment_method,
|
data_models::mandates::MandateTypeDetails::MandateType(_) => {
|
||||||
&payment_method_object.payment_method_type,
|
(true, false)
|
||||||
connector_variant,
|
}
|
||||||
)
|
data_models::mandates::MandateTypeDetails::MandateDetails(
|
||||||
|
mand_details,
|
||||||
|
) => (
|
||||||
|
mand_details.mandate_type.is_some(),
|
||||||
|
mand_details.update_mandate_id.is_some(),
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
if mandate_type_present || update_mandate_id_present {
|
||||||
|
filter_pm_based_on_supported_payments_for_mandate(
|
||||||
|
supported_payment_methods_for_mandate,
|
||||||
|
&payment_method,
|
||||||
|
&payment_method_object.payment_method_type,
|
||||||
|
connector_variant,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
true
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.unwrap_or(true);
|
.unwrap_or(true);
|
||||||
|
|
||||||
|
|||||||
@ -712,7 +712,9 @@ impl PaymentCreate {
|
|||||||
Err(errors::ApiErrorResponse::InvalidRequestData {message:"Only one field out of 'mandate_type' and 'update_mandate_id' was expected, found both".to_string()})?
|
Err(errors::ApiErrorResponse::InvalidRequestData {message:"Only one field out of 'mandate_type' and 'update_mandate_id' was expected, found both".to_string()})?
|
||||||
}
|
}
|
||||||
|
|
||||||
let mandate_dets = if let Some(update_id) = request
|
let mandate_details = if request.mandate_data.is_none() {
|
||||||
|
None
|
||||||
|
} else if let Some(update_id) = request
|
||||||
.mandate_data
|
.mandate_data
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|inner| inner.update_mandate_id.clone())
|
.and_then(|inner| inner.update_mandate_id.clone())
|
||||||
@ -723,8 +725,6 @@ impl PaymentCreate {
|
|||||||
};
|
};
|
||||||
Some(MandateTypeDetails::MandateDetails(mandate_data))
|
Some(MandateTypeDetails::MandateDetails(mandate_data))
|
||||||
} else {
|
} else {
|
||||||
// let mandate_type: data_models::mandates::MandateDataType =
|
|
||||||
|
|
||||||
let mandate_data = MandateDetails {
|
let mandate_data = MandateDetails {
|
||||||
update_mandate_id: None,
|
update_mandate_id: None,
|
||||||
mandate_type: request
|
mandate_type: request
|
||||||
@ -761,7 +761,7 @@ impl PaymentCreate {
|
|||||||
business_sub_label: request.business_sub_label.clone(),
|
business_sub_label: request.business_sub_label.clone(),
|
||||||
surcharge_amount,
|
surcharge_amount,
|
||||||
tax_amount,
|
tax_amount,
|
||||||
mandate_details: mandate_dets,
|
mandate_details,
|
||||||
..storage::PaymentAttemptNew::default()
|
..storage::PaymentAttemptNew::default()
|
||||||
},
|
},
|
||||||
additional_pm_data,
|
additional_pm_data,
|
||||||
|
|||||||
Reference in New Issue
Block a user