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(payments): add merchant order ref id filter #6630

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

Conversation

apoorvdixit88
Copy link
Contributor

@apoorvdixit88 apoorvdixit88 commented Nov 21, 2024

Type of Change

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

Description

The PR

  • Add merchant order reference id filter for payments list
  • Fix bug for search by refund id (or payment_id), using or instead of or_filter. Earlier we were searching in whole list, ignoring the filter previously applied in the query.
    However this was the only case for when we were searching dynamically for ids, it can be payment or refund id. It was producing correct result when searching for only payment id or only refund id.

Additional Changes

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

Motivation and Context

Closes #6629

How did you test it?

Merchant Order filter is working as expected
Request

curl --location 'http://localhost:8080/payments/list' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer JWT' \
--data '{
    "merchant_order_reference_id": "test"
}'

Response:

{
    "count": 1,
    "total_count": 1,
    "data": [
        {
            "payment_id": "test_rkAjUPAeyOVH0V1JPBcg",
            "merchant_id": "merchant_1732182386",
            "status": "succeeded",
            "amount": 19900,
            "net_amount": 19900,
            "shipping_cost": null,
            "amount_capturable": 0,
            "amount_received": null,
            "connector": "stripe_test",
            "client_secret": "test_rkAjUPAeyOVH0V1JPBcg_secret_s8xZQVITYn3CT5RKTiUj",
            "created": "2024-11-20T22:30:10.000Z",
            "currency": "USD",
            "customer_id": "hs-dashboard-user",
            "customer": null,
            "description": "This is a sample payment",
            "refunds": null,
            "disputes": null,
            "mandate_id": null,
            "mandate_data": null,
            "setup_future_usage": null,
            "off_session": null,
            "capture_on": null,
            "capture_method": null,
            "payment_method": "card",
            "payment_method_data": null,
            "payment_token": null,
            "shipping": null,
            "billing": null,
            "order_details": null,
            "email": null,
            "name": null,
            "phone": null,
            "return_url": null,
            "authentication_type": "three_ds",
            "statement_descriptor_name": null,
            "statement_descriptor_suffix": null,
            "next_action": null,
            "cancellation_reason": null,
            "error_code": null,
            "error_message": null,
            "unified_code": null,
            "unified_message": null,
            "payment_experience": null,
            "payment_method_type": "debit",
            "connector_label": null,
            "business_country": null,
            "business_label": "default",
            "business_sub_label": null,
            "allowed_payment_method_types": null,
            "ephemeral_key": null,
            "manual_retry_allowed": null,
            "connector_transaction_id": "test_rkAjUPAeyOVH0V1JPBcg_1",
            "frm_message": null,
            "metadata": null,
            "connector_metadata": null,
            "feature_metadata": null,
            "reference_id": null,
            "payment_link": null,
            "profile_id": "pro_7J9fiPceBUM7IMdb045X",
            "surcharge_details": null,
            "attempt_count": 1,
            "merchant_decision": null,
            "merchant_connector_id": null,
            "incremental_authorization_allowed": null,
            "authorization_count": null,
            "incremental_authorizations": null,
            "external_authentication_details": null,
            "external_3ds_authentication_attempted": null,
            "expires_on": null,
            "fingerprint": null,
            "browser_info": null,
            "payment_method_id": null,
            "payment_method_status": null,
            "updated": null,
            "charges": null,
            "frm_metadata": null,
            "merchant_order_reference_id": "test",
            "order_tax_amount": null,
            "connector_mandate_id": null
        }
    ]
}

In refunds list when dynamically searching for both payment_id and refund_id, we are getting correct result now

curl --location 'http://localhost:8080/refunds/list' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer JWT' \
--data '{
    "refund_id": "test_LlBBfgQbHHJfQxsoLiyT",
    "payment_id": "test_LlBBfgQbHHJfQxsoLiyT"
    
}'

Response:

{
    "count": 0,
    "total_count": 0,
    "data": []
}

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

@apoorvdixit88 apoorvdixit88 added C-bug Category: Bug C-feature Category: Feature request or enhancement A-payments Area: payments A-users Area: Users labels Nov 21, 2024
@apoorvdixit88 apoorvdixit88 self-assigned this Nov 21, 2024
@apoorvdixit88 apoorvdixit88 requested a review from a team as a code owner November 21, 2024 10:51
Copy link

semanticdiff-com bot commented Nov 21, 2024

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/types/storage/dispute.rs  94% smaller
  crates/router/src/types/storage/refund.rs  89% smaller
  crates/api_models/src/payments.rs  0% smaller
  crates/hyperswitch_domain_models/src/payments/payment_intent.rs  0% smaller
  crates/storage_impl/src/payments/payment_intent.rs  0% smaller

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-payments Area: payments A-users Area: Users C-bug Category: Bug C-feature Category: Feature request or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fix: merchant order ref id filter and refund_id filter
3 participants