mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-28 20:23:43 +08:00
chore: add customer, shipping and billing details to payment_response for payment list api (#5401)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -206,7 +206,9 @@ pub struct CustomerDetails {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Details of customer attached to this payment
|
/// Details of customer attached to this payment
|
||||||
#[derive(Debug, Default, serde::Serialize, Clone, ToSchema, PartialEq, Setter)]
|
#[derive(
|
||||||
|
Debug, Default, serde::Serialize, serde::Deserialize, Clone, ToSchema, PartialEq, Setter,
|
||||||
|
)]
|
||||||
pub struct CustomerDetailsResponse {
|
pub struct CustomerDetailsResponse {
|
||||||
/// The identifier for the customer.
|
/// The identifier for the customer.
|
||||||
#[schema(value_type = Option<String>, max_length = 64, min_length = 1, example = "cus_y3oqhf46pyzuxjbcn2giaqnb44")]
|
#[schema(value_type = Option<String>, max_length = 64, min_length = 1, example = "cus_y3oqhf46pyzuxjbcn2giaqnb44")]
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
use std::{fmt::Debug, marker::PhantomData, str::FromStr};
|
use std::{fmt::Debug, marker::PhantomData, str::FromStr};
|
||||||
|
|
||||||
use api_models::payments::{
|
use api_models::payments::{
|
||||||
CustomerDetailsResponse, FrmMessage, GetAddressFromPaymentMethodData, PaymentChargeRequest,
|
Address, CustomerDetailsResponse, FrmMessage, GetAddressFromPaymentMethodData,
|
||||||
PaymentChargeResponse, RequestSurchargeDetails,
|
PaymentChargeRequest, PaymentChargeResponse, RequestSurchargeDetails,
|
||||||
};
|
};
|
||||||
#[cfg(feature = "payouts")]
|
#[cfg(feature = "payouts")]
|
||||||
use api_models::payouts::PayoutAttemptResponse;
|
use api_models::payouts::PayoutAttemptResponse;
|
||||||
@ -1036,7 +1036,7 @@ impl ForeignFrom<(storage::PaymentIntent, storage::PaymentAttempt)> for api::Pay
|
|||||||
description: pi.description,
|
description: pi.description,
|
||||||
metadata: pi.metadata,
|
metadata: pi.metadata,
|
||||||
order_details: pi.order_details,
|
order_details: pi.order_details,
|
||||||
customer_id: pi.customer_id,
|
customer_id: pi.customer_id.clone(),
|
||||||
connector: pa.connector,
|
connector: pa.connector,
|
||||||
payment_method: pa.payment_method,
|
payment_method: pa.payment_method,
|
||||||
payment_method_type: pa.payment_method_type,
|
payment_method_type: pa.payment_method_type,
|
||||||
@ -1060,6 +1060,40 @@ impl ForeignFrom<(storage::PaymentIntent, storage::PaymentAttempt)> for api::Pay
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
merchant_order_reference_id: pi.merchant_order_reference_id,
|
merchant_order_reference_id: pi.merchant_order_reference_id,
|
||||||
|
customer: pi.customer_details.and_then(|customer_details|
|
||||||
|
match customer_details.into_inner().expose().parse_value::<CustomerData>("CustomerData"){
|
||||||
|
Ok(parsed_data) => Some(
|
||||||
|
CustomerDetailsResponse {
|
||||||
|
id: pi.customer_id,
|
||||||
|
name: parsed_data.name,
|
||||||
|
phone: parsed_data.phone,
|
||||||
|
email: parsed_data.email,
|
||||||
|
phone_country_code:parsed_data.phone_country_code
|
||||||
|
}),
|
||||||
|
Err(e) => {
|
||||||
|
router_env::logger::error!("Failed to parse 'CustomerDetailsResponse' from payment method data. Error: {e:?}");
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
),
|
||||||
|
billing: pi.billing_details.and_then(|billing_details|
|
||||||
|
match billing_details.into_inner().expose().parse_value::<Address>("Address") {
|
||||||
|
Ok(parsed_data) => Some(parsed_data),
|
||||||
|
Err(e) => {
|
||||||
|
router_env::logger::error!("Failed to parse 'BillingAddress' from payment method data. Error: {e:?}");
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
),
|
||||||
|
shipping: pi.shipping_details.and_then(|shipping_details|
|
||||||
|
match shipping_details.into_inner().expose().parse_value::<Address>("Address") {
|
||||||
|
Ok(parsed_data) => Some(parsed_data),
|
||||||
|
Err(e) => {
|
||||||
|
router_env::logger::error!("Failed to parse 'ShippingAddress' from payment method data. Error: {e:?}");
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user