-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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(core): [Payouts] Add retrieve flow for payouts #4936
Conversation
crates/router/src/core/payouts.rs
Outdated
let payout_attempt = payout_data.payout_attempt.to_owned(); | ||
|
||
// Form connector data | ||
let connector_call_type = get_connector_choice( |
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 call the underlying connector only when force_sync
is 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.
Also, do we need to run this logic again for retrieve call? We already have the connector where the payout was created, could we directly use that connector for doing a sync?
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 is being called to get the ConnectorData, as for using the already present connector, payout_attempt.connector
is being passed as a parameter to set the call connector type as predetermined. Thus, we remove all the other cases of the call connector type
crates/router/src/core/payouts.rs
Outdated
let payout_attempt = &payout_data.payout_attempt.to_owned(); | ||
let status = payout_attempt.status; | ||
|
||
if matches!(req.force_sync, Some(true)) && helpers::should_call_retrieve(status) { |
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 move this check to the main caller function?
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.
Looks good, added a few suggestions
crates/router/src/core/payouts.rs
Outdated
} | ||
} | ||
Err(err) => { | ||
let status = storage_enums::PayoutStatus::Failed; |
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 shouldn't update the status of payouts in case retrieval fails 🤔
pub fn should_call_retrieve(status: api_enums::PayoutStatus) -> bool { | ||
matches!( | ||
status, | ||
api_enums::PayoutStatus::Pending | api_enums::PayoutStatus::Initiated |
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 should have all the non-terminal states right?
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.
these are the only two non-terminal status where we can retrieve, in case of require_creation
/require_confirmation
, since we don't hit the connector, we can't retrieve it. in case of require_fulfillment
, we don't hit the connector for some of the connector ( creating payout object only at our end) thus not able to retrieve in those cases
35ee07e
@@ -18,3 +18,6 @@ pub struct PoRecipient; | |||
|
|||
#[derive(Debug, Clone)] | |||
pub struct PoRecipientAccount; | |||
|
|||
#[derive(Debug, Clone)] | |||
pub struct PoSync; |
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.
Please name these types as PayoutsSync
or PayoutSync
instead. Can pick this change in a separate PR.
* 'main' of github.com:juspay/hyperswitch: (25 commits) fix(logs): ignore request headers while logging (#5273) feat(webhooks): add support for custom outgoing webhook http headers (#5275) fix(payment_methods): set `requires_cvv` to false when either `connector_mandate_details` or `network_transaction_id` is present during MITs (#5331) chore: create justfile for running commands for v1 and v2 migrations (#5325) fix(routing): do not update `perform_session_flow_routing` output if the `SessionRoutingChoice` is none (#5336) fix(database): modified_at updated for every state change for Payment Attempts (#5312) feat(mca): Added recipient connector call for open banking connectors (#3758) chore(version): 2024.07.16.0 refactor(connector): [Mifinity] add a field language_preference in payment request for mifinity payment method data (#5326) fix(router): store `customer_acceptance` in payment_attempt, use it in confirm flow for delayed authorizations like external 3ds flow (#5308) feat(proxy): add support to pass proxy bypass urls from configs (#5322) Docs: Updating Error codes in API-ref (#5296) feat(core): [Payouts] Add retrieve flow for payouts (#4936) fix(connector): [AUTHORIZEDOTNET] Populate error reason for failure transactions (#5319) chore(version): 2024.07.15.0 feat(logging): Emit a setup error when a restricted keys are used for logging default keys (#5185) feat(payment_methods): add support to migrate existing customer PMs from processor to hyperswitch (#5306) feat(connector): [DATATRANS] Implement card payments (#5028) chore: making of function create_encrypted_data (#5251) fix(payments): populate merchant order ref id in list (#5310) ...
Type of Change
Description
Add retrieve call for payouts in case for transaction that need status update
Additional Changes
Motivation and Context
How did you test it?
Tested through Postman:
success
Checklist
cargo +nightly fmt --all
cargo clippy