Skip to content

Commit 752d9a7

Browse files
committed
feat(debit_routing): Handle missing merchant_business_country by defaulting to US
1 parent 5642080 commit 752d9a7

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

crates/router/src/core/debit_routing.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,17 @@ where
4949
let debit_routing_config = state.conf.debit_routing_config.clone();
5050
let debit_routing_supported_connectors = debit_routing_config.supported_connectors.clone();
5151

52-
if let Some((call_connector_type, acquirer_country)) = connector
53-
.clone()
54-
.zip(business_profile.merchant_business_country)
55-
{
52+
// If the business profile does not have a country set, we cannot perform debit routing,
53+
// because the merchant_business_country will be treated as the acquirer_country,
54+
// which is used to determine whether a transaction is local or global in the open router.
55+
// For now, since debit routing is only implemented for USD, we can safely assume the
56+
// acquirer_country is US if not provided by the merchant.
57+
58+
let acquirer_country = business_profile
59+
.merchant_business_country
60+
.unwrap_or_default();
61+
62+
if let Some(call_connector_type) = connector.clone() {
5663
debit_routing_output = match call_connector_type {
5764
ConnectorCallType::PreDetermined(connector_data) => {
5865
logger::info!("Performing debit routing for PreDetermined connector");
@@ -117,7 +124,6 @@ where
117124
{
118125
if business_profile.is_debit_routing_enabled
119126
&& state.conf.open_router.enabled
120-
&& business_profile.merchant_business_country.is_some()
121127
{
122128
logger::info!("Debit routing is enabled for the profile");
123129

0 commit comments

Comments
 (0)