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(bank-redirect): dynamic field changes for bankredirect payment method #4650

Merged
merged 2 commits into from
May 23, 2024

Conversation

swangi-kumari
Copy link
Contributor

@swangi-kumari swangi-kumari commented May 15, 2024

Type of Change

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

Description

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?

  1. Payment connector Create via Stripe
{
    "connector_type": "fiz_operations",
    "connector_name": "stripe",
    "business_country": "US",
    "business_label": "default",
    "connector_account_details": {
        "auth_type": "HeaderKey",
        "api_key": "{{connector_api_key}}"
    },
    "test_mode": false,
    "disabled": false,
    "payment_methods_enabled": [
        {
            "payment_method": "bank_redirect",
            "payment_method_types": [
                {
                    "payment_method_type": "ideal",
                    "payment_experience": "redirect_to_url",
                    "card_networks": null,
                    "accepted_currencies": null,
                    "accepted_countries": null,
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "giropay",
                    "payment_experience": "redirect_to_url",
                    "card_networks": null,
                    "accepted_currencies": null,
                    "accepted_countries": null,
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "sofort",
                    "payment_experience": "redirect_to_url",
                    "card_networks": null,
                    "accepted_currencies": null,
                    "accepted_countries": null,
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "eps",
                    "payment_experience": "redirect_to_url",
                    "card_networks": null,
                    "accepted_currencies": null,
                    "accepted_countries": null,
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        }
    ],
    "metadata": {
        "google_pay": {
            "allowed_payment_methods": [
                {
                    "type": "CARD",
                    "parameters": {
                        "allowed_auth_methods": [
                            "PAN_ONLY",
                            "CRYPTOGRAM_3DS"
                        ],
                        "allowed_card_networks": [
                            "AMEX",
                            "DISCOVER",
                            "INTERAC",
                            "JCB",
                            "MASTERCARD",
                            "VISA"
                        ]
                    },
                    "tokenization_specification": {
                        "type": "PAYMENT_GATEWAY",
                        "parameters": {
                            "gateway": "example",
                            "gateway_merchant_id": "{{gateway_merchant_id}}"
                        }
                    }
                }
            ],
            "merchant_info": {
                "merchant_name": "Narayan Bhat"
            }
        }
    }
}
  1. Create a idea pm via Stripe
{
    "amount": 6540,
    "currency": "EUR",
    "confirm": false,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "amount_to_capture": 6540,
    "customer_id": "StripeCustomer",
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+1",
    "description": "Its my first payment request",
    "authentication_type": "no_three_ds",
    "return_url": "https://duck.com",
     "payment_method": "bank_redirect",
    "payment_method_type": "ideal",
    "payment_method_data": {
        "bank_redirect": {
            "ideal": {
                "bank_name": "ing",
                "preferred_language": "en"
            }
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "DE",
            "first_name": "sundari"
        }
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "DE",
            "first_name": "sundari"
        }
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    },
    "routing": {
        "type": "single",
        "data": "stripe"
    }
}
  1. List Payment Method for a Merchant
  • In response check for required fields for bank_redirect payment methods
{
    "redirect_url": "https://duck.com/",
    "currency": "EUR",
    "payment_methods": [
        {
            "payment_method": "bank_redirect",
            "payment_method_types": [
                {
                    "payment_method_type": "sofort",
                    "payment_experience": [
                        {
                            "payment_experience_type": "redirect_to_url",
                            "eligible_connectors": [
                                "stripe"
                            ]
                        }
                    ],
                    "card_networks": null,
                    "bank_names": null,
                    "bank_debits": null,
                    "bank_transfers": null,
                    "required_fields": {
                        "billing.address.country": {
                            "required_field": "payment_method_data.billing.address.country",
                            "display_name": "country",
                            "field_type": {
                                "user_country": {
                                    "options": [
                                        "ES",
                                        "AT",
                                        "NL",
                                        "DE",
                                        "BE"
                                    ]
                                }
                            },
                            "value": "DE"
                        }
                    },
                    "surcharge_details": null,
                    "pm_auth_connector": null
                },
                {
                    "payment_method_type": "giropay",
                    "payment_experience": [
                        {
                            "payment_experience_type": "redirect_to_url",
                            "eligible_connectors": [
                                "stripe"
                            ]
                        }
                    ],
                    "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": "billing_name",
                            "field_type": "user_billing_name",
                            "value": "sundari"
                        },
                        "billing.address.last_name": {
                            "required_field": "payment_method_data.billing.address.last_name",
                            "display_name": "billing_name",
                            "field_type": "user_billing_name",
                            "value": null
                        }
                    },
                    "surcharge_details": null,
                    "pm_auth_connector": null
                }
            ]
        },
        {
            "payment_method": "bank_redirect",
            "payment_method_types": [
                {
                    "payment_method_type": "giropay",
                    "payment_experience": null,
                    "card_networks": null,
                    "bank_names": [
                        {
                            "bank_name": [],
                            "eligible_connectors": [
                                "stripe"
                            ]
                        }
                    ],
                    "bank_debits": null,
                    "bank_transfers": null,
                    "required_fields": {
                        "billing.address.first_name": {
                            "required_field": "payment_method_data.billing.address.first_name",
                            "display_name": "billing_name",
                            "field_type": "user_billing_name",
                            "value": "sundari"
                        },
                        "billing.address.last_name": {
                            "required_field": "payment_method_data.billing.address.last_name",
                            "display_name": "billing_name",
                            "field_type": "user_billing_name",
                            "value": null
                        }
                    },
                    "surcharge_details": null,
                    "pm_auth_connector": null
                },
                {
                    "payment_method_type": "sofort",
                    "payment_experience": null,
                    "card_networks": null,
                    "bank_names": [
                        {
                            "bank_name": [],
                            "eligible_connectors": [
                                "stripe"
                            ]
                        }
                    ],
                    "bank_debits": null,
                    "bank_transfers": null,
                    "required_fields": {
                        "billing.address.country": {
                            "required_field": "payment_method_data.billing.address.country",
                            "display_name": "country",
                            "field_type": {
                                "user_country": {
                                    "options": [
                                        "ES",
                                        "AT",
                                        "NL",
                                        "DE",
                                        "BE"
                                    ]
                                }
                            },
                            "value": "DE"
                        }
                    },
                    "surcharge_details": null,
                    "pm_auth_connector": null
                }
            ]
        }
    ],
    "mandate_payment": null,
    "merchant_name": "NewAge Retailer",
    "show_surcharge_breakup_screen": false,
    "payment_type": "normal"
}

  1. Payment connector Create via Aci
{
  "connector_type": "fiz_operations",
  "connector_name": "aci",
  "connector_account_details": {
    "auth_type": "BodyKey",
    "api_key": "{{connector_api_key}}",
    "key1": "{{connector_key1}}"
  },
  "test_mode": false,
  "disabled": false,
  "payment_methods_enabled": [
    {
      "payment_method": "card",
      "payment_method_types": [
        {
          "payment_method_type": "credit",
          "card_networks": [
            "Visa",
            "Mastercard"
          ],
          "minimum_amount": 1,
          "maximum_amount": 68607706,
          "recurring_enabled": true,
          "installment_payment_enabled": true
        },
        {
          "payment_method_type": "debit",
          "card_networks": [
            "Visa",
            "Mastercard"
          ],
          "minimum_amount": 1,
          "maximum_amount": 68607706,
          "recurring_enabled": true,
          "installment_payment_enabled": true
        }
      ]
    },
    {
            "payment_method": "bank_redirect",
            "payment_method_types": [
                {
                    "payment_method_type": "ideal",
                    "payment_experience": "redirect_to_url",
                    "card_networks": null,
                    "accepted_currencies": null,
                    "accepted_countries": {
                        "type": "enable_only",
                        "list": [
                            "NL"
                        ]
                    },
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "giropay",
                    "payment_experience": "redirect_to_url",
                    "card_networks": null,
                    "accepted_currencies": null,
                     "accepted_countries": {
                        "type": "enable_only",
                        "list": [
                            "DE"
                        ]
                    },
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "sofort",
                    "payment_experience": "redirect_to_url",
                    "card_networks": null,
                    "accepted_currencies": null,
                     "accepted_countries": {
                        "type": "enable_only",
                        "list": [
                            "ES", "GB", "SE", "AT", "NL"
                        ]
                    },
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "eps",
                    "payment_experience": "redirect_to_url",
                    "card_networks": null,
                    "accepted_currencies": null,
                     "accepted_countries": {
                        "type": "enable_only",
                        "list": [
                            "AT"
                        ]
                    },
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        }
  ],
  "metadata": {
    "city": "NY",
    "unit": "245"
  }
}
  1. Create a EPS payment via ACI with confirm false
{
  "amount": 6540,
  "currency": "EUR",
  "confirm": false,
  "capture_method": "automatic",
  "capture_on": "2022-09-10T10:11:12Z",
  "amount_to_capture": 6540,
  "customer_id": "StripeCustomer",
  "email": "guest@example.com",
  "name": "John Doe",
  "phone": "999999999",
  "phone_country_code": "+1",
  "description": "Its my first payment request",
  "authentication_type": "no_three_ds",
  "return_url": "https://hs-payments-test.netlify.app/payments",
  "payment_method": "bank_redirect",
  "payment_method_type": "eps",
  "payment_method_data": {
    "bank_redirect": {
      "eps": {
        "bank_name": "ing"
      }
    }
  },
  "billing": {
    "address": {
      "line1": "1467",
      "line2": "Harrison Street",
      "line3": "Harrison Street",
      "city": "San Fransico",
      "state": "California",
      "zip": "94122",
      "country": "AT",
      "first_name": "joseph",
      "last_name": "Doe"
    },
    "phone": {
      "number": "8056594427",
      "country_code": "+91"
    }
  },
  "shipping": {
    "address": {
      "line1": "1467",
      "line2": "Harrison Street",
      "line3": "Harrison Street",
      "city": "San Fransico",
      "state": "California",
      "zip": "94122",
      "country": "AT",
      "first_name": "joseph",
      "last_name": "Doe"
    },
    "phone": {
      "number": "8056594427",
      "country_code": "+91"
    }
  },
  "statement_descriptor_name": "joseph",
  "statement_descriptor_suffix": "JS",
  "metadata": {
    "udf1": "value1",
    "new_customer": "true",
    "login_date": "2019-09-10T10:11:12Z"
  }
}
  1. List Payment Method for a Merchant
  • In response check for required fields for bank_redirect payment methods
{
    "redirect_url": "https://google.com/success",
    "currency": "EUR",
    "payment_methods": [
        {
            "payment_method": "bank_redirect",
            "payment_method_types": [
                {
                    "payment_method_type": "eps",
                    "payment_experience": [
                        {
                            "payment_experience_type": "redirect_to_url",
                            "eligible_connectors": [
                                "aci"
                            ]
                        }
                    ],
                    "card_networks": null,
                    "bank_names": null,
                    "bank_debits": null,
                    "bank_transfers": null,
                    "required_fields": {
                        "billing.address.country": {
                            "required_field": "payment_method_data.billing.address.country",
                            "display_name": "bank_account_country",
                            "field_type": {
                                "user_country": {
                                    "options": [
                                        "AT"
                                    ]
                                }
                            },
                            "value": "AT"
                        }
                    },
                    "surcharge_details": null,
                    "pm_auth_connector": null
                },
                {
                    "payment_method_type": "sofort",
                    "payment_experience": [
                        {
                            "payment_experience_type": "redirect_to_url",
                            "eligible_connectors": [
                                "aci"
                            ]
                        }
                    ],
                    "card_networks": null,
                    "bank_names": null,
                    "bank_debits": null,
                    "bank_transfers": null,
                    "required_fields": {
                        "billing.address.country": {
                            "required_field": "payment_method_data.billing.address.country",
                            "display_name": "country",
                            "field_type": {
                                "user_country": {
                                    "options": [
                                        "ES",
                                        "GB",
                                        "SE",
                                        "AT",
                                        "NL",
                                        "DE",
                                        "CH",
                                        "BE",
                                        "FR",
                                        "FI",
                                        "IT",
                                        "PL"
                                    ]
                                }
                            },
                            "value": "AT"
                        }
                    },
                    "surcharge_details": null,
                    "pm_auth_connector": null
                }
            ]
        },
        {
            "payment_method": "card",
            "payment_method_types": [
                {
                    "payment_method_type": "credit",
                    "payment_experience": null,
                    "card_networks": [
                        {
                            "card_network": "Mastercard",
                            "surcharge_details": null,
                            "eligible_connectors": [
                                "aci"
                            ]
                        },
                        {
                            "card_network": "Visa",
                            "surcharge_details": null,
                            "eligible_connectors": [
                                "aci"
                            ]
                        }
                    ],
                    "bank_names": null,
                    "bank_debits": null,
                    "bank_transfers": null,
                    "required_fields": {
                        "payment_method_data.card.card_exp_year": {
                            "required_field": "payment_method_data.card.card_exp_year",
                            "display_name": "card_exp_year",
                            "field_type": "user_card_expiry_year",
                            "value": null
                        },
                        "payment_method_data.card.card_exp_month": {
                            "required_field": "payment_method_data.card.card_exp_month",
                            "display_name": "card_exp_month",
                            "field_type": "user_card_expiry_month",
                            "value": null
                        },
                        "payment_method_data.card.card_cvc": {
                            "required_field": "payment_method_data.card.card_cvc",
                            "display_name": "card_cvc",
                            "field_type": "user_card_cvc",
                            "value": null
                        },
                        "payment_method_data.card.card_number": {
                            "required_field": "payment_method_data.card.card_number",
                            "display_name": "card_number",
                            "field_type": "user_card_number",
                            "value": null
                        },
                        "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.last_name": {
                            "required_field": "payment_method_data.billing.address.last_name",
                            "display_name": "card_holder_name",
                            "field_type": "user_full_name",
                            "value": "Doe"
                        }
                    },
                    "surcharge_details": null,
                    "pm_auth_connector": null
                },
                {
                    "payment_method_type": "debit",
                    "payment_experience": null,
                    "card_networks": [
                        {
                            "card_network": "Visa",
                            "surcharge_details": null,
                            "eligible_connectors": [
                                "aci"
                            ]
                        },
                        {
                            "card_network": "Mastercard",
                            "surcharge_details": null,
                            "eligible_connectors": [
                                "aci"
                            ]
                        }
                    ],
                    "bank_names": null,
                    "bank_debits": null,
                    "bank_transfers": null,
                    "required_fields": {
                        "payment_method_data.card.card_cvc": {
                            "required_field": "payment_method_data.card.card_cvc",
                            "display_name": "card_cvc",
                            "field_type": "user_card_cvc",
                            "value": null
                        },
                        "payment_method_data.card.card_exp_month": {
                            "required_field": "payment_method_data.card.card_exp_month",
                            "display_name": "card_exp_month",
                            "field_type": "user_card_expiry_month",
                            "value": null
                        },
                        "payment_method_data.card.card_exp_year": {
                            "required_field": "payment_method_data.card.card_exp_year",
                            "display_name": "card_exp_year",
                            "field_type": "user_card_expiry_year",
                            "value": null
                        },
                        "payment_method_data.card.card_number": {
                            "required_field": "payment_method_data.card.card_number",
                            "display_name": "card_number",
                            "field_type": "user_card_number",
                            "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": "Doe"
                        },
                        "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"
                        }
                    },
                    "surcharge_details": null,
                    "pm_auth_connector": null
                }
            ]
        },
        {
            "payment_method": "bank_redirect",
            "payment_method_types": [
                {
                    "payment_method_type": "sofort",
                    "payment_experience": null,
                    "card_networks": null,
                    "bank_names": [
                        {
                            "bank_name": [],
                            "eligible_connectors": [
                                "aci"
                            ]
                        }
                    ],
                    "bank_debits": null,
                    "bank_transfers": null,
                    "required_fields": {
                        "billing.address.country": {
                            "required_field": "payment_method_data.billing.address.country",
                            "display_name": "country",
                            "field_type": {
                                "user_country": {
                                    "options": [
                                        "ES",
                                        "GB",
                                        "SE",
                                        "AT",
                                        "NL",
                                        "DE",
                                        "CH",
                                        "BE",
                                        "FR",
                                        "FI",
                                        "IT",
                                        "PL"
                                    ]
                                }
                            },
                            "value": "AT"
                        }
                    },
                    "surcharge_details": null,
                    "pm_auth_connector": null
                },
                {
                    "payment_method_type": "eps",
                    "payment_experience": null,
                    "card_networks": null,
                    "bank_names": [],
                    "bank_debits": null,
                    "bank_transfers": null,
                    "required_fields": {
                        "billing.address.country": {
                            "required_field": "payment_method_data.billing.address.country",
                            "display_name": "bank_account_country",
                            "field_type": {
                                "user_country": {
                                    "options": [
                                        "AT"
                                    ]
                                }
                            },
                            "value": "AT"
                        }
                    },
                    "surcharge_details": null,
                    "pm_auth_connector": null
                }
            ]
        }
    ],
    "mandate_payment": null,
    "merchant_name": "NewAge Retailer",
    "show_surcharge_breakup_screen": false,
    "payment_type": "normal"
}

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

@swangi-kumari swangi-kumari self-assigned this May 15, 2024
@swangi-kumari swangi-kumari requested a review from a team as a code owner May 15, 2024 10:11
@swangi-kumari swangi-kumari added A-connector-integration Area: Connector integration C-refactor Category: Refactor labels May 15, 2024
RequiredFieldInfo {
required_field: "payment_method_data.billing.address.first_name".to_string(),
display_name: "billing_name".to_string(),
field_type: enums::FieldType::UserBillingName,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

field type has to be UserFullName

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use UserBillingName also, In sdk , value for first_name and last_name will be concatenated and will appear as one field Billing Name.

RequiredFieldInfo {
required_field: "payment_method_data.billing.address.last_name".to_string(),
display_name: "billing_name".to_string(),
field_type: enums::FieldType::UserBillingName,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this case too

@likhinbopanna likhinbopanna added this pull request to the merge queue May 23, 2024
Merged via the queue into main with commit da2dc10 May 23, 2024
16 checks passed
@likhinbopanna likhinbopanna deleted the bank-redirect-dynamic-fields branch May 23, 2024 07:07
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-refactor Category: Refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants