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(core): Create Payout Webhook Flow #4696

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

Conversation

Sakilmostak
Copy link
Contributor

Type of Change

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

Description

Create core flow for processing payout webhooks and send respective outgoing webhook

Additional Changes

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

Motivation and Context

How did you test it?

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

@Sakilmostak Sakilmostak added A-core Area: Core flows C-feature Category: Feature request or enhancement labels May 19, 2024
@Sakilmostak Sakilmostak self-assigned this May 19, 2024
@Sakilmostak Sakilmostak requested review from a team as code owners May 19, 2024 16:09
pub fn is_payout_event(event_code: &WebhookEventCode) -> bool {
matches!(
event_code,
WebhookEventCode::PayoutThirdparty | WebhookEventCode::PayoutDecline
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we not handling PAYOUT_REVERSED and PAYOUT_EXPIRE?

ref - https://docs.adyen.com/online-payments/online-payouts/payout-webhook/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added support for them

Self::PayoutDetails(payout_payload) => Some(OutgoingWebhookEventContent::Payout {
payout_id: payout_payload.payout_id.clone(),
content: masking::masked_serialize(&payout_payload)
.unwrap_or(serde_json::json!({"error":"failed to serialize"})),
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this what we send to merchants if deserialization fails?

@@ -420,7 +420,7 @@ impl PayoutIndividualDetailsExt for api_models::payouts::PayoutIndividualDetails
#[derive(Clone, Debug, Default)]
pub struct PayoutsResponseData {
pub status: Option<storage_enums::PayoutStatus>,
pub connector_payout_id: String,
pub connector_payout_id: Option<String>,
Copy link
Contributor

Choose a reason for hiding this comment

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

TODO for later: make it non optional, and add new struct for connector integration if this field is not consumed in other flows

@@ -1107,6 +1108,10 @@ pub enum EventType {
DisputeLost,
MandateActive,
MandateRevoked,
PayoutSuccess,
Copy link
Contributor

Choose a reason for hiding this comment

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

Possible to add PayoutCreated? Trigger - when payout is created at connector's end.

)
.await
}
MerchantStorageScheme::RedisKv => {
Copy link
Contributor

Choose a reason for hiding this comment

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

@dracarys18 can you review the reverse lookup bit?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-core Area: Core flows C-feature Category: Feature request or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants