Skip to content

Commit

Permalink
feat(router): updated last_used_at field for apple pay and google p…
Browse files Browse the repository at this point in the history
…ay for CITs (#5087)
  • Loading branch information
ShankarSinghC committed Jun 25, 2024
1 parent ea74f3e commit 7c639bf
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 3 deletions.
8 changes: 5 additions & 3 deletions crates/router/src/core/mandate/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down
57 changes: 57 additions & 0 deletions crates/router/src/core/payments/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit 7c639bf

Please sign in to comment.