Skip to content

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

feat(connector): Add Apple Pay HS-Decryption support for Braintree (#10734)

awasthi218c0dd95f9f6f
diff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.toml
index 3b0620dce9..a20760ad14 100644
--- a/config/deployments/integration_test.toml
+++ b/config/deployments/integration_test.toml
@@ -891,7 +891,7 @@ redsys = { payment_method = "card" }
#tokenization configuration which describe token lifetime and payment method for specific connector
[tokenization]
-braintree = { long_lived_token = false, payment_method = "card" }
+braintree = { long_lived_token = false, payment_method = "card,wallet" }
checkout = { long_lived_token = false, payment_method = "wallet", apple_pay_pre_decrypt_flow = "network_tokenization", google_pay_pre_decrypt_flow = "network_tokenization" }
gocardless = { long_lived_token = true, payment_method = "bank_debit" }
hipay = { long_lived_token = false, payment_method = "card" }
diff --git a/config/deployments/production.toml b/config/deployments/production.toml
index 2d983c6fd9..651405ae26 100644
--- a/config/deployments/production.toml
+++ b/config/deployments/production.toml
@@ -899,7 +899,7 @@ redsys = { payment_method = "card" }
#tokenization configuration which describe token lifetime and payment method for specific connector
[tokenization]
-braintree = { long_lived_token = false, payment_method = "card" }
+braintree = { long_lived_token = false, payment_method = "card,wallet" }
checkout = { long_lived_token = false, payment_method = "wallet", apple_pay_pre_decrypt_flow = "network_tokenization", google_pay_pre_decrypt_flow = "network_tokenization" }
gocardless = { long_lived_token = true, payment_method = "bank_debit" }
hipay = { long_lived_token = false, payment_method = "card" }
diff --git a/config/deployments/sandbox.toml b/config/deployments/sandbox.toml
index 48c454ff64..46e4feb8ca 100644
--- a/config/deployments/sandbox.toml
+++ b/config/deployments/sandbox.toml
@@ -907,7 +907,7 @@ redsys = { payment_method = "card" }
#tokenization configuration which describe token lifetime and payment method for specific connector
[tokenization]
-braintree = { long_lived_token = false, payment_method = "card" }
+braintree = { long_lived_token = false, payment_method = "card,wallet" }
checkout = { long_lived_token = false, payment_method = "wallet", apple_pay_pre_decrypt_flow = "network_tokenization", google_pay_pre_decrypt_flow = "network_tokenization" }
gocardless = { long_lived_token = true, payment_method = "bank_debit" }
hipay = { long_lived_token = false, payment_method = "card" }
diff --git a/config/development.toml b/config/development.toml
index 753c888536..b901cbff1e 100644
--- a/config/development.toml
+++ b/config/development.toml
@@ -1049,7 +1049,7 @@ stax = { long_lived_token = true, payment_method = "card,bank_debit" }
mollie = { long_lived_token = false, payment_method = "card" }
square = { long_lived_token = false, payment_method = "card" }
hipay = { long_lived_token = false, payment_method = "card" }
-braintree = { long_lived_token = false, payment_method = "card" }
+braintree = { long_lived_token = false, payment_method = "card,wallet" }
payme = { long_lived_token = false, payment_method = "card" }
gocardless = { long_lived_token = true, payment_method = "bank_debit" }
billwerk = { long_lived_token = false, payment_method = "card" }
diff --git a/config/docker_compose.toml b/config/docker_compose.toml
index 9f4b99eaa1..259e4d1bc0 100644
--- a/config/docker_compose.toml
+++ b/config/docker_compose.toml
@@ -425,7 +425,7 @@ mollie = { long_lived_token = false, payment_method = "card" }
stax = { long_lived_token = true, payment_method = "card,bank_debit" }
square = { long_lived_token = false, payment_method = "card" }
hipay = { long_lived_token = false, payment_method = "card" }
-braintree = { long_lived_token = false, payment_method = "card" }
+braintree = { long_lived_token = false, payment_method = "card,wallet" }
gocardless = { long_lived_token = true, payment_method = "bank_debit" }
billwerk = { long_lived_token = false, payment_method = "card" }
globalpay = { long_lived_token = false, payment_method = "card", flow = "mandates" }
diff --git a/crates/common_types/src/payments.rs b/crates/common_types/src/payments.rs
index 42d13fd218..07935cfbaf 100644
--- a/crates/common_types/src/payments.rs
+++ b/crates/common_types/src/payments.rs
@@ -847,6 +847,25 @@ impl ApplePayPredecryptData {
Ok(self.application_expiration_month.clone())
}
+ /// Get the two-digit expiration month from the Apple Pay pre-decrypt data
+ /// Returns the month with zero-padding if it's a single digit (e.g., "1" -> "01")
+ pub fn get_two_digit_expiry_month(&self) -> Result<Secret<String>, errors::ValidationError> {
+ let month_str = self.application_expiration_month.peek();
+ let month = month_str
+ .parse::<u8>()
+ .map_err(|_| errors::ValidationError::InvalidValue {
+ message: format!("Failed to parse expiry month: {month_str}"),
+ })?;
+
+ if !(1..=12).contains(&month) {
+ return Err(errors::ValidationError::InvalidValue {
+ message: format!("Invalid expiry month: {month}. Must be between 1 and 12"),
+ }
+ .into());
+ }
+ Ok(Secret::new(format!("{:02}", month)))
+ }
+
/// Get the expiry date in MMYY format from the Apple Pay pre-decrypt data
pub fn get_expiry_date_as_mmyy(&self) -> Result<Secret<String>, errors::ValidationError> {
let year = self.get_two_digit_expiry_year()?.expose();
diff --git a/crates/connector_configs/toml/development.toml b/crates/connector_configs/toml/development.toml
index 520581e69d..8b062d34be 100644
--- a/crates/connector_configs/toml/development.toml
+++ b/crates/connector_configs/toml/development.toml
@@ -1430,6 +1430,85 @@ required=true
type="Select"
options=[]
+[braintree.metadata.acquirer_bin]
+name="acquirer_bin"
+label="Acquirer Bin"
+placeholder="Enter Acquirer Bin"
+required=false
+type="Text"
+[braintree.metadata.acquirer_merchant_id]
+name="acquirer_merchant_id"
+label="Acquirer Merchant ID"
+placeholder="Enter Acquirer Merchant ID"
+required=false
+type="Text"
+[braintree.metadata.acquirer_country_code]
+name="acquirer_country_code"
+label="Acquirer Country Code"
+placeholder="Enter Acquirer Country Code"
+required=false
+type="Text"
+
+
+[[braintree.metadata.apple_pay]]
+name="certificate"
+label="Merchant Certificate (Base64 Encoded)"
+placeholder="Enter Merchant Certificate (Base64 Encoded)"
+required=true
+type="Text"
+
+[[braintree.metadata.apple_pay]]
+name="certificate_keys"
+label="Merchant PrivateKey (Base64 Encoded)"
+placeholder="Enter Merchant PrivateKey (Base64 Encoded)"
+required=true
+type="Text"
+
+[[braintree.metadata.apple_pay]]
+name="merchant_identifier"
+label="Apple Merchant Identifier"
+placeholder="Enter Apple Merchant Identifier"
+required=true
+type="Text"
+
+[[braintree.metadata.apple_pay]]
+name="display_name"
+label="Display Name"
+placeholder="Enter Display Name"
+required=true
+type="Text"
+
+[[braintree.metadata.apple_pay]]
+name="initiative"
+label="Domain"
+placeholder="Enter Domain"
+required=true
+type="Select"
+options=["web","ios"]
+
+[[braintree.metadata.apple_pay]]
+name="initiative_context"
+label="Domain Name"
+placeholder="Enter Domain Name"
+required=true
+type="Text"
+
+[[braintree.metadata.apple_pay]]
+name="merchant_business_country"
+label="Merchant Business Country"
+placeholder="Enter Merchant Business Country"
+required=true
+type="Select"
+options=[]
+
+[[braintree.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"]
+
[[braintree.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 ecffb305ed..16a33407ba 100644
--- a/crates/connector_configs/toml/production.toml
+++ b/crates/connector_configs/toml/production.toml
@@ -762,6 +762,86 @@ required = true
type = "Select"
options = []
+
+[braintree.metadata.acquirer_bin]
+name="acquirer_bin"
+label="Acquirer Bin"
+placeholder="Enter Acquirer Bin"
+required=false
+type="Text"
+[braintree.metadata.acquirer_merchant_id]
+name="acquirer_merchant_id"
+label="Acquirer Merchant ID"
+placeholder="Enter Acquirer Merchant ID"
+required=false
+type="Text"
+[braintree.metadata.acquirer_country_code]
+name="acquirer_country_code"
+label="Acquirer Country Code"
+placeholder="Enter Acquirer Country Code"
+required=false
+type="Text"
+
+
+[[braintree.metadata.apple_pay]]
+name="certificate"
+label="Merchant Certificate (Base64 Encoded)"
+placeholder="Enter Merchant Certificate (Base64 Encoded)"
+required=true
+type="Text"
+
+[[braintree.metadata.apple_pay]]
+name="certificate_keys"
+label="Merchant PrivateKey (Base64 Encoded)"
+placeholder="Enter Merchant PrivateKey (Base64 Encoded)"
+required=true
+type="Text"
+
+[[braintree.metadata.apple_pay]]
+name="merchant_identifier"
+label="Apple Merchant Identifier"
+placeholder="Enter Apple Merchant Identifier"
+required=true
+type="Text"
+
+[[braintree.metadata.apple_pay]]
+name="display_name"
+label="Display Name"
+placeholder="Enter Display Name"
+required=true
+type="Text"
+
+[[braintree.metadata.apple_pay]]
+name="initiative"
+label="Domain"
+placeholder="Enter Domain"
+required=true
+type="Select"
+options=["web","ios"]
+
+[[braintree.metadata.apple_pay]]
+name="initiative_context"
+label="Domain Name"
+placeholder="Enter Domain Name"
+required=true
+type="Text"
+
+[[braintree.metadata.apple_pay]]
+name="merchant_business_country"
+label="Merchant Business Country"
+placeholder="Enter Merchant Business Country"
+required=true
+type="Select"
+options=[]
+
+[[braintree.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"]
+
[[braintree.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 ce4441ffb6..1dd08935aa 100644
--- a/crates/connector_configs/toml/sandbox.toml
+++ b/crates/connector_configs/toml/sandbox.toml
@@ -1411,6 +1411,86 @@ payment_method_type = "UnionPay"
merchant_secret = "Source verification key"
+[braintree.metadata.acquirer_bin]
+name="acquirer_bin"
+label="Acquirer Bin"
+placeholder="Enter Acquirer Bin"
+required=false
+type="Text"
+[braintree.metadata.acquirer_merchant_id]
+name="acquirer_merchant_id"
+label="Acquirer Merchant ID"
+placeholder="Enter Acquirer Merchant ID"
+required=false
+type="Text"
+[braintree.metadata.acquirer_country_code]
+name="acquirer_country_code"
+label="Acquirer Country Code"
+placeholder="Enter Acquirer Country Code"
+required=false
+type="Text"
+
+
+[[braintree.metadata.apple_pay]]
+name="certificate"
+label="Merchant Certificate (Base64 Encoded)"
+placeholder="Enter Merchant Certificate (Base64 Encoded)"
+required=true
+type="Text"
+
+[[braintree.metadata.apple_pay]]
+name="certificate_keys"
+label="Merchant PrivateKey (Base64 Encoded)"
+placeholder="Enter Merchant PrivateKey (Base64 Encoded)"
+required=true
+type="Text"
+
+[[braintree.metadata.apple_pay]]
+name="merchant_identifier"
+label="Apple Merchant Identifier"
+placeholder="Enter Apple Merchant Identifier"
+required=true
+type="Text"
+
+[[braintree.metadata.apple_pay]]
+name="display_name"
+label="Display Name"
+placeholder="Enter Display Name"
+required=true
+type="Text"
+
+[[braintree.metadata.apple_pay]]
+name="initiative"
+label="Domain"
+placeholder="Enter Domain"
+required=true
+type="Select"
+options=["web","ios"]
+
+[[braintree.metadata.apple_pay]]
+name="initiative_context"
+label="Domain Name"
+placeholder="Enter Domain Name"
+required=true
+type="Text"
+
+[[braintree.metadata.apple_pay]]
+name="merchant_business_country"
+label="Merchant Business Country"
+placeholder="Enter Merchant Business Country"
+required=true
+type="Select"
+options=[]
+
+[[braintree.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"]
+
+
[braintree.connector_auth.SignatureKey]
api_key = "Public Key"
key1 = "Merchant Id"
diff --git a/crates/hyperswitch_connectors/src/connectors/braintree.rs b/crates/hyperswitch_connectors/src/connectors/braintree.rs
index 384a39987b..2f17b5c15b 100644
--- a/crates/hyperswitch_connectors/src/connectors/braintree.rs
+++ b/crates/hyperswitch_connectors/src/connectors/braintree.rs
@@ -220,6 +220,7 @@ impl ConnectorValidation for Braintree {
let mandate_supported_pmd = std::collections::HashSet::from([
PaymentMethodDataType::Card,
PaymentMethodDataType::ApplePayThirdPartySdk,
+ PaymentMethodDataType::ApplePay,
]);
is_mandate_supported(pm_data, pm_type, mandate_supported_pmd, self.id())
}
diff --git a/crates/hyperswitch_connectors/src/connectors/braintree/transformers.rs b/crates/hyperswitch_connectors/src/connectors/braintree/transformers.rs
index 9e55a8617e..68cfcd385d 100644
--- a/crates/hyperswitch_connectors/src/connectors/braintree/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/braintree/transformers.rs
@@ -63,6 +63,7 @@ pub const CHARGE_AND_VAULT_APPLE_PAY_MUTATION: &str = "mutation ChargeApplepay($
pub const AUTHORIZE_AND_VAULT_APPLE_PAY_MUTATION: &str = "mutation authorizeApplepay($input: AuthorizePaymentMethodInput!) { authorizePaymentMethod(input: $input) { transaction { id legacyId amount { value currencyCode } status paymentMethod { id } } } }";
pub const CHARGE_PAYPAL_MUTATION: &str = "mutation ChargePaypal($input: ChargePaymentMethodInput!) { chargePaymentMethod(input: $input) { transaction { id status amount { value currencyCode } } } }";
pub const AUTHORIZE_PAYPAL_MUTATION: &str = "mutation authorizePaypal($input: AuthorizePaymentMethodInput!) { authorizePaymentMethod(input: $input) { transaction { id legacyId amount { value currencyCode } status } } }";
+pub const TOKENIZE_NETWORK_TOKEN: &str = "mutation tokenizeNetworkToken($input: TokenizeNetworkTokenInput!) { tokenizeNetworkToken(input: $input) { clientMutationId paymentMethod { id } } }";
pub type CardPaymentRequest = GenericBraintreeRequest<VariablePaymentInput>;
pub type MandatePaymentRequest = GenericBraintreeRequest<VariablePaymentInput>;
@@ -73,6 +74,8 @@ pub type BraintreeRefundRequest = GenericBraintreeRequest<BraintreeRefundVariabl
pub type BraintreePSyncRequest = GenericBraintreeRequest<PSyncInput>;
pub type BraintreeRSyncRequest = GenericBraintreeRequest<RSyncInput>;
+pub type BraintreeApplePayTokenizeRequest = GenericBraintreeRequest<VariablePaymentInput>;
+
pub type BraintreeRefundResponse = GenericBraintreeResponse<RefundResponse>;
pub type BraintreeCaptureResponse = GenericBraintreeResponse<CaptureResponse>;
pub type BraintreePSyncResponse = GenericBraintreeResponse<PSyncResponse>;
@@ -87,6 +90,29 @@ pub type RSyncInput = GenericVariableInput<RefundSearchInput>;
pub type BraintreeWalletRequest = GenericBraintreeRequest<GenericVariableInput<WalletPaymentInput>>;
+#[derive(Debug, Clone, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct NetworkTokenData {
+ cryptogram: Secret<String>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ e_commerce_indicator: Option<String>,
+ expiration_month: Secret<String>,
+ expiration_year: Secret<String>,
+ number: cards::CardNumber,
+ origin_details: NetworkTokenOriginDetailsInput,
+}
+#[derive(Debug, Clone, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct NetworkTokenOriginDetailsInput {
+ origin: NetworkTokenOrigin,
+}
+#[derive(Debug, Clone, Serialize)]
+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
+pub enum NetworkTokenOrigin {
+ ApplePay,
+ GooglePay,
+ NetworkToken,
+}
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct WalletTransactionBody {
@@ -505,6 +531,85 @@ impl TryFrom<&BraintreeRouterData<&types::PaymentsAuthorizeRouterData>>
},
}))
}
+ WalletData::ApplePay(_apple_pay_data) => {
+ match item.router_data.payment_method_token {
+ Some(ref payment_method_token) => match payment_method_token {
+ PaymentMethodToken::Token(token) => {
+ let is_mandate = item.router_data.request.is_mandate_payment();
+ let is_auto_capture = item.router_data.request.is_auto_capture()?;
+
+ let (
+ query,
+ customer_details,
+ vault_payment_method_after_transacting,
+ ) = if is_mandate {
+ (
+ if is_auto_capture {
+ CHARGE_AND_VAULT_TRANSACTION_MUTATION.to_string()
+ } else {
+ AUTHORIZE_AND_VAULT_CREDIT_CARD_MUTATION.to_string()
+ },
+ item.router_data
+ .get_billing_email()
+ .ok()
+ .map(|email| CustomerBody { email }),
+ Some(TransactionTiming {
+ when: VaultTiming::Always,
+ }),
+ )
+ } else {
+ (
+ if is_auto_capture {
+ CHARGE_CREDIT_CARD_MUTATION.to_string()
+ } else {
+ AUTHORIZE_CREDIT_CARD_MUTATION.to_string()
+ },
+ None,
+ None,
+ )
+ };
+ Ok(Self::Wallet(BraintreeWalletRequest {
+ query,
+ variables: GenericVariableInput {
+ input: WalletPaymentInput {
+ payment_method_id: token.clone(),
+ transaction: WalletTransactionBody {
+ amount: item.amount.clone(),
+ merchant_account_id: metadata
+ .merchant_account_id
+ .clone(),
+ order_id: item
+ .router_data
+ .connector_request_reference_id
+ .clone(),
+ customer_details,
+ vault_payment_method_after_transacting,
+ },
+ },
+ },
+ }))
+ }
+ PaymentMethodToken::ApplePayDecrypt(_apple_pay_decrypt_data) => {
+ Err(errors::ConnectorError::NotImplemented(
+ utils::get_unimplemented_payment_method_error_message(
+ "braintree",
+ ),
+ )
+ .into())
+ }
+ PaymentMethodToken::PazeDecrypt(_) => {
+ Err(unimplemented_payment_method!("Paze", "Braintree"))?
+ }
+ PaymentMethodToken::GooglePayDecrypt(_) => {
+ Err(unimplemented_payment_method!("Google Pay", "Braintree"))?
+ }
+ },
+ None => Err(errors::ConnectorError::NotImplemented(
+ utils::get_unimplemented_payment_method_error_message("braintree"),
+ )
+ .into()),
+ }
+ }
_ => Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("braintree"),
)
@@ -1450,12 +1555,24 @@ pub struct ClientTokenInput {
merchant_account_id: Secret<String>,
}
+#[derive(Debug, Clone, Serialize)]
+#[serde(untagged)]
+pub enum InputData {
+ CreditCard(CreditCardInputData),
+ NetworkToken(NetworkTokenInputData),
+}
+
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
-pub struct InputData {
+pub struct CreditCardInputData {
credit_card: CreditCardData,
}
+#[derive(Debug, Clone, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct NetworkTokenInputData {
+ network_token: NetworkTokenData,
+}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct InputClientTokenData {
@@ -1469,7 +1586,7 @@ impl TryFrom<&types::TokenizationRouterData> for BraintreeTokenRequest {
PaymentMethodData::Card(card_data) => Ok(Self {
query: TOKENIZE_CREDIT_CARD.to_string(),
variables: VariableInput {
- input: InputData {
+ input: InputData::CreditCard(CreditCardInputData {
credit_card: CreditCardData {
number: card_data.card_number,
expiration_year: card_data.card_exp_year,
@@ -1479,11 +1596,11 @@ impl TryFrom<&types::TokenizationRouterData> for BraintreeTokenRequest {
.get_optional_billing_full_name()
.unwrap_or(Secret::new("".to_string())),
},
- },
+ }),
},
}),
+ PaymentMethodData::Wallet(wallet_data) => Self::try_from((item, wallet_data)),
PaymentMethodData::CardRedirect(_)
- | PaymentMethodData::Wallet(_)
| PaymentMethodData::PayLater(_)
| PaymentMethodData::BankRedirect(_)
| PaymentMethodData::BankDebit(_)
@@ -1533,6 +1650,12 @@ pub struct TokenizeCreditCard {
tokenize_credit_card: TokenizeCreditCardData,
}
+#[derive(Debug, Clone, Deserialize, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct TokenizeNetworkToken {
+ tokenize_network_token: TokenizeCreditCardData,
+}
+
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ClientTokenData {
@@ -1552,8 +1675,10 @@ pub struct ClientTokenResponse {
}
#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct TokenResponse {
- data: TokenizeCreditCard,
+#[serde(untagged)]
+pub enum TokenResponse {
+ CreditCard { data: TokenizeCreditCard },
+ NetworkToken { data: TokenizeNetworkToken },
}
#[derive(Debug, Clone, Deserialize, Serialize)]
@@ -1590,14 +1715,16 @@ impl<F, T> TryFrom<ResponseRouterData<F, BraintreeTokenResponse, T, PaymentsResp
}
BraintreeTokenResponse::TokenResponse(token_response) => {
+ let payment_method_id = match *token_response {
+ TokenResponse::CreditCard { data } => {
+ data.tokenize_credit_card.payment_method.id
+ }
+ TokenResponse::NetworkToken { data } => {
+ data.tokenize_network_token.payment_method.id
+ }
+ };
Ok(PaymentsResponseData::TokenizationResponse {
- token: token_response
- .data
- .tokenize_credit_card
- .payment_method
- .id
- .expose()
- .clone(),
+ token: payment_method_id.expose().clone(),
})
}
},
@@ -2688,3 +2815,57 @@ fn map_transaction_status_to_code(status: &common_enums::TransactionStatus) -> S
common_enums::TransactionStatus::InformationOnly => "I".to_string(),
}
}
+
+impl TryFrom<(&types::TokenizationRouterData, WalletData)> for BraintreeTokenRequest {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ (item, wallet_data): (&types::TokenizationRouterData, WalletData),
+ ) -> Result<Self, Self::Error> {
+ match wallet_data {
+ WalletData::ApplePay(_apple_pay_data) => match &item.payment_method_token {
+ Some(PaymentMethodToken::ApplePayDecrypt(decrypt_data)) => Ok(Self {
+ query: TOKENIZE_NETWORK_TOKEN.to_string(),
+ variables: VariableInput {
+ input: InputData::NetworkToken(NetworkTokenInputData {
+ network_token: NetworkTokenData {
+ cryptogram: decrypt_data
+ .payment_data
+ .online_payment_cryptogram
+ .clone(),
+ e_commerce_indicator: decrypt_data
+ .payment_data
+ .eci_indicator
+ .clone()
+ .map(|eci| {
+ if eci.len() < 2 {
+ format!("{:0>2}", eci)
+ } else {
+ eci
+ }
+ }),
+ expiration_month: decrypt_data
+ .get_two_digit_expiry_month()
+ .change_context(errors::ConnectorError::InvalidDataFormat {
+ field_name: "application_expiration_month",
+ })?,
+ expiration_year: decrypt_data.get_four_digit_expiry_year(),
+ number: decrypt_data.application_primary_account_number.clone(),
+ origin_details: NetworkTokenOriginDetailsInput {
+ origin: NetworkTokenOrigin::ApplePay,
+ },
+ },
+ }),
+ },
+ }),
+ _ => Err(errors::ConnectorError::NotImplemented(
+ utils::get_unimplemented_payment_method_error_message("braintree"),
+ )
+ .into()),
+ },
+ _ => Err(errors::ConnectorError::NotImplemented(
+ utils::get_unimplemented_payment_method_error_message("braintree"),
+ )
+ .into()),
+ }
+ }
+}