-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 endpoint for listing connector features #6612
base: main
Are you sure you want to change the base?
Conversation
Changed Files
|
Live, | ||
/// Payment Method available in sandbox | ||
Beta, | ||
/// Payment Method not available |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion this should be the default value. We cannot have Live
as the default value.
let feature_matrix_response: Vec<payment_types::FeatureMatrixResponse> = connector_list | ||
.into_iter() | ||
.filter_map(|connector_name| { | ||
api_types::ConnectorData::convert_connector(&connector_name.to_string()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we have so much of nesting here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if possible try idiomatic approach and reduce the nesting
#[derive(Default, Debug, Deserialize, Serialize, Clone, ToSchema)] | ||
pub struct FeatureMatrixRequest { | ||
// List of connectors for which the feature matrix is requested | ||
pub connectors: Option<Vec<enums::Connector>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should not accept any connector from the request, application will know how many connectors are supported, so this value should be provided by the application
ToSchema, | ||
)] | ||
#[strum(serialize_all = "snake_case")] | ||
pub enum PaymentMethodStage { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename this to PaymentMethodAvailabilityStage
#[strum(serialize_all = "snake_case")] | ||
pub enum PaymentMethodStage { | ||
/// Payment Method available in production | ||
#[default] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the default value, we should not infer any default values
let mut supported_payment_methods = SupportedPaymentMethods::new(); | ||
let mut card_payment_method = PaymentMethodTypeMetadata::new(); | ||
card_payment_method.insert( | ||
enums::PaymentMethodType::Credit, | ||
PaymentMethodDetails { | ||
availability_status: enums::PaymentMethodStage::Live, | ||
supports_mandates: false, | ||
}, | ||
); | ||
card_payment_method.insert( | ||
enums::PaymentMethodType::Debit, | ||
PaymentMethodDetails { | ||
availability_status: enums::PaymentMethodStage::Live, | ||
supports_mandates: false, | ||
}, | ||
); | ||
supported_payment_methods.insert(enums::PaymentMethod::Card, card_payment_method); | ||
Some(supported_payment_methods) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
define a toml file for the config and get these values from that config file. That will be maintainable
/// fn validate_payment_method | ||
fn validate_payment_method( | ||
&self, | ||
payment_method_type: &Option<PaymentMethodType>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this optional in the request, if we want to validate this.
Type of Change
Description
-> Why?
With new features being added, it is becoming increasingly difficult to track all the additions. This information is essential for accurately representing Hyperswitch's offerings. Having this solution will eliminate inconsistencies between the documentation and the actual implementation, ensuring clarity and alignment.
-> What?
Introduce an API endpoint that provides:
-> A list of all connectors.
-> The payment methods supported by each connector.
-> The status of these payment methods.
-> Whether these payment methods support mandates.
-> How?
-> Pre-validation for Payment Methods:
Before invoking a connector to process a payment, this function will check if the specified payment_method is implemented. This ensures developers update the relevant functions during development and testing.
-> Unified API Endpoint:
Build an endpoint that collects information from all connectors and consolidates it into a unified JSON response. This will act as a single source of truth for supported features.
Additional Changes
How did you test it?
Test the validation.
Create a Klarna payment with Bambora. It should fail with "payment method not supported" error.
Response
The payment intent status will be
requires_payment_method
Response
List for all connector (that implements this feature)
Response
Checklist
cargo +nightly fmt --all
cargo clippy