Skip to content

feat(core): Added Refund flow support for Hyperswitch <> UCS Integration#9862

Merged
bernard-eugine merged 11 commits intomainfrom
ucs-refund-integration
Oct 29, 2025
Merged

feat(core): Added Refund flow support for Hyperswitch <> UCS Integration#9862
bernard-eugine merged 11 commits intomainfrom
ucs-refund-integration

Conversation

@gopikrishna000
Copy link
Contributor

@gopikrishna000 gopikrishna000 commented Oct 15, 2025

Type of Change

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

Description

This PR implements UCS(Unified Connector Service) Integration for Refund flow, along with shadow mode for diff checker.

Additional Changes

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

Motivation and Context

Currently refund flow only uses direct connector call.
Need a divergence to ucs call based on rollout config.

How did you test it?

Create Payment Stripe
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: API_KEY' \
--data-raw '{
    "amount": 6540,
    "currency": "USD",
    "amount_to_capture": 6540,
    "confirm": true,
    "profile_id": "pro_EWeGPdvuPa9PFh3S5NKL",
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "authentication_type": "no_three_ds",
    "setup_future_usage": "on_session", 
    "customer": {
        "id": "customer123",
        "name": "John Doe",
        "email": "customer@gmail.com",
        "phone": "9999999999",
        "phone_country_code": "+1"
    },
    "customer_id": "customer123",
    "phone_country_code": "+1",
    "routing": { 
        "type": "single",
        "data": "stripe"
    },
    "description": "Its my first payment request",
    "return_url": "https://google.com",
    "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_data": { 
        "card": {
            "card_number": "4242424242424242",
            "card_exp_month": "10",
            "card_exp_year": "25",
            "card_holder_name": "joseph Doe",
            "card_cvc": "123"
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": "guest@example.com"
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": "guest@example.com"
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "order_details": [
        {
            "product_name": "Apple iphone 15",
            "quantity": 1,
            "amount": 6540,
            "account_name": "transaction_processing"
        }
    ],
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    },
    "browser_info": {
        "user_agent": "Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/70.0.3538.110 Safari\/537.36",
        "accept_header": "text\/html,application\/xhtml+xml,application\/xml;q=0.9,image\/webp,image\/apng,*\/*;q=0.8",
        "language": "nl-NL",
        "color_depth": 24,
        "screen_height": 723,
        "screen_width": 1536,
        "time_zone": 0,
        "java_enabled": true,
        "java_script_enabled": true,
        "ip_address": "128.0.0.1"
    },
    "customer_acceptance": {
        "acceptance_type": "offline",
        "accepted_at": "1963-05-03T04:07:52.723Z",
        "online": {
            "ip_address": "125.0.0.1",
            "user_agent": "amet irure esse"
        }
    },
    "connector_metadata": {
        "noon": {
            "order_category": "pay"
        }
    },
    "payment_link": false,
    "payment_link_config": {
        "theme": "",
        "logo": "",
        "seller_name": "",
        "sdk_layout": "",
        "display_sdk_only": false,
        "enabled_saved_payment_method": false
    },
    "payment_type": "normal", 
    "request_incremental_authorization": false,
    "merchant_order_reference_id": "test_ord",
    "session_expiry": 900   
}'
Refund Stripe
{
    "payment_id": "{{payment_id}}",
    "amount": 100,
    "reason": "OTHER",
    "refund_type": "instant",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    }
}
Validation Service Router data comparison image
Validation Service Refund Execute Connector Request data comparison image

metadata is actually same in both request. its just validation service parsing issue.
For eg.,
ucs actual request to connector (mitm):

image

hyperswitch actual request to connector:

image
Stripe RSync Request
curl --location 'http://localhost:8080/refunds/ref_83ruweUDFqeCH5jqFlSQ?force_sync=true' \
--header 'Accept: application/json' \
--header 'api-key: API_KEY' \
Validation Service Refund Sync Router data comparison image Note: integrity check is done in ucs, so integrity object is not set.
Validation Service Refund Sync Connector Request data comparison image Note: ucs uses GET method, hs uses POST method.. But both are correct.

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

@gopikrishna000 gopikrishna000 requested review from a team as code owners October 15, 2025 13:26
@semanticdiff-com
Copy link

semanticdiff-com bot commented Oct 15, 2025

@gopikrishna000 gopikrishna000 force-pushed the ucs-refund-integration branch 3 times, most recently from 99b9b51 to dfc72b6 Compare October 15, 2025 20:27
@gopikrishna000 gopikrishna000 linked an issue Oct 15, 2025 that may be closed by this pull request
2 tasks
@gopikrishna000 gopikrishna000 force-pushed the ucs-refund-integration branch 2 times, most recently from 2fa684c to 8f101aa Compare October 15, 2025 22:00
@gopikrishna000 gopikrishna000 force-pushed the ucs-refund-integration branch 2 times, most recently from dbceca9 to 4bddfa4 Compare October 24, 2025 15:28
@codecov
Copy link

codecov bot commented Oct 24, 2025

Codecov Report

❌ Patch coverage is 2.67062% with 328 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@8245838). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...src/core/unified_connector_service/transformers.rs 0.00% 187 Missing ⚠️
...rates/router/src/core/unified_connector_service.rs 0.00% 93 Missing ⚠️
...vices/src/grpc_client/unified_connector_service.rs 15.78% 48 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #9862   +/-   ##
=======================================
  Coverage        ?    3.92%           
=======================================
  Files           ?     1223           
  Lines           ?   300980           
  Branches        ?        0           
=======================================
  Hits            ?    11803           
  Misses          ?   289177           
  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.

jarnura
jarnura previously approved these changes Oct 27, 2025
chaitak-gorai
chaitak-gorai previously approved these changes Oct 28, 2025
jarnura
jarnura previously approved these changes Oct 29, 2025
chaitak-gorai
chaitak-gorai previously approved these changes Oct 29, 2025
jarnura
jarnura previously approved these changes Oct 29, 2025
@gopikrishna000 gopikrishna000 force-pushed the ucs-refund-integration branch 2 times, most recently from 18cdc08 to 44005a7 Compare October 29, 2025 11:24
chaitak-gorai
chaitak-gorai previously approved these changes Oct 29, 2025
jarnura
jarnura previously approved these changes Oct 29, 2025
@bernard-eugine bernard-eugine added this pull request to the merge queue Oct 29, 2025
Merged via the queue into main with commit 4bb60d0 Oct 29, 2025
25 of 27 checks passed
@bernard-eugine bernard-eugine deleted the ucs-refund-integration branch October 29, 2025 15:29
aadityaguptaa pushed a commit that referenced this pull request Nov 10, 2025
…ion (#9862)

Co-authored-by: Amitsingh Tanwar <amitsingh.tanwar@juspay.in>
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
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.

[FEATURE] Add UCS integration for Refund flow

6 participants