mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-01 11:06:50 +08:00
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:
@ -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 {},
|
||||||
))
|
))
|
||||||
|
|||||||
@ -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 {}
|
||||||
|
|||||||
@ -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?;
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -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,
|
||||||
|
|||||||
@ -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(
|
||||||
|
|||||||
@ -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>(
|
||||||
|
|||||||
@ -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(
|
||||||
|
|||||||
@ -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(
|
||||||
|
|||||||
@ -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>(
|
||||||
|
|||||||
@ -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(
|
||||||
|
|||||||
@ -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(
|
||||||
|
|||||||
@ -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(
|
||||||
|
|||||||
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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>(
|
||||||
|
|||||||
@ -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);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user