feat(webhooks): Provide outgoing webhook support for revenue recovery#9294
Conversation
Changed Files
|
| // External Payments which enter the calculate workflow for the first time will have active attempt id as None | ||
| // Then we dont need to send an webhook to the merchant as its not a failure from our side. | ||
| // Thus we dont need to a payment get call for such payments. | ||
| let is_there_an_active_payment_attempt_id = payment_intent.active_attempt_id.is_some(); |
There was a problem hiding this comment.
Do not handle is there an active attempt id like this, do a map and handle the None case if required
| merchant_context: &domain::MerchantContext, | ||
| is_there_an_active_payment_attempt_id: bool, | ||
| ) -> Result<Option<ApplicationResponse<PaymentsResponse>>, sch_errors::ProcessTrackerError> { | ||
| if is_there_an_active_payment_attempt_id { |
There was a problem hiding this comment.
Do not use if else here, use map , and instead of passing a bool flag around, get the active attempt from the revenue_recovery_payment_data, or pass an optional id here, and then perform the check here for the presence of an active attempt id
| if is_there_an_active_payment_attempt_id { | ||
| let operation = payments::operations::PaymentGet; | ||
|
|
||
| let request = router_api_types::PaymentsRetrieveRequest { |
There was a problem hiding this comment.
there is already a function call psync api, try using that, all the variable fields pass it as an argument to that function
There was a problem hiding this comment.
But that would call the connector(force_sync is true in the request) to get the details I need just the latest attempt and intent status data
There was a problem hiding this comment.
We can pass force_sync as an argument
There was a problem hiding this comment.
I just need get tracker response
| state: &SessionState, | ||
| payment_intent: &PaymentIntent, | ||
| revenue_recovery_payment_data: &pcr::RevenueRecoveryPaymentData, | ||
| mut revenue_recovery_metadata: api_models::payments::PaymentRevenueRecoveryMetadata, |
There was a problem hiding this comment.
do not pass a mutable argument to the function , make it mutable when you would want to use it . Passing a mutable reference along is not a good practice
| mut revenue_recovery_metadata: api_models::payments::PaymentRevenueRecoveryMetadata, | ||
| is_there_an_active_payment_attempt_id: bool, | ||
| ) -> Result<Option<()>, sch_errors::ProcessTrackerError> { | ||
| if is_there_an_active_payment_attempt_id { |
There was a problem hiding this comment.
avoid using if else , and preferably do not pass this as an argument
There was a problem hiding this comment.
This is needed in future to not send outgoing webhook when a intent moves to calculate to the first time
| revenue_recovery_payment_data: &storage::revenue_recovery::RevenueRecoveryPaymentData, | ||
| payment_attempt: PaymentAttempt, | ||
| revenue_recovery_metadata: &mut PaymentRevenueRecoveryMetadata, | ||
| psync_response: &PaymentStatusData<router_flow_types::PSync>, |
There was a problem hiding this comment.
Same for this pass it in the session revenue_recovery_payment_data
| let profile_id = revenue_recovery_payment_data.profile.get_id(); | ||
| let billing_mca_id = revenue_recovery_payment_data.billing_mca.get_id(); | ||
|
|
||
| let event_class = common_enums::EventClass::Payments; |
There was a problem hiding this comment.
nit: this variable is not necessary.
2f9523f
…ee-ds * 'main' of github.com:juspay/hyperswitch: feat(webhooks): Provide outgoing webhook support for revenue recovery (#9294) feat(connector): Add Peachpayments Template Code (#9363) feat(connector): [Paysafe] Implement card 3ds flow (#9305) feat(router): Add Connector changes for 3ds (v2) (#9117) feat(connector): [ADYEN] Add support to ideal Mandate Webhook (#9347) refactor(core): accept manual retry from profile (#9302) fix(nuvei): nuvei 3ds fix + psync fix (#9279) fix(connector): [checkout] Add US Support for Apple Pay and Google Pay + Enhanced Checkout Response Data (#9356) fix(router): adding connector_customer_id for external vault proxy (#9263) feat(core): Add first_name and last_name as Secret<String> Types. (#9326) feat(injector): injector request formation changes (#9306) fix(revenue-recovery): Update Redis TTL for customer locks after token selection (#9282) chore(version): 2025.09.11.0 refactor(connector): [Paysafe] fix wasm (#9349) refactor(connector): rename RevenueRecoveryRecordBack as InvoiceRecordBack (#9321) feat(connector): [checkout] add support for MOTO payments (#9327) feat(connector): enhance ACI connector with comprehensive 3DS support - DRAFT (#8986) feat(core): [Retry] MIT Retries (#8628)
Type of Change
Description
This PR enables outgoing webhook support for revenue recovery.
When the retries get succeeded that are done using the revenue recovery system, an outgoing webhook needs to be triggered to the url in business profile. This pr adds that support.
Additional Changes
Motivation and Context
How did you test it?
Sample screen shot and sample webhook body are mentioned below
Checklist
cargo +nightly fmt --allcargo clippy