Skip to content

feat(core): Add Session flow support in Hyperswitch<>UCS tunnel#10552

Merged
likhinbopanna merged 8 commits intomainfrom
sdk-session-ucs
Dec 12, 2025
Merged

feat(core): Add Session flow support in Hyperswitch<>UCS tunnel#10552
likhinbopanna merged 8 commits intomainfrom
sdk-session-ucs

Conversation

@Saptak88
Copy link
Contributor

@Saptak88 Saptak88 commented Dec 5, 2025

Type of Change

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

Description

This PR adds Session flow (SDK session tokens) support for the Unified Connector Service (UCS) by implementing a new session_gateway and updating the connector service client.

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?

Rollout key:
ucs_rollout_config_wallet_Session
Shadow Rollout key:
ucs_rollout_config
_wallet_Session_shadow

Direct mode testing
Screenshot 2025-12-10 at 1 39 59 PM
Req payload

{"payment_id":"pay_DT2tAU0PaWACqu4kLaUi","client_secret":"pay_DT2tAU0PaWACqu4kLaUi_secret_yKYooiG5MEc2mdBqTxAG","wallets":[],"delayed_session_token":false}

Response

{
    "payment_id": "pay_DT2tAU0PaWACqu4kLaUi",
    "client_secret": "pay_DT2tAU0PaWACqu4kLaUi_secret_yKYooiG5MEc2mdBqTxAG",
    "session_token": [
        {
            "wallet_name": "google_pay",
            "merchant_info": {
                "merchant_id": "abc",
                "merchant_name": "abc"
            },
            "shipping_address_required": false,
            "email_required": false,
            "shipping_address_parameters": {
                "phone_number_required": false
            },
            "allowed_payment_methods": [
                {
                    "type": "CARD",
                    "parameters": {
                        "allowed_auth_methods": [
                            "PAN_ONLY"
                        ],
                        "allowed_card_networks": [
                            "AMEX",
                            "DISCOVER",
                            "INTERAC",
                            "JCB",
                            "MASTERCARD",
                            "VISA"
                        ],
                        "billing_address_required": false
                    },
                    "tokenization_specification": {
                        "type": "PAYMENT_GATEWAY",
                        "parameters": {
                            "gateway": "stripe",
                            "stripe:version": "2018-10-31",
                            "stripe:publishableKey": "pk_test_51M7fTaD5R7gDAGffAofar8mp1iheEOKC3ZFXJcKdTCnWXBFgcxqOMt5zFCswSHP9zy1KzrjctJIQCYK1h7le3dAb00O0zVhQBY"
                        }
                    }
                }
            ],
            "transaction_info": {
                "country_code": "US",
                "currency_code": "USD",
                "total_price_status": "Final",
                "total_price": "65.00"
            },
            "delayed_session_token": false,
            "connector": "stripe",
            "sdk_next_action": {
                "next_action": "confirm"
            },
            "secrets": null
        },
        {
            "wallet_name": "apple_pay",
            "payment_request_data": {
                "country_code": "US",
                "currency_code": "USD",
                "total": {
                    "label": "ApplePay",
                    "type": "final",
                    "amount": "65.00"
                },
                "merchant_capabilities": [
                    "supports3DS"
                ],
                "supported_networks": [
                    "visa",
                    "masterCard",
                    "amex",
                    "discover"
                ],
                "merchant_identifier": "merchant.hyperswitch-ucs"
            },
            "connector": "stripe",
            "delayed_session_token": false,
            "sdk_next_action": {
                "next_action": "confirm"
            },
            "connector_reference_id": null,
            "connector_sdk_public_key": null,
            "connector_merchant_id": null
        }
    ]
}

Shadow mode testing.
Testes via HS<>UCS tunnel
Req
Screenshot 2025-12-05 at 5 40 44 PM
Routerdata
Screenshot 2025-12-05 at 5 40 29 PM

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

@Saptak88 Saptak88 requested review from a team as code owners December 5, 2025 11:59
@semanticdiff-com
Copy link

