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(router): fix billing details path in required field #5992

Merged
merged 2 commits into from
Sep 26, 2024

Conversation

AkshayaFoiger
Copy link
Contributor

@AkshayaFoiger AkshayaFoiger commented Sep 23, 2024

Type of Change

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

Description

When we provide address in both billing and payment_method_data.billing, only one will be taken. Hence the details provided in one of the path will discarded.
eg/- if we provide payment_method_data.billing.phone.number and billing.phone.country_code, we will still throw a required_field phone_number not found error.
PR fixes, this bug for the following payment methods

  1. Ach Bank Transfer
    2.Sepa Bank Transfer
    3.Bacs Bank Transfer
    4.Klarna
    5.Affirm
    6.Boleto
    7.OnlineBankingPoland

This PR will not affect the current behavior of SDK as SDK has not enabled required_fields for these payment methods

How did you test it?

  1. Test all the payment methods through SDK, after enabling required fields.

List PML

curl --location 'http://localhost:8080/account/payment_methods?client_secret=pay_4Q5gYsCHR8NzW5aOJQ6A_secret_HLlMnZDQR9NBg1ejePHm' \
--header 'Accept: application/json' \
--header 'api-key: pk_dev_ad24dbf9b29b45e386a11ea8ad478f8f'

Response

  1. Ach Bank Transfer
 {
   		 "payment_method": "bank_transfer",
   		 "payment_method_types": [
       		 {
           		 "payment_method_type": "ach",
           		 "payment_experience": null,
           		 "card_networks": null,
           		 "bank_names": null,
           		 "bank_debits": null,
           		 "bank_transfers": {
               		 "eligible_connectors": [
                   		 "stripe"
               		 ]
           		 },
           		 "required_fields": {
               		 "billing.email": {
                   		 "required_field": "payment_method_data.billing.email",
                   		 "display_name": "email",
                   		 "field_type": "user_email_address",
                   		 "value": "example@example.com"
               		 }
           		 },
           		 "surcharge_details": null,
           		 "pm_auth_connector": null
       		 },
        		 ]
   	 }

  1. Sepa Bank Transfer
{
           		 "payment_method_type": "sepa",
           		 "payment_experience": null,
           		 "card_networks": null,
           		 "bank_names": null,
           		 "bank_debits": null,
           		 "bank_transfers": {
               		 "eligible_connectors": [
                   		 "stripe"
               		 ]
           		 },
           		 "required_fields": {
               		 "billing.address.country": {
                   		 "required_field": "payment_method_data.billing.address.country",
                   		 "display_name": "country",
                   		 "field_type": {
                       		 "user_address_country": {
                           		 "options": [
                               		 "BE",
                               		 "DE",
                               		 "ES",
                               		 "FR",
                               		 "IE",
                               		 "NL"
                           		 ]
                       		 }
                   		 },
                   		 "value": null
               		 },
               		 "billing.address.last_name": {
                   		 "required_field": "payment_method_data.billing.address.last_name",
                   		 "display_name": "card_holder_name",
                   		 "field_type": "user_full_name",
                   		 "value": null
               		 },
               		 "billing.email": {
                   		 "required_field": "payment_method_data.billing.email",
                   		 "display_name": "email",
                   		 "field_type": "user_email_address",
                   		 "value": "example@example.com"
               		 },
               		 "billing.address.first_name": {
                   		 "required_field": "payment_method_data.billing.address.first_name",
                   		 "display_name": "card_holder_name",
                   		 "field_type": "user_full_name",
                   		 "value": null
               		 }
           		 },
           		 "surcharge_details": null,
           		 "pm_auth_connector": null
       		 },
       		 {
           		 "payment_method_type": "multibanco",
           		 "payment_experience": null,
           		 "card_networks": null,
           		 "bank_names": null,
           		 "bank_debits": null,
           		 "bank_transfers": {
               		 "eligible_connectors": [
                   		 "stripe"
               		 ]
           		 },
           		 "required_fields": {
               		 "billing.email": {
                   		 "required_field": "payment_method_data.billing.email",
                   		 "display_name": "email",
                   		 "field_type": "user_email_address",
                   		 "value": "example@example.com"
               		 }
           		 },
           		 "surcharge_details": null,
           		 "pm_auth_connector": null
       		 },
       		 {
           		 "payment_method_type": "ach",
           		 "payment_experience": null,
           		 "card_networks": null,
           		 "bank_names": null,
           		 "bank_debits": null,
           		 "bank_transfers": {
               		 "eligible_connectors": [
                   		 "stripe"
               		 ]
           		 },
           		 "required_fields": {
               		 "billing.email": {
                   		 "required_field": "payment_method_data.billing.email",
                   		 "display_name": "email",
                   		 "field_type": "user_email_address",
                   		 "value": "example@example.com"
               		 }
           		 },
           		 "surcharge_details": null,
           		 "pm_auth_connector": null
       		 }
  1. Bacs bank transfer
 {
        	"payment_method": "bank_transfer",
        	"payment_method_types": [
            	{
                	"payment_method_type": "bacs",
                	"payment_experience": null,
                	"card_networks": null,
                	"bank_names": null,
                	"bank_debits": null,
                	"bank_transfers": {
                    	"eligible_connectors": [
                        	"stripe"
                    	]
                	},
                	"required_fields": {
                    	"billing.address.first_name": {
                        	"required_field": "payment_method_data.billing.address.first_name",
                        	"display_name": "card_holder_name",
                        	"field_type": "user_full_name",
                        	"value": null
                    	},
                    	"billing.address.last_name": {
                        	"required_field": "payment_method_data.billing.address.last_name",
                        	"display_name": "card_holder_name",
                        	"field_type": "user_full_name",
                        	"value": null
                    	},
                    	"billing.email": {
                        	"required_field": "payment_method_data.billing.email",
                        	"display_name": "email",
                        	"field_type": "user_email_address",
                        	"value": "example@example.com"
                    	}
                	},
                	"surcharge_details": null,
                	"pm_auth_connector": null
            	},
             	]
    	}

  1. Klarna
{
  	"payment_method": "pay_later",
  	"payment_method_types": [
    	{
      	"payment_method_type": "klarna",
      	"payment_experience": [
        	{
          	"payment_experience_type": "redirect_to_url",
          	"eligible_connectors": ["adyen"]
        	}
      	],
      	"card_networks": null,
      	"bank_names": null,
      	"bank_debits": null,
      	"bank_transfers": null,
      	"required_fields": {
        	"payment_method_data.pay_later.klarna.billing_country": {
          	"required_field": "payment_method_data.pay_later.klarna.billing_country",
          	"display_name": "billing_country",
          	"field_type": {
            	"user_address_country": {
              	"options": ["ALL"]
            	}
          	},
          	"value": null
        	},
        	"billing.email": {
          	"required_field": "payment_method_data.billing.email",
          	"display_name": "email",
          	"field_type": "user_email_address",
          	"value": "hyperswitch_sdk_demo_id@gmail.com"
        	}
      	},
      	"surcharge_details": null,
      	"pm_auth_connector": null
    	}
  	]
	}}
]

