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

fix(router): Treat ApplePay session Response as an opaque object (#12336)

Anurag Thakur378dc3aba3d5
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.json
index efb5f18233..bda988c878 100644
--- a/api-reference/v1/openapi_spec_v1.json
+++ b/api-reference/v1/openapi_spec_v1.json
@@ -9952,7 +9952,7 @@
"$ref": "#/components/schemas/ThirdPartySdkSessionResponse"
},
{
- "$ref": "#/components/schemas/NoThirdPartySdkSessionResponse"
+ "description": "We get this session response, when there is no involvement of third party sdk\nThis is the common response most of the times"
},
{
"$ref": "#/components/schemas/NullObject"
@@ -26245,74 +26245,6 @@
"invoke_upi_qr_flow"
]
},
- "NoThirdPartySdkSessionResponse": {
- "type": "object",
- "required": [
- "epoch_timestamp",
- "expires_at",
- "merchant_session_identifier",
- "nonce",
- "merchant_identifier",
- "domain_name",
- "display_name",
- "signature",
- "operational_analytics_identifier",
- "retries",
- "psp_id"
- ],
- "properties": {
- "epoch_timestamp": {
- "type": "integer",
- "format": "int64",
- "description": "Timestamp at which session is requested",
- "minimum": 0
- },
- "expires_at": {
- "type": "integer",
- "format": "int64",
- "description": "Timestamp at which session expires",
- "minimum": 0
- },
- "merchant_session_identifier": {
- "type": "string",
- "description": "The identifier for the merchant session"
- },
- "nonce": {
- "type": "string",
- "description": "Apple pay generated unique ID (UUID) value"
- },
- "merchant_identifier": {
- "type": "string",
- "description": "The identifier for the merchant"
- },
- "domain_name": {
- "type": "string",
- "description": "The domain name of the merchant which is registered in Apple Pay"
- },
- "display_name": {
- "type": "string",
- "description": "The name to be displayed on Apple Pay button"
- },
- "signature": {
- "type": "string",
- "description": "A string which represents the properties of a payment"
- },
- "operational_analytics_identifier": {
- "type": "string",
- "description": "The identifier for the operational analytics"
- },
- "retries": {
- "type": "integer",
- "format": "int32",
- "description": "The number of retries to get the session response",
- "minimum": 0
- },
- "psp_id": {
- "type": "string",
- "description": "The identifier for the connector transaction"
- }
- }
- },
"NoonData": {
"type": "object",
"properties": {
diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.json
index 8d56a94bed..052e13aa02 100644
--- a/api-reference/v2/openapi_spec_v2.json
+++ b/api-reference/v2/openapi_spec_v2.json
@@ -6450,7 +6450,7 @@
"$ref": "#/components/schemas/ThirdPartySdkSessionResponse"
},
{
- "$ref": "#/components/schemas/NoThirdPartySdkSessionResponse"
+ "description": "We get this session response, when there is no involvement of third party sdk\nThis is the common response most of the times"
},
{
"$ref": "#/components/schemas/NullObject"
@@ -19294,74 +19294,6 @@
"invoke_upi_qr_flow"
]
},
- "NoThirdPartySdkSessionResponse": {
- "type": "object",
- "required": [
- "epoch_timestamp",
- "expires_at",
- "merchant_session_identifier",
- "nonce",
- "merchant_identifier",
- "domain_name",
- "display_name",
- "signature",
- "operational_analytics_identifier",
- "retries",
- "psp_id"
- ],
- "properties": {
- "epoch_timestamp": {
- "type": "integer",
- "format": "int64",
- "description": "Timestamp at which session is requested",
- "minimum": 0
- },
- "expires_at": {
- "type": "integer",
- "format": "int64",
- "description": "Timestamp at which session expires",
- "minimum": 0
- },
- "merchant_session_identifier": {
- "type": "string",
- "description": "The identifier for the merchant session"
- },
- "nonce": {
- "type": "string",
- "description": "Apple pay generated unique ID (UUID) value"
- },
- "merchant_identifier": {
- "type": "string",
- "description": "The identifier for the merchant"
- },
- "domain_name": {
- "type": "string",
- "description": "The domain name of the merchant which is registered in Apple Pay"
- },
- "display_name": {
- "type": "string",
- "description": "The name to be displayed on Apple Pay button"
- },
- "signature": {
- "type": "string",
- "description": "A string which represents the properties of a payment"
- },
- "operational_analytics_identifier": {
- "type": "string",
- "description": "The identifier for the operational analytics"
- },
- "retries": {
- "type": "integer",
- "format": "int32",
- "description": "The number of retries to get the session response",
- "minimum": 0
- },
- "psp_id": {
- "type": "string",
- "description": "The identifier for the connector transaction"
- }
- }
- },
"NoonData": {
"type": "object",
"properties": {
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index ceb2be972b..33954b64b1 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -6662,7 +6662,7 @@ pub struct UrlDetails {
pub struct AuthenticationForStartResponse {
pub authentication: UrlDetails,
}
-#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, ToSchema)]
+#[derive(Clone, Debug, PartialEq, serde::Serialize, ToSchema)]
#[serde(rename_all = "snake_case")]
pub enum NextActionType {
RedirectToUrl,
@@ -6677,9 +6677,7 @@ pub enum NextActionType {
InvokeUpiQrFlow,
}
-#[derive(
- Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema, SmithyModel,
-)]
+#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize, ToSchema, SmithyModel)]
#[serde(tag = "type", rename_all = "snake_case")]
#[smithy(namespace = "com.hyperswitch.smithy.types")]
pub enum NextActionData {
@@ -10308,9 +10306,7 @@ pub struct GooglePayTokenizationParameters {
pub stripe_version: Option<Secret<String>>,
}
-#[derive(
- Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema, SmithyModel,
-)]
+#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, ToSchema, SmithyModel)]
#[serde(tag = "wallet_name")]
#[serde(rename_all = "snake_case")]
#[smithy(namespace = "com.hyperswitch.smithy.types")]
@@ -10652,9 +10648,7 @@ pub struct OpenBankingSessionToken {
pub open_banking_session_token: String,
}
-#[derive(
- Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema, SmithyModel,
-)]
+#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, ToSchema, SmithyModel)]
#[serde(rename_all = "lowercase")]
#[smithy(namespace = "com.hyperswitch.smithy.types")]
pub struct ApplepaySessionTokenResponse {
@@ -10718,9 +10712,7 @@ pub enum NextActionCall {
EligibilityCheck,
}
-#[derive(
- Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema, SmithyModel,
-)]
+#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, ToSchema, SmithyModel)]
#[serde(untagged)]
#[smithy(namespace = "com.hyperswitch.smithy.types")]
pub enum ApplePaySessionResponse {
@@ -10729,54 +10721,12 @@ pub enum ApplePaySessionResponse {
ThirdPartySdk(ThirdPartySdkSessionResponse),
/// We get this session response, when there is no involvement of third party sdk
/// This is the common response most of the times
- #[smithy(value_type = "NoThirdPartySdkSessionResponse")]
- NoThirdPartySdk(NoThirdPartySdkSessionResponse),
+ NoThirdPartySdk(serde_json::Value),
/// This is for the empty session response
#[smithy(value_type = "smithy.api#Unit")]
NoSessionResponse(NullObject),
}
-#[derive(
- Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema, serde::Deserialize, SmithyModel,
-)]
-#[serde(rename_all(deserialize = "camelCase"))]
-#[smithy(namespace = "com.hyperswitch.smithy.types")]
-pub struct NoThirdPartySdkSessionResponse {
- /// Timestamp at which session is requested
- #[smithy(value_type = "u64")]
- pub epoch_timestamp: u64,
- /// Timestamp at which session expires
- #[smithy(value_type = "u64")]
- pub expires_at: u64,
- /// The identifier for the merchant session
- #[smithy(value_type = "String")]
- pub merchant_session_identifier: String,
- /// Apple pay generated unique ID (UUID) value
- #[smithy(value_type = "String")]
- pub nonce: String,
- /// The identifier for the merchant
- #[smithy(value_type = "String")]
- pub merchant_identifier: String,
- /// The domain name of the merchant which is registered in Apple Pay
- #[smithy(value_type = "String")]
- pub domain_name: String,
- /// The name to be displayed on Apple Pay button
- #[smithy(value_type = "String")]
- pub display_name: String,
- /// A string which represents the properties of a payment
- #[smithy(value_type = "String")]
- pub signature: String,
- /// The identifier for the operational analytics
- #[smithy(value_type = "String")]
- pub operational_analytics_identifier: String,
- /// The number of retries to get the session response
- #[smithy(value_type = "u8")]
- pub retries: u8,
- /// The identifier for the connector transaction
- #[smithy(value_type = "String")]
- pub psp_id: String,
-}
-
#[derive(
Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema, SmithyModel,
)]
diff --git a/crates/hyperswitch_connectors/src/connectors/bluesnap/transformers.rs b/crates/hyperswitch_connectors/src/connectors/bluesnap/transformers.rs
index ed8c719fc6..7cab45be3e 100644
--- a/crates/hyperswitch_connectors/src/connectors/bluesnap/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/bluesnap/transformers.rs
@@ -4,8 +4,7 @@ use api_models::{
payments::{
AmountInfo, ApplePayPaymentRequest, ApplePaySessionResponse,
ApplepayCombinedSessionTokenData, ApplepaySessionTokenData, ApplepaySessionTokenMetadata,
- ApplepaySessionTokenResponse, NextActionCall, NoThirdPartySdkSessionResponse,
- SdkNextAction, SessionToken,
+ ApplepaySessionTokenResponse, NextActionCall, SdkNextAction, SessionToken,
},
webhooks::IncomingWebhookEvent,
};
@@ -528,8 +527,8 @@ impl
.decode(response.wallet_token.clone().expose())
.change_context(errors::ConnectorError::ResponseHandlingFailed)?;
- let session_response: NoThirdPartySdkSessionResponse = wallet_token
- .parse_struct("NoThirdPartySdkSessionResponse")
+ let session_response: Value = wallet_token
+ .parse_struct("serde_json::Value")
.change_context(errors::ConnectorError::ParsingFailed)?;
let metadata = item.data.get_connector_meta()?.expose();
diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rs
index 3fc6ae5267..f8eadb6a84 100644
--- a/crates/openapi/src/openapi.rs
+++ b/crates/openapi/src/openapi.rs
@@ -628,7 +628,6 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::payments::ApplePaySessionResponse,
api_models::payments::NullObject,
api_models::payments::ThirdPartySdkSessionResponse,
- api_models::payments::NoThirdPartySdkSessionResponse,
api_models::payments::SecretInfoToInitiateSdk,
api_models::payments::ApplePayPaymentRequest,
api_models::payments::ApplePayBillingContactFields,
diff --git a/crates/openapi/src/openapi_v2.rs b/crates/openapi/src/openapi_v2.rs
index 2f712b2215..ebf5756215 100644
--- a/crates/openapi/src/openapi_v2.rs
+++ b/crates/openapi/src/openapi_v2.rs
@@ -551,7 +551,6 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::payments::HyperswitchVaultSessionDetails,
api_models::payments::ApplePaySessionResponse,
api_models::payments::ThirdPartySdkSessionResponse,
- api_models::payments::NoThirdPartySdkSessionResponse,
api_models::payments::SecretInfoToInitiateSdk,
api_models::payments::ApplePayPaymentRequest,
api_models::payments::ApplePayBillingContactFields,
diff --git a/crates/router/src/compatibility/stripe/payment_intents/types.rs b/crates/router/src/compatibility/stripe/payment_intents/types.rs
index 1731b87b82..d20770e3dd 100644
--- a/crates/router/src/compatibility/stripe/payment_intents/types.rs
+++ b/crates/router/src/compatibility/stripe/payment_intents/types.rs
@@ -469,7 +469,7 @@ impl From<StripePaymentCancelRequest> for payments::PaymentsCancelRequest {
}
}
-#[derive(Default, Eq, PartialEq, Serialize, Debug)]
+#[derive(Default, PartialEq, Serialize, Debug)]
pub struct StripePaymentIntentResponse {
pub id: id_type::PaymentId,
pub object: &'static str,
@@ -677,7 +677,7 @@ fn from_timestamp_to_datetime(
}
}
-#[derive(Default, Eq, PartialEq, Serialize)]
+#[derive(Default, PartialEq, Serialize)]
pub struct StripePaymentIntentListResponse {
pub object: String,
pub url: String,
@@ -815,7 +815,7 @@ pub struct RedirectUrl {
pub url: Option<String>,
}
-#[derive(Eq, PartialEq, serde::Serialize, Debug)]
+#[derive(PartialEq, serde::Serialize, Debug)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum StripeNextAction {
RedirectToUrl {
diff --git a/crates/router/src/compatibility/stripe/setup_intents/types.rs b/crates/router/src/compatibility/stripe/setup_intents/types.rs
index 6874ea0d91..5e72d41c2b 100644
--- a/crates/router/src/compatibility/stripe/setup_intents/types.rs
+++ b/crates/router/src/compatibility/stripe/setup_intents/types.rs
@@ -365,7 +365,7 @@ pub struct RedirectUrl {
pub url: Option<String>,
}
-#[derive(Eq, PartialEq, serde::Serialize)]
+#[derive(PartialEq, serde::Serialize)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum StripeNextAction {
RedirectToUrl {
@@ -505,7 +505,7 @@ pub(crate) fn into_stripe_next_action(
})
}
-#[derive(Default, Eq, PartialEq, Serialize)]
+#[derive(Default, PartialEq, Serialize)]
pub struct StripeSetupIntentResponse {
pub id: id_type::PaymentId,
pub object: String,
diff --git a/crates/router/src/core/payments/flows/session_flow.rs b/crates/router/src/core/payments/flows/session_flow.rs
index 4f0c513c5d..a2fccaaff3 100644
--- a/crates/router/src/core/payments/flows/session_flow.rs
+++ b/crates/router/src/core/payments/flows/session_flow.rs
@@ -574,9 +574,9 @@ async fn create_applepay_session_token(
apple_pay_res
.map(|res| {
let response: Result<
- payment_types::NoThirdPartySdkSessionResponse,
+ serde_json::Value,
Report<common_utils::errors::ParsingError>,
- > = res.response.parse_struct("NoThirdPartySdkSessionResponse");
+ > = res.response.parse_struct("serde_json::Value");
// logging the parsing failed error
if let Err(error) = response.as_ref() {