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(core): Add payments update-intent API for v2 #6490

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
openapi: post /v2/payments/{id}/update-intent
---
1 change: 1 addition & 0 deletions api-reference-v2/mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"pages": [
"api-reference/payments/payments--create-intent",
"api-reference/payments/payments--get-intent",
"api-reference/payments/payments--update-intent",
"api-reference/payments/payments--session-token",
"api-reference/payments/payments--confirm-intent",
"api-reference/payments/payments--get"
Expand Down
239 changes: 239 additions & 0 deletions api-reference-v2/openapi_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -1911,6 +1911,67 @@
]
}
},
"/v2/payments/{id}/update-intent": {
"put": {
"tags": [
"Payments"
],
"summary": "Payments - Update Intent",
"description": "**Update a payment intent object**\n\nYou will require the 'API - Key' from the Hyperswitch dashboard to make the call.",
"operationId": "Update a Payment Intent",
"parameters": [
{
"name": "id",
"in": "path",
"description": "The unique identifier for the Payment Intent",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PaymentsUpdateIntentRequest"
},
"examples": {
"Update a payment intent with minimal fields": {
"value": {
"amount_details": {
"currency": "USD",
"order_amount": 6540
}
}
}
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Payment Intent Updated",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PaymentsIntentResponse"
}
}
}
},
"404": {
"description": "Payment Intent Not Found"
}
},
"security": [
{
"api_key": []
}
]
}
},
"/v2/payments/{id}/confirm-intent": {
"post": {
"tags": [
Expand Down Expand Up @@ -15256,6 +15317,184 @@
}
}
},
"PaymentsUpdateIntentRequest": {
"type": "object",
"properties": {
"amount_details": {
"allOf": [
{
"$ref": "#/components/schemas/AmountDetails"
}
],
"nullable": true
},
"routing_algorithm_id": {
"type": "string",
"description": "The routing algorithm id to be used for the payment",
"nullable": true
},
"capture_method": {
"allOf": [
{
"$ref": "#/components/schemas/CaptureMethod"
}
],
"nullable": true
},
"authentication_type": {
"allOf": [
{
"$ref": "#/components/schemas/AuthenticationType"
}
],
"default": "no_three_ds",
"nullable": true
},
"billing": {
"allOf": [
{
"$ref": "#/components/schemas/Address"
}
],
"nullable": true
},
"shipping": {
"allOf": [
{
"$ref": "#/components/schemas/Address"
}
],
"nullable": true
},
"customer_present": {
"allOf": [
{
"$ref": "#/components/schemas/PresenceOfCustomerDuringPayment"
}
],
"nullable": true
},
"description": {
"type": "string",
"description": "A description for the payment",
"example": "It's my first payment request",
"nullable": true
},
"return_url": {
"type": "string",
"description": "The URL to which you want the user to be redirected after the completion of the payment operation",
"example": "https://hyperswitch.io",
"nullable": true
},
"setup_future_usage": {
"allOf": [
{
"$ref": "#/components/schemas/FutureUsage"
}
],
"nullable": true
},
"apply_mit_exemption": {
"allOf": [
{
"$ref": "#/components/schemas/MitExemptionRequest"
}
],
"nullable": true
},
"statement_descriptor": {
"type": "string",
"description": "For non-card charges, you can use this value as the complete description that appears on your customers’ statements. Must contain at least one letter, maximum 22 characters.",
"example": "Hyperswitch Router",
"nullable": true,
"maxLength": 22
},
"order_details": {
"type": "array",
"items": {
"$ref": "#/components/schemas/OrderDetailsWithAmount"
},
"description": "Use this object to capture the details about the different products for which the payment is being made. The sum of amount across different products here should be equal to the overall payment amount",
"example": "[{\n \"product_name\": \"Apple iPhone 16\",\n \"quantity\": 1,\n \"amount\" : 69000\n \"product_img_link\" : \"https://dummy-img-link.com\"\n }]",
"nullable": true
},
"allowed_payment_method_types": {
"type": "array",
"items": {
"$ref": "#/components/schemas/PaymentMethodType"
},
"description": "Use this parameter to restrict the Payment Method Types to show for a given PaymentIntent",
"nullable": true
},
"metadata": {
"type": "object",
"description": "Metadata is useful for storing additional, unstructured information on an object.",
"nullable": true
},
"connector_metadata": {
"allOf": [
{
"$ref": "#/components/schemas/ConnectorMetadata"
}
],
"nullable": true
},
"feature_metadata": {
"allOf": [
{
"$ref": "#/components/schemas/FeatureMetadata"
}
],
"nullable": true
},
"enable_payment_link": {
"allOf": [
{
"$ref": "#/components/schemas/EnablePaymentLinkRequest"
}
],
"nullable": true
},
"payment_link_config": {
"allOf": [
{
"$ref": "#/components/schemas/PaymentLinkConfigRequest"
}
],
"nullable": true
},
"request_incremental_authorization": {
"allOf": [
{
"$ref": "#/components/schemas/RequestIncrementalAuthorization"
}
],
"nullable": true
},
"session_expiry": {
"type": "integer",
"format": "int32",
"description": "Will be used to expire client secret after certain amount of time to be supplied in seconds, if not sent it will be taken from profile config\n(900) for 15 mins",
"example": 900,
"nullable": true,
"minimum": 0
},
"frm_metadata": {
"type": "object",
"description": "Additional data related to some frm(Fraud Risk Management) connectors",
"nullable": true
},
"request_external_three_ds_authentication": {
"allOf": [
{
"$ref": "#/components/schemas/External3dsAuthenticationRequest"
}
],
"nullable": true
}
},
"additionalProperties": false
},
"PayoutActionRequest": {
"type": "object"
},
Expand Down
99 changes: 99 additions & 0 deletions crates/api_models/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,105 @@ pub struct PaymentsGetIntentRequest {
pub id: id_type::GlobalPaymentId,
}

