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)

Co-authored-by: Samraat Bansal <samraat.bansal@juspay.in>
Co-authored-by: Narayan Bhat <narayan.bhat@juspay.in>
This commit is contained in:
AkshayaFoiger
2024-06-19 16:22:38 +05:30
committed by GitHub
parent 8c7e1a3b8b
commit 655b81d697
16 changed files with 59 additions and 44 deletions

View File

@ -946,7 +946,7 @@ fn get_pmd_based_on_payment_method_type(
.and_then(|billing_data| billing_data.get_optional_country()), .and_then(|billing_data| billing_data.get_optional_country()),
}), }),
), ),
Some(api_enums::PaymentMethodType::LocalBankTransfer) => { Some(api_enums::PaymentMethodType::LocalBankRedirect) => {
Some(payments::PaymentMethodData::BankRedirect( Some(payments::PaymentMethodData::BankRedirect(
payments::BankRedirectData::LocalBankRedirect {}, payments::BankRedirectData::LocalBankRedirect {},
)) ))

View File

@ -153,32 +153,7 @@ impl
(common_enums::CountryAlpha2::NL, None, None) (common_enums::CountryAlpha2::NL, None, None)
} }
domain::BankRedirectData::LocalBankRedirect {} => { domain::BankRedirectData::LocalBankRedirect {} => {
let billing_country = item.router_data.get_billing_country()?; (common_enums::CountryAlpha2::AT, None, None)
(
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,
)
} }
domain::BankRedirectData::BancontactCard { .. } domain::BankRedirectData::BancontactCard { .. }
| domain::BankRedirectData::Bizum {} | domain::BankRedirectData::Bizum {}

View File

@ -1461,7 +1461,12 @@ where
.await?; .await?;
let add_access_token_result = router_data 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?; .await?;
router_data = router_data.add_session_token(state, &connector).await?; router_data = router_data.add_session_token(state, &connector).await?;

View File

@ -58,6 +58,7 @@ pub async fn add_access_token<
connector: &api_types::ConnectorData, connector: &api_types::ConnectorData,
merchant_account: &domain::MerchantAccount, merchant_account: &domain::MerchantAccount,
router_data: &types::RouterData<F, Req, Res>, router_data: &types::RouterData<F, Req, Res>,
creds_identifier: Option<&String>,
) -> RouterResult<types::AddAccessTokenResult> { ) -> RouterResult<types::AddAccessTokenResult> {
if connector if connector
.connector_name .connector_name
@ -75,6 +76,7 @@ pub async fn add_access_token<
let merchant_connector_id_or_connector_name = connector let merchant_connector_id_or_connector_name = connector
.merchant_connector_id .merchant_connector_id
.clone() .clone()
.or(creds_identifier.cloned())
.unwrap_or(connector.connector_name.to_string()); .unwrap_or(connector.connector_name.to_string());
let old_access_token = store let old_access_token = store

View File

@ -58,6 +58,7 @@ pub trait Feature<F, T> {
state: &SessionState, state: &SessionState,
connector: &api::ConnectorData, connector: &api::ConnectorData,
merchant_account: &domain::MerchantAccount, merchant_account: &domain::MerchantAccount,
creds_identifier: Option<&String>,
) -> RouterResult<types::AddAccessTokenResult> ) -> RouterResult<types::AddAccessTokenResult>
where where
F: Clone, F: Clone,

View File

@ -64,8 +64,10 @@ impl Feature<api::Approve, types::PaymentsApproveData>
state: &SessionState, state: &SessionState,
connector: &api::ConnectorData, connector: &api::ConnectorData,
merchant_account: &domain::MerchantAccount, merchant_account: &domain::MerchantAccount,
creds_identifier: Option<&String>,
) -> RouterResult<types::AddAccessTokenResult> { ) -> 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( async fn build_flow_specific_connector_request(

View File

@ -97,8 +97,10 @@ impl Feature<api::Authorize, types::PaymentsAuthorizeData> for types::PaymentsAu
state: &SessionState, state: &SessionState,
connector: &api::ConnectorData, connector: &api::ConnectorData,
merchant_account: &domain::MerchantAccount, merchant_account: &domain::MerchantAccount,
creds_identifier: Option<&String>,
) -> RouterResult<types::AddAccessTokenResult> { ) -> 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>( async fn add_session_token<'a>(

View File

@ -84,8 +84,10 @@ impl Feature<api::Void, types::PaymentsCancelData>
state: &SessionState, state: &SessionState,
connector: &api::ConnectorData, connector: &api::ConnectorData,
merchant_account: &domain::MerchantAccount, merchant_account: &domain::MerchantAccount,
creds_identifier: Option<&String>,
) -> RouterResult<types::AddAccessTokenResult> { ) -> 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( async fn build_flow_specific_connector_request(

View File

@ -78,8 +78,10 @@ impl Feature<api::Capture, types::PaymentsCaptureData>
state: &SessionState, state: &SessionState,
connector: &api::ConnectorData, connector: &api::ConnectorData,
merchant_account: &domain::MerchantAccount, merchant_account: &domain::MerchantAccount,
creds_identifier: Option<&String>,
) -> RouterResult<types::AddAccessTokenResult> { ) -> 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( async fn build_flow_specific_connector_request(

View File

@ -92,8 +92,10 @@ impl Feature<api::CompleteAuthorize, types::CompleteAuthorizeData>
state: &SessionState, state: &SessionState,
connector: &api::ConnectorData, connector: &api::ConnectorData,
merchant_account: &domain::MerchantAccount, merchant_account: &domain::MerchantAccount,
creds_identifier: Option<&String>,
) -> RouterResult<types::AddAccessTokenResult> { ) -> 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>( async fn add_payment_method_token<'a>(

View File

@ -85,8 +85,10 @@ impl Feature<api::IncrementalAuthorization, types::PaymentsIncrementalAuthorizat
state: &SessionState, state: &SessionState,
connector: &api::ConnectorData, connector: &api::ConnectorData,
merchant_account: &domain::MerchantAccount, merchant_account: &domain::MerchantAccount,
creds_identifier: Option<&String>,
) -> RouterResult<types::AddAccessTokenResult> { ) -> 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( async fn build_flow_specific_connector_request(

View File

@ -104,8 +104,10 @@ impl Feature<api::PSync, types::PaymentsSyncData>
state: &SessionState, state: &SessionState,
connector: &api::ConnectorData, connector: &api::ConnectorData,
merchant_account: &domain::MerchantAccount, merchant_account: &domain::MerchantAccount,
creds_identifier: Option<&String>,
) -> RouterResult<types::AddAccessTokenResult> { ) -> 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( async fn build_flow_specific_connector_request(

View File

@ -63,8 +63,10 @@ impl Feature<api::Reject, types::PaymentsRejectData>
state: &SessionState, state: &SessionState,
connector: &api::ConnectorData, connector: &api::ConnectorData,
merchant_account: &domain::MerchantAccount, merchant_account: &domain::MerchantAccount,
creds_identifier: Option<&String>,
) -> RouterResult<types::AddAccessTokenResult> { ) -> 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( async fn build_flow_specific_connector_request(

View File

@ -82,8 +82,10 @@ impl Feature<api::Session, types::PaymentsSessionData> for types::PaymentsSessio
state: &routes::SessionState, state: &routes::SessionState,
connector: &api::ConnectorData, connector: &api::ConnectorData,
merchant_account: &domain::MerchantAccount, merchant_account: &domain::MerchantAccount,
creds_identifier: Option<&String>,
) -> RouterResult<types::AddAccessTokenResult> { ) -> 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
} }
} }

View File

@ -81,8 +81,10 @@ impl Feature<api::SetupMandate, types::SetupMandateRequestData> for types::Setup
state: &SessionState, state: &SessionState,
connector: &api::ConnectorData, connector: &api::ConnectorData,
merchant_account: &domain::MerchantAccount, merchant_account: &domain::MerchantAccount,
creds_identifier: Option<&String>,
) -> RouterResult<types::AddAccessTokenResult> { ) -> 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>( async fn add_payment_method_token<'a>(

View File

@ -181,13 +181,19 @@ pub async fn trigger_refund_to_gateway(
payment_intent, payment_intent,
payment_attempt, payment_attempt,
refund, refund,
creds_identifier, creds_identifier.clone(),
charges, charges,
) )
.await?; .await?;
let add_access_token_result = let add_access_token_result = access_token::add_access_token(
access_token::add_access_token(state, &connector, merchant_account, &router_data).await?; state,
&connector,
merchant_account,
&router_data,
creds_identifier.as_ref(),
)
.await?;
logger::debug!(refund_router_data=?router_data); logger::debug!(refund_router_data=?router_data);
@ -458,13 +464,19 @@ pub async fn sync_refund_with_gateway(
payment_intent, payment_intent,
payment_attempt, payment_attempt,
refund, refund,
creds_identifier, creds_identifier.clone(),
None, None,
) )
.await?; .await?;
let add_access_token_result = let add_access_token_result = access_token::add_access_token(
access_token::add_access_token(state, &connector, merchant_account, &router_data).await?; state,
&connector,
merchant_account,
&router_data,
creds_identifier.as_ref(),
)
.await?;
logger::debug!(refund_retrieve_router_data=?router_data); logger::debug!(refund_retrieve_router_data=?router_data);