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(router): Add Payments - List endpoint for v2 #7191

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

Conversation

AnuthaDev
Copy link
Contributor

@AnuthaDev AnuthaDev commented Feb 5, 2025

Type of Change

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

Description

Added Payments - List endpoint for v2

Additional Changes

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

Motivation and Context

How did you test it?

  • Request:
curl --location 'http://localhost:8080/v2/payments/list' \
--header 'Content-Type: application/json' \
--header 'x-profile-id: pro_oJHm83lyP59ddE5WUaY8' \
--header 'api-key: dev_Mz8tRnZsfjgA5eIibpiQ3SQcL0fJ3XeHnZOjFZpOmfOv84zK6vkzhz1KL4JgXG7S' \
--data '{
    "limit": 20
}'
  • Response:
{
    "count": 1,
    "total_count": 1,
    "data": [
        {
            "id": "12345_pay_0194eeb7d3c37a7081eeee3d3435e9a6",
            "merchant_id": "cloth_seller_amGnZWFTPuy2tgN2Ajxl",
            "profile_id": "pro_oJHm83lyP59ddE5WUaY8",
            "customer_id": null,
            "payment_method_id": null,
            "status": "requires_payment_method",
            "amount": {
                "order_amount": 100,
                "currency": "USD",
                "shipping_cost": null,
                "order_tax_amount": null,
                "external_tax_calculation": "skip",
                "surcharge_calculation": "skip",
                "surcharge_amount": null,
                "tax_on_surcharge": null,
                "net_amount": 100,
                "amount_to_capture": null,
                "amount_capturable": 0,
                "amount_captured": null
            },
            "created": "2025-02-10T07:16:52.303Z",
            "payment_method_type": null,
            "payment_method_subtype": null,
            "connector": null,
            "merchant_connector_id": null,
            "customer": null,
            "merchant_reference_id": null,
            "connector_payment_id": null,
            "connector_response_reference_id": null,
            "metadata": null,
            "description": null,
            "authentication_type": "no_three_ds",
            "capture_method": "manual",
            "setup_future_usage": "on_session",
            "attempt_count": 0,
            "error": null,
            "cancellation_reason": null,
            "order_details": null,
            "return_url": null,
            "statement_descriptor": null,
            "allowed_payment_method_types": null,
            "authorization_count": 0,
            "modified_at": "2025-02-10T07:16:52.303Z"
        }
    ]
}

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

@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Feb 5, 2025
@AnuthaDev AnuthaDev self-assigned this Feb 10, 2025
@AnuthaDev AnuthaDev added this to the February 2025 Release milestone Feb 10, 2025
@AnuthaDev AnuthaDev linked an issue Feb 10, 2025 that may be closed by this pull request
@AnuthaDev AnuthaDev marked this pull request as ready for review February 10, 2025 07:18
@AnuthaDev AnuthaDev requested review from a team as code owners February 10, 2025 07:18
@AnuthaDev AnuthaDev removed the request for review from a team February 12, 2025 09:54
pub struct CustomerDetailsResponse {
/// The identifier for the customer.
#[schema(value_type = Option<String>, max_length = 64, min_length = 1, example = "cus_y3oqhf46pyzuxjbcn2giaqnb44")]
pub id: Option<id_type::GlobalCustomerId>,
Copy link
Contributor

Choose a reason for hiding this comment

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

id should be mandatory when you are returning CustomerDetailsResponse right?


/// A unique identifier for a payment provided by the connector
#[schema(value_type = Option<String>, example = "993672945374576J")]
pub connector_payment_id: Option<String>,
Copy link
Contributor

Choose a reason for hiding this comment

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

How's it different from connector_response_reference_id?

@@ -5504,6 +5684,18 @@ pub struct PaymentListResponseV2 {
pub data: Vec<PaymentsResponse>,
}

#[cfg(feature = "v2")]
#[derive(Clone, Debug, serde::Serialize)]
pub struct PaymentListResponseV2 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need both PaymentListResponse and PaymentListResponseV2 in V2?

req,
)
},
&auth::ApiKeyAuth,
Copy link
Contributor

Choose a reason for hiding this comment

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

We should add JWTAuth here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
M-api-contract-changes Metadata: This PR involves API contract changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE]: Add Payments - List to v2
3 participants