mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-01 19:42:27 +08:00
fix(core): fetch customer id from customer object during MIT (#5218)
Co-authored-by: Chikke Srujan <chikke.srujan@Chikke-Srujan-N7WRTY72X7.local>
This commit is contained in:
@ -505,10 +505,7 @@ pub async fn get_token_pm_type_mandate_details(
|
||||
.to_not_found_response(
|
||||
errors::ApiErrorResponse::PaymentMethodNotFound,
|
||||
)?;
|
||||
|
||||
let customer_id = request
|
||||
.customer_id
|
||||
.clone()
|
||||
let customer_id = get_customer_id_from_payment_request(request)
|
||||
.get_required_value("customer_id")?;
|
||||
|
||||
verify_mandate_details_for_recurring_payments(
|
||||
@ -555,8 +552,10 @@ pub async fn get_token_pm_type_mandate_details(
|
||||
|| request.payment_method_type
|
||||
== Some(api_models::enums::PaymentMethodType::GooglePay)
|
||||
{
|
||||
let payment_request_customer_id =
|
||||
get_customer_id_from_payment_request(request);
|
||||
if let Some(customer_id) =
|
||||
&request.customer_id.clone().or(customer_id.clone())
|
||||
&payment_request_customer_id.or(customer_id.clone())
|
||||
{
|
||||
let customer_saved_pm_option = match state
|
||||
.store
|
||||
@ -712,8 +711,7 @@ pub async fn get_token_for_recurring_mandate(
|
||||
.map(|pi| pi.amount.get_amount_as_i64());
|
||||
let original_payment_authorized_currency =
|
||||
original_payment_intent.clone().and_then(|pi| pi.currency);
|
||||
|
||||
let customer = req.customer_id.clone().get_required_value("customer_id")?;
|
||||
let customer = get_customer_id_from_payment_request(req).get_required_value("customer_id")?;
|
||||
|
||||
let payment_method_id = {
|
||||
if mandate.customer_id != customer {
|
||||
@ -1578,6 +1576,16 @@ pub fn get_customer_details_from_request(
|
||||
}
|
||||
}
|
||||
|
||||
fn get_customer_id_from_payment_request(
|
||||
request: &api_models::payments::PaymentsRequest,
|
||||
) -> Option<id_type::CustomerId> {
|
||||
request
|
||||
.customer
|
||||
.as_ref()
|
||||
.map(|customer| customer.id.clone())
|
||||
.or(request.customer_id.clone())
|
||||
}
|
||||
|
||||
pub async fn get_connector_default(
|
||||
_state: &SessionState,
|
||||
request_connector: Option<serde_json::Value>,
|
||||
|
||||
Reference in New Issue
Block a user