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(refunds): Refunds aggregate api #5795

Merged
merged 24 commits into from
Sep 12, 2024
Merged

Conversation

gitanjli525
Copy link
Contributor

@gitanjli525 gitanjli525 commented Sep 4, 2024

Type of Change

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

Description

Added new api for refunds status aggregate

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

Closed #5796

How did you test it?

Request

curl --location 'http://localhost:8080/refunds/aggregate?start_time=2022-08-28T18%3A30%3A00Z' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiZjNmYzEyNjYtZDQ2MS00NWU3LWFkMzEtODdlMDA4ZWVlYjZjIiwibWVyY2hhbnRfaWQiOiJtZXJjaGFudF8xNzI0NjYxNjQ3Iiwicm9sZV9pZCI6Im9yZ19hZG1pbiIsImV4cCI6MTcyNTYyMDQ1MSwib3JnX2lkIjoib3JnX3pXYVBBZDBxOGtxcnRpQzN4U3o3IiwicHJvZmlsZV9pZCI6bnVsbH0.VXacvv96BOspj033EFwKvaYdyqjlSNIzMFXYQ-DvsvE' \
--header 'Cookie: login_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiZjNmYzEyNjYtZDQ2MS00NWU3LWFkMzEtODdlMDA4ZWVlYjZjIiwibWVyY2hhbnRfaWQiOiJtZXJjaGFudF8xNzI0NjYxNjQ3Iiwicm9sZV9pZCI6Im9yZ19hZG1pbiIsImV4cCI6MTcyNTYyMDQ1MSwib3JnX2lkIjoib3JnX3pXYVBBZDBxOGtxcnRpQzN4U3o3IiwicHJvZmlsZV9pZCI6bnVsbH0.VXacvv96BOspj033EFwKvaYdyqjlSNIzMFXYQ-DvsvE'

Response

{
    "status_with_count": {
        "pending": 0,
        "transaction_failure": 0,
        "success": 40,
        "failure": 0,
        "manual_review": 0
    }
}

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

@gitanjli525 gitanjli525 added the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Sep 4, 2024
@gitanjli525 gitanjli525 self-assigned this Sep 4, 2024
@gitanjli525 gitanjli525 requested review from a team as code owners September 4, 2024 11:12
Copy link

semanticdiff-com bot commented Sep 4, 2024

Review changes with SemanticDiff.

Analyzed 14 of 14 files.

Overall, the semantic diff is 2% smaller than the GitHub diff.

Filename Status
✔️ crates/router_env/src/logger/types.rs Analyzed
✔️ crates/router/src/types/storage/refund.rs Analyzed
✔️ crates/router/src/routes/app.rs Analyzed
✔️ crates/router/src/routes/lock_utils.rs 38.89% smaller
✔️ crates/router/src/routes/refunds.rs Analyzed
✔️ crates/router/src/db/kafka_store.rs Analyzed
✔️ crates/router/src/db/refund.rs 0.69% smaller
✔️ crates/router/src/core/refunds.rs Analyzed
✔️ crates/openapi/src/openapi.rs 7.74% smaller
✔️ crates/openapi/src/openapi_v2.rs 7.74% smaller
✔️ crates/api_models/src/refunds.rs Analyzed
✔️ crates/api_models/src/events/refund.rs 18.51% smaller
✔️ api-reference-v2/openapi_spec.json Analyzed
✔️ api-reference/openapi_spec.json Analyzed

@gitanjli525 gitanjli525 added C-feature Category: Feature request or enhancement A-refunds Area: Refund flows A-users Area: Users labels Sep 4, 2024
@gitanjli525
Copy link
Contributor Author

Please fix above comments

updated the PR

@juspay juspay deleted a comment from apoorvdixit88 Sep 10, 2024
apoorvdixit88
apoorvdixit88 previously approved these changes Sep 10, 2024
let refund_status_with_count = db
.get_refund_status_with_count(merchant.get_id(), &time_range, merchant.storage_scheme)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)?;
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 attach_printable if you are raising Internal server error

@@ -234,6 +234,12 @@ pub struct RefundListFilters {
pub refund_status: Vec<enums::RefundStatus>,
}

#[derive(Clone, Debug, serde::Serialize, ToSchema)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you mention this type in openapi.rs module

@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Sep 12, 2024
.get_refund_status_with_count(merchant.get_id(), &time_range, merchant.storage_scheme)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to find status count")?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit:

Suggested change
.attach_printable("Failed to find status count")?;
.attach_printable("Failed to find refund status count")?;

@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Sep 12, 2024
Merged via the queue into main with commit 00386f3 Sep 12, 2024
12 of 14 checks passed
@Gnanasundari24 Gnanasundari24 deleted the refunds-aggregate-api branch September 12, 2024 13:57
pixincreate added a commit that referenced this pull request Sep 13, 2024
* 'main' of github.com:juspay/hyperswitch: (51 commits)
  feat(connector): [DEUTSCHEBANK] Integrate SEPA Payments (#5826)
  feat(payments_v2): payment intent diesel and domain models changes v2 (#5783)
  feat(connector): [Fiuu] ADD Wasm Configs (#5874)
  chore(version): 2024.09.13.0
  refactor(core): Update shipping_cost and order_tax_amount to net_amount of payment_attempt (#5844)
  refactor: return optional request body from build_request_v2 in ConnectorIntegrationV2 trait (#5865)
  feat(refunds): Refunds aggregate api (#5795)
  refactor: handle redirections for iframed content (#5591)
  refactor(payment_links): Update API contract for dynamic transaction details and upgrade UI (#5849)
  fix(router): add payment_method check in `get_mandate_type` (#5828)
  fix(connector): [ZSL] compare consr_paid_amt with the total amount for identifying partial payments (#5873)
  feat(connector): [Novalnet] add Payment flows for cards (#5726)
  chore(version): 2024.09.12.0
  fix(router): return `collect_billing_details_from_wallet_connector` if `always_collect_billing_details_from_wallet_connector ` is false in merchant payment method list (#5854)
  feat(opensearch): add profile_id and organization_id to /search APIs (#5705)
  build(deps): bump `sqlx` to `0.8.2` (#5859)
  refactor: Remove unwanted commented lines (#5851)
  feat(payments): add support for profile aggregates (#5845)
  Feat(connector): [Fiuu] Add DuitNow/FPX PaymentMethod (#5841)
  chore: remove Connectors enum dependency from ConnectorIntegrationV2 trait (#5840)
  ...
@gitanjli525 gitanjli525 removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-refunds Area: Refund flows A-users Area: Users 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.

feat(payments): show aggregate count of refund status
6 participants