New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(router): send poll_config in next_action of confirm response for external 3ds flow #4443
Changes from 4 commits
60e9bd3
7cdc855
8f6991a
c68850d
c77248c
e7bca3d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,10 @@ pub mod types; | |
|
||
use api_models::payments; | ||
use common_enums::Currency; | ||
use common_utils::{errors::CustomResult, ext_traits::ValueExt}; | ||
use common_utils::{ | ||
errors::CustomResult, | ||
ext_traits::{Encode, ValueExt}, | ||
}; | ||
use error_stack::{report, ResultExt}; | ||
use masking::{ExposeInterface, PeekInterface}; | ||
|
||
|
@@ -234,9 +237,12 @@ pub async fn perform_pre_authentication<F: Clone + Send>( | |
&three_ds_connector_account, | ||
business_profile.merchant_id.clone(), | ||
)?; | ||
let router_data = | ||
utils::do_auth_connector_call(state, authentication_connector_name, router_data) | ||
.await?; | ||
let router_data = utils::do_auth_connector_call( | ||
state, | ||
authentication_connector_name.clone(), | ||
router_data, | ||
) | ||
.await?; | ||
let acquirer_details: types::AcquirerDetails = payment_connector_account | ||
.get_metadata() | ||
.get_required_value("merchant_connector_account.metadata")? | ||
|
@@ -257,6 +263,27 @@ pub async fn perform_pre_authentication<F: Clone + Send>( | |
|| authentication.authentication_status.is_failed() | ||
{ | ||
*should_continue_confirm_transaction = false; | ||
// If flow is going through external authentication, set the poll_config in payment_data which can be fetched while sending next_action block in confirm response | ||
let default_poll_config = core_types::PollConfig::default(); | ||
let default_config_str = default_poll_config | ||
.encode_to_string_of_json() | ||
.change_context(errors::ApiErrorResponse::InternalServerError) | ||
.attach_printable("Error while stringifying default poll config")?; | ||
let poll_config = state | ||
.store | ||
.find_config_by_key_unwrap_or( | ||
&format!("poll_config_external_three_ds_{authentication_connector_name}"), | ||
Some(default_config_str), | ||
) | ||
.await | ||
.change_context(errors::ApiErrorResponse::InternalServerError) | ||
.attach_printable("The poll config was not found in the DB")?; | ||
let poll_config = | ||
serde_json::from_str::<Option<core_types::PollConfig>>(&poll_config.config) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you use ParseStruct here? and in other places too where we are doing this for poll config |
||
.change_context(errors::ApiErrorResponse::InternalServerError) | ||
.attach_printable("Error while parsing PollConfig")? | ||
.unwrap_or(default_poll_config); | ||
payment_data.poll_config = Some(poll_config) | ||
} | ||
payment_data.authentication = Some(authentication); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -570,6 +570,8 @@ where | |
Some(authentication) => { | ||
if payment_intent.status == common_enums::IntentStatus::RequiresCustomerAction && authentication.cavv.is_none() && authentication.is_separate_authn_required(){ | ||
// if preAuthn and separate authentication needed. | ||
let poll_config = payment_data.poll_config.unwrap_or_default(); | ||
let request_poll_id = core_utils::get_external_authentication_request_poll_id(&payment_intent.payment_id); | ||
let payment_connector_name = payment_attempt.connector | ||
.as_ref() | ||
.get_required_value("connector")?; | ||
|
@@ -592,6 +594,7 @@ where | |
three_ds_method_data: None, | ||
three_ds_method_url: None, | ||
}), | ||
poll_config: api_models::payments::PollConfigResponse {poll_id: request_poll_id, delay_in_secs: poll_config.delay_in_secs, frequency: poll_config.frequency}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit pick. |
||
}, | ||
}) | ||
}else{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If PollConfig is a connector property, This logic can be moved into a impl function in PollConfig.