mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 11:24:45 +08:00
feat(core): Implement 3ds decision manger for V2 (#7022)
This commit is contained in:
@ -15,10 +15,12 @@ v2 = ["common_utils/v2"]
|
||||
diesel = "2.2.3"
|
||||
serde = { version = "1.0.197", features = ["derive"] }
|
||||
serde_json = "1.0.115"
|
||||
strum = { version = "0.26", features = ["derive"] }
|
||||
utoipa = { version = "4.2.0", features = ["preserve_order", "preserve_path_order"] }
|
||||
|
||||
common_enums = { version = "0.1.0", path = "../common_enums" }
|
||||
common_utils = { version = "0.1.0", path = "../common_utils"}
|
||||
euclid = { version = "0.1.0", path = "../euclid" }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
@ -3,8 +3,12 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use common_enums::enums;
|
||||
use common_utils::{errors, impl_to_sql_from_sql_json, types::MinorUnit};
|
||||
use common_utils::{errors, events, impl_to_sql_from_sql_json, types::MinorUnit};
|
||||
use diesel::{sql_types::Jsonb, AsExpression, FromSqlRow};
|
||||
use euclid::frontend::{
|
||||
ast::Program,
|
||||
dir::{DirKeyKind, EuclidDirFilter},
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use utoipa::ToSchema;
|
||||
|
||||
@ -21,26 +25,6 @@ pub enum SplitPaymentsRequest {
|
||||
}
|
||||
impl_to_sql_from_sql_json!(SplitPaymentsRequest);
|
||||
|
||||
#[derive(
|
||||
Serialize, Deserialize, Debug, Clone, PartialEq, Eq, FromSqlRow, AsExpression, ToSchema,
|
||||
)]
|
||||
#[diesel(sql_type = Jsonb)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
/// Fee information for Split Payments to be charged on the payment being collected for Stripe
|
||||
pub struct StripeSplitPaymentRequest {
|
||||
/// Stripe's charge type
|
||||
#[schema(value_type = PaymentChargeType, example = "direct")]
|
||||
pub charge_type: enums::PaymentChargeType,
|
||||
|
||||
/// Platform fees to be collected on the payment
|
||||
#[schema(value_type = i64, example = 6540)]
|
||||
pub application_fees: MinorUnit,
|
||||
|
||||
/// Identifier for the reseller's account to send the funds to
|
||||
pub transfer_account_id: String,
|
||||
}
|
||||
impl_to_sql_from_sql_json!(StripeSplitPaymentRequest);
|
||||
|
||||
#[derive(
|
||||
Serialize, Deserialize, Debug, Clone, PartialEq, Eq, FromSqlRow, AsExpression, ToSchema,
|
||||
)]
|
||||
@ -65,3 +49,70 @@ impl AuthenticationConnectorAccountMap {
|
||||
.cloned()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Serialize, Deserialize, Debug, Clone, PartialEq, Eq, FromSqlRow, AsExpression, ToSchema,
|
||||
)]
|
||||
#[diesel(sql_type = Jsonb)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
/// Fee information for Split Payments to be charged on the payment being collected for Stripe
|
||||
pub struct StripeSplitPaymentRequest {
|
||||
/// Stripe's charge type
|
||||
#[schema(value_type = PaymentChargeType, example = "direct")]
|
||||
pub charge_type: enums::PaymentChargeType,
|
||||
|
||||
/// Platform fees to be collected on the payment
|
||||
#[schema(value_type = i64, example = 6540)]
|
||||
pub application_fees: MinorUnit,
|
||||
|
||||
/// Identifier for the reseller's account to send the funds to
|
||||
pub transfer_account_id: String,
|
||||
}
|
||||
impl_to_sql_from_sql_json!(StripeSplitPaymentRequest);
|
||||
|
||||
#[derive(
|
||||
Serialize, Default, Deserialize, Debug, Clone, PartialEq, Eq, FromSqlRow, AsExpression, ToSchema,
|
||||
)]
|
||||
#[diesel(sql_type = Jsonb)]
|
||||
/// ConditionalConfigs
|
||||
pub struct ConditionalConfigs {
|
||||
/// Override 3DS
|
||||
pub override_3ds: Option<common_enums::AuthenticationType>,
|
||||
}
|
||||
impl EuclidDirFilter for ConditionalConfigs {
|
||||
const ALLOWED: &'static [DirKeyKind] = &[
|
||||
DirKeyKind::PaymentMethod,
|
||||
DirKeyKind::CardType,
|
||||
DirKeyKind::CardNetwork,
|
||||
DirKeyKind::MetaData,
|
||||
DirKeyKind::PaymentAmount,
|
||||
DirKeyKind::PaymentCurrency,
|
||||
DirKeyKind::CaptureMethod,
|
||||
DirKeyKind::BillingCountry,
|
||||
DirKeyKind::BusinessCountry,
|
||||
];
|
||||
}
|
||||
|
||||
impl_to_sql_from_sql_json!(ConditionalConfigs);
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, FromSqlRow, AsExpression, ToSchema)]
|
||||
#[diesel(sql_type = Jsonb)]
|
||||
/// DecisionManagerRecord
|
||||
pub struct DecisionManagerRecord {
|
||||
/// Name of the Decision Manager
|
||||
pub name: String,
|
||||
/// Program to be executed
|
||||
pub program: Program<ConditionalConfigs>,
|
||||
/// Created at timestamp
|
||||
pub created_at: i64,
|
||||
}
|
||||
|
||||
impl events::ApiEventMetric for DecisionManagerRecord {
|
||||
fn get_api_event_type(&self) -> Option<events::ApiEventsType> {
|
||||
Some(events::ApiEventsType::Routing)
|
||||
}
|
||||
}
|
||||
impl_to_sql_from_sql_json!(DecisionManagerRecord);
|
||||
|
||||
/// DecisionManagerResponse
|
||||
pub type DecisionManagerResponse = DecisionManagerRecord;
|
||||
|
||||
Reference in New Issue
Block a user