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

refactor(required_fields): move pm required fields to pm crate #7539

Draft
wants to merge 12 commits into
base: refactor-customer-db
Choose a base branch
from

Conversation

jagan-jaya
Copy link
Contributor

@jagan-jaya jagan-jaya commented Mar 17, 2025

Type of Change

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

Description

Use enums in payment_connector_required_fields.rs instead of string for required fields and reduce duplication

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?

Original output: original_required_fields.json
New Output: new_required_fields.json

diff --git a/Users/jagan.elavarasan/Desktop/hyperswitch/crates/router/target/required_fields/default_fields.json b/Users/jagan.elavarasan/Desktop/tmp/hyperswitch/crates/payment_methods/target/required_fields/default_fields.json
index 3c57984473..b865cfa3cd 100644
--- a/Users/jagan.elavarasan/Desktop/hyperswitch/crates/router/target/required_fields/default_fields.json
+++ b/Users/jagan.elavarasan/Desktop/tmp/hyperswitch/crates/payment_methods/target/required_fields/default_fields.json
@@ -486,7 +486,7 @@
                   "mandate": {},
                   "non_mandate": {
                       "billing.address.country": {
-                          "display_name": "bank_account_country",
+                          "display_name": "country",
                           "field_type": {
                               "user_country": {
                                   "options": [
@@ -575,7 +575,7 @@
                   "mandate": {},
                   "non_mandate": {
                       "billing.address.country": {
-                          "display_name": "bank_account_country",
+                          "display_name": "country",
                           "field_type": {
                               "user_country": {
                                   "options": [
@@ -1001,7 +1001,7 @@
                           "value": null
                       },
                       "billing.email": {
-                          "display_name": "billing_email",
+                          "display_name": "email",
                           "field_type": "user_email_address",
                           "required_field": "payment_method_data.billing.email",
                           "value": null
@@ -3211,7 +3211,7 @@
                           "value": null
                       },
                       "billing.address.zip": {
-                          "display_name": "billing_zip",
+                          "display_name": "zip",
                           "field_type": "user_address_pincode",
                           "required_field": "payment_method_data.billing.address.zip",
                           "value": null
@@ -3299,7 +3299,7 @@
                           "value": null
                       },
                       "billing.email": {
-                          "display_name": "email_address",
+                          "display_name": "email",
                           "field_type": "user_email_address",
                           "required_field": "payment_method_data.billing.email",
                           "value": null
@@ -4286,7 +4286,7 @@
                       "payment_method_data.billing.phone.number": {
                           "display_name": "phone_number",
                           "field_type": "user_phone_number",
-                          "required_field": "billing.phone.number",
+                          "required_field": "payment_method_data.billing.phone.number",
                           "value": null
                       },
                       "payment_method_data.card.card_cvc": {
@@ -5682,7 +5682,7 @@
                           "value": null
                       },
                       "billing.address.zip": {
-                          "display_name": "billing_zip",
+                          "display_name": "zip",
                           "field_type": "user_address_pincode",
                           "required_field": "payment_method_data.billing.address.zip",
                           "value": null
@@ -5770,7 +5770,7 @@
                           "value": null
                       },
                       "billing.email": {
-                          "display_name": "email_address",
+                          "display_name": "email",
                           "field_type": "user_email_address",
                           "required_field": "payment_method_data.billing.email",
                           "value": null
@@ -6757,7 +6757,7 @@
                       "payment_method_data.billing.phone.number": {
                           "display_name": "phone_number",
                           "field_type": "user_phone_number",
-                          "required_field": "billing.phone.number",
+                          "required_field": "payment_method_data.billing.phone.number",
                           "value": null
                       },
                       "payment_method_data.card.card_cvc": {
@@ -7093,7 +7093,7 @@
                           "value": null
                       },
                       "billing.phone.number": {
-                          "display_name": "phone_number",
+                          "display_name": "phone",
                           "field_type": "user_phone_number",
                           "required_field": "payment_method_data.billing.phone.number",
                           "value": null
@@ -7118,13 +7118,13 @@
                       },
                       "shipping.address.line1": {
                           "display_name": "line1",
-                          "field_type": "user_address_line1",
+                          "field_type": "user_shipping_address_line1",
                           "required_field": "shipping.address.line1",
                           "value": null
                       },
                       "shipping.address.line2": {
                           "display_name": "line2",
-                          "field_type": "user_address_line2",
+                          "field_type": "user_shipping_address_line2",
                           "required_field": "shipping.address.line2",
                           "value": null
                       },
@@ -7444,7 +7444,7 @@
                       "payment_method_data.billing.phone.number": {
                           "display_name": "phone_number",
                           "field_type": "user_phone_number",
-                          "required_field": "billing.phone.number",
+                          "required_field": "payment_method_data.billing.phone.number",
                           "value": null
                       }
                   }
@@ -7527,7 +7527,7 @@
                       "payment_method_data.billing.phone.number": {
                           "display_name": "phone_number",
                           "field_type": "user_phone_number",
-                          "required_field": "billing.phone.number",
+                          "required_field": "payment_method_data.billing.phone.number",
                           "value": null
                       }
                   }
@@ -7539,7 +7539,7 @@
               "adyen": {
                   "common": {
                       "billing.address.country": {
-                          "display_name": "billing_country",
+                          "display_name": "country",
                           "field_type": {
                               "user_address_country": {
                                   "options": [
@@ -7604,7 +7604,7 @@
                   "mandate": {},
                   "non_mandate": {
                       "billing.address.country": {
-                          "display_name": "billing_country",
+                          "display_name": "country",
                           "field_type": {
                               "user_address_country": {
                                   "options": [
@@ -8372,7 +8372,7 @@
               "novalnet": {
                   "common": {
                       "billing.email": {
-                          "display_name": "email_address",
+                          "display_name": "email",
                           "field_type": "user_email_address",
                           "required_field": "payment_method_data.billing.email",
                           "value": null
@@ -8743,7 +8743,7 @@
               "novalnet": {
                   "common": {
                       "billing.email": {
-                          "display_name": "email_address",
+                          "display_name": "email",
                           "field_type": "user_email_address",
                           "required_field": "payment_method_data.billing.email",
                           "value": null
@@ -8911,7 +8911,7 @@
                       "payment_method_data.billing.phone.number": {
                           "display_name": "phone_number",
                           "field_type": "user_phone_number",
-                          "required_field": "billing.phone.number",
+                          "required_field": "payment_method_data.billing.phone.number",
                           "value": null
                       }
                   }
@@ -8929,7 +8929,7 @@
                           "value": null
                       },
                       "billing.address.country": {
-                          "display_name": "nationality",
+                          "display_name": "country",
                           "field_type": {
                               "user_country": {
                                   "options": [
@@ -9185,7 +9185,7 @@
                           "value": null
                       },
                       "billing.email": {
-                          "display_name": "email_address",
+                          "display_name": "email",
                           "field_type": "user_email_address",
                           "required_field": "payment_method_data.billing.email",
                           "value": null
@@ -9289,7 +9289,7 @@
               "novalnet": {
                   "common": {
                       "billing.email": {
-                          "display_name": "email_address",
+                          "display_name": "email",
                           "field_type": "user_email_address",
                           "required_field": "payment_method_data.billing.email",
                           "value": null

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

@jagan-jaya jagan-jaya self-assigned this Mar 17, 2025
Copy link

semanticdiff-com bot commented Mar 17, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/core/payment_methods/cards.rs  47% smaller
  crates/router/src/configs/settings.rs  1% smaller
  crates/router/src/configs/defaults.rs  1% smaller
  Cargo.lock Unsupported file format
  crates/payment_methods/Cargo.toml Unsupported file format
  crates/payment_methods/src/configs.rs  0% smaller
  crates/payment_methods/src/configs/default.rs  0% smaller
  crates/payment_methods/src/configs/settings.rs  0% smaller
  crates/payment_methods/src/lib.rs  0% smaller
  crates/router/Cargo.toml Unsupported file format
  crates/router/src/configs/defaults/payment_connector_required_fields.rs Unsupported file format
  crates/router/src/configs/secrets_transformers.rs  0% smaller

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant