Skip to content

feat(core): Added support for unified_connector_service CardNumber and Secret<String> Type#9044

Merged
bernard-eugine merged 11 commits intomainfrom
ucs_card_number_type
Aug 27, 2025
Merged

feat(core): Added support for unified_connector_service CardNumber and Secret<String> Type#9044
bernard-eugine merged 11 commits intomainfrom
ucs_card_number_type

Conversation

@Debarshi-Gupta
Copy link
Contributor

@Debarshi-Gupta Debarshi-Gupta commented Aug 25, 2025

Type of Change

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

Description

Added SecretString type definition in UCS proto files which will get swapped out with hyperswitch_masking::Secret type during build. This will allow us to mask any sensitive data like card_cvc, card _exp_month etc.

In this PR, all proto request types for which masked types were added, have been handled.

Additional Changes

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

Motivation and Context

Added SecretString type definition in UCS proto files which will get swapped out with hyperswitch_masking::Secret type during build. This will allow us to mask any sensitive data like card_cvc, card _exp_month etc.

In this PR, all proto request types for which masked types were added, have been handled.

How did you test it?

Postman Tests

-Request

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_zYV0Xu6QYgNJZuZOeDHIjfk3DluWR00euuAzMdaMqRxP49SewUCvTsDxUF7Pti1g' \
--data-raw '{
    "amount": 6540,
    "currency": "USD",
    "confirm": true,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "amount_to_capture": 6540,
    "customer_id": "StripeCustomer",
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment request",
    "authentication_type": "no_three_ds",
    "return_url": "https://duck.com",
    "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_data": {
        "card": {
            "card_number": "4111111111111111",
            "card_exp_month": "03",
            "card_exp_year": "2030",
            "card_holder_name": "joseph Doe",
            "card_cvc": "737",
            "card_network": "Visa"
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "PiX"
        }
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "PiX"
        }
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    },
    "browser_info": {
        "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36",
        "accept_header": "text\\/html,application\\/xhtml+xml,application\\/xml;q=0.9,image\\/webp,image\\/apng,*\\/*;q=0.8",
        "language": "en-GB",
        "color_depth": 30,
        "screen_height": 1117,
        "screen_width": 1728,
        "time_zone": -330,
        "java_enabled": true,
        "java_script_enabled": true
    }
}'

-Response

{
    "payment_id": "pay_ti0kJ7n39hCU1Za6BA1Q",
    "merchant_id": "postman_merchant_GHAction_f7d1326e-6685-4d0a-9e2b-cfa156f58d72",
    "status": "succeeded",
    "amount": 6540,
    "net_amount": 6540,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 6540,
    "connector": "adyen",
    "client_secret": "pay_ti0kJ7n39hCU1Za6BA1Q_secret_0u8uwkwWbCZoBzgbc1Gi",
    "created": "2025-08-25T16:56:36.422Z",
    "currency": "USD",
    "customer_id": "StripeCustomer",
    "customer": {
        "id": "StripeCustomer",
        "name": "John Doe",
        "email": "guest@example.com",
        "phone": "999999999",
        "phone_country_code": "+65"
    },
    "description": "Its my first payment request",
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": null,
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "1111",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "411111",
            "card_extended_bin": null,
            "card_exp_month": "03",
            "card_exp_year": "2030",
            "card_holder_name": "joseph Doe",
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "PiX",
            "last_name": null,
            "origin_zip": null
        },
        "phone": null,
        "email": null
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "PiX",
            "last_name": null,
            "origin_zip": null
        },
        "phone": null,
        "email": null
    },
    "order_details": null,
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://duck.com/",
    "authentication_type": "no_three_ds",
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "next_action": null,
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "payment_experience": null,
    "payment_method_type": "credit",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "StripeCustomer",
        "created_at": 1756140996,
        "expires": 1756144596,
        "secret": "epk_771b7c9d4b7d496bbbe978d3d0a9cf3c"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "GC7LHGQ4H4H89PV5",
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": null,
    "feature_metadata": {
        "redirect_response": null,
        "search_tags": null,
        "apple_pay_recurring_details": null,
        "gateway_system": "unified_connector_service"
    },
    "reference_id": "pay_ti0kJ7n39hCU1Za6BA1Q_1",
    "payment_link": null,
    "profile_id": "pro_dofrMH9OfAlOx7z74Tqu",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_gGrBd8TAXH5LZWccr8Fm",
    "incremental_authorization_allowed": false,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-08-25T17:11:36.422Z",
    "fingerprint": null,
    "browser_info": {
        "language": "en-GB",
        "time_zone": -330,
        "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36",
        "color_depth": 30,
        "java_enabled": true,
        "screen_width": 1728,
        "accept_header": "text\/html,application\/xhtml+xml,application\/xml;q=0.9,image\/webp,image\/apng,*\/*;q=0.8",
        "screen_height": 1117,
        "java_script_enabled": true
    },
    "payment_channel": null,
    "payment_method_id": null,
    "network_transaction_id": null,
    "payment_method_status": null,
    "updated": "2025-08-25T16:56:37.362Z",
    "split_payments": null,
    "frm_metadata": null,
    "extended_authorization_applied": null,
    "capture_before": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null,
    "card_discovery": "manual",
    "force_3ds_challenge": false,
    "force_3ds_challenge_trigger": false,
    "issuer_error_code": null,
    "issuer_error_message": null,
    "is_iframe_redirection_enabled": null,
    "enable_partial_authorization": null
}

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

@Debarshi-Gupta Debarshi-Gupta requested review from a team as code owners August 25, 2025 06:49
@semanticdiff-com
Copy link

semanticdiff-com bot commented Aug 25, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/core/unified_connector_service.rs  69% smaller
  crates/router/src/core/unified_connector_service/transformers.rs  56% smaller
  Cargo.lock Unsupported file format
  crates/external_services/Cargo.toml Unsupported file format
  crates/router/Cargo.toml Unsupported file format

@Debarshi-Gupta Debarshi-Gupta changed the title Added support for unified_connector_service CardNumber type feat(core): Added support for unified_connector_service CardNumber and Secret<String> Type Aug 25, 2025
@Debarshi-Gupta Debarshi-Gupta self-assigned this Aug 25, 2025
@Debarshi-Gupta Debarshi-Gupta added A-core Area: Core flows A-framework Area: Framework labels Aug 25, 2025
gopikrishna000
gopikrishna000 previously approved these changes Aug 26, 2025
)?,
),
card_exp_month: Some(card_exp_month.into()),
card_exp_year: Some(card.get_expiry_year_4_digit().expose().into()),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we doing .expose().into() here?

@bernard-eugine bernard-eugine added this pull request to the merge queue Aug 27, 2025
Merged via the queue into main with commit cf64d2a Aug 27, 2025
21 of 25 checks passed
@bernard-eugine bernard-eugine deleted the ucs_card_number_type branch August 27, 2025 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-core Area: Core flows A-framework Area: Framework

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants