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(core): Returning customer acceptance in the payments response (#15306)
Swangi Kumaria8e316094adb
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.jsonindex 5c563c04cd..5422a817a4 100644--- a/api-reference/v1/openapi_spec_v1.json+++ b/api-reference/v1/openapi_spec_v1.json@@ -36978,6 +36978,14 @@],"nullable": true},+ "customer_acceptance": {+ "allOf": [+ {+ "$ref": "#/components/schemas/CustomerAcceptance"+ }+ ],+ "nullable": true+ },"setup_future_usage": {"allOf": [{@@ -38931,6 +38939,14 @@],"nullable": true},+ "customer_acceptance": {+ "allOf": [+ {+ "$ref": "#/components/schemas/CustomerAcceptance"+ }+ ],+ "nullable": true+ },"setup_future_usage": {"allOf": [{diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rsindex adbefc67da..44424694cd 100644--- a/crates/api_models/src/payments.rs+++ b/crates/api_models/src/payments.rs@@ -7883,6 +7883,11 @@ pub struct PaymentsResponse {#[smithy(value_type = "Option<MandateData>")]pub mandate_data: Option<MandateData>,+ /// Evidence of the customer's acceptance that was captured when the payment was confirmed, returned as stored on the payment attempt.+ #[schema(value_type = Option<CustomerAcceptance>)]+ #[smithy(value_type = "Option<CustomerAcceptance>")]+ pub customer_acceptance: Option<pii::SecretSerdeValue>,+/// Indicates that you intend to make future payments with this Payment’s payment method. Providing this parameter will attach the payment method to the Customer, if present, after the Payment is confirmed and any required actions from the user are complete.#[schema(value_type = Option<FutureUsage>, example = "off_session")]#[smithy(value_type = "Option<FutureUsage>")]diff --git a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rsindex 7778ae0a9a..754e9c87f3 100644--- a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs+++ b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs@@ -2089,6 +2089,11 @@ impl PaymentAttempt {_ => None,})}++ /// Extract the customer_acceptance stored on the payment attempt+ pub fn get_customer_acceptance(&self) -> Option<pii::SecretSerdeValue> {+ self.customer_acceptance.clone()+ }}#[derive(Clone, Debug, Eq, PartialEq)]diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rsindex e145186b37..f825db5322 100644--- a/crates/router/src/core/payments/transformers.rs+++ b/crates/router/src/core/payments/transformers.rs@@ -4678,6 +4678,7 @@ wherelet masked_sender_details = payment_intent.get_sender_details().map(api_models::sender::SenderDetailsResponse::from);+ let customer_acceptance = payment_attempt.get_customer_acceptance();let payments_response = api::PaymentsResponse {// Populated only for server integrations, by the update-context enrichment.payment_method_list: None,@@ -4711,6 +4712,7 @@ wherecaptures: captures_response,mandate_id,mandate_data,+ customer_acceptance,setup_future_usage,off_session: payment_intent.off_session,capture_on: None,@@ -5191,6 +5193,7 @@ impl ForeignFrom<(storage::PaymentIntent, storage::PaymentAttempt)> for api::Paylet masked_sender_details = pi.get_sender_details().map(api_models::sender::SenderDetailsResponse::from);+ let customer_acceptance = pa.get_customer_acceptance();Self {// Populated only for server integrations, by the update-context enrichment.payment_method_list: None,@@ -5276,6 +5279,7 @@ impl ForeignFrom<(storage::PaymentIntent, storage::PaymentAttempt)> for api::Paycaptures: None,mandate_id: None,mandate_data: None,+ customer_acceptance,off_session: None,capture_on: None,payment_token: None,diff --git a/crates/router/src/db/events.rs b/crates/router/src/db/events.rsindex 099c3fe63a..08fa39c0d7 100644--- a/crates/router/src/db/events.rs+++ b/crates/router/src/db/events.rs@@ -2141,6 +2141,7 @@ mod tests {attempts: None,captures: None,mandate_data: None,+ customer_acceptance: None,setup_future_usage: None,off_session: None,capture_on: None,diff --git a/crates/router/tests/payments.rs b/crates/router/tests/payments.rsindex d54ba7adb4..4f35a6612c 100644--- a/crates/router/tests/payments.rs+++ b/crates/router/tests/payments.rs@@ -400,6 +400,7 @@ async fn payments_create_core() {attempts: None,captures: None,mandate_data: None,+ customer_acceptance: None,setup_future_usage: None,off_session: None,capture_on: None,@@ -719,6 +720,7 @@ async fn payments_create_core_adyen_no_redirect() {attempts: None,captures: None,mandate_data: None,+ customer_acceptance: None,setup_future_usage: None,off_session: None,capture_on: None,diff --git a/crates/router/tests/payments2.rs b/crates/router/tests/payments2.rsindex 4e19a15ff5..26f8de66e1 100644--- a/crates/router/tests/payments2.rs+++ b/crates/router/tests/payments2.rs@@ -160,6 +160,7 @@ async fn payments_create_core() {attempts: None,captures: None,mandate_data: None,+ customer_acceptance: None,setup_future_usage: None,off_session: None,capture_on: None,@@ -488,6 +489,7 @@ async fn payments_create_core_adyen_no_redirect() {attempts: None,captures: None,mandate_data: None,+ customer_acceptance: None,setup_future_usage: None,off_session: None,capture_on: None,