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_list): handle same payment/attempt ids for different merchants #6917

Merged
merged 4 commits into from
Dec 24, 2024

Conversation

apoorvdixit88
Copy link
Contributor

@apoorvdixit88 apoorvdixit88 commented Dec 23, 2024

Type of Change

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

Description

Changed the query to apply the merchant_id filter after the join. This ensures valid rows aren’t excluded too early and fixes an issue where payments with the same IDs but different merchants were being handled incorrectly.

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 #6916

How did you test it?

Tried to have to merchant id that have same payment/atttempt id. And tested for the logic:
Screenshot 2024-12-23 at 7 31 50 PM
Screenshot 2024-12-23 at 4 32 48 PM
Now the list api is working as expected for merchants who have same payment id
Request:

curl 'http://localhost:8080/payments/list' \
  -H 'Accept: */*' \
  -H 'Accept-Language: en-GB,en-US;q=0.9,en;q=0.8' \
  -H 'Connection: keep-alive' \
  -H 'Content-Type: application/json' \
  -H 'Origin: http://localhost:9000' \
  -H 'Referer: http://localhost:9000/' \
  -H 'Sec-Fetch-Dest: empty' \
  -H 'Sec-Fetch-Mode: cors' \
  -H 'Sec-Fetch-Site: same-site' \
  -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36' \
  -H 'api-key: hyperswitch' \
  -H 'authorization: Bearer JWT' \
  -H 'sec-ch-ua: "Google Chrome";v="131", "Chromium";v="131", "Not_A Brand";v="24"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  --data-raw '{"offset":0,"limit":50,"start_time":"2024-11-22T18:30:00Z","amount_filter":{"start_amount":null,"end_amount":null}}'

Response

{
    "count": 1,
    "total_count": 1,
    "data": [
        {
            "payment_id": "x",
            "merchant_id": "merchant_1734940244",
            "status": "succeeded",
            "amount": 12300,
            "net_amount": 18000,
            "shipping_cost": null,
            "amount_capturable": 0,
            "amount_received": null,
            "connector": "stripe_test",
            "client_secret": "test_gFFhcIbCS0LkwFmaCdAl_secret_GmvAjH9YCyyXzoJVaBCT",
            "created": "2024-12-17T04:07:36.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_W7bBdLqIBIxUMkpKsvu9_1",
            "frm_message": null,
            "metadata": null,
            "connector_metadata": null,
            "feature_metadata": null,
            "reference_id": null,
            "payment_link": null,
            "profile_id": "pro_N7DbBIewrQYTC9qagLJY",
            "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,
            "split_payments": 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

@apoorvdixit88 apoorvdixit88 self-assigned this Dec 23, 2024
@apoorvdixit88 apoorvdixit88 requested a review from a team as a code owner December 23, 2024 09:39
Copy link

semanticdiff-com bot commented Dec 23, 2024

Review changes with  SemanticDiff

Changed Files
File Status
  crates/storage_impl/src/payments/payment_intent.rs  1% smaller

@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Dec 24, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 24, 2024
@SanchithHegde SanchithHegde added this pull request to the merge queue Dec 24, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 24, 2024
@SanchithHegde SanchithHegde added this pull request to the merge queue Dec 24, 2024
Merged via the queue into main with commit 2e472e3 Dec 24, 2024
17 of 19 checks passed
@SanchithHegde SanchithHegde deleted the fix-payments-list-for-same-payment-ids branch December 24, 2024 13:29
pixincreate added a commit to Ankesh2004/hyperswitch that referenced this pull request Dec 26, 2024
…r-verifyurl-in-redirection-handler

* 'main' of github.com:juspay/hyperswitch: (444 commits)
  ci: add tests that make use of locker (juspay#6735)
  chore(version): 2024.12.26.1
  fix(router): populate `profile_id` in for the HeaderAuth of v1 (juspay#6936)
  docs(openapi): update /relay request example (juspay#6942)
  chore(version): 2024.12.26.0
  fix(payments_list): handle same payment/attempt ids for different merchants (juspay#6917)
  refactor(core): remove merchant return url from `router_data` (juspay#6895)
  feat(router): add endpoint for listing connector features  (juspay#6612)
  fix(wasm): remove chasenet from jpmorgan wasm as ChaseNet doesn’t exist in PMT (juspay#6927)
  fix(cors): expose all headers set by application in `access-control-expose-headers` header value (juspay#6877)
  chore(version): 2024.12.24.0
  feat(cypress): valdiate `error_code` and `error_message` and make it visible in `reports` (juspay#6913)
  fix(wasm): remove extra space from wasm for payment_method_type of JPMorgan (juspay#6923)
  fix(wasm): fix feature dependencies in `connector_configs` crate for WASM builds  (juspay#6832)
  feat(router): add /retrieve api for relay (juspay#6918)
  feat(core): implemented platform merchant account (juspay#6882)
  feat(payments_v2): add payment method list endpoint (juspay#6805)
  fix(connector): [Cybersource] fix the required fields for wallet mandate payments (juspay#6911)
  chore(version): 2024.12.23.0
  feat(connector): [JPMORGAN] add Payment flows for cards (juspay#6668)
  ...
pixincreate added a commit to Ankesh2004/hyperswitch that referenced this pull request Dec 26, 2024
…r-verifyurl-in-redirection-handler

* 'main' of github.com:juspay/hyperswitch: (444 commits)
  ci: add tests that make use of locker (juspay#6735)
  chore(version): 2024.12.26.1
  fix(router): populate `profile_id` in for the HeaderAuth of v1 (juspay#6936)
  docs(openapi): update /relay request example (juspay#6942)
  chore(version): 2024.12.26.0
  fix(payments_list): handle same payment/attempt ids for different merchants (juspay#6917)
  refactor(core): remove merchant return url from `router_data` (juspay#6895)
  feat(router): add endpoint for listing connector features  (juspay#6612)
  fix(wasm): remove chasenet from jpmorgan wasm as ChaseNet doesn’t exist in PMT (juspay#6927)
  fix(cors): expose all headers set by application in `access-control-expose-headers` header value (juspay#6877)
  chore(version): 2024.12.24.0
  feat(cypress): valdiate `error_code` and `error_message` and make it visible in `reports` (juspay#6913)
  fix(wasm): remove extra space from wasm for payment_method_type of JPMorgan (juspay#6923)
  fix(wasm): fix feature dependencies in `connector_configs` crate for WASM builds  (juspay#6832)
  feat(router): add /retrieve api for relay (juspay#6918)
  feat(core): implemented platform merchant account (juspay#6882)
  feat(payments_v2): add payment method list endpoint (juspay#6805)
  fix(connector): [Cybersource] fix the required fields for wallet mandate payments (juspay#6911)
  chore(version): 2024.12.23.0
  feat(connector): [JPMORGAN] add Payment flows for cards (juspay#6668)
  ...
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.

fix(payments_list): handle same payment/attempt IDs for different merchants
3 participants