refactor(paymentMethods): move all pm migration related changes to payment methods crate

## Type of Change
<!-- Put an `x` in the boxes that apply -->

- [ ] Bugfix
- [ ] New feature
- [ ] Enhancement
- [X] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD

## Description
<!-- Describe your changes in detail -->
This PR moves all payment method migration related code and functionality from the router crate to the payment_methods crate. This refactoring improves code organization and maintainability by keeping payment method related logic in a dedicated crate.

### Additional Changes

- [ ] This PR modifies the API contract
- [ ] This PR modifies the database schema
- [ ] This PR modifies application configuration/environment variables

<!--
Provide links to the files with corresponding changes.

Following are the paths where you can find config files:
1. `config`
2. `crates/router/src/configs`
3. `loadtest/config`
-->


## Motivation and Context
<!--
Why is this change required? What problem does it solve?
If it fixes an open issue, please link to the issue here.

If you don't have an issue, we'd recommend starting with one first so the PR
can focus on the implementation (unless it is an obvious bug or documentation fix
that will have little conversation).
-->

- Moved payment method migration handlers to the payment_methods crate
- Refactored migration-related data structures and types
- Updated feature flags and conditional compilation blocks
- Improved error handling and response types for migration operations
- Support for network token migration
- Enhanced payment method data validation during migration

- Added migration-specific types and structs in the payment_methods crate
- Implemented proper error handling and status tracking for migration operations
- Added support for migrating various payment method attributes:
  - Card details
  - Network tokens
  - Connector mandate details
  - Network transaction IDs
- Improved validation and error reporting during migration

## How did you test it?
<!--
Did you write an integration/unit/API test to verify the code changes?
Or did you test this change manually (provide relevant screenshots)?
-->



1. Create a Merchant, API Key, Business profile, Connector, and a customer
<details>
<summary>Create on-session payment with the created customer</summary>

Request

    curl --location 'http://localhost:8080/payments' \
    --header 'Content-Type: application/json' \
    --header 'Accept: application/json' \
    --header 'api-key: dev_FnltW73uMOCcEBApQnrAFpC4E570KVRJWzevF3NMlZS15o13tdMU60eh1wtqz3rc' \
    --data-raw '{
        "amount": 1000,
        "currency": "USD",
        "confirm": false,
        "capture_method": "automatic",
        "authentication_type": "no_three_ds",
        "customer_id": "cus_qmEvJXTwol5oGfYQL25C",
        "profile_id": "pro_5VR03thJTJH5WVRNXDSp",
        "email": "hyperswitch_sdk_demo_id@gmail.com",
        "description": "Hello this is description",
        "shipping": {
            "address": {
                "state": "zsaasdas",
                "city": "Banglore",
                "country": "US",
                "line1": "sdsdfsdf",
                "line2": "hsgdbhd",
                "line3": "alsksoe",
                "zip": "571201",
                "first_name": "joseph",
                "last_name": "doe"
            },
            "phone": {
                "number": "123456789",
                "country_code": "+1"
            }
        },
        "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": "123456789",
                "country_code": "+1"
            }
        },
        "setup_future_usage": "on_session",
        "order_details": null
    }'
Response

    {
        "payment_id": "pay_qmwSjRRAsWceStL7ZlWP",
        "merchant_id": "merchant_1744875358",
        "status": "requires_payment_method",
        "amount": 1000,
        "net_amount": 1000,
        "shipping_cost": null,
        "amount_capturable": 0,
        "amount_received": null,
        "connector": null,
        "client_secret": "pay_qmwSjRRAsWceStL7ZlWP_secret_qpwNxseYRkppM8dQLGJ2",
        "created": "2025-04-17T08:26:19.988Z",
        "currency": "USD",
        "customer_id": "cus_qmEvJXTwol5oGfYQL25C",
        "customer": {
            "id": "cus_qmEvJXTwol5oGfYQL25C",
            "name": "John Doe",
            "email": "hyperswitch_sdk_demo_id@gmail.com",
            "phone": "999999999",
            "phone_country_code": "+65"
        },
        "description": "Hello this is description",
        "refunds": null,
        "disputes": null,
        "mandate_id": null,
        "mandate_data": null,
        "setup_future_usage": "on_session",
        "off_session": null,
        "capture_on": null,
        "capture_method": "automatic",
        "payment_method": null,
        "payment_method_data": null,
        "payment_token": null,
        "shipping": {
            "address": {
                "city": "Banglore",
                "country": "US",
                "line1": "sdsdfsdf",
                "line2": "hsgdbhd",
                "line3": "alsksoe",
                "zip": "571201",
                "state": "zsaasdas",
                "first_name": "joseph",
                "last_name": "doe"
            },
            "phone": {
                "number": "123456789",
                "country_code": "+1"
            },
            "email": null
        },
        "billing": {
            "address": {
                "city": "San Fransico",
                "country": "US",
                "line1": "1467",
                "line2": "Harrison Street",
                "line3": "Harrison Street",
                "zip": "94122",
                "state": "California",
                "first_name": "joseph",
                "last_name": "Doe"
            },
            "phone": {
                "number": "123456789",
                "country_code": "+1"
            },
            "email": null
        },
        "order_details": null,
        "email": "hyperswitch_sdk_demo_id@gmail.com",
        "name": "John Doe",
        "phone": "999999999",
        "return_url": null,
        "authentication_type": "no_three_ds",
        "statement_descriptor_name": null,
        "statement_descriptor_suffix": null,
        "next_action": null,
        "cancellation_reason": null,
        "error_code": null,
        "error_message": null,
        "unified_code": null,
        "unified_message": null,
        "payment_experience": null,
        "payment_method_type": null,
        "connector_label": null,
        "business_country": null,
        "business_label": "default",
        "business_sub_label": null,
        "allowed_payment_method_types": null,
        "ephemeral_key": {
            "customer_id": "cus_qmEvJXTwol5oGfYQL25C",
            "created_at": 1744878379,
            "expires": 1744881979,
            "secret": "epk_73acc74e655e4163ba338a637b1248aa"
        },
        "manual_retry_allowed": null,
        "connector_transaction_id": null,
        "frm_message": null,
        "metadata": null,
        "connector_metadata": null,
        "feature_metadata": null,
        "reference_id": null,
        "payment_link": null,
        "profile_id": "pro_5VR03thJTJH5WVRNXDSp",
        "surcharge_details": null,
        "attempt_count": 1,
        "merchant_decision": null,
        "merchant_connector_id": null,
        "incremental_authorization_allowed": null,
        "authorization_count": null,
        "incremental_authorizations": null,
        "external_authentication_details": null,
        "external_3ds_authentication_attempted": false,
        "expires_on": "2025-04-17T08:41:19.988Z",
        "fingerprint": null,
        "browser_info": null,
        "payment_method_id": null,
        "payment_method_status": null,
        "updated": "2025-04-17T08:26:20.045Z",
        "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": null,
        "force_3ds_challenge": false,
        "force_3ds_challenge_trigger": false,
        "issuer_error_code": null,
        "issuer_error_message": null
    }

</details>

<details>
<summary>Confirm the payment</summary>

