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(payment_methods): send capture_method in payment method list api… (#12084)
Nithin N3f3071c529ac
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.jsonindex 466ccc1930..dad2e6c9fd 100644--- a/api-reference/v1/openapi_spec_v1.json+++ b/api-reference/v1/openapi_spec_v1.json@@ -29049,6 +29049,14 @@},"description": "Installment options available for this payment","nullable": true+ },+ "capture_method": {+ "allOf": [+ {+ "$ref": "#/components/schemas/CaptureMethod"+ }+ ],+ "nullable": true}}},diff --git a/crates/api_models/src/payment_methods.rs b/crates/api_models/src/payment_methods.rsindex 9a301cb992..9379a7d43a 100644--- a/crates/api_models/src/payment_methods.rs+++ b/crates/api_models/src/payment_methods.rs@@ -2826,6 +2826,10 @@ pub struct PaymentMethodListIntentData {/// Installment options available for this paymentpub installment_options: Option<Vec<PaymentMethodListInstallmentOption>>,++ /// The capture method for the payment+ #[schema(value_type = Option<CaptureMethod>)]+ pub capture_method: Option<api_enums::CaptureMethod>,}/// Installment options for a payment method, as returned in the payment method list responsediff --git a/crates/hyperswitch_domain_models/src/payments.rs b/crates/hyperswitch_domain_models/src/payments.rsindex 1b2e981580..58b0c58009 100644--- a/crates/hyperswitch_domain_models/src/payments.rs+++ b/crates/hyperswitch_domain_models/src/payments.rs@@ -476,6 +476,7 @@ impl PaymentIntent {self,net_amount: MinorUnit,show_installments: bool,+ capture_method: Option<common_enums::CaptureMethod>,) -> CustomResult<PaymentMethodListIntentData, errors::api_error_response::ApiErrorResponse>{let billing: Option<Address> = self@@ -540,6 +541,7 @@ impl PaymentIntent {merchant_order_reference_id: self.merchant_order_reference_id,attempt_count: self.attempt_count,installment_options,+ capture_method,})}diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rsindex 117292fcea..8223d4581e 100644--- a/crates/router/src/core/payment_methods/cards.rs+++ b/crates/router/src/core/payment_methods/cards.rs@@ -4023,6 +4023,7 @@ pub async fn list_payment_methods(});}let currency = payment_intent.as_ref().and_then(|pi| pi.currency);+ let capture_method = payment_attempt.as_ref().and_then(|pa| pa.capture_method);let skip_external_tax_calculation = payment_intent.as_ref().and_then(|intent| intent.skip_external_tax_calculation)@@ -4102,7 +4103,11 @@ pub async fn list_payment_methods(.as_ref().map(|pa| pa.net_amount.get_total_amount()).unwrap_or(pi.amount);- pi.into_payment_method_list_intent_data(net_amount, connector_supports_installments)+ pi.into_payment_method_list_intent_data(+ net_amount,+ connector_supports_installments,+ capture_method,+ )}).transpose().change_context(errors::ApiErrorResponse::InternalServerError)@@ -4118,8 +4123,10 @@ pub async fn list_payment_methods(.to_owned(),payment_type,payment_methods: payment_method_responses,- mandate_payment: payment_attempt.and_then(|inner| inner.mandate_details).map(- |d| match d {+ mandate_payment: payment_attempt+ .as_ref()+ .and_then(|inner| inner.mandate_details.clone())+ .map(|d| match d {hyperswitch_domain_models::mandates::MandateDataType::SingleUse(i) => {api::MandateType::SingleUse(api::MandateAmountData {amount: i.amount,@@ -4141,8 +4148,7 @@ pub async fn list_payment_methods(hyperswitch_domain_models::mandates::MandateDataType::MultiUse(None) => {api::MandateType::MultiUse(None)}- },- ),+ }),show_surcharge_breakup_screen: merchant_surcharge_configs.show_surcharge_breakup_screen.unwrap_or_default(),