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(router): add v2 endpoint retrieve payment aggregate based on merchant profile #7196

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

Conversation

aniketburman014
Copy link

@aniketburman014 aniketburman014 commented Feb 5, 2025

Type of Change

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

Description

Add Aggregate API which enables merchants to retrieve summarized payment data based on a specified date range at profile or merchant level. The API aggregates key payment metrics, such as total transaction count, total processed amount, and status breakdown, helping merchants analyze their payment performance effectively.

Key Changes

pub async fn get_payments_aggregates_profile -> crates/router/src/routes/payments.rs - this implementation extracts the profile ID directly from the authentication data, ensuring profile-based filtering of payment aggregates.

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?

  • Curl
    curl --location 'http://localhost:8080/v2/payments/aggregate?start_time=2025-01-05T18%3A30%3A00Z&end_time=2025-02-05T08%3A59%3A00Z' \ --header 'X-Profile-Id: pro_68rBAUSCoq91kQ870GFR' \ --header 'api-key: dev_elV1dBHRfYgbT09Q3R914ZOZzKCsJFjMJRot4TUcByFCYDseSZHTrZbCJuBX6ZHO'
Screenshot 2025-02-05 at 6 04 35 PM

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

@aniketburman014 aniketburman014 requested review from a team as code owners February 5, 2025 12:38
Copy link

semanticdiff-com bot commented Feb 5, 2025

Narayanbhat166
Narayanbhat166 previously approved these changes Feb 6, 2025
crates/router/src/core/payments.rs Outdated Show resolved Hide resolved
crates/router/src/db/kafka_store.rs Outdated Show resolved Hide resolved
crates/storage_impl/src/mock_db/payment_intent.rs Outdated Show resolved Hide resolved
crates/storage_impl/src/payments/payment_intent.rs Outdated Show resolved Hide resolved
crates/storage_impl/src/payments/payment_intent.rs Outdated Show resolved Hide resolved
Narayanbhat166
Narayanbhat166 previously approved these changes Feb 7, 2025
auth::auth_type(
&auth::HeaderAuth(auth::ApiKeyAuth),
&auth::JWTAuth {
permission: Permission::MerchantPaymentRead,
Copy link
Member

Choose a reason for hiding this comment

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

Should this have been ProfilePaymentRead?

Comment on lines 562 to 566
);

route = route.service(
web::resource("/aggregate").route(web::get().to(payments::get_payments_aggregates)),
);
Copy link
Member

Choose a reason for hiding this comment

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

Nit: You can combine with the previous routes being registered.

Suggested change
);
route = route.service(
web::resource("/aggregate").route(web::get().to(payments::get_payments_aggregates)),
);
)
.service(
web::resource("/aggregate").route(web::get().to(payments::get_payments_aggregates)),
);

Copy link
Contributor

@apoorvdixit88 apoorvdixit88 left a comment

Choose a reason for hiding this comment

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

In V1 we have two routes for aggregate, one is merchant level other is at profile level, we should have in V2 as well? here

Narayanbhat166
Narayanbhat166 previously approved these changes Feb 10, 2025
SanchithHegde
SanchithHegde previously approved these changes Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants