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

fix(payments): filter total count by card-network value #6397

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

Conversation

Riddhiagrawal001
Copy link
Contributor

@Riddhiagrawal001 Riddhiagrawal001 commented Oct 22, 2024

Type of Change

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

Description

The total count in the payments response was incorrect when the card-network filter was applied. With this PR, the count will now be accurately filtered as well.

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 issues https://github.com/juspay/hyperswitch-cloud/issues/7206

How did you test it?

Request :

curl 'http://localhost:8080/payments/list' \
  -H 'authorization: Bearer JWT token' \
  -H 'sec-ch-ua: "Google Chrome";v="129", "Not=A?Brand";v="8", "Chromium";v="129"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  --data-raw '{"offset":0,"limit":50,"start_time":"2024-09-21T18:30:00Z","card_network":["Visa"]}'

Response
Lets say the total number of payments are 50 , when you apply filter the total_count and count should come as the filtered number . For Eg: When card-network filter = Visa , then the count = 4 and total_count =4

{
    "count": 4,
    "total_count": 4,
    "data": [
        {
            "payment_id": "test_RoHcgHs3m6ZsJ0Y5MEMU",
            "merchant_id": "merchant_1729190909",
            "status": "failed",
            "amount": 10200,
            "net_amount": 10200,
            "shipping_cost": null,
            "amount_capturable": 0,
            "amount_received": null,
            "connector": "stripe_test",
            "client_secret": "test_RoHcgHs3m6ZsJ0Y5MEMU_secret_wQHDmUUPatRIfmY8P8VO",
            "created": "2024-10-22T00:08:58.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": "credit",
            "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_RoHcgHs3m6ZsJ0Y5MEMU_1",
            "frm_message": null,
            "metadata": null,
            "connector_metadata": null,
            "feature_metadata": null,
            "reference_id": null,
            "payment_link": null,
            "profile_id": "pro_lqOYR8GAg2uTrz5WaqA5",
            "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": null,
            "order_tax_amount": null,
            "connector_mandate_id": null
        },
        {
            "payment_id": "test_EEe6rS8Mkv2vVDxZWowp",
            "merchant_id": "merchant_1729190909",
            "status": "succeeded",
            "amount": 18600,
            "net_amount": 18600,
            "shipping_cost": null,
            "amount_capturable": 0,
            "amount_received": null,
            "connector": "stripe_test",
            "client_secret": "test_EEe6rS8Mkv2vVDxZWowp_secret_fvEF0uo7CYqPOgasFSrQ",
            "created": "2024-10-21T02:51:29.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_EEe6rS8Mkv2vVDxZWowp_1",
            "frm_message": null,
            "metadata": null,
            "connector_metadata": null,
            "feature_metadata": null,
            "reference_id": null,
            "payment_link": null,
            "profile_id": "pro_lqOYR8GAg2uTrz5WaqA5",
            "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": null,
            "order_tax_amount": null,
            "connector_mandate_id": null
        },
        {
            "payment_id": "test_46x3ZcQVz6U9RtJitDO4",
            "merchant_id": "merchant_1729190909",
            "status": "succeeded",
            "amount": 18200,
            "net_amount": 18200,
            "shipping_cost": null,
            "amount_capturable": 0,
            "amount_received": null,
            "connector": "stripe_test",
            "client_secret": "test_46x3ZcQVz6U9RtJitDO4_secret_hrOArvzAKBpwXvShhHo4",
            "created": "2024-10-20T18:06:38.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": "credit",
            "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_46x3ZcQVz6U9RtJitDO4_1",
            "frm_message": null,
            "metadata": null,
            "connector_metadata": null,
            "feature_metadata": null,
            "reference_id": null,
            "payment_link": null,
            "profile_id": "pro_lqOYR8GAg2uTrz5WaqA5",
            "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": null,
            "order_tax_amount": null,
            "connector_mandate_id": null
        },
        {
            "payment_id": "test_pghhoGT9kuPuXf2yopXO",
            "merchant_id": "merchant_1729190909",
            "status": "succeeded",
            "amount": 11800,
            "net_amount": 11800,
            "shipping_cost": null,
            "amount_capturable": 0,
            "amount_received": null,
            "connector": "paypal_test",
            "client_secret": "test_pghhoGT9kuPuXf2yopXO_secret_R0uu1JcxCBN1UFyMDVal",
            "created": "2024-10-16T05:26:35.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": "no_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": "credit",
            "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_pghhoGT9kuPuXf2yopXO_1",
            "frm_message": null,
            "metadata": null,
            "connector_metadata": null,
            "feature_metadata": null,
            "reference_id": null,
            "payment_link": null,
            "profile_id": "pro_lqOYR8GAg2uTrz5WaqA5",
            "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": null,
            "order_tax_amount": null,
            "connector_mandate_id": null
        }
    ]
}

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

@Riddhiagrawal001 Riddhiagrawal001 requested review from a team as code owners October 22, 2024 12:47
Copy link

semanticdiff-com bot commented Oct 22, 2024

@Riddhiagrawal001 Riddhiagrawal001 linked an issue Oct 22, 2024 that may be closed by this pull request
@apoorvdixit88 apoorvdixit88 added C-bug Category: Bug A-payments Area: payments A-users Area: Users labels Oct 22, 2024
@Riddhiagrawal001 Riddhiagrawal001 changed the title fix(payments): total count issue for card-network filter fix(payments): filter total count by card-network value Oct 23, 2024
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fix(payments): total count issue for card-network filter
4 participants