Request
    
    curl --location 'http://localhost:8080/payments/pay_qmwSjRRAsWceStL7ZlWP/confirm' \
    --header 'Content-Type: application/json' \
    --header 'Accept: application/json' \
    --header 'api-key: pk_dev_83200543d7d045f89bd4aa0d9475a63a' \
    --data '{
        "payment_method": "card",
        "payment_method_type": "credit",
        "client_secret": "pay_qmwSjRRAsWceStL7ZlWP_secret_qpwNxseYRkppM8dQLGJ2",
        "profile_id": "pro_5VR03thJTJH5WVRNXDSp",
        "payment_method_data": {
            "card": {
                "card_number": "4111111111111111",
                "card_exp_month": "03",
                "card_exp_year": "2030",
                "card_holder_name": "CLBRW dffdg",
                "card_cvc": "737"
            }
        },
        "payment_type": "new_mandate",
        "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"
            }
        }
    }'

Response

    {
        "payment_id": "pay_qmwSjRRAsWceStL7ZlWP",
        "merchant_id": "merchant_1744875358",
        "status": "succeeded",
        "amount": 1000,
        "net_amount": 1000,
        "shipping_cost": null,
        "amount_capturable": 0,
        "amount_received": 1000,
        "connector": "cybersource",
        "client_secret": "pay_qmwSjRRAsWceStL7ZlWP_secret_qpwNxseYRkppM8dQLGJ2",
        "created": "2025-04-17T08:26:19.988Z",
        "currency": "USD",
        "customer_id": "cus_qmEvJXTwol5oGfYQL25C",
        "customer": {
            "id": "cus_qmEvJXTwol5oGfYQL25C",
            "name": "John Doe",
            "email": "hyperswitch_sdk_demo_id@gmail.com",
            "phone": "999999999",
            "phone_country_code": "+65"
        },
        "description": "Hello this is description",
        "refunds": null,
        "disputes": null,
        "mandate_id": null,
        "mandate_data": null,
        "setup_future_usage": "on_session",
        "off_session": null,
        "capture_on": null,
        "capture_method": "automatic",
        "payment_method": "card",
        "payment_method_data": {
            "card": {
                "last4": "1111",
                "card_type": "CREDIT",
                "card_network": "Visa",
                "card_issuer": "JP Morgan",
                "card_issuing_country": "INDIA",
                "card_isin": "411111",
                "card_extended_bin": null,
                "card_exp_month": "03",
                "card_exp_year": "2030",
                "card_holder_name": "CLBRW dffdg",
                "payment_checks": {
                    "avs_response": {
                        "code": "Y",
                        "codeRaw": "Y"
                    },
                    "card_verification": null
                },
                "authentication_data": null
            },
            "billing": null
        },
        "payment_token": "token_DirGLr4ZuG0YQLDjnthZ",
        "shipping": {
            "address": {
                "city": "Banglore",
                "country": "US",
                "line1": "sdsdfsdf",
                "line2": "hsgdbhd",
                "line3": "alsksoe",
                "zip": "571201",
                "state": "zsaasdas",
                "first_name": "joseph",
                "last_name": "doe"
            },
            "phone": {
                "number": "123456789",
                "country_code": "+1"
            },
            "email": null
        },
        "billing": {
            "address": {
                "city": "San Fransico",
                "country": "US",
                "line1": "1467",
                "line2": "Harrison Street",
                "line3": "Harrison Street",
                "zip": "94122",
                "state": "California",
                "first_name": "joseph",
                "last_name": "Doe"
            },
            "phone": {
                "number": "123456789",
                "country_code": "+1"
            },
            "email": null
        },
        "order_details": null,
        "email": "hyperswitch_sdk_demo_id@gmail.com",
        "name": "John Doe",
        "phone": "999999999",
        "return_url": null,
        "authentication_type": "no_three_ds",
        "statement_descriptor_name": null,
        "statement_descriptor_suffix": null,
        "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": null,
        "manual_retry_allowed": false,
        "connector_transaction_id": "7448785550036549704805",
        "frm_message": null,
        "metadata": null,
        "connector_metadata": null,
        "feature_metadata": null,
        "reference_id": "pay_qmwSjRRAsWceStL7ZlWP_1",
        "payment_link": null,
        "profile_id": "pro_5VR03thJTJH5WVRNXDSp",
        "surcharge_details": null,
        "attempt_count": 1,
        "merchant_decision": null,
        "merchant_connector_id": "mca_4cXM5Pc7p96fCmB2oZim",
        "incremental_authorization_allowed": false,
        "authorization_count": null,
        "incremental_authorizations": null,
        "external_authentication_details": null,
        "external_3ds_authentication_attempted": false,
        "expires_on": "2025-04-17T08:41:19.988Z",
        "fingerprint": null,
        "browser_info": {
            "os_type": null,
            "language": null,
            "time_zone": null,
            "ip_address": "::1",
            "os_version": null,
            "user_agent": null,
            "color_depth": null,
            "device_model": null,
            "java_enabled": null,
            "screen_width": null,
            "accept_header": null,
            "screen_height": null,
            "accept_language": "en",
            "java_script_enabled": null
        },
        "payment_method_id": null,
        "payment_method_status": null,
        "updated": "2025-04-17T08:29:15.447Z",
        "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
    }
</details>

<details>
<summary>List customer Payment Methods</summary>

Request

    curl --location 'http://localhost:8080/customers/cus_qmEvJXTwol5oGfYQL25C/payment_methods' \
    --header 'Accept: application/json' \
    --header 'api-key: dev_FnltW73uMOCcEBApQnrAFpC4E570KVRJWzevF3NMlZS15o13tdMU60eh1wtqz3rc'

Response

    {
        "customer_payment_methods": [
            {
                "payment_token": "token_C0qM39EOKWuXXaZiqleE",
                "payment_method_id": "pm_pLVoa3evTaZFbZzjLA8s",
                "customer_id": "cus_qmEvJXTwol5oGfYQL25C",
                "payment_method": "card",
                "payment_method_type": "credit",
                "payment_method_issuer": "JP Morgan",
                "payment_method_issuer_code": null,
                "recurring_enabled": false,
                "installment_payment_enabled": false,
                "payment_experience": [
                    "redirect_to_url"
                ],
                "card": {
                    "scheme": "Visa",
                    "issuer_country": "INDIA",
                    "last4_digits": "1111",
                    "expiry_month": "03",
                    "expiry_year": "2030",
                    "card_token": null,
                    "card_holder_name": "CLBRW dffdg",
                    "card_fingerprint": null,
                    "nick_name": null,
                    "card_network": "Visa",
                    "card_isin": "411111",
                    "card_issuer": "JP Morgan",
                    "card_type": "CREDIT",
                    "saved_to_locker": true
                },
                "metadata": null,
                "created": "2025-04-17T08:29:15.455Z",
                "bank": null,
                "surcharge_details": null,
                "requires_cvv": true,
                "last_used_at": "2025-04-17T08:29:15.455Z",
                "default_payment_method_set": true,
                "billing": {
                    "address": {
                        "city": "San Fransico",
                        "country": "US",
                        "line1": "1467",
                        "line2": "Harrison Street",
                        "line3": "Harrison Street",
                        "zip": "94122",
                        "state": "California",
                        "first_name": "CLBRW",
                        "last_name": "dffdg"
                    },
                    "phone": {
                        "number": "123456789",
                        "country_code": "+1"
                    },
                    "email": null
                }
            }
        ],
        "is_guest_customer": null
    }
    
</details>


2. Create a new customer for offsession payment testing
<details>
<summary>Create a payment intent with setup_future_usage: offsession</summary>

