diff --git a/api-reference-v2/api-reference/payment-method-session/payment-method-session--confirm-a-payment-method-session.mdx b/api-reference-v2/api-reference/payment-method-session/payment-method-session--confirm-a-payment-method-session.mdx new file mode 100644 index 00000000000..d115fc72370 --- /dev/null +++ b/api-reference-v2/api-reference/payment-method-session/payment-method-session--confirm-a-payment-method-session.mdx @@ -0,0 +1,3 @@ +--- +openapi: post /v2/payment-method-session/:id/confirm +--- \ No newline at end of file diff --git a/api-reference-v2/mint.json b/api-reference-v2/mint.json index 8fd3b64230b..212fc873ade 100644 --- a/api-reference-v2/mint.json +++ b/api-reference-v2/mint.json @@ -65,7 +65,8 @@ "api-reference/payment-method-session/payment-method-session--create", "api-reference/payment-method-session/payment-method-session--retrieve", "api-reference/payment-method-session/payment-method-session--list-payment-methods", - "api-reference/payment-method-session/payment-method-session--update-a-saved-payment-method" + "api-reference/payment-method-session/payment-method-session--update-a-saved-payment-method", + "api-reference/payment-method-session/payment-method-session--confirm-a-payment-method-session" ] }, { diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.json index 62e12cbddea..5b22a31aaed 100644 --- a/api-reference-v2/openapi_spec.json +++ b/api-reference-v2/openapi_spec.json @@ -2690,6 +2690,83 @@ ] } }, + "/v2/payment-method-session/:id/confirm": { + "post": { + "tags": [ + "Payment Method Session" + ], + "summary": "Payment Method Session - Confirm a payment method session", + "description": "**Confirms a payment method session object with the payment method data**", + "operationId": "Confirm the payment method session", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The unique identifier for the Payment Method Session", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "X-Profile-Id", + "in": "header", + "description": "Profile ID associated to the payment intent", + "required": true, + "schema": { + "type": "string" + }, + "example": "pro_abcdefghijklmnop" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PaymentMethodSessionConfirmRequest" + }, + "examples": { + "Confirm the payment method session with card details": { + "value": { + "payment_method_data": { + "card": { + "card_cvc": "123", + "card_exp_month": "10", + "card_exp_year": "25", + "card_number": "4242424242424242" + } + }, + "payment_method_subtype": "credit", + "payment_method_type": "card" + } + } + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Payment Method created", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PaymentMethodResponse" + } + } + } + }, + "400": { + "description": "Missing Mandatory fields" + } + }, + "security": [ + { + "publishable_key": [] + } + ] + } + }, "/v2/refunds": { "post": { "tags": [ @@ -14581,6 +14658,25 @@ } ] }, + "PaymentMethodSessionConfirmRequest": { + "type": "object", + "required": [ + "payment_method_type", + "payment_method_subtype", + "payment_method_data" + ], + "properties": { + "payment_method_type": { + "$ref": "#/components/schemas/PaymentMethod" + }, + "payment_method_subtype": { + "$ref": "#/components/schemas/PaymentMethodType" + }, + "payment_method_data": { + "$ref": "#/components/schemas/PaymentMethodDataRequest" + } + } + }, "PaymentMethodSessionRequest": { "type": "object", "required": [ diff --git a/crates/api_models/src/payment_methods.rs b/crates/api_models/src/payment_methods.rs index a8e074cfd1e..fae12289521 100644 --- a/crates/api_models/src/payment_methods.rs +++ b/crates/api_models/src/payment_methods.rs @@ -576,7 +576,7 @@ pub enum CardType { // We cannot use the card struct that we have for payments for the following reason // The card struct used for payments has card_cvc as mandatory -// but when vulting the card, we do not need cvc to be collected from the user +// but when vaulting the card, we do not need cvc to be collected from the user // This is because, the vaulted payment method can be used for future transactions in the presence of the customer // when the customer is on_session again, the cvc can be collected from the customer #[cfg(all(feature = "v2", feature = "payment_methods_v2"))] @@ -2586,6 +2586,7 @@ pub struct PaymentMethodSessionConfirmRequest { pub payment_method_subtype: common_enums::PaymentMethodType, /// The payment instrument data to be used for the payment + #[schema(value_type = PaymentMethodDataRequest)] pub payment_method_data: payments::PaymentMethodDataRequest, } diff --git a/crates/openapi/src/openapi_v2.rs b/crates/openapi/src/openapi_v2.rs index e5c9c6fa81f..deaa1577d4d 100644 --- a/crates/openapi/src/openapi_v2.rs +++ b/crates/openapi/src/openapi_v2.rs @@ -141,6 +141,7 @@ Never share your secret api keys. Keep them guarded and secure. routes::payment_method::payment_method_session_retrieve, routes::payment_method::payment_method_session_list_payment_methods, routes::payment_method::payment_method_session_update_saved_payment_method, + routes::payment_method::payment_method_session_confirm, //Routes for refunds routes::refunds::refunds_create, @@ -672,6 +673,7 @@ Never share your secret api keys. Keep them guarded and secure. api_models::enums::TokenizationType, api_models::enums::NetworkTokenizationToggle, api_models::payments::PaymentAmountDetailsResponse, + api_models::payment_methods::PaymentMethodSessionConfirmRequest, routes::payments::ForceSync, )), modifiers(&SecurityAddon) diff --git a/crates/openapi/src/routes/payment_method.rs b/crates/openapi/src/routes/payment_method.rs index 3c1f66e6e76..c980ef5aeff 100644 --- a/crates/openapi/src/routes/payment_method.rs +++ b/crates/openapi/src/routes/payment_method.rs @@ -423,3 +423,48 @@ pub fn payment_method_session_list_payment_methods() {} security(("ephemeral_key" = [])) )] pub fn payment_method_session_update_saved_payment_method() {} + +/// Payment Method Session - Confirm a payment method session +/// +/// **Confirms a payment method session object with the payment method data** +#[utoipa::path( + post, + path = "/v2/payment-method-session/:id/confirm", + params (("id" = String, Path, description = "The unique identifier for the Payment Method Session"), + ( + "X-Profile-Id" = String, Header, + description = "Profile ID associated to the payment intent", + example = "pro_abcdefghijklmnop" + ) + ), + request_body( + content = PaymentMethodSessionConfirmRequest, + examples( + ( + "Confirm the payment method session with card details" = ( + value = json!({ + "payment_method_type": "card", + "payment_method_subtype": "credit", + "payment_method_data": { + "card": { + "card_number": "4242424242424242", + "card_exp_month": "10", + "card_exp_year": "25", + "card_cvc": "123" + } + }, + }) + ) + ), + ), + ), + responses( + (status = 200, description = "Payment Method created", body = PaymentMethodResponse), + (status = 400, description = "Missing Mandatory fields") + ), + tag = "Payment Method Session", + operation_id = "Confirm the payment method session", + security(("publishable_key" = [])), +)] +#[cfg(feature = "v2")] +pub fn payment_method_session_confirm() {} diff --git a/crates/router/src/core/payment_methods.rs b/crates/router/src/core/payment_methods.rs index 94b93a8f5b4..e573b9a4df5 100644 --- a/crates/router/src/core/payment_methods.rs +++ b/crates/router/src/core/payment_methods.rs @@ -2252,6 +2252,8 @@ async fn create_zero_auth_payment( )) .await?; + logger::info!(associated_payments_response=?response); + Ok(()) }