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

feat(router): Add v2 endpoint to retrieve payment filters at merchant and profile level #7171

Open
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

aniketburman014
Copy link
Contributor

@aniketburman014 aniketburman014 commented Feb 3, 2025

Type of Change

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

Description

Added the v2/payments/filter and v2/payments/profile/filter API to retrieve available payment filters (connectors, statuses, payment methods, authentication types, etc.) at merchant and profile level.

Key Changes

1. `get_payment_filters_profile` -> `crates/router/src/routes/payments.rs`
   - Supports profile-based filtering for merchants.
   
2. `get_payment_filters` -> `crates/router/src/core/payments.rs`
   - Refactor get_payment_filters to support both v1 and v2  
   - Updated get_payment_filters to work with both PaymentListFiltersV1 and PaymentListFiltersV2  

Additional Changes

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

Links to the files with corresponding changes.

  1. crates/api_models/src/admin.rs
  2. crates/api_models/src/payment_methods.rs
  3. crates/router/src/routes/payments.rs
  4. crates/common_types/src/payment_methods.rs
  5. crates/router/Cargo.toml
  6. crates/router/src/core/payments.rs
  7. crates/router/src/routes/app.rs

Motivation and Context

How did you test it?

-Request

curl --location 'http://localhost:8080/v2/payments/filter' \
--header 'X-Profile-Id: pro_68rBAUSCoq91kQ870GFR' \
--header 'X-Merchant-Id: cloth_seller_cnwkRpdOSnP0vLY1lhGb' \
--header 'api-key: dev_elV1dBHRfYgbT09Q3R914ZOZzKCsJFjMJRot4TUcByFCYDseSZHTrZbCJuBX6ZHO'
  • Response
    "connector": {
        "stripe": [
            {
                "connector_label": "stripe_business11",
                "merchant_connector_id": "mca_2jsckz0TAfE0z52dJUY1"
            }
        ]
    },
    "currency": [
        "AED",
        "AFN",
        "ALL",
        "AMD",
        "ANG",
        "AOA",
        "ARS",
        "AUD",
        "AWG",
        "AZN",
        "BAM",
        "BBD",
        "BDT",
        "BGN",
        "BHD",
        "BIF",
        "BMD",
        "BND",
        "BOB",
        "BRL",
        "BSD",
        "BTN",
        "BWP",
        "BYN",
        "BZD",
        "CAD",
        "CDF",
        "CHF",
        "CLP",
        "CNY",
        "COP",
        "CRC",
        "CUP",
        "CVE",
        "CZK",
        "DJF",
        "DKK",
        "DOP",
        "DZD",
        "EGP",
        "ERN",
        "ETB",
        "EUR",
        "FJD",
        "FKP",
        "GBP",
        "GEL",
        "GHS",
        "GIP",
        "GMD",
        "GNF",
        "GTQ",
        "GYD",
        "HKD",
        "HNL",
        "HRK",
        "HTG",
        "HUF",
        "IDR",
        "ILS",
        "INR",
        "IQD",
        "IRR",
        "ISK",
        "JMD",
        "JOD",
        "JPY",
        "KES",
        "KGS",
        "KHR",
        "KMF",
        "KPW",
        "KRW",
        "KWD",
        "KYD",
        "KZT",
        "LAK",
        "LBP",
        "LKR",
        "LRD",
        "LSL",
        "LYD",
        "MAD",
        "MDL",
        "MGA",
        "MKD",
        "MMK",
        "MNT",
        "MOP",
        "MRU",
        "MUR",
        "MVR",
        "MWK",
        "MXN",
        "MYR",
        "MZN",
        "NAD",
        "NGN",
        "NIO",
        "NOK",
        "NPR",
        "NZD",
        "OMR",
        "PAB",
        "PEN",
        "PGK",
        "PHP",
        "PKR",
        "PLN",
        "PYG",
        "QAR",
        "RON",
        "RSD",
        "RUB",
        "RWF",
        "SAR",
        "SBD",
        "SCR",
        "SDG",
        "SEK",
        "SGD",
        "SHP",
        "SLE",
        "SLL",
        "SOS",
        "SRD",
        "SSP",
        "STN",
        "SVC",
        "SYP",
        "SZL",
        "THB",
        "TJS",
        "TMT",
        "TND",
        "TOP",
        "TRY",
        "TTD",
        "TWD",
        "TZS",
        "UAH",
        "UGX",
        "USD",
        "UYU",
        "UZS",
        "VES",
        "VND",
        "VUV",
        "WST",
        "XAF",
        "XCD",
        "XOF",
        "XPF",
        "YER",
        "ZAR",
        "ZMW",
        "ZWL"
    ],
    "status": [
        "succeeded",
        "failed",
        "cancelled",
        "processing",
        "requires_customer_action",
        "requires_merchant_action",
        "requires_payment_method",
        "requires_confirmation",
        "requires_capture",
        "partially_captured",
        "partially_captured_and_capturable"
    ],
    "payment_method": {
        "card": [
            "debit",
            "credit"
        ]
    },
    "authentication_type": [
        "three_ds",
        "no_three_ds"
    ],
    "card_network": [
        "Visa",
        "Mastercard",
        "AmericanExpress",
        "JCB",
        "DinersClub",
        "Discover",
        "CartesBancaires",
        "UnionPay",
        "Interac",
        "RuPay",
        "Maestro"
    ]
}

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

@aniketburman014 aniketburman014 added the M-api-contract-changes Metadata: This PR involves API contract changes label Feb 3, 2025
@aniketburman014 aniketburman014 self-assigned this Feb 3, 2025
@aniketburman014 aniketburman014 requested review from a team as code owners February 3, 2025 13:04
Copy link

semanticdiff-com bot commented Feb 3, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/core/payments.rs  85% smaller
  crates/router/src/routes/app.rs  5% smaller
  crates/api_models/src/admin.rs  0% smaller
  crates/api_models/src/payment_methods.rs  0% smaller
  crates/common_types/src/payment_methods.rs  0% smaller
  crates/router/Cargo.toml Unsupported file format
  crates/router/src/routes/payments.rs  0% smaller

@hyperswitch-bot hyperswitch-bot bot removed the M-api-contract-changes Metadata: This PR involves API contract changes label Feb 3, 2025
@aniketburman014 aniketburman014 requested a review from a team as a code owner February 14, 2025 08:15
@aniketburman014 aniketburman014 changed the title feat(router): add v2 endpoint retrieve payment filters based on merchant profile feat(router): Add v2 endpoint to retrieve payment filters at merchant and profile level Feb 14, 2025
Narayanbhat166
Narayanbhat166 previously approved these changes Feb 19, 2025
jarnura
jarnura previously approved these changes Feb 19, 2025
ShankarSinghC
ShankarSinghC previously approved these changes Feb 20, 2025
.extend(
payment_method_types_vec
.iter()
.filter_map(|p| p.get_payment_method_type()),
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Consider avoiding single-letter variable names like p. It's generally more readable to use more descriptive names that convey the purpose of the variable.

@likhinbopanna likhinbopanna added this pull request to the merge queue Feb 20, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Feb 20, 2025
Narayanbhat166
Narayanbhat166 previously approved these changes Feb 21, 2025
ShankarSinghC
ShankarSinghC previously approved these changes Feb 21, 2025
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.

4 participants