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

bug(auth_v2): remove duplicate profile fetch #6871

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Narayanbhat166
Copy link
Member

Type of Change

  • Refactoring

Description

Avoid fetching business profile twice in the authentication layer for ApiKeyAuth.

Motivation and Context

How did you test it?

  • Create a payment
curl --location 'http://localhost:8080/v2/payments/create-intent' \
--header 'api-key: dev_UaD3RfzLgxyPHIOlZh9iIYC9OC5YyGi1XREAADQ8h6caYGSlrcZ1R8HE7A4PGae7' \
--header 'Content-Type: application/json' \
--header 'x-profile-id: pro_FKgrBzV4FwvbjWNFbnHQ' \
--data-raw '{
    "amount_details": {
        "order_amount": 100,
        "currency": "USD"
    },
    "capture_method":"manual",
    "authentication_type": "three_ds",
    "billing": {
        "address": {
            "first_name": "John",
            "last_name": "Dough"
        },
        "email": "[email protected]"
    },
    "shipping": {
        "address": {
            "first_name": "John",
            "last_name": "Dough",
            "city": "Karwar",
            "zip": "581301",
            "state": "Karnataka"
        },
        "email": "[email protected]"
    }
}'
  • Check for the fetching business profile log, there should be only one log line
Screenshot 2024-12-18 at 11 33 37 AM

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code

@Narayanbhat166 Narayanbhat166 requested a review from a team as a code owner December 18, 2024 06:04
Copy link

semanticdiff-com bot commented Dec 18, 2024

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/services/authentication.rs  28% smaller

Comment on lines +685 to +694
match enable_partial_auth {
true => self.0.authenticate_and_fetch(request_headers, state).await,
false => {
let auth = self
.0
.authenticate_and_fetch(request_headers, state)
.await?;
Ok(auth)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

what is the purpose of this match?

Copy link
Contributor

Choose a reason for hiding this comment

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

please add a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants