Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

feat(router): add api_models and openapi changes for modular auth eligibility apis (#10059)

Sai Harsha Vardhan415af87bc522
diff --git a/api-reference/docs.json b/api-reference/docs.json
index 558f38a6e6..2e11595f36 100644
--- a/api-reference/docs.json
+++ b/api-reference/docs.json
@@ -103,6 +103,14 @@
"v1/disputes/disputes--list"
]
},
+ {
+ "group": "Authentication",
+ "pages": [
+ "v1/authentication/authentication--create",
+ "v1/authentication/authentication--post-eligibility-check",
+ "v1/authentication/authentication--get-eligibility-check"
+ ]
+ },
{
"group": "Payouts",
"pages": [
diff --git a/api-reference/v1/authentication/authentication--create.mdx b/api-reference/v1/authentication/authentication--create.mdx
new file mode 100644
index 0000000000..23c3f5c8ff
--- /dev/null
+++ b/api-reference/v1/authentication/authentication--create.mdx
@@ -0,0 +1,3 @@
+---
+openapi: post /authentication
+---
\ No newline at end of file
diff --git a/api-reference/v1/authentication/authentication--get-eligibility-check.mdx b/api-reference/v1/authentication/authentication--get-eligibility-check.mdx
new file mode 100644
index 0000000000..f13f44d0f8
--- /dev/null
+++ b/api-reference/v1/authentication/authentication--get-eligibility-check.mdx
@@ -0,0 +1,3 @@
+---
+openapi: get /authentication/{authentication_id}/eligibility-check
+---
\ No newline at end of file
diff --git a/api-reference/v1/authentication/authentication--post-eligibility-check.mdx b/api-reference/v1/authentication/authentication--post-eligibility-check.mdx
new file mode 100644
index 0000000000..083f10fdc4
--- /dev/null
+++ b/api-reference/v1/authentication/authentication--post-eligibility-check.mdx
@@ -0,0 +1,3 @@
+---
+openapi: post /authentication/{authentication_id}/eligibility-check
+---
\ No newline at end of file
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.json
index 80cd3335ae..96ba9a6630 100644
--- a/api-reference/v1/openapi_spec_v1.json
+++ b/api-reference/v1/openapi_spec_v1.json
@@ -6807,6 +6807,82 @@
]
}
},
+ "/authentication/{authentication_id}/eligibility-check": {
+ "post": {
+ "tags": [
+ "Authentication"
+ ],
+ "summary": "Authentication - POST Eligibility Check",
+ "operationId": "Submit Eligibility for an Authentication",
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/AuthenticationEligibilityCheckRequest"
+ }
+ }
+ },
+ "required": true
+ },
+ "responses": {
+ "200": {
+ "description": "Eligibility Performed for the Authentication",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/AuthenticationEligibilityCheckResponse"
+ }
+ }
+ }
+ },
+ "400": {
+ "description": "Invalid data"
+ }
+ },
+ "security": [
+ {
+ "publishable_key": []
+ }
+ ]
+ },
+ "get": {
+ "tags": [
+ "Authentication"
+ ],
+ "summary": "Authentication - GET Eligibility Check",
+ "operationId": "Retrieve Eligibility Check data for an Authentication",
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/AuthenticationRetrieveEligibilityCheckRequest"
+ }
+ }
+ },
+ "required": true
+ },
+ "responses": {
+ "200": {
+ "description": "Retrieved Eligibility check data for the Authentication",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/AuthenticationRetrieveEligibilityCheckResponse"
+ }
+ }
+ }
+ },
+ "400": {
+ "description": "Invalid data"
+ }
+ },
+ "security": [
+ {
+ "api_key": []
+ }
+ ]
+ }
+ },
"/user/create_platform": {
"post": {
"tags": [
@@ -9259,6 +9335,69 @@
}
}
},
+ "AuthenticationEligibilityCheckData": {
+ "oneOf": [
+ {
+ "type": "object",
+ "required": [
+ "click_to_pay"
+ ],
+ "properties": {
+ "click_to_pay": {
+ "$ref": "#/components/schemas/ClickToPayEligibilityCheckData"
+ }
+ }
+ }
+ ]
+ },
+ "AuthenticationEligibilityCheckRequest": {
+ "type": "object",
+ "required": [
+ "eligibility_check_data"
+ ],
+ "properties": {
+ "client_secret": {
+ "type": "string",
+ "description": "Optional secret value used to identify and authorize the client making the request.\nThis can help ensure that the payment session is secure and valid.",
+ "nullable": true
+ },
+ "eligibility_check_data": {
+ "$ref": "#/components/schemas/AuthenticationEligibilityCheckData"
+ }
+ }
+ },
+ "AuthenticationEligibilityCheckResponse": {
+ "type": "object",
+ "required": [
+ "authentication_id",
+ "sdk_next_action"
+ ],
+ "properties": {
+ "authentication_id": {
+ "type": "string",
+ "description": "The unique identifier for this authentication.",
+ "example": "auth_mbabizu24mvu3mela5njyhpit4"
+ },
+ "sdk_next_action": {
+ "$ref": "#/components/schemas/AuthenticationSdkNextAction"
+ }
+ }
+ },
+ "AuthenticationEligibilityCheckResponseData": {
+ "oneOf": [
+ {
+ "type": "object",
+ "required": [
+ "click_to_pay_enrollment_status"
+ ],
+ "properties": {
+ "click_to_pay_enrollment_status": {
+ "$ref": "#/components/schemas/ClickToPayEligibilityCheckResponseData"
+ }
+ }
+ }
+ ]
+ },
"AuthenticationEligibilityRequest": {
"type": "object",
"required": [
@@ -9512,6 +9651,51 @@
}
}
},
+ "AuthenticationRetrieveEligibilityCheckRequest": {
+ "type": "object"
+ },
+ "AuthenticationRetrieveEligibilityCheckResponse": {
+ "type": "object",
+ "required": [
+ "eligibility_check_data"
+ ],
+ "properties": {
+ "eligibility_check_data": {
+ "$ref": "#/components/schemas/AuthenticationEligibilityCheckResponseData"
+ }
+ }
+ },
+ "AuthenticationSdkNextAction": {
+ "oneOf": [
+ {
+ "type": "string",
+ "description": "The next action is to await for a merchant callback",
+ "enum": [
+ "await_merchant_callback"
+ ]
+ },
+ {
+ "type": "object",
+ "required": [
+ "deny"
+ ],
+ "properties": {
+ "deny": {
+ "type": "object",
+ "description": "The next action is to deny the payment with an error message",
+ "required": [
+ "message"
+ ],
+ "properties": {
+ "message": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ ]
+ },
"AuthenticationStatus": {
"type": "string",
"enum": [
@@ -13107,6 +13291,40 @@
"add_to_unbilled_charges"
]
},
+ "ClickToPayEligibilityCheckData": {
+ "type": "object",
+ "properties": {
+ "visa": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/VisaEligibilityCheckData"
+ }
+ ],
+ "nullable": true
+ },
+ "mastercard": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/MasterCardEligibilityCheckData"
+ }
+ ],
+ "nullable": true
+ }
+ }
+ },
+ "ClickToPayEligibilityCheckResponseData": {
+ "type": "object",
+ "properties": {
+ "visa": {
+ "type": "boolean",
+ "nullable": true
+ },
+ "mastercard": {
+ "type": "boolean",
+ "nullable": true
+ }
+ }
+ },
"ClickToPaySessionResponse": {
"type": "object",
"required": [
@@ -19375,6 +19593,25 @@
}
}
},
+ "MasterCardEligibilityCheckData": {
+ "type": "object",
+ "required": [
+ "consumerPresent"
+ ],
+ "properties": {
+ "consumerPresent": {
+ "type": "boolean"
+ },
+ "idLookupSessionId": {
+ "type": "string",
+ "nullable": true
+ },
+ "lastUsedCardTimestamp": {
+ "type": "string",
+ "nullable": true
+ }
+ }
+ },
"MbWayRedirection": {
"type": "object",
"required": [
@@ -35761,6 +35998,29 @@
}
}
},
+ "VisaEligibilityCheckData": {
+ "type": "object",
+ "required": [
+ "consumerPresent"
+ ],
+ "properties": {
+ "consumerPresent": {
+ "type": "boolean"
+ },
+ "consumerStatus": {
+ "type": "string",
+ "nullable": true
+ },
+ "customData": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/BrowserInformation"
+ }
+ ],
+ "nullable": true
+ }
+ }
+ },
"VoucherData": {
"oneOf": [
{
diff --git a/crates/api_models/src/authentication.rs b/crates/api_models/src/authentication.rs
index bd3d222560..b730ee8582 100644
--- a/crates/api_models/src/authentication.rs
+++ b/crates/api_models/src/authentication.rs
@@ -158,6 +158,42 @@ impl ApiEventMetric for AuthenticationResponse {
}
}
+#[cfg(feature = "v1")]
+impl ApiEventMetric for AuthenticationEligibilityCheckRequest {
+ fn get_api_event_type(&self) -> Option<ApiEventsType> {
+ Some(ApiEventsType::Authentication {
+ authentication_id: self.authentication_id.clone(),
+ })
+ }
+}
+
+#[cfg(feature = "v1")]
+impl ApiEventMetric for AuthenticationEligibilityCheckResponse {
+ fn get_api_event_type(&self) -> Option<ApiEventsType> {
+ Some(ApiEventsType::Authentication {
+ authentication_id: self.authentication_id.clone(),
+ })
+ }
+}
+
+#[cfg(feature = "v1")]
+impl ApiEventMetric for AuthenticationRetrieveEligibilityCheckRequest {
+ fn get_api_event_type(&self) -> Option<ApiEventsType> {
+ Some(ApiEventsType::Authentication {
+ authentication_id: self.authentication_id.clone(),
+ })
+ }
+}
+
+#[cfg(feature = "v1")]
+impl ApiEventMetric for AuthenticationRetrieveEligibilityCheckResponse {
+ fn get_api_event_type(&self) -> Option<ApiEventsType> {
+ Some(ApiEventsType::Authentication {
+ authentication_id: self.authentication_id.clone(),
+ })
+ }
+}
+
#[cfg(feature = "v1")]
#[derive(Debug, Serialize, Deserialize, ToSchema)]
pub struct AuthenticationEligibilityRequest {
@@ -280,6 +316,130 @@ pub struct AuthenticationEligibilityResponse {
pub acquirer_details: Option<AcquirerDetails>,
}
+#[cfg(feature = "v1")]
+#[derive(Debug, Serialize, Deserialize, ToSchema)]
+pub struct AuthenticationEligibilityCheckRequest {
+ /// The unique identifier for this authentication.
+ /// Added in the request for api event metrics, populated from path parameter
+ #[serde(skip)]
+ pub authentication_id: id_type::AuthenticationId,
+ /// Optional secret value used to identify and authorize the client making the request.
+ /// This can help ensure that the payment session is secure and valid.
+ #[schema(value_type = Option<String>)]
+ pub client_secret: Option<masking::Secret<String>>,
+ /// The data for this authentication eligibility check.
+ pub eligibility_check_data: AuthenticationEligibilityCheckData,
+}
+
+#[cfg(feature = "v1")]
+#[derive(Debug, Serialize, ToSchema)]
+pub struct AuthenticationEligibilityCheckResponse {
+ /// The unique identifier for this authentication.
+ #[schema(value_type = String, example = "auth_mbabizu24mvu3mela5njyhpit4")]
+ pub authentication_id: id_type::AuthenticationId,
+ // The next action for this authentication eligibility check.
+ pub sdk_next_action: AuthenticationSdkNextAction,
+}
+
+#[derive(Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, Clone, ToSchema)]
+#[serde(rename_all = "snake_case")]
+pub enum AuthenticationSdkNextAction {
+ /// The next action is to await for a merchant callback
+ AwaitMerchantCallback,
+ /// The next action is to deny the payment with an error message
+ Deny { message: String },
+}
+
+#[cfg(feature = "v1")]
+#[derive(Debug, Serialize, Deserialize, ToSchema)]
+pub struct AuthenticationRetrieveEligibilityCheckRequest {
+ /// The unique identifier for this authentication.
+ /// Added in the request for api event metrics, populated from path parameter
+ #[serde(skip)]
+ pub authentication_id: id_type::AuthenticationId,
+}
+
+#[cfg(feature = "v1")]
+#[derive(Debug, Serialize, Deserialize, ToSchema)]
+pub struct AuthenticationRetrieveEligibilityCheckResponse {
+ /// The unique identifier for this authentication.
+ /// Added in the request for api event metrics, populated from path parameter
+ #[serde(skip)]
+ pub authentication_id: id_type::AuthenticationId,
+ /// The data for this authentication eligibility check.
+ pub eligibility_check_data: AuthenticationEligibilityCheckResponseData,
+}
+
+#[cfg(feature = "v1")]
+#[derive(Debug, Serialize, Deserialize, ToSchema)]
+#[serde(rename_all = "snake_case")]
+pub enum AuthenticationEligibilityCheckData {
+ ClickToPay(ClickToPayEligibilityCheckData),
+}
+
+#[cfg(feature = "v1")]
+impl AuthenticationEligibilityCheckData {
+ pub fn get_click_to_pay_data(&self) -> Option<&ClickToPayEligibilityCheckData> {
+ match self {
+ Self::ClickToPay(data) => Some(data),
+ }
+ }
+}
+
+#[cfg(feature = "v1")]
+#[derive(Debug, Serialize, Deserialize, ToSchema)]
+#[serde(rename_all = "snake_case")]
+pub enum AuthenticationEligibilityCheckResponseData {
+ ClickToPayEnrollmentStatus(ClickToPayEligibilityCheckResponseData),
+}
+
+#[cfg(feature = "v1")]
+#[derive(Debug, Serialize, Deserialize, ToSchema)]
+pub struct ClickToPayEligibilityCheckData {
+ // Visa specific eligibility check data
+ pub visa: Option<VisaEligibilityCheckData>,
+ // MasterCard specific eligibility check data
+ pub mastercard: Option<MasterCardEligibilityCheckData>,
+}
+
+#[cfg(feature = "v1")]
+#[derive(Debug, Serialize, Deserialize, ToSchema)]
+pub struct ClickToPayEligibilityCheckResponseData {
+ // Visa specific eligibility check data
+ pub visa: Option<bool>,
+ // MasterCard specific eligibility check data
+ pub mastercard: Option<bool>,
+}
+
+#[cfg(feature = "v1")]
+#[derive(Debug, Serialize, Deserialize, Clone, ToSchema)]
+#[serde(rename_all = "camelCase")]
+pub struct VisaEligibilityCheckData {
+ // Indicates whether the consumer is enrolled in Visa Secure program
+ pub consumer_present: bool,
+ // Status of the consumer in Visa Secure program]
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub consumer_status: Option<String>,
+ // Additional data for eligibility check
+ #[serde(skip_serializing_if = "Option::is_none")]
+ #[schema(value_type = Option<BrowserInformation>)]
+ pub custom_data: Option<common_utils::pii::SecretSerdeValue>,
+}
+
+#[cfg(feature = "v1")]
+#[derive(Debug, Serialize, Deserialize, Clone, ToSchema)]
+#[serde(rename_all = "camelCase")]
+pub struct MasterCardEligibilityCheckData {
+ // Indicates whether the consumer is enrolled in MasterCard Identity Check program
+ pub consumer_present: bool,
+ // Session ID from MasterCard Identity Check program
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub id_lookup_session_id: Option<String>,
+ // Timestamp of the last time the card was used
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub last_used_card_timestamp: Option<String>,
+}
+
#[derive(Debug, Serialize, ToSchema)]
pub enum EligibilityResponseParams {
ThreeDsData(ThreeDsData),
diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rs
index daa311cb2a..bff3c723e8 100644
--- a/crates/openapi/src/openapi.rs
+++ b/crates/openapi/src/openapi.rs
@@ -220,6 +220,8 @@ Never share your secret api keys. Keep them guarded and secure.
// Routes for authentication
routes::authentication::authentication_create,
+ routes::authentication::authentication_eligibility_check,
+ routes::authentication::authentication_retrieve_eligibility_check,
// Routes for platform account
routes::platform::create_platform_account,
@@ -866,6 +868,17 @@ Never share your secret api keys. Keep them guarded and secure.
euclid::frontend::dir::enums::CustomerDeviceDisplaySize,
api_models::authentication::AuthenticationCreateRequest,
api_models::authentication::AuthenticationResponse,
+ api_models::authentication::AuthenticationEligibilityCheckRequest,
+ api_models::authentication::AuthenticationEligibilityCheckResponse,
+ api_models::authentication::AuthenticationRetrieveEligibilityCheckRequest,
+ api_models::authentication::AuthenticationRetrieveEligibilityCheckResponse,
+ api_models::authentication::AuthenticationEligibilityCheckData,
+ api_models::authentication::AuthenticationEligibilityCheckResponseData,
+ api_models::authentication::ClickToPayEligibilityCheckResponseData,
+ api_models::authentication::VisaEligibilityCheckData,
+ api_models::authentication::MasterCardEligibilityCheckData,
+ api_models::authentication::AuthenticationSdkNextAction,
+ api_models::authentication::ClickToPayEligibilityCheckData,
api_models::authentication::AcquirerDetails,
api_models::authentication::NextAction,
common_utils::request::Method,
diff --git a/crates/openapi/src/routes/authentication.rs b/crates/openapi/src/routes/authentication.rs
index ebc4590bb6..239321ba2f 100644
--- a/crates/openapi/src/routes/authentication.rs
+++ b/crates/openapi/src/routes/authentication.rs
@@ -15,3 +15,35 @@
security(("api_key" = []))
)]
pub async fn authentication_create() {}
+
+/// Authentication - POST Eligibility Check
+///
+#[utoipa::path(
+ post,
+ path = "/authentication/{authentication_id}/eligibility-check",
+ request_body = AuthenticationEligibilityCheckRequest,
+ responses(
+ (status = 200, description = "Eligibility Performed for the Authentication", body = AuthenticationEligibilityCheckResponse),
+ (status = 400, description = "Invalid data")
+ ),
+ tag = "Authentication",
+ operation_id = "Submit Eligibility for an Authentication",
+ security(("publishable_key" = []))
+)]
+pub async fn authentication_eligibility_check() {}
+
+/// Authentication - GET Eligibility Check
+///
+#[utoipa::path(
+ get,
+ path = "/authentication/{authentication_id}/eligibility-check",
+ request_body = AuthenticationRetrieveEligibilityCheckRequest,
+ responses(
+ (status = 200, description = "Retrieved Eligibility check data for the Authentication", body = AuthenticationRetrieveEligibilityCheckResponse),
+ (status = 400, description = "Invalid data")
+ ),
+ tag = "Authentication",
+ operation_id = "Retrieve Eligibility Check data for an Authentication",
+ security(("api_key" = []))
+)]
+pub async fn authentication_retrieve_eligibility_check() {}
diff --git a/crates/router/src/routes/lock_utils.rs b/crates/router/src/routes/lock_utils.rs
index ff4b79d525..9f8a5add7d 100644
--- a/crates/router/src/routes/lock_utils.rs
+++ b/crates/router/src/routes/lock_utils.rs
@@ -355,7 +355,9 @@ impl From<Flow> for ApiIdentifier {
| Flow::AuthenticationEligibility
| Flow::AuthenticationSync
| Flow::AuthenticationSyncPostUpdate
- | Flow::AuthenticationAuthenticate => Self::Authentication,
+ | Flow::AuthenticationAuthenticate
+ | Flow::AuthenticationEligibilityCheck
+ | Flow::AuthenticationRetrieveEligibilityCheck => Self::Authentication,
Flow::Proxy => Self::Proxy,
Flow::ProfileAcquirerCreate | Flow::ProfileAcquirerUpdate => Self::ProfileAcquirer,
Flow::ThreeDsDecisionRuleExecute => Self::ThreeDsDecisionRule,
diff --git a/crates/router/src/services/authentication.rs b/crates/router/src/services/authentication.rs
index dcdb1ffe6f..dc5c84f6ab 100644
--- a/crates/router/src/services/authentication.rs
+++ b/crates/router/src/services/authentication.rs
@@ -4366,6 +4366,15 @@ impl ClientSecretFetch for api_models::authentication::AuthenticationAuthenticat
}
}
+#[cfg(feature = "v1")]
+impl ClientSecretFetch for api_models::authentication::AuthenticationEligibilityCheckRequest {
+ fn get_client_secret(&self) -> Option<&String> {
+ self.client_secret
+ .as_ref()
+ .map(|client_secret| client_secret.peek())
+ }
+}
+
impl ClientSecretFetch for api_models::authentication::AuthenticationSyncRequest {
fn get_client_secret(&self) -> Option<&String> {
self.client_secret
diff --git a/crates/router_env/src/logger/types.rs b/crates/router_env/src/logger/types.rs
index 98f900ace8..cdb9788fce 100644
--- a/crates/router_env/src/logger/types.rs
+++ b/crates/router_env/src/logger/types.rs
@@ -664,6 +664,10 @@ pub enum Flow {
AuthenticationSyncPostUpdate,
/// Authentication Authenticate flow
AuthenticationAuthenticate,
+ /// Authentication Eligibility Check flow
+ AuthenticationEligibilityCheck,
+ /// Authentication Retrieve Eligibility Check flow
+ AuthenticationRetrieveEligibilityCheck,
///Proxy Flow
Proxy,
/// Profile Acquirer Create flow