Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

docs: updated documentation for v2 PM session (#10884)

Sarthak Soni7ff68af7da77
diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.json
index c82b89e92d..0def8f8906 100644
--- a/api-reference/v2/openapi_spec_v2.json
+++ b/api-reference/v2/openapi_spec_v2.json
@@ -3128,7 +3128,7 @@
"examples": {
"Update the card holder name": {
"value": {
- "payment_method_id": "12345_pm_0194b1ecabc172e28aeb71f70a4daba3"
+ "payment_method_token": "token_9wcXDRVkfEtLEsSnYKgQ"
}
}
}
@@ -3138,11 +3138,11 @@
},
"responses": {
"200": {
- "description": "The payment method has been updated successfully",
+ "description": "The payment method has been deleted successfully",
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/PaymentMethodDeleteResponse"
+ "$ref": "#/components/schemas/PaymentMethodDeleteSessionResponse"
}
}
}
@@ -3229,10 +3229,11 @@
"value": {
"payment_method_data": {
"card": {
+ "card_cvc": "456",
"card_holder_name": "Narayan Bhat"
}
},
- "payment_method_id": "12345_pm_0194b1ecabc172e28aeb71f70a4daba3"
+ "payment_method_token": "token_9wcXDRVkfEtLEsSnYKgQ"
}
}
}
@@ -3246,7 +3247,7 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/PaymentMethodResponse"
+ "$ref": "#/components/schemas/PaymentMethodSessionResponse"
}
}
}
@@ -3323,7 +3324,7 @@
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/PaymentMethodResponse"
+ "$ref": "#/components/schemas/PaymentMethodSessionResponse"
}
}
}
@@ -5379,6 +5380,46 @@
}
}
},
+ "AssociatedPaymentMethodTokenType": {
+ "oneOf": [
+ {
+ "type": "object",
+ "required": [
+ "type",
+ "data"
+ ],
+ "properties": {
+ "type": {
+ "type": "string",
+ "enum": [
+ "payment_method_session_token"
+ ]
+ },
+ "data": {
+ "type": "string",
+ "description": "Payment Method Session Token",
+ "example": "token_9wcXDRVkfEtLEsSnYKgQ"
+ }
+ }
+ }
+ ],
+ "description": "Token type for Payment Method Session associated payment methods",
+ "discriminator": {
+ "propertyName": "type"
+ }
+ },
+ "AssociatedPaymentMethods": {
+ "type": "object",
+ "description": "Details of associated payment methods for Payment Methods Session",
+ "required": [
+ "payment_method_token"
+ ],
+ "properties": {
+ "payment_method_token": {
+ "$ref": "#/components/schemas/AssociatedPaymentMethodTokenType"
+ }
+ }
+ },
"AttemptStatus": {
"type": "string",
"description": "The status of the attempt",
@@ -8322,26 +8363,32 @@
},
"last4_digits": {
"type": "string",
+ "example": "4242",
"nullable": true
},
"expiry_month": {
"type": "string",
+ "example": "10",
"nullable": true
},
"expiry_year": {
"type": "string",
+ "example": "25",
"nullable": true
},
"card_holder_name": {
"type": "string",
+ "example": "John Doe",
"nullable": true
},
"card_fingerprint": {
"type": "string",
+ "example": "fingerprint_12345",
"nullable": true
},
"nick_name": {
"type": "string",
+ "example": "Card",
"nullable": true
},
"card_network": {
@@ -8354,18 +8401,22 @@
},
"card_isin": {
"type": "string",
+ "example": "4567890",
"nullable": true
},
"card_issuer": {
"type": "string",
+ "example": "Issuer Bank",
"nullable": true
},
"card_type": {
"type": "string",
+ "example": "Credit",
"nullable": true
},
"saved_to_locker": {
- "type": "boolean"
+ "type": "boolean",
+ "example": true
}
}
},
@@ -11601,40 +11652,48 @@
"properties": {
"code": {
"type": "string",
- "description": "The error code"
+ "description": "The error code",
+ "example": "card_declined"
},
"message": {
"type": "string",
- "description": "The error message"
+ "description": "The error message",
+ "example": "The card was declined."
},
"reason": {
"type": "string",
"description": "The detailed error reason that was returned by the connector.",
+ "example": "The card was declined.",
"nullable": true
},
"unified_code": {
"type": "string",
"description": "The unified error code across all connectors.\nThis can be relied upon for taking decisions based on the error.",
+ "example": "card_declined",
"nullable": true
},
"unified_message": {
"type": "string",
"description": "The unified error message across all connectors.\nIf there is a translation available, this will have the translated message",
+ "example": "The card was declined.",
"nullable": true
},
"network_advice_code": {
"type": "string",
"description": "This field can be returned for both approved and refused Mastercard payments.\nThis code provides additional information about the type of transaction or the reason why the payment failed.\nIf the payment failed, the network advice code gives guidance on if and when you can retry the payment.",
+ "example": "01",
"nullable": true
},
"network_decline_code": {
"type": "string",
"description": "For card errors resulting from a card issuer decline, a brand specific 2, 3, or 4 digit code which indicates the reason the authorization failed.",
+ "example": "05",
"nullable": true
},
"network_error_message": {
"type": "string",
"description": "A string indicating how to proceed with an network error if payment gateway provide one. This is used to understand the network error code better.",
+ "example": "Do not retry",
"nullable": true
}
}
@@ -15887,6 +15946,7 @@
"properties": {
"last4_digits": {
"type": "string",
+ "example": "4242",
"nullable": true
},
"issuer_country": {
@@ -15899,26 +15959,32 @@
},
"network_token_expiry_month": {
"type": "string",
+ "example": "05",
"nullable": true
},
"network_token_expiry_year": {
"type": "string",
+ "example": "27",
"nullable": true
},
"nick_name": {
"type": "string",
+ "example": "Card",
"nullable": true
},
"card_holder_name": {
"type": "string",
+ "example": "John Doe",
"nullable": true
},
"card_isin": {
"type": "string",
+ "example": "16712672",
"nullable": true
},
"card_issuer": {
"type": "string",
+ "example": "Bank of America",
"nullable": true
},
"card_network": {
@@ -15931,6 +15997,7 @@
},
"card_type": {
"type": "string",
+ "example": "Credit",
"nullable": true
},
"saved_to_locker": {
@@ -16391,7 +16458,8 @@
],
"properties": {
"redirect_to_url": {
- "type": "string"
+ "type": "string",
+ "example": "https://example.com/redirect"
},
"type": {
"type": "string",
@@ -19346,6 +19414,19 @@
}
}
},
+ "PaymentMethodDeleteSessionResponse": {
+ "type": "object",
+ "required": [
+ "payment_method_token"
+ ],
+ "properties": {
+ "payment_method_token": {
+ "type": "string",
+ "description": "The unique identifier of the Payment method",
+ "example": "token_9wcXDRVkfEtLEsSnYKgQ"
+ }
+ }
+ },
"PaymentMethodGetTokenDetailsResponse": {
"type": "object",
"required": [
@@ -19760,7 +19841,7 @@
"properties": {
"payment_method_token": {
"type": "string",
- "description": "The payment method token associated with the payment method to be updated",
+ "description": "The payment method token associated with the payment method to be deleted",
"example": "token_9wcXDRVkfEtLEsSnYKgQ"
}
}
@@ -19872,11 +19953,13 @@
},
"client_secret": {
"type": "string",
- "description": "Client Secret"
+ "description": "Client Secret",
+ "example": "cs_9wcXDRVkfEtLEsSnYKgQ"
},
"return_url": {
"type": "string",
"description": "The return url to which the user should be redirected to",
+ "example": "https://merchant-website.com/return",
"nullable": true
},
"next_action": {
@@ -19898,7 +19981,7 @@
"associated_payment_methods": {
"type": "array",
"items": {
- "type": "string"
+ "$ref": "#/components/schemas/AssociatedPaymentMethods"
},
"description": "The payment method that was created using this payment method session",
"nullable": true
@@ -24350,7 +24433,8 @@
},
"connector_id": {
"type": "string",
- "description": "The merchant connector id to be used for tokenization"
+ "description": "The merchant connector id to be used for tokenization",
+ "example": "mca_28a7367sad8239s67"
}
}
},
diff --git a/crates/api_models/src/payment_methods.rs b/crates/api_models/src/payment_methods.rs
index 74cc4ff7c6..7cf9c9388a 100644
--- a/crates/api_models/src/payment_methods.rs
+++ b/crates/api_models/src/payment_methods.rs
@@ -1232,21 +1232,25 @@ impl From<CoBadgedCardDataToBeSaved> for CoBadgedCardData {
#[derive(Clone, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)]
pub struct NetworkTokenDetailsPaymentMethod {
+ #[schema(value_type = Option<String>, example = "4242")]
pub last4_digits: Option<String>,
#[schema(value_type = Option<CountryAlpha2>)]
pub issuer_country: Option<common_enums::CountryAlpha2>,
- #[schema(value_type = Option<String>)]
+ #[schema(value_type = Option<String>, example = "05")]
pub network_token_expiry_month: Option<masking::Secret<String>>,
- #[schema(value_type = Option<String>)]
+ #[schema(value_type = Option<String>, example = "27")]
pub network_token_expiry_year: Option<masking::Secret<String>>,
- #[schema(value_type = Option<String>)]
+ #[schema(value_type = Option<String>, example = "Card")]
pub nick_name: Option<masking::Secret<String>>,
- #[schema(value_type = Option<String>)]
+ #[schema(value_type = Option<String>, example = "John Doe")]
pub card_holder_name: Option<masking::Secret<String>>,
+ #[schema(value_type = Option<String>, example = "16712672")]
pub card_isin: Option<String>,
+ #[schema(value_type = Option<String>, example = "Bank of America")]
pub card_issuer: Option<String>,
- #[schema(value_type = Option<CardNetwork>)]
+ #[schema(value_type = Option<CardNetwork>, example = "VISA")]
pub card_network: Option<api_enums::CardNetwork>,
+ #[schema(value_type = Option<String>, example = "Credit")]
pub card_type: Option<String>,
#[serde(default = "saved_in_locker_default")]
pub saved_to_locker: bool,
@@ -1449,32 +1453,37 @@ pub struct CardDetailFromLocker {
pub struct CardDetailFromLocker {
#[schema(value_type = Option<CountryAlpha2>)]
pub issuer_country: Option<api_enums::CountryAlpha2>,
+ #[schema(value_type = Option<String>, example = "4242")]
pub last4_digits: Option<String>,
#[serde(skip)]
#[schema(value_type=Option<String>)]
pub card_number: Option<CardNumber>,
- #[schema(value_type=Option<String>)]
+ #[schema(value_type=Option<String>, example = "10")]
pub expiry_month: Option<masking::Secret<String>>,
- #[schema(value_type=Option<String>)]
+ #[schema(value_type=Option<String>, example = "25")]
pub expiry_year: Option<masking::Secret<String>>,
- #[schema(value_type=Option<String>)]
+ #[schema(value_type=Option<String>, example = "John Doe")]
pub card_holder_name: Option<masking::Secret<String>>,
- #[schema(value_type=Option<String>)]
+ #[schema(value_type=Option<String>, example = "fingerprint_12345")]
pub card_fingerprint: Option<masking::Secret<String>>,
- #[schema(value_type=Option<String>)]
+ #[schema(value_type=Option<String>, example = "Card")]
pub nick_name: Option<masking::Secret<String>>,
- #[schema(value_type = Option<CardNetwork>)]
+ #[schema(value_type = Option<CardNetwork>, example = "VISA")]
pub card_network: Option<api_enums::CardNetwork>,
+ #[schema(value_type=Option<String>, example = "4567890")]
pub card_isin: Option<String>,
+ #[schema(value_type=Option<String>, example = "Issuer Bank")]
pub card_issuer: Option<String>,
+ #[schema(value_type=Option<String>, example = "Credit")]
pub card_type: Option<String>,
+ #[schema(value_type=bool, example = true)]
pub saved_to_locker: bool,
}
@@ -3448,7 +3457,7 @@ impl PaymentMethodSessionUpdateSavedPaymentMethod {
#[cfg(feature = "v2")]
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize, ToSchema)]
pub struct PaymentMethodSessionDeleteSavedPaymentMethod {
- /// The payment method token associated with the payment method to be updated
+ /// The payment method token associated with the payment method to be deleted
#[schema(value_type = String, example = "token_9wcXDRVkfEtLEsSnYKgQ")]
pub payment_method_token: String,
}
@@ -3510,11 +3519,11 @@ pub struct PaymentMethodSessionResponse {
pub expires_at: time::PrimitiveDateTime,
/// Client Secret
- #[schema(value_type = String)]
+ #[schema(value_type = String, example = "cs_9wcXDRVkfEtLEsSnYKgQ")]
pub client_secret: masking::Secret<String>,
/// The return url to which the user should be redirected to
- #[schema(value_type = Option<String>)]
+ #[schema(value_type = Option<String>, example = "https://merchant-website.com/return")]
pub return_url: Option<common_utils::types::Url>,
/// The next action details for the payment method session
@@ -3526,7 +3535,7 @@ pub struct PaymentMethodSessionResponse {
pub authentication_details: Option<AuthenticationDetails>,
/// The payment method that was created using this payment method session
- #[schema(value_type = Option<Vec<String>>)]
+ #[schema(value_type = Option<Vec<AssociatedPaymentMethods>>)]
pub associated_payment_methods:
Option<Vec<common_types::payment_methods::AssociatedPaymentMethods>>,
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index b69ad4caea..08bf07edd1 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -6521,7 +6521,7 @@ pub enum NextActionData {
/// Contains the url for redirection flow
#[cfg(feature = "v2")]
RedirectToUrl {
- #[schema(value_type = String)]
+ #[schema(value_type = String, example = "https://example.com/redirect")]
redirect_to_url: Url,
},
/// Informs the next steps for bank transfer and also contains the charges details (ex: amount received, amount charged etc)
@@ -8212,24 +8212,32 @@ pub struct PaymentsStatusRequest {
#[derive(Debug, serde::Serialize, serde::Deserialize, Clone, PartialEq, ToSchema)]
pub struct ErrorDetails {
/// The error code
+ #[schema(value_type = String, example = "card_declined")]
pub code: String,
/// The error message
+ #[schema(value_type = String, example = "The card was declined.")]
pub message: String,
/// The detailed error reason that was returned by the connector.
+ #[schema(value_type = Option<String>, example = "The card was declined.")]
pub reason: Option<String>,
/// The unified error code across all connectors.
/// This can be relied upon for taking decisions based on the error.
+ #[schema(value_type = Option<String>, example = "card_declined")]
pub unified_code: Option<String>,
/// The unified error message across all connectors.
/// If there is a translation available, this will have the translated message
+ #[schema(value_type = Option<String>, example = "The card was declined.")]
pub unified_message: Option<String>,
/// This field can be returned for both approved and refused Mastercard payments.
/// This code provides additional information about the type of transaction or the reason why the payment failed.
/// If the payment failed, the network advice code gives guidance on if and when you can retry the payment.
+ #[schema(value_type = Option<String>, example = "01")]
pub network_advice_code: Option<String>,
/// For card errors resulting from a card issuer decline, a brand specific 2, 3, or 4 digit code which indicates the reason the authorization failed.
+ #[schema(value_type = Option<String>, example = "05")]
pub network_decline_code: Option<String>,
/// A string indicating how to proceed with an network error if payment gateway provide one. This is used to understand the network error code better.
+ #[schema(value_type = Option<String>, example = "Do not retry")]
pub network_error_message: Option<String>,
}
diff --git a/crates/common_types/src/payment_methods.rs b/crates/common_types/src/payment_methods.rs
index 341a9c2113..cf922adfed 100644
--- a/crates/common_types/src/payment_methods.rs
+++ b/crates/common_types/src/payment_methods.rs
@@ -262,7 +262,7 @@ pub struct PspTokenization {
pub tokenization_type: common_enums::TokenizationType,
/// The merchant connector id to be used for tokenization
- #[schema(value_type = String)]
+ #[schema(value_type = String, example = "mca_28a7367sad8239s67")]
pub connector_id: common_utils::id_type::MerchantConnectorAccountId,
}
@@ -271,7 +271,7 @@ pub struct PspTokenization {
#[serde(tag = "type", content = "data", rename_all = "snake_case")]
pub enum AssociatedPaymentMethodTokenType {
/// Payment Method Session Token
- #[schema(value_type = String)]
+ #[schema(value_type = String, example = "token_9wcXDRVkfEtLEsSnYKgQ")]
PaymentMethodSessionToken(String),
}
diff --git a/crates/openapi/src/openapi_v2.rs b/crates/openapi/src/openapi_v2.rs
index 9053070c8e..c9e2c0252c 100644
--- a/crates/openapi/src/openapi_v2.rs
+++ b/crates/openapi/src/openapi_v2.rs
@@ -212,6 +212,8 @@ Never share your secret api keys. Keep them guarded and secure.
common_types::payment_methods::PaymentMethodsEnabled,
common_types::payment_methods::PspTokenization,
common_types::payment_methods::NetworkTokenization,
+ common_types::payment_methods::AssociatedPaymentMethods,
+ common_types::payment_methods::AssociatedPaymentMethodTokenType,
common_types::refunds::SplitRefund,
common_types::payments::ConnectorChargeResponseData,
common_types::payments::StripeChargeResponseData,
@@ -642,6 +644,7 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::payment_methods::TokenizeDataRequest,
api_models::payment_methods::TokenizePaymentMethodRequest,
api_models::payment_methods::CardCVCTokenStorageDetails,
+ api_models::payment_methods::PaymentMethodDeleteSessionResponse,
api_models::refunds::RefundListRequest,
api_models::refunds::RefundListResponse,
api_models::payments::AmountFilter,
diff --git a/crates/openapi/src/routes/payment_method.rs b/crates/openapi/src/routes/payment_method.rs
index a8d3d9065c..04f7ec9e17 100644
--- a/crates/openapi/src/routes/payment_method.rs
+++ b/crates/openapi/src/routes/payment_method.rs
@@ -467,10 +467,11 @@ pub fn payment_method_session_list_payment_methods() {}
content = PaymentMethodSessionUpdateSavedPaymentMethod,
examples(( "Update the card holder name" = (
value =json!( {
- "payment_method_id": "12345_pm_0194b1ecabc172e28aeb71f70a4daba3",
+ "payment_method_token": "token_9wcXDRVkfEtLEsSnYKgQ",
"payment_method_data": {
"card": {
- "card_holder_name": "Narayan Bhat"
+ "card_holder_name": "Narayan Bhat",
+ "card_cvc": "456"
}
}
}
@@ -478,7 +479,7 @@ pub fn payment_method_session_list_payment_methods() {}
)))
),
responses(
- (status = 200, description = "The payment method has been updated successfully", body = PaymentMethodResponse),
+ (status = 200, description = "The payment method has been updated successfully", body = PaymentMethodSessionResponse),
(status = 404, description = "The request is invalid")
),
tag = "Payment Method Session",
@@ -501,13 +502,13 @@ pub fn payment_method_session_update_saved_payment_method() {}
content = PaymentMethodSessionDeleteSavedPaymentMethod,
examples(( "Update the card holder name" = (
value =json!( {
- "payment_method_id": "12345_pm_0194b1ecabc172e28aeb71f70a4daba3",
+ "payment_method_token": "token_9wcXDRVkfEtLEsSnYKgQ",
}
)
)))
),
responses(
- (status = 200, description = "The payment method has been updated successfully", body = PaymentMethodDeleteResponse),
+ (status = 200, description = "The payment method has been deleted successfully", body = PaymentMethodDeleteSessionResponse),
(status = 404, description = "The request is invalid")
),
tag = "Payment Method Session",
@@ -590,7 +591,7 @@ pub async fn tokenize_card_using_pm_api() {}
),
),
responses(
- (status = 200, description = "Payment Method created", body = PaymentMethodResponse),
+ (status = 200, description = "Payment Method created", body = PaymentMethodSessionResponse),
(status = 400, description = "Missing Mandatory fields")
),
tag = "Payment Method Session",