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

fix(webhooks): add support for updating mandate details in webhooks flow #6523

Merged
merged 16 commits into from
Nov 13, 2024

Conversation

srujanchikke
Copy link
Contributor

@srujanchikke srujanchikke commented Nov 10, 2024

Type of Change

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

Description

For Fiuu, the mandate ID is updated via webhooks in the case of 3DS payments. The payment webhook body was not consumed when the payment was successful, causing intermittent issues in the sandbox environment. This PR adds support to address this issue.

more detailed issue description :

  • Fiuu mandate id is consumed from webhooks
  • Incase of 3ds payment, on returning to hs return url we do a psync call
  • If psync happends before we get notification from connector, we don't consume the webhook. Hence we will never have connector mandate id in our system.
  • To consume the webhook, we can add logic in webhooks core that after psync check for the source verification & webhook event based on that get mandate details from webhook and update it in the payment method & payment attempt.

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?

Cannot be tested directly this is an intermediate issue in sandbox. So please test this flow multiple time and mandate id should be stored in CIT transaction against both payment attempt & payment method for the transaction.

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

@srujanchikke srujanchikke added the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Nov 10, 2024
@srujanchikke srujanchikke self-assigned this Nov 10, 2024
@srujanchikke srujanchikke requested review from a team as code owners November 10, 2024 19:34
@srujanchikke srujanchikke added A-connector-integration Area: Connector integration A-core Area: Core flows A-webhooks Area: Webhook flows labels Nov 10, 2024
AkshayaFoiger
AkshayaFoiger previously approved these changes Nov 11, 2024
@@ -246,3 +246,8 @@ pub struct ConnectorWebhookSecrets {
pub secret: Vec<u8>,
pub additional_secret: Option<masking::Secret<String>>,
}

#[derive(Debug, Clone, Serialize)]
pub struct ConnectorMandateDetails {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please move this to domain models

request
.body
.parse_struct("fiuu::FiuuWebhooksResponse")
.change_context(errors::ConnectorError::WebhookResourceObjectNotFound)?
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
.change_context(errors::ConnectorError::WebhookResourceObjectNotFound)?
.change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?

.change_context(errors::ConnectorError::WebhookResourceObjectNotFound)?
};
match payload.clone() {
FiuuWebhooksResponse::FiuuWebhookPaymentResponse(webhook_payment_response) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

We can directly parse it into FiuuWebhookPaymentResponse

.await
.to_not_found_response(errors::ApiErrorResponse::PaymentMethodNotFound)?;

if payment_method_info.connector_mandate_details.is_none() {
Copy link
Contributor

Choose a reason for hiding this comment

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

is_none won't work here, we should check the existence of mca_id in the hashmap

jarnura
jarnura previously approved these changes Nov 12, 2024
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Nov 13, 2024
Merged via the queue into main with commit 6eb72e9 Nov 13, 2024
15 of 17 checks passed
@Gnanasundari24 Gnanasundari24 deleted the webhook_fix branch November 13, 2024 10:20
srujanchikke added a commit that referenced this pull request Nov 13, 2024
…low (#6523)

Co-authored-by: Chikke Srujan <[email protected]>
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
srujanchikke added a commit that referenced this pull request Nov 13, 2024
…low (#6523)

Co-authored-by: Chikke Srujan <[email protected]>
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
@SanchithHegde SanchithHegde removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Nov 17, 2024
bsayak03 pushed a commit that referenced this pull request Nov 26, 2024
…low (#6523)

Co-authored-by: Chikke Srujan <[email protected]>
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
bsayak03 pushed a commit that referenced this pull request Nov 26, 2024
…low (#6523)

Co-authored-by: Chikke Srujan <[email protected]>
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-connector-integration Area: Connector integration A-core Area: Core flows A-webhooks Area: Webhook flows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants