From ed22b2af763425d4e71cccd8da158e5e95722fed Mon Sep 17 00:00:00 2001 From: ItsMeShashank Date: Wed, 17 May 2023 15:39:00 +0530 Subject: [PATCH] fix(router): aggregate critical hotfixes for v0.5.10 (#1162) Co-authored-by: Narayan Bhat Co-authored-by: Jagan Elavarasan Co-authored-by: SamraatBansal Co-authored-by: Arun Raj M --- crates/api_models/src/payments.rs | 2 +- crates/router/src/connector/bluesnap.rs | 8 +++++--- crates/router/src/connector/utils.rs | 5 +++++ crates/router/src/core/payment_methods/cards.rs | 2 +- crates/router/src/core/payments/flows/session_flow.rs | 9 ++++++++- crates/router/src/core/payments/helpers.rs | 2 +- 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs index fa44ab63ab..86fa2c9686 100644 --- a/crates/api_models/src/payments.rs +++ b/crates/api_models/src/payments.rs @@ -1523,7 +1523,7 @@ pub struct GpayTransactionInfo { /// The total price status (ex: 'FINAL') pub total_price_status: String, /// The total price - pub total_price: i64, + pub total_price: String, } #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)] diff --git a/crates/router/src/connector/bluesnap.rs b/crates/router/src/connector/bluesnap.rs index abe5fe734e..061619de99 100644 --- a/crates/router/src/connector/bluesnap.rs +++ b/crates/router/src/connector/bluesnap.rs @@ -10,7 +10,9 @@ use common_utils::{ use error_stack::{IntoReport, ResultExt}; use transformers as bluesnap; -use super::utils::{self as connector_utils, RefundsRequestData, RouterData}; +use super::utils::{ + self as connector_utils, PaymentsAuthorizeRequestData, RefundsRequestData, RouterData, +}; use crate::{ configs::settings, consts, @@ -517,7 +519,7 @@ impl ConnectorIntegration CustomResult { - match req.is_three_ds() { + match req.is_three_ds() && !req.request.is_wallet() { true => Ok(format!( "{}{}{}", self.base_url(connectors), @@ -570,7 +572,7 @@ impl ConnectorIntegration CustomResult { - match (data.is_three_ds(), res.headers) { + match (data.is_three_ds() && !data.request.is_wallet(), res.headers) { (true, Some(headers)) => { let location = connector_utils::get_http_header("Location", &headers)?; let payment_fields_token = location diff --git a/crates/router/src/connector/utils.rs b/crates/router/src/connector/utils.rs index 461c9d6e33..f68e54ef9f 100644 --- a/crates/router/src/connector/utils.rs +++ b/crates/router/src/connector/utils.rs @@ -170,6 +170,7 @@ pub trait PaymentsAuthorizeRequestData { fn is_mandate_payment(&self) -> bool; fn get_webhook_url(&self) -> Result; fn get_router_return_url(&self) -> Result; + fn is_wallet(&self) -> bool; fn get_payment_method_type(&self) -> Result; } @@ -234,6 +235,10 @@ impl PaymentsAuthorizeRequestData for types::PaymentsAuthorizeData { .clone() .ok_or_else(missing_field_err("webhook_url")) } + fn is_wallet(&self) -> bool { + matches!(self.payment_method_data, api::PaymentMethodData::Wallet(_)) + } + fn get_payment_method_type(&self) -> Result { self.payment_method_type .to_owned() diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rs index 8e12da732b..cde48cc4a9 100644 --- a/crates/router/src/core/payment_methods/cards.rs +++ b/crates/router/src/core/payment_methods/cards.rs @@ -1098,7 +1098,7 @@ pub async fn list_payment_methods( } #[allow(clippy::too_many_arguments)] -async fn filter_payment_methods( +pub async fn filter_payment_methods( payment_methods: Vec, req: &mut api::PaymentMethodListRequest, resp: &mut Vec, diff --git a/crates/router/src/core/payments/flows/session_flow.rs b/crates/router/src/core/payments/flows/session_flow.rs index e95f0c5af4..20d820a520 100644 --- a/crates/router/src/core/payments/flows/session_flow.rs +++ b/crates/router/src/core/payments/flows/session_flow.rs @@ -251,7 +251,14 @@ fn create_gpay_session_token( country_code: session_data.country.unwrap_or_default(), currency_code: router_data.request.currency.to_string(), total_price_status: "Final".to_string(), - total_price: router_data.request.amount, + total_price: utils::to_currency_base_unit( + router_data.request.amount, + router_data.request.currency, + ) + .attach_printable("Cannot convert given amount to base currency denomination".to_string()) + .change_context(errors::ApiErrorResponse::InvalidDataValue { + field_name: "amount", + })?, }; let response_router_data = types::PaymentsSessionRouterData { diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs index ed5afe925d..477c39b69d 100644 --- a/crates/router/src/core/payments/helpers.rs +++ b/crates/router/src/core/payments/helpers.rs @@ -1282,7 +1282,7 @@ pub(crate) fn validate_pm_or_token_given( } // A function to perform database lookup and then verify the client secret -pub(crate) async fn verify_payment_intent_time_and_client_secret( +pub async fn verify_payment_intent_time_and_client_secret( db: &dyn StorageInterface, merchant_account: &merchant_account::MerchantAccount, client_secret: Option,