semanticdiff-com bot commented Dec 5, 2025

@Saptak88 Saptak88 self-assigned this Dec 5, 2025
@codecov
Copy link

codecov bot commented Dec 5, 2025

Codecov Report

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

Files with missing lines Patch % Lines
...src/core/unified_connector_service/transformers.rs 0.00% 475 Missing ⚠️
...outer/src/core/payments/gateway/session_gateway.rs 0.00% 81 Missing ⚠️
...vices/src/grpc_client/unified_connector_service.rs 0.00% 23 Missing ⚠️
...rates/router/src/core/unified_connector_service.rs 27.27% 8 Missing ⚠️
...tes/router/src/core/payments/flows/session_flow.rs 0.00% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #10552   +/-   ##
=======================================
  Coverage        ?    6.43%           
=======================================
  Files           ?     1255           
  Lines           ?   314377           
  Branches        ?        0           
=======================================
  Hits            ?    20216           
  Misses          ?   294161           
  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.

@Saptak88 Saptak88 linked an issue Dec 5, 2025 that may be closed by this pull request
@Saptak88 Saptak88 changed the title Add Session flow support in HS<>UCS feat(core): Add Session flow support in Hyperswitch<>UCS tunnel Dec 5, 2025
}
}

impl transformers::ForeignTryFrom<common_enums::PaymentMethodType>
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't we already have this conversion logic?

Copy link
Contributor Author

@Saptak88 Saptak88 Dec 8, 2025

Choose a reason for hiding this comment

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

No we dont have, we only have from HS payment_method_data to UCS payment_method.
And in this flow only payment_method_type information is required

business_profile.get_id().clone(),
payment_data.get_creds_identifier().map(|id| id.to_string()),
);
let res = match session_connector_data.connector.get_token {
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this match statement needed?

Copy link
Contributor Author

@Saptak88 Saptak88 Dec 8, 2025

Choose a reason for hiding this comment

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

I used this match because for the other GetToken variants (except GetToken::Connector), we don’t trigger a connector call to create a session token. In those cases we don’t use execute_connector_processing_step, so routing them through the unified connector call path would end up causing unnecessary DB lookups inside the UCS decide flow.

Copy link
Contributor

Choose a reason for hiding this comment

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

this logic is already handled in decide_flows of SessionFlow

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed the match statement

hrithikesh026
hrithikesh026 previously approved these changes Dec 9, 2025
.and_then(|c| payments_grpc::CountryAlpha2::from_str_name(&c.to_string()))
.map(|country| country.into());

let merchant_account_metadata = serde_json::to_string(&router_data.connector_meta_data)
Copy link
Contributor

@AmitsinghTanwar007 AmitsinghTanwar007 Dec 10, 2025

Choose a reason for hiding this comment

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

map connector metadata with connector metadata
because then in future when someone will need this variable again we have to change the mapping
which problem is arising now.

Copy link
Contributor Author

@Saptak88 Saptak88 Dec 10, 2025

Choose a reason for hiding this comment

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

In HS connector_meta_data is the metadata provided in the MCA.
I think its correct only to call it merchant account metadata in UCS.

}),
amount: router_data.request.amount,
currency: currency.into(),
minor_amount: router_data.request.amount,
Copy link
Contributor

Choose a reason for hiding this comment

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

In minor amount pass minor amount from the PaymentSessionData

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

hrithikesh026
hrithikesh026 previously approved these changes Dec 12, 2025
gopikrishna000
gopikrishna000 previously approved these changes Dec 12, 2025
@likhinbopanna likhinbopanna added this pull request to the merge queue Dec 12, 2025
Merged via the queue into main with commit 00c62d4 Dec 12, 2025
26 of 27 checks passed
@likhinbopanna likhinbopanna deleted the sdk-session-ucs branch December 12, 2025 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Introduce Session flow support in Hyperswitch<>UCS tunnel

5 participants