-
Notifications
You must be signed in to change notification settings - Fork 4.2k
feat(payouts): add country, currency filters for payout methods #5130
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
Conversation
pmts.payment_method_type, | ||
)) | ||
}); | ||
let address = db |
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 can move address retrieval to outer function to avoid making this db call every time
if currency_country_filter != Some(false) { | ||
if payment_method == common_enums::PaymentMethod::Card { | ||
card_hs.insert(pmts.payment_method_type); | ||
payment_method_list_hm.insert(payment_method, card_hs.clone()); | ||
} else if payment_method == common_enums::PaymentMethod::Wallet { | ||
wallet_hs.insert(pmts.payment_method_type); | ||
payment_method_list_hm.insert(payment_method, wallet_hs.clone()); | ||
} else if payment_method == common_enums::PaymentMethod::BankTransfer { | ||
bank_transfer_hs.insert(pmts.payment_method_type); | ||
payment_method_list_hm.insert(payment_method, bank_transfer_hs.clone()); | ||
} | ||
} |
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.
Optional - Possible to use match here to avoid if-else-if ladders?
@@ -147,7 +148,7 @@ pub async fn initiate_payout_link( | |||
let enabled_payment_methods = link_data | |||
.enabled_payment_methods | |||
.unwrap_or(fallback_enabled_payout_methods.to_vec()); | |||
|
|||
logger::debug!("enabled_payment_methods : {:?}", enabled_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.
Does this serve any good purpose other than just logging? If not, we can remove it
1926dcf
to
b205fea
Compare
@@ -225,11 +225,12 @@ pub async fn initiate_payout_link( | |||
|
|||
#[cfg(feature = "payouts")] | |||
pub async fn filter_payout_methods( | |||
db: &dyn StorageInterface, | |||
state: SessionState, |
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.
Can we take the reference here, to avoid the additional clones?
@@ -256,6 +267,7 @@ pub async fn filter_payout_methods( | |||
let mut bank_transfer_hs: HashSet<common_enums::PaymentMethodType> = HashSet::new(); | |||
let mut card_hs: HashSet<common_enums::PaymentMethodType> = HashSet::new(); | |||
let mut wallet_hs: HashSet<common_enums::PaymentMethodType> = HashSet::new(); | |||
let payout_filter_config = &state.conf.clone().payout_filters; |
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.
Can we clone payout_filters here instead?
)) | ||
}); | ||
let country_filter = country.as_ref().and_then(|country| { | ||
pmt_filter.and_then(|pmt_filter_hm| { |
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.
Can we please use the proper naming convention here for better clarity?
&address.country, | ||
) | ||
.await?; | ||
if currency_country_filter != Some(false) { |
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 currency_country_filter != Some(false) { | |
if currency_country_filter == Some(true) { |
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.
None
here means Payoutmethod for that connector doesn't have configs in the application configs. For which we still want to show the payout method. Some(false)
indicates that payout method filter is available but currency
/ country
is not present in the list. So we need to check for Some(true)
or None
.
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.
You can also write this as:
if currency_country_filter != Some(false) { | |
if currency_country_filter.unwrap_or(true) { |
Optional change.
request_payout_method_type: &api_models::payment_methods::RequestPaymentMethodTypes, | ||
currency: &common_enums::Currency, | ||
country: &Option<enums::CountryAlpha2>, | ||
) -> errors::RouterResult<Option<bool>> { |
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 can't we return bool here, instead of Option?
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 there is no filter available for connector-> payout method configuration we will still show the payout method by default. We can't remove payout method just because filters are not declared for that.
config/development.toml
Outdated
wallet = ["paypal", "pix", "venmo"] | ||
|
||
[payout_filters.adyen] | ||
sepa = { country = "ES,SK,AT,NL,DE,BE,FR,FI,PT,IE,EE,LT,LV,IT", currency = "EUR" } |
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.
--
0897681
config/development.toml
Outdated
[payout_filters.stripe] | ||
ach = { country = "US", currency = "USD" } | ||
|
||
[payout_filters.wise] |
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.
--
Signed-off-by: Chikke Srujan <[email protected]>
1806204
Signed-off-by: Chikke Srujan <[email protected]>
4b7785a
Type of Change
Description
This PR includes :
ach
&bacs
payout methods for adyen in dashboard.Additional Changes
Motivation and Context
How did you test it?
Test case 1: create mca with connector adyen with payment method
EUR
andNL
. You should be seeing sepa as only payout method when you redirect to payout linkTest Case 2 : Verify all currency & country configuration. You can verify country & currencies from
development.toml
->payout_filters.adyen
.Test Case 3 : Create MCA as created in test case1 , While creating payout link, try creating with different currency other than
EUR
. Default Payout method card should be present after redirecting to payout list.Test Case 4 : After WASM deployment, please verify Adyen payout connector doesn't have
ach
&bacs
in bank transfers.Checklist
cargo +nightly fmt --all
cargo clippy