5.Affirm

 {
  	"payment_method": "pay_later",
  	"payment_method_types": [
    	{
      	"payment_method_type": "affirm",
      	"payment_experience": [
        	{
          	"payment_experience_type": "redirect_to_url",
          	"eligible_connectors": ["adyen"]
        	}
      	],
      	"card_networks": null,
      	"bank_names": null,
      	"bank_debits": null,
      	"bank_transfers": null,
      	"required_fields":{
    "billing.address.first_name": {
   	 "required_field": "payment_method_data.billing.address.first_name",
   	 "display_name": "card_holder_name",
   	 "field_type": "user_full_name",
   	 "value": null
    },
    "billing.address.last_name": {
   	 "required_field": "payment_method_data.billing.address.last_name",
   	 "display_name": "card_holder_name",
   	 "field_type": "user_full_name",
   	 "value": null
    },
    "billing.address.city": {
   	 "required_field": "payment_method_data.billing.address.city",
   	 "display_name": "city",
   	 "field_type": "user_address_city",
   	 "value": null
    },
    "billing.address.state": {
   	 "required_field": "payment_method_data.billing.address.state",
   	 "display_name": "state",
   	 "field_type": "user_address_state",
   	 "value": null
    },
    "billing.address.zip": {
   	 "required_field": "payment_method_data.billing.address.zip",
   	 "display_name": "zip",
   	 "field_type": "user_address_pincode",
   	 "value": null
    },
    "billing.address.country": {
   	 "required_field": "payment_method_data.billing.address.country",
   	 "display_name": "country",
   	 "field_type": {
   		 "user_address_country": {
   			 "options": ["CA"]
   		 }
   	 },
   	 "value": null
    },
    "payment_method_data.billing.phone.number": {
   	 "required_field": "payment_method_data.billing.phone.number",
   	 "display_name": "phone_number",
   	 "field_type": "user_phone_number",
   	 "value": null
    },
    "billing.phone.country_code": {
   	 "required_field": "payment_method_data.billing.phone.country_code",
   	 "display_name": "dialing_code",
   	 "field_type": "user_phone_number_country_code",
   	 "value": null
    },
    "billing.email": {
   	 "required_field": "payment_method_data.billing.email",
   	 "display_name": "email",
   	 "field_type": "user_email_address",
   	 "value": null
    },
    "billing.address.line1": {
   	 "required_field": "payment_method_data.billing.address.line1",
   	 "display_name": "line1",
   	 "field_type": "user_address_line1",
   	 "value": null
    },
    "billing.address.line2": {
   	 "required_field": "payment_method_data.billing.address.line2",
   	 "display_name": "line2",
   	 "field_type": "user_address_line2",
   	 "value": null
    },
    "shipping.address.city": {
   	 "required_field": "shipping.address.city",
   	 "display_name": "city",
   	 "field_type": "user_shipping_address_city",
   	 "value": null
    },
    "shipping.address.zip": {
   	 "required_field": "shipping.address.zip",
   	 "display_name": "zip",
   	 "field_type": "user_shipping_address_pincode",
   	 "value": null
    },
    "shipping.address.country": {
   	 "required_field": "shipping.address.country",
   	 "display_name": "country",
   	 "field_type": {
   		 "user_shipping_address_country": {
   			 "options": ["ALL"]
   		 }
   	 },
   	 "value": null
    },
    "shipping.address.line1": {
   	 "required_field": "shipping.address.line1",
   	 "display_name": "line1",
   	 "field_type": "user_shipping_address_line1",
   	 "value": null
    },
    "shipping.address.line2": {
   	 "required_field": "shipping.address.line2",
   	 "display_name": "line2",
   	 "field_type": "user_shipping_address_line2",
   	 "value": null
    }
},
      	"surcharge_details": null,
      	"pm_auth_connector": null
    	}]
}

