Bug: restructure `Samsung Pay` connector wallet details



We need to restructure the Samsung Pay session token data stored in the connector wallet details as going forward we will add support for samsung pay payments with hyperswitch credentials. Then the samsung pay payment can be done using either merchant's credentials or hyperswitch's credentials. If it is  merchant's credentials, it needs to be provided in the time of the merchant connector account creation. 

But when it comes to hyperswitch's credentials flow, merchant will provide only merchant specific business information (like merchant name that should be displayed to customer during the payment and merchant's business country). Whereas the private key or the required Samsung Pay certificates for the decryption will reside in the application env.

```
"connector_wallets_details": {
        "samsung_pay": {
            "merchant_credentials": {
                "service_id": "samsung pay service id",
                "merchant_display_name": "merchant name",
                "merchant_business_country": "IN",
                "allowed_brands": [
                    "visa",
                    "masterCard",
                    "amex",
                    "discover"
                ]
            }
        }
```

```
"connector_wallets_details": {
        "samsung_pay": {
            "application_credentials": {
                "merchant_display_name": "merchant name",
                "merchant_business_country": "IN",
                "allowed_brands": [
                    "visa",
                    "masterCard",
                    "amex",
                    "discover"
                ]
            }
        }
```
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index 456bb8e43a3..9d606dacb9f 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -4908,20 +4908,37 @@ pub struct GpaySessionTokenData {
     pub data: GpayMetaData,
 }
 
+#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
+#[serde(rename_all = "snake_case")]
+pub enum SamsungPayCombinedMetadata {
+    // This is to support the Samsung Pay decryption flow with application credentials,
+    // where the private key, certificates, or any other information required for decryption
+    // will be obtained from the environment variables.
+    ApplicationCredentials(SamsungPayApplicationCredentials),
+    MerchantCredentials(SamsungPayMerchantCredentials),
+}
+
 #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
 pub struct SamsungPaySessionTokenData {
     #[serde(rename = "samsung_pay")]
-    pub data: SamsungPayMetadata,
+    pub data: SamsungPayCombinedMetadata,
 }
 
 #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
