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
fix(connector): fix UCS webhook config and update connector configs for Truelayer and Trustly (#11780)
Vani Guptae18abbb309bd
diff --git a/config/config.example.toml b/config/config.example.tomlindex bcb3921b61..e168a18c5e 100644--- a/config/config.example.toml+++ b/config/config.example.toml@@ -1330,8 +1330,8 @@ url = "http://localhost:8080" # Open Router URL[grpc_client.unified_connector_service]base_url = "http://localhost:8000" # Unified Connector Service Base URLconnection_timeout = 10 # Connection Timeout Duration in Seconds-ucs_only_connectors = "paytm, phonepe, hyperpg, revolv3, truelayer, fiservcommercehub, trustly" # Comma-separated list of connectors that use UCS only-ucs_psync_disabled_connectors = "cashtocode" # Comma-separated list of connectors to disable UCS PSync call+ucs_only_connectors = "paytm, phonepe, hyperpg, revolv3, fiservcommercehub" # Comma-separated list of connectors that use UCS only+ucs_psync_disabled_connectors = "cashtocode, trustly" # Comma-separated list of connectors to disable UCS PSync call[grpc_client.recovery_decider_client] # Revenue recovery client base urlbase_url = "http://127.0.0.1:8080" #Base URLdiff --git a/config/deployments/env_specific.toml b/config/deployments/env_specific.tomlindex c0f6c9f217..ec26f03886 100644--- a/config/deployments/env_specific.toml+++ b/config/deployments/env_specific.toml@@ -406,8 +406,8 @@ connector_names = "connector_names" # Comma-separated list of allowed connec[grpc_client.unified_connector_service]base_url = "http://localhost:8000" # Unified Connector Service Base URLconnection_timeout = 10 # Connection Timeout Duration in Seconds-ucs_only_connectors = "paytm, phonepe, hyperpg, revolv3, truelayer, fiservcommercehub, trustly" # Comma-separated list of connectors that use UCS only-ucs_psync_disabled_connectors = "cashtocode" # Comma-separated list of connectors to disable UCS PSync call+ucs_only_connectors = "paytm, phonepe, hyperpg, revolv3, fiservcommercehub" # Comma-separated list of connectors that use UCS only+ucs_psync_disabled_connectors = "cashtocode, trustly" # Comma-separated list of connectors to disable UCS PSync call[revenue_recovery]# monitoring threshold - 120 daysdiff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.tomlindex 6e8f9dba60..c433a91ce0 100644--- a/config/deployments/integration_test.toml+++ b/config/deployments/integration_test.toml@@ -1011,8 +1011,8 @@ connector_list = "juspaythreedsserver, ctp_mastercard, ctp_visa"connector_list = "worldpayvantiv"[grpc_client.unified_connector_service]-ucs_only_connectors = "paytm, phonepe, hyperpg, revolv3, truelayer, fiservcommercehub, trustly" # Comma-separated list of connectors that use UCS only-ucs_psync_disabled_connectors = "cashtocode" # Comma-separated list of connectors to disable UCS PSync call+ucs_only_connectors = "paytm, phonepe, hyperpg, revolv3, fiservcommercehub" # Comma-separated list of connectors that use UCS only+ucs_psync_disabled_connectors = "cashtocode, trustly" # Comma-separated list of connectors to disable UCS PSync call# Merchant Advice Code Configuration[merchant_advice_codes.visa]diff --git a/config/deployments/production.toml b/config/deployments/production.tomlindex 387d7dead0..609330c3b0 100644--- a/config/deployments/production.toml+++ b/config/deployments/production.toml@@ -1019,8 +1019,8 @@ click_to_pay = {connector_list = "adyen, cybersource, trustpay"}connector_list = "juspaythreedsserver, ctp_mastercard, ctp_visa"[grpc_client.unified_connector_service]-ucs_only_connectors = "paytm, phonepe, hyperpg, revolv3, truelayer, fiservcommercehub, trustly" # Comma-separated list of connectors that use UCS only-ucs_psync_disabled_connectors = "cashtocode" # Comma-separated list of connectors to disable UCS PSync call+ucs_only_connectors = "paytm, phonepe, hyperpg, revolv3, fiservcommercehub" # Comma-separated list of connectors that use UCS only+ucs_psync_disabled_connectors = "cashtocode, trustly" # Comma-separated list of connectors to disable UCS PSync call# Merchant Advice Code Configuration[merchant_advice_codes.visa]diff --git a/config/deployments/sandbox.toml b/config/deployments/sandbox.tomlindex 77e6c180e8..59a3e7b355 100644--- a/config/deployments/sandbox.toml+++ b/config/deployments/sandbox.toml@@ -1029,8 +1029,8 @@ connector_list = "juspaythreedsserver, ctp_mastercard, ctp_visa"connector_list = "worldpayvantiv"[grpc_client.unified_connector_service]-ucs_only_connectors = "paytm, phonepe, hyperpg, revolv3, truelayer, fiservcommercehub, trustly" # Comma-separated list of connectors that use UCS only-ucs_psync_disabled_connectors = "cashtocode" # Comma-separated list of connectors to disable UCS PSync call+ucs_only_connectors = "paytm, phonepe, hyperpg, revolv3, fiservcommercehub" # Comma-separated list of connectors that use UCS only+ucs_psync_disabled_connectors = "cashtocode, trustly" # Comma-separated list of connectors to disable UCS PSync call# Merchant Advice Code Configuration[merchant_advice_codes.visa]diff --git a/config/development.toml b/config/development.tomlindex 16dd0c211e..5ca950de35 100644--- a/config/development.toml+++ b/config/development.toml@@ -1465,8 +1465,8 @@ enabled = "true"[grpc_client.unified_connector_service]base_url = "http://localhost:8000"connection_timeout = 10-ucs_only_connectors = "paytm, phonepe, hyperpg, revolv3, truelayer, fiservcommercehub, trustly" # Comma-separated list of connectors that use UCS only-ucs_psync_disabled_connectors = "cashtocode" # Comma-separated list of connectors to disable UCS PSync call+ucs_only_connectors = "paytm, phonepe, hyperpg, revolv3, fiservcommercehub" # Comma-separated list of connectors that use UCS only+ucs_psync_disabled_connectors = "cashtocode, trustly" # Comma-separated list of connectors to disable UCS PSync call[revenue_recovery]monitoring_threshold_in_seconds = 60diff --git a/crates/hyperswitch_connectors/src/connectors/trustly.rs b/crates/hyperswitch_connectors/src/connectors/trustly.rsindex a882181f85..1faca9f824 100644--- a/crates/hyperswitch_connectors/src/connectors/trustly.rs+++ b/crates/hyperswitch_connectors/src/connectors/trustly.rs@@ -24,11 +24,12 @@ use hyperswitch_domain_models::{RefundsData, SetupMandateRequestData,},router_response_types::{- ConnectorInfo, PaymentsResponseData, RefundsResponseData, SupportedPaymentMethods,+ ConnectorInfo, PaymentMethodDetails, PaymentsResponseData, RefundsResponseData,+ SupportedPaymentMethods, SupportedPaymentMethodsExt,},types::{- PaymentsAuthorizeRouterData, PaymentsCaptureRouterData, PaymentsSyncRouterData,- RefundSyncRouterData, RefundsRouterData,+ PaymentsAuthorizeRouterData, PaymentsCaptureRouterData, RefundSyncRouterData,+ RefundsRouterData,},};#[cfg(feature = "payouts")]@@ -286,69 +287,7 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData}}-impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for Trustly {- fn get_headers(- &self,- req: &PaymentsSyncRouterData,- connectors: &Connectors,- ) -> CustomResult<Vec<(String, hyperswitch_masking::Maskable<String>)>, ConnectorError> {- self.build_headers(req, connectors)- }-- fn get_content_type(&self) -> &'static str {- self.common_get_content_type()- }-- fn get_url(- &self,- _req: &PaymentsSyncRouterData,- _connectors: &Connectors,- ) -> CustomResult<String, ConnectorError> {- Err(ConnectorError::NotImplemented("get_url method".to_string()).into())- }-- fn build_request(- &self,- req: &PaymentsSyncRouterData,- connectors: &Connectors,- ) -> CustomResult<Option<Request>, ConnectorError> {- Ok(Some(- RequestBuilder::new()- .method(Method::Get)- .url(&types::PaymentsSyncType::get_url(self, req, connectors)?)- .attach_default_headers()- .headers(types::PaymentsSyncType::get_headers(self, req, connectors)?)- .build(),- ))- }-- fn handle_response(- &self,- data: &PaymentsSyncRouterData,- event_builder: Option<&mut ConnectorEvent>,- res: Response,- ) -> CustomResult<PaymentsSyncRouterData, ConnectorError> {- let response: trustly::TrustlyPaymentsResponse = res- .response- .parse_struct("trustly PaymentsSyncResponse")- .change_context(ConnectorError::ResponseDeserializationFailed)?;- event_builder.map(|i| i.set_response_body(&response));- router_env::logger::info!(connector_response=?response);- RouterData::try_from(ResponseRouterData {- response,- data: data.clone(),- http_code: res.status_code,- })- }-- fn get_error_response(- &self,- res: Response,- event_builder: Option<&mut ConnectorEvent>,- ) -> CustomResult<ErrorResponse, ConnectorError> {- self.build_error_response(res, event_builder)- }-}+impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for Trustly {}impl ConnectorIntegration<Capture, PaymentsCaptureData, PaymentsResponseData> for Trustly {fn get_headers(@@ -966,8 +905,23 @@ impl webhooks::IncomingWebhook for Trustly {}}-static TRUSTLY_SUPPORTED_PAYMENT_METHODS: LazyLock<SupportedPaymentMethods> =- LazyLock::new(SupportedPaymentMethods::new);+static TRUSTLY_SUPPORTED_PAYMENT_METHODS: LazyLock<SupportedPaymentMethods> = LazyLock::new(|| {+ let supported_capture_methods = vec![enums::CaptureMethod::Automatic];++ let mut trustly_supported_payment_methods = SupportedPaymentMethods::new();+ trustly_supported_payment_methods.add(+ enums::PaymentMethod::BankRedirect,+ enums::PaymentMethodType::Trustly,+ PaymentMethodDetails {+ mandates: common_enums::FeatureStatus::NotSupported,+ refunds: common_enums::FeatureStatus::Supported,+ supported_capture_methods: supported_capture_methods.clone(),+ specific_features: None,+ },+ );++ trustly_supported_payment_methods+});static TRUSTLY_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo {display_name: "Trustly",diff --git a/crates/router/src/core/unified_connector_service.rs b/crates/router/src/core/unified_connector_service.rsindex d5c9f1f5c5..3c9aee92cb 100644--- a/crates/router/src/core/unified_connector_service.rs+++ b/crates/router/src/core/unified_connector_service.rs@@ -689,6 +689,7 @@ pub async fn should_call_unified_connector_service_for_webhooks(state: &SessionState,processor: &Processor,connector_name: &str,+ merchant_connector_id: Option<&id_type::MerchantConnectorAccountId>,) -> RouterResult<ExecutionPath> {// Extract context informationlet merchant_id = processor.get_account().get_id().get_string_repr();@@ -702,12 +703,16 @@ pub async fn should_call_unified_connector_service_for_webhooks(// Check UCS availability using idiomatic helperlet ucs_availability = check_ucs_availability(state).await;+ let connector_key = merchant_connector_id+ .map(|id| id.get_string_repr().to_owned())+ .unwrap_or_else(|| connector_name.to_string());+// Build rollout keys - webhooks don't use payment method, so use a simplified key formatlet rollout_key = format!("{}_{}_{}_{}",consts::UCS_ROLLOUT_PERCENT_CONFIG_PREFIX,merchant_id,- connector_name,+ connector_key,flow_name);diff --git a/crates/router/src/core/webhooks/incoming.rs b/crates/router/src/core/webhooks/incoming.rsindex b7a00d0652..e4638b6fd2 100644--- a/crates/router/src/core/webhooks/incoming.rs+++ b/crates/router/src/core/webhooks/incoming.rs@@ -280,6 +280,10 @@ async fn incoming_webhooks_core<W: types::OutgoingWebhookType>(&state,platform.get_processor(),&mca_data.connector_name,+ mca_data+ .merchant_connector_account+ .as_ref()+ .map(|mca| &mca.merchant_connector_id),).await?;