feat(router): updated last_used_at field for apple pay and google pay for CITs (#5087)

This commit is contained in:
Shankar Singh C
2024-06-25 18:42:47 +05:30
committed by GitHub
parent ea74f3e537
commit 7c639bf878
2 changed files with 62 additions and 3 deletions

View File

@ -70,9 +70,11 @@ pub fn get_mandate_type(
Ok(Some(api::MandateTransactionType::NewMandateTransaction))
}
(_, _, Some(enums::FutureUsage::OffSession), _, Some(_)) | (_, Some(_), _, _, _) => Ok(
Some(api::MandateTransactionType::RecurringMandateTransaction),
),
(_, _, Some(enums::FutureUsage::OffSession), _, Some(_))
| (_, Some(_), _, _, _)
| (_, _, Some(enums::FutureUsage::OffSession), _, _) => Ok(Some(
api::MandateTransactionType::RecurringMandateTransaction,
)),
_ => Ok(None),
}

View File

@ -533,6 +533,63 @@ pub async fn get_token_pm_type_mandate_details(
mandate_generic_data.mandate_connector,
mandate_generic_data.payment_method_info,
)
} else if request.payment_method_type
== Some(api_models::enums::PaymentMethodType::ApplePay)
|| request.payment_method_type
== Some(api_models::enums::PaymentMethodType::GooglePay)
{
if let Some(customer_id) = &request.customer_id {
let customer_saved_pm_option = match state
.store
.find_payment_method_by_customer_id_merchant_id_list(
customer_id,
merchant_account.merchant_id.as_str(),
None,
)
.await
{
Ok(customer_payment_methods) => Ok(customer_payment_methods
.iter()
.find(|payment_method| {
payment_method.payment_method_type
== request.payment_method_type
})
.cloned()),
Err(error) => {
if error.current_context().is_db_not_found() {
Ok(None)
} else {
Err(error)
.change_context(
errors::ApiErrorResponse::InternalServerError,
)
.attach_printable(
"failed to find payment methods for a customer",
)
}
}
}?;
(
None,
request.payment_method,
request.payment_method_type,
None,
None,
None,
customer_saved_pm_option,
)
} else {
(
None,
request.payment_method,
request.payment_method_type,
None,
None,
None,
None,
)
}
} else {
(
request.payment_token.to_owned(),