Skip to content

Commit

Permalink
fixed customer_details requirement logic
Browse files Browse the repository at this point in the history
  • Loading branch information
sahkal committed Dec 19, 2024
1 parent 4ccb2ee commit fda4a1c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions crates/router/src/core/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3441,14 +3441,19 @@ pub async fn get_session_token_for_click_to_pay(
message: "Failed to convert amount to string major unit for clickToPay".to_string(),
})?;

let customer_details: &CustomerData = &payment_intent
let optional_customer_details: Option<CustomerData> = payment_intent
.customer_details
.clone()
.parse_value("CustomerData")
.map(|details| details.parse_value("CustomerData"))
.transpose()
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Error while parsing customer data from payment intent")?;
let customer_details =
optional_customer_details.ok_or(errors::ApiErrorResponse::MissingRequiredField {
field_name: "customer_details",
})?;

validate_customer_details_for_click_to_pay(customer_details)?;
validate_customer_details_for_click_to_pay(&customer_details)?;

Ok(api_models::payments::SessionToken::ClickToPay(Box::new(
api_models::payments::ClickToPaySessionResponse {
Expand Down

0 comments on commit fda4a1c

Please sign in to comment.