-pub struct SamsungPayMetadata {
+pub struct SamsungPayMerchantCredentials {
     pub service_id: String,
     pub merchant_display_name: String,
     pub merchant_business_country: api_enums::CountryAlpha2,
     pub allowed_brands: Vec<String>,
 }
 
+#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
+pub struct SamsungPayApplicationCredentials {
+    pub merchant_display_name: String,
+    pub merchant_business_country: api_enums::CountryAlpha2,
+    pub allowed_brands: Vec<String>,
+}
+
 #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
 pub struct PaypalSdkMetaData {
     pub client_id: String,
diff --git a/crates/router/src/core/payments/flows/session_flow.rs b/crates/router/src/core/payments/flows/session_flow.rs
index 5bd81897dd8..ee657bc3949 100644
--- a/crates/router/src/core/payments/flows/session_flow.rs
+++ b/crates/router/src/core/payments/flows/session_flow.rs
@@ -502,7 +502,7 @@ fn create_samsung_pay_session_token(
     router_data: &types::PaymentsSessionRouterData,
     header_payload: api_models::payments::HeaderPayload,
 ) -> RouterResult<types::PaymentsSessionRouterData> {
-    let samsung_pay_wallet_details = router_data
+    let samsung_pay_session_token_data = router_data
         .connector_wallets_details
         .clone()
         .parse_value::<payment_types::SamsungPaySessionTokenData>("SamsungPaySessionTokenData")
@@ -527,18 +527,30 @@ fn create_samsung_pay_session_token(
         .get_required_value("samsung pay domain")
         .attach_printable("Failed to get domain for samsung pay session call")?;
 
+    let samsung_pay_wallet_details = match samsung_pay_session_token_data.data {
+        payment_types::SamsungPayCombinedMetadata::MerchantCredentials(
+            samsung_pay_merchant_credentials,
+        ) => samsung_pay_merchant_credentials,
+        payment_types::SamsungPayCombinedMetadata::ApplicationCredentials(
+            _samsung_pay_application_credentials,
+        ) => Err(errors::ApiErrorResponse::NotSupported {
+            message: "Samsung Pay decryption flow with application credentials is not implemented"
+                .to_owned(),
+        })?,
+    };
+
     Ok(types::PaymentsSessionRouterData {
         response: Ok(types::PaymentsResponseData::SessionResponse {
             session_token: payment_types::SessionToken::SamsungPay(Box::new(
                 payment_types::SamsungPaySessionTokenResponse {
                     version: "2".to_string(),
-                    service_id: samsung_pay_wallet_details.data.service_id,
+                    service_id: samsung_pay_wallet_details.service_id,
                     order_number: router_data.payment_id.clone(),
                     merchant_payment_information:
                         payment_types::SamsungPayMerchantPaymentInformation {
-                            name: samsung_pay_wallet_details.data.merchant_display_name,
+                            name: samsung_pay_wallet_details.merchant_display_name,
                             url: merchant_domain,
-                            country_code: samsung_pay_wallet_details.data.merchant_business_country,
+                            country_code: samsung_pay_wallet_details.merchant_business_country,
                         },
                     amount: payment_types::SamsungPayAmountDetails {
                         amount_format: payment_types::SamsungPayAmountFormat::FormatTotalPriceOnly,
@@ -546,7 +558,7 @@ fn create_samsung_pay_session_token(
                         total_amount: samsung_pay_amount,
                     },
                     protocol: payment_types::SamsungPayProtocolType::Protocol3ds,
-                    allowed_brands: samsung_pay_wallet_details.data.allowed_brands,
+                    allowed_brands: samsung_pay_wallet_details.allowed_brands,
                 },
             )),
         }),

## Type of Change
<!-- Put an `x` in the boxes that apply -->

- [ ] Bugfix
- [ ] New feature
- [ ] Enhancement
- [x] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD

## Description
<!-- Describe your changes in detail -->
We need to restructure the Samsung Pay session token data stored in the connector wallet details as going forward we will add support for samsung pay payments with hyperswitch credentials. Then the samsung pay payment can be done using either merchant's credentials or hyperswitch's credentials. If it is  merchant's credentials, it needs to be provided in the time of the merchant connector account creation. 

But when it comes to hyperswitch's credentials flow, merchant will provide only merchant specific business information (like merchant name that should be displayed to customer during the payment and merchant's business country). Whereas the private key or the required Samsung Pay certificates for the decryption will reside in the application env.

```
"connector_wallets_details": {
        "samsung_pay": {
            "merchant_credentials": {
                "service_id": "samsung pay service id",
                "merchant_display_name": "merchant name",
                "merchant_business_country": "IN",
                "allowed_brands": [
                    "visa",
                    "masterCard",
                    "amex",
                    "discover"
                ]
            }
        }
```

```
"connector_wallets_details": {
        "samsung_pay": {
            "application_credentials": {
                "merchant_display_name": "Hyperswitch",
                "merchant_business_country": "IN",
                "allowed_brands": [
                    "visa",
                    "masterCard",
                    "amex",
                    "discover"
                ]
            }
        }
    },
```

### Additional Changes

- [ ] This PR modifies the API contract
- [ ] This PR modifies the database schema
- [ ] This PR modifies application configuration/environment variables

<!--
Provide links to the files with corresponding changes.

Following are the paths where you can find config files:
1. `config`
2. `crates/router/src/configs`
3. `loadtest/config`
-->


## Motivation and Context
<!--
Why is this change required? What problem does it solve?
If it fixes an open issue, please link to the issue here.

If you don't have an issue, we'd recommend starting with one first so the PR
can focus on the implementation (unless it is an obvious bug or documentation fix
that will have little conversation).
-->


## How did you test it?
<!--
Did you write an integration/unit/API test to verify the code changes?
Or did you test this change manually (provide relevant screenshots)?
-->
```
{
    "connector_type": "payment_processor",
    "connector_name": "cybersource",
    "connector_account_details": {
        "auth_type": "SignatureKey",
        "api_secret": "api_secret",
        "key1": "key1",
        "api_key": "api_key"
    },
    "test_mode": true,
    "disabled": false,
    "payment_methods_enabled": [
        {
            "payment_method": "pay_later",
            "payment_method_types": [
                {
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true,
                    "payment_experience": "invoke_sdk_client",
                    "payment_method_type": "klarna"
                }
            ]
        },
        {
            "payment_method": "pay_later",
            "payment_method_types": [
                {
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true,
                    "payment_experience": "redirect_to_url",
                    "payment_method_type": "klarna"
                }
            ]
        },
        {
            "payment_method": "card",
            "payment_method_types": [
                {
                    "payment_method_type": "credit",
                    "payment_experience": null,
                    "card_networks": [
                        "Visa",
                        "Mastercard",
                        "Discover",
                        "DinersClub"
                    ],
                    "accepted_currencies": null,
                    "accepted_countries": null,
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "debit",
                    "payment_experience": null,
                    "card_networks": [
                        "Visa",
                        "Mastercard"
                    ],
                    "accepted_currencies": null,
                    "accepted_countries": null,
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        },
        {
            "payment_method": "bank_debit",
            "payment_method_types": [
                {
                    "payment_method_type": "ach",
                    "recurring_enabled": true,
                    "installment_payment_enabled": true,
                    "minimum_amount": 0,
                    "maximum_amount": 10000
                }
            ]
        },
        {
            "payment_method": "wallet",
            "payment_method_types": [
                {
                    "payment_method_type": "google_pay",
                    "payment_experience": "invoke_sdk_client",
                    "card_networks": null,
                    "accepted_currencies": null,
                    "accepted_countries": null,
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "samsung_pay",
                    "payment_experience": "invoke_sdk_client",
                    "card_networks": null,
                    "accepted_currencies": null,
                    "accepted_countries": null,
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "apple_pay",
                    "payment_experience": "invoke_sdk_client",
                    "card_networks": null,
                    "accepted_currencies": null,
                    "accepted_countries": null,
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "paypal",
                    "payment_experience": "redirect_to_url",
                    "card_networks": null,
                    "accepted_currencies": null,
                    "accepted_countries": null,
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        }
    ],
    "connector_wallets_details": {
        "samsung_pay": {
            "application_credentials": {
                "service_id": "49400558c67f4a97b3925f",
                "merchant_display_name": "Hyperswitch",
                "merchant_business_country": "IN",
                "allowed_brands": [
                    "visa",
                    "masterCard",
                    "amex",
                    "discover"
                ]
            }
        }
    },
    "connector_webhook_details": {
        "merchant_secret": "merchant_secret"
    }
}
```
-> create a payment with confirm false
```
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key:' \
--data '{
  "amount": 100000,
  "currency": "USD",
  "capture_method": "automatic",
  "authentication_type": "no_three_ds",
  "confirm": false,
  "customer_id": "cu_1727248481"
}'
```
```
{
    "payment_id": "pay_wySk2SloqGsTbSB8ficv",
    "merchant_id": "merchant_1727343230",
    "status": "requires_payment_method",
    "amount": 100000,
    "net_amount": 100000,
    "amount_capturable": 0,
    "amount_received": null,
    "connector": null,
    "client_secret": "pay_wySk2SloqGsTbSB8ficv_secret_LDsqsymJeHNbX6X6tGW6",
    "created": "2024-09-26T13:33:39.781Z",
    "currency": "USD",
    "customer_id": "cu_1727248481",
    "customer": {
        "id": "cu_1727248481",
        "name": null,
        "email": null,
        "phone": null,
        "phone_country_code": null
    },
    "description": null,
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": null,
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": null,
    "payment_method_data": null,
    "payment_token": null,
    "shipping": null,
    "billing": null,
    "order_details": null,
    "email": null,
    "name": null,
    "phone": null,
    "return_url": null,
    "authentication_type": "no_three_ds",
    "statement_descriptor_name": null,
    "statement_descriptor_suffix": null,
    "next_action": null,
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "payment_experience": null,
    "payment_method_type": null,
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "cu_1727248481",
        "created_at": 1727357619,
        "expires": 1727361219,
        "secret": "epk_780a72fc4a0d48338eeb3f029191723e"
    },
    "manual_retry_allowed": null,
    "connector_transaction_id": null,
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": null,
    "payment_link": null,
    "profile_id": "pro_xEdgnpJ0oxDZrkzS02MR",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": null,
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-09-26T13:48:39.780Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2024-09-26T13:33:39.842Z",
    "charges": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null
}
```
-> Session call
```
curl --location 'http://localhost:8080/payments/session_tokens' \
--header 'Content-Type: application/json' \
--header 'x-browser-name: Chrome' \
--header 'x-client-platform: web' \
--header 'x-merchant-domain: sdk-test-app.netlify.app' \
--header 'api-key:' \
--data '{
    "payment_id": "pay_GEoTU1wJGcWqs0vQ9TLD",
    "wallets": [],
    "client_secret": "pay_GEoTU1wJGcWqs0vQ9TLD_secret_HIh790VwGvLS2aTVfIAN"
}'
```
```
{
    "payment_id": "pay_GEoTU1wJGcWqs0vQ9TLD",
    "client_secret": "pay_GEoTU1wJGcWqs0vQ9TLD_secret_HIh790VwGvLS2aTVfIAN",
    "session_token": [
        {
            "wallet_name": "google_pay",
            "merchant_info": {
                "merchant_name": "Stripe"
            },
            "shipping_address_required": false,
            "email_required": false,
            "shipping_address_parameters": {
                "phone_number_required": false
            },
            "allowed_payment_methods": [
                {
                    "type": "CARD",
                    "parameters": {
                        "allowed_auth_methods": [
                            "PAN_ONLY",
                            "CRYPTOGRAM_3DS"
                        ],
                        "allowed_card_networks": [
                            "AMEX",
                            "DISCOVER",
                            "INTERAC",
                            "JCB",
                            "MASTERCARD",
                            "VISA"
                        ],
                        "billing_address_required": false
                    },
                    "tokenization_specification": {
                        "type": "PAYMENT_GATEWAY",
                        "parameters": {
                            "gateway": "stripe",
                            "stripe:version": "2018-10-31",
                            "stripe:publishableKey": "pk_test_51Msk2GAGHc77EJXX78h549SX2uaOnEkUYqBfjcoD05PIpAnDkYxMn8nQ4d19im85NQuX4Z6WDyHaUw2fFTPBWsIY00Wa7oNerO"
                        }
                    }
                }
            ],
            "transaction_info": {
                "country_code": "US",
                "currency_code": "USD",
                "total_price_status": "Final",
                "total_price": "1000.00"
            },
            "delayed_session_token": false,
            "connector": "cybersource",
            "sdk_next_action": {
                "next_action": "confirm"
            },
            "secrets": null
        },
        {
            "wallet_name": "samsung_pay",
            "version": "2",
            "service_id": "49400558c67f4a97b3925f",
            "order_number": "pay_GEoTU1wJGcWqs0vQ9TLD",
            "merchant": {
                "name": "Hyperswitch",
                "url": "sdk-test-app.netlify.app",
                "country_code": "IN"
            },
            "amount": {
                "option": "FORMAT_TOTAL_PRICE_ONLY",
                "currency_code": "USD",
                "total": "1000.00"
            },
            "protocol": "PROTOCOL3DS",
            "allowed_brands": [
                "visa",
                "masterCard",
                "amex",
                "discover"
            ]
        },
        {
            "wallet_name": "apple_pay",
            "payment_request_data": {
                "country_code": "US",
                "currency_code": "USD",
                "total": {
                    "label": "applepay",
                    "type": "final",
                    "amount": "1000.00"
                },
                "merchant_capabilities": [
                    "supports3DS"
                ],
                "supported_networks": [
                    "visa",
                    "masterCard",
                    "amex",
                    "discover"
                ],
                "merchant_identifier": "merchant.com.hyperswitch.checkout"
            },
            "connector": "cybersource",
            "delayed_session_token": false,
            "sdk_next_action": {
                "next_action": "confirm"
            },
            "connector_reference_id": null,
            "connector_sdk_public_key": null,
            "connector_merchant_id": null
        }
    ]
}
```


## Checklist
<!-- Put an `x` in the boxes that apply -->

- [x] I formatted the code `cargo +nightly fmt --all`
- [x] I addressed lints thrown by `cargo clippy`
- [x] I reviewed the submitted code
- [ ] I added unit tests for my changes where possible
