juspay / hyperswitch

An open source payments switch written in Rust to make payments fast, reliable and affordable
https://hyperswitch.io/
Apache License 2.0
12.66k stars 1.36k forks source link

fix(router): validate each field for migration request body #6525

Open prasunna09 opened 2 weeks ago

prasunna09 commented 2 weeks ago

Type of Change

Description

6300 has inconsistent response due to no validations for each field in migration api request body.

Additional Changes

Motivation and Context

How did you test it?

test case - test migration api with empty fields. req -

curl --location 'http://localhost:8080/payment_methods/migrate' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: api-key' \
--data '{
    "merchant_id": "merchant_id",
    "card": {
        "card_number": "card_number",
        "card_exp_month": "12",
        "card_exp_year": "21",
        "card_holder_name": "joseph Doe"
    },
    "customer_id": "customer_id",
    "network_transaction_id": "",
    "payment_method": "card",
    "connector_mandate_details": {},
    "network_token": {
        "network_token_data": {
            "network_token_number": "  ",
            "network_token_exp_month": "12",
            "network_token_exp_year": "21"
        },
        "network_token_requestor_ref_id": ""
    }
}'
Screenshot 2024-11-11 at 11 43 58 AM

Checklist

semanticdiff-com[bot] commented 2 weeks ago

Review changes with  SemanticDiff

Changed Files
| File | Status | | :--- | :--- | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6525/changes#crates/router/src/types/api/payment_methods.rs)  [crates/router/src/types/api/payment\_methods\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6525/changes#crates/router/src/types/api/payment_methods.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6525/changes#crates/router/src/types/api/payment_methods.rs)  82% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6525/changes#crates/api_models/src/payment_methods.rs)  [crates/api\_models/src/payment\_methods\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6525/changes#crates/api_models/src/payment_methods.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6525/changes#crates/api_models/src/payment_methods.rs)  7% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6525/changes#crates/router/src/core/payment_methods/cards.rs)  [crates/router/src/core/payment\_methods/cards\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6525/changes#crates/router/src/core/payment_methods/cards.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6525/changes#crates/router/src/core/payment_methods/cards.rs)  7% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6525/changes#crates/api_models/src/events/payment.rs)  [crates/api\_models/src/events/payment\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6525/changes#crates/api_models/src/events/payment.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6525/changes#crates/api_models/src/events/payment.rs)  1% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6525/changes#crates/diesel_models/src/payment_method.rs)  [crates/diesel\_models/src/payment\_method\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6525/changes#crates/diesel_models/src/payment_method.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6525/changes#crates/diesel_models/src/payment_method.rs)  0% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6525/changes#crates/router/src/core/payment_methods/migration.rs)  [crates/router/src/core/payment\_methods/migration\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6525/changes#crates/router/src/core/payment_methods/migration.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6525/changes#crates/router/src/core/payment_methods/migration.rs)  0% smaller | | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6525/changes#crates/router/src/core/payments/tokenization.rs)  [crates/router/src/core/payments/tokenization\.rs](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6525/changes#crates/router/src/core/payments/tokenization.rs) | [](https://app.semanticdiff.com/gh/juspay/hyperswitch/pull/6525/changes#crates/router/src/core/payments/tokenization.rs)  0% smaller |