hyperswitch icon indicating copy to clipboard operation
hyperswitch copied to clipboard

feat(router): Introduce NameType for Business Profile

Open AnuthaDev opened this issue 4 months ago • 1 comments

Type of Change

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

Description

Introduce NameType for Business Profile Name, to ensure its length is between 1 and 64

Additional Changes

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

Motivation and Context

How did you test it?

1a. >64 Request

curl --location 'http://localhost:8080/account/merchant_1728387874/business_profile' \
--header 'Content-Type: application/json' \
--header 'api-key: test_admin' \
--data '{
    "profile_name": "qwertyuioplkjhgfdsazxcvbnm,😂./\\/\/\/=-098765432123456789yuguwyduyya"
}'

1b. Response

{
    "error": "Json deserialize error: the maximum allowed length for this field is 64 at line 3 column 1"
}

2a. Empty Request

curl --location 'http://localhost:8080/account/merchant_1728387874/business_profile' \
--header 'Content-Type: application/json' \
--header 'api-key: test_admin' \
--data '{
    "profile_name": ""
}'

2b. Response

{
    "error": "Json deserialize error: the minimum required length for this field is 1 at line 3 column 1"
}

3a. Field omitted Request

curl --location 'http://localhost:8080/account/merchant_1728455771/business_profile' \
--header 'Content-Type: application/json' \
--header 'api-key: test_admin' \
--data '{}'

3b. Response

{
    "merchant_id": "merchant_1728455771",
    "profile_id": "pro_ALypYxsKzK9yUyIsFEGi",
    "profile_name": "default",
    "return_url": "https://google.com/success",
    "enable_payment_response_hash": true,
    "payment_response_hash_key": "wC7KUuHlfisgtGSiZOYyR8mIjIsNyTLOgNKjg89pycdzmnNXYZqzdWR6Yb07jdSi",
    "redirect_to_merchant_with_http_post": false,
    "webhook_details": {
        "webhook_version": "1.0.1",
        "webhook_username": "ekart_retail",
        "webhook_password": "password_ekart@123",
        "webhook_url": "https://webhook.site",
        "payment_created_enabled": true,
        "payment_succeeded_enabled": true,
        "payment_failed_enabled": true
    },
    "metadata": null,
    "routing_algorithm": null,
    "intent_fulfillment_time": 900,
    "frm_routing_algorithm": null,
    "payout_routing_algorithm": null,
    "applepay_verified_domains": null,
    "session_expiry": 900,
    "payment_link_config": null,
    "authentication_connector_details": null,
    "use_billing_as_payment_method_billing": true,
    "extended_card_info_config": null,
    "collect_shipping_details_from_wallet_connector": false,
    "collect_billing_details_from_wallet_connector": false,
    "always_collect_shipping_details_from_wallet_connector": false,
    "always_collect_billing_details_from_wallet_connector": false,
    "is_connector_agnostic_mit_enabled": false,
    "payout_link_config": null,
    "outgoing_webhook_custom_http_headers": null,
    "tax_connector_id": null,
    "is_tax_connector_enabled": false,
    "is_network_tokenization_enabled": false,
    "is_auto_retries_enabled": false,
    "max_auto_retries_enabled": null
}

4a. Regular Request

curl --location 'http://localhost:8080/account/merchant_1728455771/business_profile' \
--header 'Content-Type: application/json' \
--header 'api-key: test_admin' \
--data '{
    "profile_name": "Normal Name with Emoji 😁"
}'

4b. Response

{
    "merchant_id": "merchant_1728455771",
    "profile_id": "pro_2womvp2eqGVRbj7kZKc8",
    "profile_name": "Normal Name with Emoji 😁",
    "return_url": "https://google.com/success",
    "enable_payment_response_hash": true,
    "payment_response_hash_key": "wC7KUuHlfisgtGSiZOYyR8mIjIsNyTLOgNKjg89pycdzmnNXYZqzdWR6Yb07jdSi",
    "redirect_to_merchant_with_http_post": false,
    "webhook_details": {
        "webhook_version": "1.0.1",
        "webhook_username": "ekart_retail",
        "webhook_password": "password_ekart@123",
        "webhook_url": "https://webhook.site",
        "payment_created_enabled": true,
        "payment_succeeded_enabled": true,
        "payment_failed_enabled": true
    },
    "metadata": null,
    "routing_algorithm": null,
    "intent_fulfillment_time": 900,
    "frm_routing_algorithm": null,
    "payout_routing_algorithm": null,
    "applepay_verified_domains": null,
    "session_expiry": 900,
    "payment_link_config": null,
    "authentication_connector_details": null,
    "use_billing_as_payment_method_billing": true,
    "extended_card_info_config": null,
    "collect_shipping_details_from_wallet_connector": false,
    "collect_billing_details_from_wallet_connector": false,
    "always_collect_shipping_details_from_wallet_connector": false,
    "always_collect_billing_details_from_wallet_connector": false,
    "is_connector_agnostic_mit_enabled": false,
    "payout_link_config": null,
    "outgoing_webhook_custom_http_headers": null,
    "tax_connector_id": null,
    "is_tax_connector_enabled": false,
    "is_network_tokenization_enabled": false,
    "is_auto_retries_enabled": false,
    "max_auto_retries_enabled": null
}

Checklist

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

AnuthaDev avatar Oct 09 '24 06:10 AnuthaDev