Skip to content

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

fix(connector): add local bank redirect type in compatibility layer, default the country to AT for Local Bank Redirect and add creds_identifier in access token (#5038)

AkshayaFoiger655b81d69743
diff --git a/crates/router/src/compatibility/stripe/payment_intents/types.rs b/crates/router/src/compatibility/stripe/payment_intents/types.rs
index 3c7562d507..6b3054e7c3 100644
--- a/crates/router/src/compatibility/stripe/payment_intents/types.rs
+++ b/crates/router/src/compatibility/stripe/payment_intents/types.rs
@@ -946,7 +946,7 @@ fn get_pmd_based_on_payment_method_type(
.and_then(|billing_data| billing_data.get_optional_country()),
}),
),
- Some(api_enums::PaymentMethodType::LocalBankTransfer) => {
+ Some(api_enums::PaymentMethodType::LocalBankRedirect) => {
Some(payments::PaymentMethodData::BankRedirect(
payments::BankRedirectData::LocalBankRedirect {},
))
diff --git a/crates/router/src/connector/iatapay/transformers.rs b/crates/router/src/connector/iatapay/transformers.rs
index f733dcdc96..ec1deb34ce 100644
--- a/crates/router/src/connector/iatapay/transformers.rs
+++ b/crates/router/src/connector/iatapay/transformers.rs
@@ -153,32 +153,7 @@ impl
(common_enums::CountryAlpha2::NL, None, None)
}
domain::BankRedirectData::LocalBankRedirect {} => {
- let billing_country = item.router_data.get_billing_country()?;
- (
- if matches!(
- billing_country,
- common_enums::CountryAlpha2::AT
- | common_enums::CountryAlpha2::BE
- | common_enums::CountryAlpha2::DE
- | common_enums::CountryAlpha2::EE
- | common_enums::CountryAlpha2::ES
- | common_enums::CountryAlpha2::FI
- | common_enums::CountryAlpha2::FR
- | common_enums::CountryAlpha2::IE
- | common_enums::CountryAlpha2::IT
- | common_enums::CountryAlpha2::LU
- | common_enums::CountryAlpha2::LV
- | common_enums::CountryAlpha2::LT
- | common_enums::CountryAlpha2::NL
- | common_enums::CountryAlpha2::PT
- ) {
- billing_country
- } else {
- common_enums::CountryAlpha2::AT
- },
- None,
- None,
- )
+ (common_enums::CountryAlpha2::AT, None, None)
}
domain::BankRedirectData::BancontactCard { .. }
| domain::BankRedirectData::Bizum {}
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs
index 8935c3ac0e..f445d476f4 100644
--- a/crates/router/src/core/payments.rs
+++ b/crates/router/src/core/payments.rs
@@ -1461,7 +1461,12 @@ where
.await?;
let add_access_token_result = router_data
- .add_access_token(state, &connector, merchant_account)
+ .add_access_token(
+ state,
+ &connector,
+ merchant_account,
+ payment_data.creds_identifier.as_ref(),
+ )
.await?;
router_data = router_data.add_session_token(state, &connector).await?;
diff --git a/crates/router/src/core/payments/access_token.rs b/crates/router/src/core/payments/access_token.rs
index a53a3d405a..6166c256af 100644
--- a/crates/router/src/core/payments/access_token.rs
+++ b/crates/router/src/core/payments/access_token.rs
@@ -58,6 +58,7 @@ pub async fn add_access_token<
connector: &api_types::ConnectorData,
merchant_account: &domain::MerchantAccount,
router_data: &types::RouterData<F, Req, Res>,
+ creds_identifier: Option<&String>,
) -> RouterResult<types::AddAccessTokenResult> {
if connector
.connector_name
@@ -75,6 +76,7 @@ pub async fn add_access_token<
let merchant_connector_id_or_connector_name = connector
.merchant_connector_id
.clone()
+ .or(creds_identifier.cloned())
.unwrap_or(connector.connector_name.to_string());
let old_access_token = store
diff --git a/crates/router/src/core/payments/flows.rs b/crates/router/src/core/payments/flows.rs
index 4c55ebc359..f460946520 100644
--- a/crates/router/src/core/payments/flows.rs
+++ b/crates/router/src/core/payments/flows.rs
@@ -58,6 +58,7 @@ pub trait Feature<F, T> {
state: &SessionState,
connector: &api::ConnectorData,
merchant_account: &domain::MerchantAccount,
+ creds_identifier: Option<&String>,
) -> RouterResult<types::AddAccessTokenResult>
where
F: Clone,
diff --git a/crates/router/src/core/payments/flows/approve_flow.rs b/crates/router/src/core/payments/flows/approve_flow.rs
index 6d4a88c0bf..f15274ba5b 100644
--- a/crates/router/src/core/payments/flows/approve_flow.rs
+++ b/crates/router/src/core/payments/flows/approve_flow.rs
@@ -64,8 +64,10 @@ impl Feature<api::Approve, types::PaymentsApproveData>
state: &SessionState,
connector: &api::ConnectorData,
merchant_account: &domain::MerchantAccount,
+ creds_identifier: Option<&String>,
) -> RouterResult<types::AddAccessTokenResult> {
- access_token::add_access_token(state, connector, merchant_account, self).await
+ access_token::add_access_token(state, connector, merchant_account, self, creds_identifier)
+ .await
}
async fn build_flow_specific_connector_request(
diff --git a/crates/router/src/core/payments/flows/authorize_flow.rs b/crates/router/src/core/payments/flows/authorize_flow.rs
index 433274587a..26b643248a 100644
--- a/crates/router/src/core/payments/flows/authorize_flow.rs
+++ b/crates/router/src/core/payments/flows/authorize_flow.rs
@@ -97,8 +97,10 @@ impl Feature<api::Authorize, types::PaymentsAuthorizeData> for types::PaymentsAu
state: &SessionState,
connector: &api::ConnectorData,
merchant_account: &domain::MerchantAccount,
+ creds_identifier: Option<&String>,
) -> RouterResult<types::AddAccessTokenResult> {
- access_token::add_access_token(state, connector, merchant_account, self).await
+ access_token::add_access_token(state, connector, merchant_account, self, creds_identifier)
+ .await
}
async fn add_session_token<'a>(
diff --git a/crates/router/src/core/payments/flows/cancel_flow.rs b/crates/router/src/core/payments/flows/cancel_flow.rs
index 2a6774a91e..7af317bc40 100644
--- a/crates/router/src/core/payments/flows/cancel_flow.rs
+++ b/crates/router/src/core/payments/flows/cancel_flow.rs
@@ -84,8 +84,10 @@ impl Feature<api::Void, types::PaymentsCancelData>
state: &SessionState,
connector: &api::ConnectorData,
merchant_account: &domain::MerchantAccount,
+ creds_identifier: Option<&String>,
) -> RouterResult<types::AddAccessTokenResult> {
- access_token::add_access_token(state, connector, merchant_account, self).await
+ access_token::add_access_token(state, connector, merchant_account, self, creds_identifier)
+ .await
}
async fn build_flow_specific_connector_request(
diff --git a/crates/router/src/core/payments/flows/capture_flow.rs b/crates/router/src/core/payments/flows/capture_flow.rs
index 268281e515..00ff6c2d10 100644
--- a/crates/router/src/core/payments/flows/capture_flow.rs
+++ b/crates/router/src/core/payments/flows/capture_flow.rs
@@ -78,8 +78,10 @@ impl Feature<api::Capture, types::PaymentsCaptureData>
state: &SessionState,
connector: &api::ConnectorData,
merchant_account: &domain::MerchantAccount,
+ creds_identifier: Option<&String>,
) -> RouterResult<types::AddAccessTokenResult> {
- access_token::add_access_token(state, connector, merchant_account, self).await
+ access_token::add_access_token(state, connector, merchant_account, self, creds_identifier)
+ .await
}
async fn build_flow_specific_connector_request(
diff --git a/crates/router/src/core/payments/flows/complete_authorize_flow.rs b/crates/router/src/core/payments/flows/complete_authorize_flow.rs
index bb2c959f29..3a976219b6 100644
--- a/crates/router/src/core/payments/flows/complete_authorize_flow.rs
+++ b/crates/router/src/core/payments/flows/complete_authorize_flow.rs
@@ -92,8 +92,10 @@ impl Feature<api::CompleteAuthorize, types::CompleteAuthorizeData>
state: &SessionState,
connector: &api::ConnectorData,
merchant_account: &domain::MerchantAccount,
+ creds_identifier: Option<&String>,
) -> RouterResult<types::AddAccessTokenResult> {
- access_token::add_access_token(state, connector, merchant_account, self).await
+ access_token::add_access_token(state, connector, merchant_account, self, creds_identifier)
+ .await
}
async fn add_payment_method_token<'a>(
diff --git a/crates/router/src/core/payments/flows/incremental_authorization_flow.rs b/crates/router/src/core/payments/flows/incremental_authorization_flow.rs
index 58e5db8fbd..6785203e40 100644
--- a/crates/router/src/core/payments/flows/incremental_authorization_flow.rs
+++ b/crates/router/src/core/payments/flows/incremental_authorization_flow.rs
@@ -85,8 +85,10 @@ impl Feature<api::IncrementalAuthorization, types::PaymentsIncrementalAuthorizat
state: &SessionState,
connector: &api::ConnectorData,
merchant_account: &domain::MerchantAccount,
+ creds_identifier: Option<&String>,
) -> RouterResult<types::AddAccessTokenResult> {
- access_token::add_access_token(state, connector, merchant_account, self).await
+ access_token::add_access_token(state, connector, merchant_account, self, creds_identifier)
+ .await
}
async fn build_flow_specific_connector_request(
diff --git a/crates/router/src/core/payments/flows/psync_flow.rs b/crates/router/src/core/payments/flows/psync_flow.rs
index bec29f97e9..cc8e152604 100644
--- a/crates/router/src/core/payments/flows/psync_flow.rs
+++ b/crates/router/src/core/payments/flows/psync_flow.rs
@@ -104,8 +104,10 @@ impl Feature<api::PSync, types::PaymentsSyncData>
state: &SessionState,
connector: &api::ConnectorData,
merchant_account: &domain::MerchantAccount,
+ creds_identifier: Option<&String>,
) -> RouterResult<types::AddAccessTokenResult> {
- access_token::add_access_token(state, connector, merchant_account, self).await
+ access_token::add_access_token(state, connector, merchant_account, self, creds_identifier)
+ .await
}
async fn build_flow_specific_connector_request(
diff --git a/crates/router/src/core/payments/flows/reject_flow.rs b/crates/router/src/core/payments/flows/reject_flow.rs
index 865c6ea201..020e6ff101 100644
--- a/crates/router/src/core/payments/flows/reject_flow.rs
+++ b/crates/router/src/core/payments/flows/reject_flow.rs
@@ -63,8 +63,10 @@ impl Feature<api::Reject, types::PaymentsRejectData>
state: &SessionState,
connector: &api::ConnectorData,
merchant_account: &domain::MerchantAccount,
+ creds_identifier: Option<&String>,
) -> RouterResult<types::AddAccessTokenResult> {
- access_token::add_access_token(state, connector, merchant_account, self).await
+ access_token::add_access_token(state, connector, merchant_account, self, creds_identifier)
+ .await
}
async fn build_flow_specific_connector_request(
diff --git a/crates/router/src/core/payments/flows/session_flow.rs b/crates/router/src/core/payments/flows/session_flow.rs
index e279e6f7c3..ef2116a685 100644
--- a/crates/router/src/core/payments/flows/session_flow.rs
+++ b/crates/router/src/core/payments/flows/session_flow.rs
@@ -82,8 +82,10 @@ impl Feature<api::Session, types::PaymentsSessionData> for types::PaymentsSessio
state: &routes::SessionState,
connector: &api::ConnectorData,
merchant_account: &domain::MerchantAccount,
+ creds_identifier: Option<&String>,
) -> RouterResult<types::AddAccessTokenResult> {
- access_token::add_access_token(state, connector, merchant_account, self).await
+ access_token::add_access_token(state, connector, merchant_account, self, creds_identifier)
+ .await
}
}
diff --git a/crates/router/src/core/payments/flows/setup_mandate_flow.rs b/crates/router/src/core/payments/flows/setup_mandate_flow.rs
index 987d3f3380..bf5d0c047d 100644
--- a/crates/router/src/core/payments/flows/setup_mandate_flow.rs
+++ b/crates/router/src/core/payments/flows/setup_mandate_flow.rs
@@ -81,8 +81,10 @@ impl Feature<api::SetupMandate, types::SetupMandateRequestData> for types::Setup
state: &SessionState,
connector: &api::ConnectorData,
merchant_account: &domain::MerchantAccount,
+ creds_identifier: Option<&String>,
) -> RouterResult<types::AddAccessTokenResult> {
- access_token::add_access_token(state, connector, merchant_account, self).await
+ access_token::add_access_token(state, connector, merchant_account, self, creds_identifier)
+ .await
}
async fn add_payment_method_token<'a>(
diff --git a/crates/router/src/core/refunds.rs b/crates/router/src/core/refunds.rs
index 78b4762777..20b1b7a2f7 100644
--- a/crates/router/src/core/refunds.rs
+++ b/crates/router/src/core/refunds.rs
@@ -181,13 +181,19 @@ pub async fn trigger_refund_to_gateway(
payment_intent,
payment_attempt,
refund,
- creds_identifier,
+ creds_identifier.clone(),
charges,
)
.await?;
- let add_access_token_result =
- access_token::add_access_token(state, &connector, merchant_account, &router_data).await?;
+ let add_access_token_result = access_token::add_access_token(
+ state,
+ &connector,
+ merchant_account,
+ &router_data,
+ creds_identifier.as_ref(),
+ )
+ .await?;
logger::debug!(refund_router_data=?router_data);
@@ -458,13 +464,19 @@ pub async fn sync_refund_with_gateway(
payment_intent,
payment_attempt,
refund,
- creds_identifier,
+ creds_identifier.clone(),
None,
)
.await?;
- let add_access_token_result =
- access_token::add_access_token(state, &connector, merchant_account, &router_data).await?;
+ let add_access_token_result = access_token::add_access_token(
+ state,
+ &connector,
+ merchant_account,
+ &router_data,
+ creds_identifier.as_ref(),
+ )
+ .await?;
logger::debug!(refund_retrieve_router_data=?router_data);