-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(connectors): fix wallet token deserialization error #4133
Conversation
@@ -708,7 +708,9 @@ impl TryFrom<&BankOfAmericaRouterData<&types::PaymentsAuthorizeRouterData>> | |||
Self::try_from((item, decrypt_data, apple_pay_data)) | |||
} | |||
types::PaymentMethodToken::Token(_) => { | |||
Err(errors::ConnectorError::InvalidWalletToken)? | |||
Err(errors::ConnectorError::InvalidWalletToken { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be payment method not implemented rather than InvalidWalletToken
@@ -1335,7 +1335,9 @@ impl | |||
payment_method_id: match item.router_data.get_payment_method_token()? { | |||
types::PaymentMethodToken::Token(token) => token.into(), | |||
types::PaymentMethodToken::ApplePayDecrypt(_) => { | |||
Err(errors::ConnectorError::InvalidWalletToken)? | |||
Err(errors::ConnectorError::InvalidWalletToken { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Throw not implemented error
@@ -1417,7 +1419,9 @@ fn get_braintree_redirect_form( | |||
card_token: match payment_method_token { | |||
types::PaymentMethodToken::Token(token) => token, | |||
types::PaymentMethodToken::ApplePayDecrypt(_) => { | |||
Err(errors::ConnectorError::InvalidWalletToken)? | |||
Err(errors::ConnectorError::InvalidWalletToken { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
@@ -308,7 +308,9 @@ impl TryFrom<&CheckoutRouterData<&types::PaymentsAuthorizeRouterData>> for Payme | |||
token: match item.router_data.get_payment_method_token()? { | |||
types::PaymentMethodToken::Token(token) => token.into(), | |||
types::PaymentMethodToken::ApplePayDecrypt(_) => { | |||
Err(errors::ConnectorError::InvalidWalletToken)? | |||
Err(errors::ConnectorError::InvalidWalletToken { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw not implemented error
@@ -140,7 +140,9 @@ impl TryFrom<&types::SetupMandateRouterData> for CybersourceZeroMandateRequest { | |||
) | |||
} | |||
types::PaymentMethodToken::Token(_) => { | |||
Err(errors::ConnectorError::InvalidWalletToken)? | |||
Err(errors::ConnectorError::InvalidWalletToken { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw not implemented error
crates/router/src/connector/utils.rs
Outdated
@@ -921,7 +921,9 @@ impl WalletData for api::WalletData { | |||
{ | |||
serde_json::from_str::<T>(self.get_wallet_token()?.peek()) | |||
.into_report() | |||
.change_context(errors::ConnectorError::InvalidWalletToken) | |||
.change_context(errors::ConnectorError::InvalidWalletToken { | |||
wallet_name: "".to_string(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add wallet name
crates/router/src/connector/utils.rs
Outdated
let encoded_token = consts::BASE64_ENGINE.encode(token_as_vec); | ||
Ok(encoded_token) | ||
} | ||
_ => Err(errors::ConnectorError::InvalidWalletToken.into()), | ||
_ => Err(errors::ConnectorError::InvalidWalletToken { | ||
wallet_name: "".to_string(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add not implemented
crates/router/src/connector/utils.rs
Outdated
) | ||
.into_report() | ||
.change_context(errors::ConnectorError::InvalidWalletToken)?, | ||
.change_context(errors::ConnectorError::InvalidWalletToken { | ||
wallet_name: "".to_string(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add wallet name
@@ -79,6 +79,11 @@ pub enum ApiErrorResponse { | |||
message = "Access forbidden, invalid JWT token was used" | |||
)] | |||
InvalidJwtToken, | |||
#[error( | |||
error_type = ErrorType::ProcessingError, code = "IR_17", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use new code
@@ -95,7 +100,7 @@ impl ErrorSwitch<api_models::errors::types::ApiErrorResponse> for ApiErrorRespon | |||
Self::FileProviderNotSupported { message } => { | |||
AER::BadRequest(ApiError::new("IR", 23, message.to_string(), None)) | |||
}, | |||
Self::UnprocessableEntity {message} => AER::Unprocessable(ApiError::new("IR", 23, message.to_string(), None)), | |||
Self::UnprocessableEntity {message} => AER::Unprocessable(ApiError::new("IR", 24, message.to_string(), None)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not required
} | ||
types::PaymentMethodToken::ApplePayDecrypt(_) => Err(unimplemented_payment_method!( | ||
"Apple Pay", | ||
"Decrypt", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use Simplified instead of Decrypt
@@ -384,7 +384,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 { .. } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even here ConnectorError::InvalidWalletToken should be mapped to ApiErrorResponse::InvalidWalletToken
* 'main' of github.com:juspay/hyperswitch: refactor(core): removed the processing status for payment_method_status (#4213) docs(README): remove link to outdated early access form build(deps): bump `error-stack` from version `0.3.1` to `0.4.1` (#4188) chore(version): 2024.04.01.0 feat(mandates): allow off-session payments using `payment_method_id` (#4132) ci(CI-pr): determine modified crates more deterministically (#4233) chore(config): add billwerk base URL in deployment configs (#4243) feat(payment_method): API to list countries and currencies supported by a country and payment method type (#4126) chore(version): 2024.03.28.0 refactor(config): allow wildcard origin for development and Docker Compose setups (#4231) fix(core): Amount capturable remain same for `processing` status in capture (#4229) fix(euclid_wasm): checkout wasm metadata issue (#4198) fix(trustpay): [Trustpay] Add error code mapping '800.100.100' (#4224) feat(connector): [billwerk] add connector template code (#4123) fix(connectors): fix wallet token deserialization error (#4133) fix(log): adding span metadata to `tokio` spawned futures (#4118) chore(version): 2024.03.27.0 fix(connector): [CRYPTOPAY] Skip metadata serialization if none (#4205) fix(connector): [Trustpay] fix deserialization error for incoming webhook response for trustpay and add error code mapping '800.100.203' (#4199) fix(core): make eci in AuthenticationData optional (#4187)
Type of Change
Description
If deserialization fails for Google pay, Apple Pay and any other wallets token - Hyperswitch should respond with 4xx and proper error message
Test case
Response
2.Create a failed stripe Googlepay payment - with wrong token struct
Response
Checklist
cargo +nightly fmt --all
cargo clippy