Skip to content

Conversation

apoorvdixit88
Copy link
Contributor

@apoorvdixit88 apoorvdixit88 commented Jul 21, 2024

Type of Change

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

Description

Support sort criterial for payments list:

  • sort on basis of amount (ascending or descending)
  • sort on basis of created at time (ascending or descending)

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

How did you test it?

Use the curl to sort the list by following order. Order takes on (the field which need to be considered) and by( ascending or descending)

curl --location 'http://localhost:8080/payments/list' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer JWT' \
--data '{  
    "order": {
        "on": "created",
        "by": "asc" 
    }   
}'

Or

curl --location 'http://localhost:8080/payments/list' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer JWT' \
--data '{  
    "order": {
        "on": "amount",
        "by": "desc" 
    }   
}'

Response, here the payments will be sorted in decreasing order of amount:

{
    "count": 2,
    "total_count": 2,
    "data": [
        {
            "payment_id": "pay_gBlmx0AlNp55baW0ATDt",
            "merchant_id": "merchant_1721657037",
            "status": "succeeded",
            "amount": 7000,
            "net_amount": 0,
            "amount_capturable": 7000,
            "amount_received": null,
            "connector": "stripe",
            "client_secret": "pay_gBlmx0AlNp55baW0ATDt_secret_Ay9Hs88sJ24Md4CRkL0v",
            "created": "2024-07-23T09:32:56.212Z",
            "currency": "EUR",
            "customer_id": "uiuiuiui",
            "customer": {
                "id": "uiuiuiui",
                "name": null,
                "email": "[email protected]",
                "phone": null,
                "phone_country_code": null
            },
            "description": "Its my first payment request",
            "refunds": null,
            "disputes": null,
            "mandate_id": null,
            "mandate_data": null,
            "setup_future_usage": "on_session",
            "off_session": null,
            "capture_on": null,
            "capture_method": "automatic",
            "payment_method": "card",
            "payment_method_data": {
                "card": {
                    "last4": "0003",
                    "card_type": null,
                    "card_network": null,
                    "card_issuer": null,
                    "card_issuing_country": null,
                    "card_isin": "400000",
                    "card_extended_bin": null,
                    "card_exp_month": "10",
                    "card_exp_year": "25",
                    "card_holder_name": null,
                    "payment_checks": {
                        "cvc_check": "pass",
                        "address_line1_check": "pass",
                        "address_postal_code_check": "pass"
                    },
                    "authentication_data": null
                },
                "billing": null
            },
            "payment_token": null,
            "shipping": {
                "address": {
                    "city": "San Fransico",
                    "country": "US",
                    "line1": "1467",
                    "line2": "Harrison Street",
                    "line3": "Harrison Street",
                    "zip": "94122",
                    "state": "California",
                    "first_name": "joseph",
                    "last_name": "Doe"
                },
                "phone": {
                    "number": "8056594427",
                    "country_code": "+91"
                },
                "email": null
            },
            "billing": {
                "address": {
                    "city": "San Fransico",
                    "country": "NL",
                    "line1": "1467",
                    "line2": "Harrison Street",
                    "line3": "Harrison Street",
                    "zip": "94122",
                    "state": "California",
                    "first_name": "joseph",
                    "last_name": "Doe"
                },
                "phone": {
                    "number": "8056594427",
                    "country_code": "+91"
                },
                "email": "[email protected]"
            },
            "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": null,
            "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": "pi_3Pff5ZD5R7gDAGff0gTXIJJX",
            "frm_message": null,
            "metadata": {
                "udf1": "value1",
                "login_date": "2019-09-10T10:11:12Z",
                "new_customer": "true"
            },
            "connector_metadata": null,
            "feature_metadata": null,
            "reference_id": null,
            "payment_link": null,
            "profile_id": "pro_YbnmkkPd2qkewT96ujee",
            "surcharge_details": null,
            "attempt_count": 1,
            "merchant_decision": null,
            "merchant_connector_id": "mca_f3JtTVYi3pElw14sKngo",
            "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
        },
        {
            "payment_id": "pay_SqPYBFChdnejflFdVXm0",
            "merchant_id": "merchant_1721657037",
            "status": "succeeded",
            "amount": 6540,
            "net_amount": 0,
            "amount_capturable": 6540,
            "amount_received": null,
            "connector": "stripe",
            "client_secret": "pay_SqPYBFChdnejflFdVXm0_secret_VTAtKjSlI7fnCEICo9v3",
            "created": "2024-07-22T14:12:15.554Z",
            "currency": "EUR",
            "customer_id": "uiuiuiui",
            "customer": {
                "id": "uiuiuiui",
                "name": null,
                "email": "[email protected]",
                "phone": null,
                "phone_country_code": null
            },
            "description": "Its my first payment request",
            "refunds": null,
            "disputes": null,
            "mandate_id": null,
            "mandate_data": null,
            "setup_future_usage": "on_session",
            "off_session": null,
            "capture_on": null,
            "capture_method": "automatic",
            "payment_method": "card",
            "payment_method_data": {
                "card": {
                    "last4": "0003",
                    "card_type": null,
                    "card_network": null,
                    "card_issuer": null,
                    "card_issuing_country": null,
                    "card_isin": "400000",
                    "card_extended_bin": null,
                    "card_exp_month": "10",
                    "card_exp_year": "25",
                    "card_holder_name": null,
                    "payment_checks": {
                        "cvc_check": "pass",
                        "address_line1_check": "pass",
                        "address_postal_code_check": "pass"
                    },
                    "authentication_data": null
                },
                "billing": null
            },
            "payment_token": null,
            "shipping": {
                "address": {
                    "city": "San Fransico",
                    "country": "US",
                    "line1": "1467",
                    "line2": "Harrison Street",
                    "line3": "Harrison Street",
                    "zip": "94122",
                    "state": "California",
                    "first_name": "joseph",
                    "last_name": "Doe"
                },
                "phone": {
                    "number": "8056594427",
                    "country_code": "+91"
                },
                "email": null
            },
            "billing": {
                "address": {
                    "city": "San Fransico",
                    "country": "NL",
                    "line1": "1467",
                    "line2": "Harrison Street",
                    "line3": "Harrison Street",
                    "zip": "94122",
                    "state": "California",
                    "first_name": "joseph",
                    "last_name": "Doe"
                },
                "phone": {
                    "number": "8056594427",
                    "country_code": "+91"
                },
                "email": "[email protected]"
            },
            "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": null,
            "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": "pi_3PfMyLD5R7gDAGff1mamZiPY",
            "frm_message": null,
            "metadata": {
                "udf1": "value1",
                "login_date": "2019-09-10T10:11:12Z",
                "new_customer": "true"
            },
            "connector_metadata": null,
            "feature_metadata": null,
            "reference_id": null,
            "payment_link": null,
            "profile_id": "pro_YbnmkkPd2qkewT96ujee",
            "surcharge_details": null,
            "attempt_count": 1,
            "merchant_decision": null,
            "merchant_connector_id": "mca_f3JtTVYi3pElw14sKngo",
            "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
        }
    ]
}

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-feature Category: Feature request or enhancement A-payments Area: payments labels Jul 21, 2024
@apoorvdixit88 apoorvdixit88 self-assigned this Jul 21, 2024
@apoorvdixit88 apoorvdixit88 requested a review from a team as a code owner July 21, 2024 23:14
@apoorvdixit88 apoorvdixit88 marked this pull request as draft July 21, 2024 23:14
@apoorvdixit88 apoorvdixit88 marked this pull request as ready for review July 23, 2024 09:29
@apoorvdixit88 apoorvdixit88 added the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Jul 23, 2024
lsampras
lsampras previously approved these changes Jul 25, 2024
jarnura
jarnura previously approved these changes Jul 25, 2024
@apoorvdixit88 apoorvdixit88 dismissed stale reviews from jarnura and lsampras via 2de6431 July 25, 2024 21:15
ThisIsMani
ThisIsMani previously approved these changes Jul 26, 2024
@likhinbopanna likhinbopanna enabled auto-merge July 26, 2024 13:14
@likhinbopanna likhinbopanna added this pull request to the merge queue Jul 26, 2024
Merged via the queue into main with commit 043ea6d Jul 26, 2024
14 checks passed
@likhinbopanna likhinbopanna deleted the implement-sorting-for-payments-operations branch July 26, 2024 14:18
@SanchithHegde SanchithHegde removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Jul 28, 2024
pixincreate added a commit that referenced this pull request Jul 30, 2024
* 'main' of github.com:juspay/hyperswitch:
  refactor(router): remove `connector_account_details` and `connector_webhook_details` in merchant_connector_account list response (#5457)
  feat: add env variable for enable key manager service (#5442)
  chore(version): 2024.07.29.0
  feat(payments): support sort criteria in payments list (#5389)
  refactor(connector):  add amount conversion framework to placetopay (#4988)
  feat(connector): [Bambora APAC] add mandate flow (#5376)
  ci: set code owners for payment methods files (#5453)
  refactor(opensearch): Add Error Handling for Empty Query and Filters in Request (#5432)
  chore: address Rust 1.80 clippy lints (#5447)
  feat(connector): [FISERV] Move connector to hyperswitch_connectors (#5441)
  ci: add support for just hack_v2 check for PRs (#5426)
  fix: added created at and modified at keys in PaymentAttemptResponse (#5412)
  refactor(merchant_account_v2): recreate id for `merchant_account` v2  (#5439)
  chore(version): 2024.07.26.0
  feat(events): forward the tenant configuration as part of the kafka message (#5224)
  refactor(connector):  add amount conversion framework to payone (#4981)
  refactor(user_roles): make org and merchant id nullable (#5353)
  fix(euclid): change the address taken in SessionFlowRouting from shipping to billing address (#5435)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-payments Area: payments C-feature Category: Feature request or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Sorting POC
6 participants