#[derive(Debug, serde::Serialize, serde::Deserialize, Clone, ToSchema)]
#[serde(deny_unknown_fields)]
#[cfg(feature = "v2")]
pub struct PaymentsUpdateIntentRequest {
pub amount_details: Option<AmountDetails>,

/// The routing algorithm id to be used for the payment
#[schema(value_type = Option<String>)]
pub routing_algorithm_id: Option<id_type::RoutingId>,

#[schema(value_type = Option<CaptureMethod>, example = "automatic")]
Copy link
Contributor Author

@AnuthaDev AnuthaDev Nov 7, 2024

Choose a reason for hiding this comment

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

Should the value_type be omitted for fields having same type as value_type?

Copy link
Member

Choose a reason for hiding this comment

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

No, we are specifying the value type here because the enum is type qualified. Type qualified usages do not work with ToSchema macro

pub capture_method: Option<api_enums::CaptureMethod>,

#[schema(value_type = Option<AuthenticationType>, example = "no_three_ds", default = "no_three_ds")]
pub authentication_type: Option<api_enums::AuthenticationType>,

/// The billing details of the payment. This address will be used for invoicing.
#[schema(value_type = Option<Address>)]
pub billing: Option<Address>,

/// The shipping address for the payment
#[schema(value_type = Option<Address>)]
pub shipping: Option<Address>,

/// Set to true to indicate that the customer is in your checkout flow during this payment, and therefore is able to authenticate. This parameter should be false when merchant's doing merchant initiated payments and customer is not present while doing the payment.
#[schema(example = true, value_type = Option<PresenceOfCustomerDuringPayment>)]
pub customer_present: Option<common_enums::PresenceOfCustomerDuringPayment>,

/// A description for the payment
#[schema(example = "It's my first payment request", value_type = Option<String>)]
pub description: Option<common_utils::types::Description>,

/// The URL to which you want the user to be redirected after the completion of the payment operation
#[schema(value_type = Option<String>, example = "https://hyperswitch.io")]
pub return_url: Option<common_utils::types::Url>,

#[schema(value_type = Option<FutureUsage>, example = "off_session")]
pub setup_future_usage: Option<api_enums::FutureUsage>,

/// Apply MIT exemption for a payment
#[schema(value_type = Option<MitExemptionRequest>)]
pub apply_mit_exemption: Option<common_enums::MitExemptionRequest>,

/// For non-card charges, you can use this value as the complete description that appears on your customers’ statements. Must contain at least one letter, maximum 22 characters.
#[schema(max_length = 22, example = "Hyperswitch Router", value_type = Option<String>)]
pub statement_descriptor: Option<common_utils::types::StatementDescriptor>,

/// Use this object to capture the details about the different products for which the payment is being made. The sum of amount across different products here should be equal to the overall payment amount
#[schema(value_type = Option<Vec<OrderDetailsWithAmount>>, example = r#"[{
"product_name": "Apple iPhone 16",
"quantity": 1,
"amount" : 69000
"product_img_link" : "https://dummy-img-link.com"
}]"#)]
pub order_details: Option<Vec<OrderDetailsWithAmount>>,

/// Use this parameter to restrict the Payment Method Types to show for a given PaymentIntent
#[schema(value_type = Option<Vec<PaymentMethodType>>)]
pub allowed_payment_method_types: Option<Vec<api_enums::PaymentMethodType>>,

/// Metadata is useful for storing additional, unstructured information on an object.
#[schema(value_type = Option<Object>, example = r#"{ "udf1": "some-value", "udf2": "some-value" }"#)]
pub metadata: Option<pii::SecretSerdeValue>,

/// Some connectors like Apple pay, Airwallex and Noon might require some additional information, find specific details in the child attributes below.
#[schema(value_type = Option<ConnectorMetadata>)]
pub connector_metadata: Option<pii::SecretSerdeValue>,

/// Additional data that might be required by hyperswitch based on the requested features by the merchants.
#[schema(value_type = Option<FeatureMetadata>)]
pub feature_metadata: Option<FeatureMetadata>,

/// Whether to generate the payment link for this payment or not (if applicable)
#[schema(value_type = Option<EnablePaymentLinkRequest>)]
pub enable_payment_link: Option<common_enums::EnablePaymentLinkRequest>,

/// Configure a custom payment link for the particular payment
#[schema(value_type = Option<PaymentLinkConfigRequest>)]
pub payment_link_config: Option<admin::PaymentLinkConfigRequest>,

/// Request an incremental authorization, i.e., increase the authorized amount on a confirmed payment before you capture it.
#[schema(value_type = Option<RequestIncrementalAuthorization>)]
pub request_incremental_authorization: Option<common_enums::RequestIncrementalAuthorization>,

/// Will be used to expire client secret after certain amount of time to be supplied in seconds, if not sent it will be taken from profile config
///(900) for 15 mins
#[schema(value_type = Option<u32>, example = 900)]
pub session_expiry: Option<u32>,

/// Additional data related to some frm(Fraud Risk Management) connectors
#[schema(value_type = Option<Object>, example = r#"{ "coverage_request" : "fraud", "fulfillment_method" : "delivery" }"#)]
pub frm_metadata: Option<pii::SecretSerdeValue>,

/// Whether to perform external authentication (if applicable)
#[schema(value_type = Option<External3dsAuthenticationRequest>)]
pub request_external_three_ds_authentication:
Option<common_enums::External3dsAuthenticationRequest>,
}

#[derive(Debug, serde::Serialize, Clone, ToSchema)]
#[serde(deny_unknown_fields)]
#[cfg(feature = "v2")]
Expand Down
Loading
Loading