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(revenue-recovery): handle custom billing engine retries without record-back (#14850)
balakrishnacd57941c09fb
diff --git a/config/config.example.toml b/config/config.example.tomlindex 5c36b33aab..70cb334aa8 100644--- a/config/config.example.toml+++ b/config/config.example.toml@@ -1603,6 +1603,9 @@ base_url = "http://127.0.0.1:8080" #Base URL[billing_connectors_invoice_sync]billing_connectors_which_requires_invoice_sync_call = "recurly" # List of billing connectors which has invoice sync api call+[billing_connectors_invoice_record_back]+billing_connectors_which_require_invoice_record_back_call = "chargebee,stripebilling,recurly" # Billing connectors eligible for invoice record-back after a recovery payment+[billing_connectors_dispute_record_back]billing_connectors_which_requires_dispute_record_back_call = "chargebee" # List of billing connectors which support the dispute record back api calldiff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.tomlindex 0c7d27089a..3afae5331c 100644--- a/config/deployments/integration_test.toml+++ b/config/deployments/integration_test.toml@@ -1073,6 +1073,9 @@ billing_connectors_which_require_payment_sync = "stripebilling, recurly"[billing_connectors_invoice_sync]billing_connectors_which_requires_invoice_sync_call = "recurly"+[billing_connectors_invoice_record_back]+billing_connectors_which_require_invoice_record_back_call = "chargebee,stripebilling,recurly"+[billing_connectors_dispute_record_back]billing_connectors_which_requires_dispute_record_back_call = "chargebee"diff --git a/config/deployments/production.toml b/config/deployments/production.tomlindex df5765646f..9301db7cb4 100644--- a/config/deployments/production.toml+++ b/config/deployments/production.toml@@ -1088,6 +1088,9 @@ billing_connectors_which_require_payment_sync = "stripebilling, recurly"[billing_connectors_invoice_sync]billing_connectors_which_requires_invoice_sync_call = "recurly"+[billing_connectors_invoice_record_back]+billing_connectors_which_require_invoice_record_back_call = "chargebee,stripebilling,recurly"+[billing_connectors_dispute_record_back]billing_connectors_which_requires_dispute_record_back_call = "chargebee"diff --git a/config/deployments/sandbox.toml b/config/deployments/sandbox.tomlindex 47f73054e4..43385ec070 100644--- a/config/deployments/sandbox.toml+++ b/config/deployments/sandbox.toml@@ -1092,6 +1092,9 @@ billing_connectors_which_require_payment_sync = "stripebilling, recurly"[billing_connectors_invoice_sync]billing_connectors_which_requires_invoice_sync_call = "recurly"+[billing_connectors_invoice_record_back]+billing_connectors_which_require_invoice_record_back_call = "chargebee,stripebilling,recurly"+[billing_connectors_dispute_record_back]billing_connectors_which_requires_dispute_record_back_call = "chargebee"diff --git a/config/development.toml b/config/development.tomlindex dfa3f723a8..dab77fb4cb 100644--- a/config/development.toml+++ b/config/development.toml@@ -1353,6 +1353,9 @@ billing_connectors_which_require_payment_sync = "stripebilling, recurly"[billing_connectors_invoice_sync]billing_connectors_which_requires_invoice_sync_call = "recurly"+[billing_connectors_invoice_record_back]+billing_connectors_which_require_invoice_record_back_call = "chargebee,stripebilling,recurly"+[billing_connectors_dispute_record_back]billing_connectors_which_requires_dispute_record_back_call = "chargebee"diff --git a/config/docker_compose.toml b/config/docker_compose.tomlindex 8d99bb08bc..3e313bf199 100644--- a/config/docker_compose.toml+++ b/config/docker_compose.toml@@ -560,6 +560,9 @@ billing_connectors_which_require_payment_sync = "stripebilling, recurly"[billing_connectors_invoice_sync]billing_connectors_which_requires_invoice_sync_call = "recurly"+[billing_connectors_invoice_record_back]+billing_connectors_which_require_invoice_record_back_call = "chargebee,stripebilling,recurly"+[billing_connectors_dispute_record_back]billing_connectors_which_requires_dispute_record_back_call = "chargebee"diff --git a/crates/router/src/configs/secrets_transformers.rs b/crates/router/src/configs/secrets_transformers.rsindex 57d52ded39..5ea54e6a61 100644--- a/crates/router/src/configs/secrets_transformers.rs+++ b/crates/router/src/configs/secrets_transformers.rs@@ -747,6 +747,7 @@ pub(crate) async fn fetch_raw_secrets(webhook_source_verification_call: conf.webhook_source_verification_call,billing_connectors_payment_sync: conf.billing_connectors_payment_sync,billing_connectors_invoice_sync: conf.billing_connectors_invoice_sync,+ billing_connectors_invoice_record_back: conf.billing_connectors_invoice_record_back,billing_connectors_dispute_record_back: conf.billing_connectors_dispute_record_back,payment_method_auth,connector_request_reference_id_config: conf.connector_request_reference_id_config,diff --git a/crates/router/src/configs/settings.rs b/crates/router/src/configs/settings.rsindex 01de3aab16..6647a7ac76 100644--- a/crates/router/src/configs/settings.rs+++ b/crates/router/src/configs/settings.rs@@ -140,6 +140,7 @@ pub struct Settings<S: SecretState> {pub webhook_source_verification_call: WebhookSourceVerificationCall,pub billing_connectors_payment_sync: BillingConnectorPaymentsSyncCall,pub billing_connectors_invoice_sync: BillingConnectorInvoiceSyncCall,+ pub billing_connectors_invoice_record_back: BillingConnectorInvoiceRecordBackCall,pub billing_connectors_dispute_record_back: BillingConnectorDisputeRecordBackCall,pub payment_method_auth: SecretStateContainer<PaymentMethodAuth, S>,pub connector_request_reference_id_config: ConnectorRequestReferenceIdConfig,@@ -1377,6 +1378,19 @@ pub struct BillingConnectorInvoiceSyncCall {pub billing_connectors_which_requires_invoice_sync_call: HashSet<enums::Connector>,}+#[derive(Debug, Deserialize, Clone, Default)]+pub struct BillingConnectorInvoiceRecordBackCall {+ #[serde(deserialize_with = "deserialize_hashset")]+ pub billing_connectors_which_require_invoice_record_back_call: HashSet<enums::Connector>,+}++impl BillingConnectorInvoiceRecordBackCall {+ pub fn is_connector_eligible(&self, connector: enums::Connector) -> bool {+ self.billing_connectors_which_require_invoice_record_back_call+ .contains(&connector)+ }+}+#[derive(Debug, Deserialize, Clone, Default)]pub struct BillingConnectorDisputeRecordBackCall {#[serde(deserialize_with = "deserialize_hashset")]diff --git a/crates/router/src/core/revenue_recovery/types.rs b/crates/router/src/core/revenue_recovery/types.rsindex 6ad9034bfc..6a704eadab 100644--- a/crates/router/src/core/revenue_recovery/types.rs+++ b/crates/router/src/core/revenue_recovery/types.rs@@ -1566,6 +1566,16 @@ async fn record_back_to_billing_connector(logger::info!("Entering record_back_to_billing_connector");let billing_mca = &revenue_recovery_payment_data.billing_mca;+ let connector = billing_mca.connector_name;+ let invoice_record_back_config = &state.conf.billing_connectors_invoice_record_back;+ if !invoice_record_back_config.is_connector_eligible(connector) {+ logger::info!(+ %connector,+ "Skipping invoice record-back because the billing connector is not eligible"+ );+ return Ok(());+ }+let connector_name = billing_mca.connector_name.to_string();let connector_data = api_types::ConnectorData::get_connector_by_name(&state.conf.connectors,