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 get-intent API for v2 #6396

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

Conversation

AnuthaDev
Copy link
Contributor

@AnuthaDev AnuthaDev commented Oct 22, 2024

Type of Change

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

Description

Added get-intent API for payments

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

How did you test it?

1a. Request

curl --location 'http://localhost:8080/v2/payments/12345_pay_0192b3a0145173519abaa04d4b939558/get-intent' \
--header 'Content-Type: application/json' \
--header 'X-Profile-Id: pro_wcilqiS8axGFvpzfO9pw' \
--header 'api-key: dev_D3bTAROAIoP4nlqsaQXLzXoLdZznkpWQ3l4mzMRJEAP7V46pSnZucJM2zQiVwG0J'

1b. Response

{
    "id": "12345_pay_0192b3a0145173519abaa04d4b939558",
    "amount_details": {
        "order_amount": {
            "Value": 100
        },
        "currency": "USD",
        "shipping_cost": null,
        "order_tax_amount": null,
        "skip_external_tax_calculation": "Skip",
        "skip_surcharge_calculation": "Skip",
        "surcharge_amount": null,
        "tax_on_surcharge": null
    },
    "client_secret": "12345_pay_0192b3a0145173519abaa04d4b939558_secret_0192b3a0145173519abaa05c07ec3e61",
    "merchant_reference_id": null,
    "routing_algorithm_id": null,
    "capture_method": "automatic",
    "authentication_type": "no_three_ds",
    "billing": null,
    "shipping": null,
    "customer_id": null,
    "customer_present": "Present",
    "description": null,
    "return_url": null,
    "setup_future_usage": "on_session",
    "apply_mit_exemption": "Skip",
    "statement_descriptor": null,
    "order_details": null,
    "allowed_payment_method_types": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "payment_link_enabled": "Skip",
    "payment_link_config": null,
    "request_incremental_authorization": "default",
    "expires_on": "2024-10-22T10:02:45.618Z",
    "frm_metadata": null,
    "request_external_three_ds_authentication": "Skip"
}

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

Copy link

semanticdiff-com bot commented Oct 22, 2024

Review changes with SemanticDiff.

Analyzed 16 of 17 files.

Overall, the semantic diff is 48% smaller than the GitHub diff.

Filename Status
✔️ crates/router_env/src/logger/types.rs Analyzed
✔️ crates/router/src/types/api/payments.rs 7.29% smaller
✔️ crates/router/src/services/api.rs Analyzed
✔️ crates/router/src/routes/app.rs 30.95% smaller
✔️ crates/router/src/routes/lock_utils.rs 37.84% smaller
✔️ crates/router/src/routes/payments.rs Analyzed
✔️ crates/router/src/core/payments/operations.rs Analyzed
✔️ crates/router/src/core/payments/transformers.rs Analyzed
✔️ crates/router/src/core/payments/operations/payment_get_intent.rs Analyzed
✔️ crates/openapi/src/openapi_v2.rs Analyzed
✔️ crates/openapi/src/routes/payments.rs Analyzed
✔️ crates/hyperswitch_domain_models/src/router_flow_types/payments.rs Analyzed
✔️ crates/api_models/src/payments.rs Analyzed
✔️ crates/api_models/src/events/payment.rs 24.77% smaller
✔️ api-reference-v2/mint.json Analyzed
✔️ api-reference-v2/openapi_spec.json 88.83% smaller
api-reference-v2/api-reference/payments/payments--get-intent.mdx Unsupported file format

@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Oct 22, 2024
@AnuthaDev AnuthaDev added this to the October 2024 Release milestone Oct 22, 2024
@AnuthaDev AnuthaDev marked this pull request as ready for review October 23, 2024 09:34
@AnuthaDev AnuthaDev requested review from a team as code owners October 23, 2024 09:34
@@ -57,7 +57,7 @@ pub struct CalculateTax;
pub struct SdkSessionUpdate;

#[derive(Debug, Clone)]
pub struct CreateIntent;
pub struct Intent;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this OK or should this be PaymentsIntent instead? Or we need separate CreateIntent and GetIntent?

params (("id" = String, Path, description = "The unique identifier for the Payment Intent")),
responses(
(status = 200, description = "Payment Intent", body = PaymentsIntentResponse),
(status = 404, description = "Payment ID not found")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should this be 400 instead? What all status codes need to be mentioned here?

.find_payment_intent_by_id(key_manager_state, &request.id, key_store, storage_scheme)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Payment Intent Not Found")?;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This feels incomplete?

errors::StorageError,
> {
// validate customer_id if sent in the request
if let Some(id) = payment_data.payment_intent.customer_id.clone() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This shouldn't be needed for GetIntent. Should I remove this?

impl ApiEventMetric for PaymentsGetIntentRequest {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Payment {
payment_id: self.id.clone(),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should this be a reference instead?

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 get-intent API for v2
1 participant