hyperswitch-funcdiff / prs /pr_10091.json
SirajRLX's picture
Add files using upload-large-folder tool
cd3e498 verified
{
"number": 10091,
"title": "feat: add support to call ucs authorize function during complete authorize",
"description": "# feat: Enhance UCS integration with improved authentication flow and proxy selection logic\r\n\r\n## Type of Change\r\n<!-- Put an `x` in the boxes that apply -->\r\n\r\n- [ ] Bugfix\r\n- [x] New feature\r\n- [x] Enhancement\r\n- [x] Refactoring\r\n- [ ] Dependency updates\r\n- [ ] Documentation\r\n- [ ] CI/CD\r\n\r\n## Description\r\n<!-- Describe your changes in detail -->\r\n\r\nThis PR introduces significant enhancements to the Unified Connector Service (UCS) integration, focusing on authentication flow improvements and comprehensive data handling updates.\r\n\r\n### Key Changes:\r\n\r\n1. **Enhanced Authentication Flow**:\r\n - Added support for `payment_method_type` in `PaymentsAuthenticateData` and `PaymentsPostAuthenticateData`\r\n - Implemented authentication data propagation in complete authorize flow\r\n - Added new fields to `AuthenticationData` including `trans_status` and `transaction_id`\r\n - Improved authentication data conversion between domain and gRPC models\r\n\r\n2. **UCS Integration Improvements**:\r\n - Updated connector-service dependency to revision `13c6e387c81c4573d382677d19ad91e3605ba9af`\r\n - Added complete authorize flow support in UCS\r\n - Enhanced preprocessing flow handling with authentication result storage\r\n - Improved error handling and response transformation\r\n\r\n3. **Data Model Enhancements**:\r\n - Added `authentication_data` and `payment_method_type` to `CompleteAuthorizeData`\r\n - Removed deprecated `CompleteAuthorizeRedirectResponse` struct\r\n - Enhanced payment method handling in UCS transformers\r\n - Improved merchant account metadata processing\r\n\r\n4. **Logging and Monitoring**:\r\n - Enhanced `ucs_logging_wrapper` to support flow output data\r\n - Improved error tracking and metrics for UCS calls\r\n - Better debugging information for proxy selection\r\n\r\n### Additional Changes\r\n\r\n- [x] This PR modifies the API contract\r\n- [ ] This PR modifies the database schema\r\n- [x] This PR modifies application configuration/environment variables\r\n\r\n<!--\r\nProvide links to the files with corresponding changes.\r\n\r\nFollowing are the paths where you can find config files:\r\n1. `config`\r\n2. `crates/router/src/configs`\r\n3. `loadtest/config`\r\n-->\r\n\r\n## Motivation and Context\r\n<!--\r\nWhy is this change required? What problem does it solve?\r\nIf it fixes an open issue, please link to the issue here.\r\n\r\nIf you don't have an issue, we'd recommend starting with one first so the PR\r\ncan focus on the implementation (unless it is an obvious bug or documentation fix\r\nthat will have little conversation).\r\n-->\r\n\r\nThis change addresses several critical improvements in the UCS integration:\r\n\r\n1. **Authentication Flow Enhancement**: The previous implementation lacked proper authentication data propagation in complete authorize flows, leading to incomplete payment processing for 3DS transactions.\r\n\r\n2. **Performance Optimization**: The proxy selection logic was making redundant database calls and had complex decision-making logic that could be simplified for better maintainability and performance.\r\n\r\n3. **Data Consistency**: Missing fields in authentication data structures were causing issues with proper 3DS flow handling and response processing.\r\n\r\n4. **Dependency Updates**: Updated to the latest connector-service revision to leverage new features and bug fixes.\r\n\r\n## How did you test it?\r\n<!--\r\nDid you write an integration/unit/API test to verify the code changes?\r\nOr did you test this change manually (provide relevant screenshots)?\r\n-->\r\n1. Create merchant account, MCA, and cybersource connector.\r\n2. Enable UCS for cybersource. using below curls.\r\n```\r\ncurl --location 'http://localhost:8080/configs/' \\\r\n--header 'Content-Type: application/json' \\\r\n--header 'x-tenant-id: public' \\\r\n--header 'authorization: admin-api-key=test_admin' \\\r\n--header 'api-key: test_admin' \\\r\n--data '\r\n{\r\n \"key\": \"ucs_rollout_config_{merchant_id}_cybersource_card_Authorize\",\r\n \"value\": \"{\\\"rollout_percent\\\": 1.0}\"\r\n}\r\n'\r\n```\r\n```\r\ncurl --location 'http://localhost:8080/configs/' \\\r\n--header 'Content-Type: application/json' \\\r\n--header 'x-tenant-id: public' \\\r\n--header 'authorization: admin-api-key=test_admin' \\\r\n--header 'api-key: test_admin' \\\r\n--data '\r\n{\r\n \"key\": \"ucs_rollout_config_{merchant_id}_cybersource_card_CompleteAuthorize\",\r\n \"value\": \"{\\\"rollout_percent\\\": 1.0}\"\r\n}\r\n'\r\n```\r\n\r\n3. Make a 3ds payment.\r\n```\r\ncurl --location 'http://localhost:8080/payments' \\\r\n--header 'Content-Type: application/json' \\\r\n--header 'Accept: application/json' \\\r\n--header 'api-key: dev_3PqW18IEFGhqTmD1sfyvX4Z1ExVJmUIUVUDh0TCwRyj2pLUfdZO5u2mydrpxf10Y' \\\r\n--header 'x-reference-id: merchant_1758644770_payment_1' \\\r\n--data-raw '{\r\n \"amount\": 1000,\r\n \"currency\": \"USD\",\r\n \"confirm\": true,\r\n \"capture_method\": \"automatic\",\r\n \"capture_on\": \"2022-09-10T10:11:12Z\",\r\n \"customer_id\": \"StripeCustomer\",\r\n \"email\": \"guest@example.com\",\r\n \"name\": \"John Doe\",\r\n \"phone\": \"999999999\",\r\n \"phone_country_code\": \"+1\",\r\n \"description\": \"Its my first payment request\",\r\n \"authentication_type\": \"three_ds\",\r\n \"return_url\": \"https://google.com\",\r\n \"merchant_order_reference_id\": \"Payment_reference_1000\",\r\n \"payment_method\": \"card\",\r\n \"payment_method_type\": \"credit\",\r\n \"payment_method_data\": {\r\n \"card\": {\r\n \"card_number\": \"5200000000002151\",\r\n \"card_exp_month\": \"01\",\r\n \"card_exp_year\": \"2028\",\r\n \"card_holder_name\": \"joseph Doe\",\r\n \"card_cvc\": \"123\"\r\n \r\n }\r\n },\r\n \"billing\": {\r\n \"address\": {\r\n \"line1\": \"1467\",\r\n \"line2\": \"Harrison Street\",\r\n \"line3\": \"Harrison Street\",\r\n \"city\": \"San Fransico\",\r\n \"state\": \"California\",\r\n \"zip\": \"94122\",\r\n \"country\": \"US\",\r\n \"first_name\": \"joseph\",\r\n \"last_name\": \"Doe\"\r\n },\r\n \"phone\": {\r\n \"number\": \"8056594427\",\r\n \"country_code\": \"+91\"\r\n }\r\n },\r\n \"statement_descriptor_name\": \"joseph\",\r\n \"statement_descriptor_suffix\": \"JS\"\r\n}'\r\n```\r\nResponse:\r\n```\r\n{\r\n \"payment_id\": \"pay_uCWksYmUt19asmAgaSG2\",\r\n \"merchant_id\": \"merchant_1762157899\",\r\n \"status\": \"requires_customer_action\",\r\n \"amount\": 1000,\r\n \"net_amount\": 1000,\r\n \"shipping_cost\": null,\r\n \"amount_capturable\": 1000,\r\n \"amount_received\": null,\r\n \"connector\": \"cybersource\",\r\n \"client_secret\": \"pay_uCWksYmUt19asmAgaSG2_secret_1g4dDqdVVpXQihahuXR0\",\r\n \"created\": \"2025-11-03T10:12:20.663Z\",\r\n \"currency\": \"USD\",\r\n \"customer_id\": \"StripeCustomer\",\r\n \"customer\": {\r\n \"id\": \"StripeCustomer\",\r\n \"name\": \"John Doe\",\r\n \"email\": \"guest@example.com\",\r\n \"phone\": \"999999999\",\r\n \"phone_country_code\": \"+1\"\r\n },\r\n \"description\": \"Its my first payment request\",\r\n \"refunds\": null,\r\n \"disputes\": null,\r\n \"mandate_id\": null,\r\n \"mandate_data\": null,\r\n \"setup_future_usage\": null,\r\n \"off_session\": null,\r\n \"capture_on\": null,\r\n \"capture_method\": \"automatic\",\r\n \"payment_method\": \"card\",\r\n \"payment_method_data\": {\r\n \"card\": {\r\n \"last4\": \"2151\",\r\n \"card_type\": null,\r\n \"card_network\": null,\r\n \"card_issuer\": null,\r\n \"card_issuing_country\": null,\r\n \"card_isin\": \"520000\",\r\n \"card_extended_bin\": null,\r\n \"card_exp_month\": \"01\",\r\n \"card_exp_year\": \"2028\",\r\n \"card_holder_name\": \"joseph Doe\",\r\n \"payment_checks\": null,\r\n \"authentication_data\": null\r\n },\r\n \"billing\": null\r\n },\r\n \"payment_token\": \"token_trsiX1X1HNAK7poz9jtO\",\r\n \"shipping\": null,\r\n \"billing\": {\r\n \"address\": {\r\n \"city\": \"San Fransico\",\r\n \"country\": \"US\",\r\n \"line1\": \"1467\",\r\n \"line2\": \"Harrison Street\",\r\n \"line3\": \"Harrison Street\",\r\n \"zip\": \"94122\",\r\n \"state\": \"California\",\r\n \"first_name\": \"joseph\",\r\n \"last_name\": \"Doe\",\r\n \"origin_zip\": null\r\n },\r\n \"phone\": {\r\n \"number\": \"8056594427\",\r\n \"country_code\": \"+91\"\r\n },\r\n \"email\": null\r\n },\r\n \"order_details\": null,\r\n \"email\": \"guest@example.com\",\r\n \"name\": \"John Doe\",\r\n \"phone\": \"999999999\",\r\n \"return_url\": \"https://google.com/\",\r\n \"authentication_type\": \"three_ds\",\r\n \"statement_descriptor_name\": \"joseph\",\r\n \"statement_descriptor_suffix\": \"JS\",\r\n \"next_action\": {\r\n \"type\": \"redirect_to_url\",\r\n \"redirect_to_url\": \"http://localhost:8080/payments/redirect/pay_uCWksYmUt19asmAgaSG2/merchant_1762157899/pay_uCWksYmUt19asmAgaSG2_1\"\r\n },\r\n \"cancellation_reason\": null,\r\n \"error_code\": null,\r\n \"error_message\": null,\r\n \"unified_code\": null,\r\n \"unified_message\": null,\r\n \"payment_experience\": null,\r\n \"payment_method_type\": \"credit\",\r\n \"connector_label\": null,\r\n \"business_country\": null,\r\n \"business_label\": \"default\",\r\n \"business_sub_label\": null,\r\n \"allowed_payment_method_types\": null,\r\n \"ephemeral_key\": {\r\n \"customer_id\": \"StripeCustomer\",\r\n \"created_at\": 1762164739,\r\n \"expires\": 1762168339,\r\n \"secret\": \"epk_13ebbd353e144057b6a2ccfbf35a5636\"\r\n },\r\n \"manual_retry_allowed\": null,\r\n \"connector_transaction_id\": null,\r\n \"frm_message\": null,\r\n \"metadata\": null,\r\n \"connector_metadata\": null,\r\n \"feature_metadata\": {\r\n \"redirect_response\": null,\r\n \"search_tags\": null,\r\n \"apple_pay_recurring_details\": null,\r\n \"gateway_system\": \"unified_connector_service\"\r\n },\r\n \"reference_id\": \"pay_uCWksYmUt19asmAgaSG2_1\",\r\n \"payment_link\": null,\r\n \"profile_id\": \"pro_aI3SYpyPOvNnwVxWAhMg\",\r\n \"surcharge_details\": null,\r\n \"attempt_count\": 1,\r\n \"merchant_decision\": null,\r\n \"merchant_connector_id\": \"mca_Q25hV2RKehYlDxOj2Bzw\",\r\n \"incremental_authorization_allowed\": false,\r\n \"authorization_count\": null,\r\n \"incremental_authorizations\": null,\r\n \"external_authentication_details\": null,\r\n \"external_3ds_authentication_attempted\": false,\r\n \"expires_on\": \"2025-11-03T10:27:20.663Z\",\r\n \"fingerprint\": null,\r\n \"browser_info\": null,\r\n \"payment_channel\": null,\r\n \"payment_method_id\": null,\r\n \"network_transaction_id\": null,\r\n \"payment_method_status\": null,\r\n \"updated\": \"2025-11-03T10:12:24.333Z\",\r\n \"split_payments\": null,\r\n \"frm_metadata\": null,\r\n \"extended_authorization_applied\": null,\r\n \"request_extended_authorization\": null,\r\n \"capture_before\": null,\r\n \"merchant_order_reference_id\": \"Payment_reference_1000\",\r\n \"order_tax_amount\": null,\r\n \"connector_mandate_id\": null,\r\n \"card_discovery\": \"manual\",\r\n \"force_3ds_challenge\": false,\r\n \"force_3ds_challenge_trigger\": false,\r\n \"issuer_error_code\": null,\r\n \"issuer_error_message\": null,\r\n \"is_iframe_redirection_enabled\": null,\r\n \"whole_connector_response\": \"{\\\"clientReferenceInformation\\\":{\\\"code\\\":\\\"pay_uCWksYmUt19asmAgaSG2_1\\\"},\\\"consumerAuthenticationInformation\\\":{\\\"accessToken\\\":\\\"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIwZDVlZTIwYy0yZGFiLTQ3MGUtOTNkYS1lMmUyZTRmZDhmODUiLCJpYXQiOjE3NjIxNjQ3NDQsImlzcyI6IjVkZDgzYmYwMGU0MjNkMTQ5OGRjYmFjYSIsImV4cCI6MTc2MjE2ODM0NCwiT3JnVW5pdElkIjoiNjQxMDNkYTQxY2ZiOTM1ODcxMWQ3OTBmIiwiUmVmZXJlbmNlSWQiOiJkODlhZTY0Yi03NzM2LTRiYWEtYjRjYy00OTY2MTM0YjBkNTQifQ.QqhbG4QqkyY-wI4EDplHXSK2tB3C5w6L1mFOLnr5d7I\\\",\\\"deviceDataCollectionUrl\\\":\\\"https://centinelapistag.cardinalcommerce.com/V1/Cruise/Collect\\\",\\\"referenceId\\\":\\\"d89ae64b-7736-4baa-b4cc-4966134b0d54\\\",\\\"token\\\":\\\"AxizbwSTnSubHWK0F2xmAEMCT36P7wV4ApdwyaSZejFrdyoAgAAA3wgr\\\"},\\\"id\\\":\\\"7621647439916831304806\\\",\\\"status\\\":\\\"COMPLETED\\\",\\\"submitTimeUtc\\\":\\\"2025-11-03T10:12:24Z\\\"}\",\r\n \"enable_partial_authorization\": null,\r\n \"enable_overcapture\": null,\r\n \"is_overcapture_enabled\": null,\r\n \"network_details\": null,\r\n \"is_stored_credential\": null,\r\n \"mit_category\": null\r\n}\r\n```\r\n4. Copy paste `next_action.redirect_to_url` on a browser and complete redirection step.\r\n5. Do a PSync. Payment should be succeeded.\r\n6. To verify the payment actually went through UCS, search for this log line in Hyperswitch logs. `Payment gateway decision: gateway=UnifiedConnectorService`\r\n\r\n\r\n## Checklist\r\n<!-- Put an `x` in the boxes that apply -->\r\n\r\n- [ ] I formatted the code `cargo +nightly fmt --all`\r\n- [ ] I addressed lints thrown by `cargo clippy`\r\n- [x] I reviewed the submitted code\r\n- [x] I added unit tests for my changes where possible\r\n",
"author": "hrithikesh026",
"created_at": "2025-11-02T13:25:36+00:00",
"merged_at": "2025-11-05T09:26:30+00:00",
"base_branch": "main",
"labels": [],
"url": "https://github.com/juspay/hyperswitch/pull/10091",
"commits": [
{
"sha": "cbff113d7ccc54f04c978cdb8e41efe13f5b976e",
"message": "feat: add support to call ucs authorize function during complete authorize",
"author": "hrithikesh026",
"date": "2025-11-02T13:22:58+00:00",
"url": "https://github.com/juspay/hyperswitch/commit/cbff113d7ccc54f04c978cdb8e41efe13f5b976e"
},
{
"sha": "10820607b9ea2890b99940b6144fd0947309c3e4",
"message": "chore: remove dead code",
"author": "hrithikesh026",
"date": "2025-11-02T13:27:34+00:00",
"url": "https://github.com/juspay/hyperswitch/commit/10820607b9ea2890b99940b6144fd0947309c3e4"
},
{
"sha": "84564ed7025ff933ad9571470233297254881331",
"message": "Merge branch 'main' into call-ucs-for-authorize-in-complete-authorize",
"author": "Hrithikesh",
"date": "2025-11-03T07:45:30+00:00",
"url": "https://github.com/juspay/hyperswitch/commit/84564ed7025ff933ad9571470233297254881331"
},
{
"sha": "dd1f7b28d08ff77f1bd173103344c4eedcebcbe0",
"message": "chore: include ucaf collection indicator in Authentication Data",
"author": "hrithikesh026",
"date": "2025-11-03T10:15:35+00:00",
"url": "https://github.com/juspay/hyperswitch/commit/dd1f7b28d08ff77f1bd173103344c4eedcebcbe0"
},
{
"sha": "3fd244cd339037b532acc07c3b9e54d9d93bff3f",
"message": "chore: include ucaf collection indicator in Authentication Data in aci test module",
"author": "hrithikesh026",
"date": "2025-11-03T11:45:34+00:00",
"url": "https://github.com/juspay/hyperswitch/commit/3fd244cd339037b532acc07c3b9e54d9d93bff3f"
},
{
"sha": "47fcda181a329780258f06a2bc80a8f2adeae3f5",
"message": "chore: update Cargo.lock",
"author": "hyperswitch-bot[bot]",
"date": "2025-11-03T11:54:34+00:00",
"url": "https://github.com/juspay/hyperswitch/commit/47fcda181a329780258f06a2bc80a8f2adeae3f5"
},
{
"sha": "47494ff4f3bb4494b1345baef454294e1f210b2d",
"message": "chore: update UCS ref",
"author": "hrithikesh026",
"date": "2025-11-03T16:18:57+00:00",
"url": "https://github.com/juspay/hyperswitch/commit/47494ff4f3bb4494b1345baef454294e1f210b2d"
},
{
"sha": "56b642e4b014f8cbaa5396cc4b15545042639a01",
"message": "Merge remote-tracking branch 'origin/main' into call-ucs-for-authorize-in-complete-authorize",
"author": "hrithikesh026",
"date": "2025-11-03T16:28:57+00:00",
"url": "https://github.com/juspay/hyperswitch/commit/56b642e4b014f8cbaa5396cc4b15545042639a01"
},
{
"sha": "688981d089ee7a1f526d13265c1f049f95a085c2",
"message": "chore: address merge related errors",
"author": "hrithikesh026",
"date": "2025-11-03T16:59:28+00:00",
"url": "https://github.com/juspay/hyperswitch/commit/688981d089ee7a1f526d13265c1f049f95a085c2"
},
{
"sha": "9bf37bb79de5f6140736384bbe69c6af95494762",
"message": "chore: wrap large futures with Box::pin",
"author": "hrithikesh026",
"date": "2025-11-04T08:20:22+00:00",
"url": "https://github.com/juspay/hyperswitch/commit/9bf37bb79de5f6140736384bbe69c6af95494762"
},
{
"sha": "de3edfab34f5200a1e126105dc95e25358691197",
"message": "chore: wrap large futures with Box::pin",
"author": "hrithikesh026",
"date": "2025-11-04T09:18:17+00:00",
"url": "https://github.com/juspay/hyperswitch/commit/de3edfab34f5200a1e126105dc95e25358691197"
},
{
"sha": "6dbfc73f14f3d968ceaa38cb789fe042d2eae3f6",
"message": "Merge remote-tracking branch 'origin/main' into call-ucs-for-authorize-in-complete-authorize",
"author": "hrithikesh026",
"date": "2025-11-04T09:18:38+00:00",
"url": "https://github.com/juspay/hyperswitch/commit/6dbfc73f14f3d968ceaa38cb789fe042d2eae3f6"
},
{
"sha": "6462e17844c253d642b5fd80426d01d0d51ec5d5",
"message": "Merge remote-tracking branch 'origin/main' into call-ucs-for-authorize-in-complete-authorize",
"author": "hrithikesh026",
"date": "2025-11-04T09:20:38+00:00",
"url": "https://github.com/juspay/hyperswitch/commit/6462e17844c253d642b5fd80426d01d0d51ec5d5"
},
{
"sha": "6c9f662aced597b70384613e97eb37c2908baa31",
"message": "chore: run formatter",
"author": "hyperswitch-bot[bot]",
"date": "2025-11-04T09:21:41+00:00",
"url": "https://github.com/juspay/hyperswitch/commit/6c9f662aced597b70384613e97eb37c2908baa31"
},
{
"sha": "86c975c896a639c4c66d8a4d3a57661151596541",
"message": "chore: address merge related errors",
"author": "hrithikesh026",
"date": "2025-11-04T10:02:50+00:00",
"url": "https://github.com/juspay/hyperswitch/commit/86c975c896a639c4c66d8a4d3a57661151596541"
},
{
"sha": "c1e36870c548cb95440d1a75b97189dd2f5b999c",
"message": "Merge branch 'call-ucs-for-authorize-in-complete-authorize' of https://github.com/juspay/hyperswitch into call-ucs-for-authorize-in-complete-authorize",
"author": "hrithikesh026",
"date": "2025-11-04T10:19:25+00:00",
"url": "https://github.com/juspay/hyperswitch/commit/c1e36870c548cb95440d1a75b97189dd2f5b999c"
},
{
"sha": "5310ef5a4f9f5c89dda02707ea641fc7dde2f184",
"message": "chore: introduce UcsAuthenticationData",
"author": "hrithikesh026",
"date": "2025-11-04T14:56:12+00:00",
"url": "https://github.com/juspay/hyperswitch/commit/5310ef5a4f9f5c89dda02707ea641fc7dde2f184"
},
{
"sha": "0561c83f0521f458351ba7fe8104aaf818483575",
"message": "chore: revert changes done to existing AuthenticationData",
"author": "hrithikesh026",
"date": "2025-11-05T06:11:36+00:00",
"url": "https://github.com/juspay/hyperswitch/commit/0561c83f0521f458351ba7fe8104aaf818483575"
}
]
}