6.Boleto

{
  	"payment_method": "voucher",
  	"payment_method_types": [
    	{
      	"payment_method_type": "boleto",
      	"payment_experience": [
        	{
          	"payment_experience_type": "redirect_to_url",
          	"eligible_connectors": ["adyen"]
        	}
      	],
      	"card_networks": null,
      	"bank_names": null,
      	"bank_debits": null,
      	"bank_transfers": null,
      	"required_fields": {
        	"billing.address.state": {
          	"required_field": "payment_method_data.billing.address.state",
          	"display_name": "state",
          	"field_type": "user_address_state",
          	"value": "California"
        	},
        	"billing.address.first_name": {
          	"required_field": "payment_method_data.billing.address.first_name",
          	"display_name": "card_holder_name",
          	"field_type": "user_full_name",
          	"value": "joseph"
        	},
        	"billing.address.line1": {
          	"required_field": "payment_method_data.billing.address.line1",
          	"display_name": "line1",
          	"field_type": "user_address_line1",
          	"value": "1467"
        	},
        	"billing.address.city": {
          	"required_field": "payment_method_data.billing.address.city",
          	"display_name": "city",
          	"field_type": "user_address_city",
          	"value": "San Francisco"
        	},
        	"billing.address.line2": {
          	"required_field": "payment_method_data.billing.address.line2",
          	"display_name": "line2",
          	"field_type": "user_address_line2",
          	"value": "Harrison Street"
        	},
        	"billing.address.zip": {
          	"required_field": "payment_method_data.billing.address.zip",
          	"display_name": "zip",
          	"field_type": "user_address_pincode",
          	"value": "94122"
        	},
        	"billing.address.last_name": {
          	"required_field": "payment_method_data.billing.address.last_name",
          	"display_name": "card_holder_name",
          	"field_type": "user_full_name",
          	"value": "Doe"
        	},
        	"payment_method_data.voucher.boleto.social_security_number": {
          	"required_field": "payment_method_data.voucher.boleto.social_security_number",
          	"display_name": "social_security_number",
          	"field_type": "text",
          	"value": null
        	},
        	"billing.address.country": {
          	"required_field": "payment_method_data.billing.address.country",
          	"display_name": "country",
          	"field_type": {
            	"user_address_country": {
              	"options": ["BR"]
            	}
          	},
          	"value": "BR"
        	}
      	},
      	"surcharge_details": null,
      	"pm_auth_connector": null
    	}
  	]
	}
  1. Online Banking Poland
  {
                    "payment_method_type": "online_banking_poland",
                    "payment_experience": null,
                    "card_networks": null,
                    "bank_names": [
                        {
                            "bank_name": [
                                "bank_nowy_s_a",
                                "credit_agricole",
                                "pay_with_plus_bank",
                                "pay_with_i_n_g",
                                "pay_with_inteligo",
                                "place_z_i_p_k_o",
                                "pay_with_citi_handlowy",
                                "velo_bank",
                                "b_n_p_paribas_poland",
                                "blik_p_s_p",
                                "banki_spoldzielcze",
                                "bank_millennium",
                                "pay_with_b_o_s",
                                "toyota_bank",
                                "pay_with_alior_bank",
                                "e_transfer_pocztowy24",
                                "m_bank",
                                "bank_p_e_k_a_o_s_a",
                                "santander_przelew24"
                            ],
                            "eligible_connectors": [
                                "adyen"
                            ]
                        }
                    ],
                    "bank_debits": null,
                    "bank_transfers": null,
                    "required_fields": {
                        "payment_method_data.bank_redirect.open_banking_poland.issuer": {
                            "required_field": "payment_method_data.bank_redirect.open_banking_poland.issuer",
                            "display_name": "issuer",
                            "field_type": "user_bank",
                            "value": null
                        },
                        "billing.email": {
                            "required_field": "payment_method_data.billing.email",
                            "display_name": "email",
                            "field_type": "user_email_address",
                            "value": null
                        }
                    },
                    "surcharge_details": null,
                    "pm_auth_connector": 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

@AkshayaFoiger AkshayaFoiger requested a review from a team as a code owner September 23, 2024 07:06
Copy link

semanticdiff-com bot commented Sep 23, 2024

Review changes with SemanticDiff.

Analyzed 1 of 1 files.

Overall, the semantic diff is 8% smaller than the GitHub diff.

Filename Status
✔️ crates/router/src/configs/defaults.rs 7.02% smaller

@AkshayaFoiger AkshayaFoiger self-assigned this Sep 23, 2024
@AkshayaFoiger AkshayaFoiger added A-connector-compatibility Area: Connector compatibility C-bug Category: Bug labels Sep 23, 2024
SamraatBansal
SamraatBansal previously approved these changes Sep 23, 2024
SanchithHegde
SanchithHegde previously approved these changes Sep 24, 2024
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Sep 26, 2024
Merged via the queue into main with commit e0a33f8 Sep 26, 2024
24 checks passed
@Gnanasundari24 Gnanasundari24 deleted the fix-default-fields branch September 26, 2024 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-connector-compatibility Area: Connector compatibility C-bug Category: Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants