Skip to content

feat(router): add core changes for post and get eligibility check apis for modular authentication#10131

Merged
likhinbopanna merged 2 commits intomainfrom
add-core-changes-eligibility-api-modular-auth
Nov 7, 2025
Merged

feat(router): add core changes for post and get eligibility check apis for modular authentication#10131
likhinbopanna merged 2 commits intomainfrom
add-core-changes-eligibility-api-modular-auth

Conversation

@sai-harsha-vardhan
Copy link
Contributor

@sai-harsha-vardhan sai-harsha-vardhan commented Nov 5, 2025

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

add core changes for post and get eligibility check apis for modular authentication

POST eligibility check data api - SDK will call this api to post the eligibility check data, where we persist the data in redis if merchant config is enabled

GET eligibility check data api - Merchant will call this api, to get the eligibility check data which posted by our SDK previously

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

How did you test it?

Tested Manually

  1. Authentication Create

CURL

curl --location 'http://localhost:8080/authentication' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'x-profile-id: pro_AYrfQjQv1mXSrBxelmzy' \
--header 'x-feature: router-custom-be' \
--header 'api-key: dev_6JC7plPPZjbEpQKNcjSypowOhQ1EEhf8aSqWRiH6embO0ulKH93amC9PXLLH5MPd' \
--data-raw '{
    "amount": 10,
    "currency": "USD",
    "customer_details" : {
        "id": "sahkal1243",
        "name": "sahkal",
        "email": "sahkalplanet@gmail.com",
        "phone":"7028323872831",
        "phone_country_code": "+91"
    },
    "authentication_connector": "ctp_visa",
    "profile_id": "pro_AYrfQjQv1mXSrBxelmzy"
}'

Response

{
    "authentication_id": "authn_FtMvp5kpHQfD9L93IVcS",
    "merchant_id": "merchant_1762327680",
    "status": "started",
    "client_secret": "authn_FtMvp5kpHQfD9L93IVcS_secret_hY2gcvgiArf62p2AwNtl",
    "amount": 10,
    "currency": "USD",
    "authentication_connector": "ctp_visa",
    "force_3ds_challenge": false,
    "return_url": null,
    "created_at": "2025-11-05T07:50:43.534Z",
    "error_code": null,
    "error_message": null,
    "profile_id": "pro_AYrfQjQv1mXSrBxelmzy",
    "psd2_sca_exemption_type": null,
    "acquirer_details": {
        "acquirer_bin": null,
        "acquirer_merchant_id": null,
        "merchant_country_code": null
    },
    "profile_acquirer_id": null
}
  1. Enable merchant config for storing eligibility data

CURL

curl --location 'http://localhost:8080/configs/should_store_eligibility_check_data_for_authentication_merchant_1762327680' \
--header 'Content-Type: application/json' \
--header 'api-key: test_admin' \
--data '{
    "key": "should_store_eligibility_check_data_for_authentication_merchant_1762327680",
    "value": "true"
}'

Response

{
    "key": "should_store_eligibility_check_data_for_authentication_merchant_1762327680",
    "value": "true"
}
  1. Post eligibility check data

CURL

curl --location 'http://localhost:8080/authentication/authn_FtMvp5kpHQfD9L93IVcS/eligibility-check' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'x-profile-id: pro_AYrfQjQv1mXSrBxelmzy' \
--header 'x-feature: router-custom-be' \
--header 'api-key: dev_6JC7plPPZjbEpQKNcjSypowOhQ1EEhf8aSqWRiH6embO0ulKH93amC9PXLLH5MPd' \
--data '{
    "eligibility_check_data": {
        "click_to_pay": {
            "visa": {
                "consumerPresent": true,
                "consumerStatus": "ACTIVE",
                "customData": {
                    "locality": {
                        "country": "344",
                        "locale": "en-HK"
                    }
                }
            },
            "mastercard": {
                "consumerPresent": false,
                "idLookupSessionId": "eyJraWQiOiIyMDIzMDIyNzEzNTMzMC1wcm9kLWlkZW50aXR5LXZlcmlmaWNhdGlvbi1zcmMtbWFzdGVyY2FyZC1pbnQiLCJ0eXAiOiJKV",
                "lastUsedCardTimestamp": "1742805883",
                "supportedValidationChannels": [
                    {
                        "identityType": "EMAIL"
                    },
                    {
                        "identityType": "SMS"
                    }
                ]
            }
        }
    }
}'

Response

{
    "authentication_id": "authn_FtMvp5kpHQfD9L93IVcS",
    "sdk_next_action": "await_merchant_callback"
}

  1. Get Eligibility Data

CURL

curl --location 'http://localhost:8080/authentication/authn_FtMvp5kpHQfD9L93IVcS/eligibility-check' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'x-profile-id: pro_AYrfQjQv1mXSrBxelmzy' \
--header 'x-feature: router-custom-be' \
--header 'api-key: dev_6JC7plPPZjbEpQKNcjSypowOhQ1EEhf8aSqWRiH6embO0ulKH93amC9PXLLH5MPd'

Response

{
    "eligibility_check_data": {
        "click_to_pay_enrollment_status": {
            "visa": true,
            "mastercard": false
        }
    }
}

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible

@sai-harsha-vardhan sai-harsha-vardhan added this to the July 2025 Release milestone Nov 5, 2025
@sai-harsha-vardhan sai-harsha-vardhan self-assigned this Nov 5, 2025
@sai-harsha-vardhan sai-harsha-vardhan requested a review from a team as a code owner November 5, 2025 09:09
@sai-harsha-vardhan sai-harsha-vardhan added the A-core Area: Core flows label Nov 5, 2025
@sai-harsha-vardhan sai-harsha-vardhan requested a review from a team as a code owner November 5, 2025 09:09
@sai-harsha-vardhan sai-harsha-vardhan added the C-feature Category: Feature request or enhancement label Nov 5, 2025
@semanticdiff-com
Copy link

semanticdiff-com bot commented Nov 5, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/routes/app.rs  9% smaller
  crates/router/src/routes/authentication.rs  3% smaller
  crates/router/src/core/unified_authentication_service.rs  3% smaller
  api-reference/v1/openapi_spec_v1.json  0% smaller
  crates/api_models/src/authentication.rs  0% smaller
  crates/common_utils/src/id_type/merchant.rs  0% smaller
  crates/router/src/consts.rs  0% smaller

@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Nov 5, 2025
@sai-harsha-vardhan sai-harsha-vardhan added the T-Core For Work done by the core team label Nov 5, 2025
let sdk_next_action = eligibility_handler
.run_check(StoreEligibilityCheckData)
.await?
.unwrap_or(AuthenticationSdkNextAction::Proceed);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the eligiblity check fails we will still proceed?? then what is point of eligibility

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If eligibility check fails, sdk_next_action is sent as Deny
If there's any failure while running eligibility checks, then the error is propogated
Proceed is sent only when all the eligibility checks are run and nothing failed

@codecov
Copy link

codecov bot commented Nov 5, 2025

Codecov Report

❌ Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@166025d). Learn more about missing BASE report.

Files with missing lines Patch % Lines
crates/common_utils/src/id_type/merchant.rs 0.00% 5 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #10131   +/-   ##
=======================================
  Coverage        ?    3.89%           
=======================================
  Files           ?     1224           
  Lines           ?   303048           
  Branches        ?        0           
=======================================
  Hits            ?    11804           
  Misses          ?   291244           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@likhinbopanna likhinbopanna added this pull request to the merge queue Nov 7, 2025
Merged via the queue into main with commit d11be0e Nov 7, 2025
30 of 34 checks passed
@likhinbopanna likhinbopanna deleted the add-core-changes-eligibility-api-modular-auth branch November 7, 2025 11:35
aadityaguptaa pushed a commit that referenced this pull request Nov 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-core Area: Core flows C-feature Category: Feature request or enhancement M-api-contract-changes Metadata: This PR involves API contract changes T-Core For Work done by the core team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants