Bug: [BUG]: 2-Letter State abbreviation is not accepted



### Bug Description

Currently 2-Letter State abbreviation is not accepted, in `billing.state` if you pass 2 letter valid state it should not throw an error

### Expected Behavior

Both 2 letter and full state name shall be accepted in `billing.state` and should be manipulated according to the requirements before sending it to the connector.

### Actual Behavior

Currently 2-Letter State abbreviation is not accepted, in `billing.state` if you pass 2 letter valid state it should not throw an error

### Steps To Reproduce

Provide an unambiguous set of steps to reproduce this bug. Include code or configuration to reproduce, if relevant.
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'


### Context For The Bug

_No response_

### Environment

Are you using hyperswitch hosted version? Yes/No
If yes, please provide the value of the `x-request-id` response header to help us debug your issue.

If not (or if building/running locally), please provide the following details:
1. Operating System or Linux distribution:
2. Rust version (output of `rustc --version`): ``
3. App version (output of `cargo r --features vergen -- --version`): ``


### Have you spent some time checking if this bug has been raised before?

- [X] I checked and didn't find a similar issue

### Have you read the Contributing Guidelines?

- [X] I have read the [Contributing Guidelines](https://github.com/juspay/hyperswitch/blob/main/docs/CONTRIBUTING.md)

### Are you willing to submit a PR?

Yes, I am willing to submit a PR!
diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs
index 8b0974cc4f8..74eb8c048f9 100644
--- a/crates/common_enums/src/enums.rs
+++ b/crates/common_enums/src/enums.rs
@@ -2010,7 +2010,9 @@ pub enum FileUploadProvider {
     Checkout,
 }
 
-#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, strum::Display)]
+#[derive(
+    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, strum::Display, strum::EnumString,
+)]
 pub enum UsStatesAbbreviation {
     AL,
     AK,
@@ -2073,7 +2075,9 @@ pub enum UsStatesAbbreviation {
     WY,
 }
 
-#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, strum::Display)]
+#[derive(
+    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, strum::Display, strum::EnumString,
+)]
 pub enum CanadaStatesAbbreviation {
     AB,
     BC,
diff --git a/crates/router/src/connector/utils.rs b/crates/router/src/connector/utils.rs
index 6a569e76a62..0d8f42e6504 100644
--- a/crates/router/src/connector/utils.rs
+++ b/crates/router/src/connector/utils.rs
@@ -10,6 +10,7 @@ use base64::Engine;
 use common_utils::{
     date_time,
     errors::ReportSwitchExt,
+    ext_traits::StringExt,
     pii::{self, Email, IpAddress},
 };
 use diesel_models::enums;
@@ -1801,72 +1802,80 @@ pub fn get_webhook_merchant_secret_key(connector_label: &str, merchant_id: &str)
 impl ForeignTryFrom<String> for UsStatesAbbreviation {
     type Error = error_stack::Report<errors::ConnectorError>;
     fn foreign_try_from(value: String) -> Result<Self, Self::Error> {
-        let binding = value.as_str().to_lowercase();
-        let state = binding.as_str();
-        match state {
-            "alabama" => Ok(Self::AL),
-            "alaska" => Ok(Self::AK),
-            "american samoa" => Ok(Self::AS),
-            "arizona" => Ok(Self::AZ),
-            "arkansas" => Ok(Self::AR),
-            "california" => Ok(Self::CA),
-            "colorado" => Ok(Self::CO),
-            "connecticut" => Ok(Self::CT),
-            "delaware" => Ok(Self::DE),
-            "district of columbia" | "columbia" => Ok(Self::DC),
-            "federated states of micronesia" | "micronesia" => Ok(Self::FM),
-            "florida" => Ok(Self::FL),
-            "georgia" => Ok(Self::GA),
-            "guam" => Ok(Self::GU),
-            "hawaii" => Ok(Self::HI),
-            "idaho" => Ok(Self::ID),
-            "illinois" => Ok(Self::IL),
-            "indiana" => Ok(Self::IN),
-            "iowa" => Ok(Self::IA),
-            "kansas" => Ok(Self::KS),
-            "kentucky" => Ok(Self::KY),
-            "louisiana" => Ok(Self::LA),
-            "maine" => Ok(Self::ME),
-            "marshall islands" => Ok(Self::MH),
-            "maryland" => Ok(Self::MD),
-            "massachusetts" => Ok(Self::MA),
-            "michigan" => Ok(Self::MI),
-            "minnesota" => Ok(Self::MN),
-            "mississippi" => Ok(Self::MS),
-            "missouri" => Ok(Self::MO),
-            "montana" => Ok(Self::MT),
-            "nebraska" => Ok(Self::NE),
-            "nevada" => Ok(Self::NV),
-            "new hampshire" => Ok(Self::NH),
-            "new jersey" => Ok(Self::NJ),
-            "new mexico" => Ok(Self::NM),
-            "new york" => Ok(Self::NY),
-            "north carolina" => Ok(Self::NC),
-            "north dakota" => Ok(Self::ND),
-            "northern mariana islands" => Ok(Self::MP),
-            "ohio" => Ok(Self::OH),
-            "oklahoma" => Ok(Self::OK),
-            "oregon" => Ok(Self::OR),
-            "palau" => Ok(Self::PW),
-            "pennsylvania" => Ok(Self::PA),
-            "puerto rico" => Ok(Self::PR),
-            "rhode island" => Ok(Self::RI),
-            "south carolina" => Ok(Self::SC),
-            "south dakota" => Ok(Self::SD),
-            "tennessee" => Ok(Self::TN),
-            "texas" => Ok(Self::TX),
-            "utah" => Ok(Self::UT),
-            "vermont" => Ok(Self::VT),
-            "virgin islands" => Ok(Self::VI),
-            "virginia" => Ok(Self::VA),
-            "washington" => Ok(Self::WA),
-            "west virginia" => Ok(Self::WV),
-            "wisconsin" => Ok(Self::WI),
-            "wyoming" => Ok(Self::WY),
-            _ => Err(errors::ConnectorError::InvalidDataFormat {
-                field_name: "address.state",
+        let state_abbreviation_check =
+            StringExt::<Self>::parse_enum(value.to_uppercase().clone(), "UsStatesAbbreviation");
+
+        match state_abbreviation_check {
+            Ok(state_abbreviation) => Ok(state_abbreviation),
+            Err(_) => {
+                let binding = value.as_str().to_lowercase();
+                let state = binding.as_str();
+                match state {
+                    "alabama" => Ok(Self::AL),
+                    "alaska" => Ok(Self::AK),
+                    "american samoa" => Ok(Self::AS),
+                    "arizona" => Ok(Self::AZ),
+                    "arkansas" => Ok(Self::AR),
+                    "california" => Ok(Self::CA),
+                    "colorado" => Ok(Self::CO),
+                    "connecticut" => Ok(Self::CT),
+                    "delaware" => Ok(Self::DE),
+                    "district of columbia" | "columbia" => Ok(Self::DC),
+                    "federated states of micronesia" | "micronesia" => Ok(Self::FM),
+                    "florida" => Ok(Self::FL),
+                    "georgia" => Ok(Self::GA),
+                    "guam" => Ok(Self::GU),
+                    "hawaii" => Ok(Self::HI),
+                    "idaho" => Ok(Self::ID),
+                    "illinois" => Ok(Self::IL),
+                    "indiana" => Ok(Self::IN),
+                    "iowa" => Ok(Self::IA),
+                    "kansas" => Ok(Self::KS),
+                    "kentucky" => Ok(Self::KY),
+                    "louisiana" => Ok(Self::LA),
+                    "maine" => Ok(Self::ME),
+                    "marshall islands" => Ok(Self::MH),
+                    "maryland" => Ok(Self::MD),
+                    "massachusetts" => Ok(Self::MA),
+                    "michigan" => Ok(Self::MI),
+                    "minnesota" => Ok(Self::MN),
+                    "mississippi" => Ok(Self::MS),
+                    "missouri" => Ok(Self::MO),
+                    "montana" => Ok(Self::MT),
+                    "nebraska" => Ok(Self::NE),
+                    "nevada" => Ok(Self::NV),
+                    "new hampshire" => Ok(Self::NH),
+                    "new jersey" => Ok(Self::NJ),
+                    "new mexico" => Ok(Self::NM),
+                    "new york" => Ok(Self::NY),
+                    "north carolina" => Ok(Self::NC),
+                    "north dakota" => Ok(Self::ND),
+                    "northern mariana islands" => Ok(Self::MP),
+                    "ohio" => Ok(Self::OH),
+                    "oklahoma" => Ok(Self::OK),
+                    "oregon" => Ok(Self::OR),
+                    "palau" => Ok(Self::PW),
+                    "pennsylvania" => Ok(Self::PA),
+                    "puerto rico" => Ok(Self::PR),
+                    "rhode island" => Ok(Self::RI),
+                    "south carolina" => Ok(Self::SC),
+                    "south dakota" => Ok(Self::SD),
+                    "tennessee" => Ok(Self::TN),
+                    "texas" => Ok(Self::TX),
+                    "utah" => Ok(Self::UT),
+                    "vermont" => Ok(Self::VT),
+                    "virgin islands" => Ok(Self::VI),
+                    "virginia" => Ok(Self::VA),
+                    "washington" => Ok(Self::WA),
+                    "west virginia" => Ok(Self::WV),
+                    "wisconsin" => Ok(Self::WI),
+                    "wyoming" => Ok(Self::WY),
+                    _ => Err(errors::ConnectorError::InvalidDataFormat {
+                        field_name: "address.state",
+                    }
+                    .into()),
+                }
             }
-            .into()),
         }
     }
 }
@@ -1874,26 +1883,33 @@ impl ForeignTryFrom<String> for UsStatesAbbreviation {
 impl ForeignTryFrom<String> for CanadaStatesAbbreviation {
     type Error = error_stack::Report<errors::ConnectorError>;
     fn foreign_try_from(value: String) -> Result<Self, Self::Error> {
-        let binding = value.as_str().to_lowercase();
-        let state = binding.as_str();
-        match state {
-            "alberta" => Ok(Self::AB),
-            "british columbia" => Ok(Self::BC),
-            "manitoba" => Ok(Self::MB),
-            "new brunswick" => Ok(Self::NB),
-            "newfoundland and labrador" | "newfoundland & labrador" => Ok(Self::NL),
-            "northwest territories" => Ok(Self::NT),
-            "nova scotia" => Ok(Self::NS),
-            "nunavut" => Ok(Self::NU),
-            "ontario" => Ok(Self::ON),
-            "prince edward island" => Ok(Self::PE),
-            "quebec" => Ok(Self::QC),
-            "saskatchewan" => Ok(Self::SK),
-            "yukon" => Ok(Self::YT),
-            _ => Err(errors::ConnectorError::InvalidDataFormat {
-                field_name: "address.state",
+        let state_abbreviation_check =
+            StringExt::<Self>::parse_enum(value.to_uppercase().clone(), "CanadaStatesAbbreviation");
+        match state_abbreviation_check {
+            Ok(state_abbreviation) => Ok(state_abbreviation),
+            Err(_) => {
+                let binding = value.as_str().to_lowercase();
+                let state = binding.as_str();
+                match state {
+                    "alberta" => Ok(Self::AB),
+                    "british columbia" => Ok(Self::BC),
+                    "manitoba" => Ok(Self::MB),
+                    "new brunswick" => Ok(Self::NB),
+                    "newfoundland and labrador" | "newfoundland & labrador" => Ok(Self::NL),
+                    "northwest territories" => Ok(Self::NT),
+                    "nova scotia" => Ok(Self::NS),
+                    "nunavut" => Ok(Self::NU),
+                    "ontario" => Ok(Self::ON),
+                    "prince edward island" => Ok(Self::PE),
+                    "quebec" => Ok(Self::QC),
+                    "saskatchewan" => Ok(Self::SK),
+                    "yukon" => Ok(Self::YT),
+                    _ => Err(errors::ConnectorError::InvalidDataFormat {
+                        field_name: "address.state",
+                    }
+                    .into()),
+                }
             }
-            .into()),
         }
     }
 }

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

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

## Description
<!-- Describe your changes in detail -->
Accept `billing.state` with 2-letter abbreviation for US and CA

### 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).
-->
#4647 

## 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)?
-->

### For CA test with `AB` or any other abbreviation it should pass
```
curl --location 'http://localhost:8080/payments' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'api-key: dev_mFmnWfEBGI9OvZdkWlkrAEcp6PBReLfXynzHIbcl0d2z4bSDvvHIsegcqrCMDDqv' \
--data-raw '{
    "amount": 9040,
    "currency": "USD",
    "confirm": true,    
    "capture_method": "automatic",
    "customer_id": "shanks57",
    "authentication_type": "no_three_ds",
    "return_url": "https://google.com",
    "email": "abc-ext.kylta@flowbird.group",
    "name": "Joseph Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment",
    "statement_descriptor_name": "Juspay",
    "statement_descriptor_suffix": "Router",
    "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_data": {
        "card": {
            "card_number": "4242424242424242",
            "card_exp_month": "01",
            "card_exp_year": "2027",
            "card_holder_name": "joseph Doe",
            "card_cvc": "100",
            "nick_name": "hehe"
        }
    },
    "billing": {
        "address": {
            "city": "SanFrancisco",
            "country": "CA",
            "line1": "1562",
            "line2": "HarrisonStreet",
            "line3": "HarrisonStreet",
            "zip": "K1A 0A0",
            "state": "AB",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        }
    },
    "browser_info": {
        "user_agent": "Mozilla\/5.0 (iPhone 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"
    },
    "connector_metadata": {
        "noon": {
            "order_category": "pay"
        }
    },
    "order_details": [
        {
            "product_name": "Apple iphone 15",
            "quantity": 1,
            "amount": 10,
            "account_name": "transaction_processing"
        }
    ]
}'

```

### For US test with `ca` or any other abbreviation it should pass
```
curl --location 'http://localhost:8080/payments' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'api-key: dev_mFmnWfEBGI9OvZdkWlkrAEcp6PBReLfXynzHIbcl0d2z4bSDvvHIsegcqrCMDDqv' \
--data-raw '{
    "amount": 9040,
    "currency": "USD",
    "confirm": true,    
    "capture_method": "automatic",
    "customer_id": "shanks57",
    "authentication_type": "no_three_ds",
    "return_url": "https://google.com",
    "email": "abc-ext.kylta@flowbird.group",
    "name": "Joseph Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment",
    "statement_descriptor_name": "Juspay",
    "statement_descriptor_suffix": "Router",
    "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_data": {
        "card": {
            "card_number": "4242424242424242",
            "card_exp_month": "01",
            "card_exp_year": "2027",
            "card_holder_name": "joseph Doe",
            "card_cvc": "100",
            "nick_name": "hehe"
        }
    },
    "billing": {
        "address": {
            "city": "SanFrancisco",
            "country": "US",
            "line1": "1562",
            "line2": "HarrisonStreet",
            "line3": "HarrisonStreet",
            "zip": "94122",
            "state": "CA",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        }
    },
    "browser_info": {
        "user_agent": "Mozilla\/5.0 (iPhone 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"
    },
    "connector_metadata": {
        "noon": {
            "order_category": "pay"
        }
    },
    "order_details": [
        {
            "product_name": "Apple iphone 15",
            "quantity": 1,
            "amount": 10,
            "account_name": "transaction_processing"
        }
    ]
}'

```

### For US/CA test with full state name it should pass
```
curl --location 'http://localhost:8080/payments' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'api-key: dev_mFmnWfEBGI9OvZdkWlkrAEcp6PBReLfXynzHIbcl0d2z4bSDvvHIsegcqrCMDDqv' \
--data-raw '{
    "amount": 9040,
    "currency": "USD",
    "confirm": true,    
    "capture_method": "automatic",
    "customer_id": "shanks57",
    "authentication_type": "no_three_ds",
    "return_url": "https://google.com",
    "email": "abc-ext.kylta@flowbird.group",
    "name": "Joseph Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment",
    "statement_descriptor_name": "Juspay",
    "statement_descriptor_suffix": "Router",
    "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_data": {
        "card": {
            "card_number": "4242424242424242",
            "card_exp_month": "01",
            "card_exp_year": "2027",
            "card_holder_name": "joseph Doe",
            "card_cvc": "100",
            "nick_name": "hehe"
        }
    },
    "billing": {
        "address": {
            "city": "SanFrancisco",
            "country": "US",
            "line1": "1562",
            "line2": "HarrisonStreet",
            "line3": "HarrisonStreet",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        }
    },
    "browser_info": {
        "user_agent": "Mozilla\/5.0 (iPhone 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"
    },
    "connector_metadata": {
        "noon": {
            "order_category": "pay"
        }
    },
    "order_details": [
        {
            "product_name": "Apple iphone 15",
            "quantity": 1,
            "amount": 10,
            "account_name": "transaction_processing"
        }
    ]
}'

```

### For US/CA test with invalid state name or abbreviation it should fail at hyperswitch level.
```
curl --location 'http://localhost:8080/payments' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'api-key: dev_mFmnWfEBGI9OvZdkWlkrAEcp6PBReLfXynzHIbcl0d2z4bSDvvHIsegcqrCMDDqv' \
--data-raw '{
    "amount": 9040,
    "currency": "USD",
    "confirm": true,    
    "capture_method": "automatic",
    "customer_id": "shanks57",
    "authentication_type": "no_three_ds",
    "return_url": "https://google.com",
    "email": "abc-ext.kylta@flowbird.group",
    "name": "Joseph Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment",
    "statement_descriptor_name": "Juspay",
    "statement_descriptor_suffix": "Router",
    "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_data": {
        "card": {
            "card_number": "4242424242424242",
            "card_exp_month": "01",
            "card_exp_year": "2027",
            "card_holder_name": "joseph Doe",
            "card_cvc": "100",
            "nick_name": "hehe"
        }
    },
    "billing": {
        "address": {
            "city": "SanFrancisco",
            "country": "US",
            "line1": "1562",
            "line2": "HarrisonStreet",
            "line3": "HarrisonStreet",
            "zip": "94122",
            "state": "random_state",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        }
    },
    "browser_info": {
        "user_agent": "Mozilla\/5.0 (iPhone 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"
    },
    "connector_metadata": {
        "noon": {
            "order_category": "pay"
        }
    },
    "order_details": [
        {
            "product_name": "Apple iphone 15",
            "quantity": 1,
            "amount": 10,
            "account_name": "transaction_processing"
        }
    ]
}'

```

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

- [X] I formatted the code `cargo +nightly fmt --all`
- [X] I addressed lints thrown by `cargo clippy`
- [X] I reviewed the submitted code
- [ ] I added unit tests for my changes where possible
