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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
fix(connectors): fix wallet token deserialization error (#4133)
AkshayaFoiger929848f8713b
diff --git a/crates/router/src/compatibility/stripe/errors.rs b/crates/router/src/compatibility/stripe/errors.rsindex 60f4391bdf..0181ec4e79 100644--- a/crates/router/src/compatibility/stripe/errors.rs+++ b/crates/router/src/compatibility/stripe/errors.rs@@ -51,6 +51,12 @@ pub enum StripeErrorCode {#[error(error_type = StripeErrorType::CardError, code = "invalid_card_type", message = "Card data is invalid")]InvalidCardType,+ #[error(+ error_type = StripeErrorType::ConnectorError, code = "invalid_wallet_token",+ message = "Invalid {wallet_name} wallet token"+ )]+ InvalidWalletToken { wallet_name: String },+#[error(error_type = StripeErrorType::ApiError, code = "refund_failed", message = "refund has failed")]RefundFailed, // stripe error code@@ -625,6 +631,9 @@ impl From<errors::ApiErrorResponse> for StripeErrorCode {}errors::ApiErrorResponse::CurrencyConversionFailed => Self::CurrencyConversionFailed,errors::ApiErrorResponse::PaymentMethodDeleteFailed => Self::PaymentMethodDeleteFailed,+ errors::ApiErrorResponse::InvalidWalletToken { wallet_name } => {+ Self::InvalidWalletToken { wallet_name }+ }}}}@@ -671,6 +680,7 @@ impl actix_web::ResponseError for StripeErrorCode {| Self::PaymentIntentInvalidParameter { .. }| Self::SerdeQsError { .. }| Self::InvalidRequestData { .. }+ | Self::InvalidWalletToken { .. }| Self::PreconditionFailed { .. }| Self::DuplicateMandate| Self::SuccessfulPaymentNotFounddiff --git a/crates/router/src/connector/bankofamerica/transformers.rs b/crates/router/src/connector/bankofamerica/transformers.rsindex b9a1432102..b4b8ce87ec 100644--- a/crates/router/src/connector/bankofamerica/transformers.rs+++ b/crates/router/src/connector/bankofamerica/transformers.rs@@ -22,6 +22,7 @@ use crate::{transformers::ForeignFrom,ApplePayPredecryptData,},+ unimplemented_payment_method,};pub struct BankOfAmericaAuthType {@@ -708,7 +709,11 @@ impl TryFrom<&BankOfAmericaRouterData<&types::PaymentsAuthorizeRouterData>>Self::try_from((item, decrypt_data, apple_pay_data))}types::PaymentMethodToken::Token(_) => {- Err(errors::ConnectorError::InvalidWalletToken)?+ Err(unimplemented_payment_method!(+ "Apple Pay",+ "Manual",+ "Bank Of America"+ ))?}},None => {diff --git a/crates/router/src/connector/bluesnap/transformers.rs b/crates/router/src/connector/bluesnap/transformers.rsindex 24cc3069f3..a48e38705c 100644--- a/crates/router/src/connector/bluesnap/transformers.rs+++ b/crates/router/src/connector/bluesnap/transformers.rs@@ -310,14 +310,15 @@ impl TryFrom<&BluesnapRouterData<&types::PaymentsAuthorizeRouterData>> for Blues))}api_models::payments::WalletData::ApplePay(payment_method_data) => {- let apple_pay_payment_data = payment_method_data- .get_applepay_decoded_payment_data()- .change_context(errors::ConnectorError::RequestEncodingFailed)?;+ let apple_pay_payment_data =+ payment_method_data.get_applepay_decoded_payment_data()?;let apple_pay_payment_data: ApplePayEncodedPaymentData = apple_pay_payment_data.expose()[..].as_bytes().parse_struct("ApplePayEncodedPaymentData")- .change_context(errors::ConnectorError::RequestEncodingFailed)?;+ .change_context(errors::ConnectorError::InvalidWalletToken {+ wallet_name: "Apple Pay".to_string(),+ })?;let billing = item.router_data.get_billing()?.to_owned();diff --git a/crates/router/src/connector/braintree/braintree_graphql_transformers.rs b/crates/router/src/connector/braintree/braintree_graphql_transformers.rsindex 190cd27657..78c4ee0e10 100644--- a/crates/router/src/connector/braintree/braintree_graphql_transformers.rs+++ b/crates/router/src/connector/braintree/braintree_graphql_transformers.rs@@ -10,6 +10,7 @@ use crate::{core::errors,services,types::{self, api, storage::enums},+ unimplemented_payment_method,};pub const CLIENT_TOKEN_MUTATION: &str = "mutation createClientToken($input: CreateClientTokenInput!) { createClientToken(input: $input) { clientToken}}";@@ -1334,9 +1335,9 @@ implinput: PaymentInput {payment_method_id: match item.router_data.get_payment_method_token()? {types::PaymentMethodToken::Token(token) => token.into(),- types::PaymentMethodToken::ApplePayDecrypt(_) => {- Err(errors::ConnectorError::InvalidWalletToken)?- }+ types::PaymentMethodToken::ApplePayDecrypt(_) => Err(+ unimplemented_payment_method!("Apple Pay", "Simplified", "Braintree"),+ )?,},transaction: TransactionBody {amount: item.amount.to_owned(),@@ -1416,9 +1417,11 @@ fn get_braintree_redirect_form(.expose(),card_token: match payment_method_token {types::PaymentMethodToken::Token(token) => token,- types::PaymentMethodToken::ApplePayDecrypt(_) => {- Err(errors::ConnectorError::InvalidWalletToken)?- }+ types::PaymentMethodToken::ApplePayDecrypt(_) => Err(unimplemented_payment_method!(+ "Apple Pay",+ "Simplified",+ "Braintree"+ ))?,},bin: match card_details {api_models::payments::PaymentMethodData::Card(card_details) => {diff --git a/crates/router/src/connector/checkout/transformers.rs b/crates/router/src/connector/checkout/transformers.rsindex 64fddca13b..6328f98081 100644--- a/crates/router/src/connector/checkout/transformers.rs+++ b/crates/router/src/connector/checkout/transformers.rs@@ -14,6 +14,7 @@ use crate::{core::errors,services,types::{self, api, storage::enums, transformers::ForeignFrom},+ unimplemented_payment_method,};#[derive(Debug, Serialize)]@@ -92,12 +93,12 @@ impl TryFrom<&types::TokenizationRouterData> for TokenRequest {api::PaymentMethodData::Wallet(wallet_data) => match wallet_data.clone() {api_models::payments::WalletData::GooglePay(_data) => {let json_wallet_data: CheckoutGooglePayData =- wallet_data.get_wallet_token_as_json()?;+ wallet_data.get_wallet_token_as_json("Google Pay".to_string())?;Ok(Self::Googlepay(json_wallet_data))}api_models::payments::WalletData::ApplePay(_data) => {let json_wallet_data: CheckoutApplePayData =- wallet_data.get_wallet_token_as_json()?;+ wallet_data.get_wallet_token_as_json("Apple Pay".to_string())?;Ok(Self::Applepay(json_wallet_data))}api_models::payments::WalletData::AliPayQr(_)@@ -308,7 +309,11 @@ impl TryFrom<&CheckoutRouterData<&types::PaymentsAuthorizeRouterData>> for Paymetoken: match item.router_data.get_payment_method_token()? {types::PaymentMethodToken::Token(token) => token.into(),types::PaymentMethodToken::ApplePayDecrypt(_) => {- Err(errors::ConnectorError::InvalidWalletToken)?+ Err(unimplemented_payment_method!(+ "Apple Pay",+ "Simplified",+ "Checkout"+ ))?}},}))diff --git a/crates/router/src/connector/cybersource/transformers.rs b/crates/router/src/connector/cybersource/transformers.rsindex d9fab9a902..19d5e17722 100644--- a/crates/router/src/connector/cybersource/transformers.rs+++ b/crates/router/src/connector/cybersource/transformers.rs@@ -23,6 +23,7 @@ use crate::{transformers::ForeignFrom,ApplePayPredecryptData,},+ unimplemented_payment_method,};#[derive(Debug, Serialize)]@@ -139,9 +140,9 @@ impl TryFrom<&types::SetupMandateRouterData> for CybersourceZeroMandateRequest {Some(PaymentSolution::ApplePay),)}- types::PaymentMethodToken::Token(_) => {- Err(errors::ConnectorError::InvalidWalletToken)?- }+ types::PaymentMethodToken::Token(_) => Err(+ unimplemented_payment_method!("Apple Pay", "Manual", "Cybersource"),+ )?,},None => (PaymentInformation::ApplePayToken(ApplePayTokenPaymentInformation {@@ -980,7 +981,11 @@ impl TryFrom<&CybersourceRouterData<&types::PaymentsAuthorizeRouterData>>Self::try_from((item, decrypt_data, apple_pay_data))}types::PaymentMethodToken::Token(_) => {- Err(errors::ConnectorError::InvalidWalletToken)?+ Err(unimplemented_payment_method!(+ "Apple Pay",+ "Manual",+ "Cybersource"+ ))?}},None => {diff --git a/crates/router/src/connector/globalpay/transformers.rs b/crates/router/src/connector/globalpay/transformers.rsindex 1e41094625..35987ae26b 100644--- a/crates/router/src/connector/globalpay/transformers.rs+++ b/crates/router/src/connector/globalpay/transformers.rs@@ -459,7 +459,7 @@ fn get_wallet_data(api_models::payments::WalletData::GooglePay(_) => {Ok(PaymentMethodData::DigitalWallet(requests::DigitalWallet {provider: Some(requests::DigitalWalletProvider::PayByGoogle),- payment_token: wallet_data.get_wallet_token_as_json()?,+ payment_token: wallet_data.get_wallet_token_as_json("Google Pay".to_string())?,}))}_ => Err(errors::ConnectorError::NotImplemented(diff --git a/crates/router/src/connector/mollie/transformers.rs b/crates/router/src/connector/mollie/transformers.rsindex 4c18b59cd1..be0c0475fd 100644--- a/crates/router/src/connector/mollie/transformers.rs+++ b/crates/router/src/connector/mollie/transformers.rs@@ -15,6 +15,7 @@ use crate::{core::errors,services, types,types::storage::enums as storage_enums,+ unimplemented_payment_method,};type Error = error_stack::Report<errors::ConnectorError>;@@ -178,7 +179,11 @@ impl TryFrom<&MollieRouterData<&types::PaymentsAuthorizeRouterData>> for MolliePcard_token: Some(Secret::new(match pm_token {types::PaymentMethodToken::Token(token) => token,types::PaymentMethodToken::ApplePayDecrypt(_) => {- Err(errors::ConnectorError::InvalidWalletToken)?+ Err(unimplemented_payment_method!(+ "Apple Pay",+ "Simplified",+ "Mollie"+ ))?}})),},diff --git a/crates/router/src/connector/nexinets/transformers.rs b/crates/router/src/connector/nexinets/transformers.rsindex 9fdaaa36b3..dc87189114 100644--- a/crates/router/src/connector/nexinets/transformers.rs+++ b/crates/router/src/connector/nexinets/transformers.rs@@ -665,7 +665,7 @@ fn get_applepay_details(wallet_data: &api_models::payments::WalletData,applepay_data: &api_models::payments::ApplePayWalletData,) -> CustomResult<ApplePayDetails, errors::ConnectorError> {- let payment_data = wallet_data.get_wallet_token_as_json()?;+ let payment_data = wallet_data.get_wallet_token_as_json("Apple Pay".to_string())?;Ok(ApplePayDetails {payment_data,payment_method: ApplepayPaymentMethod {diff --git a/crates/router/src/connector/noon/transformers.rs b/crates/router/src/connector/noon/transformers.rsindex 08cde4041d..92def17aea 100644--- a/crates/router/src/connector/noon/transformers.rs+++ b/crates/router/src/connector/noon/transformers.rs@@ -259,7 +259,8 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for NoonPaymentsRequest {api_models::payments::WalletData::ApplePay(apple_pay_data) => {let payment_token_data = NoonApplePayTokenData {token: NoonApplePayData {- payment_data: wallet_data.get_wallet_token_as_json()?,+ payment_data: wallet_data+ .get_wallet_token_as_json("Apple Pay".to_string())?,payment_method: NoonApplePayPaymentMethod {display_name: apple_pay_data.payment_method.display_name,network: apple_pay_data.payment_method.network,diff --git a/crates/router/src/connector/payme/transformers.rs b/crates/router/src/connector/payme/transformers.rsindex 5a84d7c4ed..4db0a0bd07 100644--- a/crates/router/src/connector/payme/transformers.rs+++ b/crates/router/src/connector/payme/transformers.rs@@ -21,6 +21,7 @@ use crate::{core::errors,services,types::{self, api, storage::enums, MandateReference},+ unimplemented_payment_method,};const LANGUAGE: &str = "en";@@ -708,9 +709,9 @@ impl TryFrom<&types::PaymentsCompleteAuthorizeRouterData> for Pay3dsRequest {let pm_token = item.get_payment_method_token()?;let buyer_key = match pm_token {types::PaymentMethodToken::Token(token) => token,- types::PaymentMethodToken::ApplePayDecrypt(_) => {- Err(errors::ConnectorError::InvalidWalletToken)?- }+ types::PaymentMethodToken::ApplePayDecrypt(_) => Err(+ unimplemented_payment_method!("Apple Pay", "Simplified", "Payme"),+ )?,};Ok(Self {buyer_email,diff --git a/crates/router/src/connector/square/transformers.rs b/crates/router/src/connector/square/transformers.rsindex 03bd0ac83e..66a0282f92 100644--- a/crates/router/src/connector/square/transformers.rs+++ b/crates/router/src/connector/square/transformers.rs@@ -10,6 +10,7 @@ use crate::{self, api,storage::{self, enums},},+ unimplemented_payment_method,};impl TryFrom<(&types::TokenizationRouterData, BankDebitData)> for SquareTokenRequest {@@ -257,9 +258,9 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for SquarePaymentsRequest {idempotency_key: Secret::new(item.attempt_id.clone()),source_id: Secret::new(match pm_token {types::PaymentMethodToken::Token(token) => token,- types::PaymentMethodToken::ApplePayDecrypt(_) => {- Err(errors::ConnectorError::InvalidWalletToken)?- }+ types::PaymentMethodToken::ApplePayDecrypt(_) => Err(+ unimplemented_payment_method!("Apple Pay", "Simplified", "Square"),+ )?,}),amount_money: SquarePaymentsAmountData {amount: item.request.amount,diff --git a/crates/router/src/connector/stax/transformers.rs b/crates/router/src/connector/stax/transformers.rsindex a9bb68d558..d28b5c1fa4 100644--- a/crates/router/src/connector/stax/transformers.rs+++ b/crates/router/src/connector/stax/transformers.rs@@ -9,6 +9,7 @@ use crate::{},core::errors,types::{self, api, storage::enums},+ unimplemented_payment_method,};#[derive(Debug, Serialize)]@@ -80,9 +81,9 @@ impl TryFrom<&StaxRouterData<&types::PaymentsAuthorizeRouterData>> for StaxPaymepre_auth,payment_method_id: Secret::new(match pm_token {types::PaymentMethodToken::Token(token) => token,- types::PaymentMethodToken::ApplePayDecrypt(_) => {- Err(errors::ConnectorError::InvalidWalletToken)?- }+ types::PaymentMethodToken::ApplePayDecrypt(_) => Err(+ unimplemented_payment_method!("Apple Pay", "Simplified", "Stax"),+ )?,}),idempotency_id: Some(item.router_data.connector_request_reference_id.clone()),})@@ -99,9 +100,9 @@ impl TryFrom<&StaxRouterData<&types::PaymentsAuthorizeRouterData>> for StaxPaymepre_auth,payment_method_id: Secret::new(match pm_token {types::PaymentMethodToken::Token(token) => token,- types::PaymentMethodToken::ApplePayDecrypt(_) => {- Err(errors::ConnectorError::InvalidWalletToken)?- }+ types::PaymentMethodToken::ApplePayDecrypt(_) => Err(+ unimplemented_payment_method!("Apple Pay", "Simplified", "Stax"),+ )?,}),idempotency_id: Some(item.router_data.connector_request_reference_id.clone()),})diff --git a/crates/router/src/connector/stripe/transformers.rs b/crates/router/src/connector/stripe/transformers.rsindex a4c1668816..860065b2b0 100644--- a/crates/router/src/connector/stripe/transformers.rs+++ b/crates/router/src/connector/stripe/transformers.rs@@ -29,6 +29,7 @@ use crate::{storage::enums,transformers::{ForeignFrom, ForeignTryFrom},},+ unimplemented_payment_method,utils::OptionExt,};@@ -1541,9 +1542,7 @@ impl TryFrom<(&payments::WalletData, Option<types::PaymentMethodToken>)>if apple_pay_decrypt_data.is_none() {apple_pay_decrypt_data =Some(Self::Wallet(StripeWallet::ApplepayToken(StripeApplePay {- pk_token: applepay_data- .get_applepay_decoded_payment_data()- .change_context(errors::ConnectorError::RequestEncodingFailed)?,+ pk_token: applepay_data.get_applepay_decoded_payment_data()?,pk_token_instrument_name: applepay_data.payment_method.pm_type@@ -1715,7 +1714,9 @@ impl TryFrom<&payments::GooglePayWalletData> for StripePaymentMethodData {.token.as_bytes().parse_struct::<StripeGpayToken>("StripeGpayToken")- .change_context(errors::ConnectorError::RequestEncodingFailed)?+ .change_context(errors::ConnectorError::InvalidWalletToken {+ wallet_name: "Google Pay".to_string(),+ })?.id,),payment_type: StripePaymentMethodType::Card,@@ -1862,12 +1863,15 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for PaymentIntentRequest {.payment_method_token.to_owned().get_required_value("payment_token")- .change_context(errors::ConnectorError::RequestEncodingFailed)?;+ .change_context(errors::ConnectorError::InvalidWalletToken {+ wallet_name: "Apple Pay".to_string(),+ })?;+let payment_method_token = match payment_method_token {types::PaymentMethodToken::Token(payment_method_token) => payment_method_token,- types::PaymentMethodToken::ApplePayDecrypt(_) => {- Err(errors::ConnectorError::InvalidWalletToken)?- }+ types::PaymentMethodToken::ApplePayDecrypt(_) => Err(+ unimplemented_payment_method!("Apple Pay", "Simplified", "Stripe"),+ )?,};Some(StripePaymentMethodData::Wallet(StripeWallet::ApplepayPayment(ApplepayPayment {diff --git a/crates/router/src/connector/utils.rs b/crates/router/src/connector/utils.rsindex e510f3bfaf..a41c05f19b 100644--- a/crates/router/src/connector/utils.rs+++ b/crates/router/src/connector/utils.rs@@ -900,7 +900,7 @@ fn get_card_issuer(card_number: &str) -> Result<CardIssuer, Error> {}pub trait WalletData {fn get_wallet_token(&self) -> Result<Secret<String>, Error>;- fn get_wallet_token_as_json<T>(&self) -> Result<T, Error>+ fn get_wallet_token_as_json<T>(&self, wallet_name: String) -> Result<T, Error>whereT: serde::de::DeserializeOwned;fn get_encoded_wallet_token(&self) -> Result<String, Error>;@@ -915,26 +915,31 @@ impl WalletData for api::WalletData {_ => Err(errors::ConnectorError::InvalidWallet.into()),}}- fn get_wallet_token_as_json<T>(&self) -> Result<T, Error>+ fn get_wallet_token_as_json<T>(&self, wallet_name: String) -> Result<T, Error>whereT: serde::de::DeserializeOwned,{serde_json::from_str::<T>(self.get_wallet_token()?.peek()).into_report()- .change_context(errors::ConnectorError::InvalidWalletToken)+ .change_context(errors::ConnectorError::InvalidWalletToken { wallet_name })}fn get_encoded_wallet_token(&self) -> Result<String, Error> {match self {Self::GooglePay(_) => {- let json_token: serde_json::Value = self.get_wallet_token_as_json()?;+ let json_token: serde_json::Value =+ self.get_wallet_token_as_json("Google Pay".to_owned())?;let token_as_vec = serde_json::to_vec(&json_token).into_report()- .change_context(errors::ConnectorError::InvalidWalletToken)?;+ .change_context(errors::ConnectorError::InvalidWalletToken {+ wallet_name: "Google Pay".to_string(),+ })?;let encoded_token = consts::BASE64_ENGINE.encode(token_as_vec);Ok(encoded_token)}- _ => Err(errors::ConnectorError::InvalidWalletToken.into()),+ _ => Err(+ errors::ConnectorError::NotImplemented("SELECTED PAYMENT METHOD".to_owned()).into(),+ ),}}}@@ -950,10 +955,14 @@ impl ApplePay for payments::ApplePayWalletData {consts::BASE64_ENGINE.decode(&self.payment_data).into_report()- .change_context(errors::ConnectorError::InvalidWalletToken)?,+ .change_context(errors::ConnectorError::InvalidWalletToken {+ wallet_name: "Apple Pay".to_string(),+ })?,).into_report()- .change_context(errors::ConnectorError::InvalidWalletToken)?,+ .change_context(errors::ConnectorError::InvalidWalletToken {+ wallet_name: "Apple Pay".to_string(),+ })?,);Ok(token)}diff --git a/crates/router/src/connector/zen/transformers.rs b/crates/router/src/connector/zen/transformers.rsindex b01b3f027a..3e52742357 100644--- a/crates/router/src/connector/zen/transformers.rs+++ b/crates/router/src/connector/zen/transformers.rs@@ -473,13 +473,17 @@ implZenPaymentChannels::PclApplepay,session.apple_pay- .ok_or(errors::ConnectorError::RequestEncodingFailed)?,+ .ok_or(errors::ConnectorError::InvalidWalletToken {+ wallet_name: "Apple Pay".to_string(),+ })?,),api_models::payments::WalletData::GooglePayRedirect(_) => (ZenPaymentChannels::PclGooglepay,session.google_pay- .ok_or(errors::ConnectorError::RequestEncodingFailed)?,+ .ok_or(errors::ConnectorError::InvalidWalletToken {+ wallet_name: "Google Pay".to_string(),+ })?,),api_models::payments::WalletData::WeChatPayRedirect(_)| api_models::payments::WalletData::PaypalRedirect(_)diff --git a/crates/router/src/core/errors.rs b/crates/router/src/core/errors.rsindex c468fea54c..a7d36ff512 100644--- a/crates/router/src/core/errors.rs+++ b/crates/router/src/core/errors.rs@@ -68,6 +68,22 @@ macro_rules! capture_method_not_supported {};}+#[macro_export]+macro_rules! unimplemented_payment_method {+ ($payment_method:expr, $connector:expr) => {+ errors::ConnectorError::NotImplemented(format!(+ "{} through {}",+ $payment_method, $connector+ ))+ };+ ($payment_method:expr, $flow:expr, $connector:expr) => {+ errors::ConnectorError::NotImplemented(format!(+ "{} {} through {}",+ $payment_method, $flow, $connector+ ))+ };+}+macro_rules! impl_error_type {($name: ident, $arg: tt) => {#[derive(Debug)]@@ -179,8 +195,8 @@ pub enum ConnectorError {InvalidDataFormat { field_name: &'static str },#[error("Payment Method data / Payment Method Type / Payment Experience Mismatch ")]MismatchedPaymentData,- #[error("Failed to parse Wallet token")]- InvalidWalletToken,+ #[error("Failed to parse {wallet_name} wallet token")]+ InvalidWalletToken { wallet_name: String },#[error("Missing Connector Related Transaction ID")]MissingConnectorRelatedTransactionID { id: String },#[error("File Validation failed")]diff --git a/crates/router/src/core/errors/api_error_response.rs b/crates/router/src/core/errors/api_error_response.rsindex 3fc93e4e73..b3fbbaaf14 100644--- a/crates/router/src/core/errors/api_error_response.rs+++ b/crates/router/src/core/errors/api_error_response.rs@@ -96,6 +96,11 @@ pub enum ApiErrorResponse {FileProviderNotSupported { message: String },#[error(error_type = ErrorType::InvalidRequestError, code = "IR_23", message = "{message}")]UnprocessableEntity { message: String },+ #[error(+ error_type = ErrorType::ProcessingError, code = "IR_24",+ message = "Invalid {wallet_name} wallet token"+ )]+ InvalidWalletToken { wallet_name: String },#[error(error_type = ErrorType::ConnectorError, code = "CE_00", message = "{code}: {message}", ignore = "status_code")]ExternalConnectorError {code: String,@@ -122,7 +127,6 @@ pub enum ApiErrorResponse {VerificationFailed { data: Option<serde_json::Value> },#[error(error_type = ErrorType::ProcessingError, code = "CE_08", message = "Dispute operation failed while processing with connector. Retry operation")]DisputeFailed { data: Option<serde_json::Value> },-#[error(error_type = ErrorType::ServerNotAvailable, code = "HE_00", message = "Something went wrong")]InternalServerError,#[error(error_type = ErrorType::LockTimeout, code = "HE_00", message = "Resource is busy. Please try again later.")]diff --git a/crates/router/src/core/errors/transformers.rs b/crates/router/src/core/errors/transformers.rsindex b570dda437..110feb22df 100644--- a/crates/router/src/core/errors/transformers.rs+++ b/crates/router/src/core/errors/transformers.rs@@ -96,6 +96,11 @@ impl ErrorSwitch<api_models::errors::types::ApiErrorResponse> for ApiErrorResponAER::BadRequest(ApiError::new("IR", 23, message.to_string(), None))},Self::UnprocessableEntity {message} => AER::Unprocessable(ApiError::new("IR", 23, message.to_string(), None)),+ Self::InvalidWalletToken { wallet_name} => AER::Unprocessable(ApiError::new(+ "IR",+ 24,+ format!("Invalid {wallet_name} wallet token"), None+ )),Self::ExternalConnectorError {code,message,diff --git a/crates/router/src/core/errors/utils.rs b/crates/router/src/core/errors/utils.rsindex d9b4e19013..f664c33681 100644--- a/crates/router/src/core/errors/utils.rs+++ b/crates/router/src/core/errors/utils.rs@@ -204,7 +204,7 @@ impl<T> ConnectorErrorExt<T> for error_stack::Result<T, errors::ConnectorError>| errors::ConnectorError::DateFormattingFailed| errors::ConnectorError::InvalidDataFormat { .. }| errors::ConnectorError::MismatchedPaymentData- | errors::ConnectorError::InvalidWalletToken+ | errors::ConnectorError::InvalidWalletToken { .. }| errors::ConnectorError::MissingConnectorRelatedTransactionID { .. }| errors::ConnectorError::FileValidationFailed { .. }| errors::ConnectorError::MissingConnectorRedirectionPayload { .. }@@ -265,6 +265,7 @@ impl<T> ConnectorErrorExt<T> for error_stack::Result<T, errors::ConnectorError>errors::ConnectorError::InvalidDataFormat { field_name } => {errors::ApiErrorResponse::InvalidDataValue { field_name }},+ errors::ConnectorError::InvalidWalletToken {wallet_name} => errors::ApiErrorResponse::InvalidWalletToken {wallet_name: wallet_name.to_string()},errors::ConnectorError::CurrencyNotSupported { message, connector} => errors::ApiErrorResponse::CurrencyNotSupported { message: format!("Credentials for the currency {message} are not configured with the connector {connector}/hyperswitch") },errors::ConnectorError::FailedToObtainAuthType => errors::ApiErrorResponse::InvalidConnectorConfiguration {config: "connector_account_details".to_string()},errors::ConnectorError::InvalidConnectorConfig { config } => errors::ApiErrorResponse::InvalidConnectorConfiguration { config: config.to_string() },@@ -299,7 +300,6 @@ impl<T> ConnectorErrorExt<T> for error_stack::Result<T, errors::ConnectorError>errors::ConnectorError::WebhookResponseEncodingFailed |errors::ConnectorError::InvalidDateFormat |errors::ConnectorError::DateFormattingFailed |- errors::ConnectorError::InvalidWalletToken |errors::ConnectorError::MissingConnectorRelatedTransactionID { .. } |errors::ConnectorError::FileValidationFailed { .. } |errors::ConnectorError::MissingConnectorRedirectionPayload { .. } |@@ -347,6 +347,11 @@ impl<T> ConnectorErrorExt<T> for error_stack::Result<T, errors::ConnectorError>config: field_name.to_string(),}}+ errors::ConnectorError::InvalidWalletToken { wallet_name } => {+ errors::ApiErrorResponse::InvalidWalletToken {+ wallet_name: wallet_name.to_string(),+ }+ }errors::ConnectorError::RequestEncodingFailed| errors::ConnectorError::RequestEncodingFailedWithReason(_)| errors::ConnectorError::ParsingFailed@@ -384,7 +389,6 @@ impl<T> ConnectorErrorExt<T> for error_stack::Result<T, errors::ConnectorError>| errors::ConnectorError::DateFormattingFailed| errors::ConnectorError::InvalidDataFormat { .. }| errors::ConnectorError::MismatchedPaymentData- | errors::ConnectorError::InvalidWalletToken| errors::ConnectorError::MissingConnectorRelatedTransactionID { .. }| errors::ConnectorError::FileValidationFailed { .. }| errors::ConnectorError::MissingConnectorRedirectionPayload { .. }diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rsindex 112e3e64d6..7eab4c0d26 100644--- a/crates/router/src/core/payments/helpers.rs+++ b/crates/router/src/core/payments/helpers.rs@@ -3605,8 +3605,10 @@ impl ApplePayData {pub fn token_json(wallet_data: api_models::payments::WalletData,) -> CustomResult<Self, errors::ConnectorError> {- let json_wallet_data: Self =- connector::utils::WalletData::get_wallet_token_as_json(&wallet_data)?;+ let json_wallet_data: Self = connector::utils::WalletData::get_wallet_token_as_json(+ &wallet_data,+ "Apple Pay".to_string(),+ )?;Ok(json_wallet_data)}diff --git a/crates/storage_impl/src/errors.rs b/crates/storage_impl/src/errors.rsindex 59ddacc5dc..7002d0946f 100644--- a/crates/storage_impl/src/errors.rs+++ b/crates/storage_impl/src/errors.rs@@ -374,7 +374,7 @@ pub enum ConnectorError {#[error("Payment Method data / Payment Method Type / Payment Experience Mismatch ")]MismatchedPaymentData,#[error("Failed to parse Wallet token")]- InvalidWalletToken,+ InvalidWalletToken { wallet_name: String },#[error("Missing Connector Related Transaction ID")]MissingConnectorRelatedTransactionID { id: String },#[error("File Validation failed")]