Request

    curl --location 'http://localhost:8080/payments' \
    --header 'Content-Type: application/json' \
    --header 'Accept: application/json' \
    --header 'api-key: dev_FnltW73uMOCcEBApQnrAFpC4E570KVRJWzevF3NMlZS15o13tdMU60eh1wtqz3rc' \
    --data-raw '{
        "amount": 1000,
        "currency": "USD",
        "confirm": false,
        "capture_method": "automatic",
        "authentication_type": "no_three_ds",
        "customer_id": "cus_X4kaqOtEassKw3iiRM4v",
        "profile_id": "pro_5VR03thJTJH5WVRNXDSp",
        "email": "hyperswitch_sdk_demo_id@gmail.com",
        "description": "Hello this is description",
        "shipping": {
            "address": {
                "state": "zsaasdas",
                "city": "Banglore",
                "country": "US",
                "line1": "sdsdfsdf",
                "line2": "hsgdbhd",
                "line3": "alsksoe",
                "zip": "571201",
                "first_name": "joseph",
                "last_name": "doe"
            },
            "phone": {
                "number": "123456789",
                "country_code": "+1"
            }
        },
        "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": "123456789",
                "country_code": "+1"
            }
        },
        "setup_future_usage": "off_session",
        "order_details": null
    }'

Response

    {
        "payment_id": "pay_mbPUbwCkHDFtfTWgRpun",
        "merchant_id": "merchant_1744875358",
        "status": "requires_payment_method",
        "amount": 1000,
        "net_amount": 1000,
        "shipping_cost": null,
        "amount_capturable": 0,
        "amount_received": null,
        "connector": null,
        "client_secret": "pay_mbPUbwCkHDFtfTWgRpun_secret_gPLUinlRR0INPY21se4T",
        "created": "2025-04-17T08:32:21.848Z",
        "currency": "USD",
        "customer_id": "cus_X4kaqOtEassKw3iiRM4v",
        "customer": {
            "id": "cus_X4kaqOtEassKw3iiRM4v",
            "name": "John Doe",
            "email": "hyperswitch_sdk_demo_id@gmail.com",
            "phone": "999999999",
            "phone_country_code": "+65"
        },
        "description": "Hello this is description",
        "refunds": null,
        "disputes": null,
        "mandate_id": null,
        "mandate_data": null,
        "setup_future_usage": "off_session",
        "off_session": null,
        "capture_on": null,
        "capture_method": "automatic",
        "payment_method": null,
        "payment_method_data": null,
        "payment_token": null,
        "shipping": {
            "address": {
                "city": "Banglore",
                "country": "US",
                "line1": "sdsdfsdf",
                "line2": "hsgdbhd",
                "line3": "alsksoe",
                "zip": "571201",
                "state": "zsaasdas",
                "first_name": "joseph",
                "last_name": "doe"
            },
            "phone": {
                "number": "123456789",
                "country_code": "+1"
            },
            "email": null
        },
        "billing": {
            "address": {
                "city": "San Fransico",
                "country": "US",
                "line1": "1467",
                "line2": "Harrison Street",
                "line3": "Harrison Street",
                "zip": "94122",
                "state": "California",
                "first_name": "joseph",
                "last_name": "Doe"
            },
            "phone": {
                "number": "123456789",
                "country_code": "+1"
            },
            "email": null
        },
        "order_details": null,
        "email": "hyperswitch_sdk_demo_id@gmail.com",
        "name": "John Doe",
        "phone": "999999999",
        "return_url": null,
        "authentication_type": "no_three_ds",
        "statement_descriptor_name": null,
        "statement_descriptor_suffix": null,
        "next_action": null,
        "cancellation_reason": null,
        "error_code": null,
        "error_message": null,
        "unified_code": null,
        "unified_message": null,
        "payment_experience": null,
        "payment_method_type": null,
        "connector_label": null,
        "business_country": null,
        "business_label": "default",
        "business_sub_label": null,
        "allowed_payment_method_types": null,
        "ephemeral_key": {
            "customer_id": "cus_X4kaqOtEassKw3iiRM4v",
            "created_at": 1744878741,
            "expires": 1744882341,
            "secret": "epk_8cb5ff9074c2494c8449346ee3c44a12"
        },
        "manual_retry_allowed": null,
        "connector_transaction_id": null,
        "frm_message": null,
        "metadata": null,
        "connector_metadata": null,
        "feature_metadata": null,
        "reference_id": null,
        "payment_link": null,
        "profile_id": "pro_5VR03thJTJH5WVRNXDSp",
        "surcharge_details": null,
        "attempt_count": 1,
        "merchant_decision": null,
        "merchant_connector_id": null,
        "incremental_authorization_allowed": null,
        "authorization_count": null,
        "incremental_authorizations": null,
        "external_authentication_details": null,
        "external_3ds_authentication_attempted": false,
        "expires_on": "2025-04-17T08:47:21.848Z",
        "fingerprint": null,
        "browser_info": null,
        "payment_method_id": null,
        "payment_method_status": null,
        "updated": "2025-04-17T08:32:21.876Z",
        "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": null,
        "force_3ds_challenge": false,
        "force_3ds_challenge_trigger": false,
        "issuer_error_code": null,
        "issuer_error_message": null
    }
</details>

<details>
<summary>Confirm the payment intent</summary>

Request

    curl --location 'http://localhost:8080/payments/pay_mbPUbwCkHDFtfTWgRpun/confirm' \
    --header 'Content-Type: application/json' \
    --header 'Accept: application/json' \
    --header 'api-key: pk_dev_83200543d7d045f89bd4aa0d9475a63a' \
    --data '{
        "payment_method": "card",
        "payment_method_type": "credit",
        "client_secret": "pay_mbPUbwCkHDFtfTWgRpun_secret_gPLUinlRR0INPY21se4T",
        "profile_id": "pro_5VR03thJTJH5WVRNXDSp",
        "payment_method_data": {
            "card": {
                "card_number": "4111111111111111",
                "card_exp_month": "03",
                "card_exp_year": "2030",
                "card_holder_name": "CLBRW dffdg",
                "card_cvc": "737"
            }
        },
        "payment_type": "new_mandate",
        "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"
            }
        }
    }'

Response

    {
        "payment_id": "pay_mbPUbwCkHDFtfTWgRpun",
        "merchant_id": "merchant_1744875358",
        "status": "succeeded",
        "amount": 1000,
        "net_amount": 1000,
        "shipping_cost": null,
        "amount_capturable": 0,
        "amount_received": 1000,
        "connector": "cybersource",
        "client_secret": "pay_mbPUbwCkHDFtfTWgRpun_secret_gPLUinlRR0INPY21se4T",
        "created": "2025-04-17T08:32:21.848Z",
        "currency": "USD",
        "customer_id": "cus_X4kaqOtEassKw3iiRM4v",
        "customer": {
            "id": "cus_X4kaqOtEassKw3iiRM4v",
            "name": "John Doe",
            "email": "hyperswitch_sdk_demo_id@gmail.com",
            "phone": "999999999",
            "phone_country_code": "+65"
        },
        "description": "Hello this is description",
        "refunds": null,
        "disputes": null,
        "mandate_id": null,
        "mandate_data": null,
        "setup_future_usage": "off_session",
        "off_session": null,
        "capture_on": null,
        "capture_method": "automatic",
        "payment_method": "card",
        "payment_method_data": {
            "card": {
                "last4": "1111",
                "card_type": "CREDIT",
                "card_network": "Visa",
                "card_issuer": "JP Morgan",
                "card_issuing_country": "INDIA",
                "card_isin": "411111",
                "card_extended_bin": null,
                "card_exp_month": "03",
                "card_exp_year": "2030",
                "card_holder_name": "CLBRW dffdg",
                "payment_checks": {
                    "avs_response": {
                        "code": "Y",
                        "codeRaw": "Y"
                    },
                    "card_verification": null
                },
                "authentication_data": null
            },
            "billing": null
        },
        "payment_token": "token_HXjTgyijlJIT12YmXCZT",
        "shipping": {
            "address": {
                "city": "Banglore",
                "country": "US",
                "line1": "sdsdfsdf",
                "line2": "hsgdbhd",
                "line3": "alsksoe",
                "zip": "571201",
                "state": "zsaasdas",
                "first_name": "joseph",
                "last_name": "doe"
            },
            "phone": {
                "number": "123456789",
                "country_code": "+1"
            },
            "email": null
        },
        "billing": {
            "address": {
                "city": "San Fransico",
                "country": "US",
                "line1": "1467",
                "line2": "Harrison Street",
                "line3": "Harrison Street",
                "zip": "94122",
                "state": "California",
                "first_name": "joseph",
                "last_name": "Doe"
            },
            "phone": {
                "number": "123456789",
                "country_code": "+1"
            },
            "email": null
        },
        "order_details": null,
        "email": "hyperswitch_sdk_demo_id@gmail.com",
        "name": "John Doe",
        "phone": "999999999",
        "return_url": null,
        "authentication_type": "no_three_ds",
        "statement_descriptor_name": null,
        "statement_descriptor_suffix": null,
        "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": null,
        "manual_retry_allowed": false,
        "connector_transaction_id": "7448787948566158204806",
        "frm_message": null,
        "metadata": null,
        "connector_metadata": null,
        "feature_metadata": null,
        "reference_id": "pay_mbPUbwCkHDFtfTWgRpun_1",
        "payment_link": null,
        "profile_id": "pro_5VR03thJTJH5WVRNXDSp",
        "surcharge_details": null,
        "attempt_count": 1,
        "merchant_decision": null,
        "merchant_connector_id": "mca_4cXM5Pc7p96fCmB2oZim",
        "incremental_authorization_allowed": false,
        "authorization_count": null,
        "incremental_authorizations": null,
        "external_authentication_details": null,
        "external_3ds_authentication_attempted": false,
        "expires_on": "2025-04-17T08:47:21.848Z",
        "fingerprint": null,
        "browser_info": {
            "os_type": null,
            "language": null,
            "time_zone": null,
            "ip_address": "::1",
            "os_version": null,
            "user_agent": null,
            "color_depth": null,
            "device_model": null,
            "java_enabled": null,
            "screen_width": null,
            "accept_header": null,
            "screen_height": null,
            "accept_language": "en",
            "java_script_enabled": null
        },
        "payment_method_id": "pm_eeUJfBIaOvdZZCB49l72",
        "payment_method_status": "active",
        "updated": "2025-04-17T08:33:16.039Z",
        "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": "32F638788713F60BE063AF598E0AECE9",
        "card_discovery": "manual",
        "force_3ds_challenge": false,
        "force_3ds_challenge_trigger": false,
        "issuer_error_code": null,
        "issuer_error_message": null
    }


</details>

<details>
<summary>List the customer payment methods</summary>

Request

    curl --location 'http://localhost:8080/customers/cus_X4kaqOtEassKw3iiRM4v/payment_methods' \
    --header 'Accept: application/json' \
    --header 'api-key: dev_FnltW73uMOCcEBApQnrAFpC4E570KVRJWzevF3NMlZS15o13tdMU60eh1wtqz3rc'

Response

    {
        "customer_payment_methods": [
            {
                "payment_token": "token_Xz7iFHHg2og0ixOa8CYr",
                "payment_method_id": "pm_eeUJfBIaOvdZZCB49l72",
                "customer_id": "cus_X4kaqOtEassKw3iiRM4v",
                "payment_method": "card",
                "payment_method_type": "credit",
                "payment_method_issuer": "JP Morgan",
                "payment_method_issuer_code": null,
                "recurring_enabled": false,
                "installment_payment_enabled": false,
                "payment_experience": [
                    "redirect_to_url"
                ],
                "card": {
                    "scheme": "Visa",
                    "issuer_country": "INDIA",
                    "last4_digits": "1111",
                    "expiry_month": "03",
                    "expiry_year": "2030",
                    "card_token": null,
                    "card_holder_name": "CLBRW dffdg",
                    "card_fingerprint": null,
                    "nick_name": null,
                    "card_network": "Visa",
                    "card_isin": "411111",
                    "card_issuer": "JP Morgan",
                    "card_type": "CREDIT",
                    "saved_to_locker": true
                },
                "metadata": null,
                "created": "2025-04-17T08:33:16.010Z",
                "bank": null,
                "surcharge_details": null,
                "requires_cvv": true,
                "last_used_at": "2025-04-17T08:33:16.010Z",
                "default_payment_method_set": true,
                "billing": {
                    "address": {
                        "city": "San Fransico",
                        "country": "US",
                        "line1": "1467",
                        "line2": "Harrison Street",
                        "line3": "Harrison Street",
                        "zip": "94122",
                        "state": "California",
                        "first_name": "CLBRW",
                        "last_name": "dffdg"
                    },
                    "phone": {
                        "number": "123456789",
                        "country_code": "+1"
                    },
                    "email": null
                }
            }
        ],
        "is_guest_customer": null
    }

</details>

3. Test payment method migrate for new customer. Create a new customer

<details>
<summary>List payment methods of the customer</summary>

Request

    curl --location 'http://localhost:8080/customers/cus_KLhHM9R3f16CP2v1OuXt/payment_methods' \
    --header 'Accept: application/json' \
    --header 'x-feature: router-custom-be' \
    --header 'api-key: dev_FnltW73uMOCcEBApQnrAFpC4E570KVRJWzevF3NMlZS15o13tdMU60eh1wtqz3rc'

Response
    Expected empty list as the customer is new

    {
        "customer_payment_methods": [],
        "is_guest_customer": null
    }

</details>

<details>
<summary>Add a payment method for the new customer using /migrate API </summary>

Request

    curl --location 'http://localhost:8080/payment_methods/migrate' \
    --header 'api-key: test_admin' \
    --header 'Content-Type: application/json' \
    --data '{
        "payment_method": "card",
        "merchant_id": "merchant_1744875358",
        "card": {
            "card_number": "6011111111111117",
            "card_exp_month": "10",
            "card_exp_year": "33",
            "nick_name": "Joh"
        },
        "customer_id": "cus_KLhHM9R3f16CP2v1OuXt",
        "connector_mandate_details": {
            "mca_4cXM5Pc7p96fCmB2oZim": {
                "connector_mandate_id": "juaghfija"
            }
        }
    }
    '

Response

    {
        "payment_method_response": {
            "merchant_id": "merchant_1744875358",
            "customer_id": "cus_KLhHM9R3f16CP2v1OuXt",
            "payment_method_id": "pm_x58uwwcP6pcqSMPPOsnx",
            "payment_method": "card",
            "payment_method_type": null,
            "card": {
                "scheme": "DinersClub",
                "issuer_country": null,
                "last4_digits": "1117",
                "expiry_month": "10",
                "expiry_year": "33",
                "card_token": null,
                "card_holder_name": null,
                "card_fingerprint": null,
                "nick_name": "Joh",
                "card_network": "DinersClub",
                "card_isin": "601111",
                "card_issuer": null,
                "card_type": "CREDIT",
                "saved_to_locker": true
            },
            "recurring_enabled": false,
            "installment_payment_enabled": false,
            "payment_experience": [
                "redirect_to_url"
            ],
            "metadata": null,
            "created": "2025-04-17T08:36:45.651Z",
            "last_used_at": "2025-04-17T08:36:45.651Z",
            "client_secret": "pm_x58uwwcP6pcqSMPPOsnx_secret_VbS8w4pFXCc60aLm0aD4"
        },
        "card_migrated": true,
        "network_token_migrated": null,
        "connector_mandate_details_migrated": true,
        "network_transaction_id_migrated": null
    }

</details>

<details>
<summary>List the Customer PMs again</summary>

Request

    curl --location 'http://localhost:8080/customers/cus_KLhHM9R3f16CP2v1OuXt/payment_methods' \
    --header 'Accept: application/json' \
    --header 'x-feature: router-custom-be' \
    --header 'api-key: dev_FnltW73uMOCcEBApQnrAFpC4E570KVRJWzevF3NMlZS15o13tdMU60eh1wtqz3rc'

Response

    As expected the customer has new payment methods added via /migrate API

    {
        "customer_payment_methods": [
            {
                "payment_token": "token_I9VnnF5P5tBIiQ0xZnM2",
                "payment_method_id": "pm_x58uwwcP6pcqSMPPOsnx",
                "customer_id": "cus_KLhHM9R3f16CP2v1OuXt",
                "payment_method": "card",
                "payment_method_type": null,
                "payment_method_issuer": null,
                "payment_method_issuer_code": null,
                "recurring_enabled": false,
                "installment_payment_enabled": false,
                "payment_experience": [
                    "redirect_to_url"
                ],
                "card": {
                    "scheme": "DinersClub",
                    "issuer_country": null,
                    "last4_digits": "1117",
                    "expiry_month": "10",
                    "expiry_year": "33",
                    "card_token": null,
                    "card_holder_name": null,
                    "card_fingerprint": null,
                    "nick_name": "Joh",
                    "card_network": "DinersClub",
                    "card_isin": "601111",
                    "card_issuer": null,
                    "card_type": "CREDIT",
                    "saved_to_locker": true
                },
                "metadata": null,
                "created": "2025-04-17T08:36:45.652Z",
                "bank": null,
                "surcharge_details": null,
                "requires_cvv": true,
                "last_used_at": "2025-04-17T08:36:45.652Z",
                "default_payment_method_set": true,
                "billing": null
            }
        ],
        "is_guest_customer": null
    }

</details>

4. To check if the migrated payment method can be used in the payment, we create an onsession payment intent with this customer id

<details>
<summary>List the customer payment methods using the client secret</summary>

Request

    curl --location 'http://localhost:8080/customers/payment_methods?client_secret=pay_TcXsFdXIIKsg0vMtsNcw_secret_vfeAOfTzSQfxUajzKe4K' \
    --header 'Accept: application/json' \
    --header 'api-key: pk_dev_83200543d7d045f89bd4aa0d9475a63a'

Response

    {
        "customer_payment_methods": [
            {
                "payment_token": "token_gHFHR6PsW8pk1YbLV994",
                "payment_method_id": "pm_x58uwwcP6pcqSMPPOsnx",
                "customer_id": "cus_KLhHM9R3f16CP2v1OuXt",
                "payment_method": "card",
                "payment_method_type": null,
                "payment_method_issuer": null,
                "payment_method_issuer_code": null,
                "recurring_enabled": true,
                "installment_payment_enabled": false,
                "payment_experience": [
                    "redirect_to_url"
                ],
                "card": {
                    "scheme": "DinersClub",
                    "issuer_country": null,
                    "last4_digits": "1117",
                    "expiry_month": "10",
                    "expiry_year": "33",
                    "card_token": null,
                    "card_holder_name": null,
                    "card_fingerprint": null,
                    "nick_name": "Joh",
                    "card_network": "DinersClub",
                    "card_isin": "601111",
                    "card_issuer": null,
                    "card_type": "CREDIT",
                    "saved_to_locker": true
                },
                "metadata": null,
                "created": "2025-04-17T08:36:45.652Z",
                "bank": null,
                "surcharge_details": null,
                "requires_cvv": true,
                "last_used_at": "2025-04-17T08:36:45.652Z",
                "default_payment_method_set": true,
                "billing": null
            }
        ],
        "is_guest_customer": false
    }

</details>

<details>
<summary>Confirm the payment with above payment token</summary>

Request

    curl --location 'http://localhost:8080/payments/pay_TcXsFdXIIKsg0vMtsNcw/confirm' \
    --header 'Content-Type: application/json' \
    --header 'Accept: application/json' \
    --header 'api-key: pk_dev_83200543d7d045f89bd4aa0d9475a63a' \
    --data '{
        "payment_method": "card",
        "client_secret": "pay_TcXsFdXIIKsg0vMtsNcw_secret_vfeAOfTzSQfxUajzKe4K",
        "payment_token": "token_gHFHR6PsW8pk1YbLV994"
    }'

Response

    {
        "payment_id": "pay_TcXsFdXIIKsg0vMtsNcw",
        "merchant_id": "merchant_1744875358",
        "status": "succeeded",
        "amount": 1000,
        "net_amount": 1000,
        "shipping_cost": null,
        "amount_capturable": 0,
        "amount_received": 1000,
        "connector": "cybersource",
        "client_secret": "pay_TcXsFdXIIKsg0vMtsNcw_secret_vfeAOfTzSQfxUajzKe4K",
        "created": "2025-04-17T08:47:25.193Z",
        "currency": "USD",
        "customer_id": "cus_KLhHM9R3f16CP2v1OuXt",
        "customer": {
            "id": "cus_KLhHM9R3f16CP2v1OuXt",
            "name": "John Doe",
            "email": "hyperswitch_sdk_demo_id@gmail.com",
            "phone": "999999999",
            "phone_country_code": "+65"
        },
        "description": "Hello this is description",
        "refunds": null,
        "disputes": null,
        "mandate_id": null,
        "mandate_data": null,
        "setup_future_usage": "on_session",
        "off_session": null,
        "capture_on": null,
        "capture_method": "automatic",
        "payment_method": "card",
        "payment_method_data": {
            "card": {
                "last4": "1117",
                "card_type": "CREDIT",
                "card_network": "DinersClub",
                "card_issuer": null,
                "card_issuing_country": null,
                "card_isin": "601111",
                "card_extended_bin": null,
                "card_exp_month": "10",
                "card_exp_year": "33",
                "card_holder_name": null,
                "payment_checks": {
                    "avs_response": {
                        "code": "A",
                        "codeRaw": "Y"
                    },
                    "card_verification": null
                },
                "authentication_data": null
            },
            "billing": null
        },
        "payment_token": "token_gHFHR6PsW8pk1YbLV994",
        "shipping": {
            "address": {
                "city": "Banglore",
                "country": "US",
                "line1": "sdsdfsdf",
                "line2": "hsgdbhd",
                "line3": "alsksoe",
                "zip": "571201",
                "state": "zsaasdas",
                "first_name": "joseph",
                "last_name": "doe"
            },
            "phone": {
                "number": "123456789",
                "country_code": "+1"
            },
            "email": null
        },
        "billing": {
            "address": {
                "city": "San Fransico",
                "country": "US",
                "line1": "1467",
                "line2": "Harrison Street",
                "line3": "Harrison Street",
                "zip": "94122",
                "state": "California",
                "first_name": "joseph",
                "last_name": "Doe"
            },
            "phone": {
                "number": "123456789",
                "country_code": "+1"
            },
            "email": null
        },
        "order_details": null,
        "email": "hyperswitch_sdk_demo_id@gmail.com",
        "name": "John Doe",
        "phone": "999999999",
        "return_url": null,
        "authentication_type": "no_three_ds",
        "statement_descriptor_name": null,
        "statement_descriptor_suffix": null,
        "next_action": null,
        "cancellation_reason": null,
        "error_code": null,
        "error_message": null,
        "unified_code": null,
        "unified_message": null,
        "payment_experience": null,
        "payment_method_type": null,
        "connector_label": null,
        "business_country": null,
        "business_label": "default",
        "business_sub_label": null,
        "allowed_payment_method_types": null,
        "ephemeral_key": null,
        "manual_retry_allowed": false,
        "connector_transaction_id": "7448796541886364904807",
        "frm_message": null,
        "metadata": null,
        "connector_metadata": null,
        "feature_metadata": null,
        "reference_id": "pay_TcXsFdXIIKsg0vMtsNcw_1",
        "payment_link": null,
        "profile_id": "pro_5VR03thJTJH5WVRNXDSp",
        "surcharge_details": null,
        "attempt_count": 1,
        "merchant_decision": null,
        "merchant_connector_id": "mca_4cXM5Pc7p96fCmB2oZim",
        "incremental_authorization_allowed": false,
        "authorization_count": null,
        "incremental_authorizations": null,
        "external_authentication_details": null,
        "external_3ds_authentication_attempted": false,
        "expires_on": "2025-04-17T09:02:25.193Z",
        "fingerprint": null,
        "browser_info": {
            "os_type": null,
            "language": null,
            "time_zone": null,
            "ip_address": "::1",
            "os_version": null,
            "user_agent": null,
            "color_depth": null,
            "device_model": null,
            "java_enabled": null,
            "screen_width": null,
            "accept_header": null,
            "screen_height": null,
            "accept_language": "en",
            "java_script_enabled": null
        },
        "payment_method_id": "pm_x58uwwcP6pcqSMPPOsnx",
        "payment_method_status": "active",
        "updated": "2025-04-17T08:47:34.548Z",
        "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": "saved_card",
        "force_3ds_challenge": false,
        "force_3ds_challenge_trigger": false,
        "issuer_error_code": null,
        "issuer_error_message": null
    }

</details>

5. Test payment method migration api with network_transaction_id
<details>
Create a new customer
<summary>Add customer payment method with NTID</summary>

Request

    curl --location 'http://localhost:8080/payment_methods/migrate' \
    --header 'api-key: test_admin' \
    --header 'Content-Type: application/json' \
    --data '{
        "payment_method": "card",
        "merchant_id": "merchant_1744875358",
        "card": {
            "card_number": "4242424242424242",
            "card_exp_month": "10",
            "card_exp_year": "26",
            "nick_name": "Joh"
        },
        "customer_id": "cus_gIbOHWMUdVIJPXkOmEGw",
        "network_transaction_id": "network_transaction_id",
        "connector_mandate_details": {
            "mca_4cXM5Pc7p96fCmB2oZim": {
                "connector_mandate_id": "connector_mandate_id",
                "original_payment_authorized_amount": 6560,
                "original_payment_authorized_currency": "USD"
            }
        }
    }
    '

Response

    {
        "payment_method_response": {
            "merchant_id": "merchant_1744875358",
            "customer_id": "cus_gIbOHWMUdVIJPXkOmEGw",
            "payment_method_id": "pm_33dm3RNHzkNRoYmkZkq8",
            "payment_method": "card",
            "payment_method_type": null,
            "card": {
                "scheme": "Visa",
                "issuer_country": "UNITEDKINGDOM",
                "last4_digits": "4242",
                "expiry_month": "10",
                "expiry_year": "26",
                "card_token": null,
                "card_holder_name": null,
                "card_fingerprint": null,
                "nick_name": "Joh",
                "card_network": "Visa",
                "card_isin": "424242",
                "card_issuer": "STRIPE PAYMENTS UK LIMITED",
                "card_type": "CREDIT",
                "saved_to_locker": true
            },
            "recurring_enabled": false,
            "installment_payment_enabled": false,
            "payment_experience": [
                "redirect_to_url"
            ],
            "metadata": null,
            "created": "2025-04-17T08:55:40.382Z",
            "last_used_at": "2025-04-17T08:55:40.382Z",
            "client_secret": "pm_33dm3RNHzkNRoYmkZkq8_secret_2xHRJBFxmybLzoB1x0hA"
        },
        "card_migrated": true,
        "network_token_migrated": null,
        "connector_mandate_details_migrated": true,
        "network_transaction_id_migrated": true
    }

</details>

<details>
Create an onsession payment and get the client secret from response
<summary>List all the payment methods of the customer using the client secret</summary>

Request

    curl --location 'http://localhost:8080/customers/payment_methods?client_secret=pay_4slVZnQjT2Rgf6hsnH2f_secret_KQqTcwrHYsZmDWfDaqCr' \
    --header 'Accept: application/json' \
    --header 'api-key: pk_dev_83200543d7d045f89bd4aa0d9475a63a'

Response

    {
        "customer_payment_methods": [
            {
                "payment_token": "token_rADRActu2VQW7vsZWU51",
                "payment_method_id": "pm_33dm3RNHzkNRoYmkZkq8",
                "customer_id": "cus_gIbOHWMUdVIJPXkOmEGw",
                "payment_method": "card",
                "payment_method_type": null,
                "payment_method_issuer": null,
                "payment_method_issuer_code": null,
                "recurring_enabled": true,
                "installment_payment_enabled": false,
                "payment_experience": [
                    "redirect_to_url"
                ],
                "card": {
                    "scheme": "Visa",
                    "issuer_country": "UNITEDKINGDOM",
                    "last4_digits": "4242",
                    "expiry_month": "10",
                    "expiry_year": "26",
                    "card_token": null,
                    "card_holder_name": null,
                    "card_fingerprint": null,
                    "nick_name": "Joh",
                    "card_network": "Visa",
                    "card_isin": "424242",
                    "card_issuer": "STRIPE PAYMENTS UK LIMITED",
                    "card_type": "CREDIT",
                    "saved_to_locker": true
                },
                "metadata": null,
                "created": "2025-04-17T08:55:40.385Z",
                "bank": null,
                "surcharge_details": null,
                "requires_cvv": true,
                "last_used_at": "2025-04-17T08:55:40.385Z",
                "default_payment_method_set": true,
                "billing": null
            }
        ],
        "is_guest_customer": false
    }

</details>

<details>
<summary>Confirm the payment with payment token</summary>

