feat(router): add start_redirection api for three_ds flow in v2 (#6470)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Sai Harsha Vardhan
2024-11-08 19:20:25 +05:30
committed by GitHub
parent 0389ae74e1
commit 6f24bb4ee3
19 changed files with 316 additions and 28 deletions

View File

@ -2,8 +2,8 @@ use common_utils::events::{ApiEventMetric, ApiEventsType};
#[cfg(feature = "v2")]
use super::{
PaymentsConfirmIntentResponse, PaymentsCreateIntentRequest, PaymentsGetIntentRequest,
PaymentsIntentResponse,
PaymentStartRedirectionRequest, PaymentsConfirmIntentResponse, PaymentsCreateIntentRequest,
PaymentsGetIntentRequest, PaymentsIntentResponse,
};
#[cfg(all(
any(feature = "v2", feature = "v1"),
@ -365,3 +365,12 @@ impl ApiEventMetric for PaymentsSessionResponse {
})
}
}
#[cfg(feature = "v2")]
impl ApiEventMetric for PaymentStartRedirectionRequest {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Payment {
payment_id: self.id.clone(),
})
}
}

View File

@ -3876,9 +3876,16 @@ pub enum NextActionType {
#[serde(tag = "type", rename_all = "snake_case")]
pub enum NextActionData {
/// Contains the url for redirection flow
#[cfg(feature = "v1")]
RedirectToUrl {
redirect_to_url: String,
},
/// Contains the url for redirection flow
#[cfg(feature = "v2")]
RedirectToUrl {
#[schema(value_type = String)]
redirect_to_url: Url,
},
/// Informs the next steps for bank transfer and also contains the charges details (ex: amount received, amount charged etc)
DisplayBankTransferInformation {
bank_transfer_steps_and_charges_details: BankTransferNextStepsData,
@ -4538,6 +4545,9 @@ pub struct PaymentsConfirmIntentResponse {
#[schema(value_type = PaymentMethodType, example = "apple_pay")]
pub payment_method_subtype: api_enums::PaymentMethodType,
/// Additional information required for redirection
pub next_action: Option<NextActionData>,
/// A unique identifier for a payment provided by the connector
#[schema(value_type = Option<String>, example = "993672945374576J")]
pub connector_transaction_id: Option<String>,
@ -4558,6 +4568,22 @@ pub struct PaymentsConfirmIntentResponse {
pub error: Option<ErrorDetails>,
}
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone)]
#[cfg(feature = "v2")]
pub struct PaymentStartRedirectionRequest {
/// Global Payment ID
pub id: id_type::GlobalPaymentId,
}
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone)]
#[cfg(feature = "v2")]
pub struct PaymentStartRedirectionParams {
/// The identifier for the Merchant Account.
pub publishable_key: String,
/// The identifier for business profile
pub profile_id: id_type::ProfileId,
}
/// Fee information to be charged on the payment being collected
#[derive(Setter, Clone, Default, Debug, PartialEq, serde::Serialize, ToSchema)]
pub struct PaymentChargeResponse {