-
Notifications
You must be signed in to change notification settings - Fork 3.9k
feat(payment-methods): add filtering logic for payment method list v2 #8606
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
39d06ee
feat: add filtering logic for payment method list
Sakilmostak b4b6340
Merge branch 'main' into filter_payment_method_v2
Sakilmostak db720f6
refactor: conflict with main
Sakilmostak 7137725
fix: add correct field_type for required_fields
Sakilmostak f9cea38
feat(payments_v2): add logic to render required_fields in response of…
Sakilmostak ac39e8e
refactor: add required_fields
Sakilmostak 3af0c8c
feat: add level based filter for pml
Sakilmostak 952336a
refactor: remove unused import
Sakilmostak bc2f457
refactor: resolve comment
Sakilmostak a7a22dc
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,8 @@ use common_utils::{ | |
pii::{self, Email}, | ||
types::{MinorUnit, StringMajorUnit}, | ||
}; | ||
#[cfg(feature = "v2")] | ||
use deserialize_form_style_query_parameter::option_form_vec_deserialize; | ||
use error_stack::ResultExt; | ||
use masking::{PeekInterface, Secret, WithType}; | ||
use router_derive::Setter; | ||
|
@@ -7701,7 +7703,38 @@ pub enum SdkType { | |
|
||
#[cfg(feature = "v2")] | ||
#[derive(Debug, serde::Serialize, serde::Deserialize, Clone, ToSchema)] | ||
pub struct PaymentMethodsListRequest {} | ||
pub struct PaymentMethodsListRequest { | ||
/// This is a 15 minute expiry token which shall be used from the client to authenticate and perform sessions from the SDK | ||
#[schema(max_length = 30, min_length = 30, example = "secret_k2uj3he2893eiu2d")] | ||
pub client_secret: Option<String>, | ||
|
||
/// The two-letter ISO currency code | ||
#[serde(deserialize_with = "option_form_vec_deserialize", default)] | ||
#[schema(value_type = Option<Vec<CountryAlpha2>>, example = json!(["US", "UK", "IN"]))] | ||
pub accepted_countries: Option<Vec<api_enums::CountryAlpha2>>, | ||
|
||
/// Filter by amount | ||
#[schema(example = 60)] | ||
pub amount: Option<MinorUnit>, | ||
|
||
/// The three-letter ISO currency code | ||
#[serde(deserialize_with = "option_form_vec_deserialize", default)] | ||
#[schema(value_type = Option<Vec<Currency>>,example = json!(["USD", "EUR"]))] | ||
pub accepted_currencies: Option<Vec<api_enums::Currency>>, | ||
|
||
/// Indicates whether the payment method supports recurring payments. Optional. | ||
#[schema(example = true)] | ||
pub recurring_enabled: Option<bool>, | ||
|
||
/// Indicates whether the payment method is eligible for card networks | ||
#[serde(deserialize_with = "option_form_vec_deserialize", default)] | ||
#[schema(value_type = Option<Vec<CardNetwork>>, example = json!(["visa", "mastercard"]))] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we please have a test case added for the deserializer which is added |
||
pub card_networks: Option<Vec<api_enums::CardNetwork>>, | ||
|
||
/// Indicates the limit of last used payment methods | ||
#[schema(example = 1)] | ||
pub limit: Option<i64>, | ||
} | ||
|
||
#[cfg(feature = "v2")] | ||
#[derive(Debug, serde::Serialize, ToSchema)] | ||
|
@@ -7737,8 +7770,8 @@ pub struct ResponsePaymentMethodTypesForPayments { | |
|
||
/// Required fields for the payment_method_type. | ||
/// This is the union of all the required fields for the payment method type enabled in all the connectors. | ||
#[schema(value_type = Option<RequiredFieldInfo>)] | ||
pub required_fields: Option<Vec<payment_methods::RequiredFieldInfo>>, | ||
#[schema(value_type = RequiredFieldInfo)] | ||
pub required_fields: Vec<payment_methods::RequiredFieldInfo>, | ||
|
||
/// surcharge details for this payment method type if exists | ||
#[schema(value_type = Option<SurchargeDetailsResponse>)] | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 already have a
PaymentMethodListRequest
struct inapi_models/src/payment_methods.rs
. Please consider using that. We can also remove the extra deserializer crate dependency.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.
This struct was introduced by @Narayanbhat166 for v2, while the struct in
api_models/src/payment_methods.rs
is for v1. Are we sure about merging them given if we try to differentiate v1 and v2 parameters?Uh oh!
There was an error while loading. Please reload this page.
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.
deserialize_form_style_query_parameter
crate is import for v2 specifically to take vector as a input in query params. for example{{baseUrl}}/v2/payments/:id/payment-methods?accepted_countries=US,UK,NZ
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 have 2 versions of
PaymentMethodListRequest
inpayment_methods.rs
, one for v1 and another for v2.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.
There are two separate structure present to differentiate payment's and payment method's PML. In case of future deviation in implementation, this will be useful. Currently updating the name of both as per suggestion