Request

    curl --location 'http://localhost:8080/payments/pay_4slVZnQjT2Rgf6hsnH2f/confirm' \
    --header 'Content-Type: application/json' \
    --header 'Accept: application/json' \
    --header 'api-key: pk_dev_83200543d7d045f89bd4aa0d9475a63a' \
    --data '{
        "payment_method": "card",
        "client_secret": "pay_4slVZnQjT2Rgf6hsnH2f_secret_KQqTcwrHYsZmDWfDaqCr",
        "payment_token": "token_rADRActu2VQW7vsZWU51"
    }'

Response

    {
        "payment_id": "pay_4slVZnQjT2Rgf6hsnH2f",
        "merchant_id": "merchant_1744875358",
        "status": "succeeded",
        "amount": 1000,
        "net_amount": 1000,
        "shipping_cost": null,
        "amount_capturable": 0,
        "amount_received": 1000,
        "connector": "cybersource",
        "client_secret": "pay_4slVZnQjT2Rgf6hsnH2f_secret_KQqTcwrHYsZmDWfDaqCr",
        "created": "2025-04-17T08:58:04.694Z",
        "currency": "USD",
        "customer_id": "cus_gIbOHWMUdVIJPXkOmEGw",
        "customer": {
            "id": "cus_gIbOHWMUdVIJPXkOmEGw",
            "name": "John Doe",
            "email": "hyperswitch_sdk_demo_id@gmail.com",
            "phone": "999999999",
            "phone_country_code": "+65"
        },
        "description": "Hello this is description",
        "refunds": null,
        "disputes": null,
        "mandate_id": null,
        "mandate_data": null,
        "setup_future_usage": "on_session",
        "off_session": null,
        "capture_on": null,
        "capture_method": "automatic",
        "payment_method": "card",
        "payment_method_data": {
            "card": {
                "last4": "4242",
                "card_type": "CREDIT",
                "card_network": "Visa",
                "card_issuer": "STRIPE PAYMENTS UK LIMITED",
                "card_issuing_country": "UNITEDKINGDOM",
                "card_isin": "424242",
                "card_extended_bin": null,
                "card_exp_month": "10",
                "card_exp_year": "26",
                "card_holder_name": null,
                "payment_checks": {
                    "avs_response": {
                        "code": "Y",
                        "codeRaw": "Y"
                    },
                    "card_verification": null
                },
                "authentication_data": null
            },
            "billing": null
        },
        "payment_token": "token_rADRActu2VQW7vsZWU51",
        "shipping": {
            "address": {
                "city": "Banglore",
                "country": "US",
                "line1": "sdsdfsdf",
                "line2": "hsgdbhd",
                "line3": "alsksoe",
                "zip": "571201",
                "state": "zsaasdas",
                "first_name": "joseph",
                "last_name": "doe"
            },
            "phone": {
                "number": "123456789",
                "country_code": "+1"
            },
            "email": null
        },
        "billing": {
            "address": {
                "city": "San Fransico",
                "country": "US",
                "line1": "1467",
                "line2": "Harrison Street",
                "line3": "Harrison Street",
                "zip": "94122",
                "state": "California",
                "first_name": "joseph",
                "last_name": "Doe"
            },
            "phone": {
                "number": "123456789",
                "country_code": "+1"
            },
            "email": null
        },
        "order_details": null,
        "email": "hyperswitch_sdk_demo_id@gmail.com",
        "name": "John Doe",
        "phone": "999999999",
        "return_url": null,
        "authentication_type": "no_three_ds",
        "statement_descriptor_name": null,
        "statement_descriptor_suffix": null,
        "next_action": null,
        "cancellation_reason": null,
        "error_code": null,
        "error_message": null,
        "unified_code": null,
        "unified_message": null,
        "payment_experience": null,
        "payment_method_type": null,
        "connector_label": null,
        "business_country": null,
        "business_label": "default",
        "business_sub_label": null,
        "allowed_payment_method_types": null,
        "ephemeral_key": null,
        "manual_retry_allowed": false,
        "connector_transaction_id": "7448803299126792804805",
        "frm_message": null,
        "metadata": null,
        "connector_metadata": null,
        "feature_metadata": null,
        "reference_id": "pay_4slVZnQjT2Rgf6hsnH2f_1",
        "payment_link": null,
        "profile_id": "pro_5VR03thJTJH5WVRNXDSp",
        "surcharge_details": null,
        "attempt_count": 1,
        "merchant_decision": null,
        "merchant_connector_id": "mca_4cXM5Pc7p96fCmB2oZim",
        "incremental_authorization_allowed": false,
        "authorization_count": null,
        "incremental_authorizations": null,
        "external_authentication_details": null,
        "external_3ds_authentication_attempted": false,
        "expires_on": "2025-04-17T09:13:04.694Z",
        "fingerprint": null,
        "browser_info": {
            "os_type": null,
            "language": null,
            "time_zone": null,
            "ip_address": "::1",
            "os_version": null,
            "user_agent": null,
            "color_depth": null,
            "device_model": null,
            "java_enabled": null,
            "screen_width": null,
            "accept_header": null,
            "screen_height": null,
            "accept_language": "en",
            "java_script_enabled": null
        },
        "payment_method_id": "pm_33dm3RNHzkNRoYmkZkq8",
        "payment_method_status": "active",
        "updated": "2025-04-17T08:58:50.272Z",
        "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": "saved_card",
        "force_3ds_challenge": false,
        "force_3ds_challenge_trigger": false,
        "issuer_error_code": null,
        "issuer_error_message": null
    }

</details>

<details>
<summary>Verify Discover cards validation in migrate API</summary>

Request

    curl --location 'http://localhost:8080/payment_methods/migrate' \
    --header 'api-key: test_admin' \
    --header 'Content-Type: application/json' \
    --data '{
        "payment_method": "card",
        "merchant_id": "merchant_1744875358",
        "card": {
            "card_number": "6043101111111117",
            "card_exp_month": "10",
            "card_exp_year": "33",
            "nick_name": "Joh"
        },
        "customer_id": "cus_gHT9elNyHdZPJh7Rjv2y",
        "connector_mandate_details": {
            "mca_4cXM5Pc7p96fCmB2oZim": {
                "connector_mandate_id": "juaghfija"
            }
        }
    }
    '

Response

    {
        "error": {
            "type": "invalid_request",
            "message": "Missing required params",
            "code": "IR_21",
            "data": [
                "original_payment_authorized_currency",
                "original_payment_authorized_amount"
            ]
        }
    }

</details>

<details>
<summary>Test payment method addition using migrate batch endpoint</summary>

Request

    sample.csv
        merchant_id,merchant_connector_id,name,email,phone,phone_country_code,customer_id,subscription_id,payment_method,payment_method_type,nick_name,payment_instrument_id,card_number_masked,card_expiry_month,card_expiry_year,card_scheme,original_transaction_id,billing_address_zip,billing_address_state,billing_address_first_name,billing_address_last_name,billing_address_city,billing_address_country,billing_address_line1,billing_address_line2,raw_card_number,original_transaction_amount,original_transaction_currency,network_token_number
        merchant_1744875358,mca_4cXM5Pc7p96fCmB2oZim,noreal name,test@gmail.com,523698741,33,23dsfw23234a,900036959,card,credit,,4CBB27C05DE063AF598E,4242424242424242,03,2027,1,16153570198,94043,CA,NOREAL,NAME,Mountain View,US,1295 Charleston Rd,,,1000,USD,4242424242424242

    curl --location 'http://localhost:8080/payment_methods/migrate-batch' \
    --header 'api-key: test_admin' \
    --header 'Content-Type: application/json' \
    --form 'file=@"/Users/jagan.elavarasan/Downloads/sample.csv"' \
    --form 'merchant_id="merchant_1745224962"' \
    --form 'merchant_connector_id="mca_HmNmIqOB3UlY2ccFnGXV"'

