Skip to content

Commit

Permalink
feat: add openapi for payment method session confirm
Browse files Browse the repository at this point in the history
  • Loading branch information
Narayanbhat166 committed Feb 18, 2025
1 parent 80a6ba9 commit 834b42e
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
openapi: post /v2/payment-method-session/:id/confirm
---
3 changes: 2 additions & 1 deletion api-reference-v2/mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
{
Expand Down
96 changes: 96 additions & 0 deletions api-reference-v2/openapi_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down Expand Up @@ -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": [
Expand Down
3 changes: 2 additions & 1 deletion crates/api_models/src/payment_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))]
Expand Down Expand Up @@ -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,
}

Expand Down
2 changes: 2 additions & 0 deletions crates/openapi/src/openapi_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
45 changes: 45 additions & 0 deletions crates/openapi/src/routes/payment_method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
2 changes: 2 additions & 0 deletions crates/router/src/core/payment_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2252,6 +2252,8 @@ async fn create_zero_auth_payment(
))
.await?;

logger::info!(associated_payments_response=?response);

Ok(())
}

Expand Down

0 comments on commit 834b42e

Please sign in to comment.