Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(connector): accept state abbreviation in 2 letter #4646

Merged
merged 5 commits into from
May 15, 2024

Conversation

SamraatBansal
Copy link
Contributor

@SamraatBansal SamraatBansal commented May 15, 2024

Type of Change

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

Description

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

Motivation and Context

#4647

How did you test it?

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

  • 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

@SamraatBansal SamraatBansal added A-connector-integration Area: Connector integration C-bug Category: Bug S-waiting-on-review Status: This PR has been implemented and needs to be reviewed labels May 15, 2024
@SamraatBansal SamraatBansal self-assigned this May 15, 2024
@SamraatBansal SamraatBansal requested review from a team as code owners May 15, 2024 07:38
jagan-jaya
jagan-jaya previously approved these changes May 15, 2024
@SamraatBansal SamraatBansal linked an issue May 15, 2024 that may be closed by this pull request
2 tasks
@likhinbopanna likhinbopanna removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label May 15, 2024
@likhinbopanna likhinbopanna added this pull request to the merge queue May 15, 2024
Merged via the queue into main with commit 3cf840e May 15, 2024
9 of 12 checks passed
@likhinbopanna likhinbopanna deleted the cybersource-state branch May 15, 2024 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-connector-integration Area: Connector integration C-bug Category: Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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