Response

    [
        {
            "line_number": 1,
            "payment_method_id": "pm_4KzRt3iagMk4O1I0DZwi",
            "payment_method": "card",
            "payment_method_type": "credit",
            "customer_id": "23dsfw23234a",
            "migration_status": "Success",
            "card_number_masked": "4242424242424242",
            "card_migrated": true,
            "network_token_migrated": true,
            "connector_mandate_details_migrated": true,
            "network_transaction_id_migrated": true
        }
    ]

</details>

<details>
<summary>Test payment using the saved payment method</summary>

Request

    curl --location 'http://localhost:8080/payments/pay_3NFFos2v0BeZCqmi4h82/confirm' \
    --header 'Content-Type: application/json' \
    --header 'Accept: application/json' \
    --header 'api-key: pk_dev_9b7204ae65c8401da71fcc17d0dee950' \
    --data '{
        "payment_method": "card",
        "client_secret": "pay_3NFFos2v0BeZCqmi4h82_secret_bTwL7nF0BSm9eJXJuSpc",
        "payment_token": "token_S6l6CTSbQTsAmIPxVyLP"
    }'

Response

    {
        "payment_id": "pay_3NFFos2v0BeZCqmi4h82",
        "merchant_id": "merchant_1745224962",
        "status": "succeeded",
        "amount": 1000,
        "net_amount": 1000,
        "shipping_cost": null,
        "amount_capturable": 0,
        "amount_received": 1000,
        "connector": "cybersource",
        "client_secret": "pay_3NFFos2v0BeZCqmi4h82_secret_bTwL7nF0BSm9eJXJuSpc",
        "created": "2025-04-21T10:33:08.321Z",
        "currency": "USD",
        "customer_id": "23dsfw23234a",
        "customer": {
            "id": "23dsfw23234a",
            "name": "noreal name",
            "email": "hyperswitch_sdk_demo_id@gmail.com",
            "phone": "523698741",
            "phone_country_code": "33"
        },
        "description": "Hello this is description",
        "refunds": null,
        "disputes": null,
        "mandate_id": null,
        "mandate_data": null,
        "setup_future_usage": "on_session",
        "off_session": null,
        "capture_on": null,
        "capture_method": "automatic",
        "payment_method": "card",
        "payment_method_data": {
            "card": {
                "last4": "4242",
                "card_type": "CREDIT",
                "card_network": "Visa",
                "card_issuer": "STRIPE PAYMENTS UK LIMITED",
                "card_issuing_country": "UNITEDKINGDOM",
                "card_isin": "424242",
                "card_extended_bin": null,
                "card_exp_month": "03",
                "card_exp_year": "2027",
                "card_holder_name": "noreal name",
                "payment_checks": {
                    "avs_response": {
                        "code": "Y",
                        "codeRaw": "Y"
                    },
                    "card_verification": null
                },
                "authentication_data": null
            },
            "billing": null
        },
        "payment_token": "token_S6l6CTSbQTsAmIPxVyLP",
        "shipping": {
            "address": {
                "city": "Banglore",
                "country": "US",
                "line1": "sdsdfsdf",
                "line2": "hsgdbhd",
                "line3": "alsksoe",
                "zip": "571201",
                "state": "zsaasdas",
                "first_name": "joseph",
                "last_name": "doe"
            },
            "phone": {
                "number": "123456789",
                "country_code": "+1"
            },
            "email": null
        },
        "billing": {
            "address": {
                "city": "San Fransico",
                "country": "US",
                "line1": "1467",
                "line2": "Harrison Street",
                "line3": "Harrison Street",
                "zip": "94122",
                "state": "California",
                "first_name": "joseph",
                "last_name": "Doe"
            },
            "phone": {
                "number": "123456789",
                "country_code": "+1"
            },
            "email": null
        },
        "order_details": null,
        "email": "hyperswitch_sdk_demo_id@gmail.com",
        "name": "noreal name",
        "phone": "523698741",
        "return_url": null,
        "authentication_type": "no_three_ds",
        "statement_descriptor_name": null,
        "statement_descriptor_suffix": null,
        "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": null,
        "manual_retry_allowed": false,
        "connector_transaction_id": "7452315950806121404805",
        "frm_message": null,
        "metadata": null,
        "connector_metadata": null,
        "feature_metadata": null,
        "reference_id": "pay_3NFFos2v0BeZCqmi4h82_1",
        "payment_link": null,
        "profile_id": "pro_fg5JtKgrVIYUVB7x7zYh",
        "surcharge_details": null,
        "attempt_count": 1,
        "merchant_decision": null,
        "merchant_connector_id": "mca_HmNmIqOB3UlY2ccFnGXV",
        "incremental_authorization_allowed": false,
        "authorization_count": null,
        "incremental_authorizations": null,
        "external_authentication_details": null,
        "external_3ds_authentication_attempted": false,
        "expires_on": "2025-04-21T10:48:08.321Z",
        "fingerprint": null,
        "browser_info": {
            "os_type": null,
            "language": null,
            "time_zone": null,
            "ip_address": "::1",
            "os_version": null,
            "user_agent": null,
            "color_depth": null,
            "device_model": null,
            "java_enabled": null,
            "screen_width": null,
            "accept_header": null,
            "screen_height": null,
            "accept_language": "en",
            "java_script_enabled": null
        },
        "payment_method_id": "pm_4KzRt3iagMk4O1I0DZwi",
        "payment_method_status": "active",
        "updated": "2025-04-21T10:33:15.495Z",
        "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": "saved_card",
        "force_3ds_challenge": false,
        "force_3ds_challenge_trigger": false,
        "issuer_error_code": null,
        "issuer_error_message": null
    }

</details>

## Checklist
<!-- Put an `x` in the boxes that apply -->

- [ ] 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

<think>
PR Context:
- Title: fix(payment-methods): fetch payment method details in payouts flow
- Merged: 2025-07-24T15:48:58Z
- Files changed: 3 files
- Commits: 2 commits

Implementation approach:
## Type of Change
- [x] Bugfix

## Description
Fixed payout method data not being fetched from card vault when using `payout_method_id` in payouts flow.

**Changes:**
- Added `force_fetch_card_from_vault` parameter to `get_pm_list_context` to enable card vault lookup for payouts
- Added `get_card_details_from_locker` method to PaymentMethodsController trait
- Set `force_fetch_card_from_vault=true` in payouts validator to ensure card details are retrieved from vault
- Fixed typo in erro
</think>

To implement this, you'll need to modify:


**Detailed Implementation:**


**Commit 1:** fix(payment-methods): fetch payment method details in payouts flow (#8729)
Files to modify:


**crates/payment_methods/src/controller.rs**
  Modify existing code

**crates/router/src/core/payment_methods/cards.rs**
  Add:
    - function: private::get_card_details_from_locker

**crates/router/src/core/payouts/validator.rs**
  Modify existing code
{"issue_number": 7786, "pr_number": 8729, "commits_count": 1, "files_changed": 3, "response_length": 1146, "file_count": 6, "needs_breakdown": false}