Bug: [FEATURE] Add Apple Pay Payment Method In Barclaycard



### Feature Description

Add Apple Pay Payment Method In Barclaycard

### Possible Implementation

Add Apple Pay Payment Method In Barclaycard

### Have you spent some time checking if this feature request has been raised before?

- [x] I checked and didn't find a similar issue

### Have you read the Contributing Guidelines?

- [x] I have read the [Contributing Guidelines](https://github.com/juspay/hyperswitch/blob/main/docs/CONTRIBUTING.md)

### Are you willing to submit a PR?

Yes, I am willing to submit a PR!
diff --git a/config/config.example.toml b/config/config.example.toml
index 00f7ba33a59..fdb5c2a0e5e 100644
--- a/config/config.example.toml
+++ b/config/config.example.toml
@@ -702,6 +702,7 @@ paze = { currency = "USD,SEK" }
 credit = { currency = "USD,GBP,EUR,PLN,SEK" }
 debit = { currency = "USD,GBP,EUR,PLN,SEK" }
 google_pay = { currency = "ARS, AUD, CAD, CLP, COP, EUR, HKD, INR, KWD, MYR, MXN, NZD, PEN, QAR, SAR, SGD, ZAR, UAH, AED, GBP, USD, PLN, SEK" }
+apple_pay = { currency = "ARS, CAD, CLP, COP, CNY, EUR, HKD, KWD, MYR, MXN, NZD, PEN, QAR, SAR, SGD, ZAR, UAH, GBP, AED, USD, PLN, SEK" }
 
 [pm_filters.globepay]
 ali_pay = { country = "GB",currency = "GBP" }
diff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.toml
index 40a0bdb137e..02b5a084f11 100644
--- a/config/deployments/integration_test.toml
+++ b/config/deployments/integration_test.toml
@@ -526,6 +526,7 @@ paze = { currency = "USD,SEK" }
 credit = { currency = "USD,GBP,EUR,PLN,SEK" }
 debit = { currency = "USD,GBP,EUR,PLN,SEK" }
 google_pay = { currency = "ARS, AUD, CAD, CLP, COP, EUR, HKD, INR, KWD, MYR, MXN, NZD, PEN, QAR, SAR, SGD, ZAR, UAH, AED, GBP, USD, PLN, SEK" }
+apple_pay = { currency = "ARS, CAD, CLP, COP, CNY, EUR, HKD, KWD, MYR, MXN, NZD, PEN, QAR, SAR, SGD, ZAR, UAH, GBP, AED, USD, PLN, SEK" }
 
 [pm_filters.itaubank]
 pix = { country = "BR", currency = "BRL" }
diff --git a/config/deployments/production.toml b/config/deployments/production.toml
index c4c37289fa1..9bebc017d1a 100644
--- a/config/deployments/production.toml
+++ b/config/deployments/production.toml
@@ -443,6 +443,7 @@ paze = { currency = "USD,SEK" }
 credit = { currency = "USD,GBP,EUR,PLN,SEK" }
 debit = { currency = "USD,GBP,EUR,PLN,SEK" }
 google_pay = { currency = "ARS, AUD, CAD, CLP, COP, EUR, HKD, INR, KWD, MYR, MXN, NZD, PEN, QAR, SAR, SGD, ZAR, UAH, AED, GBP, USD, PLN, SEK" }
+apple_pay = { currency = "ARS, CAD, CLP, COP, CNY, EUR, HKD, KWD, MYR, MXN, NZD, PEN, QAR, SAR, SGD, ZAR, UAH, GBP, AED, USD, PLN, SEK" }
 
 [pm_filters.itaubank]
 pix = { country = "BR", currency = "BRL" }
diff --git a/config/deployments/sandbox.toml b/config/deployments/sandbox.toml
index 171b4bf0987..b01733d1ae4 100644
--- a/config/deployments/sandbox.toml
+++ b/config/deployments/sandbox.toml
@@ -455,6 +455,7 @@ paze = { currency = "USD,SEK" }
 credit = { currency = "USD,GBP,EUR,PLN,SEK" }
 debit = { currency = "USD,GBP,EUR,PLN,SEK" }
 google_pay = { currency = "ARS, AUD, CAD, CLP, COP, EUR, HKD, INR, KWD, MYR, MXN, NZD, PEN, QAR, SAR, SGD, ZAR, UAH, AED, GBP, USD, PLN, SEK" }
+apple_pay = { currency = "ARS, CAD, CLP, COP, CNY, EUR, HKD, KWD, MYR, MXN, NZD, PEN, QAR, SAR, SGD, ZAR, UAH, GBP, AED, USD, PLN, SEK" }
 
 [pm_filters.nexixpay]
 credit = { country = "AT,BE,CY,EE,FI,FR,DE,GR,IE,IT,LV,LT,LU,MT,NL,PT,SK,SI,ES,BG,HR,DK,GB,NO,PL,CZ,RO,SE,CH,HU,AU,BR,US", currency = "ARS,AUD,BHD,CAD,CLP,CNY,COP,HRK,CZK,DKK,HKD,HUF,INR,JPY,KZT,JOD,KRW,KWD,MYR,MXN,NGN,NOK,PHP,QAR,RUB,SAR,SGD,VND,ZAR,SEK,CHF,THB,AED,EGP,GBP,USD,TWD,BYN,RSD,AZN,RON,TRY,AOA,BGN,EUR,UAH,PLN,BRL" }
diff --git a/config/development.toml b/config/development.toml
index a2d06e7d28e..6ed294918b6 100644
--- a/config/development.toml
+++ b/config/development.toml
@@ -621,6 +621,7 @@ paze = { currency = "USD,SEK" }
 credit = { currency = "USD,GBP,EUR,PLN,SEK" }
 debit = { currency = "USD,GBP,EUR,PLN,SEK" }
 google_pay = { currency = "ARS, AUD, CAD, CLP, COP, EUR, HKD, INR, KWD, MYR, MXN, NZD, PEN, QAR, SAR, SGD, ZAR, UAH, AED, GBP, USD, PLN, SEK" }
+apple_pay = { currency = "ARS, CAD, CLP, COP, CNY, EUR, HKD, KWD, MYR, MXN, NZD, PEN, QAR, SAR, SGD, ZAR, UAH, GBP, AED, USD, PLN, SEK" }
 
 
 [pm_filters.globepay]
diff --git a/config/docker_compose.toml b/config/docker_compose.toml
index 544caf4c9f2..5ab5b481905 100644
--- a/config/docker_compose.toml
+++ b/config/docker_compose.toml
@@ -669,6 +669,7 @@ paze = { currency = "USD,SEK" }
 credit = { currency = "USD,GBP,EUR,PLN,SEK" }
 debit = { currency = "USD,GBP,EUR,PLN,SEK" }
 google_pay = { currency = "ARS, AUD, CAD, CLP, COP, EUR, HKD, INR, KWD, MYR, MXN, NZD, PEN, QAR, SAR, SGD, ZAR, UAH, AED, GBP, USD, PLN, SEK" }
+apple_pay = { currency = "ARS, CAD, CLP, COP, CNY, EUR, HKD, KWD, MYR, MXN, NZD, PEN, QAR, SAR, SGD, ZAR, UAH, GBP, AED, USD, PLN, SEK" }
 
 [pm_filters.globepay]
 ali_pay = { country = "GB",currency = "GBP,CNY" }
diff --git a/crates/connector_configs/toml/development.toml b/crates/connector_configs/toml/development.toml
index bdedcf9d1f7..daf0119b9fe 100644
--- a/crates/connector_configs/toml/development.toml
+++ b/crates/connector_configs/toml/development.toml
@@ -1028,11 +1028,65 @@ options=["visa","masterCard","amex","discover"]
   payment_method_type = "UnionPay"
 [[barclaycard.wallet]]
   payment_method_type = "google_pay"
+[[barclaycard.wallet]]
+  payment_method_type = "apple_pay"
 [barclaycard.connector_auth.SignatureKey]
 api_key="Key"
 key1="Merchant ID"
 api_secret="Shared Secret"
 
+[[barclaycard.metadata.apple_pay]]
+name="certificate"
+label="Merchant Certificate (Base64 Encoded)"
+placeholder="Enter Merchant Certificate (Base64 Encoded)"
+required=true
+type="Text"
+[[barclaycard.metadata.apple_pay]]
+name="certificate_keys"
+label="Merchant PrivateKey (Base64 Encoded)"
+placeholder="Enter Merchant PrivateKey (Base64 Encoded)"
+required=true
+type="Text"
+[[barclaycard.metadata.apple_pay]]
+name="merchant_identifier"
+label="Apple Merchant Identifier"
+placeholder="Enter Apple Merchant Identifier"
+required=true
+type="Text"
+[[barclaycard.metadata.apple_pay]]
+name="display_name"
+label="Display Name"
+placeholder="Enter Display Name"
+required=true
+type="Text"
+[[barclaycard.metadata.apple_pay]]
+name="initiative"
+label="Domain"
+placeholder="Enter Domain"
+required=true
+type="Select"
+options=["web","ios"]
+[[barclaycard.metadata.apple_pay]]
+name="initiative_context"
+label="Domain Name"
+placeholder="Enter Domain Name"
+required=true
+type="Text"
+[[barclaycard.metadata.apple_pay]]
+name="merchant_business_country"
+label="Merchant Business Country"
+placeholder="Enter Merchant Business Country"
+required=true
+type="Select"
+options=[]
+[[barclaycard.metadata.apple_pay]]
+name="payment_processing_details_at"
+label="Payment Processing Details At"
+placeholder="Enter Payment Processing Details At"
+required=true
+type="Radio"
+options=["Connector","Hyperswitch"]
+
 [[barclaycard.metadata.google_pay]]
 name = "merchant_name"
 label = "Google Pay Merchant Name"
diff --git a/crates/connector_configs/toml/production.toml b/crates/connector_configs/toml/production.toml
index 21c9f20fedc..61e58a1cc32 100644
--- a/crates/connector_configs/toml/production.toml
+++ b/crates/connector_configs/toml/production.toml
@@ -1032,11 +1032,65 @@ payment_method_type = "CartesBancaires"
 payment_method_type = "UnionPay"
 [[barclaycard.wallet]]
   payment_method_type = "google_pay"
+[[barclaycard.wallet]]
+  payment_method_type = "apple_pay"
 [barclaycard.connector_auth.SignatureKey]
 api_key = "Key"
 key1 = "Merchant ID"
 api_secret = "Shared Secret"
 
+[[barclaycard.metadata.apple_pay]]
+name="certificate"
+label="Merchant Certificate (Base64 Encoded)"
+placeholder="Enter Merchant Certificate (Base64 Encoded)"
+required=true
+type="Text"
+[[barclaycard.metadata.apple_pay]]
+name="certificate_keys"
+label="Merchant PrivateKey (Base64 Encoded)"
+placeholder="Enter Merchant PrivateKey (Base64 Encoded)"
+required=true
+type="Text"
+[[barclaycard.metadata.apple_pay]]
+name="merchant_identifier"
+label="Apple Merchant Identifier"
+placeholder="Enter Apple Merchant Identifier"
+required=true
+type="Text"
+[[barclaycard.metadata.apple_pay]]
+name="display_name"
+label="Display Name"
+placeholder="Enter Display Name"
+required=true
+type="Text"
+[[barclaycard.metadata.apple_pay]]
+name="initiative"
+label="Domain"
+placeholder="Enter Domain"
+required=true
+type="Select"
+options=["web","ios"]
+[[barclaycard.metadata.apple_pay]]
+name="initiative_context"
+label="Domain Name"
+placeholder="Enter Domain Name"
+required=true
+type="Text"
+[[barclaycard.metadata.apple_pay]]
+name="merchant_business_country"
+label="Merchant Business Country"
+placeholder="Enter Merchant Business Country"
+required=true
+type="Select"
+options=[]
+[[barclaycard.metadata.apple_pay]]
+name="payment_processing_details_at"
+label="Payment Processing Details At"
+placeholder="Enter Payment Processing Details At"
+required=true
+type="Radio"
+options=["Connector","Hyperswitch"]
+
 [[barclaycard.metadata.google_pay]]
 name = "merchant_name"
 label = "Google Pay Merchant Name"
diff --git a/crates/connector_configs/toml/sandbox.toml b/crates/connector_configs/toml/sandbox.toml
index 597c3fb7276..217203879d4 100644
--- a/crates/connector_configs/toml/sandbox.toml
+++ b/crates/connector_configs/toml/sandbox.toml
@@ -1028,11 +1028,65 @@ payment_method_type = "CartesBancaires"
 payment_method_type = "UnionPay"
 [[barclaycard.wallet]]
   payment_method_type = "google_pay"
+[[barclaycard.wallet]]
+  payment_method_type = "apple_pay"
 [barclaycard.connector_auth.SignatureKey]
 api_key = "Key"
 key1 = "Merchant ID"
 api_secret = "Shared Secret"
 
+[[barclaycard.metadata.apple_pay]]
+name="certificate"
+label="Merchant Certificate (Base64 Encoded)"
+placeholder="Enter Merchant Certificate (Base64 Encoded)"
+required=true
+type="Text"
+[[barclaycard.metadata.apple_pay]]
+name="certificate_keys"
+label="Merchant PrivateKey (Base64 Encoded)"
+placeholder="Enter Merchant PrivateKey (Base64 Encoded)"
+required=true
+type="Text"
+[[barclaycard.metadata.apple_pay]]
+name="merchant_identifier"
+label="Apple Merchant Identifier"
+placeholder="Enter Apple Merchant Identifier"
+required=true
+type="Text"
+[[barclaycard.metadata.apple_pay]]
+name="display_name"
+label="Display Name"
+placeholder="Enter Display Name"
+required=true
+type="Text"
+[[barclaycard.metadata.apple_pay]]
+name="initiative"
+label="Domain"
+placeholder="Enter Domain"
+required=true
+type="Select"
+options=["web","ios"]
+[[barclaycard.metadata.apple_pay]]
+name="initiative_context"
+label="Domain Name"
+placeholder="Enter Domain Name"
+required=true
+type="Text"
+[[barclaycard.metadata.apple_pay]]
+name="merchant_business_country"
+label="Merchant Business Country"
+placeholder="Enter Merchant Business Country"
+required=true
+type="Select"
+options=[]
+[[barclaycard.metadata.apple_pay]]
+name="payment_processing_details_at"
+label="Payment Processing Details At"
+placeholder="Enter Payment Processing Details At"
+required=true
+type="Radio"
+options=["Connector","Hyperswitch"]
+
 [[barclaycard.metadata.google_pay]]
 name = "merchant_name"
 label = "Google Pay Merchant Name"
diff --git a/crates/hyperswitch_connectors/src/connectors/barclaycard.rs b/crates/hyperswitch_connectors/src/connectors/barclaycard.rs
index 98843a068f4..7a1e09a24f2 100644
--- a/crates/hyperswitch_connectors/src/connectors/barclaycard.rs
+++ b/crates/hyperswitch_connectors/src/connectors/barclaycard.rs
@@ -1315,6 +1315,17 @@ static BARCLAYCARD_SUPPORTED_PAYMENT_METHODS: LazyLock<SupportedPaymentMethods>
         barclaycard_supported_payment_methods.add(
             enums::PaymentMethod::Wallet,
             enums::PaymentMethodType::GooglePay,
+            PaymentMethodDetails {
+                mandates: enums::FeatureStatus::NotSupported,
+                refunds: enums::FeatureStatus::Supported,
+                supported_capture_methods: supported_capture_methods.clone(),
+                specific_features: None,
+            },
+        );
+
+        barclaycard_supported_payment_methods.add(
+            enums::PaymentMethod::Wallet,
+            enums::PaymentMethodType::ApplePay,
             PaymentMethodDetails {
                 mandates: enums::FeatureStatus::NotSupported,
                 refunds: enums::FeatureStatus::Supported,
diff --git a/crates/hyperswitch_connectors/src/connectors/barclaycard/transformers.rs b/crates/hyperswitch_connectors/src/connectors/barclaycard/transformers.rs
index 9d78d9de9a4..6be869fa217 100644
--- a/crates/hyperswitch_connectors/src/connectors/barclaycard/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/barclaycard/transformers.rs
@@ -1,5 +1,6 @@
 use base64::Engine;
 use common_enums::enums;
+use common_types::payments::ApplePayPredecryptData;
 use common_utils::{
     consts, date_time,
     ext_traits::ValueExt,
@@ -8,10 +9,10 @@ use common_utils::{
 };
 use error_stack::ResultExt;
 use hyperswitch_domain_models::{
-    payment_method_data::{GooglePayWalletData, PaymentMethodData, WalletData},
+    payment_method_data::{ApplePayWalletData, GooglePayWalletData, PaymentMethodData, WalletData},
     router_data::{
         AdditionalPaymentMethodConnectorResponse, ConnectorAuthType, ConnectorResponseData,
-        ErrorResponse, RouterData,
+        ErrorResponse, PaymentMethodToken, RouterData,
     },
     router_flow_types::refunds::{Execute, RSync},
     router_request_types::{
@@ -33,6 +34,7 @@ use serde_json::Value;
 use crate::{
     constants,
     types::{RefundsResponseRouterData, ResponseRouterData},
+    unimplemented_payment_method,
     utils::{
         self, AddressDetailsData, CardData, PaymentsAuthorizeRequestData,
         PaymentsCompleteAuthorizeRequestData, PaymentsPreProcessingRequestData,
@@ -179,11 +181,44 @@ pub struct GooglePayPaymentInformation {
     fluid_data: FluidData,
 }
 
+#[derive(Debug, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct TokenizedCard {
+    number: cards::CardNumber,
+    expiration_month: Secret<String>,
+    expiration_year: Secret<String>,
+    cryptogram: Option<Secret<String>>,
+    transaction_type: TransactionType,
+}
+
+#[derive(Debug, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct ApplePayTokenizedCard {
+    transaction_type: TransactionType,
+}
+
+#[derive(Debug, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct ApplePayTokenPaymentInformation {
+    fluid_data: FluidData,
+    tokenized_card: ApplePayTokenizedCard,
+}
+
+#[derive(Debug, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct ApplePayPaymentInformation {
+    tokenized_card: TokenizedCard,
+}
+
+pub const FLUID_DATA_DESCRIPTOR: &str = "RklEPUNPTU1PTi5BUFBMRS5JTkFQUC5QQVlNRU5U";
+
 #[derive(Debug, Serialize)]
 #[serde(untagged)]
 pub enum PaymentInformation {
     Cards(Box<CardPaymentInformation>),
     GooglePay(Box<GooglePayPaymentInformation>),
+    ApplePay(Box<ApplePayPaymentInformation>),
+    ApplePayToken(Box<ApplePayTokenPaymentInformation>),
 }
 
 #[derive(Debug, Serialize)]
@@ -202,6 +237,8 @@ pub struct Card {
 #[serde(rename_all = "camelCase")]
 pub struct FluidData {
     value: Secret<String>,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    descriptor: Option<String>,
 }
 
 #[derive(Debug, Serialize)]
@@ -289,12 +326,20 @@ fn get_barclaycard_card_type(card_network: common_enums::CardNetwork) -> Option<
 #[derive(Debug, Serialize)]
 pub enum PaymentSolution {
     GooglePay,
+    ApplePay,
+}
+
+#[derive(Debug, Serialize)]
+pub enum TransactionType {
+    #[serde(rename = "1")]
+    InApp,
 }
 
 impl From<PaymentSolution> for String {
     fn from(solution: PaymentSolution) -> Self {
         let payment_solution = match solution {
             PaymentSolution::GooglePay => "012",
+            PaymentSolution::ApplePay => "001",
         };
         payment_solution.to_string()
     }
@@ -338,7 +383,23 @@ impl
             Option<String>,
         ),
     ) -> Result<Self, Self::Error> {
-        let commerce_indicator = get_commerce_indicator(network);
+        let commerce_indicator = solution
+            .as_ref()
+            .map(|pm_solution| match pm_solution {
+                PaymentSolution::ApplePay => network
+                    .as_ref()
+                    .map(|card_network| match card_network.to_lowercase().as_str() {
+                        "amex" => "internet",
+                        "discover" => "internet",
+                        "mastercard" => "spa",
+                        "visa" => "internet",
+                        _ => "internet",
+                    })
+                    .unwrap_or("internet"),
+                PaymentSolution::GooglePay => "internet",
+            })
+            .unwrap_or("internet")
+            .to_string();
         let cavv_algorithm = Some("2".to_string());
         Ok(Self {
             capture: Some(matches!(
@@ -1278,6 +1339,90 @@ impl
     }
 }
 
+impl
+    TryFrom<(
+        &BarclaycardRouterData<&PaymentsAuthorizeRouterData>,
+        Box<ApplePayPredecryptData>,
+        ApplePayWalletData,
+    )> for BarclaycardPaymentsRequest
+{
+    type Error = error_stack::Report<errors::ConnectorError>;
+    fn try_from(
+        (item, apple_pay_data, apple_pay_wallet_data): (
+            &BarclaycardRouterData<&PaymentsAuthorizeRouterData>,
+            Box<ApplePayPredecryptData>,
+            ApplePayWalletData,
+        ),
+    ) -> Result<Self, Self::Error> {
+        let email = item
+            .router_data
+            .get_billing_email()
+            .or(item.router_data.request.get_email())?;
+        let bill_to = build_bill_to(item.router_data.get_billing_address()?, email)?;
+        let order_information = OrderInformationWithBill::from((item, Some(bill_to)));
+        let processing_information =
+            ProcessingInformation::try_from((item, Some(PaymentSolution::ApplePay), None))?;
+        let client_reference_information = ClientReferenceInformation::from(item);
+        let expiration_month = apple_pay_data.get_expiry_month().change_context(
+            errors::ConnectorError::InvalidDataFormat {
+                field_name: "expiration_month",
+            },
+        )?;
+        let expiration_year = apple_pay_data.get_four_digit_expiry_year();
+        let payment_information =
+            PaymentInformation::ApplePay(Box::new(ApplePayPaymentInformation {
+                tokenized_card: TokenizedCard {
+                    number: apple_pay_data.application_primary_account_number,
+                    cryptogram: Some(apple_pay_data.payment_data.online_payment_cryptogram),
+                    transaction_type: TransactionType::InApp,
+                    expiration_year,
+                    expiration_month,
+                },
+            }));
+        let merchant_defined_information = item
+            .router_data
+            .request
+            .metadata
+            .clone()
+            .map(convert_metadata_to_merchant_defined_info);
+        let ucaf_collection_indicator = match apple_pay_wallet_data
+            .payment_method
+            .network
+            .to_lowercase()
+            .as_str()
+        {
+            "mastercard" => Some("2".to_string()),
+            _ => None,
+        };
+        Ok(Self {
+            processing_information,
+            payment_information,
+            order_information,
+            client_reference_information,
+            consumer_authentication_information: Some(BarclaycardConsumerAuthInformation {
+                ucaf_collection_indicator,
+                cavv: None,
+                ucaf_authentication_data: None,
+                xid: None,
+                directory_server_transaction_id: None,
+                specification_version: None,
+                pa_specification_version: None,
+                veres_enrolled: None,
+                eci_raw: None,
+                pares_status: None,
+                authentication_date: None,
+                effective_authentication_type: None,
+                challenge_code: None,
+                pares_status_reason: None,
+                challenge_cancel_code: None,
+                network_score: None,
+                acs_transaction_id: None,
+            }),
+            merchant_defined_information,
+        })
+    }
+}
+
 impl TryFrom<&BarclaycardRouterData<&PaymentsAuthorizeRouterData>> for BarclaycardPaymentsRequest {
     type Error = error_stack::Report<errors::ConnectorError>;
     fn try_from(
@@ -1287,11 +1432,105 @@ impl TryFrom<&BarclaycardRouterData<&PaymentsAuthorizeRouterData>> for Barclayca
             PaymentMethodData::Card(ccard) => Self::try_from((item, ccard)),
             PaymentMethodData::Wallet(wallet_data) => match wallet_data {
                 WalletData::GooglePay(google_pay_data) => Self::try_from((item, google_pay_data)),
+                WalletData::ApplePay(apple_pay_data) => {
+                    match item.router_data.payment_method_token.clone() {
+                        Some(payment_method_token) => match payment_method_token {
+                            PaymentMethodToken::ApplePayDecrypt(decrypt_data) => {
+                                Self::try_from((item, decrypt_data, apple_pay_data))
+                            }
+                            PaymentMethodToken::Token(_) => Err(unimplemented_payment_method!(
+                                "Apple Pay",
+                                "Manual",
+                                "Cybersource"
+                            ))?,
+                            PaymentMethodToken::PazeDecrypt(_) => {
+                                Err(unimplemented_payment_method!("Paze", "Cybersource"))?
+                            }
+                            PaymentMethodToken::GooglePayDecrypt(_) => {
+                                Err(unimplemented_payment_method!("Google Pay", "Cybersource"))?
+                            }
+                        },
+                        None => {
+                            let transaction_type = TransactionType::InApp;
+                            let email = item
+                                .router_data
+                                .get_billing_email()
+                                .or(item.router_data.request.get_email())?;
+                            let bill_to =
+                                build_bill_to(item.router_data.get_billing_address()?, email)?;
+                            let order_information =
+                                OrderInformationWithBill::from((item, Some(bill_to)));
+                            let processing_information = ProcessingInformation::try_from((
+                                item,
+                                Some(PaymentSolution::ApplePay),
+                                Some(apple_pay_data.payment_method.network.clone()),
+                            ))?;
+                            let client_reference_information =
+                                ClientReferenceInformation::from(item);
+
+                            let apple_pay_encrypted_data = apple_pay_data
+                                .payment_data
+                                .get_encrypted_apple_pay_payment_data_mandatory()
+                                .change_context(errors::ConnectorError::MissingRequiredField {
+                                    field_name: "Apple pay encrypted data",
+                                })?;
+                            let payment_information = PaymentInformation::ApplePayToken(Box::new(
+                                ApplePayTokenPaymentInformation {
+                                    fluid_data: FluidData {
+                                        value: Secret::from(apple_pay_encrypted_data.clone()),
+                                        descriptor: Some(FLUID_DATA_DESCRIPTOR.to_string()),
+                                    },
+                                    tokenized_card: ApplePayTokenizedCard { transaction_type },
+                                },
+                            ));
+                            let merchant_defined_information =
+                                item.router_data.request.metadata.clone().map(|metadata| {
+                                    convert_metadata_to_merchant_defined_info(metadata)
+                                });
+                            let ucaf_collection_indicator = match apple_pay_data
+                                .payment_method
+                                .network
+                                .to_lowercase()
+                                .as_str()
+                            {
+                                "mastercard" => Some("2".to_string()),
+                                _ => None,
+                            };
+                            Ok(Self {
+                                processing_information,
+                                payment_information,
+                                order_information,
+                                client_reference_information,
+                                merchant_defined_information,
+                                consumer_authentication_information: Some(
+                                    BarclaycardConsumerAuthInformation {
+                                        ucaf_collection_indicator,
+                                        cavv: None,
+                                        ucaf_authentication_data: None,
+                                        xid: None,
+                                        directory_server_transaction_id: None,
+                                        specification_version: None,
+                                        pa_specification_version: None,
+                                        veres_enrolled: None,
+                                        eci_raw: None,
+                                        pares_status: None,
+                                        authentication_date: None,
+                                        effective_authentication_type: None,
+                                        challenge_code: None,
+                                        pares_status_reason: None,
+                                        challenge_cancel_code: None,
+                                        network_score: None,
+                                        acs_transaction_id: None,
+                                    },
+                                ),
+                            })
+                        }
+                    }
+                }
                 WalletData::AliPayQr(_)
                 | WalletData::AliPayRedirect(_)
                 | WalletData::AliPayHkRedirect(_)
                 | WalletData::AmazonPayRedirect(_)
-                | WalletData::ApplePay(_)
                 | WalletData::MomoRedirect(_)
                 | WalletData::KakaoPayRedirect(_)
                 | WalletData::GoPayRedirect(_)
@@ -2671,6 +2910,7 @@ impl TryFrom<&GooglePayWalletData> for PaymentInformation {
                             .clone(),
                     ),
                 ),
+                descriptor: None,
             },
         })))
     }

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

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

Closes this [issue](https://github.com/juspay/hyperswitch/issues/8884)

## Description
<!-- Describe your changes in detail -->

Added Apple Pay Flow for Barclaycard

### 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)?
-->

Postman Test

<details>

<summary>Hyperswitch Decryption Flow </summary>

1. Payment Connector - Create

Request:

```
curl --location 'http://localhost:8080/account/merchant_1755085109/connectors' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_taZoWveMbydxSkllyD5IB1sPHXNYOLLR2iveHgisLDodWCnHUkaXOF5k8RS8jMFC' \
--data '{
    "connector_type": "payment_processor",
    "connector_name": "barclaycard",
    "connector_account_details": {
        "auth_type":"SignatureKey",
        "api_secret": API_SECRET
        "api_key": API_KEY,
        "key1": KEY1
    },
    "test_mode": true,
    "disabled": false,
    "payment_methods_enabled": [
        {
            "payment_method": "wallet",
            "payment_method_types": [
                {
                    "payment_method_type": "apple_pay",
                    "payment_experience": "invoke_sdk_client",
                    "card_networks": null,
                    "accepted_currencies": null,
                    "accepted_countries": null,
                    "minimum_amount": 0,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": false
                }
            ]
        }
    ],
     "metadata": {
        "apple_pay_combined": {
            "manual": {
                "session_token_data": {
                    "initiative": "web",
                    "certificate": CERTIFICATE,
                    "display_name": "Applepay",
                    "certificate_keys": CERTIFICATE_KEYS,
                    "initiative_context": INITIATIVE_CONTEXT,
                    "merchant_identifier": MERCHANT_IDENTIFIER
                    "merchant_business_country": "US",
                    "payment_processing_details_at": "Hyperswitch",
                    "payment_processing_certificate": PAYMENT_PROCESSING_CERTIFICATE,
                    "payment_processing_certificate_key": PAYMENT_PROCESSING_CERTIFICATE_KEY,
                },
                "payment_request_data": {
                    "label": "Applepay",
                    "supported_networks": [
                        "visa",
                        "masterCard",
                        "amex",
                        "discover"
                    ],
                    "merchant_capabilities": [
                        "supports3DS"
                    ]
                }
            }
        }
    },
    "business_country": "US",
    "business_label": "default"
}'
```

Response:

```
{
    "connector_type": "payment_processor",
    "connector_name": "barclaycard",
    "connector_label": "barclaycard_US_default",
    "merchant_connector_id": "mca_eS9yhJMxUdKy4eZJ1Ea1",
    "profile_id": "pro_v4sNqtQqIhqC7zNvjBna",
    "connector_account_details": {
        "auth_type": "SignatureKey",
        "api_key": API_KEY,
        "key1": KEY1,
        "api_secret": API_SECRET
    },
    "payment_methods_enabled": [
        {
            "payment_method": "wallet",
            "payment_method_types": [
                {
                    "payment_method_type": "apple_pay",
                    "payment_experience": "invoke_sdk_client",
                    "card_networks": null,
                    "accepted_currencies": null,
                    "accepted_countries": null,
                    "minimum_amount": 0,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": false
                }
            ]
        }
    ],
    "connector_webhook_details": null,
    "metadata": {
        "apple_pay_combined": {
            "manual": {
                "session_token_data": {
                    "initiative": "web",
                    "certificate": CERTIFICATE,
                    "display_name": "Applepay",
                    "certificate_keys": CERTIFICATE_KEYS,
                    "initiative_context": INITIATIVE_CONTEXT,
                    "merchant_identifier": MERCHANT_IDENTIFIER,
                    "merchant_business_country": "US",
                    "payment_processing_details_at": "Hyperswitch",
                    "payment_processing_certificate": PAYMENT_PROCESSING_CERTIFICATE,
                    "payment_processing_certificate_key": PAYMENT_PROCESSING_CERTIFICATE_KEY
                },
                "payment_request_data": {
                    "label": "Applepay",
                    "supported_networks": [
                        "visa",
                        "masterCard",
                        "amex",
                        "discover"
                    ],
                    "merchant_capabilities": [
                        "supports3DS"
                    ]
                }
            }
        }
    },
    "test_mode": true,
    "disabled": false,
    "frm_configs": null,
    "business_country": "US",
    "business_label": "default",
    "business_sub_label": null,
    "applepay_verified_domains": null,
    "pm_auth_config": null,
    "status": "active",
    "additional_merchant_data": null,
    "connector_wallets_details": {
        "apple_pay_combined": {
            "manual": {
                "payment_request_data": {
                    "supported_networks": [
                        "visa",
                        "masterCard",
                        "amex",
                        "discover"
                    ],
                    "merchant_capabilities": [
                        "supports3DS"
                    ],
                    "label": "Applepay"
                },
                "session_token_data": {
                    "certificate": CERTIFICATE,
                    "certificate_keys": CERTIFICATE_KEYS,
                    "merchant_identifier": MERCHANT_IDENTIFIER,
                    "display_name": "Applepay",
                    "initiative": "web",
                    "initiative_context": INITIATIVE_CONTEXT,
                    "merchant_business_country": "US",
                    "payment_processing_details_at": "Hyperswitch",
                    "payment_processing_certificate": PAYMENT_PROCESSING_CERTIFICATE,
                    "payment_processing_certificate_key": PAYMENT_PROCESSING_CERTIFICATE_KEY
                }
            }
        }
    }
}
```

2. Payments - Create

Request:

```
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_taZoWveMbydxSkllyD5IB1sPHXNYOLLR2iveHgisLDodWCnHUkaXOF5k8RS8jMFC' \
--data-raw '{
    "amount": 650,
    "currency": "USD",
    "confirm": true,
    "business_country": "US",
    "business_label": "default",
    "amount_to_capture": 650,
    "customer_id": "cu_1752502119",
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "setup_future_usage": "off_session",
    "authentication_type": "no_three_ds",
    "return_url": "https://google.com",
    "email": "something@gmail.com",
    "name": "Joseph Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment request",
    "statement_descriptor_name": "Juspay",
    "statement_descriptor_suffix": "Router",
    "billing": {
        "address": {
            "line1": "1467",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": NUMBER
            "country_code": "+91"
        }
    },
    "customer_acceptance": {
        "acceptance_type": "offline",
        "accepted_at": "1963-05-03T04:07:52.723Z",
        "online": {
            "ip_address": "in sit",
            "user_agent": "amet irure esse"
        }
    },
    "payment_method": "wallet",
    "payment_method_type": "apple_pay",
    "payment_method_data": {
        "wallet": {
            "apple_pay": {
                "payment_data": PAYMENT_DATA,
                    "display_name": "MasterCard 0049",
                    "network": "MasterCard",
                    "type": "credit"
                },
                "transaction_identifier": TRANSACTION_IDENTIFIER
            }
        }
    },
    "shipping": {
        "phone": {
            "number": "4081234567"
        },
        "email": EMAIL
    }
}'
```

Response:

```
{
    "payment_id": "pay_ytnuQR2VsUo0pTAPUlvy",
    "merchant_id": "merchant_1755085109",
    "status": "succeeded",
    "amount": 650,
    "net_amount": 650,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 650,
    "connector": "barclaycard",
    "client_secret": "pay_ytnuQR2VsUo0pTAPUlvy_secret_pdWZPEULnUSv9XOzVUaF",
    "created": "2025-08-13T11:38:39.949Z",
    "currency": "USD",
    "customer_id": "cu_1752502119",
    "customer": {
        "id": "cu_1752502119",
        "name": "Joseph Doe",
        "email": "something@gmail.com",
        "phone": "999999999",
        "phone_country_code": "+65"
    },
    "description": "Its my first payment request",
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": "on_session",
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "wallet",
    "payment_method_data": {
        "wallet": {
            "apple_pay": {
                "last4": "0049",
                "card_network": "MasterCard",
                "type": "credit"
            }
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": {
        "address": null,
        "phone": {
            "number": "4081234567",
            "country_code": null
        },
        "email": EMAIL
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": null,
            "line3": null,
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe",
            "origin_zip": null
        },
        "phone": {
            "number": NUMBER,
            "country_code": "+91"
        },
        "email": null
    },
    "order_details": null,
    "email": "something@gmail.com",
    "name": "Joseph Doe",
    "phone": "999999999",
    "return_url": "https://google.com/",
    "authentication_type": "no_three_ds",
    "statement_descriptor_name": "Juspay",
    "statement_descriptor_suffix": "Router",
    "next_action": null,
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "payment_experience": null,
    "payment_method_type": "apple_pay",
    "connector_label": "barclaycard_US_default",
    "business_country": "US",
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "cu_1752502119",
        "created_at": 1755085119,
        "expires": 1755088719,
        "secret": "SECRET
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "7550851222606001203813",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pay_ytnuQR2VsUo0pTAPUlvy_1",
    "payment_link": null,
    "profile_id": "pro_v4sNqtQqIhqC7zNvjBna",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_eS9yhJMxUdKy4eZJ1Ea1",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-08-13T11:53:39.949Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_channel": null,
    "payment_method_id": null,
    "network_transaction_id": null,
    "payment_method_status": null,
    "updated": "2025-08-13T11:38:43.164Z",
    "split_payments": null,
    "frm_metadata": null,
    "extended_authorization_applied": null,
    "capture_before": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null,
    "card_discovery": null,
    "force_3ds_challenge": false,
    "force_3ds_challenge_trigger": false,
    "issuer_error_code": null,
    "issuer_error_message": null,
    "is_iframe_redirection_enabled": null,
    "whole_connector_response": null,
    "enable_partial_authorization": null
}
```
</details>


<details>

<summary>Connector Decryption Flow </summary>

1. Payment Connector - Create

Request:

```
curl --location 'http://localhost:8080/account/merchant_1757312693/connectors' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_tO4QhL39rQMDHYzzbfwpngxQRd7PfKBjb3H9h0ngxbMUeLjNovXFBbIRDfRhBkKk' \
--data '{
    "connector_type": "payment_processor",
    "connector_name": "barclaycard",
    "connector_account_details": {
        "auth_type": "SignatureKey",
        "api_secret": API_SECRET,
        "api_key": API_KEY,
        "key1": KEY1
    },
    "test_mode": true,
    "disabled": false,
    "payment_methods_enabled": [
        {
            "payment_method": "wallet",
            "payment_method_types": [
                {
                    "payment_method_type": "apple_pay",
                    "payment_experience": "invoke_sdk_client",
                    "minimum_amount": 0,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": false
                }
            ]
        }
    ],
    "metadata": {
        "apple_pay_combined": {
            "manual": {
                "session_token_data": {
                    "initiative": "ios",
                    "certificate": CERTIFICATE,
                    "display_name": "Barclaycard via Hyperswitch",
                    "certificate_keys": CERTIFICATE_KEYS,
                    "merchant_identifier": MERCHANT_IDENTIFIER,
                    "merchant_business_country": MERCHANT_BUSINESS_COUNTRY,
                    "payment_processing_details_at": "Connector"
                },
                "payment_request_data": {
                    "label": "Cybersource via Hyperswitch",
                    "supported_networks": [
                        "visa",
                        "masterCard",
                        "amex",
                        "discover"
                    ],
                    "merchant_capabilities": [
                        "supports3DS"
                    ]
                }
            }
        }
    },
    "connector_webhook_details": {
        "merchant_secret": "MyWebhookSecret"
    },
    "business_country": "US",
    "business_label": "default"
}'
```

Response:

```
{
    "connector_type": "payment_processor",
    "connector_name": "barclaycard",
    "connector_label": "barclaycard_US_default",
    "merchant_connector_id": "mca_dQAvxu5nKalC1YM9Nh4c",
    "profile_id": "pro_PbbZjjifqFiYwIXrlBjq",
    "connector_account_details": {
        "auth_type": "SignatureKey",
        "api_key": API_KEY,
        "key1": KEY1,
        "api_secret": API_SECRET
    },
    "payment_methods_enabled": [
        {
            "payment_method": "wallet",
            "payment_method_types": [
                {
                    "payment_method_type": "apple_pay",
                    "payment_experience": "invoke_sdk_client",
                    "card_networks": null,
                    "accepted_currencies": null,
                    "accepted_countries": null,
                    "minimum_amount": 0,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": false
                }
            ]
        }
    ],
    "connector_webhook_details": {
        "merchant_secret": "MyWebhookSecret",
        "additional_secret": null
    },
    "metadata": {
        "apple_pay_combined": {
            "manual": {
                "session_token_data": {
                    "initiative": "ios",
                    "certificate": CERTIFICATE,
                    "display_name": "Barclaycard via Hyperswitch",
                    "certificate_keys": CERTIFICATE_KEYS,
                    "merchant_identifier": MERCHANT_IDENTIFIER,
                    "merchant_business_country": MERCHANT_BUSINESS_COUNTRY,
                    "payment_processing_details_at": "Connector"
                },
                "payment_request_data": {
                    "label": "Barclaycard via Hyperswitch",
                    "supported_networks": [
                        "visa",
                        "masterCard",
                        "amex",
                        "discover"
                    ],
                    "merchant_capabilities": [
                        "supports3DS"
                    ]
                }
            }
        }
    },
    "test_mode": true,
    "disabled": false,
    "frm_configs": null,
    "business_country": "US",
    "business_label": "default",
    "business_sub_label": null,
    "applepay_verified_domains": null,
    "pm_auth_config": null,
    "status": "active",
    "additional_merchant_data": null,
    "connector_wallets_details": {
        "apple_pay_combined": {
            "manual": {
                "payment_request_data": {
                    "supported_networks": [
                        "visa",
                        "masterCard",
                        "amex",
                        "discover"
                    ],
                    "merchant_capabilities": [
                        "supports3DS"
                    ],
                    "label": "Barclaycard via Hyperswitch"
                },
                "session_token_data": {
                    "certificate": CERTIFICATE,
                    "certificate_keys": CERTIFICATE_KEYS,
                    "merchant_identifier": MERCHANT_IDENTIFIER,
                    "display_name": MERCHANT_BUSINESS_COUNTRY,
                    "initiative": "ios",
                    "initiative_context": null,
                    "merchant_business_country": MERCHANT_BUSINESS_COUNTRY,
                    "payment_processing_details_at": "Connector"
                }
            }
        }
    }
}
```

2. Payments - Create

Request:

```
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_tO4QhL39rQMDHYzzbfwpngxQRd7PfKBjb3H9h0ngxbMUeLjNovXFBbIRDfRhBkKk' \
--data-raw '{
    "amount": 2229,
    "currency": "USD",
    "confirm": true,
    "customer_id": "gmail",
    "email": "email@email.com",
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": "guest@example.com"
    },
    "payment_method_data": {
        "wallet": {
            "apple_pay": {
                "payment_data": PAYMENT_DATA,
                "payment_method": {
                    "display_name": "MasterCard 0049",
                    "network": "MasterCard",
                    "type": "credit"
                },
                "transaction_identifier": TRANSACTION_IDENTIFIER
            }
        }
    },
    "payment_method": "wallet",
    "payment_method_type": "apple_pay"
}'
```

Response:

```
{
    "payment_id": "pay_PGO6Zpfp4QqUUVrcV69m",
    "merchant_id": "merchant_1757312693",
    "status": "succeeded",
    "amount": 2229,
    "net_amount": 2229,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 2229,
    "connector": "barclaycard",
    "client_secret": "pay_PGO6Zpfp4QqUUVrcV69m_secret_4NqlDHVTMiECtyKhMRgN",
    "created": "2025-09-08T06:25:44.739Z",
    "currency": "USD",
    "customer_id": "gmail",
    "customer": {
        "id": "gmail",
        "name": null,
        "email": "email@email.com",
        "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": null,
    "payment_method": "wallet",
    "payment_method_data": {
        "wallet": {
            "apple_pay": {
                "last4": "0049",
                "card_network": "MasterCard",
                "type": "credit"
            }
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": null,
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe",
            "origin_zip": null
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": "guest@example.com"
    },
    "order_details": null,
    "email": "email@email.com",
    "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": "apple_pay",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "gmail",
        "created_at": 1757312744,
        "expires": 1757316344,
        "secret": "epk_972bbb09245349088a4f2eb20ffb472e"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "7573127477466909504807",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": {
        "redirect_response": null,
        "search_tags": null,
        "apple_pay_recurring_details": null,
        "gateway_system": "direct"
    },
    "reference_id": "pay_PGO6Zpfp4QqUUVrcV69m_1",
    "payment_link": null,
    "profile_id": "pro_PbbZjjifqFiYwIXrlBjq",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_dQAvxu5nKalC1YM9Nh4c",
    "incremental_authorization_allowed": false,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-09-08T06:40:44.739Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_channel": null,
    "payment_method_id": null,
    "network_transaction_id": null,
    "payment_method_status": null,
    "updated": "2025-09-08T06:25:48.784Z",
    "split_payments": null,
    "frm_metadata": null,
    "extended_authorization_applied": null,
    "capture_before": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null,
    "card_discovery": null,
    "force_3ds_challenge": false,
    "force_3ds_challenge_trigger": false,
    "issuer_error_code": null,
    "issuer_error_message": null,
    "is_iframe_redirection_enabled": null,
    "whole_connector_response": null,
    "enable_partial_authorization": null
}
```

</details>

## 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



Postman Test

<details>

<summary>Hyperswitch Decryption Flow </summary>

1. Payment Connector - Create

Request:

```
curl --location 'http://localhost:8080/account/merchant_1755085109/connectors' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_taZoWveMbydxSkllyD5IB1sPHXNYOLLR2iveHgisLDodWCnHUkaXOF5k8RS8jMFC' \
--data '{
    "connector_type": "payment_processor",
    "connector_name": "barclaycard",
    "connector_account_details": {
        "auth_type":"SignatureKey",
        "api_secret": API_SECRET
        "api_key": API_KEY,
        "key1": KEY1
    },
    "test_mode": true,
    "disabled": false,
    "payment_methods_enabled": [
        {
            "payment_method": "wallet",
            "payment_method_types": [
                {
                    "payment_method_type": "apple_pay",
                    "payment_experience": "invoke_sdk_client",
                    "card_networks": null,
                    "accepted_currencies": null,
                    "accepted_countries": null,
                    "minimum_amount": 0,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": false
                }
            ]
        }
    ],
     "metadata": {
        "apple_pay_combined": {
            "manual": {
                "session_token_data": {
                    "initiative": "web",
                    "certificate": CERTIFICATE,
                    "display_name": "Applepay",
                    "certificate_keys": CERTIFICATE_KEYS,
                    "initiative_context": INITIATIVE_CONTEXT,
                    "merchant_identifier": MERCHANT_IDENTIFIER
                    "merchant_business_country": "US",
                    "payment_processing_details_at": "Hyperswitch",
                    "payment_processing_certificate": PAYMENT_PROCESSING_CERTIFICATE,
                    "payment_processing_certificate_key": PAYMENT_PROCESSING_CERTIFICATE_KEY,
                },
                "payment_request_data": {
                    "label": "Applepay",
                    "supported_networks": [
                        "visa",
                        "masterCard",
                        "amex",
                        "discover"
                    ],
                    "merchant_capabilities": [
                        "supports3DS"
                    ]
                }
            }
        }
    },
    "business_country": "US",
    "business_label": "default"
}'
```

Response:

```
{
    "connector_type": "payment_processor",
    "connector_name": "barclaycard",
    "connector_label": "barclaycard_US_default",
    "merchant_connector_id": "mca_eS9yhJMxUdKy4eZJ1Ea1",
    "profile_id": "pro_v4sNqtQqIhqC7zNvjBna",
    "connector_account_details": {
        "auth_type": "SignatureKey",
        "api_key": API_KEY,
        "key1": KEY1,
        "api_secret": API_SECRET
    },
    "payment_methods_enabled": [
        {
            "payment_method": "wallet",
            "payment_method_types": [
                {
                    "payment_method_type": "apple_pay",
                    "payment_experience": "invoke_sdk_client",
                    "card_networks": null,
                    "accepted_currencies": null,
                    "accepted_countries": null,
                    "minimum_amount": 0,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": false
                }
            ]
        }
    ],
    "connector_webhook_details": null,
    "metadata": {
        "apple_pay_combined": {
            "manual": {
                "session_token_data": {
                    "initiative": "web",
                    "certificate": CERTIFICATE,
                    "display_name": "Applepay",
                    "certificate_keys": CERTIFICATE_KEYS,
                    "initiative_context": INITIATIVE_CONTEXT,
                    "merchant_identifier": MERCHANT_IDENTIFIER,
                    "merchant_business_country": "US",
                    "payment_processing_details_at": "Hyperswitch",
                    "payment_processing_certificate": PAYMENT_PROCESSING_CERTIFICATE,
                    "payment_processing_certificate_key": PAYMENT_PROCESSING_CERTIFICATE_KEY
                },
                "payment_request_data": {
                    "label": "Applepay",
                    "supported_networks": [
                        "visa",
                        "masterCard",
                        "amex",
                        "discover"
                    ],
                    "merchant_capabilities": [
                        "supports3DS"
                    ]
                }
            }
        }
    },
    "test_mode": true,
    "disabled": false,
    "frm_configs": null,
    "business_country": "US",
    "business_label": "default",
    "business_sub_label": null,
    "applepay_verified_domains": null,
    "pm_auth_config": null,
    "status": "active",
    "additional_merchant_data": null,
    "connector_wallets_details": {
        "apple_pay_combined": {
            "manual": {
                "payment_request_data": {
                    "supported_networks": [
                        "visa",
                        "masterCard",
                        "amex",
                        "discover"
                    ],
                    "merchant_capabilities": [
                        "supports3DS"
                    ],
                    "label": "Applepay"
                },
                "session_token_data": {
                    "certificate": CERTIFICATE,
                    "certificate_keys": CERTIFICATE_KEYS,
                    "merchant_identifier": MERCHANT_IDENTIFIER,
                    "display_name": "Applepay",
                    "initiative": "web",
                    "initiative_context": INITIATIVE_CONTEXT,
                    "merchant_business_country": "US",
                    "payment_processing_details_at": "Hyperswitch",
                    "payment_processing_certificate": PAYMENT_PROCESSING_CERTIFICATE,
                    "payment_processing_certificate_key": PAYMENT_PROCESSING_CERTIFICATE_KEY
                }
            }
        }
    }
}
```

2. Payments - Create

Request:

```
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_taZoWveMbydxSkllyD5IB1sPHXNYOLLR2iveHgisLDodWCnHUkaXOF5k8RS8jMFC' \
--data-raw '{
    "amount": 650,
    "currency": "USD",
    "confirm": true,
    "business_country": "US",
    "business_label": "default",
    "amount_to_capture": 650,
    "customer_id": "cu_1752502119",
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "setup_future_usage": "off_session",
    "authentication_type": "no_three_ds",
    "return_url": "https://google.com",
    "email": "something@gmail.com",
    "name": "Joseph Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment request",
    "statement_descriptor_name": "Juspay",
    "statement_descriptor_suffix": "Router",
    "billing": {
        "address": {
            "line1": "1467",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": NUMBER
            "country_code": "+91"
        }
    },
    "customer_acceptance": {
        "acceptance_type": "offline",
        "accepted_at": "1963-05-03T04:07:52.723Z",
        "online": {
            "ip_address": "in sit",
            "user_agent": "amet irure esse"
        }
    },
    "payment_method": "wallet",
    "payment_method_type": "apple_pay",
    "payment_method_data": {
        "wallet": {
            "apple_pay": {
                "payment_data": PAYMENT_DATA,
                    "display_name": "MasterCard 0049",
                    "network": "MasterCard",
                    "type": "credit"
                },
                "transaction_identifier": TRANSACTION_IDENTIFIER
            }
        }
    },
    "shipping": {
        "phone": {
            "number": "4081234567"
        },
        "email": EMAIL
    }
}'
```

Response:

```
{
    "payment_id": "pay_ytnuQR2VsUo0pTAPUlvy",
    "merchant_id": "merchant_1755085109",
    "status": "succeeded",
    "amount": 650,
    "net_amount": 650,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 650,
    "connector": "barclaycard",
    "client_secret": "pay_ytnuQR2VsUo0pTAPUlvy_secret_pdWZPEULnUSv9XOzVUaF",
    "created": "2025-08-13T11:38:39.949Z",
    "currency": "USD",
    "customer_id": "cu_1752502119",
    "customer": {
        "id": "cu_1752502119",
        "name": "Joseph Doe",
        "email": "something@gmail.com",
        "phone": "999999999",
        "phone_country_code": "+65"
    },
    "description": "Its my first payment request",
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": "on_session",
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "wallet",
    "payment_method_data": {
        "wallet": {
            "apple_pay": {
                "last4": "0049",
                "card_network": "MasterCard",
                "type": "credit"
            }
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": {
        "address": null,
        "phone": {
            "number": "4081234567",
            "country_code": null
        },
        "email": EMAIL
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": null,
            "line3": null,
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe",
            "origin_zip": null
        },
        "phone": {
            "number": NUMBER,
            "country_code": "+91"
        },
        "email": null
    },
    "order_details": null,
    "email": "something@gmail.com",
    "name": "Joseph Doe",
    "phone": "999999999",
    "return_url": "https://google.com/",
    "authentication_type": "no_three_ds",
    "statement_descriptor_name": "Juspay",
    "statement_descriptor_suffix": "Router",
    "next_action": null,
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "payment_experience": null,
    "payment_method_type": "apple_pay",
    "connector_label": "barclaycard_US_default",
    "business_country": "US",
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "cu_1752502119",
        "created_at": 1755085119,
        "expires": 1755088719,
        "secret": "SECRET
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "7550851222606001203813",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pay_ytnuQR2VsUo0pTAPUlvy_1",
    "payment_link": null,
    "profile_id": "pro_v4sNqtQqIhqC7zNvjBna",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_eS9yhJMxUdKy4eZJ1Ea1",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-08-13T11:53:39.949Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_channel": null,
    "payment_method_id": null,
    "network_transaction_id": null,
    "payment_method_status": null,
    "updated": "2025-08-13T11:38:43.164Z",
    "split_payments": null,
    "frm_metadata": null,
    "extended_authorization_applied": null,
    "capture_before": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null,
    "card_discovery": null,
    "force_3ds_challenge": false,
    "force_3ds_challenge_trigger": false,
    "issuer_error_code": null,
    "issuer_error_message": null,
    "is_iframe_redirection_enabled": null,
    "whole_connector_response": null,
    "enable_partial_authorization": null
}
```
</details>


<details>

<summary>Connector Decryption Flow </summary>

1. Payment Connector - Create

Request:

```
curl --location 'http://localhost:8080/account/merchant_1757312693/connectors' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_tO4QhL39rQMDHYzzbfwpngxQRd7PfKBjb3H9h0ngxbMUeLjNovXFBbIRDfRhBkKk' \
--data '{
    "connector_type": "payment_processor",
    "connector_name": "barclaycard",
    "connector_account_details": {
        "auth_type": "SignatureKey",
        "api_secret": API_SECRET,
        "api_key": API_KEY,
        "key1": KEY1
    },
    "test_mode": true,
    "disabled": false,
    "payment_methods_enabled": [
        {
            "payment_method": "wallet",
            "payment_method_types": [
                {
                    "payment_method_type": "apple_pay",
                    "payment_experience": "invoke_sdk_client",
                    "minimum_amount": 0,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": false
                }
            ]
        }
    ],
    "metadata": {
        "apple_pay_combined": {
            "manual": {
                "session_token_data": {
                    "initiative": "ios",
                    "certificate": CERTIFICATE,
                    "display_name": "Barclaycard via Hyperswitch",
                    "certificate_keys": CERTIFICATE_KEYS,
                    "merchant_identifier": MERCHANT_IDENTIFIER,
                    "merchant_business_country": MERCHANT_BUSINESS_COUNTRY,
                    "payment_processing_details_at": "Connector"
                },
                "payment_request_data": {
                    "label": "Cybersource via Hyperswitch",
                    "supported_networks": [
                        "visa",
                        "masterCard",
                        "amex",
                        "discover"
                    ],
                    "merchant_capabilities": [
                        "supports3DS"
                    ]
                }
            }
        }
    },
    "connector_webhook_details": {
        "merchant_secret": "MyWebhookSecret"
    },
    "business_country": "US",
    "business_label": "default"
}'
```

Response:

```
{
    "connector_type": "payment_processor",
    "connector_name": "barclaycard",
    "connector_label": "barclaycard_US_default",
    "merchant_connector_id": "mca_dQAvxu5nKalC1YM9Nh4c",
    "profile_id": "pro_PbbZjjifqFiYwIXrlBjq",
    "connector_account_details": {
        "auth_type": "SignatureKey",
        "api_key": API_KEY,
        "key1": KEY1,
        "api_secret": API_SECRET
    },
    "payment_methods_enabled": [
        {
            "payment_method": "wallet",
            "payment_method_types": [
                {
                    "payment_method_type": "apple_pay",
                    "payment_experience": "invoke_sdk_client",
                    "card_networks": null,
                    "accepted_currencies": null,
                    "accepted_countries": null,
                    "minimum_amount": 0,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": false
                }
            ]
        }
    ],
    "connector_webhook_details": {
        "merchant_secret": "MyWebhookSecret",
        "additional_secret": null
    },
    "metadata": {
        "apple_pay_combined": {
            "manual": {
                "session_token_data": {
                    "initiative": "ios",
                    "certificate": CERTIFICATE,
                    "display_name": "Barclaycard via Hyperswitch",
                    "certificate_keys": CERTIFICATE_KEYS,
                    "merchant_identifier": MERCHANT_IDENTIFIER,
                    "merchant_business_country": MERCHANT_BUSINESS_COUNTRY,
                    "payment_processing_details_at": "Connector"
                },
                "payment_request_data": {
                    "label": "Barclaycard via Hyperswitch",
                    "supported_networks": [
                        "visa",
                        "masterCard",
                        "amex",
                        "discover"
                    ],
                    "merchant_capabilities": [
                        "supports3DS"
                    ]
                }
            }
        }
    },
    "test_mode": true,
    "disabled": false,
    "frm_configs": null,
    "business_country": "US",
    "business_label": "default",
    "business_sub_label": null,
    "applepay_verified_domains": null,
    "pm_auth_config": null,
    "status": "active",
    "additional_merchant_data": null,
    "connector_wallets_details": {
        "apple_pay_combined": {
            "manual": {
                "payment_request_data": {
                    "supported_networks": [
                        "visa",
                        "masterCard",
                        "amex",
                        "discover"
                    ],
                    "merchant_capabilities": [
                        "supports3DS"
                    ],
                    "label": "Barclaycard via Hyperswitch"
                },
                "session_token_data": {
                    "certificate": CERTIFICATE,
                    "certificate_keys": CERTIFICATE_KEYS,
                    "merchant_identifier": MERCHANT_IDENTIFIER,
                    "display_name": MERCHANT_BUSINESS_COUNTRY,
                    "initiative": "ios",
                    "initiative_context": null,
                    "merchant_business_country": MERCHANT_BUSINESS_COUNTRY,
                    "payment_processing_details_at": "Connector"
                }
            }
        }
    }
}
```

2. Payments - Create

Request:

```
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_tO4QhL39rQMDHYzzbfwpngxQRd7PfKBjb3H9h0ngxbMUeLjNovXFBbIRDfRhBkKk' \
--data-raw '{
    "amount": 2229,
    "currency": "USD",
    "confirm": true,
    "customer_id": "gmail",
    "email": "email@email.com",
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": "guest@example.com"
    },
    "payment_method_data": {
        "wallet": {
            "apple_pay": {
                "payment_data": PAYMENT_DATA,
                "payment_method": {
                    "display_name": "MasterCard 0049",
                    "network": "MasterCard",
                    "type": "credit"
                },
                "transaction_identifier": TRANSACTION_IDENTIFIER
            }
        }
    },
    "payment_method": "wallet",
    "payment_method_type": "apple_pay"
}'
```

Response:

```
{
    "payment_id": "pay_PGO6Zpfp4QqUUVrcV69m",
    "merchant_id": "merchant_1757312693",
    "status": "succeeded",
    "amount": 2229,
    "net_amount": 2229,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 2229,
    "connector": "barclaycard",
    "client_secret": "pay_PGO6Zpfp4QqUUVrcV69m_secret_4NqlDHVTMiECtyKhMRgN",
    "created": "2025-09-08T06:25:44.739Z",
    "currency": "USD",
    "customer_id": "gmail",
    "customer": {
        "id": "gmail",
        "name": null,
        "email": "email@email.com",
        "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": null,
    "payment_method": "wallet",
    "payment_method_data": {
        "wallet": {
            "apple_pay": {
                "last4": "0049",
                "card_network": "MasterCard",
                "type": "credit"
            }
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": null,
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe",
            "origin_zip": null
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": "guest@example.com"
    },
    "order_details": null,
    "email": "email@email.com",
    "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": "apple_pay",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "gmail",
        "created_at": 1757312744,
        "expires": 1757316344,
        "secret": "epk_972bbb09245349088a4f2eb20ffb472e"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "7573127477466909504807",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": {
        "redirect_response": null,
        "search_tags": null,
        "apple_pay_recurring_details": null,
        "gateway_system": "direct"
    },
    "reference_id": "pay_PGO6Zpfp4QqUUVrcV69m_1",
    "payment_link": null,
    "profile_id": "pro_PbbZjjifqFiYwIXrlBjq",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_dQAvxu5nKalC1YM9Nh4c",
    "incremental_authorization_allowed": false,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-09-08T06:40:44.739Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_channel": null,
    "payment_method_id": null,
    "network_transaction_id": null,
    "payment_method_status": null,
    "updated": "2025-09-08T06:25:48.784Z",
    "split_payments": null,
    "frm_metadata": null,
    "extended_authorization_applied": null,
    "capture_before": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null,
    "card_discovery": null,
    "force_3ds_challenge": false,
    "force_3ds_challenge_trigger": false,
    "issuer_error_code": null,
    "issuer_error_message": null,
    "is_iframe_redirection_enabled": null,
    "whole_connector_response": null,
    "enable_partial_authorization": null
}
```

</details>
