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): confirm flow and authorization api changes for external authentication #4015

Merged
merged 38 commits into from
Mar 12, 2024

Conversation

hrithikesh026
Copy link
Contributor

@hrithikesh026 hrithikesh026 commented Mar 7, 2024

Type of Change

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

Description

Added post 3ds authentication, payment authorize endpoint to send authrorization request to the payment connector after completing 3ds authentication separately.

newly added endpoint is {base_url}/payments/{payment_id}/{merchant_id}/authorize/{connector}.

Other changes:
added support for calling pre and post authentication services in payments core.

pre_authn will be called during confirm flow to determine the 3ds version.
post_authn will be called after external authentication is completed to retrieve the authentication data.

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
  • I added a CHANGELOG entry if applicable

@hrithikesh026 hrithikesh026 added C-feature Category: Feature request or enhancement S-waiting-on-review Status: This PR has been implemented and needs to be reviewed M-api-contract-changes Metadata: This PR involves API contract changes labels Mar 7, 2024
@hrithikesh026 hrithikesh026 added this to the March 2024 milestone Mar 7, 2024
@hrithikesh026 hrithikesh026 self-assigned this Mar 7, 2024
@hrithikesh026 hrithikesh026 requested review from a team as code owners March 7, 2024 18:52
Base automatically changed from core-modules-for-external-authn to main March 8, 2024 14:00
@hrithikesh026 hrithikesh026 requested a review from a team as a code owner March 8, 2024 14:00
}

fn get_payment_action(&self) -> services::PaymentAction {
services::PaymentAction::CompleteAuthorize
Copy link
Member

Choose a reason for hiding this comment

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

we can maybe add a separate variant for this use case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will fixed in the upcoming refactor PR.

Comment on lines +800 to +810
authentication::perform_post_authentication(
state,
authentication_connector_name.clone(),
business_profile.clone(),
authentication_connector_mca,
authentication::types::PostAuthenthenticationFlowInput::PaymentAuthNFlow {
payment_data,
authentication_data,
should_continue_confirm_transaction,
},
)
Copy link
Member

Choose a reason for hiding this comment

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

call authentication core with appropriate generics, can be taken up in the refactors PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will fixed in the upcoming refactor PR.

Comment on lines +789 to +806
payment_data.authentication = match payment_data.authentication {
Some((authentication, authentication_data)) => {
let authentication_update = storage::AuthenticationUpdate::PostAuthorizationUpdate {
authentication_lifecycle_status:
storage::enums::AuthenticationLifecycleStatus::Used,
};
let updated_authentication = state
.store
.update_authentication_by_merchant_id_authentication_id(
authentication,
authentication_update,
)
.await
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;
Some((updated_authentication, authentication_data))
}
None => None,
};
Copy link
Member

Choose a reason for hiding this comment

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

this can also be handled in the authentication_core.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will fixed in the upcoming refactor PR.

.attach_printable("Error while parsing authentication_data")
})
.transpose()?
.unwrap_or_default();
Copy link
Member

Choose a reason for hiding this comment

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

this should not be inferred as default.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will fixed in the upcoming refactor PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is fixed in this PR. #4093

crates/router/src/core/payments/transformers.rs Outdated Show resolved Hide resolved
crates/router/src/routes/payments.rs Outdated Show resolved Hide resolved
Narayanbhat166
Narayanbhat166 previously approved these changes Mar 12, 2024
@hrithikesh026 hrithikesh026 requested a review from vspecky March 12, 2024 06:58
Copy link
Contributor

@srujanchikke srujanchikke left a comment

Choose a reason for hiding this comment

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

There are no connector specific changes in this PR.

Copy link
Member

@vspecky vspecky left a comment

Choose a reason for hiding this comment

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

Approved on behalf of @juspay/hyperswitch-routing

@likhinbopanna likhinbopanna added this pull request to the merge queue Mar 12, 2024
Merged via the queue into main with commit ce3625c Mar 12, 2024
13 of 15 checks passed
@likhinbopanna likhinbopanna deleted the confirm-and-authorization-api-changes branch March 12, 2024 10:55
@likhinbopanna likhinbopanna removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature Category: Feature request or enhancement M-api-contract-changes Metadata: This PR involves API contract changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants