Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
feat: return customer details in payments response body (#4237)
Hrithikesh740749e18ae4
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rsindex 72592ec3ca..63b2930611 100644--- a/crates/api_models/src/payments.rs+++ b/crates/api_models/src/payments.rs@@ -169,7 +169,7 @@ mod client_secret_tests {}}-#[derive(Default, Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema)]+#[derive(Default, Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema, PartialEq)]pub struct CustomerDetails {/// The identifier for the customer.pub id: String,@@ -2935,6 +2935,9 @@ pub struct PaymentsResponse {#[schema(max_length = 255, example = "cus_y3oqhf46pyzuxjbcn2giaqnb44")]pub customer_id: Option<String>,+ /// Details of customer attached to this payment+ pub customer: Option<CustomerDetails>,+/// A description of the payment#[schema(example = "It's my first payment request")]pub description: Option<String>,diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rsindex d686d741c8..9aa552b86d 100644--- a/crates/router/src/core/payments/transformers.rs+++ b/crates/router/src/core/payments/transformers.rs@@ -490,6 +490,8 @@ where))}+ let customer_details_response = customer.as_ref().map(ForeignInto::foreign_into);+headers.extend(external_latency.map(|latency| {@@ -779,6 +781,7 @@ where.set_payment_method_status(payment_data.payment_method_info.map(|info| info.status),)+ .set_customer(customer_details_response.clone()).to_owned(),headers,))@@ -849,6 +852,7 @@ whereexpires_on: payment_intent.session_expiry,external_3ds_authentication_attempted: payment_attempt.external_three_ds_authentication_attempted,+ customer: customer_details_response,..Default::default()},headers,diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rsindex 8a53a58aab..237dea196d 100644--- a/crates/router/src/types/transformers.rs+++ b/crates/router/src/types/transformers.rs@@ -1130,6 +1130,24 @@ impl ForeignFrom<storage::GatewayStatusMap> for gsm_api_types::GsmResponse {}}+impl ForeignFrom<&domain::Customer> for api_models::payments::CustomerDetails {+ fn foreign_from(customer: &domain::Customer) -> Self {+ Self {+ id: customer.customer_id.clone(),+ name: customer+ .name+ .as_ref()+ .map(|name| name.get_inner().to_owned()),+ email: customer.email.clone().map(Into::into),+ phone: customer+ .phone+ .as_ref()+ .map(|phone| phone.get_inner().to_owned()),+ phone_country_code: customer.phone_country_code.clone(),+ }+ }+}+#[cfg(feature = "olap")]impl ForeignTryFrom<api_types::webhook_events::EventListConstraints>for api_types::webhook_events::EventListConstraintsInternaldiff --git a/openapi/openapi_spec.json b/openapi/openapi_spec.jsonindex fa9c743563..1e16d07247 100644--- a/openapi/openapi_spec.json+++ b/openapi/openapi_spec.json@@ -14338,6 +14338,14 @@"nullable": true,"maxLength": 255},+ "customer": {+ "allOf": [+ {+ "$ref": "#/components/schemas/CustomerDetails"+ }+ ],+ "nullable": true+ },"description": {"type": "string","description": "A description of the payment",