From 0f8384dde996a455920bd4127c1d0ce62d5312ba Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 28 Mar 2024 05:54:30 +0000 Subject: [PATCH 01/19] chore(version): 2024.03.28.0 --- CHANGELOG.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69d68df55c49..f41ba2b094d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,28 @@ All notable changes to HyperSwitch will be documented here. - - - +## 2024.03.28.0 + +### Features + +- **connector:** [billwerk] add connector template code ([#4123](https://github.com/juspay/hyperswitch/pull/4123)) ([`37be05d`](https://github.com/juspay/hyperswitch/commit/37be05d31d97651ddaa2c67b828d24563b35d37e)) + +### Bug Fixes + +- **connectors:** Fix wallet token deserialization error ([#4133](https://github.com/juspay/hyperswitch/pull/4133)) ([`929848f`](https://github.com/juspay/hyperswitch/commit/929848f8713b45daf479ba24fb0a49b8e327b6fd)) +- **core:** Amount capturable remain same for `processing` status in capture ([#4229](https://github.com/juspay/hyperswitch/pull/4229)) ([`9523cf4`](https://github.com/juspay/hyperswitch/commit/9523cf4bbac488503c31640cade326095937e33c)) +- **euclid_wasm:** Checkout wasm metadata issue ([#4198](https://github.com/juspay/hyperswitch/pull/4198)) ([`246898f`](https://github.com/juspay/hyperswitch/commit/246898fbb00a67d5791827527ce45e01b01b232c)) +- **log:** Adding span metadata to `tokio` spawned futures ([#4118](https://github.com/juspay/hyperswitch/pull/4118)) ([`0706221`](https://github.com/juspay/hyperswitch/commit/070622125f49c4cc9c35f5ba9c634f1fef6b26d2)) +- **trustpay:** [Trustpay] Add error code mapping '800.100.100' ([#4224](https://github.com/juspay/hyperswitch/pull/4224)) ([`9798db4`](https://github.com/juspay/hyperswitch/commit/9798db4558d926a218a0ca6f7f7c4e24a187b3da)) + +### Refactors + +- **config:** Allow wildcard origin for development and Docker Compose setups ([#4231](https://github.com/juspay/hyperswitch/pull/4231)) ([`6587472`](https://github.com/juspay/hyperswitch/commit/65874728094bb550d6c311965fbb5f1577091bbb)) + +**Full Changelog:** [`2024.03.27.0...2024.03.28.0`](https://github.com/juspay/hyperswitch/compare/2024.03.27.0...2024.03.28.0) + +- - - + ## 2024.03.27.0 ### Bug Fixes From 74cd4a79526eb1a2dead87855e6a39248ec5ccb7 Mon Sep 17 00:00:00 2001 From: Amisha Prabhat <55580080+Aprabhat19@users.noreply.github.com> Date: Thu, 28 Mar 2024 12:30:11 +0530 Subject: [PATCH 02/19] feat(payment_method): API to list countries and currencies supported by a country and payment method type (#4126) Co-authored-by: Mani Chandra Dulam Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> --- crates/api_models/src/events/payment.rs | 8 ++- crates/api_models/src/payment_methods.rs | 22 ++++++- crates/common_enums/src/enums.rs | 1 + .../router/src/core/payment_methods/cards.rs | 62 ++++++++++++++++++- crates/router/src/routes/app.rs | 53 ++++++++++------ crates/router/src/routes/lock_utils.rs | 1 + crates/router/src/routes/payment_methods.rs | 32 +++++++++- .../router/src/types/api/payment_methods.rs | 10 +-- crates/router_env/src/logger/types.rs | 2 + 9 files changed, 160 insertions(+), 31 deletions(-) diff --git a/crates/api_models/src/events/payment.rs b/crates/api_models/src/events/payment.rs index 346ee34b2cff..b26ee0ae68ea 100644 --- a/crates/api_models/src/events/payment.rs +++ b/crates/api_models/src/events/payment.rs @@ -3,8 +3,9 @@ use common_utils::events::{ApiEventMetric, ApiEventsType}; use crate::{ payment_methods::{ CustomerDefaultPaymentMethodResponse, CustomerPaymentMethodsListResponse, - DefaultPaymentMethod, PaymentMethodDeleteResponse, PaymentMethodListRequest, - PaymentMethodListResponse, PaymentMethodResponse, PaymentMethodUpdate, + DefaultPaymentMethod, ListCountriesCurrenciesRequest, ListCountriesCurrenciesResponse, + PaymentMethodDeleteResponse, PaymentMethodListRequest, PaymentMethodListResponse, + PaymentMethodResponse, PaymentMethodUpdate, }, payments::{ PaymentIdType, PaymentListConstraints, PaymentListFilterConstraints, PaymentListFilters, @@ -131,6 +132,9 @@ impl ApiEventMetric for PaymentMethodListRequest { } } +impl ApiEventMetric for ListCountriesCurrenciesRequest {} + +impl ApiEventMetric for ListCountriesCurrenciesResponse {} impl ApiEventMetric for PaymentMethodListResponse {} impl ApiEventMetric for CustomerDefaultPaymentMethodResponse { diff --git a/crates/api_models/src/payment_methods.rs b/crates/api_models/src/payment_methods.rs index 37580edbc713..f08a793ebf50 100644 --- a/crates/api_models/src/payment_methods.rs +++ b/crates/api_models/src/payment_methods.rs @@ -1,4 +1,4 @@ -use std::collections::HashMap; +use std::collections::{HashMap, HashSet}; use cards::CardNumber; use common_utils::{ @@ -914,6 +914,26 @@ pub struct TokenizedCardValue1 { pub card_token: Option, } +#[derive(Debug, serde::Serialize, serde::Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct ListCountriesCurrenciesRequest { + pub connector: api_enums::Connector, + pub payment_method_type: api_enums::PaymentMethodType, +} + +#[derive(Debug, serde::Serialize, serde::Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct ListCountriesCurrenciesResponse { + pub currencies: HashSet, + pub countries: HashSet, +} + +#[derive(Debug, serde::Serialize, serde::Deserialize, Eq, Hash, PartialEq)] +pub struct CountryCodeWithName { + pub code: api_enums::CountryAlpha2, + pub name: api_enums::Country, +} + #[derive(Debug, serde::Serialize, serde::Deserialize)] #[serde(rename_all = "camelCase")] pub struct TokenizedCardValue2 { diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs index 65842a4203da..bbabab3a4e74 100644 --- a/crates/common_enums/src/enums.rs +++ b/crates/common_enums/src/enums.rs @@ -1626,6 +1626,7 @@ pub enum DisputeStatus { serde::Deserialize, serde::Serialize, strum::Display, + strum::EnumIter, strum::EnumString, utoipa::ToSchema, Copy diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rs index 289654f93ed9..2a6c29ce8036 100644 --- a/crates/router/src/core/payment_methods/cards.rs +++ b/crates/router/src/core/payment_methods/cards.rs @@ -7,8 +7,9 @@ use api_models::{ admin::{self, PaymentMethodsEnabled}, enums::{self as api_enums}, payment_methods::{ - BankAccountTokenData, CardDetailsPaymentMethod, CardNetworkTypes, - CustomerDefaultPaymentMethodResponse, MaskedBankDetails, PaymentExperienceTypes, + BankAccountTokenData, CardDetailsPaymentMethod, CardNetworkTypes, CountryCodeWithName, + CustomerDefaultPaymentMethodResponse, ListCountriesCurrenciesRequest, + ListCountriesCurrenciesResponse, MaskedBankDetails, PaymentExperienceTypes, PaymentMethodsData, RequestPaymentMethodTypes, RequiredFieldInfo, ResponsePaymentMethodIntermediate, ResponsePaymentMethodTypes, ResponsePaymentMethodsEnabled, @@ -30,6 +31,7 @@ use domain::CustomerUpdate; use error_stack::{report, IntoReport, ResultExt}; use masking::Secret; use router_env::{instrument, tracing}; +use strum::IntoEnumIterator; use super::surcharge_decision_configs::{ perform_surcharge_decision_management_for_payment_method_list, @@ -3606,3 +3608,59 @@ pub async fn create_encrypted_payment_method_data( pm_data_encrypted } + +pub async fn list_countries_currencies_for_connector_payment_method( + state: routes::AppState, + req: ListCountriesCurrenciesRequest, +) -> errors::RouterResponse { + Ok(services::ApplicationResponse::Json( + list_countries_currencies_for_connector_payment_method_util( + state.conf.pm_filters.clone(), + req.connector, + req.payment_method_type, + ) + .await, + )) +} + +// This feature will be more efficient as a WASM function rather than as an API. +// So extracting this logic to a separate function so that it can be used in WASM as well. +pub async fn list_countries_currencies_for_connector_payment_method_util( + connector_filters: settings::ConnectorFilters, + connector: api_enums::Connector, + payment_method_type: api_enums::PaymentMethodType, +) -> ListCountriesCurrenciesResponse { + let payment_method_type = + settings::PaymentMethodFilterKey::PaymentMethodType(payment_method_type); + + let (currencies, country_codes) = connector_filters + .0 + .get(&connector.to_string()) + .and_then(|filter| filter.0.get(&payment_method_type)) + .map(|filter| (filter.currency.clone(), filter.country.clone())) + .unwrap_or_else(|| { + connector_filters + .0 + .get("default") + .and_then(|filter| filter.0.get(&payment_method_type)) + .map_or((None, None), |filter| { + (filter.currency.clone(), filter.country.clone()) + }) + }); + + let currencies = + currencies.unwrap_or_else(|| api_enums::Currency::iter().collect::>()); + let country_codes = + country_codes.unwrap_or_else(|| api_enums::CountryAlpha2::iter().collect::>()); + + ListCountriesCurrenciesResponse { + currencies, + countries: country_codes + .into_iter() + .map(|country_code| CountryCodeWithName { + code: country_code, + name: common_enums::Country::from_alpha2(country_code), + }) + .collect(), + } +} diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rs index a889a9c57440..01ed994a9d3b 100644 --- a/crates/router/src/routes/app.rs +++ b/crates/router/src/routes/app.rs @@ -19,8 +19,6 @@ use tokio::sync::oneshot; #[cfg(feature = "olap")] use super::blocklist; -#[cfg(any(feature = "olap", feature = "oltp"))] -use super::currency; #[cfg(feature = "dummy_connector")] use super::dummy_connector::*; #[cfg(feature = "payouts")] @@ -39,8 +37,10 @@ use super::{ use super::{cache::*, health::*}; #[cfg(any(feature = "olap", feature = "oltp"))] use super::{configs::*, customers::*, mandates::*, payments::*, refunds::*}; +#[cfg(any(feature = "olap", feature = "oltp"))] +use super::{currency, payment_methods::*}; #[cfg(feature = "oltp")] -use super::{ephemeral_key::*, payment_methods::*, webhooks::*}; +use super::{ephemeral_key::*, webhooks::*}; use crate::configs::secrets_transformers; #[cfg(all(feature = "frm", feature = "oltp"))] use crate::routes::fraud_check as frm_routes; @@ -738,24 +738,39 @@ impl Payouts { pub struct PaymentMethods; -#[cfg(feature = "oltp")] +#[cfg(any(feature = "olap", feature = "oltp"))] impl PaymentMethods { pub fn server(state: AppState) -> Scope { - web::scope("/payment_methods") - .app_data(web::Data::new(state)) - .service( - web::resource("") - .route(web::post().to(create_payment_method_api)) - .route(web::get().to(list_payment_method_api)), // TODO : added for sdk compatibility for now, need to deprecate this later - ) - .service( - web::resource("/{payment_method_id}") - .route(web::get().to(payment_method_retrieve_api)) - .route(web::post().to(payment_method_update_api)) - .route(web::delete().to(payment_method_delete_api)), - ) - .service(web::resource("/auth/link").route(web::post().to(pm_auth::link_token_create))) - .service(web::resource("/auth/exchange").route(web::post().to(pm_auth::exchange_token))) + let mut route = web::scope("/payment_methods").app_data(web::Data::new(state)); + #[cfg(feature = "olap")] + { + route = route.service( + web::resource("/filter") + .route(web::get().to(list_countries_currencies_for_connector_payment_method)), + ); + } + #[cfg(feature = "oltp")] + { + route = route + .service( + web::resource("") + .route(web::post().to(create_payment_method_api)) + .route(web::get().to(list_payment_method_api)), // TODO : added for sdk compatibility for now, need to deprecate this later + ) + .service( + web::resource("/{payment_method_id}") + .route(web::get().to(payment_method_retrieve_api)) + .route(web::post().to(payment_method_update_api)) + .route(web::delete().to(payment_method_delete_api)), + ) + .service( + web::resource("/auth/link").route(web::post().to(pm_auth::link_token_create)), + ) + .service( + web::resource("/auth/exchange").route(web::post().to(pm_auth::exchange_token)), + ) + } + route } } diff --git a/crates/router/src/routes/lock_utils.rs b/crates/router/src/routes/lock_utils.rs index 4826a72f9d1f..7908b9dfdca2 100644 --- a/crates/router/src/routes/lock_utils.rs +++ b/crates/router/src/routes/lock_utils.rs @@ -97,6 +97,7 @@ impl From for ApiIdentifier { | Flow::PaymentMethodsUpdate | Flow::PaymentMethodsDelete | Flow::ValidatePaymentMethod + | Flow::ListCountriesCurrencies | Flow::DefaultPaymentMethodsSet => Self::PaymentMethods, Flow::PmAuthLinkTokenCreate | Flow::PmAuthExchangeToken => Self::PaymentMethodAuth, diff --git a/crates/router/src/routes/payment_methods.rs b/crates/router/src/routes/payment_methods.rs index 1e2e66d583c1..7ef20994e2e4 100644 --- a/crates/router/src/routes/payment_methods.rs +++ b/crates/router/src/routes/payment_methods.rs @@ -8,7 +8,7 @@ use time::PrimitiveDateTime; use super::app::AppState; use crate::{ core::{api_locking, errors, payment_methods::cards}, - services::{api, authentication as auth}, + services::{api, authentication as auth, authorization::permissions::Permission}, types::{ api::payment_methods::{self, PaymentMethodId}, storage::payment_method::PaymentTokenData, @@ -262,6 +262,35 @@ pub async fn payment_method_delete_api( .await } +#[instrument(skip_all, fields(flow = ?Flow::ListCountriesCurrencies))] +pub async fn list_countries_currencies_for_connector_payment_method( + state: web::Data, + req: HttpRequest, + query_payload: web::Query, +) -> HttpResponse { + let flow = Flow::ListCountriesCurrencies; + let payload = query_payload.into_inner(); + Box::pin(api::server_wrap( + flow, + state, + &req, + payload, + |state, _auth: auth::AuthenticationData, req| { + cards::list_countries_currencies_for_connector_payment_method(state, req) + }, + #[cfg(not(feature = "release"))] + auth::auth_type( + &auth::ApiKeyAuth, + &auth::JWTAuth(Permission::MerchantConnectorAccountWrite), + req.headers(), + ), + #[cfg(feature = "release")] + &auth::JWTAuth(Permission::MerchantConnectorAccountWrite), + api_locking::LockAction::NotApplicable, + )) + .await +} + #[instrument(skip_all, fields(flow = ?Flow::DefaultPaymentMethodsSet))] pub async fn default_payment_method_set_api( state: web::Data, @@ -297,7 +326,6 @@ pub async fn default_payment_method_set_api( )) .await } - #[cfg(test)] mod tests { #![allow(clippy::unwrap_used)] diff --git a/crates/router/src/types/api/payment_methods.rs b/crates/router/src/types/api/payment_methods.rs index 642e94ad69e7..13c9ec61f2a5 100644 --- a/crates/router/src/types/api/payment_methods.rs +++ b/crates/router/src/types/api/payment_methods.rs @@ -1,11 +1,11 @@ pub use api_models::payment_methods::{ CardDetail, CardDetailFromLocker, CardDetailsPaymentMethod, CustomerPaymentMethod, CustomerPaymentMethodsListResponse, DefaultPaymentMethod, DeleteTokenizeByTokenRequest, - GetTokenizePayloadRequest, GetTokenizePayloadResponse, PaymentMethodCreate, - PaymentMethodDeleteResponse, PaymentMethodId, PaymentMethodList, PaymentMethodListRequest, - PaymentMethodListResponse, PaymentMethodResponse, PaymentMethodUpdate, PaymentMethodsData, - TokenizePayloadEncrypted, TokenizePayloadRequest, TokenizedCardValue1, TokenizedCardValue2, - TokenizedWalletValue1, TokenizedWalletValue2, + GetTokenizePayloadRequest, GetTokenizePayloadResponse, ListCountriesCurrenciesRequest, + PaymentMethodCreate, PaymentMethodDeleteResponse, PaymentMethodId, PaymentMethodList, + PaymentMethodListRequest, PaymentMethodListResponse, PaymentMethodResponse, + PaymentMethodUpdate, PaymentMethodsData, TokenizePayloadEncrypted, TokenizePayloadRequest, + TokenizedCardValue1, TokenizedCardValue2, TokenizedWalletValue1, TokenizedWalletValue2, }; use error_stack::report; diff --git a/crates/router_env/src/logger/types.rs b/crates/router_env/src/logger/types.rs index 363a41ad43aa..df322da9429f 100644 --- a/crates/router_env/src/logger/types.rs +++ b/crates/router_env/src/logger/types.rs @@ -117,6 +117,8 @@ pub enum Flow { CustomerPaymentMethodsList, /// List Customers for a merchant CustomersList, + /// Retrieve countries and currencies for connector and payment method + ListCountriesCurrencies, /// Payment methods retrieve flow. PaymentMethodsRetrieve, /// Payment methods update flow. From e8289f061d4735478cb1521de50f696d2412ad33 Mon Sep 17 00:00:00 2001 From: Pa1NarK <69745008+pixincreate@users.noreply.github.com> Date: Thu, 28 Mar 2024 13:30:37 +0530 Subject: [PATCH 03/19] chore(config): add billwerk base URL in deployment configs (#4243) --- config/deployments/integration_test.toml | 3 ++- config/deployments/production.toml | 3 ++- config/deployments/sandbox.toml | 13 +++++++------ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.toml index 6d4cc21c3a35..10776c766789 100644 --- a/config/deployments/integration_test.toml +++ b/config/deployments/integration_test.toml @@ -20,6 +20,7 @@ applepay.base_url = "https://apple-pay-gateway.apple.com/" authorizedotnet.base_url = "https://apitest.authorize.net/xml/v1/request.api" bambora.base_url = "https://api.na.bambora.com" bankofamerica.base_url = "https://apitest.merchant-services.bankofamerica.com/" +billwerk.base_url = "https://api.reepay.com/" bitpay.base_url = "https://test.bitpay.com" bluesnap.base_url = "https://sandbox.bluesnap.com/" bluesnap.secondary_base_url = "https://sandpay.bluesnap.com/" @@ -299,4 +300,4 @@ outgoing_enabled = true connectors_with_webhook_source_verification_call = "paypal" [unmasked_headers] -keys = "user-agent" \ No newline at end of file +keys = "user-agent" diff --git a/config/deployments/production.toml b/config/deployments/production.toml index 7c8105795b87..a6405e4a3b2d 100644 --- a/config/deployments/production.toml +++ b/config/deployments/production.toml @@ -24,6 +24,7 @@ applepay.base_url = "https://apple-pay-gateway.apple.com/" authorizedotnet.base_url = "https://api.authorize.net/xml/v1/request.api" bambora.base_url = "https://api.na.bambora.com" bankofamerica.base_url = "https://api.merchant-services.bankofamerica.com/" +billwerk.base_url = "https://api.reepay.com/" bitpay.base_url = "https://bitpay.com" bluesnap.base_url = "https://ws.bluesnap.com/" bluesnap.secondary_base_url = "https://pay.bluesnap.com/" @@ -313,4 +314,4 @@ outgoing_enabled = true connectors_with_webhook_source_verification_call = "paypal" [unmasked_headers] -keys = "user-agent" \ No newline at end of file +keys = "user-agent" diff --git a/config/deployments/sandbox.toml b/config/deployments/sandbox.toml index faf329db74cc..035c90af3789 100644 --- a/config/deployments/sandbox.toml +++ b/config/deployments/sandbox.toml @@ -24,6 +24,7 @@ applepay.base_url = "https://apple-pay-gateway.apple.com/" authorizedotnet.base_url = "https://apitest.authorize.net/xml/v1/request.api" bambora.base_url = "https://api.na.bambora.com" bankofamerica.base_url = "https://apitest.merchant-services.bankofamerica.com/" +billwerk.base_url = "https://api.reepay.com/" bitpay.base_url = "https://test.bitpay.com" bluesnap.base_url = "https://sandbox.bluesnap.com/" bluesnap.secondary_base_url = "https://sandpay.bluesnap.com/" @@ -123,8 +124,8 @@ bank_redirect.sofort.connector_list = "stripe,adyen,globalpay" bank_redirect.giropay.connector_list = "adyen,globalpay" [mandates.update_mandate_supported] -card.credit ={connector_list ="cybersource"} -card.debit = {connector_list ="cybersource"} +card.credit = { connector_list = "cybersource" } +card.debit = { connector_list = "cybersource" } [multiple_api_version_supported_connectors] supported_connectors = "braintree" @@ -190,7 +191,7 @@ google_pay = { country = "AU,NZ,JP,HK,SG,MY,TH,VN,BH,AE,KW,BR,ES,GB,SE,NO,SK,AT, ideal = { country = "NL", currency = "EUR" } indomaret = { country = "ID", currency = "IDR" } kakao_pay = { country = "KR", currency = "KRW" } -klarna = { country = "AU,AT,BE,CA,CZ,DK,FI,FR,DE,GR,IE,IT,NO,PL,PT,RO,ES,SE,CH,NL,GB,US", currency = "AUD,EUR,CAD,CZK,DKK,NOK,PLN,RON,SEK,CHF,GBP,USD"} +klarna = { country = "AU,AT,BE,CA,CZ,DK,FI,FR,DE,GR,IE,IT,NO,PL,PT,RO,ES,SE,CH,NL,GB,US", currency = "AUD,EUR,CAD,CZK,DKK,NOK,PLN,RON,SEK,CHF,GBP,USD" } lawson = { country = "JP", currency = "JPY" } mandiri_va = { country = "ID", currency = "IDR" } mb_way = { country = "PT", currency = "EUR" } @@ -214,7 +215,7 @@ permata_bank_transfer = { country = "ID", currency = "IDR" } seicomart = { country = "JP", currency = "JPY" } sepa = { country = "ES,SK,AT,NL,DE,BE,FR,FI,PT,IE,EE,LT,LV,IT", currency = "EUR" } seven_eleven = { country = "JP", currency = "JPY" } -sofort = { country = "AT,BE,DE,ES,CH,NL", currency = "CHF,EUR"} +sofort = { country = "AT,BE,DE,ES,CH,NL", currency = "CHF,EUR" } swish = { country = "SE", currency = "SEK" } touch_n_go = { country = "MY", currency = "MYR" } trustly = { country = "ES,GB,SE,NO,AT,NL,DE,DK,FI,EE,LT,LV", currency = "CZK,DKK,EUR,GBP,NOK,SEK" } @@ -271,7 +272,7 @@ klarna = { country = "AU,AT,BE,CA,CZ,DK,FI,FR,DE,GR,IE,IT,NL,NZ,NO,PL,PT,ES,SE,C sofort = { country = "AT,BE,DE,IT,NL,ES", currency = "EUR" } [pm_filters.volt] -open_banking_uk = {country = "DE,GB,AT,BE,CY,EE,ES,FI,FR,GR,HR,IE,IT,LT,LU,LV,MT,NL,PT,SI,SK,BG,CZ,DK,HU,NO,PL,RO,SE,AU,BR", currency = "EUR,GBP,DKK,NOK,PLN,SEK,AUD,BRL"} +open_banking_uk = { country = "DE,GB,AT,BE,CY,EE,ES,FI,FR,GR,HR,IE,IT,LT,LU,LV,MT,NL,PT,SI,SK,BG,CZ,DK,HU,NO,PL,RO,SE,AU,BR", currency = "EUR,GBP,DKK,NOK,PLN,SEK,AUD,BRL" } [pm_filters.worldpay] apple_pay.country = "AU,CN,HK,JP,MO,MY,NZ,SG,TW,AM,AT,AZ,BY,BE,BG,HR,CY,CZ,DK,EE,FO,FI,FR,GE,DE,GR,GL,GG,HU,IS,IE,IM,IT,KZ,JE,LV,LI,LT,LU,MT,MD,MC,ME,NL,NO,PL,PT,RO,SM,RS,SK,SI,ES,SE,CH,UA,GB,AR,CO,CR,BR,MX,PE,BH,IL,JO,KW,PS,QA,SA,AE,CA,UM,US" @@ -315,4 +316,4 @@ outgoing_enabled = true connectors_with_webhook_source_verification_call = "paypal" [unmasked_headers] -keys = "user-agent" \ No newline at end of file +keys = "user-agent" From ffb3f4be012bcbb186ad19ba895fb8cfc04c63c2 Mon Sep 17 00:00:00 2001 From: Sanchith Hegde <22217505+SanchithHegde@users.noreply.github.com> Date: Thu, 28 Mar 2024 15:50:28 +0530 Subject: [PATCH 04/19] ci(CI-pr): determine modified crates more deterministically (#4233) --- .github/workflows/CI-pr.yml | 12 ++++++++++-- crates/api_models/src/bank_accounts.rs | 1 - crates/api_models/src/lib.rs | 1 - 3 files changed, 10 insertions(+), 4 deletions(-) delete mode 100644 crates/api_models/src/bank_accounts.rs diff --git a/.github/workflows/CI-pr.yml b/.github/workflows/CI-pr.yml index efeb31cd1e88..9794afc155dc 100644 --- a/.github/workflows/CI-pr.yml +++ b/.github/workflows/CI-pr.yml @@ -141,7 +141,11 @@ jobs: # Obtain a list of workspace members workspace_members="$( cargo metadata --format-version 1 --no-deps \ - | jq --compact-output --monochrome-output --raw-output '.workspace_members | sort | .[] | split(" ")[0]' + | jq \ + --compact-output \ + --monochrome-output \ + --raw-output \ + '(.workspace_members | sort) as $package_ids | .packages[] | select(IN(.id; $package_ids[])) | .name' )" PACKAGES_CHECKED=() @@ -298,7 +302,11 @@ jobs: # Obtain a list of workspace members workspace_members="$( cargo metadata --format-version 1 --no-deps \ - | jq --compact-output --monochrome-output --raw-output '.workspace_members | sort | .[] | split(" ")[0]' + | jq \ + --compact-output \ + --monochrome-output \ + --raw-output \ + '(.workspace_members | sort) as $package_ids | .packages[] | select(IN(.id; $package_ids[])) | .name' )" PACKAGES_CHECKED=() diff --git a/crates/api_models/src/bank_accounts.rs b/crates/api_models/src/bank_accounts.rs deleted file mode 100644 index 8b137891791f..000000000000 --- a/crates/api_models/src/bank_accounts.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/crates/api_models/src/lib.rs b/crates/api_models/src/lib.rs index cc991d7a6b85..89097705a40f 100644 --- a/crates/api_models/src/lib.rs +++ b/crates/api_models/src/lib.rs @@ -2,7 +2,6 @@ pub mod admin; pub mod analytics; pub mod api_keys; -pub mod bank_accounts; pub mod blocklist; pub mod cards_info; pub mod conditional_configs; From 7b337ac39d72f90dd0ebe58133218896ff279313 Mon Sep 17 00:00:00 2001 From: Chethan Rao <70657455+Chethan-rao@users.noreply.github.com> Date: Thu, 28 Mar 2024 18:12:30 +0530 Subject: [PATCH 05/19] feat(mandates): allow off-session payments using `payment_method_id` (#4132) Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> --- crates/api_models/src/mandates.rs | 7 + crates/api_models/src/payments.rs | 21 +- crates/openapi/src/openapi.rs | 1 + crates/router/src/core/mandate/helpers.rs | 19 +- crates/router/src/core/payments.rs | 148 ++++++------ crates/router/src/core/payments/helpers.rs | 219 ++++++++++++------ .../payments/operations/payment_approve.rs | 1 + .../payments/operations/payment_cancel.rs | 1 + .../payments/operations/payment_capture.rs | 1 + .../operations/payment_complete_authorize.rs | 20 +- .../payments/operations/payment_confirm.rs | 18 +- .../payments/operations/payment_create.rs | 28 ++- .../payments/operations/payment_reject.rs | 1 + .../payments/operations/payment_session.rs | 1 + .../core/payments/operations/payment_start.rs | 1 + .../payments/operations/payment_status.rs | 1 + .../payments/operations/payment_update.rs | 33 ++- .../payments_incremental_authorization.rs | 1 + crates/router/src/types/api/payments.rs | 5 +- openapi/openapi_spec.json | 75 ++++++ 20 files changed, 429 insertions(+), 173 deletions(-) diff --git a/crates/api_models/src/mandates.rs b/crates/api_models/src/mandates.rs index bd5c5b5a1a02..4adda0d9af45 100644 --- a/crates/api_models/src/mandates.rs +++ b/crates/api_models/src/mandates.rs @@ -113,3 +113,10 @@ pub struct MandateListConstraints { #[serde(rename = "created_time.gte")] pub created_time_gte: Option, } + +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)] +#[serde(tag = "type", content = "data", rename_all = "snake_case")] +pub enum RecurringDetails { + MandateId(String), + PaymentMethodId(String), +} diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs index ce2b1c3d68a3..72592ec3cad7 100644 --- a/crates/api_models/src/payments.rs +++ b/crates/api_models/src/payments.rs @@ -19,10 +19,8 @@ use url::Url; use utoipa::ToSchema; use crate::{ - admin, disputes, - enums::{self as api_enums}, - ephemeral_key::EphemeralKeyCreateResponse, - refunds, + admin, disputes, enums as api_enums, ephemeral_key::EphemeralKeyCreateResponse, + mandates::RecurringDetails, refunds, }; #[derive(Clone, Copy, Debug, Eq, PartialEq)] @@ -459,6 +457,9 @@ pub struct PaymentsRequest { /// Whether to perform external authentication (if applicable) #[schema(example = true)] pub request_external_three_ds_authentication: Option, + + /// Details required for recurring payment + pub recurring_details: Option, } impl PaymentsRequest { @@ -3360,7 +3361,7 @@ pub struct PaymentsRedirectionResponse { } pub struct MandateValidationFields { - pub mandate_id: Option, + pub recurring_details: Option, pub confirm: Option, pub customer_id: Option, pub mandate_data: Option, @@ -3370,8 +3371,14 @@ pub struct MandateValidationFields { impl From<&PaymentsRequest> for MandateValidationFields { fn from(req: &PaymentsRequest) -> Self { + let recurring_details = req + .mandate_id + .clone() + .map(RecurringDetails::MandateId) + .or(req.recurring_details.clone()); + Self { - mandate_id: req.mandate_id.clone(), + recurring_details, confirm: req.confirm, customer_id: req .customer @@ -3389,7 +3396,7 @@ impl From<&PaymentsRequest> for MandateValidationFields { impl From<&VerifyRequest> for MandateValidationFields { fn from(req: &VerifyRequest) -> Self { Self { - mandate_id: None, + recurring_details: None, confirm: Some(true), customer_id: req.customer_id.clone(), mandate_data: req.mandate_data.clone(), diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rs index c8e89f2ee70a..4a61a20d08d0 100644 --- a/crates/openapi/src/openapi.rs +++ b/crates/openapi/src/openapi.rs @@ -410,6 +410,7 @@ Never share your secret api keys. Keep them guarded and secure. api_models::mandates::MandateRevokedResponse, api_models::mandates::MandateResponse, api_models::mandates::MandateCardDetails, + api_models::mandates::RecurringDetails, api_models::ephemeral_key::EphemeralKeyCreateResponse, api_models::payments::CustomerDetails, api_models::payments::GiftCardData, diff --git a/crates/router/src/core/mandate/helpers.rs b/crates/router/src/core/mandate/helpers.rs index 150130ed9e5d..704b7ae99f55 100644 --- a/crates/router/src/core/mandate/helpers.rs +++ b/crates/router/src/core/mandate/helpers.rs @@ -1,8 +1,14 @@ +use common_enums::enums; use common_utils::errors::CustomResult; +use data_models::mandates::MandateData; use diesel_models::Mandate; use error_stack::ResultExt; -use crate::{core::errors, routes::AppState, types::domain}; +use crate::{ + core::{errors, payments}, + routes::AppState, + types::domain, +}; pub async fn get_profile_id_for_mandate( state: &AppState, @@ -33,3 +39,14 @@ pub async fn get_profile_id_for_mandate( }?; Ok(profile_id) } + +#[derive(Clone)] +pub struct MandateGenericData { + pub token: Option, + pub payment_method: Option, + pub payment_method_type: Option, + pub mandate_data: Option, + pub recurring_mandate_payment_data: Option, + pub mandate_connector: Option, + pub payment_method_info: Option, +} diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs index 0a3a93923b73..e11a77496afd 100644 --- a/crates/router/src/core/payments.rs +++ b/crates/router/src/core/payments.rs @@ -15,6 +15,7 @@ use std::{fmt::Debug, marker::PhantomData, ops::Deref, time::Instant, vec::IntoI use api_models::{ self, enums, + mandates::RecurringDetails, payments::{self as payments_api, HeaderPayload}, }; use common_utils::{ext_traits::AsyncExt, pii, types::Surcharge}; @@ -2263,6 +2264,7 @@ where pub authorizations: Vec, pub authentication: Option, pub frm_metadata: Option, + pub recurring_details: Option, } #[derive(Debug, Default, Clone)] @@ -2907,7 +2909,7 @@ where .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Invalid connector name received")?; - return decide_connector_for_token_based_mit_flow( + return decide_multiplex_connector_for_normal_or_recurring_payment( payment_data, routing_data, connector_data, @@ -2961,7 +2963,7 @@ where .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Invalid connector name received")?; - return decide_connector_for_token_based_mit_flow( + return decide_multiplex_connector_for_normal_or_recurring_payment( payment_data, routing_data, connector_data, @@ -2980,24 +2982,26 @@ where .await } -pub fn decide_connector_for_token_based_mit_flow( +pub fn decide_multiplex_connector_for_normal_or_recurring_payment( payment_data: &mut PaymentData, routing_data: &mut storage::RoutingData, connectors: Vec, ) -> RouterResult { - if let Some((storage_enums::FutureUsage::OffSession, _)) = payment_data - .payment_intent - .setup_future_usage - .zip(payment_data.token_data.as_ref()) - { - logger::debug!("performing routing for token-based MIT flow"); + match ( + payment_data.payment_intent.setup_future_usage, + payment_data.token_data.as_ref(), + payment_data.recurring_details.as_ref(), + ) { + (Some(storage_enums::FutureUsage::OffSession), Some(_), None) + | (None, None, Some(RecurringDetails::PaymentMethodId(_))) => { + logger::debug!("performing routing for token-based MIT flow"); - let payment_method_info = payment_data - .payment_method_info - .as_ref() - .get_required_value("payment_method_info")?; + let payment_method_info = payment_data + .payment_method_info + .as_ref() + .get_required_value("payment_method_info")?; - let connector_mandate_details = payment_method_info + let connector_mandate_details = payment_method_info .connector_mandate_details .clone() .map(|details| { @@ -3010,67 +3014,69 @@ pub fn decide_connector_for_token_based_mit_flow( .change_context(errors::ApiErrorResponse::IncorrectPaymentMethodConfiguration) .attach_printable("no eligible connector found for token-based MIT flow since there were no connector mandate details")?; - let mut connector_choice = None; - for connector_data in connectors { - if let Some(merchant_connector_id) = connector_data.merchant_connector_id.as_ref() { - if let Some(mandate_reference_record) = - connector_mandate_details.get(merchant_connector_id) - { - connector_choice = Some((connector_data, mandate_reference_record.clone())); - break; + let mut connector_choice = None; + for connector_data in connectors { + if let Some(merchant_connector_id) = connector_data.merchant_connector_id.as_ref() { + if let Some(mandate_reference_record) = + connector_mandate_details.get(merchant_connector_id) + { + connector_choice = Some((connector_data, mandate_reference_record.clone())); + break; + } } } - } - let (chosen_connector_data, mandate_reference_record) = connector_choice - .get_required_value("connector_choice") - .change_context(errors::ApiErrorResponse::IncorrectPaymentMethodConfiguration) - .attach_printable("no eligible connector found for token-based MIT payment")?; + let (chosen_connector_data, mandate_reference_record) = connector_choice + .get_required_value("connector_choice") + .change_context(errors::ApiErrorResponse::IncorrectPaymentMethodConfiguration) + .attach_printable("no eligible connector found for token-based MIT payment")?; - routing_data.routed_through = Some(chosen_connector_data.connector_name.to_string()); - #[cfg(feature = "connector_choice_mca_id")] - { - routing_data.merchant_connector_id = - chosen_connector_data.merchant_connector_id.clone(); - } + routing_data.routed_through = Some(chosen_connector_data.connector_name.to_string()); + #[cfg(feature = "connector_choice_mca_id")] + { + routing_data.merchant_connector_id = + chosen_connector_data.merchant_connector_id.clone(); + } - payment_data.mandate_id = Some(payments_api::MandateIds { - mandate_id: None, - mandate_reference_id: Some(payments_api::MandateReferenceId::ConnectorMandateId( - payments_api::ConnectorMandateReferenceId { - connector_mandate_id: Some( - mandate_reference_record.connector_mandate_id.clone(), - ), - payment_method_id: Some(payment_method_info.payment_method_id.clone()), - update_history: None, - }, - )), - }); - - payment_data.recurring_mandate_payment_data = Some(RecurringMandatePaymentData { - payment_method_type: mandate_reference_record.payment_method_type, - original_payment_authorized_amount: mandate_reference_record - .original_payment_authorized_amount, - original_payment_authorized_currency: mandate_reference_record - .original_payment_authorized_currency, - }); - - Ok(api::ConnectorCallType::PreDetermined(chosen_connector_data)) - } else { - let first_choice = connectors - .first() - .ok_or(errors::ApiErrorResponse::IncorrectPaymentMethodConfiguration) - .into_report() - .attach_printable("no eligible connector found for payment")? - .clone(); - - routing_data.routed_through = Some(first_choice.connector_name.to_string()); - #[cfg(feature = "connector_choice_mca_id")] - { - routing_data.merchant_connector_id = first_choice.merchant_connector_id; + payment_data.mandate_id = Some(payments_api::MandateIds { + mandate_id: None, + mandate_reference_id: Some(payments_api::MandateReferenceId::ConnectorMandateId( + payments_api::ConnectorMandateReferenceId { + connector_mandate_id: Some( + mandate_reference_record.connector_mandate_id.clone(), + ), + payment_method_id: Some(payment_method_info.payment_method_id.clone()), + update_history: None, + }, + )), + }); + + payment_data.recurring_mandate_payment_data = Some(RecurringMandatePaymentData { + payment_method_type: mandate_reference_record.payment_method_type, + original_payment_authorized_amount: mandate_reference_record + .original_payment_authorized_amount, + original_payment_authorized_currency: mandate_reference_record + .original_payment_authorized_currency, + }); + + Ok(api::ConnectorCallType::PreDetermined(chosen_connector_data)) } + _ => { + let first_choice = connectors + .first() + .ok_or(errors::ApiErrorResponse::IncorrectPaymentMethodConfiguration) + .into_report() + .attach_printable("no eligible connector found for payment")? + .clone(); + + routing_data.routed_through = Some(first_choice.connector_name.to_string()); + #[cfg(feature = "connector_choice_mca_id")] + { + routing_data.merchant_connector_id = first_choice.merchant_connector_id; + } - Ok(api::ConnectorCallType::Retryable(connectors)) + Ok(api::ConnectorCallType::Retryable(connectors)) + } } } @@ -3291,7 +3297,11 @@ where match transaction_data { TransactionData::Payment(payment_data) => { - decide_connector_for_token_based_mit_flow(payment_data, routing_data, connector_data) + decide_multiplex_connector_for_normal_or_recurring_payment( + payment_data, + routing_data, + connector_data, + ) } #[cfg(feature = "payouts")] diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs index 7eab4c0d26ac..e9cefbf8aed5 100644 --- a/crates/router/src/core/payments/helpers.rs +++ b/crates/router/src/core/payments/helpers.rs @@ -1,6 +1,9 @@ use std::borrow::Cow; -use api_models::payments::{CardToken, GetPaymentMethodType, RequestSurchargeDetails}; +use api_models::{ + mandates::RecurringDetails, + payments::{CardToken, GetPaymentMethodType, RequestSurchargeDetails}, +}; use base64::Engine; use common_utils::{ ext_traits::{AsyncExt, ByteSliceExt, Encode, ValueExt}, @@ -34,6 +37,7 @@ use crate::{ consts::{self, BASE64_ENGINE}, core::{ errors::{self, CustomResult, RouterResult, StorageErrorExt}, + mandate::helpers::MandateGenericData, payment_methods::{cards, vault, PaymentMethodRetrieve}, payments, pm_auth::retrieve_payment_method_from_auth_service, @@ -414,59 +418,117 @@ pub async fn get_token_pm_type_mandate_details( mandate_type: Option, merchant_account: &domain::MerchantAccount, merchant_key_store: &domain::MerchantKeyStore, -) -> RouterResult<( - Option, - Option, - Option, - Option, - Option, - Option, -)> { +) -> RouterResult { let mandate_data = request.mandate_data.clone().map(MandateData::foreign_from); - match mandate_type { - Some(api::MandateTransactionType::NewMandateTransaction) => { - let setup_mandate = mandate_data.clone().get_required_value("mandate_data")?; - Ok(( - request.payment_token.to_owned(), - request.payment_method, - request.payment_method_type, - Some(setup_mandate), - None, - None, - )) - } + let ( + payment_token, + payment_method, + payment_method_type, + mandate_data, + recurring_payment_data, + mandate_connector_details, + payment_method_info, + ) = match mandate_type { + Some(api::MandateTransactionType::NewMandateTransaction) => ( + request.payment_token.to_owned(), + request.payment_method, + request.payment_method_type, + Some(mandate_data.clone().get_required_value("mandate_data")?), + None, + None, + None, + ), Some(api::MandateTransactionType::RecurringMandateTransaction) => { - let ( - token_, - payment_method_, - recurring_mandate_payment_data, - payment_method_type_, - mandate_connector, - ) = get_token_for_recurring_mandate( - state, - request, - merchant_account, - merchant_key_store, - ) - .await?; - Ok(( - token_, - payment_method_, - payment_method_type_.or(request.payment_method_type), - None, - recurring_mandate_payment_data, - mandate_connector, - )) + match &request.recurring_details { + Some(recurring_details) => match recurring_details { + RecurringDetails::MandateId(mandate_id) => { + let mandate_generic_data = get_token_for_recurring_mandate( + state, + request, + merchant_account, + merchant_key_store, + mandate_id.to_owned(), + ) + .await?; + + ( + mandate_generic_data.token, + mandate_generic_data.payment_method, + mandate_generic_data + .payment_method_type + .or(request.payment_method_type), + None, + mandate_generic_data.recurring_mandate_payment_data, + mandate_generic_data.mandate_connector, + None, + ) + } + RecurringDetails::PaymentMethodId(payment_method_id) => { + let payment_method_info = state + .store + .find_payment_method(payment_method_id) + .await + .to_not_found_response( + errors::ApiErrorResponse::PaymentMethodNotFound, + )?; + + ( + None, + Some(payment_method_info.payment_method), + payment_method_info.payment_method_type, + None, + None, + None, + Some(payment_method_info), + ) + } + }, + None => { + let mandate_id = request + .mandate_id + .clone() + .get_required_value("mandate_id")?; + let mandate_generic_data = get_token_for_recurring_mandate( + state, + request, + merchant_account, + merchant_key_store, + mandate_id, + ) + .await?; + ( + mandate_generic_data.token, + mandate_generic_data.payment_method, + mandate_generic_data + .payment_method_type + .or(request.payment_method_type), + None, + mandate_generic_data.recurring_mandate_payment_data, + mandate_generic_data.mandate_connector, + None, + ) + } + } } - None => Ok(( + None => ( request.payment_token.to_owned(), request.payment_method, request.payment_method_type, mandate_data, None, None, - )), - } + None, + ), + }; + Ok(MandateGenericData { + token: payment_token, + payment_method, + payment_method_type, + mandate_data, + recurring_mandate_payment_data: recurring_payment_data, + mandate_connector: mandate_connector_details, + payment_method_info, + }) } pub async fn get_token_for_recurring_mandate( @@ -474,15 +536,9 @@ pub async fn get_token_for_recurring_mandate( req: &api::PaymentsRequest, merchant_account: &domain::MerchantAccount, merchant_key_store: &domain::MerchantKeyStore, -) -> RouterResult<( - Option, - Option, - Option, - Option, - Option, -)> { + mandate_id: String, +) -> RouterResult { let db = &*state.store; - let mandate_id = req.mandate_id.clone().get_required_value("mandate_id")?; let mandate = db .find_mandate_by_merchant_id_mandate_id(&merchant_account.merchant_id, mandate_id.as_str()) @@ -566,29 +622,33 @@ pub async fn get_token_for_recurring_mandate( } }; - Ok(( - Some(token), - Some(payment_method.payment_method), - Some(payments::RecurringMandatePaymentData { + Ok(MandateGenericData { + token: Some(token), + payment_method: Some(payment_method.payment_method), + recurring_mandate_payment_data: Some(payments::RecurringMandatePaymentData { payment_method_type, original_payment_authorized_amount, original_payment_authorized_currency, }), - payment_method.payment_method_type, - Some(mandate_connector_details), - )) + payment_method_type: payment_method.payment_method_type, + mandate_connector: Some(mandate_connector_details), + mandate_data: None, + payment_method_info: None, + }) } else { - Ok(( - None, - Some(payment_method.payment_method), - Some(payments::RecurringMandatePaymentData { + Ok(MandateGenericData { + token: None, + payment_method: Some(payment_method.payment_method), + recurring_mandate_payment_data: Some(payments::RecurringMandatePaymentData { payment_method_type, original_payment_authorized_amount, original_payment_authorized_currency, }), - payment_method.payment_method_type, - Some(mandate_connector_details), - )) + payment_method_type: payment_method.payment_method_type, + mandate_connector: Some(mandate_connector_details), + mandate_data: None, + payment_method_info: None, + }) } } @@ -792,7 +852,7 @@ pub fn validate_mandate( let req: api::MandateValidationFields = req.into(); match req.validate_and_get_mandate_type().change_context( errors::ApiErrorResponse::MandateValidationFailed { - reason: "Expected one out of mandate_id and mandate_data but got both".into(), + reason: "Expected one out of recurring_details and mandate_data but got both".into(), }, )? { Some(api::MandateTransactionType::NewMandateTransaction) => { @@ -809,6 +869,23 @@ pub fn validate_mandate( } } +pub fn validate_recurring_details_and_token( + recurring_details: &Option, + payment_token: &Option, +) -> CustomResult<(), errors::ApiErrorResponse> { + utils::when( + recurring_details.is_some() && payment_token.is_some(), + || { + Err(report!(errors::ApiErrorResponse::PreconditionFailed { + message: "Expected one out of recurring_details and payment_token but got both" + .into() + })) + }, + )?; + + Ok(()) +} + fn validate_new_mandate_request( req: api::MandateValidationFields, is_confirm_operation: bool, @@ -940,7 +1017,8 @@ pub fn create_complete_authorize_url( } fn validate_recurring_mandate(req: api::MandateValidationFields) -> RouterResult<()> { - req.mandate_id.check_value_present("mandate_id")?; + req.recurring_details + .check_value_present("recurring_details")?; req.customer_id.check_value_present("customer_id")?; @@ -1950,7 +2028,8 @@ pub(crate) fn validate_payment_method_fields_present( utils::when( req.payment_method.is_some() && req.payment_method_data.is_none() - && req.payment_token.is_none(), + && req.payment_token.is_none() + && req.recurring_details.is_none(), || { Err(errors::ApiErrorResponse::MissingRequiredField { field_name: "payment_method_data", diff --git a/crates/router/src/core/payments/operations/payment_approve.rs b/crates/router/src/core/payments/operations/payment_approve.rs index 65b856364cc5..a2132bed8c1e 100644 --- a/crates/router/src/core/payments/operations/payment_approve.rs +++ b/crates/router/src/core/payments/operations/payment_approve.rs @@ -178,6 +178,7 @@ impl authorizations: vec![], frm_metadata: None, authentication: None, + recurring_details: None, }; let get_trackers_response = operations::GetTrackerResponse { diff --git a/crates/router/src/core/payments/operations/payment_cancel.rs b/crates/router/src/core/payments/operations/payment_cancel.rs index b25c0e2b9090..ab5feb5d9b56 100644 --- a/crates/router/src/core/payments/operations/payment_cancel.rs +++ b/crates/router/src/core/payments/operations/payment_cancel.rs @@ -187,6 +187,7 @@ impl authorizations: vec![], frm_metadata: None, authentication: None, + recurring_details: None, }; let get_trackers_response = operations::GetTrackerResponse { diff --git a/crates/router/src/core/payments/operations/payment_capture.rs b/crates/router/src/core/payments/operations/payment_capture.rs index 47d339f15be3..4445589f42f8 100644 --- a/crates/router/src/core/payments/operations/payment_capture.rs +++ b/crates/router/src/core/payments/operations/payment_capture.rs @@ -231,6 +231,7 @@ impl authorizations: vec![], frm_metadata: None, authentication: None, + recurring_details: None, }; let get_trackers_response = operations::GetTrackerResponse { diff --git a/crates/router/src/core/payments/operations/payment_complete_authorize.rs b/crates/router/src/core/payments/operations/payment_complete_authorize.rs index 8a773904ea32..b788ebc95f72 100644 --- a/crates/router/src/core/payments/operations/payment_complete_authorize.rs +++ b/crates/router/src/core/payments/operations/payment_complete_authorize.rs @@ -10,6 +10,7 @@ use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, Valida use crate::{ core::{ errors::{self, CustomResult, RouterResult, StorageErrorExt}, + mandate::helpers::MandateGenericData, payment_methods::PaymentMethodRetrieve, payments::{self, helpers, operations, CustomerDetails, PaymentAddress, PaymentData}, utils as core_utils, @@ -71,17 +72,18 @@ impl "confirm", )?; - let ( + let MandateGenericData { token, payment_method, payment_method_type, - setup_mandate, + mandate_data, recurring_mandate_payment_data, mandate_connector, - ) = helpers::get_token_pm_type_mandate_details( + payment_method_info, + } = helpers::get_token_pm_type_mandate_details( state, request, - mandate_type.clone(), + mandate_type.to_owned(), merchant_account, key_store, ) @@ -225,7 +227,7 @@ impl payment_intent.metadata = request.metadata.clone().or(payment_intent.metadata); // The operation merges mandate data from both request and payment_attempt - let setup_mandate = setup_mandate.map(Into::into); + let setup_mandate = mandate_data.map(Into::into); let mandate_details_present = payment_attempt.mandate_details.is_some() || request.mandate_data.is_some(); @@ -270,7 +272,7 @@ impl .payment_method_data .as_ref() .map(|pmd| pmd.payment_method_data.clone()), - payment_method_info: None, + payment_method_info, force_sync: None, refunds: vec![], disputes: vec![], @@ -291,6 +293,7 @@ impl authorizations: vec![], authentication: None, frm_metadata: None, + recurring_details: request.recurring_details.clone(), }; let customer_details = Some(CustomerDetails { @@ -455,6 +458,11 @@ impl ValidateRequest .setup_future_usage .or(payment_intent.setup_future_usage); - let ( + let MandateGenericData { token, payment_method, payment_method_type, - mut setup_mandate, + mandate_data, recurring_mandate_payment_data, mandate_connector, - ) = mandate_details; + payment_method_info, + } = mandate_details; let browser_info = request .browser_info @@ -406,7 +408,7 @@ impl (Some(token_data), payment_method_info) } else { - (None, None) + (None, payment_method_info) }; payment_attempt.payment_method = payment_method.or(payment_attempt.payment_method); @@ -478,7 +480,7 @@ impl .or(payment_attempt.business_sub_label); // The operation merges mandate data from both request and payment_attempt - setup_mandate = setup_mandate.map(|mut sm| { + let setup_mandate = mandate_data.map(|mut sm| { sm.mandate_type = payment_attempt.mandate_details.clone().or(sm.mandate_type); sm.update_mandate_id = payment_attempt .mandate_data @@ -619,6 +621,7 @@ impl authorizations: vec![], frm_metadata: request.frm_metadata.clone(), authentication, + recurring_details: request.recurring_details.clone(), }; let get_trackers_response = operations::GetTrackerResponse { @@ -1199,6 +1202,11 @@ impl ValidateRequest })? }; - let ( + let MandateGenericData { token, payment_method, payment_method_type, - setup_mandate, + mandate_data, recurring_mandate_payment_data, mandate_connector, - ) = helpers::get_token_pm_type_mandate_details( + payment_method_info, + } = helpers::get_token_pm_type_mandate_details( state, request, mandate_type, @@ -291,6 +293,14 @@ impl let mandate_id = request .mandate_id .as_ref() + .or_else(|| { + request.recurring_details + .as_ref() + .and_then(|recurring_details| match recurring_details { + RecurringDetails::MandateId(id) => Some(id), + _ => None, + }) + }) .async_and_then(|mandate_id| async { let mandate = db .find_mandate_by_merchant_id_mandate_id(merchant_id, mandate_id) @@ -359,7 +369,7 @@ impl .transpose()?; // The operation merges mandate data from both request and payment_attempt - let setup_mandate = setup_mandate.map(MandateData::from); + let setup_mandate = mandate_data.map(MandateData::from); let customer_acceptance = request.customer_acceptance.clone().map(From::from); @@ -398,7 +408,7 @@ impl token_data: None, confirm: request.confirm, payment_method_data: payment_method_data_after_card_bin_call, - payment_method_info: None, + payment_method_info, refunds: vec![], disputes: vec![], attempts: None, @@ -419,6 +429,7 @@ impl authorizations: vec![], authentication: None, frm_metadata: request.frm_metadata.clone(), + recurring_details: request.recurring_details.clone(), }; let get_trackers_response = operations::GetTrackerResponse { @@ -676,6 +687,11 @@ impl ValidateRequest authorizations: vec![], authentication: None, frm_metadata: None, + recurring_details: None, }; let get_trackers_response = operations::GetTrackerResponse { diff --git a/crates/router/src/core/payments/operations/payment_session.rs b/crates/router/src/core/payments/operations/payment_session.rs index 805b5fb36306..25b419e3222f 100644 --- a/crates/router/src/core/payments/operations/payment_session.rs +++ b/crates/router/src/core/payments/operations/payment_session.rs @@ -199,6 +199,7 @@ impl authorizations: vec![], authentication: None, frm_metadata: None, + recurring_details: None, }; let get_trackers_response = operations::GetTrackerResponse { diff --git a/crates/router/src/core/payments/operations/payment_start.rs b/crates/router/src/core/payments/operations/payment_start.rs index 520336be0e1a..465a2e5818dc 100644 --- a/crates/router/src/core/payments/operations/payment_start.rs +++ b/crates/router/src/core/payments/operations/payment_start.rs @@ -186,6 +186,7 @@ impl authorizations: vec![], authentication: None, frm_metadata: None, + recurring_details: None, }; let get_trackers_response = operations::GetTrackerResponse { diff --git a/crates/router/src/core/payments/operations/payment_status.rs b/crates/router/src/core/payments/operations/payment_status.rs index 101d997db217..4d6161469089 100644 --- a/crates/router/src/core/payments/operations/payment_status.rs +++ b/crates/router/src/core/payments/operations/payment_status.rs @@ -462,6 +462,7 @@ async fn get_tracker_for_sync< authorizations, authentication, frm_metadata: None, + recurring_details: None, }; let get_trackers_response = operations::GetTrackerResponse { diff --git a/crates/router/src/core/payments/operations/payment_update.rs b/crates/router/src/core/payments/operations/payment_update.rs index 2a0b99bc54b5..684f7c4b6983 100644 --- a/crates/router/src/core/payments/operations/payment_update.rs +++ b/crates/router/src/core/payments/operations/payment_update.rs @@ -1,6 +1,8 @@ use std::marker::PhantomData; -use api_models::{enums::FrmSuggestion, payments::RequestSurchargeDetails}; +use api_models::{ + enums::FrmSuggestion, mandates::RecurringDetails, payments::RequestSurchargeDetails, +}; use async_trait::async_trait; use common_utils::ext_traits::{AsyncExt, Encode, ValueExt}; use error_stack::{report, IntoReport, ResultExt}; @@ -11,6 +13,7 @@ use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, Valida use crate::{ core::{ errors::{self, CustomResult, RouterResult, StorageErrorExt}, + mandate::helpers::MandateGenericData, payment_methods::PaymentMethodRetrieve, payments::{self, helpers, operations, CustomerDetails, PaymentAddress, PaymentData}, utils as core_utils, @@ -94,17 +97,19 @@ impl )?; helpers::authenticate_client_secret(request.client_secret.as_ref(), &payment_intent)?; - let ( + + let MandateGenericData { token, payment_method, payment_method_type, - setup_mandate, + mandate_data, recurring_mandate_payment_data, mandate_connector, - ) = helpers::get_token_pm_type_mandate_details( + payment_method_info, + } = helpers::get_token_pm_type_mandate_details( state, request, - mandate_type.clone(), + mandate_type.to_owned(), merchant_account, key_store, ) @@ -263,6 +268,14 @@ impl let mandate_id = request .mandate_id .as_ref() + .or_else(|| { + request.recurring_details + .as_ref() + .and_then(|recurring_details| match recurring_details { + RecurringDetails::MandateId(id) => Some(id), + _ => None, + }) + }) .async_and_then(|mandate_id| async { let mandate = db .find_mandate_by_merchant_id_mandate_id(merchant_id, mandate_id) @@ -357,7 +370,7 @@ impl .transpose()?; // The operation merges mandate data from both request and payment_attempt - let setup_mandate = setup_mandate.map(Into::into); + let setup_mandate = mandate_data.map(Into::into); let mandate_details_present = payment_attempt.mandate_details.is_some() || request.mandate_data.is_some(); helpers::validate_mandate_data_and_future_usage( @@ -405,7 +418,7 @@ impl .payment_method_data .as_ref() .map(|pmd| pmd.payment_method_data.clone()), - payment_method_info: None, + payment_method_info, force_sync: None, refunds: vec![], disputes: vec![], @@ -426,6 +439,7 @@ impl authorizations: vec![], authentication: None, frm_metadata: request.frm_metadata.clone(), + recurring_details: request.recurring_details.clone(), }; let get_trackers_response = operations::GetTrackerResponse { @@ -737,6 +751,11 @@ impl ValidateRequest authorizations: vec![], authentication: None, frm_metadata: None, + recurring_details: None, }; let get_trackers_response = operations::GetTrackerResponse { diff --git a/crates/router/src/types/api/payments.rs b/crates/router/src/types/api/payments.rs index 8e13f6c99353..d465300dd61b 100644 --- a/crates/router/src/types/api/payments.rs +++ b/crates/router/src/types/api/payments.rs @@ -115,10 +115,11 @@ impl MandateValidationFieldsExt for MandateValidationFields { fn validate_and_get_mandate_type( &self, ) -> errors::CustomResult, errors::ValidationError> { - match (&self.mandate_data, &self.mandate_id) { + match (&self.mandate_data, &self.recurring_details) { (None, None) => Ok(None), (Some(_), Some(_)) => Err(errors::ValidationError::InvalidValue { - message: "Expected one out of mandate_id and mandate_data but got both".to_string(), + message: "Expected one out of recurring_details and mandate_data but got both" + .to_string(), }) .into_report(), (_, Some(_)) => Ok(Some(MandateTransactionType::RecurringMandateTransaction)), diff --git a/openapi/openapi_spec.json b/openapi/openapi_spec.json index 2005f9c11e01..fa9c7435632d 100644 --- a/openapi/openapi_spec.json +++ b/openapi/openapi_spec.json @@ -13334,6 +13334,14 @@ "description": "Whether to perform external authentication (if applicable)", "example": true, "nullable": true + }, + "recurring_details": { + "allOf": [ + { + "$ref": "#/components/schemas/RecurringDetails" + } + ], + "nullable": true } } }, @@ -13726,6 +13734,14 @@ "description": "Whether to perform external authentication (if applicable)", "example": true, "nullable": true + }, + "recurring_details": { + "allOf": [ + { + "$ref": "#/components/schemas/RecurringDetails" + } + ], + "nullable": true } } }, @@ -14220,6 +14236,14 @@ "description": "Whether to perform external authentication (if applicable)", "example": true, "nullable": true + }, + "recurring_details": { + "allOf": [ + { + "$ref": "#/components/schemas/RecurringDetails" + } + ], + "nullable": true } } }, @@ -15220,6 +15244,14 @@ "description": "Whether to perform external authentication (if applicable)", "example": true, "nullable": true + }, + "recurring_details": { + "allOf": [ + { + "$ref": "#/components/schemas/RecurringDetails" + } + ], + "nullable": true } } }, @@ -16129,6 +16161,49 @@ "disabled" ] }, + "RecurringDetails": { + "oneOf": [ + { + "type": "object", + "required": [ + "type", + "data" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "mandate_id" + ] + }, + "data": { + "type": "string" + } + } + }, + { + "type": "object", + "required": [ + "type", + "data" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "payment_method_id" + ] + }, + "data": { + "type": "string" + } + } + } + ], + "discriminator": { + "propertyName": "type" + } + }, "RedirectResponse": { "type": "object", "properties": { From cb2000b08856ceb64201d0aff7d81665524665b2 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 1 Apr 2024 00:06:07 +0000 Subject: [PATCH 06/19] chore(version): 2024.04.01.0 --- CHANGELOG.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f41ba2b094d5..3ead87751c49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,21 @@ All notable changes to HyperSwitch will be documented here. - - - +## 2024.04.01.0 + +### Features + +- **mandates:** Allow off-session payments using `payment_method_id` ([#4132](https://github.com/juspay/hyperswitch/pull/4132)) ([`7b337ac`](https://github.com/juspay/hyperswitch/commit/7b337ac39d72f90dd0ebe58133218896ff279313)) +- **payment_method:** API to list countries and currencies supported by a country and payment method type ([#4126](https://github.com/juspay/hyperswitch/pull/4126)) ([`74cd4a7`](https://github.com/juspay/hyperswitch/commit/74cd4a79526eb1a2dead87855e6a39248ec5ccb7)) + +### Miscellaneous Tasks + +- **config:** Add billwerk base URL in deployment configs ([#4243](https://github.com/juspay/hyperswitch/pull/4243)) ([`e8289f0`](https://github.com/juspay/hyperswitch/commit/e8289f061d4735478cb1521de50f696d2412ad33)) + +**Full Changelog:** [`2024.03.28.0...2024.04.01.0`](https://github.com/juspay/hyperswitch/compare/2024.03.28.0...2024.04.01.0) + +- - - + ## 2024.03.28.0 ### Features From ea730d4ffc712cdf264492db109836fcde9b2b03 Mon Sep 17 00:00:00 2001 From: Sanchith Hegde <22217505+SanchithHegde@users.noreply.github.com> Date: Mon, 1 Apr 2024 12:31:17 +0530 Subject: [PATCH 07/19] build(deps): bump `error-stack` from version `0.3.1` to `0.4.1` (#4188) --- Cargo.lock | 82 ++--- connector-template/mod.rs | 17 +- crates/analytics/Cargo.toml | 2 +- crates/analytics/src/api_event/core.rs | 5 +- crates/analytics/src/clickhouse.rs | 139 +++----- crates/analytics/src/connector_events/core.rs | 3 +- crates/analytics/src/disputes/core.rs | 3 +- crates/analytics/src/lambda_utils.rs | 5 +- crates/analytics/src/lib.rs | 6 +- .../src/outgoing_webhook_event/core.rs | 3 +- crates/analytics/src/payments/core.rs | 3 +- crates/analytics/src/query.rs | 7 +- crates/analytics/src/refunds/core.rs | 3 +- crates/analytics/src/sdk_events/core.rs | 5 +- crates/analytics/src/sqlx.rs | 8 +- crates/api_models/Cargo.toml | 2 +- crates/api_models/src/routing.rs | 13 +- crates/cards/Cargo.toml | 2 +- crates/common_utils/Cargo.toml | 2 +- crates/common_utils/src/crypto.rs | 25 +- crates/common_utils/src/ext_traits.rs | 17 +- crates/common_utils/src/pii.rs | 6 +- crates/common_utils/src/types.rs | 17 +- crates/data_models/Cargo.toml | 2 +- crates/data_models/src/mandates.rs | 3 +- crates/diesel_models/Cargo.toml | 2 +- crates/diesel_models/src/kv.rs | 3 +- crates/diesel_models/src/query/events.rs | 6 +- crates/diesel_models/src/query/generics.rs | 33 +- .../src/query/payment_attempt.rs | 48 +-- .../diesel_models/src/query/payment_method.rs | 3 +- .../diesel_models/src/query/payout_attempt.rs | 5 +- .../src/query/routing_algorithm.rs | 9 +- crates/diesel_models/src/query/user.rs | 11 +- .../src/query/user/sample_data.rs | 8 +- crates/drainer/Cargo.toml | 2 +- crates/drainer/src/lib.rs | 11 +- crates/drainer/src/stream.rs | 10 +- crates/drainer/src/types.rs | 3 +- crates/drainer/src/utils.rs | 15 +- crates/external_services/Cargo.toml | 2 +- crates/external_services/src/aws_kms/core.rs | 13 +- crates/external_services/src/email/ses.rs | 6 +- .../src/file_storage/file_system.rs | 20 +- .../src/no_encryption/implementers.rs | 3 +- crates/pm_auth/Cargo.toml | 2 +- crates/redis_interface/Cargo.toml | 2 +- crates/redis_interface/src/commands.rs | 41 +-- crates/redis_interface/src/lib.rs | 7 +- crates/redis_interface/src/types.rs | 7 +- crates/router/Cargo.toml | 2 +- .../stripe/payment_intents/types.rs | 15 +- .../stripe/setup_intents/types.rs | 5 +- .../src/compatibility/stripe/webhooks.rs | 3 +- crates/router/src/connection.rs | 4 +- crates/router/src/connector/aci.rs | 9 +- crates/router/src/connector/adyen.rs | 9 +- .../src/connector/adyen/transformers.rs | 4 +- crates/router/src/connector/airwallex.rs | 50 ++- .../src/connector/airwallex/transformers.rs | 3 +- .../router/src/connector/authorizedotnet.rs | 13 +- .../connector/authorizedotnet/transformers.rs | 3 +- crates/router/src/connector/bambora.rs | 11 +- .../src/connector/bambora/transformers.rs | 3 +- crates/router/src/connector/bankofamerica.rs | 14 +- .../connector/bankofamerica/transformers.rs | 3 +- crates/router/src/connector/billwerk.rs | 8 +- crates/router/src/connector/bluesnap.rs | 18 +- .../src/connector/bluesnap/transformers.rs | 11 +- crates/router/src/connector/boku.rs | 15 +- crates/router/src/connector/braintree.rs | 20 +- .../braintree_graphql_transformers.rs | 15 +- crates/router/src/connector/cashtocode.rs | 4 +- .../src/connector/cashtocode/transformers.rs | 5 +- crates/router/src/connector/checkout.rs | 19 +- .../src/connector/checkout/transformers.rs | 3 +- crates/router/src/connector/coinbase.rs | 4 +- crates/router/src/connector/cryptopay.rs | 5 +- crates/router/src/connector/cybersource.rs | 13 +- .../src/connector/cybersource/transformers.rs | 3 +- crates/router/src/connector/dlocal.rs | 32 +- crates/router/src/connector/dummyconnector.rs | 6 +- crates/router/src/connector/fiserv.rs | 39 +-- crates/router/src/connector/forte.rs | 9 +- crates/router/src/connector/globalpay.rs | 38 +-- .../src/connector/globalpay/transformers.rs | 11 +- crates/router/src/connector/globepay.rs | 8 +- crates/router/src/connector/gocardless.rs | 10 +- crates/router/src/connector/helcim.rs | 8 +- .../src/connector/helcim/transformers.rs | 19 +- crates/router/src/connector/iatapay.rs | 3 +- crates/router/src/connector/klarna.rs | 9 +- crates/router/src/connector/mollie.rs | 17 +- .../src/connector/mollie/transformers.rs | 17 +- crates/router/src/connector/multisafepay.rs | 24 +- crates/router/src/connector/nexinets.rs | 6 +- .../src/connector/nexinets/transformers.rs | 4 +- crates/router/src/connector/nmi.rs | 30 +- .../router/src/connector/nmi/transformers.rs | 19 +- crates/router/src/connector/noon.rs | 3 +- .../router/src/connector/noon/transformers.rs | 10 +- crates/router/src/connector/nuvei.rs | 13 +- .../src/connector/nuvei/transformers.rs | 5 +- crates/router/src/connector/opayo.rs | 8 +- crates/router/src/connector/opennode.rs | 8 +- crates/router/src/connector/payeezy.rs | 8 +- crates/router/src/connector/payme.rs | 10 +- .../src/connector/payme/transformers.rs | 3 +- crates/router/src/connector/paypal.rs | 3 +- .../src/connector/paypal/transformers.rs | 5 +- crates/router/src/connector/payu.rs | 39 +-- .../router/src/connector/payu/transformers.rs | 3 +- crates/router/src/connector/placetopay.rs | 8 +- .../src/connector/placetopay/transformers.rs | 9 +- crates/router/src/connector/powertranz.rs | 8 +- .../src/connector/powertranz/transformers.rs | 5 +- crates/router/src/connector/prophetpay.rs | 8 +- .../src/connector/prophetpay/transformers.rs | 8 +- crates/router/src/connector/rapyd.rs | 31 +- .../src/connector/rapyd/transformers.rs | 4 +- crates/router/src/connector/riskified.rs | 8 +- crates/router/src/connector/shift4.rs | 22 +- .../src/connector/shift4/transformers.rs | 3 +- crates/router/src/connector/signifyd.rs | 8 +- crates/router/src/connector/square.rs | 4 +- .../src/connector/square/transformers.rs | 4 +- crates/router/src/connector/stax.rs | 4 +- .../router/src/connector/stax/transformers.rs | 6 +- crates/router/src/connector/stripe.rs | 22 +- .../src/connector/stripe/transformers.rs | 10 +- crates/router/src/connector/threedsecureio.rs | 8 +- .../connector/threedsecureio/transformers.rs | 9 +- crates/router/src/connector/trustpay.rs | 3 +- crates/router/src/connector/tsys.rs | 8 +- crates/router/src/connector/utils.rs | 25 +- crates/router/src/connector/volt.rs | 3 +- crates/router/src/connector/wise.rs | 8 +- crates/router/src/connector/worldline.rs | 41 +-- crates/router/src/connector/worldpay.rs | 11 +- crates/router/src/connector/zen.rs | 7 +- crates/router/src/core/admin.rs | 42 +-- crates/router/src/core/api_keys.rs | 11 +- crates/router/src/core/api_locking.rs | 19 +- crates/router/src/core/authentication.rs | 4 +- crates/router/src/core/blocklist/utils.rs | 18 +- crates/router/src/core/conditional_config.rs | 3 +- .../src/core/connector_onboarding/paypal.rs | 5 +- crates/router/src/core/customers.rs | 6 +- crates/router/src/core/disputes.rs | 3 +- crates/router/src/core/files.rs | 4 +- crates/router/src/core/files/helpers.rs | 5 +- .../fraud_check/operation/fraud_check_post.rs | 2 - crates/router/src/core/gsm.rs | 3 +- crates/router/src/core/mandate.rs | 16 +- crates/router/src/core/payment_link.rs | 16 +- .../router/src/core/payment_methods/cards.rs | 26 +- .../surcharge_decision_configs.rs | 13 +- .../router/src/core/payment_methods/vault.rs | 22 +- crates/router/src/core/payments.rs | 20 +- .../router/src/core/payments/access_token.rs | 3 +- .../src/core/payments/conditional_configs.rs | 8 +- .../src/core/payments/flows/session_flow.rs | 4 +- .../core/payments/flows/setup_mandate_flow.rs | 7 +- crates/router/src/core/payments/helpers.rs | 315 +++++++++--------- .../payments/operations/payment_approve.rs | 10 +- .../operations/payment_complete_authorize.rs | 6 +- .../payments/operations/payment_confirm.rs | 8 +- .../payments/operations/payment_response.rs | 4 +- .../payments/operations/payment_update.rs | 6 +- .../payments_incremental_authorization.rs | 3 +- crates/router/src/core/payments/retry.rs | 13 +- crates/router/src/core/payments/routing.rs | 26 +- .../router/src/core/payments/transformers.rs | 4 +- crates/router/src/core/payments/types.rs | 4 +- crates/router/src/core/payouts.rs | 6 +- crates/router/src/core/payouts/helpers.rs | 5 +- crates/router/src/core/payouts/retry.rs | 16 +- crates/router/src/core/pm_auth.rs | 11 +- crates/router/src/core/pm_auth/helpers.rs | 3 +- crates/router/src/core/refunds.rs | 7 +- crates/router/src/core/refunds/validator.rs | 6 +- crates/router/src/core/routing.rs | 25 +- .../src/core/surcharge_decision_config.rs | 3 +- crates/router/src/core/user.rs | 18 +- .../src/core/user/dashboard_metadata.rs | 4 +- crates/router/src/core/user_role.rs | 18 +- crates/router/src/core/user_role/role.rs | 6 +- crates/router/src/core/utils.rs | 12 +- crates/router/src/core/verify_connector.rs | 14 +- crates/router/src/core/webhooks.rs | 51 +-- crates/router/src/db/address.rs | 51 +-- crates/router/src/db/api_keys.rs | 26 +- crates/router/src/db/authentication.rs | 11 +- crates/router/src/db/authorization.rs | 11 +- crates/router/src/db/blocklist.rs | 17 +- crates/router/src/db/blocklist_fingerprint.rs | 8 +- crates/router/src/db/blocklist_lookup.rs | 11 +- crates/router/src/db/business_profile.rs | 20 +- crates/router/src/db/capture.rs | 22 +- crates/router/src/db/cards_info.rs | 5 +- crates/router/src/db/configs.rs | 31 +- crates/router/src/db/customers.rs | 20 +- crates/router/src/db/dashboard_metadata.rs | 25 +- crates/router/src/db/dispute.rs | 25 +- crates/router/src/db/events.rs | 29 +- crates/router/src/db/file.rs | 15 +- crates/router/src/db/fraud_check.rs | 15 +- crates/router/src/db/gsm.rs | 18 +- crates/router/src/db/locker_mock_up.rs | 17 +- crates/router/src/db/mandate.rs | 26 +- crates/router/src/db/merchant_account.rs | 35 +- .../src/db/merchant_connector_account.rs | 35 +- crates/router/src/db/merchant_key_store.rs | 14 +- crates/router/src/db/organization.rs | 11 +- crates/router/src/db/payment_link.rs | 11 +- crates/router/src/db/payment_method.rs | 44 +-- crates/router/src/db/refund.rs | 78 ++--- crates/router/src/db/reverse_lookup.rs | 22 +- crates/router/src/db/role.rs | 27 +- crates/router/src/db/routing_algorithm.rs | 23 +- crates/router/src/db/user.rs | 29 +- crates/router/src/db/user_role.rs | 32 +- crates/router/src/routes/disputes/utils.rs | 10 +- .../src/routes/dummy_connector/utils.rs | 4 +- .../router/src/routes/files/transformers.rs | 11 +- crates/router/src/routes/payments.rs | 5 +- crates/router/src/routes/recon.rs | 8 +- crates/router/src/services.rs | 3 +- crates/router/src/services/api.rs | 19 +- crates/router/src/services/api/client.rs | 12 +- crates/router/src/services/api/request.rs | 4 +- crates/router/src/services/authentication.rs | 6 +- .../src/services/authentication/blacklist.rs | 7 +- crates/router/src/services/authorization.rs | 9 +- crates/router/src/services/encryption.rs | 12 +- crates/router/src/services/jwt.rs | 4 +- crates/router/src/services/kafka.rs | 7 +- crates/router/src/types.rs | 3 +- crates/router/src/types/api.rs | 4 +- crates/router/src/types/api/authentication.rs | 3 +- .../types/api/connector_onboarding/paypal.rs | 4 +- crates/router/src/types/api/fraud_check.rs | 3 +- crates/router/src/types/api/payments.rs | 7 +- .../router/src/types/api/verify_connector.rs | 10 +- .../src/types/api/verify_connector/stripe.rs | 6 +- crates/router/src/types/domain/address.rs | 2 +- crates/router/src/types/domain/customer.rs | 2 +- crates/router/src/types/domain/event.rs | 2 +- .../src/types/domain/merchant_account.rs | 2 +- crates/router/src/types/domain/types.rs | 9 +- crates/router/src/types/domain/user.rs | 12 +- crates/router/src/types/pm_auth.rs | 3 +- crates/router/src/types/storage/dispute.rs | 3 +- crates/router/src/types/storage/mandate.rs | 3 +- .../router/src/types/storage/payment_link.rs | 3 +- crates/router/src/types/storage/refund.rs | 7 +- crates/router/src/types/transformers.rs | 14 +- crates/router/src/utils.rs | 27 +- .../src/utils/connector_onboarding/paypal.rs | 11 +- crates/router/src/utils/currency.rs | 19 +- crates/router/src/utils/ext_traits.rs | 3 +- crates/router/src/utils/user.rs | 4 +- .../src/utils/user/dashboard_metadata.rs | 16 +- crates/router/src/utils/user/password.rs | 9 +- crates/router/src/utils/user/sample_data.rs | 5 +- crates/router/src/utils/user_role.rs | 12 +- crates/router/src/utils/verify_connector.rs | 5 +- crates/router_env/Cargo.toml | 2 +- crates/scheduler/Cargo.toml | 2 +- crates/scheduler/src/consumer.rs | 5 +- crates/scheduler/src/consumer/types/batch.rs | 12 +- crates/scheduler/src/db/process_tracker.rs | 20 +- crates/scheduler/src/producer.rs | 5 +- crates/storage_impl/Cargo.toml | 2 +- crates/storage_impl/src/connection.rs | 4 +- crates/storage_impl/src/database/store.rs | 3 +- crates/storage_impl/src/lookup.rs | 7 +- .../src/mock_db/payment_intent.rs | 8 +- .../src/payments/payment_attempt.rs | 8 +- .../src/payments/payment_intent.rs | 12 +- .../src/payouts/payout_attempt.rs | 6 +- crates/storage_impl/src/payouts/payouts.rs | 10 +- crates/storage_impl/src/redis.rs | 3 +- crates/storage_impl/src/redis/kv_store.rs | 8 +- crates/storage_impl/src/redis/pub_sub.rs | 7 +- crates/storage_impl/src/utils.rs | 4 +- 286 files changed, 1361 insertions(+), 2397 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4d8d1e8c6a3a..8f571b3b922c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -80,7 +80,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb" dependencies = [ "quote", - "syn 2.0.53", + "syn 2.0.55", ] [[package]] @@ -118,7 +118,7 @@ dependencies = [ "parse-size", "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.55", ] [[package]] @@ -255,7 +255,7 @@ dependencies = [ "actix-router", "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.55", ] [[package]] @@ -394,9 +394,9 @@ checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" [[package]] name = "anyhow" -version = "1.0.75" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" +checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" [[package]] name = "api_models" @@ -566,7 +566,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.55", ] [[package]] @@ -577,7 +577,7 @@ checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.55", ] [[package]] @@ -1600,7 +1600,7 @@ dependencies = [ "proc-macro-crate 2.0.0", "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.55", "syn_derive", ] @@ -1922,7 +1922,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.55", ] [[package]] @@ -2355,7 +2355,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.53", + "syn 2.0.55", ] [[package]] @@ -2377,7 +2377,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core 0.20.3", "quote", - "syn 2.0.53", + "syn 2.0.55", ] [[package]] @@ -2545,7 +2545,7 @@ dependencies = [ "diesel_table_macro_syntax", "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.55", ] [[package]] @@ -2575,7 +2575,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc5557efc453706fed5e4fa85006fe9817c224c3f480a34c7e5959fd700921c5" dependencies = [ - "syn 2.0.53", + "syn 2.0.55", ] [[package]] @@ -2632,7 +2632,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.55", ] [[package]] @@ -2733,9 +2733,9 @@ dependencies = [ [[package]] name = "error-stack" -version = "0.3.1" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f00447f331c7f726db5b8532ebc9163519eed03c6d7c8b73c90b3ff5646ac85" +checksum = "27a72baa257b5e0e2de241967bc5ee8f855d6072351042688621081d66b2a76b" dependencies = [ "anyhow", "rustc_version 0.4.0", @@ -2981,7 +2981,7 @@ checksum = "b0fa992f1656e1707946bbba340ad244f0814009ef8c0118eb7b658395f19a2e" dependencies = [ "frunk_proc_macro_helpers", "quote", - "syn 2.0.53", + "syn 2.0.55", ] [[package]] @@ -2993,7 +2993,7 @@ dependencies = [ "frunk_core", "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.55", ] [[package]] @@ -3005,7 +3005,7 @@ dependencies = [ "frunk_core", "frunk_proc_macro_helpers", "quote", - "syn 2.0.53", + "syn 2.0.55", ] [[package]] @@ -3118,7 +3118,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.55", ] [[package]] @@ -4480,7 +4480,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.55", ] [[package]] @@ -4766,7 +4766,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.55", ] [[package]] @@ -4856,7 +4856,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.55", ] [[package]] @@ -5683,7 +5683,7 @@ dependencies = [ "serde", "serde_json", "strum 0.24.1", - "syn 2.0.53", + "syn 2.0.55", ] [[package]] @@ -6077,7 +6077,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.55", ] [[package]] @@ -6141,7 +6141,7 @@ checksum = "8725e1dfadb3a50f7e5ce0b1a540466f6ed3fe7a0fca2ac2b8b831d31316bd00" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.55", ] [[package]] @@ -6191,7 +6191,7 @@ dependencies = [ "darling 0.20.3", "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.55", ] [[package]] @@ -6216,7 +6216,7 @@ checksum = "91d129178576168c589c9ec973feedf7d3126c01ac2bf08795109aa35b69fb8f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.55", ] [[package]] @@ -6604,7 +6604,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.53", + "syn 2.0.55", ] [[package]] @@ -6626,9 +6626,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.53" +version = "2.0.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7383cd0e49fff4b6b90ca5670bfd3e9d6a733b3f90c686605aa7eec8c4996032" +checksum = "002a1b3dbf967edfafc32655d0f377ab0bb7b994aa1d32c8cc7e9b8bf3ebb8f0" dependencies = [ "proc-macro2", "quote", @@ -6644,7 +6644,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.55", ] [[package]] @@ -6752,7 +6752,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.55", ] [[package]] @@ -6764,7 +6764,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.55", "test-case-core", ] @@ -6844,7 +6844,7 @@ checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.55", ] [[package]] @@ -7034,7 +7034,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.55", ] [[package]] @@ -7364,7 +7364,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.55", ] [[package]] @@ -7635,7 +7635,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.55", ] [[package]] @@ -7793,7 +7793,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.55", "wasm-bindgen-shared", ] @@ -7827,7 +7827,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.55", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -8201,7 +8201,7 @@ checksum = "b3c129550b3e6de3fd0ba67ba5c81818f9805e58b8d7fee80a3a59d2c9fc601a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.55", ] [[package]] diff --git a/connector-template/mod.rs b/connector-template/mod.rs index 987f6a8742fd..760e1528cfae 100644 --- a/connector-template/mod.rs +++ b/connector-template/mod.rs @@ -1,7 +1,7 @@ pub mod transformers; use std::fmt::Debug; -use error_stack::{ResultExt, IntoReport}; +use error_stack::{report, ResultExt}; use masking::ExposeInterface; use crate::{ @@ -20,7 +20,6 @@ use crate::{ } }; - use transformers as {{project-name | downcase}}; #[derive(Debug, Clone)] @@ -74,8 +73,8 @@ impl ConnectorCommon for {{project-name | downcase | pascal_case}} { fn get_currency_unit(&self) -> api::CurrencyUnit { todo!() - // TODO! Check connector documentation, on which unit they are processing the currency. - // If the connector accepts amount in lower unit ( i.e cents for USD) then return api::CurrencyUnit::Minor, + // TODO! Check connector documentation, on which unit they are processing the currency. + // If the connector accepts amount in lower unit ( i.e cents for USD) then return api::CurrencyUnit::Minor, // if connector accepts amount in base unit (i.e dollars for USD) then return api::CurrencyUnit::Base } @@ -117,7 +116,7 @@ impl ConnectorCommon for {{project-name | downcase | pascal_case}} { } } -impl ConnectorValidation for {{project-name | downcase | pascal_case}} +impl ConnectorValidation for {{project-name | downcase | pascal_case}} { //TODO: implement functions when support enabled } @@ -274,7 +273,7 @@ impl http_code: res.status_code, }) } - + fn get_error_response( &self, res: Response, @@ -492,20 +491,20 @@ impl api::IncomingWebhook for {{project-name | downcase | pascal_case}} { &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_event_type( &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_resource_object( &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } diff --git a/crates/analytics/Cargo.toml b/crates/analytics/Cargo.toml index f07e0a94ea5d..37b13a39713a 100644 --- a/crates/analytics/Cargo.toml +++ b/crates/analytics/Cargo.toml @@ -32,7 +32,7 @@ aws-config = { version = "1.1.6", features = ["behavior-version-latest"] } aws-sdk-lambda = { version = "1.1.4" } aws-smithy-types = { version = "1.1.6" } bigdecimal = { version = "0.3.1", features = ["serde"] } -error-stack = "0.3.1" +error-stack = "0.4.1" futures = "0.3.28" opensearch = { version = "2.2.0", features = ["aws-auth"] } once_cell = "1.18.0" diff --git a/crates/analytics/src/api_event/core.rs b/crates/analytics/src/api_event/core.rs index 81b82c5dce15..7225a6322d47 100644 --- a/crates/analytics/src/api_event/core.rs +++ b/crates/analytics/src/api_event/core.rs @@ -9,7 +9,7 @@ use api_models::analytics::{ GetApiEventMetricRequest, MetricsResponse, }; use common_utils::errors::ReportSwitchExt; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use router_env::{ instrument, logger, tracing::{self, Instrument}, @@ -36,7 +36,6 @@ pub async fn api_events_core( AnalyticsProvider::Sqlx(_) => Err(FiltersError::NotImplemented( "API Events not implemented for SQLX", )) - .into_report() .attach_printable("SQL Analytics is not implemented for API Events"), AnalyticsProvider::Clickhouse(pool) => get_api_event(&merchant_id, req, pool).await, AnalyticsProvider::CombinedSqlx(_sqlx_pool, ckh_pool) @@ -64,7 +63,6 @@ pub async fn get_filters( AnalyticsProvider::Sqlx(_pool) => Err(FiltersError::NotImplemented( "API Events not implemented for SQLX", )) - .into_report() .attach_printable("SQL Analytics is not implemented for API Events"), AnalyticsProvider::Clickhouse(ckh_pool) | AnalyticsProvider::CombinedSqlx(_, ckh_pool) @@ -134,7 +132,6 @@ pub async fn get_api_event_metrics( .join_next() .await .transpose() - .into_report() .change_context(AnalyticsError::UnknownError)? { let data = data?; diff --git a/crates/analytics/src/clickhouse.rs b/crates/analytics/src/clickhouse.rs index 6ebac7c1d921..4d01c20972cb 100644 --- a/crates/analytics/src/clickhouse.rs +++ b/crates/analytics/src/clickhouse.rs @@ -2,7 +2,7 @@ use std::sync::Arc; use actix_web::http::StatusCode; use common_utils::errors::ParsingError; -use error_stack::{IntoReport, Report, ResultExt}; +use error_stack::{report, Report, ResultExt}; use router_env::logger; use time::PrimitiveDateTime; @@ -71,7 +71,6 @@ impl ClickhouseClient { .body(format!("{query}\nFORMAT JSON")) .send() .await - .into_report() .change_context(ClickhouseError::ConnectionError)?; logger::debug!(clickhouse_response=?response, query=?query, "Clickhouse response"); @@ -79,16 +78,14 @@ impl ClickhouseClient { response.text().await.map_or_else( |er| { Err(ClickhouseError::ResponseError) - .into_report() .attach_printable_lazy(|| format!("Error: {er:?}")) }, - |t| Err(ClickhouseError::ResponseNotOK(t)).into_report(), + |t| Err(report!(ClickhouseError::ResponseNotOK(t))), ) } else { Ok(response .json::>() .await - .into_report() .change_context(ClickhouseError::ResponseError)? .data) } @@ -149,7 +146,7 @@ where { fn load_row(row: Self::Row) -> common_utils::errors::CustomResult { row.try_into() - .change_context(QueryExecutionError::RowExtractionFailure) + .map_err(|error| error.change_context(QueryExecutionError::RowExtractionFailure)) } } @@ -188,11 +185,9 @@ impl TryInto for serde_json::Value { type Error = Report; fn try_into(self) -> Result { - serde_json::from_value(self) - .into_report() - .change_context(ParsingError::StructParseFailure( - "Failed to parse ApiLogsResult in clickhouse results", - )) + serde_json::from_value(self).change_context(ParsingError::StructParseFailure( + "Failed to parse ApiLogsResult in clickhouse results", + )) } } @@ -200,11 +195,9 @@ impl TryInto for serde_json::Value { type Error = Report; fn try_into(self) -> Result { - serde_json::from_value(self) - .into_report() - .change_context(ParsingError::StructParseFailure( - "Failed to parse SdkEventsResult in clickhouse results", - )) + serde_json::from_value(self).change_context(ParsingError::StructParseFailure( + "Failed to parse SdkEventsResult in clickhouse results", + )) } } @@ -212,11 +205,9 @@ impl TryInto for serde_json::Value { type Error = Report; fn try_into(self) -> Result { - serde_json::from_value(self) - .into_report() - .change_context(ParsingError::StructParseFailure( - "Failed to parse ConnectorEventsResult in clickhouse results", - )) + serde_json::from_value(self).change_context(ParsingError::StructParseFailure( + "Failed to parse ConnectorEventsResult in clickhouse results", + )) } } @@ -224,11 +215,9 @@ impl TryInto for serde_json::Value { type Error = Report; fn try_into(self) -> Result { - serde_json::from_value(self) - .into_report() - .change_context(ParsingError::StructParseFailure( - "Failed to parse PaymentMetricRow in clickhouse results", - )) + serde_json::from_value(self).change_context(ParsingError::StructParseFailure( + "Failed to parse PaymentMetricRow in clickhouse results", + )) } } @@ -236,11 +225,9 @@ impl TryInto for serde_json::Value { type Error = Report; fn try_into(self) -> Result { - serde_json::from_value(self) - .into_report() - .change_context(ParsingError::StructParseFailure( - "Failed to parse PaymentDistributionRow in clickhouse results", - )) + serde_json::from_value(self).change_context(ParsingError::StructParseFailure( + "Failed to parse PaymentDistributionRow in clickhouse results", + )) } } @@ -248,11 +235,9 @@ impl TryInto for serde_json::Value { type Error = Report; fn try_into(self) -> Result { - serde_json::from_value(self) - .into_report() - .change_context(ParsingError::StructParseFailure( - "Failed to parse FilterRow in clickhouse results", - )) + serde_json::from_value(self).change_context(ParsingError::StructParseFailure( + "Failed to parse FilterRow in clickhouse results", + )) } } @@ -260,11 +245,9 @@ impl TryInto for serde_json::Value { type Error = Report; fn try_into(self) -> Result { - serde_json::from_value(self) - .into_report() - .change_context(ParsingError::StructParseFailure( - "Failed to parse RefundMetricRow in clickhouse results", - )) + serde_json::from_value(self).change_context(ParsingError::StructParseFailure( + "Failed to parse RefundMetricRow in clickhouse results", + )) } } @@ -272,22 +255,18 @@ impl TryInto for serde_json::Value { type Error = Report; fn try_into(self) -> Result { - serde_json::from_value(self) - .into_report() - .change_context(ParsingError::StructParseFailure( - "Failed to parse RefundFilterRow in clickhouse results", - )) + serde_json::from_value(self).change_context(ParsingError::StructParseFailure( + "Failed to parse RefundFilterRow in clickhouse results", + )) } } impl TryInto for serde_json::Value { type Error = Report; fn try_into(self) -> Result { - serde_json::from_value(self) - .into_report() - .change_context(ParsingError::StructParseFailure( - "Failed to parse DisputeMetricRow in clickhouse results", - )) + serde_json::from_value(self).change_context(ParsingError::StructParseFailure( + "Failed to parse DisputeMetricRow in clickhouse results", + )) } } @@ -295,11 +274,9 @@ impl TryInto for serde_json::Value { type Error = Report; fn try_into(self) -> Result { - serde_json::from_value(self) - .into_report() - .change_context(ParsingError::StructParseFailure( - "Failed to parse DisputeFilterRow in clickhouse results", - )) + serde_json::from_value(self).change_context(ParsingError::StructParseFailure( + "Failed to parse DisputeFilterRow in clickhouse results", + )) } } @@ -307,11 +284,9 @@ impl TryInto for serde_json::Value { type Error = Report; fn try_into(self) -> Result { - serde_json::from_value(self) - .into_report() - .change_context(ParsingError::StructParseFailure( - "Failed to parse ApiEventMetricRow in clickhouse results", - )) + serde_json::from_value(self).change_context(ParsingError::StructParseFailure( + "Failed to parse ApiEventMetricRow in clickhouse results", + )) } } @@ -319,11 +294,9 @@ impl TryInto for serde_json::Value { type Error = Report; fn try_into(self) -> Result { - serde_json::from_value(self) - .into_report() - .change_context(ParsingError::StructParseFailure( - "Failed to parse LatencyAvg in clickhouse results", - )) + serde_json::from_value(self).change_context(ParsingError::StructParseFailure( + "Failed to parse LatencyAvg in clickhouse results", + )) } } @@ -331,11 +304,9 @@ impl TryInto for serde_json::Value { type Error = Report; fn try_into(self) -> Result { - serde_json::from_value(self) - .into_report() - .change_context(ParsingError::StructParseFailure( - "Failed to parse SdkEventMetricRow in clickhouse results", - )) + serde_json::from_value(self).change_context(ParsingError::StructParseFailure( + "Failed to parse SdkEventMetricRow in clickhouse results", + )) } } @@ -343,11 +314,9 @@ impl TryInto for serde_json::Value { type Error = Report; fn try_into(self) -> Result { - serde_json::from_value(self) - .into_report() - .change_context(ParsingError::StructParseFailure( - "Failed to parse SdkEventFilter in clickhouse results", - )) + serde_json::from_value(self).change_context(ParsingError::StructParseFailure( + "Failed to parse SdkEventFilter in clickhouse results", + )) } } @@ -355,11 +324,9 @@ impl TryInto for serde_json::Value { type Error = Report; fn try_into(self) -> Result { - serde_json::from_value(self) - .into_report() - .change_context(ParsingError::StructParseFailure( - "Failed to parse ApiEventFilter in clickhouse results", - )) + serde_json::from_value(self).change_context(ParsingError::StructParseFailure( + "Failed to parse ApiEventFilter in clickhouse results", + )) } } @@ -367,11 +334,9 @@ impl TryInto for serde_json::Value { type Error = Report; fn try_into(self) -> Result { - serde_json::from_value(self) - .into_report() - .change_context(ParsingError::StructParseFailure( - "Failed to parse OutgoingWebhookLogsResult in clickhouse results", - )) + serde_json::from_value(self).change_context(ParsingError::StructParseFailure( + "Failed to parse OutgoingWebhookLogsResult in clickhouse results", + )) } } @@ -379,11 +344,9 @@ impl ToSql for PrimitiveDateTime { fn to_sql(&self, _table_engine: &TableEngine) -> error_stack::Result { let format = time::format_description::parse("[year]-[month]-[day] [hour]:[minute]:[second]") - .into_report() .change_context(ParsingError::DateTimeParsingError) .attach_printable("Failed to parse format description")?; self.format(&format) - .into_report() .change_context(ParsingError::EncodeError( "failed to encode to clickhouse date-time format", )) diff --git a/crates/analytics/src/connector_events/core.rs b/crates/analytics/src/connector_events/core.rs index 15f841af5f82..a7f5b978428b 100644 --- a/crates/analytics/src/connector_events/core.rs +++ b/crates/analytics/src/connector_events/core.rs @@ -1,6 +1,6 @@ use api_models::analytics::connector_events::ConnectorEventsRequest; use common_utils::errors::ReportSwitchExt; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use super::events::{get_connector_events, ConnectorEventsResult}; use crate::{errors::AnalyticsResult, types::FiltersError, AnalyticsProvider}; @@ -14,7 +14,6 @@ pub async fn connector_events_core( AnalyticsProvider::Sqlx(_) => Err(FiltersError::NotImplemented( "Connector Events not implemented for SQLX", )) - .into_report() .attach_printable("SQL Analytics is not implemented for Connector Events"), AnalyticsProvider::Clickhouse(ckh_pool) | AnalyticsProvider::CombinedSqlx(_, ckh_pool) diff --git a/crates/analytics/src/disputes/core.rs b/crates/analytics/src/disputes/core.rs index ae013aa81d17..dfba5fea1126 100644 --- a/crates/analytics/src/disputes/core.rs +++ b/crates/analytics/src/disputes/core.rs @@ -8,7 +8,7 @@ use api_models::analytics::{ AnalyticsMetadata, DisputeFilterValue, DisputeFiltersResponse, GetDisputeFilterRequest, GetDisputeMetricRequest, MetricsResponse, }; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use router_env::{ logger, tracing::{self, Instrument}, @@ -67,7 +67,6 @@ pub async fn get_metrics( .join_next() .await .transpose() - .into_report() .change_context(AnalyticsError::UnknownError)? { let data = data?; diff --git a/crates/analytics/src/lambda_utils.rs b/crates/analytics/src/lambda_utils.rs index 4f8320f29b56..9dc90531c7a9 100644 --- a/crates/analytics/src/lambda_utils.rs +++ b/crates/analytics/src/lambda_utils.rs @@ -2,7 +2,7 @@ use aws_config::{self, meta::region::RegionProviderChain, Region}; use aws_sdk_lambda::{types::InvocationType::Event, Client}; use aws_smithy_types::Blob; use common_utils::errors::CustomResult; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use crate::errors::AnalyticsError; @@ -25,10 +25,9 @@ pub async fn invoke_lambda( .payload(Blob::new(json_bytes.to_owned())) .send() .await - .into_report() .map_err(|er| { let er_rep = format!("{er:?}"); - er.attach_printable(er_rep) + report!(er).attach_printable(er_rep) }) .change_context(AnalyticsError::UnknownError) .attach_printable("Lambda invocation failed")?; diff --git a/crates/analytics/src/lib.rs b/crates/analytics/src/lib.rs index a325442047e7..3b3cbc9c0398 100644 --- a/crates/analytics/src/lib.rs +++ b/crates/analytics/src/lib.rs @@ -43,7 +43,7 @@ use api_models::analytics::{ }; use clickhouse::ClickhouseClient; pub use clickhouse::ClickhouseConfig; -use error_stack::IntoReport; +use error_stack::report; use router_env::{ logger, tracing::{self, instrument}, @@ -512,7 +512,7 @@ impl AnalyticsProvider { time_range: &TimeRange, ) -> types::MetricsResult> { match self { - Self::Sqlx(_pool) => Err(MetricsError::NotImplemented).into_report(), + Self::Sqlx(_pool) => Err(report!(MetricsError::NotImplemented)), Self::Clickhouse(pool) => { metric .load_metrics(dimensions, pub_key, filters, granularity, time_range, pool) @@ -544,7 +544,7 @@ impl AnalyticsProvider { time_range: &TimeRange, ) -> types::MetricsResult> { match self { - Self::Sqlx(_pool) => Err(MetricsError::NotImplemented).into_report(), + Self::Sqlx(_pool) => Err(report!(MetricsError::NotImplemented)), Self::Clickhouse(ckh_pool) | Self::CombinedCkh(_, ckh_pool) | Self::CombinedSqlx(_, ckh_pool) => { diff --git a/crates/analytics/src/outgoing_webhook_event/core.rs b/crates/analytics/src/outgoing_webhook_event/core.rs index 5024cc70ec1c..a78def2751e2 100644 --- a/crates/analytics/src/outgoing_webhook_event/core.rs +++ b/crates/analytics/src/outgoing_webhook_event/core.rs @@ -1,6 +1,6 @@ use api_models::analytics::outgoing_webhook_event::OutgoingWebhookLogsRequest; use common_utils::errors::ReportSwitchExt; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use super::events::{get_outgoing_webhook_event, OutgoingWebhookLogsResult}; use crate::{errors::AnalyticsResult, types::FiltersError, AnalyticsProvider}; @@ -14,7 +14,6 @@ pub async fn outgoing_webhook_events_core( AnalyticsProvider::Sqlx(_) => Err(FiltersError::NotImplemented( "Outgoing Webhook Events Logs not implemented for SQLX", )) - .into_report() .attach_printable("SQL Analytics is not implemented for Outgoing Webhook Events"), AnalyticsProvider::Clickhouse(ckh_pool) | AnalyticsProvider::CombinedSqlx(_, ckh_pool) diff --git a/crates/analytics/src/payments/core.rs b/crates/analytics/src/payments/core.rs index 138e88789327..debc03fc9d58 100644 --- a/crates/analytics/src/payments/core.rs +++ b/crates/analytics/src/payments/core.rs @@ -10,7 +10,7 @@ use api_models::analytics::{ MetricsResponse, PaymentFiltersResponse, }; use common_utils::errors::CustomResult; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use router_env::{ instrument, logger, tracing::{self, Instrument}, @@ -115,7 +115,6 @@ pub async fn get_metrics( .join_next() .await .transpose() - .into_report() .change_context(AnalyticsError::UnknownError)? { match task_type { diff --git a/crates/analytics/src/query.rs b/crates/analytics/src/query.rs index 27e4154a1a98..a7ef0d993e89 100644 --- a/crates/analytics/src/query.rs +++ b/crates/analytics/src/query.rs @@ -18,7 +18,7 @@ use api_models::{ }; use common_utils::errors::{CustomResult, ParsingError}; use diesel_models::enums as storage_enums; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use router_env::{logger, Flow}; use super::types::{AnalyticsCollection, AnalyticsDataSource, LoadRow, TableEngine}; @@ -179,7 +179,6 @@ impl SeriesBucket for Granularity { time::Time::MIDNIGHT.replace_hour(clip_start(value.hour(), i)) } } - .into_report() .change_context(PostProcessingError::BucketClipping)?; Ok(value.replace_time(clipped_time)) @@ -206,7 +205,6 @@ impl SeriesBucket for Granularity { time::Time::MIDNIGHT.replace_hour(clip_end(value.hour(), i)) } } - .into_report() .change_context(PostProcessingError::BucketClipping) .attach_printable_lazy(|| format!("Bucket Clip Error: {value}"))?; @@ -644,8 +642,7 @@ where if self.columns.is_empty() { Err(QueryBuildingError::InvalidQuery( "No select fields provided", - )) - .into_report()?; + ))?; } let mut query = String::from("SELECT "); diff --git a/crates/analytics/src/refunds/core.rs b/crates/analytics/src/refunds/core.rs index 25a1e228f567..b53d482e620a 100644 --- a/crates/analytics/src/refunds/core.rs +++ b/crates/analytics/src/refunds/core.rs @@ -8,7 +8,7 @@ use api_models::analytics::{ AnalyticsMetadata, GetRefundFilterRequest, GetRefundMetricRequest, MetricsResponse, RefundFilterValue, RefundFiltersResponse, }; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use router_env::{ logger, tracing::{self, Instrument}, @@ -66,7 +66,6 @@ pub async fn get_metrics( .join_next() .await .transpose() - .into_report() .change_context(AnalyticsError::UnknownError)? { let data = data?; diff --git a/crates/analytics/src/sdk_events/core.rs b/crates/analytics/src/sdk_events/core.rs index 46cc636f4388..a5d2900e54d8 100644 --- a/crates/analytics/src/sdk_events/core.rs +++ b/crates/analytics/src/sdk_events/core.rs @@ -8,7 +8,7 @@ use api_models::analytics::{ SdkEventFiltersResponse, }; use common_utils::errors::ReportSwitchExt; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use router_env::{instrument, logger, tracing}; use super::{ @@ -32,7 +32,6 @@ pub async fn sdk_events_core( AnalyticsProvider::Sqlx(_) => Err(FiltersError::NotImplemented( "SDK Events not implemented for SQLX", )) - .into_report() .attach_printable("SQL Analytics is not implemented for Sdk Events"), AnalyticsProvider::Clickhouse(pool) => get_sdk_event(&publishable_key, req, pool).await, AnalyticsProvider::CombinedSqlx(_sqlx_pool, ckh_pool) @@ -80,7 +79,6 @@ pub async fn get_metrics( .join_next() .await .transpose() - .into_report() .change_context(AnalyticsError::UnknownError)? { logger::info!("Logging Result {:?}", data); @@ -165,7 +163,6 @@ pub async fn get_filters( AnalyticsProvider::Sqlx(_pool) => Err(FiltersError::NotImplemented( "SDK Events not implemented for SQLX", )) - .into_report() .attach_printable("SQL Analytics is not implemented for SDK Events"), AnalyticsProvider::Clickhouse(pool) => { get_sdk_event_filter_for_dimension(dim, publishable_key, &req.time_range, pool) diff --git a/crates/analytics/src/sqlx.rs b/crates/analytics/src/sqlx.rs index e88fe519c3cb..586ec1bfb17a 100644 --- a/crates/analytics/src/sqlx.rs +++ b/crates/analytics/src/sqlx.rs @@ -8,7 +8,7 @@ use common_utils::errors::{CustomResult, ParsingError}; use diesel_models::enums::{ AttemptStatus, AuthenticationType, Currency, PaymentMethod, RefundStatus, }; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::PeekInterface; use sqlx::{ postgres::{PgArgumentBuffer, PgPoolOptions, PgRow, PgTypeInfo, PgValueRef}, @@ -138,9 +138,7 @@ where for<'a> T: FromRow<'a, PgRow>, { fn load_row(row: PgRow) -> CustomResult { - T::from_row(&row) - .into_report() - .change_context(QueryExecutionError::RowExtractionFailure) + T::from_row(&row).change_context(QueryExecutionError::RowExtractionFailure) } } @@ -163,7 +161,6 @@ impl AnalyticsDataSource for SqlxClient { sqlx::query(&format!("{query};")) .fetch_all(&self.pool) .await - .into_report() .change_context(QueryExecutionError::DatabaseError) .attach_printable_lazy(|| format!("Failed to run query {query}"))? .into_iter() @@ -179,7 +176,6 @@ impl HealthCheck for SqlxClient { .fetch_all(&self.pool) .await .map(|_| ()) - .into_report() .change_context(QueryExecutionError::DatabaseError) } } diff --git a/crates/api_models/Cargo.toml b/crates/api_models/Cargo.toml index 94202935c553..356a29830ec5 100644 --- a/crates/api_models/Cargo.toml +++ b/crates/api_models/Cargo.toml @@ -24,7 +24,7 @@ recon = [] [dependencies] actix-web = { version = "4.3.1", optional = true } -error-stack = "0.3.1" +error-stack = "0.4.1" mime = "0.3.17" reqwest = { version = "0.11.18", optional = true } serde = { version = "1.0.193", features = ["derive"] } diff --git a/crates/api_models/src/routing.rs b/crates/api_models/src/routing.rs index b82e5433e5a2..4d32f1d0f817 100644 --- a/crates/api_models/src/routing.rs +++ b/crates/api_models/src/routing.rs @@ -1,7 +1,6 @@ use std::fmt::Debug; use common_utils::errors::ParsingError; -use error_stack::IntoReport; pub use euclid::{ dssa::types::EuclidAnalysable, frontend::{ @@ -379,14 +378,12 @@ impl TryFrom for RoutingAlgorithm { RoutingAlgorithmSerde::Priority(i) if i.is_empty() => { Err(ParsingError::StructParseFailure( "Connectors list can't be empty for Priority Algorithm", - )) - .into_report()? + ))? } RoutingAlgorithmSerde::VolumeSplit(i) if i.is_empty() => { Err(ParsingError::StructParseFailure( "Connectors list can't be empty for Volume split Algorithm", - )) - .into_report()? + ))? } _ => {} }; @@ -446,14 +443,12 @@ impl TryFrom for StraightThroughAlgorithm { StraightThroughAlgorithmInner::Priority(i) if i.is_empty() => { Err(ParsingError::StructParseFailure( "Connectors list can't be empty for Priority Algorithm", - )) - .into_report()? + ))? } StraightThroughAlgorithmInner::VolumeSplit(i) if i.is_empty() => { Err(ParsingError::StructParseFailure( "Connectors list can't be empty for Volume split Algorithm", - )) - .into_report()? + ))? } _ => {} }; diff --git a/crates/cards/Cargo.toml b/crates/cards/Cargo.toml index 6892350ce6f4..bb185bf2167a 100644 --- a/crates/cards/Cargo.toml +++ b/crates/cards/Cargo.toml @@ -10,7 +10,7 @@ license.workspace = true [features] [dependencies] -error-stack = "0.3.1" +error-stack = "0.4.1" luhn = "1.0.1" serde = { version = "1.0.193", features = ["derive"] } thiserror = "1.0.40" diff --git a/crates/common_utils/Cargo.toml b/crates/common_utils/Cargo.toml index e8b3b726cec9..bc8a3af0a436 100644 --- a/crates/common_utils/Cargo.toml +++ b/crates/common_utils/Cargo.toml @@ -16,7 +16,7 @@ logs = ["dep:router_env"] async-trait = { version = "0.1.68", optional = true } bytes = "1.4.0" diesel = "2.1.0" -error-stack = "0.3.1" +error-stack = "0.4.1" futures = { version = "0.3.28", optional = true } hex = "0.4.3" http = "0.2.9" diff --git a/crates/common_utils/src/crypto.rs b/crates/common_utils/src/crypto.rs index 1a29f043e050..46904535f01a 100644 --- a/crates/common_utils/src/crypto.rs +++ b/crates/common_utils/src/crypto.rs @@ -1,7 +1,7 @@ //! Utilities for cryptographic algorithms use std::ops::Deref; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::{ExposeInterface, Secret}; use md5; use ring::{ @@ -248,18 +248,15 @@ impl EncodeMessage for GcmAes256 { secret: &[u8], msg: &[u8], ) -> CustomResult, errors::CryptoError> { - let nonce_sequence = NonceSequence::new() - .into_report() - .change_context(errors::CryptoError::EncodingFailed)?; + let nonce_sequence = + NonceSequence::new().change_context(errors::CryptoError::EncodingFailed)?; let current_nonce = nonce_sequence.current(); let key = UnboundKey::new(&aead::AES_256_GCM, secret) - .into_report() .change_context(errors::CryptoError::EncodingFailed)?; let mut key = SealingKey::new(key, nonce_sequence); let mut in_out = msg.to_vec(); key.seal_in_place_append_tag(aead::Aad::empty(), &mut in_out) - .into_report() .change_context(errors::CryptoError::EncodingFailed)?; in_out.splice(0..0, current_nonce); @@ -275,17 +272,15 @@ impl DecodeMessage for GcmAes256 { ) -> CustomResult, errors::CryptoError> { let msg = msg.expose(); let key = UnboundKey::new(&aead::AES_256_GCM, secret) - .into_report() .change_context(errors::CryptoError::DecodingFailed)?; let nonce_sequence = NonceSequence::from_bytes( - msg.get(..ring::aead::NONCE_LEN) - .ok_or(errors::CryptoError::DecodingFailed) - .into_report() - .attach_printable("Failed to read the nonce form the encrypted ciphertext")? - .try_into() - .into_report() - .change_context(errors::CryptoError::DecodingFailed)?, + <[u8; ring::aead::NONCE_LEN]>::try_from( + msg.get(..ring::aead::NONCE_LEN) + .ok_or(errors::CryptoError::DecodingFailed) + .attach_printable("Failed to read the nonce form the encrypted ciphertext")?, + ) + .change_context(errors::CryptoError::DecodingFailed)?, ); let mut key = OpeningKey::new(key, nonce_sequence); @@ -294,7 +289,6 @@ impl DecodeMessage for GcmAes256 { let result = key .open_within(aead::Aad::empty(), output, ring::aead::NONCE_LEN..) - .into_report() .change_context(errors::CryptoError::DecodingFailed)?; Ok(result.to_vec()) @@ -329,7 +323,6 @@ impl VerifySignature for Sha512 { msg: &[u8], ) -> CustomResult { let msg_str = std::str::from_utf8(msg) - .into_report() .change_context(errors::CryptoError::EncodingFailed)? .to_owned(); let hashed_digest = hex::encode( diff --git a/crates/common_utils/src/ext_traits.rs b/crates/common_utils/src/ext_traits.rs index 8f97dd755349..f71e098a99c8 100644 --- a/crates/common_utils/src/ext_traits.rs +++ b/crates/common_utils/src/ext_traits.rs @@ -3,7 +3,7 @@ //! & inbuilt datatypes. //! -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::{ExposeInterface, PeekInterface, Secret, Strategy}; use quick_xml::de; use serde::{Deserialize, Serialize}; @@ -101,7 +101,6 @@ where serde_json::to_string( &P::try_from(self).change_context(errors::ParsingError::UnknownError)?, ) - .into_report() .change_context(errors::ParsingError::EncodeError("string")) .attach_printable_lazy(|| format!("Unable to convert {self:?} to a request")) } @@ -115,7 +114,6 @@ where serde_urlencoded::to_string( &P::try_from(self).change_context(errors::ParsingError::UnknownError)?, ) - .into_report() .change_context(errors::ParsingError::EncodeError("url-encoded")) .attach_printable_lazy(|| format!("Unable to convert {self:?} to a request")) } @@ -126,7 +124,6 @@ where Self: Serialize, { serde_urlencoded::to_string(self) - .into_report() .change_context(errors::ParsingError::EncodeError("url-encoded")) .attach_printable_lazy(|| format!("Unable to convert {self:?} to a request")) } @@ -136,7 +133,6 @@ where Self: Serialize, { serde_json::to_string(self) - .into_report() .change_context(errors::ParsingError::EncodeError("json")) .attach_printable_lazy(|| format!("Unable to convert {self:?} to a request")) } @@ -146,7 +142,6 @@ where Self: Serialize, { quick_xml::se::to_string(self) - .into_report() .change_context(errors::ParsingError::EncodeError("xml")) .attach_printable_lazy(|| format!("Unable to convert {self:?} to a request")) } @@ -156,7 +151,6 @@ where Self: Serialize, { serde_json::to_value(self) - .into_report() .change_context(errors::ParsingError::EncodeError("json-value")) .attach_printable_lazy(|| format!("Unable to convert {self:?} to a value")) } @@ -166,7 +160,6 @@ where Self: Serialize, { serde_json::to_vec(self) - .into_report() .change_context(errors::ParsingError::EncodeError("byte-vec")) .attach_printable_lazy(|| format!("Unable to convert {self:?} to a value")) } @@ -198,7 +191,6 @@ impl BytesExt for bytes::Bytes { use bytes::Buf; serde_json::from_slice::(self.chunk()) - .into_report() .change_context(errors::ParsingError::StructParseFailure(type_name)) .attach_printable_lazy(|| { let variable_type = std::any::type_name::(); @@ -232,7 +224,6 @@ impl ByteSliceExt for [u8] { T: Deserialize<'de>, { serde_json::from_slice(self) - .into_report() .change_context(errors::ParsingError::StructParseFailure(type_name)) .attach_printable_lazy(|| format!("Unable to parse {type_name} from &[u8] {:?}", &self)) } @@ -260,7 +251,6 @@ impl ValueExt for serde_json::Value { &self ); serde_json::from_value::(self) - .into_report() .change_context(errors::ParsingError::StructParseFailure(type_name)) .attach_printable_lazy(|| debug) } @@ -318,7 +308,6 @@ impl StringExt for String { ::Err: std::error::Error + Send + Sync + 'static, { T::from_str(&self) - .into_report() .change_context(errors::ParsingError::EnumParseFailure(enum_name)) .attach_printable_lazy(|| format!("Invalid enum variant {self:?} for enum {enum_name}")) } @@ -331,7 +320,6 @@ impl StringExt for String { T: Deserialize<'de>, { serde_json::from_str::(self) - .into_report() .change_context(errors::ParsingError::StructParseFailure(type_name)) .attach_printable_lazy(|| { format!("Unable to parse {type_name} from string {:?}", &self) @@ -543,7 +531,6 @@ where Err(errors::ValidationError::MissingRequiredField { field_name: field_name.to_string(), }) - .into_report() .attach_printable(format!("Missing required field {field_name} in {self:?}")) }) } @@ -559,7 +546,6 @@ where None => Err(errors::ValidationError::MissingRequiredField { field_name: field_name.to_string(), }) - .into_report() .attach_printable(format!("Missing required field {field_name} in {self:?}")), } } @@ -576,7 +562,6 @@ where .change_context(errors::ParsingError::UnknownError)?; E::from_str(value.as_ref()) - .into_report() .change_context(errors::ParsingError::UnknownError) .attach_printable_lazy(|| format!("Invalid {{ {enum_name}: {value:?} }} ")) } diff --git a/crates/common_utils/src/pii.rs b/crates/common_utils/src/pii.rs index 110a7eb952c8..c1f9d716e4b1 100644 --- a/crates/common_utils/src/pii.rs +++ b/crates/common_utils/src/pii.rs @@ -10,7 +10,7 @@ use diesel::{ serialize::{Output, ToSql}, sql_types, AsExpression, }; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::{ExposeInterface, Secret, Strategy, WithType}; #[cfg(feature = "logs")] use router_env::logger; @@ -308,8 +308,8 @@ impl FromStr for Email { } Err(_) => Err(ValidationError::InvalidValue { message: "Invalid email address format".into(), - }) - .into_report(), + } + .into()), } } } diff --git a/crates/common_utils/src/types.rs b/crates/common_utils/src/types.rs index 7dfadd54a84e..418ce591fd28 100644 --- a/crates/common_utils/src/types.rs +++ b/crates/common_utils/src/types.rs @@ -8,7 +8,7 @@ use diesel::{ sql_types::Jsonb, AsExpression, FromSqlRow, }; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use semver::Version; use serde::{de::Visitor, Deserialize, Deserializer}; @@ -37,12 +37,11 @@ impl Percentage { if Self::is_valid_string_value(&value)? { Ok(Self { percentage: value - .parse() - .into_report() + .parse::() .change_context(PercentageError::InvalidPercentageValue)?, }) } else { - Err(PercentageError::InvalidPercentageValue.into()) + Err(report!(PercentageError::InvalidPercentageValue)) .attach_printable(get_invalid_percentage_error_message(PRECISION)) } } @@ -57,11 +56,10 @@ impl Percentage { let max_amount = i64::MAX / 10000; if amount > max_amount { // value gets rounded off after i64::MAX/10000 - Err(PercentageError::UnableToApplyPercentage { + Err(report!(PercentageError::UnableToApplyPercentage { percentage: self.percentage, amount, - } - .into()) + })) .attach_printable(format!( "Cannot calculate percentage for amount greater than {}", max_amount @@ -78,8 +76,7 @@ impl Percentage { } fn is_valid_float_string(value: &str) -> CustomResult { value - .parse() - .into_report() + .parse::() .change_context(PercentageError::InvalidPercentageValue) } fn is_valid_range(value: f32) -> bool { @@ -182,7 +179,7 @@ impl FromStr for SemanticVersion { type Err = error_stack::Report; fn from_str(s: &str) -> Result { - Ok(Self(Version::from_str(s).into_report().change_context( + Ok(Self(Version::from_str(s).change_context( ParsingError::StructParseFailure("SemanticVersion"), )?)) } diff --git a/crates/data_models/Cargo.toml b/crates/data_models/Cargo.toml index 9d4447b0c082..090983246d76 100644 --- a/crates/data_models/Cargo.toml +++ b/crates/data_models/Cargo.toml @@ -22,7 +22,7 @@ diesel_models = { version = "0.1.0", path = "../diesel_models", features = ["kv_ # Third party deps async-trait = "0.1.68" -error-stack = "0.3.1" +error-stack = "0.4.1" serde = { version = "1.0.193", features = ["derive"] } serde_json = "1.0.108" thiserror = "1.0.40" diff --git a/crates/data_models/src/mandates.rs b/crates/data_models/src/mandates.rs index fa22a4e57d5f..912ddc67058b 100644 --- a/crates/data_models/src/mandates.rs +++ b/crates/data_models/src/mandates.rs @@ -5,7 +5,7 @@ use api_models::payments::{ }; use common_enums::Currency; use common_utils::{date_time, errors::ParsingError, pii}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::{PeekInterface, Secret}; use time::PrimitiveDateTime; @@ -182,7 +182,6 @@ impl MandateAmountData { self.end_date .map(|date| { date_time::format_date(date, format) - .into_report() .change_context(ParsingError::DateTimeParsingError) }) .transpose() diff --git a/crates/diesel_models/Cargo.toml b/crates/diesel_models/Cargo.toml index 35a86f2e85cd..d0ef61693351 100644 --- a/crates/diesel_models/Cargo.toml +++ b/crates/diesel_models/Cargo.toml @@ -14,7 +14,7 @@ kv_store = [] [dependencies] async-bb8-diesel = { git = "https://github.com/jarnura/async-bb8-diesel", rev = "53b4ab901aab7635c8215fd1c2d542c8db443094" } diesel = { version = "2.1.0", features = ["postgres", "serde_json", "time", "64-column-tables"] } -error-stack = "0.3.1" +error-stack = "0.4.1" frunk = "0.4.1" frunk_core = "0.4.1" serde = { version = "1.0.193", features = ["derive"] } diff --git a/crates/diesel_models/src/kv.rs b/crates/diesel_models/src/kv.rs index cc67deb40c5d..38429b414bb6 100644 --- a/crates/diesel_models/src/kv.rs +++ b/crates/diesel_models/src/kv.rs @@ -1,4 +1,4 @@ -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use serde::{Deserialize, Serialize}; use crate::{ @@ -123,7 +123,6 @@ impl TypedSql { ( "typed_sql", serde_json::to_string(self) - .into_report() .change_context(errors::DatabaseError::QueryGenerationFailed)?, ), ("global_id", global_id), diff --git a/crates/diesel_models/src/query/events.rs b/crates/diesel_models/src/query/events.rs index 0fc856d600c0..1d92baaac46a 100644 --- a/crates/diesel_models/src/query/events.rs +++ b/crates/diesel_models/src/query/events.rs @@ -59,7 +59,7 @@ impl Event { ) -> StorageResult> { use async_bb8_diesel::AsyncRunQueryDsl; use diesel::{debug_query, pg::Pg, QueryDsl}; - use error_stack::{IntoReport, ResultExt}; + use error_stack::ResultExt; use router_env::logger; use super::generics::db_metrics::{track_database_call, DatabaseOperation}; @@ -95,7 +95,6 @@ impl Event { track_database_call::(query.get_results_async(conn), DatabaseOperation::Filter) .await - .into_report() .change_context(DatabaseError::Others) // Query returns empty Vec when no records are found .attach_printable("Error filtering events by constraints") } @@ -146,7 +145,7 @@ impl Event { ) -> StorageResult> { use async_bb8_diesel::AsyncRunQueryDsl; use diesel::{debug_query, pg::Pg, QueryDsl}; - use error_stack::{IntoReport, ResultExt}; + use error_stack::ResultExt; use router_env::logger; use super::generics::db_metrics::{track_database_call, DatabaseOperation}; @@ -182,7 +181,6 @@ impl Event { track_database_call::(query.get_results_async(conn), DatabaseOperation::Filter) .await - .into_report() .change_context(DatabaseError::Others) // Query returns empty Vec when no records are found .attach_printable("Error filtering events by constraints") } diff --git a/crates/diesel_models/src/query/generics.rs b/crates/diesel_models/src/query/generics.rs index 27c3d8706af2..0527ff3a181d 100644 --- a/crates/diesel_models/src/query/generics.rs +++ b/crates/diesel_models/src/query/generics.rs @@ -19,7 +19,7 @@ use diesel::{ result::Error as DieselError, Expression, Insertable, QueryDsl, QuerySource, Table, }; -use error_stack::{report, IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use router_env::logger; use crate::{errors, PgPooledConn, StorageResult}; @@ -86,14 +86,13 @@ where match track_database_call::(query.get_result_async(conn), DatabaseOperation::Insert) .await - .into_report() { Ok(value) => Ok(value), - Err(err) => match err.current_context() { + Err(err) => match err { DieselError::DatabaseError(diesel::result::DatabaseErrorKind::UniqueViolation, _) => { - Err(err).change_context(errors::DatabaseError::UniqueViolation) + Err(report!(err)).change_context(errors::DatabaseError::UniqueViolation) } - _ => Err(err).change_context(errors::DatabaseError::Others), + _ => Err(report!(err)).change_context(errors::DatabaseError::Others), }, } .attach_printable_lazy(|| format!("Error while inserting {debug_values}")) @@ -121,7 +120,6 @@ where track_database_call::(query.execute_async(conn), DatabaseOperation::Update) .await - .into_report() .change_context(errors::DatabaseError::Others) .attach_printable_lazy(|| format!("Error while updating {debug_values}")) } @@ -205,7 +203,6 @@ where } else { vec_r.pop().ok_or(errors::DatabaseError::Others) } - .into_report() .attach_printable("Maybe not queried using a unique key") })? } @@ -274,7 +271,6 @@ where track_database_call::(query.execute_async(conn), DatabaseOperation::Delete) .await - .into_report() .change_context(errors::DatabaseError::Others) .attach_printable("Error while deleting") .and_then(|result| match result { @@ -310,7 +306,6 @@ where DatabaseOperation::DeleteWithResult, ) .await - .into_report() .change_context(errors::DatabaseError::Others) .attach_printable("Error while deleting") .and_then(|result| { @@ -332,14 +327,14 @@ where let query = ::table().find(id.to_owned()); logger::debug!(query = %debug_query::(&query).to_string()); - match track_database_call::(query.first_async(conn), DatabaseOperation::FindOne) - .await - .into_report() + match track_database_call::(query.first_async(conn), DatabaseOperation::FindOne).await { Ok(value) => Ok(value), - Err(err) => match err.current_context() { - DieselError::NotFound => Err(err).change_context(errors::DatabaseError::NotFound), - _ => Err(err).change_context(errors::DatabaseError::Others), + Err(err) => match err { + DieselError::NotFound => { + Err(report!(err)).change_context(errors::DatabaseError::NotFound) + } + _ => Err(report!(err)).change_context(errors::DatabaseError::Others), }, } .attach_printable_lazy(|| format!("Error finding record by primary key: {id:?}")) @@ -382,10 +377,9 @@ where track_database_call::(query.get_result_async(conn), DatabaseOperation::FindOne) .await - .into_report() - .map_err(|err| match err.current_context() { - DieselError::NotFound => err.change_context(errors::DatabaseError::NotFound), - _ => err.change_context(errors::DatabaseError::Others), + .map_err(|err| match err { + DieselError::NotFound => report!(err).change_context(errors::DatabaseError::NotFound), + _ => report!(err).change_context(errors::DatabaseError::Others), }) .attach_printable("Error finding record by predicate") } @@ -449,7 +443,6 @@ where track_database_call::(query.get_results_async(conn), DatabaseOperation::Filter) .await - .into_report() .change_context(errors::DatabaseError::NotFound) .attach_printable("Error filtering records by predicate") } diff --git a/crates/diesel_models/src/query/payment_attempt.rs b/crates/diesel_models/src/query/payment_attempt.rs index 7e44059927b6..0133c52c5db4 100644 --- a/crates/diesel_models/src/query/payment_attempt.rs +++ b/crates/diesel_models/src/query/payment_attempt.rs @@ -5,7 +5,7 @@ use diesel::{ associations::HasTable, debug_query, pg::Pg, BoolExpressionMethods, ExpressionMethods, QueryDsl, Table, }; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use super::generics; use crate::{ @@ -89,30 +89,20 @@ impl PaymentAttempt { merchant_id: &str, ) -> StorageResult { // perform ordering on the application level instead of database level - generics::generic_filter::< - ::Table, - _, - <::Table as Table>::PrimaryKey, - Self, - >( + generics::generic_filter::<::Table, _, _, Self>( conn, dsl::payment_id .eq(payment_id.to_owned()) .and(dsl::merchant_id.eq(merchant_id.to_owned())) .and(dsl::status.eq(enums::AttemptStatus::Charged)), + Some(1), None, - None, - None, + Some(dsl::modified_at.desc()), ) .await? .into_iter() - .fold( - Err(DatabaseError::NotFound).into_report(), - |acc, cur| match acc { - Ok(value) if value.modified_at > cur.modified_at => Ok(value), - _ => Ok(cur), - }, - ) + .nth(0) + .ok_or(report!(DatabaseError::NotFound)) } pub async fn find_last_successful_or_partially_captured_attempt_by_payment_id_merchant_id( @@ -121,12 +111,7 @@ impl PaymentAttempt { merchant_id: &str, ) -> StorageResult { // perform ordering on the application level instead of database level - generics::generic_filter::< - ::Table, - _, - <::Table as Table>::PrimaryKey, - Self, - >( + generics::generic_filter::<::Table, _, _, Self>( conn, dsl::payment_id .eq(payment_id.to_owned()) @@ -136,19 +121,14 @@ impl PaymentAttempt { .eq(enums::AttemptStatus::Charged) .or(dsl::status.eq(enums::AttemptStatus::PartialCharged)), ), + Some(1), None, - None, - None, + Some(dsl::modified_at.desc()), ) .await? .into_iter() - .fold( - Err(DatabaseError::NotFound).into_report(), - |acc, cur| match acc { - Ok(value) if value.modified_at > cur.modified_at => Ok(value), - _ => Ok(cur), - }, - ) + .nth(0) + .ok_or(report!(DatabaseError::NotFound)) } pub async fn find_by_merchant_id_connector_txn_id( @@ -266,7 +246,6 @@ impl PaymentAttempt { .distinct() .get_results_async::>(conn) .await - .into_report() .change_context(errors::DatabaseError::Others) .attach_printable("Error filtering records by connector")? .into_iter() @@ -279,7 +258,6 @@ impl PaymentAttempt { .distinct() .get_results_async::>(conn) .await - .into_report() .change_context(DatabaseError::Others) .attach_printable("Error filtering records by currency")? .into_iter() @@ -292,7 +270,6 @@ impl PaymentAttempt { .distinct() .get_results_async::>(conn) .await - .into_report() .change_context(DatabaseError::Others) .attach_printable("Error filtering records by payment method")? .into_iter() @@ -305,7 +282,6 @@ impl PaymentAttempt { .distinct() .get_results_async::>(conn) .await - .into_report() .change_context(DatabaseError::Others) .attach_printable("Error filtering records by payment method type")? .into_iter() @@ -318,7 +294,6 @@ impl PaymentAttempt { .distinct() .get_results_async::>(conn) .await - .into_report() .change_context(DatabaseError::Others) .attach_printable("Error filtering records by authentication type")? .into_iter() @@ -369,7 +344,6 @@ impl PaymentAttempt { db_metrics::DatabaseOperation::Filter, ) .await - .into_report() .change_context(errors::DatabaseError::Others) .attach_printable("Error filtering count of payments") } diff --git a/crates/diesel_models/src/query/payment_method.rs b/crates/diesel_models/src/query/payment_method.rs index a27a2ae89502..7acf49a15705 100644 --- a/crates/diesel_models/src/query/payment_method.rs +++ b/crates/diesel_models/src/query/payment_method.rs @@ -3,7 +3,7 @@ use diesel::{ associations::HasTable, debug_query, pg::Pg, BoolExpressionMethods, ExpressionMethods, QueryDsl, Table, }; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use super::generics; use crate::{ @@ -124,7 +124,6 @@ impl PaymentMethod { generics::db_metrics::DatabaseOperation::Count, ) .await - .into_report() .change_context(errors::DatabaseError::Others) .attach_printable("Failed to get a count of payment methods") } diff --git a/crates/diesel_models/src/query/payout_attempt.rs b/crates/diesel_models/src/query/payout_attempt.rs index 085423710f06..ac34ee695acb 100644 --- a/crates/diesel_models/src/query/payout_attempt.rs +++ b/crates/diesel_models/src/query/payout_attempt.rs @@ -6,7 +6,7 @@ use diesel::{ query_dsl::methods::{DistinctDsl, FilterDsl, SelectDsl}, BoolExpressionMethods, ExpressionMethods, }; -use error_stack::{report, IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use super::generics; use crate::{ @@ -161,7 +161,6 @@ impl PayoutAttempt { .distinct() .get_results_async::>(conn) .await - .into_report() .change_context(errors::DatabaseError::Others) .attach_printable("Error filtering records by connector")? .into_iter() @@ -173,7 +172,6 @@ impl PayoutAttempt { .distinct() .get_results_async::(conn) .await - .into_report() .change_context(DatabaseError::Others) .attach_printable("Error filtering records by currency")? .into_iter() @@ -184,7 +182,6 @@ impl PayoutAttempt { .distinct() .get_results_async::(conn) .await - .into_report() .change_context(DatabaseError::Others) .attach_printable("Error filtering records by payout type")? .into_iter() diff --git a/crates/diesel_models/src/query/routing_algorithm.rs b/crates/diesel_models/src/query/routing_algorithm.rs index 28a5e6816e39..75a1f37f1794 100644 --- a/crates/diesel_models/src/query/routing_algorithm.rs +++ b/crates/diesel_models/src/query/routing_algorithm.rs @@ -1,6 +1,6 @@ use async_bb8_diesel::AsyncRunQueryDsl; use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods, QueryDsl}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use time::PrimitiveDateTime; use crate::{ @@ -78,12 +78,10 @@ impl RoutingAlgorithm { enums::TransactionType, )>(conn) .await - .into_report() .change_context(DatabaseError::Others)? .into_iter() .next() - .ok_or(DatabaseError::NotFound) - .into_report() + .ok_or(report!(DatabaseError::NotFound)) .map( |( profile_id, @@ -138,7 +136,6 @@ impl RoutingAlgorithm { enums::TransactionType, )>(conn) .await - .into_report() .change_context(DatabaseError::Others)? .into_iter() .map( @@ -197,7 +194,6 @@ impl RoutingAlgorithm { enums::TransactionType, )>(conn) .await - .into_report() .change_context(DatabaseError::Others)? .into_iter() .map( @@ -260,7 +256,6 @@ impl RoutingAlgorithm { enums::TransactionType, )>(conn) .await - .into_report() .change_context(DatabaseError::Others)? .into_iter() .map( diff --git a/crates/diesel_models/src/query/user.rs b/crates/diesel_models/src/query/user.rs index 9254a04de253..77d245cf5961 100644 --- a/crates/diesel_models/src/query/user.rs +++ b/crates/diesel_models/src/query/user.rs @@ -3,7 +3,7 @@ use diesel::{ associations::HasTable, debug_query, result::Error as DieselError, ExpressionMethods, JoinOnDsl, QueryDsl, }; -use error_stack::IntoReport; +use error_stack::report; use router_env::logger; pub mod sample_data; @@ -99,10 +99,11 @@ impl User { query .get_results_async::<(Self, UserRole)>(conn) .await - .into_report() - .map_err(|err| match err.current_context() { - DieselError::NotFound => err.change_context(errors::DatabaseError::NotFound), - _ => err.change_context(errors::DatabaseError::Others), + .map_err(|err| match err { + DieselError::NotFound => { + report!(err).change_context(errors::DatabaseError::NotFound) + } + _ => report!(err).change_context(errors::DatabaseError::Others), }) } } diff --git a/crates/diesel_models/src/query/user/sample_data.rs b/crates/diesel_models/src/query/user/sample_data.rs index a8ec2c3b0a4f..3a26b2cda8d3 100644 --- a/crates/diesel_models/src/query/user/sample_data.rs +++ b/crates/diesel_models/src/query/user/sample_data.rs @@ -1,6 +1,6 @@ use async_bb8_diesel::AsyncRunQueryDsl; use diesel::{associations::HasTable, debug_query, ExpressionMethods, TextExpressionMethods}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use router_env::logger; use crate::{ @@ -25,7 +25,6 @@ pub async fn insert_payment_intents( query .get_results_async(conn) .await - .into_report() .change_context(errors::DatabaseError::Others) .attach_printable("Error while inserting payment intents") } @@ -40,7 +39,6 @@ pub async fn insert_payment_attempts( query .get_results_async(conn) .await - .into_report() .change_context(errors::DatabaseError::Others) .attach_printable("Error while inserting payment attempts") } @@ -56,7 +54,6 @@ pub async fn insert_refunds( query .get_results_async(conn) .await - .into_report() .change_context(errors::DatabaseError::Others) .attach_printable("Error while inserting refunds") } @@ -74,7 +71,6 @@ pub async fn delete_payment_intents( query .get_results_async(conn) .await - .into_report() .change_context(errors::DatabaseError::Others) .attach_printable("Error while deleting payment intents") .and_then(|result| match result.len() { @@ -100,7 +96,6 @@ pub async fn delete_payment_attempts( query .get_results_async(conn) .await - .into_report() .change_context(errors::DatabaseError::Others) .attach_printable("Error while deleting payment attempts") .and_then(|result| match result.len() { @@ -124,7 +119,6 @@ pub async fn delete_refunds(conn: &PgPooledConn, merchant_id: &str) -> StorageRe query .get_results_async(conn) .await - .into_report() .change_context(errors::DatabaseError::Others) .attach_printable("Error while deleting refunds") .and_then(|result| match result.len() { diff --git a/crates/drainer/Cargo.toml b/crates/drainer/Cargo.toml index 2eea5b513cc3..4a2f7f1720e6 100644 --- a/crates/drainer/Cargo.toml +++ b/crates/drainer/Cargo.toml @@ -18,7 +18,7 @@ bb8 = "0.8" clap = { version = "4.3.2", default-features = false, features = ["std", "derive", "help", "usage"] } config = { version = "0.13.3", features = ["toml"] } diesel = { version = "2.1.0", features = ["postgres"] } -error-stack = "0.3.1" +error-stack = "0.4.1" mime = "0.3.17" once_cell = "1.18.0" reqwest = { version = "0.11.18" } diff --git a/crates/drainer/src/lib.rs b/crates/drainer/src/lib.rs index e7ae76213651..56f2db0907e1 100644 --- a/crates/drainer/src/lib.rs +++ b/crates/drainer/src/lib.rs @@ -16,7 +16,7 @@ mod secrets_transformers; use actix_web::dev::Server; use common_utils::signals::get_allowed_signals; use diesel_models::kv; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use hyperswitch_interfaces::secrets_interface::secret_state::RawSecret; use router_env::{ instrument, @@ -35,12 +35,9 @@ pub async fn start_drainer(store: Arc, conf: DrainerSettings) -> errors:: let (tx, rx) = mpsc::channel::<()>(1); - let signal = - get_allowed_signals() - .into_report() - .change_context(errors::DrainerError::SignalError( - "Failed while getting allowed signals".to_string(), - ))?; + let signal = get_allowed_signals().change_context(errors::DrainerError::SignalError( + "Failed while getting allowed signals".to_string(), + ))?; let handle = signal.handle(); let task_handle = tokio::spawn(common_utils::signals::signal_handler(signal, tx.clone()).in_current_span()); diff --git a/crates/drainer/src/stream.rs b/crates/drainer/src/stream.rs index b2775ac4ba1d..319fc2b0e1d3 100644 --- a/crates/drainer/src/stream.rs +++ b/crates/drainer/src/stream.rs @@ -1,6 +1,5 @@ use std::collections::HashMap; -use error_stack::IntoReport; use redis_interface as redis; use router_env::{logger, tracing}; @@ -66,7 +65,6 @@ impl Store { .stream_read_entries(stream_name, stream_id, Some(max_read_count)) .await .map_err(errors::DrainerError::from) - .into_report() }) .await; @@ -76,7 +74,7 @@ impl Store { &[metrics::KeyValue::new("stream", stream_name.to_owned())], ); - output + Ok(output?) } pub async fn trim_from_stream( &self, @@ -92,16 +90,14 @@ impl Store { .redis_conn .stream_trim_entries(stream_name, (trim_kind, trim_type, trim_id)) .await - .map_err(errors::DrainerError::from) - .into_report()?; + .map_err(errors::DrainerError::from)?; // Since xtrim deletes entries below given id excluding the given id. // Hence, deleting the minimum entry id self.redis_conn .stream_delete_entries(stream_name, minimum_entry_id) .await - .map_err(errors::DrainerError::from) - .into_report()?; + .map_err(errors::DrainerError::from)?; Ok(trim_result) }) diff --git a/crates/drainer/src/types.rs b/crates/drainer/src/types.rs index f1ddf8ef27e9..a61a0fd159c5 100644 --- a/crates/drainer/src/types.rs +++ b/crates/drainer/src/types.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use common_utils::errors; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use serde::{de::value::MapDeserializer, Deserialize, Serialize}; use crate::{ @@ -30,7 +30,6 @@ impl StreamData { >::new(hashmap.into_iter()); Self::deserialize(iter) - .into_report() .change_context(errors::ParsingError::StructParseFailure("StreamData")) } } diff --git a/crates/drainer/src/utils.rs b/crates/drainer/src/utils.rs index e27e04c30e68..c8c6e312f14b 100644 --- a/crates/drainer/src/utils.rs +++ b/crates/drainer/src/utils.rs @@ -1,6 +1,6 @@ use std::sync::{atomic, Arc}; -use error_stack::IntoReport; +use error_stack::report; use redis_interface as redis; use serde::de::Deserialize; @@ -13,14 +13,11 @@ pub fn parse_stream_entries<'a>( read_result: &'a StreamReadResult, stream_name: &str, ) -> errors::DrainerResult<&'a StreamEntries> { - read_result - .get(stream_name) - .ok_or_else(|| { - errors::DrainerError::RedisError(error_stack::report!( - redis::errors::RedisError::NotFound - )) - }) - .into_report() + read_result.get(stream_name).ok_or_else(|| { + report!(errors::DrainerError::RedisError(report!( + redis::errors::RedisError::NotFound + ))) + }) } pub(crate) fn deserialize_i64<'de, D>(deserializer: D) -> Result diff --git a/crates/external_services/Cargo.toml b/crates/external_services/Cargo.toml index e1ee11495e70..f19216f74d7d 100644 --- a/crates/external_services/Cargo.toml +++ b/crates/external_services/Cargo.toml @@ -23,7 +23,7 @@ aws-sdk-s3 = { version = "0.28.0", optional = true } aws-smithy-client = "0.55.3" base64 = "0.21.2" dyn-clone = "1.0.11" -error-stack = "0.3.1" +error-stack = "0.4.1" once_cell = "1.18.0" serde = { version = "1.0.193", features = ["derive"] } thiserror = "1.0.40" diff --git a/crates/external_services/src/aws_kms/core.rs b/crates/external_services/src/aws_kms/core.rs index d211f1def9b7..f63c2000fe8b 100644 --- a/crates/external_services/src/aws_kms/core.rs +++ b/crates/external_services/src/aws_kms/core.rs @@ -6,7 +6,7 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_kms::{config::Region, primitives::Blob, Client}; use base64::Engine; use common_utils::errors::CustomResult; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use router_env::logger; use crate::{consts, metrics}; @@ -49,7 +49,6 @@ impl AwsKmsClient { let start = Instant::now(); let data = consts::BASE64_ENGINE .decode(data) - .into_report() .change_context(AwsKmsError::Base64DecodingFailed)?; let ciphertext_blob = Blob::new(data); @@ -67,17 +66,13 @@ impl AwsKmsClient { metrics::AWS_KMS_DECRYPTION_FAILURES.add(&metrics::CONTEXT, 1, &[]); error }) - .into_report() .change_context(AwsKmsError::DecryptionFailed)?; let output = decrypt_output .plaintext - .ok_or(AwsKmsError::MissingPlaintextDecryptionOutput) - .into_report() + .ok_or(report!(AwsKmsError::MissingPlaintextDecryptionOutput)) .and_then(|blob| { - String::from_utf8(blob.into_inner()) - .into_report() - .change_context(AwsKmsError::Utf8DecodingFailed) + String::from_utf8(blob.into_inner()).change_context(AwsKmsError::Utf8DecodingFailed) })?; let time_taken = start.elapsed(); @@ -108,13 +103,11 @@ impl AwsKmsClient { metrics::AWS_KMS_ENCRYPTION_FAILURES.add(&metrics::CONTEXT, 1, &[]); error }) - .into_report() .change_context(AwsKmsError::EncryptionFailed)?; let output = encrypted_output .ciphertext_blob .ok_or(AwsKmsError::MissingCiphertextEncryptionOutput) - .into_report() .map(|blob| consts::BASE64_ENGINE.encode(blob.into_inner()))?; let time_taken = start.elapsed(); metrics::AWS_KMS_ENCRYPT_TIME.record(&metrics::CONTEXT, time_taken.as_secs_f64(), &[]); diff --git a/crates/external_services/src/email/ses.rs b/crates/external_services/src/email/ses.rs index de4d77949185..73599b344cd1 100644 --- a/crates/external_services/src/email/ses.rs +++ b/crates/external_services/src/email/ses.rs @@ -8,7 +8,7 @@ use aws_sdk_sesv2::{ }; use aws_sdk_sts::config::Credentials; use common_utils::{errors::CustomResult, ext_traits::OptionExt, pii}; -use error_stack::{report, IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use hyper::Uri; use masking::PeekInterface; use router_env::logger; @@ -102,7 +102,6 @@ impl AwsSes { .role_session_name(&ses_config.sts_role_session_name) .send() .await - .into_report() .change_context(AwsSesError::AssumeRoleFailure { region: conf.aws_region.to_owned(), role_arn: ses_config.email_role_arn.to_owned(), @@ -181,14 +180,12 @@ impl AwsSes { let proxy_uri = proxy_url .as_ref() .parse::() - .into_report() .attach_printable("Unable to parse the proxy url {proxy_url}") .change_context(AwsSesError::BuildingProxyConnectorFailed)?; let proxy = hyper_proxy::Proxy::new(hyper_proxy::Intercept::All, proxy_uri); hyper_proxy::ProxyConnector::from_proxy(hyper::client::HttpConnector::new(), proxy) - .into_report() .change_context(AwsSesError::BuildingProxyConnectorFailed) } } @@ -247,7 +244,6 @@ impl EmailClient for AwsSes { .send() .await .map_err(AwsSesError::SendingFailure) - .into_report() .change_context(EmailError::EmailSendingFailure)?; Ok(()) diff --git a/crates/external_services/src/file_storage/file_system.rs b/crates/external_services/src/file_storage/file_system.rs index 15ca84deeb8e..2c1ec287f5f2 100644 --- a/crates/external_services/src/file_storage/file_system.rs +++ b/crates/external_services/src/file_storage/file_system.rs @@ -9,7 +9,7 @@ use std::{ }; use common_utils::errors::CustomResult; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use crate::file_storage::{FileStorageError, FileStorageInterface}; @@ -45,18 +45,14 @@ impl FileSystem { file_path .parent() .ok_or(FileSystemStorageError::CreateDirFailed) - .into_report() .attach_printable("Failed to obtain parent directory")?, ) - .into_report() .change_context(FileSystemStorageError::CreateDirFailed)?; - let mut file_handler = File::create(file_path) - .into_report() - .change_context(FileSystemStorageError::CreateFailure)?; + let mut file_handler = + File::create(file_path).change_context(FileSystemStorageError::CreateFailure)?; file_handler .write_all(&file) - .into_report() .change_context(FileSystemStorageError::WriteFailure)?; Ok(()) } @@ -64,9 +60,7 @@ impl FileSystem { /// Deletes the file associated with the specified file key from the file system. async fn delete_file(&self, file_key: &str) -> CustomResult<(), FileSystemStorageError> { let file_path = get_file_path(file_key); - remove_file(file_path) - .into_report() - .change_context(FileSystemStorageError::DeleteFailure)?; + remove_file(file_path).change_context(FileSystemStorageError::DeleteFailure)?; Ok(()) } @@ -74,11 +68,9 @@ impl FileSystem { async fn retrieve_file(&self, file_key: &str) -> CustomResult, FileSystemStorageError> { let mut received_data: Vec = Vec::new(); let file_path = get_file_path(file_key); - let mut file = File::open(file_path) - .into_report() - .change_context(FileSystemStorageError::FileOpenFailure)?; + let mut file = + File::open(file_path).change_context(FileSystemStorageError::FileOpenFailure)?; file.read_to_end(&mut received_data) - .into_report() .change_context(FileSystemStorageError::ReadFailure)?; Ok(received_data) } diff --git a/crates/external_services/src/no_encryption/implementers.rs b/crates/external_services/src/no_encryption/implementers.rs index f67c7c85fd54..b880c3c13038 100644 --- a/crates/external_services/src/no_encryption/implementers.rs +++ b/crates/external_services/src/no_encryption/implementers.rs @@ -1,7 +1,7 @@ //! Trait implementations for No encryption client use common_utils::errors::CustomResult; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use hyperswitch_interfaces::{ encryption_interface::{EncryptionError, EncryptionManagementInterface}, secrets_interface::{SecretManagementInterface, SecretsManagementError}, @@ -29,7 +29,6 @@ impl SecretManagementInterface for NoEncryption { ) -> CustomResult, SecretsManagementError> { String::from_utf8(self.decrypt(input.expose())) .map(Into::into) - .into_report() .change_context(SecretsManagementError::FetchSecretFailed) .attach_printable("Failed to convert decrypted value to UTF-8") } diff --git a/crates/pm_auth/Cargo.toml b/crates/pm_auth/Cargo.toml index 9654932d5ef0..ef21539d4fa2 100644 --- a/crates/pm_auth/Cargo.toml +++ b/crates/pm_auth/Cargo.toml @@ -18,7 +18,7 @@ router_env = { version = "0.1.0", path = "../router_env", features = ["log_extra # Third party crates async-trait = "0.1.66" bytes = "1.4.0" -error-stack = "0.3.1" +error-stack = "0.4.1" http = "0.2.9" mime = "0.3.17" serde = "1.0.193" diff --git a/crates/redis_interface/Cargo.toml b/crates/redis_interface/Cargo.toml index 85cfef3df54c..233781b52e43 100644 --- a/crates/redis_interface/Cargo.toml +++ b/crates/redis_interface/Cargo.toml @@ -8,7 +8,7 @@ readme = "README.md" license.workspace = true [dependencies] -error-stack = "0.3.1" +error-stack = "0.4.1" fred = { version = "7.1.2", features = ["metrics", "partial-tracing", "subscriber-client", "check-unresponsive"] } futures = "0.3" serde = { version = "1.0.193", features = ["derive"] } diff --git a/crates/redis_interface/src/commands.rs b/crates/redis_interface/src/commands.rs index eb02e9bc82f1..21630fc3c087 100644 --- a/crates/redis_interface/src/commands.rs +++ b/crates/redis_interface/src/commands.rs @@ -13,7 +13,7 @@ use common_utils::{ ext_traits::{AsyncExt, ByteSliceExt, Encode, StringExt}, fp_utils, }; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use fred::{ interfaces::{HashesInterface, KeysInterface, SetsInterface, StreamsInterface}, prelude::RedisErrorKind, @@ -46,7 +46,6 @@ impl super::RedisConnectionPool { false, ) .await - .into_report() .change_context(errors::RedisError::SetFailed) } @@ -61,7 +60,6 @@ impl super::RedisConnectionPool { self.pool .msetnx(value) .await - .into_report() .change_context(errors::RedisError::SetFailed) } @@ -121,7 +119,6 @@ impl super::RedisConnectionPool { false, ) .await - .into_report() .change_context(errors::RedisError::SetExFailed) } @@ -133,7 +130,6 @@ impl super::RedisConnectionPool { self.pool .get(key) .await - .into_report() .change_context(errors::RedisError::GetFailed) } @@ -145,7 +141,6 @@ impl super::RedisConnectionPool { self.pool .exists(key) .await - .into_report() .change_context(errors::RedisError::GetFailed) } @@ -172,7 +167,6 @@ impl super::RedisConnectionPool { self.pool .del(key) .await - .into_report() .change_context(errors::RedisError::DeleteFailed) } @@ -190,7 +184,6 @@ impl super::RedisConnectionPool { self.pool .set(key, value, Some(Expiration::EX(seconds)), None, false) .await - .into_report() .change_context(errors::RedisError::SetExFailed) } @@ -216,7 +209,6 @@ impl super::RedisConnectionPool { false, ) .await - .into_report() .change_context(errors::RedisError::SetFailed) } @@ -229,7 +221,6 @@ impl super::RedisConnectionPool { self.pool .expire(key, seconds) .await - .into_report() .change_context(errors::RedisError::SetExpiryFailed) } @@ -242,7 +233,6 @@ impl super::RedisConnectionPool { self.pool .expire_at(key, timestamp) .await - .into_report() .change_context(errors::RedisError::SetExpiryFailed) } @@ -261,7 +251,6 @@ impl super::RedisConnectionPool { .pool .hset(key, values) .await - .into_report() .change_context(errors::RedisError::SetHashFailed); // setting expiry for the key output @@ -287,7 +276,6 @@ impl super::RedisConnectionPool { .pool .hsetnx(key, field, value) .await - .into_report() .change_context(errors::RedisError::SetHashFieldFailed); output @@ -330,7 +318,6 @@ impl super::RedisConnectionPool { self.pool .mget(keys) .await - .into_report() .change_context(errors::RedisError::GetFailed) } @@ -441,7 +428,6 @@ impl super::RedisConnectionPool { self.pool .hget(key, field) .await - .into_report() .change_context(errors::RedisError::GetHashFieldFailed) } @@ -479,7 +465,6 @@ impl super::RedisConnectionPool { self.pool .sadd(key, members) .await - .into_report() .change_context(errors::RedisError::SetAddMembersFailed) } @@ -497,7 +482,6 @@ impl super::RedisConnectionPool { self.pool .xadd(stream, false, None, entry_id, fields) .await - .into_report() .change_context(errors::RedisError::StreamAppendFailed) } @@ -513,7 +497,6 @@ impl super::RedisConnectionPool { self.pool .xdel(stream, ids) .await - .into_report() .change_context(errors::RedisError::StreamDeleteFailed) } @@ -530,7 +513,6 @@ impl super::RedisConnectionPool { self.pool .xtrim(stream, xcap) .await - .into_report() .change_context(errors::RedisError::StreamTrimFailed) } @@ -547,7 +529,6 @@ impl super::RedisConnectionPool { self.pool .xack(stream, group, ids) .await - .into_report() .change_context(errors::RedisError::StreamAcknowledgeFailed) } @@ -559,7 +540,6 @@ impl super::RedisConnectionPool { self.pool .xlen(stream) .await - .into_report() .change_context(errors::RedisError::GetLengthFailed) } @@ -582,12 +562,11 @@ impl super::RedisConnectionPool { ids, ) .await - .into_report() - .map_err(|err| match err.current_context().kind() { + .map_err(|err| match err.kind() { RedisErrorKind::NotFound | RedisErrorKind::Parse => { - err.change_context(errors::RedisError::StreamEmptyOrNotAvailable) + report!(err).change_context(errors::RedisError::StreamEmptyOrNotAvailable) } - _ => err.change_context(errors::RedisError::StreamReadFailed), + _ => report!(err).change_context(errors::RedisError::StreamReadFailed), }) } @@ -612,12 +591,11 @@ impl super::RedisConnectionPool { } None => self.pool.xread_map(count, block, streams, ids).await, } - .into_report() - .map_err(|err| match err.current_context().kind() { + .map_err(|err| match err.kind() { RedisErrorKind::NotFound | RedisErrorKind::Parse => { - err.change_context(errors::RedisError::StreamEmptyOrNotAvailable) + report!(err).change_context(errors::RedisError::StreamEmptyOrNotAvailable) } - _ => err.change_context(errors::RedisError::StreamReadFailed), + _ => report!(err).change_context(errors::RedisError::StreamReadFailed), }) } @@ -641,7 +619,6 @@ impl super::RedisConnectionPool { self.pool .xgroup_create(stream, group, id, true) .await - .into_report() .change_context(errors::RedisError::ConsumerGroupCreateFailed) } @@ -654,7 +631,6 @@ impl super::RedisConnectionPool { self.pool .xgroup_destroy(stream, group) .await - .into_report() .change_context(errors::RedisError::ConsumerGroupDestroyFailed) } @@ -669,7 +645,6 @@ impl super::RedisConnectionPool { self.pool .xgroup_delconsumer(stream, group, consumer) .await - .into_report() .change_context(errors::RedisError::ConsumerGroupRemoveConsumerFailed) } @@ -683,7 +658,6 @@ impl super::RedisConnectionPool { self.pool .xgroup_setid(stream, group, id) .await - .into_report() .change_context(errors::RedisError::ConsumerGroupSetIdFailed) } @@ -714,7 +688,6 @@ impl super::RedisConnectionPool { false, ) .await - .into_report() .change_context(errors::RedisError::ConsumerGroupClaimFailed) } } diff --git a/crates/redis_interface/src/lib.rs b/crates/redis_interface/src/lib.rs index b46e4aec1914..0ab1ea394c9a 100644 --- a/crates/redis_interface/src/lib.rs +++ b/crates/redis_interface/src/lib.rs @@ -23,7 +23,7 @@ pub mod types; use std::sync::{atomic, Arc}; use common_utils::errors::CustomResult; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; pub use fred::interfaces::PubsubInterface; use fred::{interfaces::ClientLike, prelude::EventInterface}; use router_env::logger; @@ -61,7 +61,6 @@ impl RedisClient { client .wait_for_connect() .await - .into_report() .change_context(errors::RedisError::RedisConnectionError)?; Ok(Self { inner: client }) } @@ -83,7 +82,6 @@ impl SubscriberClient { client .wait_for_connect() .await - .into_report() .change_context(errors::RedisError::RedisConnectionError)?; Ok(Self { inner: client }) } @@ -118,7 +116,6 @@ impl RedisConnectionPool { ), }; let mut config = fred::types::RedisConfig::from_url(&redis_connection_url) - .into_report() .change_context(errors::RedisError::RedisConnectionError)?; let perf = fred::types::PerformanceConfig { @@ -160,13 +157,11 @@ impl RedisConnectionPool { Some(reconnect_policy), conf.pool_size, ) - .into_report() .change_context(errors::RedisError::RedisConnectionError)?; pool.connect(); pool.wait_for_connect() .await - .into_report() .change_context(errors::RedisError::RedisConnectionError)?; let config = RedisConfig::from(conf); diff --git a/crates/redis_interface/src/types.rs b/crates/redis_interface/src/types.rs index cb883fc1693c..6469df507782 100644 --- a/crates/redis_interface/src/types.rs +++ b/crates/redis_interface/src/types.rs @@ -4,7 +4,6 @@ //! use common_utils::errors::CustomResult; -use error_stack::IntoReport; use fred::types::RedisValue as FredRedisValue; use crate::errors; @@ -69,14 +68,12 @@ impl RedisSettings { Err(errors::RedisError::InvalidConfiguration( "Redis `host` must be specified".into(), )) - .into_report() })?; when(self.cluster_enabled && self.cluster_urls.is_empty(), || { Err(errors::RedisError::InvalidConfiguration( "Redis `cluster_urls` must be specified if `cluster_enabled` is `true`".into(), )) - .into_report() })?; when( @@ -84,8 +81,8 @@ impl RedisSettings { || { Err(errors::RedisError::InvalidConfiguration( "Unresponsive timeout cannot be greater than the command timeout".into(), - )) - .into_report() + ) + .into()) }, ) } diff --git a/crates/router/Cargo.toml b/crates/router/Cargo.toml index df3097d9e577..288e2001876c 100644 --- a/crates/router/Cargo.toml +++ b/crates/router/Cargo.toml @@ -56,7 +56,7 @@ diesel = { version = "2.1.0", features = ["postgres"] } digest = "0.9" dyn-clone = "1.0.11" encoding_rs = "0.8.32" -error-stack = "0.3.1" +error-stack = "0.4.1" futures = "0.3.28" hex = "0.4.3" http = "0.2.9" diff --git a/crates/router/src/compatibility/stripe/payment_intents/types.rs b/crates/router/src/compatibility/stripe/payment_intents/types.rs index a74f16cee79d..5a26c5e26157 100644 --- a/crates/router/src/compatibility/stripe/payment_intents/types.rs +++ b/crates/router/src/compatibility/stripe/payment_intents/types.rs @@ -7,7 +7,7 @@ use common_utils::{ ext_traits::StringExt, pii::{IpAddress, SecretSerdeValue, UpiVpaMaskingStrategy}, }; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use serde::{Deserialize, Serialize}; use time::PrimitiveDateTime; @@ -298,7 +298,6 @@ impl TryFrom for payments::PaymentsRequest { }) .map(|r| { serde_json::to_value(r) - .into_report() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("converting to routing failed") }) @@ -308,7 +307,6 @@ impl TryFrom for payments::PaymentsRequest { .receipt_ipaddress .map(|ip| std::net::IpAddr::from_str(ip.as_str())) .transpose() - .into_report() .change_context(errors::ApiErrorResponse::InvalidDataFormat { field_name: "receipt_ipaddress".to_string(), expected_format: "127.0.0.1".to_string(), @@ -383,7 +381,6 @@ impl TryFrom for payments::PaymentsRequest { user_agent: item.user_agent, ..Default::default() }) - .into_report() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("convert to browser info failed")?, ), @@ -720,10 +717,12 @@ impl ForeignTryFrom<(Option, Option)> for Option, Option), ) -> errors::RouterResult { let currency = currency - .ok_or(errors::ApiErrorResponse::MissingRequiredField { - field_name: "currency", - }) - .into_report() + .ok_or( + errors::ApiErrorResponse::MissingRequiredField { + field_name: "currency", + } + .into(), + ) .and_then(|c| { c.to_uppercase().parse_enum("currency").change_context( errors::ApiErrorResponse::InvalidDataValue { diff --git a/crates/router/src/compatibility/stripe/setup_intents/types.rs b/crates/router/src/compatibility/stripe/setup_intents/types.rs index a05a8c241d00..6fb6b6c808b7 100644 --- a/crates/router/src/compatibility/stripe/setup_intents/types.rs +++ b/crates/router/src/compatibility/stripe/setup_intents/types.rs @@ -2,7 +2,7 @@ use std::str::FromStr; use api_models::payments; use common_utils::{date_time, ext_traits::StringExt, pii as secret}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use router_env::logger; use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -201,7 +201,6 @@ impl TryFrom for payments::PaymentsRequest { }) .map(|r| { serde_json::to_value(r) - .into_report() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("converting to routing failed") }) @@ -210,7 +209,6 @@ impl TryFrom for payments::PaymentsRequest { .receipt_ipaddress .map(|ip| std::net::IpAddr::from_str(ip.as_str())) .transpose() - .into_report() .change_context(errors::ApiErrorResponse::InvalidDataFormat { field_name: "receipt_ipaddress".to_string(), expected_format: "127.0.0.1".to_string(), @@ -292,7 +290,6 @@ impl TryFrom for payments::PaymentsRequest { user_agent: item.user_agent, ..Default::default() }) - .into_report() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("convert to browser info failed")?, ), diff --git a/crates/router/src/compatibility/stripe/webhooks.rs b/crates/router/src/compatibility/stripe/webhooks.rs index 777c36f301da..77e2c85abb43 100644 --- a/crates/router/src/compatibility/stripe/webhooks.rs +++ b/crates/router/src/compatibility/stripe/webhooks.rs @@ -3,7 +3,7 @@ use api_models::{ webhooks::{self as api}, }; use common_utils::{crypto::SignMessage, date_time, ext_traits::Encode}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use router_env::logger; use serde::Serialize; @@ -39,7 +39,6 @@ impl OutgoingWebhookType for StripeOutgoingWebhook { let payment_response_hash_key = payment_response_hash_key .ok_or(errors::WebhooksFlowError::MerchantConfigNotFound) - .into_report() .attach_printable("For stripe compatibility payment_response_hash_key is mandatory")?; let webhook_signature_payload = self diff --git a/crates/router/src/connection.rs b/crates/router/src/connection.rs index 6c10f95ea798..009149b7225a 100644 --- a/crates/router/src/connection.rs +++ b/crates/router/src/connection.rs @@ -1,6 +1,6 @@ use bb8::PooledConnection; use diesel::PgConnection; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use storage_impl::errors as storage_errors; use crate::errors; @@ -45,7 +45,6 @@ pub async fn pg_connection_read( pool.get() .await - .into_report() .change_context(storage_errors::StorageError::DatabaseConnectionError) } @@ -60,6 +59,5 @@ pub async fn pg_connection_write( pool.get() .await - .into_report() .change_context(storage_errors::StorageError::DatabaseConnectionError) } diff --git a/crates/router/src/connector/aci.rs b/crates/router/src/connector/aci.rs index b20b27f0228b..a6599405b4ae 100644 --- a/crates/router/src/connector/aci.rs +++ b/crates/router/src/connector/aci.rs @@ -3,7 +3,7 @@ pub mod transformers; use std::fmt::Debug; use common_utils::request::RequestContent; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use masking::PeekInterface; use transformers as aci; @@ -47,8 +47,7 @@ impl ConnectorCommon for Aci { &self, auth_type: &types::ConnectorAuthType, ) -> CustomResult)>, errors::ConnectorError> { - let auth: aci::AciAuthType = auth_type - .try_into() + let auth = aci::AciAuthType::try_from(auth_type) .change_context(errors::ConnectorError::FailedToObtainAuthType)?; Ok(vec![( headers::AUTHORIZATION.to_string(), @@ -575,7 +574,7 @@ impl api::IncomingWebhook for Aci { &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_event_type( @@ -589,6 +588,6 @@ impl api::IncomingWebhook for Aci { &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } diff --git a/crates/router/src/connector/adyen.rs b/crates/router/src/connector/adyen.rs index d79761da4725..44e889ed9db8 100644 --- a/crates/router/src/connector/adyen.rs +++ b/crates/router/src/connector/adyen.rs @@ -6,7 +6,7 @@ use api_models::{enums::PaymentMethodType, webhooks::IncomingWebhookEvent}; use base64::Engine; use common_utils::request::RequestContent; use diesel_models::{enums as storage_enums, enums}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use masking::ExposeInterface; use ring::hmac; use router_env::{instrument, tracing}; @@ -568,7 +568,6 @@ impl let adyen_redirection_type = serde_urlencoded::from_str::< transformers::AdyenRedirectRequestTypes, >(encoded_data.as_str()) - .into_report() .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; let connector_req = match adyen_redirection_type { @@ -1649,8 +1648,7 @@ fn get_webhook_object_from_body( .drain(..) .next() // TODO: ParsingError doesn't seem to be an apt error for this case - .ok_or(errors::ParsingError::UnknownError) - .into_report()?; + .ok_or(errors::ParsingError::UnknownError)?; Ok(item_object.notification_request_item) } @@ -1729,7 +1727,6 @@ impl api::IncomingWebhook for Adyen { .change_context(errors::ConnectorError::WebhookSourceVerificationFailed)?; let raw_key = hex::decode(connector_webhook_secrets.secret) - .into_report() .change_context(errors::ConnectorError::WebhookVerificationSecretInvalid)?; let signing_key = hmac::Key::new(hmac::HMAC_SHA256, &raw_key); @@ -1773,7 +1770,7 @@ impl api::IncomingWebhook for Adyen { ), )); } - Err(errors::ConnectorError::WebhookReferenceIdNotFound).into_report() + Err(report!(errors::ConnectorError::WebhookReferenceIdNotFound)) } fn get_webhook_event_type( diff --git a/crates/router/src/connector/adyen/transformers.rs b/crates/router/src/connector/adyen/transformers.rs index e5fe5374c451..b301be7f577f 100644 --- a/crates/router/src/connector/adyen/transformers.rs +++ b/crates/router/src/connector/adyen/transformers.rs @@ -3,7 +3,7 @@ use api_models::payouts::PayoutMethodData; use api_models::{enums, payments, webhooks}; use cards::CardNumber; use common_utils::{ext_traits::Encode, pii}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use masking::{ExposeInterface, PeekInterface}; use reqwest::Url; use serde::{Deserialize, Serialize}; @@ -294,7 +294,7 @@ impl ForeignTryFrom<(bool, AdyenWebhookStatus)> for storage_enums::AttemptStatus //If Unexpected Event is received, need to understand how it reached this point //Webhooks with Payment Events only should try to conume this resource object. AdyenWebhookStatus::UnexpectedEvent => { - Err(errors::ConnectorError::WebhookBodyDecodingFailed).into_report() + Err(report!(errors::ConnectorError::WebhookBodyDecodingFailed)) } } } diff --git a/crates/router/src/connector/airwallex.rs b/crates/router/src/connector/airwallex.rs index defc6a339fb0..6a8f384e199a 100644 --- a/crates/router/src/connector/airwallex.rs +++ b/crates/router/src/connector/airwallex.rs @@ -7,7 +7,7 @@ use common_utils::{ request::RequestContent, }; use diesel_models::enums; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use masking::PeekInterface; use transformers as airwallex; @@ -223,12 +223,11 @@ impl ConnectorIntegration for AirwallexCompleteR .as_ref() .map(|data| serde_json::to_string(data.peek())) .transpose() - .into_report() .change_context(errors::ConnectorError::ResponseDeserializationFailed)? .map(Secret::new), }, diff --git a/crates/router/src/connector/authorizedotnet.rs b/crates/router/src/connector/authorizedotnet.rs index be02b4524f8e..946fded930da 100644 --- a/crates/router/src/connector/authorizedotnet.rs +++ b/crates/router/src/connector/authorizedotnet.rs @@ -4,7 +4,7 @@ use std::fmt::Debug; use common_utils::{crypto, ext_traits::ByteSliceExt, request::RequestContent}; use diesel_models::enums; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use transformers as authorizedotnet; use crate::{ @@ -833,18 +833,13 @@ impl api::IncomingWebhook for Authorizedotnet { .to_str() .map(String::from) .map_err(|_| errors::ConnectorError::WebhookSignatureNotFound) - .into_report() }) - .ok_or(errors::ConnectorError::WebhookSignatureNotFound) - .into_report()?? + .ok_or(errors::ConnectorError::WebhookSignatureNotFound)?? .to_lowercase(); let (_, sig_value) = security_header .split_once('=') - .ok_or(errors::ConnectorError::WebhookSourceVerificationFailed) - .into_report()?; - hex::decode(sig_value) - .into_report() - .change_context(errors::ConnectorError::WebhookSignatureNotFound) + .ok_or(errors::ConnectorError::WebhookSourceVerificationFailed)?; + hex::decode(sig_value).change_context(errors::ConnectorError::WebhookSignatureNotFound) } fn get_webhook_source_verification_message( diff --git a/crates/router/src/connector/authorizedotnet/transformers.rs b/crates/router/src/connector/authorizedotnet/transformers.rs index 4a79b179b84f..2e5a9f3bbcba 100644 --- a/crates/router/src/connector/authorizedotnet/transformers.rs +++ b/crates/router/src/connector/authorizedotnet/transformers.rs @@ -2,7 +2,7 @@ use common_utils::{ errors::CustomResult, ext_traits::{Encode, ValueExt}, }; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::{ExposeInterface, PeekInterface, Secret, StrongSecret}; use serde::{Deserialize, Serialize}; @@ -1395,7 +1395,6 @@ impl TryFrom<&AuthorizedotnetRouterData<&types::PaymentsCompleteAuthorizeRouterD .ok_or(errors::ConnectorError::ResponseDeserializationFailed)?; let payer_id: Secret = serde_urlencoded::from_str::(params.peek()) - .into_report() .change_context(errors::ConnectorError::ResponseDeserializationFailed)? .payer_id; let transaction_type = match item.router_data.request.capture_method { diff --git a/crates/router/src/connector/bambora.rs b/crates/router/src/connector/bambora.rs index d453677deb6e..a9bfc54313d9 100644 --- a/crates/router/src/connector/bambora.rs +++ b/crates/router/src/connector/bambora.rs @@ -4,7 +4,7 @@ use std::fmt::Debug; use common_utils::request::RequestContent; use diesel_models::enums; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use transformers as bambora; use super::utils::RefundsRequestData; @@ -74,8 +74,7 @@ impl ConnectorCommon for Bambora { &self, auth_type: &types::ConnectorAuthType, ) -> CustomResult)>, errors::ConnectorError> { - let auth: bambora::BamboraAuthType = auth_type - .try_into() + let auth = bambora::BamboraAuthType::try_from(auth_type) .change_context(errors::ConnectorError::FailedToObtainAuthType)?; Ok(vec![( headers::AUTHORIZATION.to_string(), @@ -607,7 +606,7 @@ impl ConnectorIntegration, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_event_type( @@ -718,7 +717,7 @@ impl api::IncomingWebhook for Bambora { &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } diff --git a/crates/router/src/connector/bambora/transformers.rs b/crates/router/src/connector/bambora/transformers.rs index c47b0718287c..40c3219d353e 100644 --- a/crates/router/src/connector/bambora/transformers.rs +++ b/crates/router/src/connector/bambora/transformers.rs @@ -1,6 +1,6 @@ use base64::Engine; use common_utils::{ext_traits::ValueExt, pii::IpAddress}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::{ExposeInterface, PeekInterface, Secret}; use serde::{Deserialize, Deserializer, Serialize}; @@ -239,7 +239,6 @@ impl serde_json::to_value(BamboraMeta { three_d_session_data: response.three_d_session_data.expose(), }) - .into_report() .change_context(errors::ConnectorError::ResponseHandlingFailed)?, ), network_txn_id: None, diff --git a/crates/router/src/connector/bankofamerica.rs b/crates/router/src/connector/bankofamerica.rs index aac441201eb0..15c19622bc9a 100644 --- a/crates/router/src/connector/bankofamerica.rs +++ b/crates/router/src/connector/bankofamerica.rs @@ -5,7 +5,7 @@ use std::fmt::Debug; use base64::Engine; use common_utils::request::RequestContent; use diesel_models::enums; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use masking::{ExposeInterface, PeekInterface}; use ring::{digest, hmac}; use time::OffsetDateTime; @@ -87,7 +87,6 @@ impl Bankofamerica { ); let key_value = consts::BASE64_ENGINE .decode(api_secret.expose()) - .into_report() .change_context(errors::ConnectorError::InvalidConnectorConfig { config: "connector_account_details.api_secret", })?; @@ -129,9 +128,8 @@ where let auth = bankofamerica::BankOfAmericaAuthType::try_from(&req.connector_auth_type)?; let merchant_account = auth.merchant_account.clone(); let base_url = connectors.bankofamerica.base_url.as_str(); - let boa_host = Url::parse(base_url) - .into_report() - .change_context(errors::ConnectorError::RequestEncodingFailed)?; + let boa_host = + Url::parse(base_url).change_context(errors::ConnectorError::RequestEncodingFailed)?; let host = boa_host .host_str() .ok_or(errors::ConnectorError::RequestEncodingFailed)?; @@ -1175,20 +1173,20 @@ impl api::IncomingWebhook for Bankofamerica { &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_event_type( &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_resource_object( &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } diff --git a/crates/router/src/connector/bankofamerica/transformers.rs b/crates/router/src/connector/bankofamerica/transformers.rs index b4b8ce87ec86..c5a4f0b317aa 100644 --- a/crates/router/src/connector/bankofamerica/transformers.rs +++ b/crates/router/src/connector/bankofamerica/transformers.rs @@ -1,7 +1,7 @@ use api_models::payments; use base64::Engine; use common_utils::{ext_traits::ValueExt, pii}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::{ExposeInterface, PeekInterface, Secret}; use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -1500,7 +1500,6 @@ impl .consumer_authentication_information .validate_response, ) - .into_report() .change_context(errors::ConnectorError::ResponseHandlingFailed)?; Ok(Self { status, diff --git a/crates/router/src/connector/billwerk.rs b/crates/router/src/connector/billwerk.rs index c7d81e06c324..154b729abc9a 100644 --- a/crates/router/src/connector/billwerk.rs +++ b/crates/router/src/connector/billwerk.rs @@ -2,7 +2,7 @@ pub mod transformers; use std::fmt::Debug; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use masking::ExposeInterface; use transformers as billwerk; @@ -542,20 +542,20 @@ impl api::IncomingWebhook for Billwerk { &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_event_type( &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_resource_object( &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } diff --git a/crates/router/src/connector/bluesnap.rs b/crates/router/src/connector/bluesnap.rs index 71e140ca0748..e32ebfc6f459 100644 --- a/crates/router/src/connector/bluesnap.rs +++ b/crates/router/src/connector/bluesnap.rs @@ -9,7 +9,7 @@ use common_utils::{ request::RequestContent, }; use diesel_models::enums; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use masking::PeekInterface; use transformers as bluesnap; @@ -83,8 +83,7 @@ impl ConnectorCommon for Bluesnap { &self, auth_type: &types::ConnectorAuthType, ) -> CustomResult)>, errors::ConnectorError> { - let auth: bluesnap::BluesnapAuthType = auth_type - .try_into() + let auth = bluesnap::BluesnapAuthType::try_from(auth_type) .change_context(errors::ConnectorError::FailedToObtainAuthType)?; let encoded_api_key = consts::BASE64_ENGINE.encode(format!("{}:{}", auth.key1.peek(), auth.api_key.peek())); @@ -195,9 +194,9 @@ impl ConnectorValidation for Bluesnap { return Err( errors::ConnectorError::MissingConnectorRelatedTransactionID { id: "connector_transaction_id".to_string(), - }, - ) - .into_report(); + } + .into(), + ); } // if connector_transaction_id is present, psync can be made if data @@ -1051,7 +1050,6 @@ impl api::IncomingWebhook for Bluesnap { connector_utils::get_header_key_value("bls-signature", request.headers)?; hex::decode(security_header) - .into_report() .change_context(errors::ConnectorError::WebhookSignatureNotFound) } fn get_webhook_source_verification_message( @@ -1071,7 +1069,6 @@ impl api::IncomingWebhook for Bluesnap { ) -> CustomResult { let webhook_body: bluesnap::BluesnapWebhookBody = serde_urlencoded::from_bytes(request.body) - .into_report() .change_context(errors::ConnectorError::WebhookReferenceIdNotFound)?; match webhook_body.transaction_type { bluesnap::BluesnapWebhookEvents::Decline @@ -1103,7 +1100,7 @@ impl api::IncomingWebhook for Bluesnap { )) } bluesnap::BluesnapWebhookEvents::Unknown => { - Err(errors::ConnectorError::WebhookReferenceIdNotFound).into_report() + Err(report!(errors::ConnectorError::WebhookReferenceIdNotFound)) } } } @@ -1114,7 +1111,6 @@ impl api::IncomingWebhook for Bluesnap { ) -> CustomResult { let details: bluesnap::BluesnapWebhookObjectEventType = serde_urlencoded::from_bytes(request.body) - .into_report() .change_context(errors::ConnectorError::WebhookEventTypeNotFound)?; api::IncomingWebhookEvent::try_from(details) } @@ -1125,7 +1121,6 @@ impl api::IncomingWebhook for Bluesnap { ) -> CustomResult { let dispute_details: bluesnap::BluesnapDisputeWebhookBody = serde_urlencoded::from_bytes(request.body) - .into_report() .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; Ok(api::disputes::DisputePayload { amount: connector_utils::to_currency_lower_unit( @@ -1150,7 +1145,6 @@ impl api::IncomingWebhook for Bluesnap { ) -> CustomResult, errors::ConnectorError> { let resource: bluesnap::BluesnapWebhookObjectResource = serde_urlencoded::from_bytes(request.body) - .into_report() .change_context(errors::ConnectorError::WebhookResourceObjectNotFound)?; Ok(Box::new(resource)) diff --git a/crates/router/src/connector/bluesnap/transformers.rs b/crates/router/src/connector/bluesnap/transformers.rs index a48e38705c42..e22d27e4b833 100644 --- a/crates/router/src/connector/bluesnap/transformers.rs +++ b/crates/router/src/connector/bluesnap/transformers.rs @@ -7,7 +7,7 @@ use common_utils::{ ext_traits::{ByteSliceExt, StringExt, ValueExt}, pii::Email, }; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::{ExposeInterface, PeekInterface}; use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -249,8 +249,8 @@ impl TryFrom<&BluesnapRouterData<&types::PaymentsAuthorizeRouterData>> | payments::PaymentMethodData::CardToken(_) => { Err(errors::ConnectorError::NotImplemented( "Selected payment method via Token flow through bluesnap".to_string(), - )) - .into_report() + ) + .into()) } } } @@ -496,7 +496,6 @@ impl TryFrom for Value { BluesnapWebhookEvents::Chargeback | BluesnapWebhookEvents::ChargebackStatusChanged => { //It won't be consumed in dispute flow, so currently does not hold any significance return serde_json::to_value(details) - .into_report() .change_context(errors::ConnectorError::WebhookBodyDecodingFailed); } BluesnapWebhookEvents::Refund => Ok(( @@ -1082,7 +1080,7 @@ impl TryFrom for Value { .ok_or(errors::ConnectorError::WebhookResourceObjectNotFound)?, )), BluesnapWebhookEvents::Unknown => { - Err(errors::ConnectorError::WebhookResourceObjectNotFound).into_report() + Err(errors::ConnectorError::WebhookResourceObjectNotFound) } }?; let sync_struct = BluesnapPaymentsResponse { @@ -1095,7 +1093,6 @@ impl TryFrom for Value { card_transaction_type, }; serde_json::to_value(sync_struct) - .into_report() .change_context(errors::ConnectorError::WebhookBodyDecodingFailed) } } diff --git a/crates/router/src/connector/boku.rs b/crates/router/src/connector/boku.rs index b3e26430924b..7c456d2ec1c2 100644 --- a/crates/router/src/connector/boku.rs +++ b/crates/router/src/connector/boku.rs @@ -3,7 +3,7 @@ use std::fmt::Debug; use common_utils::{ext_traits::XmlExt, request::RequestContent}; use diesel_models::enums; -use error_stack::{IntoReport, Report, ResultExt}; +use error_stack::{report, Report, ResultExt}; use masking::{ExposeInterface, PeekInterface, Secret, WithType}; use ring::hmac; use roxmltree; @@ -263,12 +263,10 @@ impl ConnectorIntegration CustomResult { let response_data = String::from_utf8(res.response.to_vec()) - .into_report() .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; let response = response_data .parse_xml::() - .into_report() .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; event_builder.map(|i| i.set_response_body(&response)); router_env::logger::info!(connector_response=?response); @@ -350,12 +348,10 @@ impl ConnectorIntegration CustomResult { let response_data = String::from_utf8(res.response.to_vec()) - .into_report() .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; let response = response_data .parse_xml::() - .into_report() .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; event_builder.map(|i| i.set_response_body(&response)); router_env::logger::info!(connector_response=?response); @@ -433,12 +429,10 @@ impl ConnectorIntegration CustomResult { let response_data = String::from_utf8(res.response.to_vec()) - .into_report() .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; let response = response_data .parse_xml::() - .into_report() .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; event_builder.map(|i| i.set_response_body(&response)); router_env::logger::info!(connector_response=?response); @@ -634,21 +628,21 @@ impl api::IncomingWebhook for Boku { &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_event_type( &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_resource_object( &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } @@ -675,7 +669,6 @@ fn get_xml_deserialized( ); let response_data = String::from_utf8(res.response.to_vec()) - .into_report() .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; event_builder.map(|i| i.set_error_response_body(&response_data)); diff --git a/crates/router/src/connector/braintree.rs b/crates/router/src/connector/braintree.rs index b080db1df633..41133e3f670f 100644 --- a/crates/router/src/connector/braintree.rs +++ b/crates/router/src/connector/braintree.rs @@ -6,7 +6,7 @@ use api_models::webhooks::IncomingWebhookEvent; use base64::Engine; use common_utils::{crypto, ext_traits::XmlExt, request::RequestContent}; use diesel_models::enums; -use error_stack::{IntoReport, Report, ResultExt}; +use error_stack::{report, Report, ResultExt}; use masking::{ExposeInterface, PeekInterface}; use ring::hmac; use sha1::{Digest, Sha1}; @@ -92,8 +92,7 @@ impl ConnectorCommon for Braintree { &self, auth_type: &types::ConnectorAuthType, ) -> CustomResult)>, errors::ConnectorError> { - let auth: braintree::BraintreeAuthType = auth_type - .try_into() + let auth = braintree::BraintreeAuthType::try_from(auth_type) .change_context(errors::ConnectorError::FailedToObtainAuthType)?; Ok(vec![( headers::AUTHORIZATION.to_string(), @@ -631,7 +630,7 @@ impl ConnectorIntegration Err(errors::ConnectorError::RequestEncodingFailed).into_report(), + false => Err(report!(errors::ConnectorError::RequestEncodingFailed)), } } @@ -978,7 +977,7 @@ impl ConnectorIntegration Err(errors::ConnectorError::RequestEncodingFailed).into_report(), + false => Err(report!(errors::ConnectorError::RequestEncodingFailed)), } } @@ -1242,7 +1241,7 @@ impl ConnectorIntegration Err(errors::ConnectorError::RequestEncodingFailed).into_report(), + false => Err(report!(errors::ConnectorError::RequestEncodingFailed)), } } @@ -1419,7 +1418,7 @@ impl api::IncomingWebhook for Braintree { dispute_data.transaction.id, ), )), - None => Err(errors::ConnectorError::WebhookReferenceIdNotFound).into_report(), + None => Err(report!(errors::ConnectorError::WebhookReferenceIdNotFound)), } } @@ -1471,7 +1470,6 @@ impl api::IncomingWebhook for Braintree { let currency = diesel_models::enums::Currency::from_str( dispute_data.currency_iso_code.as_str(), ) - .into_report() .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; Ok(api::disputes::DisputePayload { amount: connector_utils::to_currency_lower_unit( @@ -1512,7 +1510,6 @@ fn get_webhook_object_from_body( body: &[u8], ) -> CustomResult { serde_urlencoded::from_bytes::(body) - .into_report() .change_context(errors::ParsingError::StructParseFailure( "BraintreeWebhookResponse", )) @@ -1523,16 +1520,13 @@ fn decode_webhook_payload( ) -> CustomResult { let decoded_response = consts::BASE64_ENGINE .decode(payload) - .into_report() .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; let xml_response = String::from_utf8(decoded_response) - .into_report() .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; xml_response .parse_xml::() - .into_report() .change_context(errors::ConnectorError::WebhookBodyDecodingFailed) } @@ -1547,7 +1541,7 @@ impl services::ConnectorRedirectResponse for Braintree { services::PaymentAction::PSync => match json_payload { Some(payload) => { let redirection_response:braintree_graphql_transformers::BraintreeRedirectionResponse = serde_json::from_value(payload) - .into_report() + .change_context( errors::ConnectorError::MissingConnectorRedirectionPayload { field_name: "redirection_response", diff --git a/crates/router/src/connector/braintree/braintree_graphql_transformers.rs b/crates/router/src/connector/braintree/braintree_graphql_transformers.rs index 78c4ee0e100a..1f933392f2b3 100644 --- a/crates/router/src/connector/braintree/braintree_graphql_transformers.rs +++ b/crates/router/src/connector/braintree/braintree_graphql_transformers.rs @@ -1,5 +1,5 @@ use common_utils::pii; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::{ExposeInterface, Secret}; use serde::{Deserialize, Serialize}; use time::PrimitiveDateTime; @@ -1370,16 +1370,15 @@ impl TryFrom<&BraintreeRouterData<&types::PaymentsCompleteAuthorizeRouterData>> &item.router_data.request, )? .expose(); - let redirection_response: BraintreeRedirectionResponse = - serde_json::from_value(payload_data) - .into_report() - .change_context(errors::ConnectorError::MissingConnectorRedirectionPayload { - field_name: "redirection_response", - })?; + let redirection_response: BraintreeRedirectionResponse = serde_json::from_value( + payload_data, + ) + .change_context(errors::ConnectorError::MissingConnectorRedirectionPayload { + field_name: "redirection_response", + })?; let three_ds_data = serde_json::from_str::( &redirection_response.authentication_response, ) - .into_report() .change_context(errors::ConnectorError::MissingConnectorRedirectionPayload { field_name: "three_ds_data", })?; diff --git a/crates/router/src/connector/cashtocode.rs b/crates/router/src/connector/cashtocode.rs index 5dc809678933..279ad23259f1 100644 --- a/crates/router/src/connector/cashtocode.rs +++ b/crates/router/src/connector/cashtocode.rs @@ -4,7 +4,7 @@ use std::fmt::Debug; use base64::Engine; use common_utils::request::RequestContent; use diesel_models::enums; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::{PeekInterface, Secret}; use transformers as cashtocode; @@ -384,11 +384,9 @@ impl api::IncomingWebhook for Cashtocode { .change_context(errors::ConnectorError::WebhookSourceVerificationFailed)?; let secret_auth = String::from_utf8(connector_webhook_secrets.secret.to_vec()) - .into_report() .change_context(errors::ConnectorError::WebhookSourceVerificationFailed) .attach_printable("Could not convert secret to UTF-8")?; let signature_auth = String::from_utf8(signature.to_vec()) - .into_report() .change_context(errors::ConnectorError::WebhookSourceVerificationFailed) .attach_printable("Could not convert secret to UTF-8")?; Ok(signature_auth == secret_auth) diff --git a/crates/router/src/connector/cashtocode/transformers.rs b/crates/router/src/connector/cashtocode/transformers.rs index 6e930d5cb4ba..525b19df0011 100644 --- a/crates/router/src/connector/cashtocode/transformers.rs +++ b/crates/router/src/connector/cashtocode/transformers.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; pub use common_utils::request::Method; use common_utils::{errors::CustomResult, ext_traits::ValueExt, pii::Email}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::Secret; use serde::{Deserialize, Serialize}; @@ -57,8 +57,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for CashtocodePaymentsRequest &item.connector_auth_type, item.request.payment_method_type, item.request.currency, - ) - .into_report()?; + )?; match item.payment_method { diesel_models::enums::PaymentMethod::Reward => Ok(Self { amount: utils::to_currency_base_unit_asf64( diff --git a/crates/router/src/connector/checkout.rs b/crates/router/src/connector/checkout.rs index 30be1315e154..33a43b0a03c8 100644 --- a/crates/router/src/connector/checkout.rs +++ b/crates/router/src/connector/checkout.rs @@ -8,7 +8,7 @@ use common_utils::{ request::RequestContent, }; use diesel_models::enums; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::PeekInterface; use self::transformers as checkout; @@ -78,8 +78,7 @@ impl ConnectorCommon for Checkout { &self, auth_type: &types::ConnectorAuthType, ) -> CustomResult)>, errors::ConnectorError> { - let auth: checkout::CheckoutAuthType = auth_type - .try_into() + let auth = checkout::CheckoutAuthType::try_from(auth_type) .change_context(errors::ConnectorError::FailedToObtainAuthType)?; Ok(vec![( headers::AUTHORIZATION.to_string(), @@ -754,12 +753,11 @@ impl ConnectorIntegration CustomResult, errors::ConnectorError> { let signature = conn_utils::get_header_key_value("cko-signature", request.headers) .change_context(errors::ConnectorError::WebhookSignatureNotFound)?; - hex::decode(signature) - .into_report() - .change_context(errors::ConnectorError::WebhookSignatureNotFound) + hex::decode(signature).change_context(errors::ConnectorError::WebhookSignatureNotFound) } fn get_webhook_source_verification_message( &self, diff --git a/crates/router/src/connector/checkout/transformers.rs b/crates/router/src/connector/checkout/transformers.rs index 6328f98081d8..1a031eaa7ca4 100644 --- a/crates/router/src/connector/checkout/transformers.rs +++ b/crates/router/src/connector/checkout/transformers.rs @@ -1,5 +1,5 @@ use common_utils::{errors::CustomResult, ext_traits::ByteSliceExt}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::{ExposeInterface, Secret}; use serde::{Deserialize, Serialize}; use time::PrimitiveDateTime; @@ -1356,7 +1356,6 @@ pub fn construct_file_upload_request( .unwrap_or_default() )) .mime_str(request.file_type.as_ref()) - .into_report() .change_context(errors::ConnectorError::RequestEncodingFailed) .attach_printable("Failure in constructing file data")?; multipart = multipart.part("file", file_data); diff --git a/crates/router/src/connector/coinbase.rs b/crates/router/src/connector/coinbase.rs index 700731348fbd..8bfbe8b695a0 100644 --- a/crates/router/src/connector/coinbase.rs +++ b/crates/router/src/connector/coinbase.rs @@ -4,7 +4,7 @@ use std::fmt::Debug; use common_utils::{crypto, ext_traits::ByteSliceExt, request::RequestContent}; use diesel_models::enums; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use transformers as coinbase; use self::coinbase::CoinbaseWebhookDetails; @@ -394,7 +394,6 @@ impl api::IncomingWebhook for Coinbase { let base64_signature = utils::get_header_key_value("X-CC-Webhook-Signature", request.headers)?; hex::decode(base64_signature) - .into_report() .change_context(errors::ConnectorError::WebhookSourceVerificationFailed) } @@ -405,7 +404,6 @@ impl api::IncomingWebhook for Coinbase { _connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets, ) -> CustomResult, errors::ConnectorError> { let message = std::str::from_utf8(request.body) - .into_report() .change_context(errors::ConnectorError::WebhookSourceVerificationFailed)?; Ok(message.to_string().into_bytes()) } diff --git a/crates/router/src/connector/cryptopay.rs b/crates/router/src/connector/cryptopay.rs index a3335b2e228a..2f9c996eff47 100644 --- a/crates/router/src/connector/cryptopay.rs +++ b/crates/router/src/connector/cryptopay.rs @@ -9,7 +9,7 @@ use common_utils::{ ext_traits::ByteSliceExt, request::RequestContent, }; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use hex::encode; use masking::PeekInterface; use transformers as cryptopay; @@ -91,7 +91,6 @@ where let api_method = method.to_string(); let now = date_time::date_as_yyyymmddthhmmssmmmz() - .into_report() .change_context(errors::ConnectorError::RequestEncodingFailed)?; let date = format!("{}+00:00", now.split_at(now.len() - 5).0); @@ -425,7 +424,6 @@ impl api::IncomingWebhook for Cryptopay { let base64_signature = utils::get_header_key_value("X-Cryptopay-Signature", request.headers)?; hex::decode(base64_signature) - .into_report() .change_context(errors::ConnectorError::WebhookSourceVerificationFailed) } @@ -436,7 +434,6 @@ impl api::IncomingWebhook for Cryptopay { _connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets, ) -> CustomResult, errors::ConnectorError> { let message = std::str::from_utf8(request.body) - .into_report() .change_context(errors::ConnectorError::WebhookSourceVerificationFailed)?; Ok(message.to_string().into_bytes()) } diff --git a/crates/router/src/connector/cybersource.rs b/crates/router/src/connector/cybersource.rs index e89810e79cf4..5298420cde29 100644 --- a/crates/router/src/connector/cybersource.rs +++ b/crates/router/src/connector/cybersource.rs @@ -5,7 +5,7 @@ use std::fmt::Debug; use base64::Engine; use common_utils::request::RequestContent; use diesel_models::enums; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use masking::{ExposeInterface, PeekInterface}; use ring::{digest, hmac}; use time::OffsetDateTime; @@ -79,7 +79,6 @@ impl Cybersource { ); let key_value = consts::BASE64_ENGINE .decode(api_secret.expose()) - .into_report() .change_context(errors::ConnectorError::InvalidConnectorConfig { config: "connector_account_details.api_secret", })?; @@ -230,9 +229,8 @@ where let auth = cybersource::CybersourceAuthType::try_from(&req.connector_auth_type)?; let merchant_account = auth.merchant_account.clone(); let base_url = connectors.cybersource.base_url.as_str(); - let cybersource_host = Url::parse(base_url) - .into_report() - .change_context(errors::ConnectorError::RequestEncodingFailed)?; + let cybersource_host = + Url::parse(base_url).change_context(errors::ConnectorError::RequestEncodingFailed)?; let host = cybersource_host .host_str() .ok_or(errors::ConnectorError::RequestEncodingFailed)?; @@ -448,7 +446,6 @@ impl } else { // If http_code != 204 || http_code != 4xx, we dont know any other response scenario yet. let response_value: serde_json::Value = serde_json::from_slice(&res.response) - .into_report() .change_context(errors::ConnectorError::ResponseHandlingFailed)?; let response_string = response_value.to_string(); @@ -1482,7 +1479,7 @@ impl api::IncomingWebhook for Cybersource { &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_event_type( @@ -1496,6 +1493,6 @@ impl api::IncomingWebhook for Cybersource { &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } diff --git a/crates/router/src/connector/cybersource/transformers.rs b/crates/router/src/connector/cybersource/transformers.rs index 19d5e177226a..d58f51e1d789 100644 --- a/crates/router/src/connector/cybersource/transformers.rs +++ b/crates/router/src/connector/cybersource/transformers.rs @@ -2,7 +2,7 @@ use api_models::payments; use base64::Engine; use common_enums::FutureUsage; use common_utils::{ext_traits::ValueExt, pii}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::{ExposeInterface, PeekInterface, Secret}; use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -2120,7 +2120,6 @@ impl .consumer_authentication_information .validate_response, ) - .into_report() .change_context(errors::ConnectorError::ResponseHandlingFailed)?; Ok(Self { status, diff --git a/crates/router/src/connector/dlocal.rs b/crates/router/src/connector/dlocal.rs index b158f239fddd..c92c6b8b8544 100644 --- a/crates/router/src/connector/dlocal.rs +++ b/crates/router/src/connector/dlocal.rs @@ -8,7 +8,7 @@ use common_utils::{ request::RequestContent, }; use diesel_models::enums; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use hex::encode; use masking::PeekInterface; use transformers as dlocal; @@ -61,7 +61,6 @@ where let dlocal_req = self.get_request_body(req, connectors)?; let date = date_time::date_as_yyyymmddthhmmssmmmz() - .into_report() .change_context(errors::ConnectorError::RequestEncodingFailed)?; let auth = dlocal::DlocalAuthType::try_from(&req.connector_auth_type)?; let sign_req: String = format!( @@ -275,12 +274,11 @@ impl ConnectorIntegration, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_event_type( @@ -702,6 +696,6 @@ impl api::IncomingWebhook for Dlocal { &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } diff --git a/crates/router/src/connector/dummyconnector.rs b/crates/router/src/connector/dummyconnector.rs index 7889c4e40533..13a05578238b 100644 --- a/crates/router/src/connector/dummyconnector.rs +++ b/crates/router/src/connector/dummyconnector.rs @@ -4,7 +4,7 @@ use std::fmt::Debug; use common_utils::request::RequestContent; use diesel_models::enums; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use super::utils::RefundsRequestData; use crate::{ @@ -594,7 +594,7 @@ impl api::IncomingWebhook for DummyConnector { &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_event_type( @@ -608,6 +608,6 @@ impl api::IncomingWebhook for DummyConnector { &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } diff --git a/crates/router/src/connector/fiserv.rs b/crates/router/src/connector/fiserv.rs index fdd904ee737e..75147fe780c7 100644 --- a/crates/router/src/connector/fiserv.rs +++ b/crates/router/src/connector/fiserv.rs @@ -5,7 +5,7 @@ use std::fmt::Debug; use base64::Engine; use common_utils::request::RequestContent; use diesel_models::enums; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use masking::{ExposeInterface, PeekInterface}; use ring::hmac; use time::OffsetDateTime; @@ -119,8 +119,7 @@ impl ConnectorCommon for Fiserv { &self, auth_type: &types::ConnectorAuthType, ) -> CustomResult)>, errors::ConnectorError> { - let auth: fiserv::FiservAuthType = auth_type - .try_into() + let auth = fiserv::FiservAuthType::try_from(auth_type) .change_context(errors::ConnectorError::FailedToObtainAuthType)?; Ok(vec![( headers::API_KEY.to_string(), @@ -305,12 +304,11 @@ impl ConnectorIntegration, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_event_type( @@ -804,6 +797,6 @@ impl api::IncomingWebhook for Fiserv { &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } diff --git a/crates/router/src/connector/forte.rs b/crates/router/src/connector/forte.rs index 7cc3f9f9a4e1..8b858e5553ed 100644 --- a/crates/router/src/connector/forte.rs +++ b/crates/router/src/connector/forte.rs @@ -5,7 +5,7 @@ use std::fmt::Debug; use base64::Engine; use common_utils::request::RequestContent; use diesel_models::enums; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use masking::PeekInterface; use transformers as forte; @@ -94,8 +94,7 @@ impl ConnectorCommon for Forte { &self, auth_type: &types::ConnectorAuthType, ) -> CustomResult)>, errors::ConnectorError> { - let auth: forte::ForteAuthType = auth_type - .try_into() + let auth = forte::ForteAuthType::try_from(auth_type) .change_context(errors::ConnectorError::FailedToObtainAuthType)?; let raw_basic_token = format!( "{}:{}", @@ -695,7 +694,7 @@ impl api::IncomingWebhook for Forte { &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_event_type( @@ -709,6 +708,6 @@ impl api::IncomingWebhook for Forte { &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } diff --git a/crates/router/src/connector/globalpay.rs b/crates/router/src/connector/globalpay.rs index d9123c516ece..447c0568dc1f 100644 --- a/crates/router/src/connector/globalpay.rs +++ b/crates/router/src/connector/globalpay.rs @@ -7,7 +7,7 @@ use std::fmt::Debug; use ::common_utils::{errors::ReportSwitchExt, ext_traits::ByteSliceExt, request::RequestContent}; use diesel_models::enums; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::PeekInterface; use serde_json::Value; @@ -304,12 +304,11 @@ impl ConnectorIntegration CustomResult, errors::ConnectorError> { let payload: Value = request.body.parse_struct("GlobalpayWebhookBody").switch()?; let mut payload_str = serde_json::to_string(&payload) - .into_report() .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; let sec = std::str::from_utf8(&connector_webhook_secrets.secret) - .into_report() .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; payload_str.push_str(sec); Ok(payload_str.into_bytes()) @@ -967,13 +960,10 @@ impl api::IncomingWebhook for Globalpay { request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { let details = std::str::from_utf8(request.body) - .into_report() .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; - Ok(Box::new( - serde_json::from_str(details) - .into_report() - .change_context(errors::ConnectorError::WebhookResourceObjectNotFound)?, - )) + Ok(Box::new(serde_json::from_str(details).change_context( + errors::ConnectorError::WebhookResourceObjectNotFound, + )?)) } } diff --git a/crates/router/src/connector/globalpay/transformers.rs b/crates/router/src/connector/globalpay/transformers.rs index 35987ae26b32..ae6f8d3966a8 100644 --- a/crates/router/src/connector/globalpay/transformers.rs +++ b/crates/router/src/connector/globalpay/transformers.rs @@ -1,5 +1,5 @@ use common_utils::crypto::{self, GenerateDigest}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::{ExposeInterface, PeekInterface, Secret}; use rand::distributions::DistString; use serde::{Deserialize, Serialize}; @@ -265,9 +265,7 @@ impl }) .filter(|redirect_str| !redirect_str.is_empty()) .map(|url| { - Url::parse(url) - .into_report() - .change_context(errors::ConnectorError::FailedToObtainIntegrationUrl) + Url::parse(url).change_context(errors::ConnectorError::FailedToObtainIntegrationUrl) }) .transpose()?; let redirection_data = @@ -486,10 +484,7 @@ impl TryFrom<&api_models::payments::BankRedirectData> for PaymentMethodData { api_models::payments::BankRedirectData::Sofort { .. } => Ok(Self::Apm(requests::Apm { provider: Some(ApmProvider::Sofort), })), - _ => Err(errors::ConnectorError::NotImplemented( - "Payment method".to_string(), - )) - .into_report(), + _ => Err(errors::ConnectorError::NotImplemented("Payment method".to_string()).into()), } } } diff --git a/crates/router/src/connector/globepay.rs b/crates/router/src/connector/globepay.rs index d480e35cfc08..6570351f9e2c 100644 --- a/crates/router/src/connector/globepay.rs +++ b/crates/router/src/connector/globepay.rs @@ -7,7 +7,7 @@ use common_utils::{ request::RequestContent, }; use diesel_models::enums; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use hex::encode; use masking::ExposeInterface; use rand::distributions::DistString; @@ -532,20 +532,20 @@ impl api::IncomingWebhook for Globepay { &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_event_type( &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_resource_object( &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } diff --git a/crates/router/src/connector/gocardless.rs b/crates/router/src/connector/gocardless.rs index 806aec7dbeb3..72007c5ba735 100644 --- a/crates/router/src/connector/gocardless.rs +++ b/crates/router/src/connector/gocardless.rs @@ -4,7 +4,7 @@ use std::fmt::Debug; use api_models::enums::enums; use common_utils::{crypto, ext_traits::ByteSliceExt, request::RequestContent}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::PeekInterface; use transformers as gocardless; @@ -738,14 +738,10 @@ impl api::IncomingWebhook for Gocardless { .to_str() .map(String::from) .map_err(|_| errors::ConnectorError::WebhookSignatureNotFound) - .into_report() }) - .ok_or(errors::ConnectorError::WebhookSignatureNotFound) - .into_report()??; + .ok_or(errors::ConnectorError::WebhookSignatureNotFound)??; - hex::decode(signature) - .into_report() - .change_context(errors::ConnectorError::WebhookSignatureNotFound) + hex::decode(signature).change_context(errors::ConnectorError::WebhookSignatureNotFound) } fn get_webhook_source_verification_message( diff --git a/crates/router/src/connector/helcim.rs b/crates/router/src/connector/helcim.rs index d1b9732cb176..a6305ef6366a 100644 --- a/crates/router/src/connector/helcim.rs +++ b/crates/router/src/connector/helcim.rs @@ -4,7 +4,7 @@ use std::fmt::Debug; use common_utils::request::RequestContent; use diesel_models::enums; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use masking::ExposeInterface; use transformers as helcim; @@ -787,20 +787,20 @@ impl api::IncomingWebhook for Helcim { &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_event_type( &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_resource_object( &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } diff --git a/crates/router/src/connector/helcim/transformers.rs b/crates/router/src/connector/helcim/transformers.rs index fba46bd721f0..66cb26660387 100644 --- a/crates/router/src/connector/helcim/transformers.rs +++ b/crates/router/src/connector/helcim/transformers.rs @@ -1,5 +1,5 @@ use common_utils::pii::{Email, IpAddress}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::Secret; use serde::{Deserialize, Serialize}; @@ -158,10 +158,9 @@ impl TryFrom<&types::SetupMandateRouterData> for HelcimVerifyRequest { fn try_from(item: &types::SetupMandateRouterData) -> Result { match item.request.payment_method_data.clone() { api::PaymentMethodData::Card(req_card) => Self::try_from((item, &req_card)), - api_models::payments::PaymentMethodData::BankTransfer(_) => Err( - errors::ConnectorError::NotImplemented("Payment Method".to_string()), - ) - .into_report(), + api_models::payments::PaymentMethodData::BankTransfer(_) => { + Err(errors::ConnectorError::NotImplemented("Payment Method".to_string()).into()) + } api_models::payments::PaymentMethodData::CardRedirect(_) | api_models::payments::PaymentMethodData::Wallet(_) | api_models::payments::PaymentMethodData::PayLater(_) @@ -260,10 +259,9 @@ impl TryFrom<&HelcimRouterData<&types::PaymentsAuthorizeRouterData>> for HelcimP ) -> Result { match item.router_data.request.payment_method_data.clone() { api::PaymentMethodData::Card(req_card) => Self::try_from((item, &req_card)), - api_models::payments::PaymentMethodData::BankTransfer(_) => Err( - errors::ConnectorError::NotImplemented("Payment Method".to_string()), - ) - .into_report(), + api_models::payments::PaymentMethodData::BankTransfer(_) => { + Err(errors::ConnectorError::NotImplemented("Payment Method".to_string()).into()) + } api_models::payments::PaymentMethodData::CardRedirect(_) | api_models::payments::PaymentMethodData::Wallet(_) | api_models::payments::PaymentMethodData::PayLater(_) @@ -541,7 +539,6 @@ impl TryFrom<&HelcimRouterData<&types::PaymentsCaptureRouterData>> for HelcimCap .request .connector_transaction_id .parse::() - .into_report() .change_context(errors::ConnectorError::RequestEncodingFailed)?, amount: item.amount, ip_address, @@ -605,7 +602,6 @@ impl TryFrom<&types::PaymentsCancelRouterData> for HelcimVoidRequest { .request .connector_transaction_id .parse::() - .into_report() .change_context(errors::ConnectorError::RequestEncodingFailed)?, ip_address, ecommerce: None, @@ -672,7 +668,6 @@ impl TryFrom<&HelcimRouterData<&types::RefundsRouterData>> for HelcimRefun .request .connector_transaction_id .parse::() - .into_report() .change_context(errors::ConnectorError::RequestEncodingFailed)?; let ip_address = item diff --git a/crates/router/src/connector/iatapay.rs b/crates/router/src/connector/iatapay.rs index c049520de28e..9adf50d6f5e2 100644 --- a/crates/router/src/connector/iatapay.rs +++ b/crates/router/src/connector/iatapay.rs @@ -4,7 +4,7 @@ use std::fmt::Debug; use base64::Engine; use common_utils::{crypto, ext_traits::ByteSliceExt, request::RequestContent}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::PeekInterface; use transformers as iatapay; @@ -652,7 +652,6 @@ impl api::IncomingWebhook for Iatapay { _connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets, ) -> CustomResult, errors::ConnectorError> { let message = std::str::from_utf8(request.body) - .into_report() .change_context(errors::ConnectorError::WebhookSourceVerificationFailed)?; Ok(message.to_string().into_bytes()) } diff --git a/crates/router/src/connector/klarna.rs b/crates/router/src/connector/klarna.rs index 8b7ab0da7f22..91ef719e5e05 100644 --- a/crates/router/src/connector/klarna.rs +++ b/crates/router/src/connector/klarna.rs @@ -3,7 +3,7 @@ use std::fmt::Debug; use api_models::payments as api_payments; use common_utils::request::RequestContent; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use transformers as klarna; use crate::{ @@ -50,8 +50,7 @@ impl ConnectorCommon for Klarna { &self, auth_type: &types::ConnectorAuthType, ) -> CustomResult)>, errors::ConnectorError> { - let auth: klarna::KlarnaAuthType = auth_type - .try_into() + let auth = klarna::KlarnaAuthType::try_from(auth_type) .change_context(errors::ConnectorError::FailedToObtainAuthType)?; Ok(vec![( headers::AUTHORIZATION.to_string(), @@ -532,7 +531,7 @@ impl api::IncomingWebhook for Klarna { &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_event_type( @@ -546,6 +545,6 @@ impl api::IncomingWebhook for Klarna { &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } diff --git a/crates/router/src/connector/mollie.rs b/crates/router/src/connector/mollie.rs index e6bbd6883766..84014fd6d59c 100644 --- a/crates/router/src/connector/mollie.rs +++ b/crates/router/src/connector/mollie.rs @@ -3,7 +3,7 @@ pub mod transformers; use std::fmt::Debug; use common_utils::request::RequestContent; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use masking::PeekInterface; use transformers as mollie; @@ -76,8 +76,7 @@ impl ConnectorCommon for Mollie { &self, auth_type: &types::ConnectorAuthType, ) -> CustomResult)>, errors::ConnectorError> { - let auth: mollie::MollieAuthType = auth_type - .try_into() + let auth = mollie::MollieAuthType::try_from(auth_type) .change_context(errors::ConnectorError::FailedToObtainAuthType)?; Ok(vec![( headers::AUTHORIZATION.to_string(), @@ -414,8 +413,8 @@ impl ConnectorIntegration, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_event_type( @@ -620,7 +619,7 @@ impl api::IncomingWebhook for Mollie { &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } diff --git a/crates/router/src/connector/mollie/transformers.rs b/crates/router/src/connector/mollie/transformers.rs index be0c0475fd73..7acf81db295a 100644 --- a/crates/router/src/connector/mollie/transformers.rs +++ b/crates/router/src/connector/mollie/transformers.rs @@ -2,7 +2,6 @@ use api_models::payments; use cards::CardNumber; use common_utils::pii::Email; use diesel_models::enums; -use error_stack::IntoReport; use masking::{ExposeInterface, Secret}; use serde::{Deserialize, Serialize}; use url::Url; @@ -198,10 +197,9 @@ impl TryFrom<&MollieRouterData<&types::PaymentsAuthorizeRouterData>> for MollieP api_models::payments::PaymentMethodData::BankDebit(ref directdebit_data) => { PaymentMethodData::try_from(directdebit_data) } - _ => Err(errors::ConnectorError::NotImplemented( - "Payment Method".to_string(), - )) - .into_report(), + _ => Err( + errors::ConnectorError::NotImplemented("Payment Method".to_string()).into(), + ), } } _ => Err(errors::ConnectorError::FlowNotSupported { @@ -210,8 +208,8 @@ impl TryFrom<&MollieRouterData<&types::PaymentsAuthorizeRouterData>> for MollieP item.router_data.request.capture_method.unwrap_or_default() ), connector: "Mollie".to_string(), - }) - .into_report(), + } + .into()), }?; Ok(Self { amount, @@ -341,10 +339,7 @@ fn get_payment_method_for_wallet( apple_pay_payment_token: Secret::new(applepay_wallet_data.payment_data.to_owned()), }))) } - _ => Err(errors::ConnectorError::NotImplemented( - "Payment Method".to_string(), - )) - .into_report(), + _ => Err(errors::ConnectorError::NotImplemented("Payment Method".to_string()).into()), } } diff --git a/crates/router/src/connector/multisafepay.rs b/crates/router/src/connector/multisafepay.rs index b039da42a0c1..fa6bb5dad3fc 100644 --- a/crates/router/src/connector/multisafepay.rs +++ b/crates/router/src/connector/multisafepay.rs @@ -3,7 +3,7 @@ pub mod transformers; use std::fmt::Debug; use common_utils::request::RequestContent; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use masking::ExposeInterface; use transformers as multisafepay; @@ -63,8 +63,7 @@ impl ConnectorCommon for Multisafepay { &self, auth_type: &types::ConnectorAuthType, ) -> CustomResult)>, errors::ConnectorError> { - let auth: multisafepay::MultisafepayAuthType = auth_type - .try_into() + let auth = multisafepay::MultisafepayAuthType::try_from(auth_type) .change_context(errors::ConnectorError::FailedToObtainAuthType)?; Ok(vec![( headers::AUTHORIZATION.to_string(), @@ -339,12 +338,11 @@ impl ConnectorIntegration, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_event_type( @@ -553,6 +549,6 @@ impl api::IncomingWebhook for Multisafepay { &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } diff --git a/crates/router/src/connector/nexinets.rs b/crates/router/src/connector/nexinets.rs index 85cc09498145..1370fcf11cd6 100644 --- a/crates/router/src/connector/nexinets.rs +++ b/crates/router/src/connector/nexinets.rs @@ -3,7 +3,7 @@ pub mod transformers; use std::fmt::Debug; use common_utils::request::RequestContent; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use transformers as nexinets; use crate::{ @@ -707,7 +707,7 @@ impl api::IncomingWebhook for Nexinets { &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_event_type( @@ -721,7 +721,7 @@ impl api::IncomingWebhook for Nexinets { &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } diff --git a/crates/router/src/connector/nexinets/transformers.rs b/crates/router/src/connector/nexinets/transformers.rs index dc871891145a..703c24e56e94 100644 --- a/crates/router/src/connector/nexinets/transformers.rs +++ b/crates/router/src/connector/nexinets/transformers.rs @@ -2,7 +2,7 @@ use api_models::payments::PaymentMethodData; use base64::Engine; use cards::CardNumber; use common_utils::errors::CustomResult; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::{ExposeInterface, PeekInterface, Secret}; use serde::{Deserialize, Serialize}; use url::Url; @@ -339,7 +339,6 @@ impl order_id: Some(item.response.order_id.clone()), psync_flow: item.response.transaction_type.clone(), }) - .into_report() .change_context(errors::ConnectorError::ResponseHandlingFailed)?; let redirection_data = item .response @@ -436,7 +435,6 @@ impl order_id: Some(item.response.order.order_id.clone()), psync_flow: item.response.transaction_type.clone(), }) - .into_report() .change_context(errors::ConnectorError::ResponseHandlingFailed)?; let resource_id = match item.response.transaction_type.clone() { NexinetsTransactionType::Debit | NexinetsTransactionType::Capture => { diff --git a/crates/router/src/connector/nmi.rs b/crates/router/src/connector/nmi.rs index 527403736aa0..d34b894411f1 100644 --- a/crates/router/src/connector/nmi.rs +++ b/crates/router/src/connector/nmi.rs @@ -4,7 +4,7 @@ use std::fmt::Debug; use common_utils::{crypto, ext_traits::ByteSliceExt, request::RequestContent}; use diesel_models::enums; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use regex::Regex; use transformers as nmi; @@ -195,7 +195,6 @@ impl res: types::Response, ) -> CustomResult { let response: nmi::StandardResponse = serde_urlencoded::from_bytes(&res.response) - .into_report() .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; event_builder.map(|i| i.set_response_body(&response)); router_env::logger::info!(connector_response=?response); @@ -283,7 +282,6 @@ impl res: types::Response, ) -> CustomResult { let response: nmi::NmiVaultResponse = serde_urlencoded::from_bytes(&res.response) - .into_report() .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; event_builder.map(|i| i.set_response_body(&response)); router_env::logger::info!(connector_response=?response); @@ -365,7 +363,6 @@ impl ConnectorIntegration CustomResult { let response: nmi::StandardResponse = serde_urlencoded::from_bytes(&res.response) - .into_report() .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; event_builder.map(|i| i.set_response_body(&response)); router_env::logger::info!(connector_response=?response); @@ -454,7 +451,6 @@ impl res: types::Response, ) -> CustomResult { let response: nmi::NmiCompleteResponse = serde_urlencoded::from_bytes(&res.response) - .into_report() .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; event_builder.map(|i| i.set_response_body(&response)); router_env::logger::info!(connector_response=?response); @@ -605,7 +601,6 @@ impl ConnectorIntegration CustomResult { let response: nmi::StandardResponse = serde_urlencoded::from_bytes(&res.response) - .into_report() .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; event_builder.map(|i| i.set_response_body(&response)); router_env::logger::info!(connector_response=?response); @@ -677,7 +672,6 @@ impl ConnectorIntegration CustomResult { let response: nmi::StandardResponse = serde_urlencoded::from_bytes(&res.response) - .into_report() .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; event_builder.map(|i| i.set_response_body(&response)); router_env::logger::info!(connector_response=?response); @@ -755,7 +749,6 @@ impl ConnectorIntegration CustomResult, errors::ConnectorError> { let response: nmi::StandardResponse = serde_urlencoded::from_bytes(&res.response) - .into_report() .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; event_builder.map(|i| i.set_response_body(&response)); router_env::logger::info!(connector_response=?response); @@ -865,19 +858,17 @@ impl api::IncomingWebhook for Nmi { let regex_pattern = r"t=(.*),s=(.*)"; if let Some(captures) = Regex::new(regex_pattern) - .into_report() .change_context(errors::ConnectorError::WebhookSignatureNotFound)? .captures(sig_header) { let signature = captures .get(1) - .ok_or(errors::ConnectorError::WebhookSignatureNotFound) - .into_report()? + .ok_or(errors::ConnectorError::WebhookSignatureNotFound)? .as_str(); return Ok(signature.as_bytes().to_vec()); } - Err(errors::ConnectorError::WebhookSignatureNotFound).into_report() + Err(report!(errors::ConnectorError::WebhookSignatureNotFound)) } fn get_webhook_source_verification_message( @@ -892,21 +883,19 @@ impl api::IncomingWebhook for Nmi { let regex_pattern = r"t=(.*),s=(.*)"; if let Some(captures) = Regex::new(regex_pattern) - .into_report() .change_context(errors::ConnectorError::WebhookSignatureNotFound)? .captures(sig_header) { let nonce = captures .get(0) - .ok_or(errors::ConnectorError::WebhookSignatureNotFound) - .into_report()? + .ok_or(errors::ConnectorError::WebhookSignatureNotFound)? .as_str(); let message = format!("{}.{}", nonce, String::from_utf8_lossy(request.body)); return Ok(message.into_bytes()); } - Err(errors::ConnectorError::WebhookSignatureNotFound).into_report() + Err(report!(errors::ConnectorError::WebhookSignatureNotFound)) } fn get_webhook_object_reference_id( @@ -942,7 +931,7 @@ impl api::IncomingWebhook for Nmi { nmi::NmiActionType::Refund => api_models::webhooks::ObjectReferenceId::RefundId( api_models::webhooks::RefundIdType::RefundId(reference_body.event_body.order_id), ), - _ => Err(errors::ConnectorError::WebhooksNotImplemented).into_report()?, + _ => Err(errors::ConnectorError::WebhooksNotImplemented)?, }; Ok(object_reference_id) @@ -999,10 +988,11 @@ impl services::ConnectorRedirectResponse for Nmi { })?; let redirect_res: nmi::NmiRedirectResponse = serde_json::from_value(payload_data) - .into_report() - .change_context(errors::ConnectorError::MissingConnectorRedirectionPayload { + .change_context( + errors::ConnectorError::MissingConnectorRedirectionPayload { field_name: "redirect_res", - })?; + }, + )?; match redirect_res { transformers::NmiRedirectResponse::NmiRedirectResponseData(_) => { diff --git a/crates/router/src/connector/nmi/transformers.rs b/crates/router/src/connector/nmi/transformers.rs index efde37d87152..2358e0f6cc06 100644 --- a/crates/router/src/connector/nmi/transformers.rs +++ b/crates/router/src/connector/nmi/transformers.rs @@ -6,7 +6,7 @@ use common_utils::{ ext_traits::XmlExt, pii::{self, Email}, }; -use error_stack::{IntoReport, Report, ResultExt}; +use error_stack::{Report, ResultExt}; use masking::{ExposeInterface, PeekInterface, Secret}; use serde::{Deserialize, Serialize}; @@ -149,8 +149,8 @@ fn get_card_details( )), _ => Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("Nmi"), - )) - .into_report(), + ) + .into()), } } @@ -314,7 +314,6 @@ impl TryFrom<&NmiRouterData<&types::PaymentsCompleteAuthorizeRouterData>> for Nm .expose(); let three_ds_data: NmiRedirectResponseData = serde_json::from_value(payload_data) - .into_report() .change_context(errors::ConnectorError::MissingConnectorRedirectionPayload { field_name: "three_ds_data", })?; @@ -554,8 +553,8 @@ impl TryFrom<&api_models::payments::PaymentMethodData> for PaymentMethod { | api_models::payments::WalletData::SwishQr(_) => { Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("nmi"), - )) - .into_report() + ) + .into()) } }, api::PaymentMethodData::CardRedirect(_) @@ -571,8 +570,8 @@ impl TryFrom<&api_models::payments::PaymentMethodData> for PaymentMethod { | api::PaymentMethodData::GiftCard(_) | api::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("nmi"), - )) - .into_report(), + ) + .into()), } } } @@ -962,11 +961,9 @@ impl TryFrom> for SyncResponse { type Error = Error; fn try_from(bytes: Vec) -> Result { let query_response = String::from_utf8(bytes) - .into_report() .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; query_response .parse_xml::() - .into_report() .change_context(errors::ConnectorError::ResponseDeserializationFailed) } } @@ -975,11 +972,9 @@ impl TryFrom> for NmiRefundSyncResponse { type Error = Error; fn try_from(bytes: Vec) -> Result { let query_response = String::from_utf8(bytes) - .into_report() .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; query_response .parse_xml::() - .into_report() .change_context(errors::ConnectorError::ResponseDeserializationFailed) } } diff --git a/crates/router/src/connector/noon.rs b/crates/router/src/connector/noon.rs index d9e9417df8e1..f247a5dae1ff 100644 --- a/crates/router/src/connector/noon.rs +++ b/crates/router/src/connector/noon.rs @@ -5,7 +5,7 @@ use std::fmt::Debug; use base64::Engine; use common_utils::{crypto, ext_traits::ByteSliceExt, request::RequestContent}; use diesel_models::enums; -use error_stack::{IntoReport, Report, ResultExt}; +use error_stack::{Report, ResultExt}; use masking::PeekInterface; use router_env::logger; use transformers as noon; @@ -803,7 +803,6 @@ impl api::IncomingWebhook for Noon { let signature = webhook_body.signature; consts::BASE64_ENGINE .decode(signature) - .into_report() .change_context(errors::ConnectorError::WebhookSignatureNotFound) } diff --git a/crates/router/src/connector/noon/transformers.rs b/crates/router/src/connector/noon/transformers.rs index 92def17aeae5..38202291b41f 100644 --- a/crates/router/src/connector/noon/transformers.rs +++ b/crates/router/src/connector/noon/transformers.rs @@ -1,5 +1,5 @@ use common_utils::{ext_traits::Encode, pii}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::{ExposeInterface, PeekInterface, Secret}; use serde::{Deserialize, Serialize}; @@ -379,13 +379,13 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for NoonPaymentsRequest { Err(errors::ConnectorError::MissingRequiredField { field_name: "setup_future_usage.mandate_data.mandate_type.multi_use.amount", - }) - .into_report() + } + .into()) } None => Err(errors::ConnectorError::MissingRequiredField { field_name: "setup_future_usage.mandate_data.mandate_type", - }) - .into_report(), + } + .into()), }?; Ok::>( diff --git a/crates/router/src/connector/nuvei.rs b/crates/router/src/connector/nuvei.rs index 0e9a9634402b..0e3ae84581af 100644 --- a/crates/router/src/connector/nuvei.rs +++ b/crates/router/src/connector/nuvei.rs @@ -8,7 +8,7 @@ use ::common_utils::{ ext_traits::{BytesExt, ValueExt}, request::RequestContent, }; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::ExposeInterface; use transformers as nuvei; @@ -290,7 +290,7 @@ impl ConnectorIntegration CustomResult, errors::ConnectorError> { let signature = utils::get_header_key_value("advanceResponseChecksum", request.headers)?; - hex::decode(signature) - .into_report() - .change_context(errors::ConnectorError::WebhookResponseEncodingFailed) + hex::decode(signature).change_context(errors::ConnectorError::WebhookResponseEncodingFailed) } fn get_webhook_source_verification_message( @@ -931,10 +929,8 @@ impl api::IncomingWebhook for Nuvei { connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets, ) -> CustomResult, errors::ConnectorError> { let body = serde_urlencoded::from_str::(&request.query_params) - .into_report() .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; let secret_str = std::str::from_utf8(&connector_webhook_secrets.secret) - .into_report() .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; let status = format!("{:?}", body.status).to_uppercase(); let to_sign = format!( @@ -956,7 +952,6 @@ impl api::IncomingWebhook for Nuvei { ) -> CustomResult { let body = serde_urlencoded::from_str::(&request.query_params) - .into_report() .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; Ok(api_models::webhooks::ObjectReferenceId::PaymentId( types::api::PaymentIdType::ConnectorTransactionId(body.ppp_transaction_id), @@ -969,7 +964,6 @@ impl api::IncomingWebhook for Nuvei { ) -> CustomResult { let body = serde_urlencoded::from_str::(&request.query_params) - .into_report() .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; match body.status { nuvei::NuveiWebhookStatus::Approved => { @@ -989,7 +983,6 @@ impl api::IncomingWebhook for Nuvei { request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { let body = serde_urlencoded::from_str::(&request.query_params) - .into_report() .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; let payment_response = nuvei::NuveiPaymentsResponse::from(body); diff --git a/crates/router/src/connector/nuvei/transformers.rs b/crates/router/src/connector/nuvei/transformers.rs index 77c08a4374f0..6753dfe203f2 100644 --- a/crates/router/src/connector/nuvei/transformers.rs +++ b/crates/router/src/connector/nuvei/transformers.rs @@ -7,7 +7,7 @@ use common_utils::{ pii::{Email, IpAddress}, }; use data_models::mandates::MandateDataType; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::{ExposeInterface, PeekInterface, Secret}; use reqwest::Url; use serde::{Deserialize, Serialize}; @@ -1080,7 +1080,6 @@ impl TryFrom for NuveiPaymentsRequest { let client_request_id = request.client_request_id; let time_stamp = date_time::format_date(date_time::now(), date_time::DateFormat::YYYYMMDDHHmmss) - .into_report() .change_context(errors::ConnectorError::RequestEncodingFailed)?; let merchant_secret = connector_meta.merchant_secret; Ok(Self { @@ -1118,7 +1117,6 @@ impl TryFrom for NuveiPaymentFlowRequest { let client_request_id = request.client_request_id; let time_stamp = date_time::format_date(date_time::now(), date_time::DateFormat::YYYYMMDDHHmmss) - .into_report() .change_context(errors::ConnectorError::RequestEncodingFailed)?; let merchant_secret = connector_meta.merchant_secret; Ok(Self { @@ -1455,7 +1453,6 @@ where serde_json::to_value(NuveiMeta { session_token: token, }) - .into_report() .change_context(errors::ConnectorError::ResponseHandlingFailed)?, ) } else { diff --git a/crates/router/src/connector/opayo.rs b/crates/router/src/connector/opayo.rs index 53a314162bb3..cd1ef67f662e 100644 --- a/crates/router/src/connector/opayo.rs +++ b/crates/router/src/connector/opayo.rs @@ -4,7 +4,7 @@ use std::fmt::Debug; use common_utils::request::RequestContent; use diesel_models::enums; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use masking::ExposeInterface; use transformers as opayo; @@ -559,20 +559,20 @@ impl api::IncomingWebhook for Opayo { &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_event_type( &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_resource_object( &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } diff --git a/crates/router/src/connector/opennode.rs b/crates/router/src/connector/opennode.rs index 1bd7461b6686..5346fc086d74 100644 --- a/crates/router/src/connector/opennode.rs +++ b/crates/router/src/connector/opennode.rs @@ -3,7 +3,7 @@ pub mod transformers; use std::fmt::Debug; use common_utils::{crypto, request::RequestContent}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use transformers as opennode; use self::opennode::OpennodeWebhookDetails; @@ -389,11 +389,9 @@ impl api::IncomingWebhook for Opennode { _connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets, ) -> CustomResult, errors::ConnectorError> { let notif = serde_urlencoded::from_bytes::(request.body) - .into_report() .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; let base64_signature = notif.hashed_order; hex::decode(base64_signature) - .into_report() .change_context(errors::ConnectorError::WebhookSourceVerificationFailed) } @@ -404,7 +402,6 @@ impl api::IncomingWebhook for Opennode { _connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets, ) -> CustomResult, errors::ConnectorError> { let message = std::str::from_utf8(request.body) - .into_report() .change_context(errors::ConnectorError::ParsingFailed)?; Ok(message.to_string().into_bytes()) } @@ -414,7 +411,6 @@ impl api::IncomingWebhook for Opennode { request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { let notif = serde_urlencoded::from_bytes::(request.body) - .into_report() .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; Ok(api_models::webhooks::ObjectReferenceId::PaymentId( api_models::payments::PaymentIdType::ConnectorTransactionId(notif.id), @@ -426,7 +422,6 @@ impl api::IncomingWebhook for Opennode { request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { let notif = serde_urlencoded::from_bytes::(request.body) - .into_report() .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; match notif.status { @@ -449,7 +444,6 @@ impl api::IncomingWebhook for Opennode { request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { let notif = serde_urlencoded::from_bytes::(request.body) - .into_report() .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; Ok(Box::new(notif.status)) diff --git a/crates/router/src/connector/payeezy.rs b/crates/router/src/connector/payeezy.rs index d24a42085a4a..5783cf1bc14f 100644 --- a/crates/router/src/connector/payeezy.rs +++ b/crates/router/src/connector/payeezy.rs @@ -5,7 +5,7 @@ use std::fmt::Debug; use base64::Engine; use common_utils::request::RequestContent; use diesel_models::enums; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use masking::ExposeInterface; use rand::distributions::DistString; use ring::hmac; @@ -572,7 +572,7 @@ impl ConnectorIntegration, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_event_type( @@ -611,6 +611,6 @@ impl api::IncomingWebhook for Payeezy { &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } diff --git a/crates/router/src/connector/payme.rs b/crates/router/src/connector/payme.rs index 5873609e3723..042b506b306b 100644 --- a/crates/router/src/connector/payme.rs +++ b/crates/router/src/connector/payme.rs @@ -5,7 +5,7 @@ use std::fmt::Debug; use api_models::enums::AuthenticationType; use common_utils::{crypto, request::RequestContent}; use diesel_models::enums; -use error_stack::{IntoReport, Report, ResultExt}; +use error_stack::{Report, ResultExt}; use masking::ExposeInterface; use transformers as payme; @@ -1086,7 +1086,6 @@ impl api::IncomingWebhook for Payme { ) -> CustomResult, errors::ConnectorError> { let resource = serde_urlencoded::from_bytes::(request.body) - .into_report() .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; Ok(resource.payme_signature.expose().into_bytes()) } @@ -1099,7 +1098,6 @@ impl api::IncomingWebhook for Payme { ) -> CustomResult, errors::ConnectorError> { let resource = serde_urlencoded::from_bytes::(request.body) - .into_report() .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; Ok(format!( "{}{}{}", @@ -1145,7 +1143,6 @@ impl api::IncomingWebhook for Payme { let mut message_to_verify = connector_webhook_secrets .additional_secret .ok_or(errors::ConnectorError::WebhookSourceVerificationFailed) - .into_report() .attach_printable("Failed to get additional secrets")? .expose() .as_bytes() @@ -1154,7 +1151,6 @@ impl api::IncomingWebhook for Payme { message_to_verify.append(&mut message); let signature_to_verify = hex::decode(signature) - .into_report() .change_context(errors::ConnectorError::WebhookResponseEncodingFailed)?; algorithm .verify_signature( @@ -1171,7 +1167,6 @@ impl api::IncomingWebhook for Payme { ) -> CustomResult { let resource = serde_urlencoded::from_bytes::(request.body) - .into_report() .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; let id = match resource.notify_type { transformers::NotifyType::SaleComplete @@ -1200,7 +1195,6 @@ impl api::IncomingWebhook for Payme { ) -> CustomResult { let resource = serde_urlencoded::from_bytes::(request.body) - .into_report() .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; Ok(api::IncomingWebhookEvent::from(resource.notify_type)) } @@ -1211,7 +1205,6 @@ impl api::IncomingWebhook for Payme { ) -> CustomResult, errors::ConnectorError> { let resource = serde_urlencoded::from_bytes::(request.body) - .into_report() .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; match resource.notify_type { @@ -1234,7 +1227,6 @@ impl api::IncomingWebhook for Payme { ) -> CustomResult { let webhook_object = serde_urlencoded::from_bytes::(request.body) - .into_report() .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; Ok(api::disputes::DisputePayload { diff --git a/crates/router/src/connector/payme/transformers.rs b/crates/router/src/connector/payme/transformers.rs index 4db0a0bd07b5..b577ae9f20ad 100644 --- a/crates/router/src/connector/payme/transformers.rs +++ b/crates/router/src/connector/payme/transformers.rs @@ -5,7 +5,7 @@ use api_models::{ payments::PaymentMethodData, }; use common_utils::pii; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::{ExposeInterface, Secret}; use serde::{Deserialize, Serialize}; use url::Url; @@ -696,7 +696,6 @@ impl TryFrom<&types::PaymentsCompleteAuthorizeRouterData> for Pay3dsRequest { let payload_data = item.request.get_redirect_response_payload()?.expose(); let jwt_data: PaymeRedirectResponseData = serde_json::from_value(payload_data) - .into_report() .change_context(errors::ConnectorError::MissingConnectorRedirectionPayload { field_name: "meta_data_jwt", })?; diff --git a/crates/router/src/connector/paypal.rs b/crates/router/src/connector/paypal.rs index 1aa1252bdd1d..69bf3f72493f 100644 --- a/crates/router/src/connector/paypal.rs +++ b/crates/router/src/connector/paypal.rs @@ -4,7 +4,7 @@ use std::fmt::{Debug, Write}; use base64::Engine; use common_utils::{ext_traits::ByteSliceExt, request::RequestContent}; use diesel_models::enums; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::{ExposeInterface, PeekInterface, Secret}; use transformers as paypal; @@ -245,7 +245,6 @@ impl ConnectorCommon for Paypal { .try_fold(String::new(), |mut acc, error| { if let Some(description) = &error.description { write!(acc, "description - {} ;", description) - .into_report() .change_context( errors::ConnectorError::ResponseDeserializationFailed, ) diff --git a/crates/router/src/connector/paypal/transformers.rs b/crates/router/src/connector/paypal/transformers.rs index d2d3989a6928..439184cafca7 100644 --- a/crates/router/src/connector/paypal/transformers.rs +++ b/crates/router/src/connector/paypal/transformers.rs @@ -1,7 +1,7 @@ use api_models::{enums, payments::BankRedirectData}; use base64::Engine; use common_utils::errors::CustomResult; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::{ExposeInterface, Secret}; use serde::{Deserialize, Serialize}; use time::PrimitiveDateTime; @@ -2133,7 +2133,6 @@ impl TryFrom<&types::VerifyWebhookSourceRequestData> for PaypalSourceVerificatio type Error = error_stack::Report; fn try_from(req: &types::VerifyWebhookSourceRequestData) -> Result { let req_body = serde_json::from_slice(&req.webhook_body) - .into_report() .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; Ok(Self { transmission_id: get_headers( @@ -2152,7 +2151,6 @@ impl TryFrom<&types::VerifyWebhookSourceRequestData> for PaypalSourceVerificatio )?, auth_algo: get_headers(&req.webhook_headers, webhook_headers::PAYPAL_AUTH_ALGO)?, webhook_id: String::from_utf8(req.merchant_secret.secret.to_vec()) - .into_report() .change_context(errors::ConnectorError::WebhookVerificationSecretNotFound) .attach_printable("Could not convert secret to UTF-8")?, webhook_event: req_body, @@ -2168,7 +2166,6 @@ fn get_headers( .get(key) .map(|value| value.to_str()) .ok_or(errors::ConnectorError::MissingRequiredField { field_name: key })? - .into_report() .change_context(errors::ConnectorError::InvalidDataFormat { field_name: key })? .to_owned(); Ok(header_value) diff --git a/crates/router/src/connector/payu.rs b/crates/router/src/connector/payu.rs index 3ff0e7093678..4ff317d1f713 100644 --- a/crates/router/src/connector/payu.rs +++ b/crates/router/src/connector/payu.rs @@ -4,7 +4,7 @@ use std::fmt::Debug; use common_utils::request::RequestContent; use diesel_models::enums; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use masking::PeekInterface; use transformers as payu; @@ -75,8 +75,7 @@ impl ConnectorCommon for Payu { &self, auth_type: &types::ConnectorAuthType, ) -> CustomResult)>, errors::ConnectorError> { - let auth: payu::PayuAuthType = auth_type - .try_into() + let auth = payu::PayuAuthType::try_from(auth_type) .change_context(errors::ConnectorError::FailedToObtainAuthType)?; Ok(vec![( headers::AUTHORIZATION.to_string(), @@ -312,12 +311,11 @@ impl ConnectorIntegration, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_event_type( @@ -796,6 +789,6 @@ impl api::IncomingWebhook for Payu { &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } diff --git a/crates/router/src/connector/payu/transformers.rs b/crates/router/src/connector/payu/transformers.rs index e8699a1a0ed3..9484749ff22a 100644 --- a/crates/router/src/connector/payu/transformers.rs +++ b/crates/router/src/connector/payu/transformers.rs @@ -1,6 +1,6 @@ use base64::Engine; use common_utils::pii::{Email, IpAddress}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use serde::{Deserialize, Serialize}; use crate::{ @@ -489,7 +489,6 @@ impl order .total_amount .parse::() - .into_report() .change_context(errors::ConnectorError::ResponseDeserializationFailed)?, ), ..item.data diff --git a/crates/router/src/connector/placetopay.rs b/crates/router/src/connector/placetopay.rs index c28fed1fedef..86a37bb0e211 100644 --- a/crates/router/src/connector/placetopay.rs +++ b/crates/router/src/connector/placetopay.rs @@ -3,7 +3,7 @@ pub mod transformers; use std::fmt::Debug; use common_utils::request::RequestContent; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use transformers as placetopay; use crate::{ @@ -662,20 +662,20 @@ impl api::IncomingWebhook for Placetopay { &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_event_type( &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_resource_object( &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } diff --git a/crates/router/src/connector/placetopay/transformers.rs b/crates/router/src/connector/placetopay/transformers.rs index 1c3b46fdb606..152e315de18f 100644 --- a/crates/router/src/connector/placetopay/transformers.rs +++ b/crates/router/src/connector/placetopay/transformers.rs @@ -1,7 +1,7 @@ use api_models::payments; use common_utils::date_time; use diesel_models::enums; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::{PeekInterface, Secret}; use ring::digest; use serde::{Deserialize, Serialize}; @@ -171,7 +171,7 @@ impl TryFrom<&types::ConnectorAuthType> for PlacetopayAuth { fn try_from(auth_type: &types::ConnectorAuthType) -> Result { let placetopay_auth = PlacetopayAuthType::try_from(auth_type)?; let nonce_bytes = utils::generate_random_bytes(16); - let now = error_stack::IntoReport::into_report(date_time::date_as_yyyymmddthhmmssmmmz()) + let now = date_time::date_as_yyyymmddthhmmssmmmz() .change_context(errors::ConnectorError::RequestEncodingFailed)?; let seed = format!("{}+00:00", now.split_at(now.len() - 5).0); let mut context = digest::Context::new(&digest::SHA256); @@ -312,7 +312,6 @@ impl TryFrom<&types::RefundsRouterData> for PlacetopayRefundRequest { .request .connector_transaction_id .parse::() - .into_report() .change_context(errors::ConnectorError::RequestEncodingFailed)?; let action = PlacetopayNextAction::Reverse; let authorization = match item.request.connector_metadata.clone() { @@ -417,7 +416,6 @@ impl TryFrom<&types::RefundsRouterData> for PlacetopayRsyncRequest { .request .connector_transaction_id .parse::() - .into_report() .change_context(errors::ConnectorError::RequestEncodingFailed)?; Ok(Self { auth, @@ -479,7 +477,6 @@ impl TryFrom<&types::PaymentsSyncRouterData> for PlacetopayPsyncRequest { .request .get_connector_transaction_id()? .parse::() - .into_report() .change_context(errors::ConnectorError::RequestEncodingFailed)?; Ok(Self { auth, @@ -515,7 +512,6 @@ impl TryFrom<&types::PaymentsCaptureRouterData> for PlacetopayNextActionRequest .request .connector_transaction_id .parse::() - .into_report() .change_context(errors::ConnectorError::RequestEncodingFailed)?; let action = PlacetopayNextAction::Checkout; Ok(Self { @@ -535,7 +531,6 @@ impl TryFrom<&types::PaymentsCancelRouterData> for PlacetopayNextActionRequest { .request .connector_transaction_id .parse::() - .into_report() .change_context(errors::ConnectorError::RequestEncodingFailed)?; let action = PlacetopayNextAction::Void; Ok(Self { diff --git a/crates/router/src/connector/powertranz.rs b/crates/router/src/connector/powertranz.rs index a26886384c03..9e514a435530 100644 --- a/crates/router/src/connector/powertranz.rs +++ b/crates/router/src/connector/powertranz.rs @@ -5,7 +5,7 @@ use std::fmt::Debug; use api_models::enums::AuthenticationType; use common_utils::{ext_traits::ValueExt, request::RequestContent}; use diesel_models::enums; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use masking::ExposeInterface; use transformers as powertranz; @@ -622,20 +622,20 @@ impl api::IncomingWebhook for Powertranz { &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_event_type( &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_resource_object( &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } diff --git a/crates/router/src/connector/powertranz/transformers.rs b/crates/router/src/connector/powertranz/transformers.rs index 0af5dde6d001..26a8e4fc69e0 100644 --- a/crates/router/src/connector/powertranz/transformers.rs +++ b/crates/router/src/connector/powertranz/transformers.rs @@ -1,7 +1,6 @@ use api_models::payments::Card; use common_utils::pii::{Email, IpAddress}; use diesel_models::enums::RefundStatus; -use error_stack::IntoReport; use masking::{ExposeInterface, Secret}; use serde::{Deserialize, Serialize}; use uuid::Uuid; @@ -117,8 +116,8 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for PowertranzPaymentsRequest | api::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotSupported { message: utils::SELECTED_PAYMENT_METHOD.to_string(), connector: "powertranz", - }) - .into_report(), + } + .into()), }?; // let billing_address = get_address_details(&item.address.billing, &item.request.email); // let shipping_address = get_address_details(&item.address.shipping, &item.request.email); diff --git a/crates/router/src/connector/prophetpay.rs b/crates/router/src/connector/prophetpay.rs index 04b3e7b6d653..ef49e716d9a8 100644 --- a/crates/router/src/connector/prophetpay.rs +++ b/crates/router/src/connector/prophetpay.rs @@ -4,7 +4,7 @@ use std::fmt::Debug; use base64::Engine; use common_utils::request::RequestContent; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use masking::PeekInterface; use transformers as prophetpay; @@ -710,20 +710,20 @@ impl api::IncomingWebhook for Prophetpay { &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_event_type( &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_resource_object( &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } diff --git a/crates/router/src/connector/prophetpay/transformers.rs b/crates/router/src/connector/prophetpay/transformers.rs index 563438203d83..06d23af33aff 100644 --- a/crates/router/src/connector/prophetpay/transformers.rs +++ b/crates/router/src/connector/prophetpay/transformers.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use common_utils::{consts, errors::CustomResult}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::{ExposeInterface, PeekInterface, Secret}; use serde::{Deserialize, Serialize}; use url::Url; @@ -201,7 +201,6 @@ impl ); let redirect_url = Url::parse(url_data.as_str()) - .into_report() .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; let redirection_data = get_redirect_url_form( @@ -304,10 +303,9 @@ fn get_card_token( .to_string(), ); } - Ok(queries) + Ok::<_, errors::ConnectorError>(queries) }) - .transpose() - .into_report()? + .transpose()? .ok_or(errors::ConnectorError::ResponseDeserializationFailed)?; for (key, val) in queries_params { diff --git a/crates/router/src/connector/rapyd.rs b/crates/router/src/connector/rapyd.rs index fd6de253047a..c5f92c20f5cd 100644 --- a/crates/router/src/connector/rapyd.rs +++ b/crates/router/src/connector/rapyd.rs @@ -8,7 +8,7 @@ use common_utils::{ request::RequestContent, }; use diesel_models::enums; -use error_stack::{IntoReport, Report, ResultExt}; +use error_stack::{Report, ResultExt}; use masking::{ExposeInterface, PeekInterface}; use rand::distributions::{Alphanumeric, DistString}; use ring::hmac; @@ -260,12 +260,11 @@ impl .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; event_builder.map(|i| i.set_response_body(&response)); router_env::logger::info!(connector_response=?response); - types::ResponseRouterData { + types::RouterData::try_from(types::ResponseRouterData { response, data: data.clone(), http_code: res.status_code, - } - .try_into() + }) .change_context(errors::ConnectorError::ResponseHandlingFailed) } @@ -383,12 +382,11 @@ impl .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; event_builder.map(|i| i.set_response_body(&response)); router_env::logger::info!(connector_response=?response); - types::ResponseRouterData { + types::RouterData::try_from(types::ResponseRouterData { response, data: data.clone(), http_code: res.status_code, - } - .try_into() + }) .change_context(errors::ConnectorError::ResponseHandlingFailed) } @@ -491,12 +489,11 @@ impl .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; event_builder.map(|i| i.set_response_body(&response)); router_env::logger::info!(connector_response=?response); - types::ResponseRouterData { + types::RouterData::try_from(types::ResponseRouterData { response, data: data.clone(), http_code: res.status_code, - } - .try_into() + }) .change_context(errors::ConnectorError::ResponseHandlingFailed) } } @@ -725,12 +722,11 @@ impl services::ConnectorIntegration .as_ref() .filter(|redirect_str| !redirect_str.is_empty()) .map(|url| { - Url::parse(url).into_report().change_context( + Url::parse(url).change_context( errors::ConnectorError::FailedToObtainIntegrationUrl, ) }) diff --git a/crates/router/src/connector/riskified.rs b/crates/router/src/connector/riskified.rs index 298f8fb1564a..b28fb5b27eff 100644 --- a/crates/router/src/connector/riskified.rs +++ b/crates/router/src/connector/riskified.rs @@ -3,7 +3,7 @@ use std::fmt::Debug; #[cfg(feature = "frm")] use common_utils::request::RequestContent; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use masking::{ExposeInterface, PeekInterface}; use ring::hmac; use transformers as riskified; @@ -551,20 +551,20 @@ impl api::IncomingWebhook for Riskified { &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_event_type( &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_resource_object( &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } diff --git a/crates/router/src/connector/shift4.rs b/crates/router/src/connector/shift4.rs index 0128aa1c2fae..e11a79cb027e 100644 --- a/crates/router/src/connector/shift4.rs +++ b/crates/router/src/connector/shift4.rs @@ -4,7 +4,7 @@ use std::fmt::Debug; use common_utils::{ext_traits::ByteSliceExt, request::RequestContent}; use diesel_models::enums; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use transformers as shift4; use super::utils::{self as connector_utils, RefundsRequestData}; @@ -74,8 +74,7 @@ impl ConnectorCommon for Shift4 { &self, auth_type: &types::ConnectorAuthType, ) -> CustomResult)>, errors::ConnectorError> { - let auth: shift4::Shift4AuthType = auth_type - .try_into() + let auth = shift4::Shift4AuthType::try_from(auth_type) .change_context(errors::ConnectorError::FailedToObtainAuthType)?; Ok(vec![( headers::AUTHORIZATION.to_string(), @@ -432,12 +431,11 @@ impl ConnectorIntegration serde_json::to_value(Shift4CardToken { id: item.response.token.id, }) - .into_report() .change_context(errors::ConnectorError::ResponseDeserializationFailed)?, ), network_txn_id: None, diff --git a/crates/router/src/connector/signifyd.rs b/crates/router/src/connector/signifyd.rs index 7d19df122211..6e63d5487e52 100644 --- a/crates/router/src/connector/signifyd.rs +++ b/crates/router/src/connector/signifyd.rs @@ -3,7 +3,7 @@ use std::fmt::Debug; #[cfg(feature = "frm")] use common_utils::request::RequestContent; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use masking::PeekInterface; use transformers as signifyd; @@ -647,20 +647,20 @@ impl api::IncomingWebhook for Signifyd { &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_event_type( &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_resource_object( &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } diff --git a/crates/router/src/connector/square.rs b/crates/router/src/connector/square.rs index 8bfc9582d0c0..915a9a9ca114 100644 --- a/crates/router/src/connector/square.rs +++ b/crates/router/src/connector/square.rs @@ -5,7 +5,7 @@ use std::fmt::Debug; use api_models::enums; use base64::Engine; use common_utils::{ext_traits::ByteSliceExt, request::RequestContent}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::PeekInterface; use transformers as square; @@ -898,7 +898,6 @@ impl api::IncomingWebhook for Square { super_utils::get_header_key_value("x-square-hmacsha256-signature", request.headers)?; let signature = consts::BASE64_ENGINE .decode(encoded_signature) - .into_report() .change_context(errors::ConnectorError::WebhookSignatureNotFound)?; Ok(signature) } @@ -915,7 +914,6 @@ impl api::IncomingWebhook for Square { .ok_or(errors::ConnectorError::WebhookSourceVerificationFailed)?; let authority = header_value .to_str() - .into_report() .change_context(errors::ConnectorError::WebhookSourceVerificationFailed)?; Ok(format!( diff --git a/crates/router/src/connector/square/transformers.rs b/crates/router/src/connector/square/transformers.rs index 66a0282f9234..064e8457403c 100644 --- a/crates/router/src/connector/square/transformers.rs +++ b/crates/router/src/connector/square/transformers.rs @@ -1,5 +1,5 @@ use api_models::payments::{BankDebitData, PayLaterData, WalletData}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::{ExposeInterface, PeekInterface, Secret}; use serde::{Deserialize, Serialize}; @@ -43,7 +43,6 @@ impl TryFrom<(&types::TokenizationRouterData, api_models::payments::Card)> for S .get_expiry_year_4_digit() .peek() .parse::() - .into_report() .change_context(errors::ConnectorError::DateFormattingFailed)?, ); let exp_month = Secret::new( @@ -51,7 +50,6 @@ impl TryFrom<(&types::TokenizationRouterData, api_models::payments::Card)> for S .card_exp_month .peek() .parse::() - .into_report() .change_context(errors::ConnectorError::DateFormattingFailed)?, ); //The below error will never happen because if session-id is not generated it would give error in execute_pretasks itself. diff --git a/crates/router/src/connector/stax.rs b/crates/router/src/connector/stax.rs index 73bcb0b8c619..c923ca0577d7 100644 --- a/crates/router/src/connector/stax.rs +++ b/crates/router/src/connector/stax.rs @@ -4,7 +4,7 @@ use std::fmt::Debug; use common_utils::{ext_traits::ByteSliceExt, request::RequestContent}; use diesel_models::enums; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::PeekInterface; use transformers as stax; @@ -107,7 +107,6 @@ impl ConnectorCommon for Stax { message: consts::NO_ERROR_MESSAGE.to_string(), reason: Some( std::str::from_utf8(&res.response) - .into_report() .change_context(errors::ConnectorError::ResponseDeserializationFailed)? .to_owned(), ), @@ -927,7 +926,6 @@ impl api::IncomingWebhook for Stax { request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { let reference_object: serde_json::Value = serde_json::from_slice(request.body) - .into_report() .change_context(errors::ConnectorError::WebhookResourceObjectNotFound)?; Ok(Box::new(reference_object)) } diff --git a/crates/router/src/connector/stax/transformers.rs b/crates/router/src/connector/stax/transformers.rs index d28b5c1fa466..1d7cc63a9379 100644 --- a/crates/router/src/connector/stax/transformers.rs +++ b/crates/router/src/connector/stax/transformers.rs @@ -1,5 +1,5 @@ use common_utils::pii::Email; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::{ExposeInterface, Secret}; use serde::{Deserialize, Serialize}; @@ -157,8 +157,8 @@ impl TryFrom<&types::ConnectorCustomerRouterData> for StaxCustomerRequest { if item.request.email.is_none() && item.request.name.is_none() { Err(errors::ConnectorError::MissingRequiredField { field_name: "email or name", - }) - .into_report() + } + .into()) } else { Ok(Self { email: item.request.email.to_owned(), diff --git a/crates/router/src/connector/stripe.rs b/crates/router/src/connector/stripe.rs index bf942ea1b3f0..a3cf0d5c8379 100644 --- a/crates/router/src/connector/stripe.rs +++ b/crates/router/src/connector/stripe.rs @@ -4,7 +4,7 @@ use std::{collections::HashMap, fmt::Debug, ops::Deref}; use common_utils::request::RequestContent; use diesel_models::enums; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::PeekInterface; use router_env::{instrument, tracing}; use stripe::auth_headers; @@ -53,8 +53,7 @@ impl ConnectorCommon for Stripe { &self, auth_type: &types::ConnectorAuthType, ) -> CustomResult)>, errors::ConnectorError> { - let auth: stripe::StripeAuthType = auth_type - .try_into() + let auth = stripe::StripeAuthType::try_from(auth_type) .change_context(errors::ConnectorError::FailedToObtainAuthType)?; Ok(vec![ ( @@ -1917,10 +1916,8 @@ fn get_signature_elements_from_header( .to_str() .map(String::from) .map_err(|_| errors::ConnectorError::WebhookSignatureNotFound) - .into_report() }) - .ok_or(errors::ConnectorError::WebhookSignatureNotFound) - .into_report()??; + .ok_or(errors::ConnectorError::WebhookSignatureNotFound)??; let props = security_header.split(',').collect::>(); let mut security_header_kvs: HashMap> = HashMap::with_capacity(props.len()); @@ -1928,8 +1925,7 @@ fn get_signature_elements_from_header( for prop_str in &props { let (prop_key, prop_value) = prop_str .split_once('=') - .ok_or(errors::ConnectorError::WebhookSourceVerificationFailed) - .into_report()?; + .ok_or(errors::ConnectorError::WebhookSourceVerificationFailed)?; security_header_kvs.insert(prop_key.to_string(), prop_value.bytes().collect()); } @@ -1955,12 +1951,9 @@ impl api::IncomingWebhook for Stripe { let signature = security_header_kvs .remove("v1") - .ok_or(errors::ConnectorError::WebhookSignatureNotFound) - .into_report()?; + .ok_or(errors::ConnectorError::WebhookSignatureNotFound)?; - hex::decode(signature) - .into_report() - .change_context(errors::ConnectorError::WebhookSignatureNotFound) + hex::decode(signature).change_context(errors::ConnectorError::WebhookSignatureNotFound) } fn get_webhook_source_verification_message( @@ -1973,8 +1966,7 @@ impl api::IncomingWebhook for Stripe { let timestamp = security_header_kvs .remove("t") - .ok_or(errors::ConnectorError::WebhookSignatureNotFound) - .into_report()?; + .ok_or(errors::ConnectorError::WebhookSignatureNotFound)?; Ok(format!( "{}.{}", diff --git a/crates/router/src/connector/stripe/transformers.rs b/crates/router/src/connector/stripe/transformers.rs index 860065b2b039..95d9b6dd9063 100644 --- a/crates/router/src/connector/stripe/transformers.rs +++ b/crates/router/src/connector/stripe/transformers.rs @@ -8,7 +8,7 @@ use common_utils::{ request::RequestContent, }; use data_models::mandates::AcceptanceType; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::{ExposeInterface, ExposeOptionInterface, PeekInterface, Secret}; use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -915,15 +915,15 @@ fn validate_shipping_address_against_payment_method( if !missing_fields.is_empty() { return Err(errors::ConnectorError::MissingRequiredFields { field_names: missing_fields, - }) - .into_report(); + } + .into()); } Ok(()) } None => Err(errors::ConnectorError::MissingRequiredField { field_name: "shipping.address", - }) - .into_report(), + } + .into()), }, _ => Ok(()), } diff --git a/crates/router/src/connector/threedsecureio.rs b/crates/router/src/connector/threedsecureio.rs index 818f2ebcec07..ecb80433594a 100644 --- a/crates/router/src/connector/threedsecureio.rs +++ b/crates/router/src/connector/threedsecureio.rs @@ -2,7 +2,7 @@ pub mod transformers; use std::fmt::Debug; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use masking::ExposeInterface; use pm_auth::consts; use transformers as threedsecureio; @@ -192,21 +192,21 @@ impl api::IncomingWebhook for Threedsecureio { &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_event_type( &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_resource_object( &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } diff --git a/crates/router/src/connector/threedsecureio/transformers.rs b/crates/router/src/connector/threedsecureio/transformers.rs index 42a453f5ce92..2d662e5e30f8 100644 --- a/crates/router/src/connector/threedsecureio/transformers.rs +++ b/crates/router/src/connector/threedsecureio/transformers.rs @@ -3,7 +3,7 @@ use std::str::FromStr; use api_models::payments::{DeviceChannel, ThreeDsCompletionIndicator}; use base64::Engine; use common_utils::date_time; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use iso_currency::Currency; use isocountry; use masking::{ExposeInterface, Secret}; @@ -86,7 +86,6 @@ impl "threeDSServerTransID": pre_authn_response.threeds_server_trans_id, }); let three_ds_method_data_str = to_string(&three_ds_method_data) - .into_report() .change_context(errors::ConnectorError::ResponseDeserializationFailed) .attach_printable("error while constructing three_ds_method_data_str")?; let three_ds_method_data_base64 = BASE64_ENGINE.encode(three_ds_method_data_str); @@ -167,7 +166,6 @@ impl "challengeWindowSize": "01", }); let creq_str = to_string(&creq) - .into_report() .change_context(errors::ConnectorError::ResponseDeserializationFailed) .attach_printable("error while constructing creq_str")?; let creq_base64 = base64::Engine::encode(&BASE64_ENGINE, creq_str) @@ -283,11 +281,9 @@ impl TryFrom<&ThreedsecureioRouterData<&types::authentication::ConnectorAuthenti .currency .map(|currency| currency.to_string()) .ok_or(errors::ConnectorError::RequestEncodingFailed) - .into_report() .attach_printable("missing field currency")?; let purchase_currency: Currency = iso_currency::Currency::from_code(¤cy) .ok_or(errors::ConnectorError::RequestEncodingFailed) - .into_report() .attach_printable("error while parsing Currency")?; let billing_address = request.billing_address.address.clone().ok_or( errors::ConnectorError::MissingRequiredField { @@ -303,7 +299,6 @@ impl TryFrom<&ThreedsecureioRouterData<&types::authentication::ConnectorAuthenti })? .to_string(), ) - .into_report() .change_context(errors::ConnectorError::RequestEncodingFailed) .attach_printable("Error parsing billing_address.address.country")?; let connector_meta_data: ThreeDSecureIoMetaData = item @@ -345,7 +340,6 @@ impl TryFrom<&ThreedsecureioRouterData<&types::authentication::ConnectorAuthenti .return_url .clone() .ok_or(errors::ConnectorError::RequestEncodingFailed) - .into_report() .attach_printable("missing return_url")?, three_dscomp_ind: ThreeDSecureIoThreeDsCompletionIndicator::from( request.threeds_method_comp_ind.clone(), @@ -426,7 +420,6 @@ impl TryFrom<&ThreedsecureioRouterData<&types::authentication::ConnectorAuthenti purchase_exponent: purchase_currency .exponent() .ok_or(errors::ConnectorError::RequestEncodingFailed) - .into_report() .attach_printable("missing purchase_exponent")? .to_string(), purchase_date: date_time::DateTime::::from(date_time::now()) diff --git a/crates/router/src/connector/trustpay.rs b/crates/router/src/connector/trustpay.rs index 116cea9e2396..ed4978743ddb 100644 --- a/crates/router/src/connector/trustpay.rs +++ b/crates/router/src/connector/trustpay.rs @@ -6,7 +6,7 @@ use base64::Engine; use common_utils::{ crypto, errors::ReportSwitchExt, ext_traits::ByteSliceExt, request::RequestContent, }; -use error_stack::{IntoReport, Report, ResultExt}; +use error_stack::{Report, ResultExt}; use masking::PeekInterface; use transformers as trustpay; @@ -942,7 +942,6 @@ impl api::IncomingWebhook for Trustpay { .parse_struct("TrustpayWebhookResponse") .switch()?; hex::decode(response.signature) - .into_report() .change_context(errors::ConnectorError::WebhookSignatureNotFound) } diff --git a/crates/router/src/connector/tsys.rs b/crates/router/src/connector/tsys.rs index 10e5af8de223..9387fbcec1ef 100644 --- a/crates/router/src/connector/tsys.rs +++ b/crates/router/src/connector/tsys.rs @@ -4,7 +4,7 @@ use std::fmt::Debug; use common_utils::request::RequestContent; use diesel_models::enums; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use transformers as tsys; use crate::{ @@ -635,20 +635,20 @@ impl api::IncomingWebhook for Tsys { &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_event_type( &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_resource_object( &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } diff --git a/crates/router/src/connector/utils.rs b/crates/router/src/connector/utils.rs index a41c05f19be0..89b88243057c 100644 --- a/crates/router/src/connector/utils.rs +++ b/crates/router/src/connector/utils.rs @@ -12,7 +12,7 @@ use common_utils::{ }; use data_models::payments::payment_attempt::PaymentAttempt; use diesel_models::enums; -use error_stack::{report, IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use masking::{ExposeInterface, Secret}; use once_cell::sync::Lazy; use regex::Regex; @@ -657,7 +657,6 @@ impl PaymentsSyncRequestData for types::PaymentsSyncData { _ => Err(errors::ValidationError::IncorrectValueProvided { field_name: "connector_transaction_id", }) - .into_report() .attach_printable("Expected connector transaction ID not found") .change_context(errors::ConnectorError::MissingConnectorTransactionID)?, } @@ -868,7 +867,6 @@ impl CardData for api::Card { .peek() .clone() .parse::() - .into_report() .change_context(errors::ConnectorError::ResponseDeserializationFailed) .map(Secret::new) } @@ -877,7 +875,6 @@ impl CardData for api::Card { .peek() .clone() .parse::() - .into_report() .change_context(errors::ConnectorError::ResponseDeserializationFailed) .map(Secret::new) } @@ -888,7 +885,6 @@ fn get_card_issuer(card_number: &str) -> Result { for (k, v) in CARD_REGEX.iter() { let regex: Regex = v .clone() - .into_report() .change_context(errors::ConnectorError::RequestEncodingFailed)?; if regex.is_match(card_number) { return Ok(*k); @@ -920,7 +916,6 @@ impl WalletData for api::WalletData { T: serde::de::DeserializeOwned, { serde_json::from_str::(self.get_wallet_token()?.peek()) - .into_report() .change_context(errors::ConnectorError::InvalidWalletToken { wallet_name }) } @@ -929,11 +924,11 @@ impl WalletData for api::WalletData { Self::GooglePay(_) => { 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 { + let token_as_vec = serde_json::to_vec(&json_token).change_context( + errors::ConnectorError::InvalidWalletToken { wallet_name: "Google Pay".to_string(), - })?; + }, + )?; let encoded_token = consts::BASE64_ENGINE.encode(token_as_vec); Ok(encoded_token) } @@ -954,12 +949,10 @@ impl ApplePay for payments::ApplePayWalletData { String::from_utf8( consts::BASE64_ENGINE .decode(&self.payment_data) - .into_report() .change_context(errors::ConnectorError::InvalidWalletToken { wallet_name: "Apple Pay".to_string(), })?, ) - .into_report() .change_context(errors::ConnectorError::InvalidWalletToken { wallet_name: "Apple Pay".to_string(), })?, @@ -1157,7 +1150,6 @@ impl MandateData for payments::MandateAmountData { "mandate_data.mandate_type.{multi_use|single_use}.end_date", ))?; date_time::format_date(date, format) - .into_report() .change_context(errors::ConnectorError::DateFormattingFailed) } fn get_metadata(&self) -> Result { @@ -1216,7 +1208,6 @@ fn get_header_field( .map(|header_value| { header_value .to_str() - .into_report() .change_context(errors::ConnectorError::WebhookSignatureNotFound) }) .ok_or(report!( @@ -1270,7 +1261,6 @@ impl common_utils::errors::ErrorSwitch for errors::Parsi pub fn base64_decode(data: String) -> Result, Error> { consts::BASE64_ENGINE .decode(data) - .into_report() .change_context(errors::ConnectorError::ResponseDeserializationFailed) } @@ -1307,7 +1297,6 @@ pub fn get_amount_as_f64( let amount = match currency_unit { types::api::CurrencyUnit::Base => to_currency_base_unit_asf64(amount, currency)?, types::api::CurrencyUnit::Minor => u32::try_from(amount) - .into_report() .change_context(errors::ConnectorError::ParsingFailed)? .into(), }; @@ -1320,7 +1309,6 @@ pub fn to_currency_base_unit( ) -> Result> { currency .to_currency_base_unit(amount) - .into_report() .change_context(errors::ConnectorError::ParsingFailed) } @@ -1330,7 +1318,6 @@ pub fn to_currency_lower_unit( ) -> Result> { currency .to_currency_lower_unit(amount) - .into_report() .change_context(errors::ConnectorError::ResponseHandlingFailed) } @@ -1359,7 +1346,6 @@ pub fn to_currency_base_unit_with_zero_decimal_check( ) -> Result> { currency .to_currency_base_unit_with_zero_decimal_check(amount) - .into_report() .change_context(errors::ConnectorError::RequestEncodingFailed) } @@ -1369,7 +1355,6 @@ pub fn to_currency_base_unit_asf64( ) -> Result> { currency .to_currency_base_unit_asf64(amount) - .into_report() .change_context(errors::ConnectorError::ParsingFailed) } diff --git a/crates/router/src/connector/volt.rs b/crates/router/src/connector/volt.rs index 4a08bc1ad6b8..9dc99e7881cb 100644 --- a/crates/router/src/connector/volt.rs +++ b/crates/router/src/connector/volt.rs @@ -3,7 +3,7 @@ pub mod transformers; use std::fmt::Debug; use common_utils::{crypto, ext_traits::ByteSliceExt, request::RequestContent}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::{ExposeInterface, PeekInterface}; use transformers as volt; @@ -642,7 +642,6 @@ impl api::IncomingWebhook for Volt { .change_context(errors::ConnectorError::WebhookSignatureNotFound)?; hex::decode(signature) - .into_report() .change_context(errors::ConnectorError::WebhookVerificationSecretInvalid) } diff --git a/crates/router/src/connector/wise.rs b/crates/router/src/connector/wise.rs index 152786b46a3a..e4a49d7c5668 100644 --- a/crates/router/src/connector/wise.rs +++ b/crates/router/src/connector/wise.rs @@ -3,7 +3,7 @@ use std::fmt::Debug; #[cfg(feature = "payouts")] use common_utils::request::RequestContent; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; #[cfg(feature = "payouts")] use masking::PeekInterface; #[cfg(feature = "payouts")] @@ -748,20 +748,20 @@ impl api::IncomingWebhook for Wise { &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_event_type( &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_resource_object( &self, _request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { - Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } diff --git a/crates/router/src/connector/worldline.rs b/crates/router/src/connector/worldline.rs index 410d096d20ad..ae5e6c1b4a33 100644 --- a/crates/router/src/connector/worldline.rs +++ b/crates/router/src/connector/worldline.rs @@ -5,7 +5,7 @@ use std::fmt::Debug; use base64::Engine; use common_utils::{ext_traits::ByteSliceExt, request::RequestContent}; use diesel_models::enums; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::{ExposeInterface, PeekInterface}; use ring::hmac; use time::{format_description, OffsetDateTime}; @@ -65,11 +65,9 @@ impl Worldline { let format = format_description::parse( "[weekday repr:short], [day] [month repr:short] [year] [hour]:[minute]:[second] GMT", ) - .into_report() .change_context(errors::ConnectorError::InvalidDateFormat)?; OffsetDateTime::now_utc() .format(&format) - .into_report() .change_context(errors::ConnectorError::InvalidDateFormat) } } @@ -575,12 +573,11 @@ impl ConnectorIntegration, ) -> CustomResult { || -> _ { - Ok(api_models::webhooks::ObjectReferenceId::PaymentId( - api_models::payments::PaymentIdType::ConnectorTransactionId( - request - .body - .parse_struct::("WorldlineWebhookEvent")? - .payment - .parse_value::("WorldlineWebhookObjectId")? - .id, + Ok::<_, error_stack::Report>( + api_models::webhooks::ObjectReferenceId::PaymentId( + api_models::payments::PaymentIdType::ConnectorTransactionId( + request + .body + .parse_struct::("WorldlineWebhookEvent")? + .payment + .parse_value::("WorldlineWebhookObjectId")? + .id, + ), ), - )) + ) }() .change_context(errors::ConnectorError::WebhookReferenceIdNotFound) } @@ -866,7 +862,6 @@ impl api::IncomingWebhook for Worldline { Some(header_value) => { let verification_signature_value = header_value .to_str() - .into_report() .change_context(errors::ConnectorError::WebhookResponseEncodingFailed)? .to_string(); services::api::ApplicationResponse::TextPlain(verification_signature_value) diff --git a/crates/router/src/connector/worldpay.rs b/crates/router/src/connector/worldpay.rs index 65d4d2553e56..1f2dac807d16 100644 --- a/crates/router/src/connector/worldpay.rs +++ b/crates/router/src/connector/worldpay.rs @@ -6,7 +6,7 @@ use std::fmt::Debug; use common_utils::{crypto, ext_traits::ByteSliceExt, request::RequestContent}; use diesel_models::enums; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use transformers as worldpay; use self::{requests::*, response::*}; @@ -73,8 +73,7 @@ impl ConnectorCommon for Worldpay { &self, auth_type: &types::ConnectorAuthType, ) -> CustomResult)>, errors::ConnectorError> { - let auth: worldpay::WorldpayAuthType = auth_type - .try_into() + let auth = worldpay::WorldpayAuthType::try_from(auth_type) .change_context(errors::ConnectorError::FailedToObtainAuthType)?; Ok(vec![( headers::AUTHORIZATION.to_string(), @@ -722,9 +721,7 @@ impl api::IncomingWebhook for Worldpay { .split('/') .last() .ok_or(errors::ConnectorError::WebhookSignatureNotFound)?; - hex::decode(signature) - .into_report() - .change_context(errors::ConnectorError::WebhookResponseEncodingFailed) + hex::decode(signature).change_context(errors::ConnectorError::WebhookResponseEncodingFailed) } fn get_webhook_source_verification_message( @@ -734,13 +731,11 @@ impl api::IncomingWebhook for Worldpay { connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets, ) -> CustomResult, errors::ConnectorError> { let secret_str = std::str::from_utf8(&connector_webhook_secrets.secret) - .into_report() .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; let to_sign = format!( "{}{}", secret_str, std::str::from_utf8(request.body) - .into_report() .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)? ); Ok(to_sign.into_bytes()) diff --git a/crates/router/src/connector/zen.rs b/crates/router/src/connector/zen.rs index 537e97cb5771..7c28dfcc43a7 100644 --- a/crates/router/src/connector/zen.rs +++ b/crates/router/src/connector/zen.rs @@ -3,7 +3,7 @@ pub mod transformers; use std::fmt::Debug; use common_utils::{crypto, ext_traits::ByteSliceExt, request::RequestContent}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::PeekInterface; use transformers as zen; use uuid::Uuid; @@ -582,9 +582,7 @@ impl api::IncomingWebhook for Zen { .parse_struct("ZenWebhookSignature") .change_context(errors::ConnectorError::WebhookSignatureNotFound)?; let signature = webhook_body.hash; - hex::decode(signature) - .into_report() - .change_context(errors::ConnectorError::WebhookSignatureNotFound) + hex::decode(signature).change_context(errors::ConnectorError::WebhookSignatureNotFound) } fn get_webhook_source_verification_message( @@ -688,7 +686,6 @@ impl api::IncomingWebhook for Zen { request: &api::IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { let reference_object: serde_json::Value = serde_json::from_slice(request.body) - .into_report() .change_context(errors::ConnectorError::WebhookResourceObjectNotFound)?; Ok(Box::new(reference_object)) } diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rs index a4be66242eeb..f48227b926ef 100644 --- a/crates/router/src/core/admin.rs +++ b/crates/router/src/core/admin.rs @@ -11,7 +11,7 @@ use common_utils::{ pii, }; use diesel_models::configs; -use error_stack::{report, FutureExt, IntoReport, ResultExt}; +use error_stack::{report, FutureExt, ResultExt}; use futures::future::try_join_all; use masking::{PeekInterface, Secret}; use pm_auth::connector::plaid::transformers::PlaidAuthType; @@ -175,7 +175,7 @@ pub async fn create_merchant_account( }; let mut merchant_account = async { - Ok(domain::MerchantAccount { + Ok::<_, error_stack::Report>(domain::MerchantAccount { merchant_id: req.merchant_id, merchant_name: req .merchant_name @@ -279,8 +279,7 @@ pub async fn create_merchant_account( .ok(); Ok(service_api::ApplicationResponse::Json( - merchant_account - .try_into() + api::MerchantAccountResponse::try_from(merchant_account) .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Failed while generating response")?, )) @@ -300,11 +299,11 @@ pub async fn list_merchant_account( let merchant_accounts = merchant_accounts .into_iter() .map(|merchant_account| { - merchant_account - .try_into() - .change_context(errors::ApiErrorResponse::InvalidDataValue { + api::MerchantAccountResponse::try_from(merchant_account).change_context( + errors::ApiErrorResponse::InvalidDataValue { field_name: "merchant_account", - }) + }, + ) }) .collect::, _>>()?; @@ -330,8 +329,7 @@ pub async fn get_merchant_account( .to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?; Ok(service_api::ApplicationResponse::Json( - merchant_account - .try_into() + api::MerchantAccountResponse::try_from(merchant_account) .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Failed to construct response")?, )) @@ -609,8 +607,7 @@ pub async fn merchant_account_update( // If there are any new business labels generated, create business profile Ok(service_api::ApplicationResponse::Json( - response - .try_into() + api::MerchantAccountResponse::try_from(response) .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Failed while generating response")?, )) @@ -796,22 +793,21 @@ pub async fn create_payment_connector( if req.connector_type != api_enums::ConnectorType::PaymentMethodAuth { return Err(errors::ApiErrorResponse::InvalidRequestData { message: "Invalid connector type given".to_string(), - }) - .into_report(); + } + .into()); } } else if authentication_connector.is_some() { if req.connector_type != api_enums::ConnectorType::AuthenticationProcessor { return Err(errors::ApiErrorResponse::InvalidRequestData { message: "Invalid connector type given".to_string(), - }) - .into_report(); + } + .into()); } } else { let routable_connector_option = req .connector_name .to_string() - .parse() - .into_report() + .parse::() .change_context(errors::ApiErrorResponse::InvalidRequestData { message: "Invalid connector name given".to_string(), })?; @@ -1047,7 +1043,6 @@ async fn validate_pm_auth( profile_id: &Option, ) -> RouterResponse<()> { let config = serde_json::from_value::(val) - .into_report() .change_context(errors::ApiErrorResponse::InvalidRequestData { message: "invalid data received for payment method auth config".to_string(), }) @@ -1071,15 +1066,14 @@ async fn validate_pm_auth( .find(|mca| mca.merchant_connector_id == conn_choice.mca_id) .ok_or(errors::ApiErrorResponse::GenericNotFoundError { message: "payment method auth connector account not found".to_string(), - }) - .into_report()?; + })?; if &pm_auth_mca.profile_id != profile_id { return Err(errors::ApiErrorResponse::GenericNotFoundError { message: "payment method auth profile_id differs from connector profile_id" .to_string(), - }) - .into_report(); + } + .into()); } } @@ -1205,7 +1199,6 @@ pub async fn update_payment_connector( let metadata = req.metadata.clone().or(mca.metadata.clone()); let connector_name = mca.connector_name.as_ref(); let connector_enum = api_models::enums::Connector::from_str(connector_name) - .into_report() .change_context(errors::ApiErrorResponse::InvalidDataValue { field_name: "connector", }) @@ -1297,7 +1290,6 @@ pub async fn update_payment_connector( .profile_id .clone() .ok_or(errors::ApiErrorResponse::InternalServerError) - .into_report() .attach_printable("Missing `profile_id` in merchant connector account")?; let request_connector_label = req.connector_label; diff --git a/crates/router/src/core/api_keys.rs b/crates/router/src/core/api_keys.rs index 738d9d0c87a3..f75ed0116880 100644 --- a/crates/router/src/core/api_keys.rs +++ b/crates/router/src/core/api_keys.rs @@ -1,7 +1,7 @@ use common_utils::date_time; #[cfg(feature = "email")] use diesel_models::{api_keys::ApiKey, enums as storage_enums}; -use error_stack::{report, IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use masking::{PeekInterface, StrongSecret}; use router_env::{instrument, tracing}; @@ -33,12 +33,10 @@ impl settings::ApiKeys { HASH_KEY.get_or_try_init(|| { <[u8; PlaintextApiKey::HASH_KEY_LEN]>::try_from( hex::decode(self.hash_key.peek()) - .into_report() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("API key hash key has invalid hexadecimal data")? .as_slice(), ) - .into_report() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("The API hashing key has incorrect length") .map(StrongSecret::new) @@ -165,7 +163,6 @@ pub async fn create_api_key( add_api_key_expiry_task(store, &api_key, expiry_reminder_days) .await - .into_report() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Failed to insert API key expiry reminder to process tracker")?; } @@ -197,7 +194,6 @@ pub async fn add_api_key_expiry_task( }) }) .ok_or(errors::ApiErrorResponse::InternalServerError) - .into_report() .attach_printable("Failed to obtain initial process tracker schedule time")?; if schedule_time <= current_time { @@ -302,7 +298,6 @@ pub async fn update_api_key( // Process exist in process, update the process with new schedule_time update_api_key_expiry_task(store, &api_key, expiry_reminder_days) .await - .into_report() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable( "Failed to update API key expiry reminder task in process tracker", @@ -313,7 +308,6 @@ pub async fn update_api_key( // Process exist in process, revoke it revoke_api_key_expiry_task(store, &key_id) .await - .into_report() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable( "Failed to revoke API key expiry reminder task in process tracker", @@ -327,7 +321,6 @@ pub async fn update_api_key( // schedule_time based on new expiry set. add_api_key_expiry_task(store, &api_key, expiry_reminder_days) .await - .into_report() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable( "Failed to insert API key expiry reminder task to process tracker", @@ -378,7 +371,6 @@ pub async fn update_api_key_expiry_task( }; let updated_api_key_expiry_workflow_model = serde_json::to_value(updated_tracking_data) - .into_report() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable_lazy(|| { format!("unable to serialize API key expiry tracker: {updated_tracking_data:?}") @@ -432,7 +424,6 @@ pub async fn revoke_api_key( if existing_process_tracker_task.is_some() { revoke_api_key_expiry_task(store, key_id) .await - .into_report() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable( "Failed to revoke API key expiry reminder task in process tracker", diff --git a/crates/router/src/core/api_locking.rs b/crates/router/src/core/api_locking.rs index b5c3f8ae53e1..ec205f524271 100644 --- a/crates/router/src/core/api_locking.rs +++ b/crates/router/src/core/api_locking.rs @@ -1,7 +1,7 @@ use std::fmt::Debug; use actix_web::rt::time as actix_time; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use redis_interface as redis; use router_env::{instrument, logger, tracing}; @@ -102,7 +102,7 @@ impl LockAction { } } - Err(errors::ApiErrorResponse::ResourceBusy).into_report() + Err(report!(errors::ApiErrorResponse::ResourceBusy)) } Self::QueueWithOk | Self::Drop | Self::NotApplicable => Ok(()), } @@ -135,19 +135,18 @@ impl LockAction { .record("redis_lock_released", redis_locking_key); Ok(()) } - Ok(redis::types::DelReply::KeyNotDeleted) => Err( - errors::ApiErrorResponse::InternalServerError, - ) - .into_report() - .attach_printable( - "Status release lock called but key is not found in redis", - ), + Ok(redis::types::DelReply::KeyNotDeleted) => { + Err(errors::ApiErrorResponse::InternalServerError) + .attach_printable( + "Status release lock called but key is not found in redis", + ) + } Err(error) => Err(error) .change_context(errors::ApiErrorResponse::InternalServerError), } } else { Err(errors::ApiErrorResponse::InternalServerError) - .into_report().attach_printable("The request_id which acquired the lock is not equal to the request_id requesting for releasing the lock") + .attach_printable("The request_id which acquired the lock is not equal to the request_id requesting for releasing the lock") } } Err(error) => { diff --git a/crates/router/src/core/authentication.rs b/crates/router/src/core/authentication.rs index fa77ac1b5da7..09d8ccc88334 100644 --- a/crates/router/src/core/authentication.rs +++ b/crates/router/src/core/authentication.rs @@ -6,7 +6,7 @@ pub mod types; use api_models::payments; use common_enums::Currency; use common_utils::{errors::CustomResult, ext_traits::ValueExt}; -use error_stack::ResultExt; +use error_stack::{report, ResultExt}; use masking::PeekInterface; use super::errors; @@ -99,7 +99,7 @@ pub async fn perform_authentication( } } }), - _ => Err(errors::ApiErrorResponse::InternalServerError.into()) + _ => Err(report!(errors::ApiErrorResponse::InternalServerError)) .attach_printable("unexpected response in authentication flow")?, } } diff --git a/crates/router/src/core/blocklist/utils.rs b/crates/router/src/core/blocklist/utils.rs index 68cdb2690b73..7c01a9aca768 100644 --- a/crates/router/src/core/blocklist/utils.rs +++ b/crates/router/src/core/blocklist/utils.rs @@ -2,7 +2,7 @@ use api_models::blocklist as api_blocklist; use common_enums::MerchantDecision; use common_utils::errors::CustomResult; use diesel_models::configs; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::StrongSecret; use super::{errors, transformers::generate_fingerprint, AppState}; @@ -120,8 +120,8 @@ fn validate_card_bin(bin: &str) -> RouterResult<()> { Err(errors::ApiErrorResponse::InvalidDataFormat { field_name: "data".to_string(), expected_format: "a 6 digit number".to_string(), - }) - .into_report() + } + .into()) } } @@ -132,8 +132,8 @@ fn validate_extended_card_bin(bin: &str) -> RouterResult<()> { Err(errors::ApiErrorResponse::InvalidDataFormat { field_name: "data".to_string(), expected_format: "an 8 digit number".to_string(), - }) - .into_report() + } + .into()) } } @@ -176,8 +176,8 @@ pub async fn insert_entry_into_blocklist( return Err(errors::ApiErrorResponse::PreconditionFailed { message: "data associated with the given fingerprint is already blocked" .to_string(), - }) - .into_report(); + } + .into()); } // if it is a db not found error, we can proceed as normal @@ -259,8 +259,8 @@ async fn duplicate_check_insert_bin( Ok(_) => { return Err(errors::ApiErrorResponse::PreconditionFailed { message: "provided bin is already blocked".to_string(), - }) - .into_report(); + } + .into()); } Err(e) if e.current_context().is_db_not_found() => {} diff --git a/crates/router/src/core/conditional_config.rs b/crates/router/src/core/conditional_config.rs index 26789470c208..c352e825052a 100644 --- a/crates/router/src/core/conditional_config.rs +++ b/crates/router/src/core/conditional_config.rs @@ -4,7 +4,7 @@ use api_models::{ }; use common_utils::ext_traits::{Encode, StringExt, ValueExt}; use diesel_models::configs; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use euclid::frontend::ast; use super::routing::helpers::{ @@ -65,7 +65,6 @@ pub async fn upsert_conditional_config( let read_config_key = db.find_config_by_key(&key).await; ast::lowering::lower_program(prog.clone()) - .into_report() .change_context(errors::ApiErrorResponse::InvalidRequestData { message: "Invalid Request Data".to_string(), }) diff --git a/crates/router/src/core/connector_onboarding/paypal.rs b/crates/router/src/core/connector_onboarding/paypal.rs index 4c1f16e91351..616fcbdc8cc3 100644 --- a/crates/router/src/core/connector_onboarding/paypal.rs +++ b/crates/router/src/core/connector_onboarding/paypal.rs @@ -1,6 +1,6 @@ use api_models::{admin::MerchantConnectorUpdate, connector_onboarding as api}; use common_utils::ext_traits::Encode; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::{ExposeInterface, PeekInterface, Secret}; use crate::{ @@ -55,7 +55,6 @@ pub async fn get_action_url_from_paypal( let parsed_response: types::paypal::PartnerReferralResponse = referral_response .json() .await - .into_report() .change_context(ApiErrorResponse::InternalServerError) .attach_printable("Failed to parse paypal response")?; @@ -106,7 +105,6 @@ pub async fn sync_merchant_onboarding_status( let parsed_response: types::paypal::SellerStatusDetailsResponse = merchant_details_response .json() .await - .into_report() .change_context(ApiErrorResponse::InternalServerError) .attach_printable("Failed to parse paypal merchant details response")?; @@ -133,7 +131,6 @@ async fn find_paypal_merchant_by_tracking_id( seller_status_response .json() .await - .into_report() .change_context(ApiErrorResponse::InternalServerError) .attach_printable("Failed to parse paypal onboarding status response")?, )); diff --git a/crates/router/src/core/customers.rs b/crates/router/src/core/customers.rs index 02127efe6deb..732596d5c1c9 100644 --- a/crates/router/src/core/customers.rs +++ b/crates/router/src/core/customers.rs @@ -2,7 +2,7 @@ use common_utils::{ crypto::{Encryptable, GcmAes256}, errors::ReportSwitchExt, }; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use masking::ExposeInterface; use router_env::{instrument, tracing}; @@ -55,7 +55,9 @@ pub async fn create_customer( Ok(()) } } - Ok(_) => Err(errors::CustomersErrorResponse::CustomerAlreadyExists).into_report(), + Ok(_) => Err(report!( + errors::CustomersErrorResponse::CustomerAlreadyExists + )), }?; let key = key_store.key.get_inner().peek(); diff --git a/crates/router/src/core/disputes.rs b/crates/router/src/core/disputes.rs index f53939a8f9dd..4928dc949dc9 100644 --- a/crates/router/src/core/disputes.rs +++ b/crates/router/src/core/disputes.rs @@ -1,6 +1,6 @@ use api_models::{disputes as dispute_models, files as files_api_models}; use common_utils::ext_traits::{Encode, ValueExt}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use router_env::{instrument, tracing}; pub mod transformers; @@ -368,7 +368,6 @@ pub async fn attach_evidence( let file_id = match &create_file_response { services::ApplicationResponse::Json(res) => res.file_id.clone(), _ => Err(errors::ApiErrorResponse::InternalServerError) - .into_report() .attach_printable("Unexpected response received from files create core")?, }; let dispute_evidence: api::DisputeEvidence = dispute diff --git a/crates/router/src/core/files.rs b/crates/router/src/core/files.rs index d3f490a0a6ce..e2ce5b42c3fc 100644 --- a/crates/router/src/core/files.rs +++ b/crates/router/src/core/files.rs @@ -1,7 +1,7 @@ pub mod helpers; use api_models::files; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use super::errors::{self, RouterResponse}; use crate::{ @@ -118,13 +118,11 @@ pub async fn files_retrieve_core( let content_type = file_metadata_object .file_type .parse::() - .into_report() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Failed to parse file content type")?; Ok(ApplicationResponse::FileData(( received_data .ok_or(errors::ApiErrorResponse::FileNotAvailable) - .into_report() .attach_printable("File data not found")?, content_type, ))) diff --git a/crates/router/src/core/files/helpers.rs b/crates/router/src/core/files/helpers.rs index 0a509b238afa..0c6a88d8270c 100644 --- a/crates/router/src/core/files/helpers.rs +++ b/crates/router/src/core/files/helpers.rs @@ -1,6 +1,6 @@ use actix_multipart::Field; use common_utils::errors::CustomResult; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use futures::TryStreamExt; use crate::{ @@ -97,7 +97,6 @@ pub async fn delete_file_using_file_id( ) { (Some(provider), Some(provider_file_id), true) => (provider, provider_file_id), _ => Err(errors::ApiErrorResponse::FileNotAvailable) - .into_report() .attach_printable("File not available")?, }; match provider { @@ -123,7 +122,6 @@ pub async fn retrieve_file_from_connector( file_metadata .file_upload_provider .ok_or(errors::ApiErrorResponse::InternalServerError) - .into_report() .attach_printable("Missing file upload provider")?, )? .to_string(); @@ -194,7 +192,6 @@ pub async fn retrieve_file_and_provider_file_id_from_file_id( ) { (Some(provider), Some(provider_file_id), true) => (provider, provider_file_id), _ => Err(errors::ApiErrorResponse::FileNotAvailable) - .into_report() .attach_printable("File not available")?, }; match provider { diff --git a/crates/router/src/core/fraud_check/operation/fraud_check_post.rs b/crates/router/src/core/fraud_check/operation/fraud_check_post.rs index 95349e44755f..a6cd0976129a 100644 --- a/crates/router/src/core/fraud_check/operation/fraud_check_post.rs +++ b/crates/router/src/core/fraud_check/operation/fraud_check_post.rs @@ -398,12 +398,10 @@ impl UpdateTracker for FraudCheckPost { last_step: frm_data.fraud_check.last_step, }; Some(fraud_check_update) - } }, }, - FrmResponse::Checkout(_) | FrmResponse::Transaction(_) => { Some(FraudCheckUpdate::ErrorUpdate { status: FraudCheckStatus::TransactionFailure, diff --git a/crates/router/src/core/gsm.rs b/crates/router/src/core/gsm.rs index 611a35d63632..668c1773e2cd 100644 --- a/crates/router/src/core/gsm.rs +++ b/crates/router/src/core/gsm.rs @@ -1,6 +1,6 @@ use api_models::gsm as gsm_api_types; use diesel_models::gsm as storage; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use router_env::{instrument, tracing}; use crate::{ @@ -132,7 +132,6 @@ pub async fn delete_gsm_rule( )) } else { Err(errors::ApiErrorResponse::InternalServerError) - .into_report() .attach_printable("Failed while Deleting Gsm rule, got response as false") } } diff --git a/crates/router/src/core/mandate.rs b/crates/router/src/core/mandate.rs index 6f022c9fca96..0ad13f0703c7 100644 --- a/crates/router/src/core/mandate.rs +++ b/crates/router/src/core/mandate.rs @@ -3,7 +3,7 @@ pub mod utils; use api_models::payments; use common_utils::ext_traits::Encode; use diesel_models::{enums as storage_enums, Mandate}; -use error_stack::{report, IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use futures::future; use router_env::{instrument, logger, tracing}; @@ -59,7 +59,7 @@ pub async fn revoke_mandate( .find_mandate_by_merchant_id_mandate_id(&merchant_account.merchant_id, &req.mandate_id) .await .to_not_found_response(errors::ApiErrorResponse::MandateNotFound)?; - let mandate_revoke_status = match mandate.mandate_status { + match mandate.mandate_status { common_enums::MandateStatus::Active | common_enums::MandateStatus::Inactive | common_enums::MandateStatus::Pending => { @@ -136,18 +136,17 @@ pub async fn revoke_mandate( connector: mandate.connector, status_code: err.status_code, reason: err.reason, - }) - .into_report(), + } + .into()), } } common_enums::MandateStatus::Revoked => { Err(errors::ApiErrorResponse::MandateValidationFailed { reason: "Mandate has already been revoked".to_string(), - }) - .into_report() + } + .into()) } - }; - mandate_revoke_status + } } #[instrument(skip(db))] @@ -261,7 +260,6 @@ where mandate_reference, .. }) => mandate_reference, Ok(_) => Err(errors::ApiErrorResponse::InternalServerError) - .into_report() .attach_printable("Unexpected response received")?, Err(_) => return Ok(resp), }; diff --git a/crates/router/src/core/payment_link.rs b/crates/router/src/core/payment_link.rs index 096d5c88743a..722aad26c0db 100644 --- a/crates/router/src/core/payment_link.rs +++ b/crates/router/src/core/payment_link.rs @@ -6,7 +6,7 @@ use common_utils::{ }, ext_traits::{OptionExt, ValueExt}, }; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use futures::future; use masking::{PeekInterface, Secret}; use time::PrimitiveDateTime; @@ -93,7 +93,6 @@ pub async fn intiate_payment_link_flow( .profile_id .or(payment_intent.profile_id) .ok_or(errors::ApiErrorResponse::InternalServerError) - .into_report() .attach_printable("Profile id missing in payment link and payment intent")?; let business_profile = db @@ -120,7 +119,6 @@ pub async fn intiate_payment_link_flow( )?; let amount = currency .to_currency_base_unit(payment_intent.amount) - .into_report() .change_context(errors::ApiErrorResponse::CurrencyConversionFailed)?; let order_details = validate_order_details(payment_intent.order_details.clone(), currency)?; @@ -236,7 +234,6 @@ The get_js_script function is used to inject dynamic value to payment_link sdk, fn get_js_script(payment_details: api_models::payments::PaymentLinkData) -> RouterResult { let payment_details_str = serde_json::to_string(&payment_details) - .into_report() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Failed to serialize PaymentLinkData")?; Ok(format!("window.__PAYMENT_DETAILS = {payment_details_str};")) @@ -336,10 +333,10 @@ fn validate_order_details( } else { order_details_amount_string.product_img_link = order.product_img_link.clone() }; - order_details_amount_string.amount = currency - .to_currency_base_unit(order.amount) - .into_report() - .change_context(errors::ApiErrorResponse::CurrencyConversionFailed)?; + order_details_amount_string.amount = + currency + .to_currency_base_unit(order.amount) + .change_context(errors::ApiErrorResponse::CurrencyConversionFailed)?; order_details_amount_string.product_name = capitalize_first_char(&order.product_name.clone()); order_details_amount_string.quantity = order.quantity; @@ -356,7 +353,6 @@ pub fn extract_payment_link_config( pl_config: serde_json::Value, ) -> Result> { serde_json::from_value::(pl_config.clone()) - .into_report() .change_context(errors::ApiErrorResponse::InvalidDataValue { field_name: "payment_link_config", }) @@ -522,7 +518,6 @@ pub async fn get_payment_link_status( let amount = currency .to_currency_base_unit(payment_attempt.net_amount) - .into_report() .change_context(errors::ApiErrorResponse::CurrencyConversionFailed)?; // converting first letter of merchant name to upperCase @@ -533,7 +528,6 @@ pub async fn get_payment_link_status( .profile_id .or(payment_intent.profile_id) .ok_or(errors::ApiErrorResponse::InternalServerError) - .into_report() .attach_printable("Profile id missing in payment link and payment intent")?; let business_profile = db diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rs index 2a6c29ce8036..59215da32f12 100644 --- a/crates/router/src/core/payment_methods/cards.rs +++ b/crates/router/src/core/payment_methods/cards.rs @@ -28,7 +28,7 @@ use diesel_models::{ payment_method, }; use domain::CustomerUpdate; -use error_stack::{report, IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use masking::Secret; use router_env::{instrument, tracing}; use strum::IntoEnumIterator; @@ -510,7 +510,6 @@ pub async fn add_bank_to_locker( logger::error!("Error while encoding payout method data: {}", err); errors::VaultError::SavePaymentMethodFailed }) - .into_report() .change_context(errors::VaultError::SavePaymentMethodFailed) .attach_printable("Unable to encode payout method data") .ok() @@ -716,7 +715,6 @@ pub async fn decode_and_decrypt_locker_data( let key = key_store.key.get_inner().peek(); // Decode let decoded_bytes = hex::decode(&enc_card_data) - .into_report() .change_context(errors::VaultError::ResponseDeserializationFailed) .attach_printable("Failed to decode hex string into bytes")?; // Decrypt @@ -1025,10 +1023,7 @@ pub async fn mock_get_card<'a>( card_fingerprint: locker_mock_up.card_fingerprint.into(), card_global_fingerprint: locker_mock_up.card_global_fingerprint.into(), merchant_id: Some(locker_mock_up.merchant_id), - card_number: locker_mock_up - .card_number - .try_into() - .into_report() + card_number: cards::CardNumber::try_from(locker_mock_up.card_number) .change_context(errors::VaultError::ResponseDeserializationFailed) .attach_printable("Invalid card number format from the mock locker") .map(Some)?, @@ -1492,10 +1487,8 @@ pub async fn list_payment_methods( .connector .connector_name .to_string() - .parse() - .into_report() - .change_context(errors::ApiErrorResponse::InternalServerError) - .attach_printable("")?, + .parse::() + .change_context(errors::ApiErrorResponse::InternalServerError)?, #[cfg(feature = "connector_choice_mca_id")] merchant_connector_id: choice.connector.merchant_connector_id, #[cfg(not(feature = "connector_choice_mca_id"))] @@ -1540,7 +1533,6 @@ pub async fn list_payment_methods( .as_ref() .map(|config| { serde_json::from_value::(config.clone()) - .into_report() .change_context(errors::StorageError::DeserializationFailed) .attach_printable("Failed to deserialize Payment Method Auth config") }) @@ -1651,7 +1643,6 @@ pub async fn list_payment_methods( let connector = element.connector.clone(); let connector_variant = api_enums::Connector::from_str(connector.as_str()) - .into_report() .change_context(errors::ConnectorError::InvalidConnectorName) .change_context(errors::ApiErrorResponse::InvalidDataValue { field_name: "connector", @@ -2238,7 +2229,6 @@ pub async fn filter_payment_methods( ); let connector_variant = api_enums::Connector::from_str(connector.as_str()) - .into_report() .change_context(errors::ConnectorError::InvalidConnectorName) .change_context(errors::ApiErrorResponse::InvalidDataValue { field_name: "connector", @@ -3161,7 +3151,7 @@ async fn get_masked_bank_details( mask: bank_details.mask, })), }, - None => Err(errors::ApiErrorResponse::InternalServerError.into()) + None => Err(report!(errors::ApiErrorResponse::InternalServerError)) .attach_printable("Unable to fetch payment method data"), } } @@ -3191,8 +3181,8 @@ async fn get_bank_account_connector_details( Some(pmd) => match pmd { PaymentMethodsData::Card(_) => Err(errors::ApiErrorResponse::UnprocessableEntity { message: "Card is not a valid entity".to_string(), - }) - .into_report(), + } + .into()), PaymentMethodsData::BankDetails(bank_details) => { let connector_details = bank_details .connector_details @@ -3240,7 +3230,6 @@ pub async fn set_default_payment_method( Err(errors::ApiErrorResponse::PreconditionFailed { message: "The payment_method_id is not valid".to_string(), }) - .into_report() }, )?; @@ -3250,7 +3239,6 @@ pub async fn set_default_payment_method( Err(errors::ApiErrorResponse::PreconditionFailed { message: "Payment Method is already set as default".to_string(), }) - .into_report() }, )?; diff --git a/crates/router/src/core/payment_methods/surcharge_decision_configs.rs b/crates/router/src/core/payment_methods/surcharge_decision_configs.rs index 874e1bde32f4..e89fb22e8790 100644 --- a/crates/router/src/core/payment_methods/surcharge_decision_configs.rs +++ b/crates/router/src/core/payment_methods/surcharge_decision_configs.rs @@ -6,7 +6,7 @@ use api_models::{ surcharge_decision_configs::{self, SurchargeDecisionConfigs, SurchargeDecisionManagerRecord}, }; use common_utils::{ext_traits::StringExt, static_cache::StaticCache, types as common_utils_types}; -use error_stack::{self, IntoReport, ResultExt}; +use error_stack::{self, ResultExt}; use euclid::{ backend, backend::{inputs as dsl_inputs, EuclidBackend}, @@ -42,7 +42,6 @@ impl TryFrom for VirInterpreterBackendCacheWrapp fn try_from(value: SurchargeDecisionManagerRecord) -> Result { let cached_alogorith = backend::VirInterpreterBackend::with_program(value.algorithm) - .into_report() .change_context(ConfigError::DslBackendInitError) .attach_printable("Error initializing DSL interpreter backend")?; let merchant_surcharge_configs = value.merchant_surcharge_configs; @@ -127,7 +126,6 @@ pub async fn perform_surcharge_decision_management_for_payment_method_list( .await?; let cached_algo = CONF_CACHE .retrieve(&key) - .into_report() .change_context(ConfigError::CacheMiss) .attach_printable( "Unable to retrieve cached routing algorithm even after refresh", @@ -182,7 +180,6 @@ pub async fn perform_surcharge_decision_management_for_payment_method_list( &surcharge_details, payment_attempt, )) - .into_report() .change_context(ConfigError::DslExecutionError) .attach_printable("Error while constructing Surcharge response type") }) @@ -208,7 +205,6 @@ pub async fn perform_surcharge_decision_management_for_payment_method_list( &surcharge_details, payment_attempt, )) - .into_report() .change_context(ConfigError::DslExecutionError) .attach_printable("Error while constructing Surcharge response type") }) @@ -247,7 +243,6 @@ where .await?; let cached_algo = CONF_CACHE .retrieve(&key) - .into_report() .change_context(ConfigError::CacheMiss) .attach_printable( "Unable to retrieve cached routing algorithm even after refresh", @@ -306,7 +301,6 @@ pub async fn perform_surcharge_decision_management_for_saved_cards( .await?; let cached_algo = CONF_CACHE .retrieve(&key) - .into_report() .change_context(ConfigError::CacheMiss) .attach_printable( "Unable to retrieve cached routing algorithm even after refresh", @@ -345,7 +339,6 @@ pub async fn perform_surcharge_decision_management_for_saved_cards( customer_payment_method.surcharge_details = surcharge_details .map(|surcharge_details| { SurchargeDetailsResponse::foreign_try_from((&surcharge_details, payment_attempt)) - .into_report() .change_context(ConfigError::DslParsingError) }) .transpose()?; @@ -402,12 +395,10 @@ pub async fn ensure_algorithm_cached( let key = format!("surcharge_dsl_{merchant_id}"); let present = CONF_CACHE .present(&key) - .into_report() .change_context(ConfigError::DslCachePoisoned) .attach_printable("Error checking presence of DSL")?; let expired = CONF_CACHE .expired(&key, timestamp) - .into_report() .change_context(ConfigError::DslCachePoisoned) .attach_printable("Error checking presence of DSL")?; @@ -437,7 +428,6 @@ pub async fn refresh_surcharge_algorithm_cache( let value_to_cache = VirInterpreterBackendCacheWrapper::try_from(record)?; CONF_CACHE .save(key, value_to_cache, timestamp) - .into_report() .change_context(ConfigError::DslCachePoisoned) .attach_printable("Error saving DSL to cache")?; Ok(()) @@ -450,7 +440,6 @@ pub fn execute_dsl_and_get_conditional_config( let routing_output = interpreter .execute(backend_input) .map(|out| out.connector_selection) - .into_report() .change_context(ConfigError::DslExecutionError)?; Ok(routing_output) } diff --git a/crates/router/src/core/payment_methods/vault.rs b/crates/router/src/core/payment_methods/vault.rs index af9f94a0bdf1..aeb1ea102be9 100644 --- a/crates/router/src/core/payment_methods/vault.rs +++ b/crates/router/src/core/payment_methods/vault.rs @@ -3,7 +3,7 @@ use common_utils::{ ext_traits::{BytesExt, Encode}, generate_id_with_default_len, }; -use error_stack::{report, IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use masking::PeekInterface; use router_env::{instrument, tracing}; use scheduler::{types::process_data, utils as process_tracker_utils}; @@ -90,10 +90,7 @@ impl Vaultable for api::Card { .attach_printable("Could not deserialize into card value2")?; let card = Self { - card_number: value1 - .card_number - .try_into() - .into_report() + card_number: cards::CardNumber::try_from(value1.card_number) .change_context(errors::VaultError::ResponseDeserializationFailed) .attach_printable("Invalid card number format from the mock locker")?, card_exp_month: value1.exp_month.into(), @@ -276,7 +273,6 @@ impl Vaultable for api::PaymentMethodData { VaultPaymentMethod::BankRedirect(bank_redirect.get_value1(customer_id)?) } _ => Err(errors::VaultError::PaymentMethodNotSupported) - .into_report() .attach_printable("Payment method not supported")?, }; @@ -297,7 +293,6 @@ impl Vaultable for api::PaymentMethodData { VaultPaymentMethod::BankRedirect(bank_redirect.get_value2(customer_id)?) } _ => Err(errors::VaultError::PaymentMethodNotSupported) - .into_report() .attach_printable("Payment method not supported")?, }; @@ -348,7 +343,6 @@ impl Vaultable for api::PaymentMethodData { } _ => Err(errors::VaultError::PaymentMethodNotSupported) - .into_report() .attach_printable("Payment method not supported"), } } @@ -678,7 +672,6 @@ impl Vaultable for api::PayoutMethodData { Ok((Self::Wallet(wallet), supp_data)) } _ => Err(errors::VaultError::PayoutMethodNotSupported) - .into_report() .attach_printable("Payout method not supported"), } } @@ -963,16 +956,13 @@ pub async fn delete_tokenized_data(state: &routes::AppState, lookup_key: &str) - Ok(redis_interface::DelReply::KeyDeleted) => Ok(()), Ok(redis_interface::DelReply::KeyNotDeleted) => { Err(errors::ApiErrorResponse::InternalServerError) - .into_report() .attach_printable("Token invalid or expired") } Err(err) => { metrics::TEMP_LOCKER_FAILURES.add(&metrics::CONTEXT, 1, &[]); - Err(errors::ApiErrorResponse::InternalServerError) - .into_report() - .attach_printable_lazy(|| { - format!("Failed to delete from redis locker: {err:?}") - }) + Err(errors::ApiErrorResponse::InternalServerError).attach_printable_lazy(|| { + format!("Failed to delete from redis locker: {err:?}") + }) } } }; @@ -1009,7 +999,6 @@ pub async fn add_delete_tokenized_data_task( let schedule_time = get_delete_tokenize_schedule_time(db, &pm, 0) .await .ok_or(errors::ApiErrorResponse::InternalServerError) - .into_report() .attach_printable("Failed to obtain initial process tracker schedule time")?; let process_tracker_entry = storage::ProcessTrackerNew::new( @@ -1041,7 +1030,6 @@ pub async fn start_tokenize_data_workflow( let delete_tokenize_data = serde_json::from_value::( tokenize_tracker.tracking_data.clone(), ) - .into_report() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable_lazy(|| { format!( diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs index e11a77496afd..b996677f7e67 100644 --- a/crates/router/src/core/payments.rs +++ b/crates/router/src/core/payments.rs @@ -21,7 +21,7 @@ use api_models::{ use common_utils::{ext_traits::AsyncExt, pii, types::Surcharge}; use data_models::mandates::{CustomerAcceptance, MandateData}; use diesel_models::{ephemeral_key, fraud_check::FraudCheck}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use futures::future::join_all; use helpers::ApplePayData; use masking::Secret; @@ -254,7 +254,6 @@ where 0, ) .await - .into_report() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Failed while getting process schedule time")? } else { @@ -310,7 +309,6 @@ where 0, ) .await - .into_report() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Failed while getting process schedule time")? } else { @@ -420,7 +418,6 @@ where .ok_or(errors::ApiErrorResponse::MissingRequiredField { field_name: "frm_configs", }) - .into_report() .attach_printable("Frm configs label not found")?, &customer, key_store.clone(), @@ -615,7 +612,6 @@ pub fn get_connector_data( connectors .next() .ok_or(errors::ApiErrorResponse::InternalServerError) - .into_report() .attach_printable("Connector not found in connectors iterator") } @@ -838,7 +834,6 @@ pub trait PaymentRedirectFlow: Sync { services::ApplicationResponse::Json(response) => Ok(response), services::ApplicationResponse::JsonWithHeaders((response, _)) => Ok(response), _ => Err(errors::ApiErrorResponse::InternalServerError) - .into_report() .attach_printable("Failed to get the response in json"), }?; @@ -933,7 +928,7 @@ impl PaymentRedirectFlow for PaymentRedirectCom api_models::payments::NextActionData::ThreeDsInvoke{..} => None, }) .ok_or(errors::ApiErrorResponse::InternalServerError) - .into_report() + .attach_printable( "did not receive redirect to url when status is requires customer action", )?; @@ -954,7 +949,7 @@ impl PaymentRedirectFlow for PaymentRedirectCom payments_response, connector, ), - _ => Err(errors::ApiErrorResponse::InternalServerError).into_report().attach_printable_lazy(|| format!("Could not proceed with payment as payment status {} cannot be handled during redirection",payments_response.status))? + _ => Err(errors::ApiErrorResponse::InternalServerError).attach_printable_lazy(|| format!("Could not proceed with payment as payment status {} cannot be handled during redirection",payments_response.status))? }?; Ok(services::ApplicationResponse::JsonForRedirection( redirection_response, @@ -2576,8 +2571,7 @@ pub async fn add_process_sync_task( tracking_data, schedule_time, ) - .map_err(errors::StorageError::from) - .into_report()?; + .map_err(errors::StorageError::from)?; db.insert_process(process_tracker_entry).await?; Ok(()) @@ -3065,7 +3059,6 @@ pub fn decide_multiplex_connector_for_normal_or_recurring_payment( let first_choice = connectors .first() .ok_or(errors::ApiErrorResponse::IncorrectPaymentMethodConfiguration) - .into_report() .attach_printable("no eligible connector found for payment")? .clone(); @@ -3274,7 +3267,6 @@ where let first_connector_choice = connectors .first() .ok_or(errors::ApiErrorResponse::IncorrectPaymentMethodConfiguration) - .into_report() .attach_printable("Empty connector list returned")? .clone(); @@ -3409,7 +3401,6 @@ pub async fn payment_external_authentication( .authentication_connector .clone() .ok_or(errors::ApiErrorResponse::InternalServerError) - .into_report() .attach_printable("authentication_connector not found in payment_attempt")?; let merchant_connector_account = helpers::get_merchant_connector_account( &state, @@ -3428,7 +3419,6 @@ pub async fn payment_external_authentication( .authentication_id .clone() .ok_or(errors::ApiErrorResponse::InternalServerError) - .into_report() .attach_printable("missing authentication_id in payment_attempt")?, ) .await @@ -3442,7 +3432,6 @@ pub async fn payment_external_authentication( ) .await? .ok_or(errors::ApiErrorResponse::InternalServerError) - .into_report() .attach_printable("missing payment_method_details")?; let browser_info: Option = payment_attempt .browser_info @@ -3456,7 +3445,6 @@ pub async fn payment_external_authentication( .connector .as_ref() .ok_or(errors::ApiErrorResponse::InternalServerError) - .into_report() .attach_printable("missing connector in payment_attempt")?; let return_url = Some(helpers::create_authorize_url( &state.conf.server.base_url, diff --git a/crates/router/src/core/payments/access_token.rs b/crates/router/src/core/payments/access_token.rs index b95c294466d3..47f6b7e2ae4d 100644 --- a/crates/router/src/core/payments/access_token.rs +++ b/crates/router/src/core/payments/access_token.rs @@ -1,7 +1,7 @@ use std::fmt::Debug; use common_utils::ext_traits::AsyncExt; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use crate::{ consts, @@ -77,7 +77,6 @@ pub async fn add_access_token< let refresh_token_request_data = types::AccessTokenRequestData::try_from( router_data.connector_auth_type.clone(), ) - .into_report() .attach_printable( "Could not create access token request, invalid connector account credentials", )?; diff --git a/crates/router/src/core/payments/conditional_configs.rs b/crates/router/src/core/payments/conditional_configs.rs index bf1f43e2b0f9..5dc78d42e5ea 100644 --- a/crates/router/src/core/payments/conditional_configs.rs +++ b/crates/router/src/core/payments/conditional_configs.rs @@ -5,7 +5,7 @@ use api_models::{ routing, }; use common_utils::{ext_traits::StringExt, static_cache::StaticCache}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use euclid::backend::{self, inputs as dsl_inputs, EuclidBackend}; use router_env::{instrument, tracing}; @@ -41,7 +41,6 @@ pub async fn perform_decision_management( .await?; let cached_algo = CONF_CACHE .retrieve(&key) - .into_report() .change_context(ConfigError::CacheMiss) .attach_printable("Unable to retrieve cached routing algorithm even after refresh")?; let backend_input = @@ -60,12 +59,10 @@ pub async fn ensure_algorithm_cached( let key = format!("dsl_{merchant_id}"); let present = CONF_CACHE .present(&key) - .into_report() .change_context(ConfigError::DslCachePoisoned) .attach_printable("Error checking presece of DSL")?; let expired = CONF_CACHE .expired(&key, timestamp) - .into_report() .change_context(ConfigError::DslCachePoisoned) .attach_printable("Error checking presence of DSL")?; if !present || expired { @@ -94,12 +91,10 @@ pub async fn refresh_routing_cache( .attach_printable("Error parsing routing algorithm from configs")?; let interpreter: backend::VirInterpreterBackend = backend::VirInterpreterBackend::with_program(rec.program) - .into_report() .change_context(ConfigError::DslBackendInitError) .attach_printable("Error initializing DSL interpreter backend")?; CONF_CACHE .save(key, interpreter, timestamp) - .into_report() .change_context(ConfigError::DslCachePoisoned) .attach_printable("Error saving DSL to cache")?; Ok(()) @@ -112,7 +107,6 @@ pub async fn execute_dsl_and_get_conditional_config( let routing_output = interpreter .execute(backend_input) .map(|out| out.connector_selection) - .into_report() .change_context(ConfigError::DslExecutionError)?; Ok(routing_output) } diff --git a/crates/router/src/core/payments/flows/session_flow.rs b/crates/router/src/core/payments/flows/session_flow.rs index 4321c0c09131..349c76cd23a8 100644 --- a/crates/router/src/core/payments/flows/session_flow.rs +++ b/crates/router/src/core/payments/flows/session_flow.rs @@ -1,7 +1,7 @@ use api_models::payments as payment_types; use async_trait::async_trait; use common_utils::{ext_traits::ByteSliceExt, request::RequestContent}; -use error_stack::{IntoReport, Report, ResultExt}; +use error_stack::{Report, ResultExt}; use masking::ExposeInterface; use super::{ConstructFlowSpecificData, Feature}; @@ -337,7 +337,6 @@ fn get_apple_pay_amount_info( amount: session_data .currency .to_currency_base_unit(session_data.amount) - .into_report() .change_context(errors::ApiErrorResponse::PreconditionFailed { message: "Failed to convert currency to base unit".to_string(), })?, @@ -445,7 +444,6 @@ fn create_gpay_session_token( .request .currency .to_currency_base_unit(router_data.request.amount) - .into_report() .attach_printable( "Cannot convert given amount to base currency denomination".to_string(), ) diff --git a/crates/router/src/core/payments/flows/setup_mandate_flow.rs b/crates/router/src/core/payments/flows/setup_mandate_flow.rs index 189a8a0a3eda..0d663df29808 100644 --- a/crates/router/src/core/payments/flows/setup_mandate_flow.rs +++ b/crates/router/src/core/payments/flows/setup_mandate_flow.rs @@ -1,6 +1,6 @@ use api_models::enums::{PaymentMethod, PaymentMethodType}; use async_trait::async_trait; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use super::{ConstructFlowSpecificData, Feature}; use crate::{ @@ -397,7 +397,6 @@ impl types::SetupMandateRouterData { .await } Ok(_) => Err(errors::ApiErrorResponse::InternalServerError) - .into_report() .attach_printable("Unexpected response received")?, Err(_) => Ok(resp), } @@ -407,8 +406,8 @@ impl types::SetupMandateRouterData { "Update Mandate flow not implemented for the connector {:?}", connector.connector_name ), - }) - .into_report() + } + .into()) } } } diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs index e9cefbf8aed5..0f80b6a52ea2 100644 --- a/crates/router/src/core/payments/helpers.rs +++ b/crates/router/src/core/payments/helpers.rs @@ -15,7 +15,7 @@ use data_models::{ }; use diesel_models::enums; // TODO : Evaluate all the helper functions () -use error_stack::{report, IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use josekit::jwe; use masking::{ExposeInterface, PeekInterface}; use openssl::{ @@ -69,24 +69,19 @@ pub fn create_identity_from_certificate_and_key( ) -> Result> { let decoded_certificate = BASE64_ENGINE .decode(encoded_certificate) - .into_report() .change_context(errors::ApiClientError::CertificateDecodeFailed)?; let decoded_certificate_key = BASE64_ENGINE .decode(encoded_certificate_key) - .into_report() .change_context(errors::ApiClientError::CertificateDecodeFailed)?; let certificate = String::from_utf8(decoded_certificate) - .into_report() .change_context(errors::ApiClientError::CertificateDecodeFailed)?; let certificate_key = String::from_utf8(decoded_certificate_key) - .into_report() .change_context(errors::ApiClientError::CertificateDecodeFailed)?; reqwest::Identity::from_pkcs8_pem(certificate.as_bytes(), certificate_key.as_bytes()) - .into_report() .change_context(errors::ApiClientError::CertificateDecodeFailed) } @@ -122,74 +117,76 @@ pub async fn create_or_update_address_for_payment_by_request( Some(id) => match req_address { Some(address) => { let address_update = async { - Ok(storage::AddressUpdate::Update { - city: address - .address - .as_ref() - .and_then(|value| value.city.clone()), - country: address.address.as_ref().and_then(|value| value.country), - line1: address - .address - .as_ref() - .and_then(|value| value.line1.clone()) - .async_lift(|inner| types::encrypt_optional(inner, key)) - .await?, - line2: address - .address - .as_ref() - .and_then(|value| value.line2.clone()) - .async_lift(|inner| types::encrypt_optional(inner, key)) - .await?, - line3: address - .address - .as_ref() - .and_then(|value| value.line3.clone()) - .async_lift(|inner| types::encrypt_optional(inner, key)) - .await?, - state: address - .address - .as_ref() - .and_then(|value| value.state.clone()) - .async_lift(|inner| types::encrypt_optional(inner, key)) - .await?, - zip: address - .address - .as_ref() - .and_then(|value| value.zip.clone()) - .async_lift(|inner| types::encrypt_optional(inner, key)) - .await?, - first_name: address - .address - .as_ref() - .and_then(|value| value.first_name.clone()) - .async_lift(|inner| types::encrypt_optional(inner, key)) - .await?, - last_name: address - .address - .as_ref() - .and_then(|value| value.last_name.clone()) - .async_lift(|inner| types::encrypt_optional(inner, key)) - .await?, - phone_number: address - .phone - .as_ref() - .and_then(|value| value.number.clone()) - .async_lift(|inner| types::encrypt_optional(inner, key)) - .await?, - country_code: address - .phone - .as_ref() - .and_then(|value| value.country_code.clone()), - updated_by: storage_scheme.to_string(), - email: address - .email - .as_ref() - .cloned() - .async_lift(|inner| { - types::encrypt_optional(inner.map(|inner| inner.expose()), key) - }) - .await?, - }) + Ok::<_, error_stack::Report>( + storage::AddressUpdate::Update { + city: address + .address + .as_ref() + .and_then(|value| value.city.clone()), + country: address.address.as_ref().and_then(|value| value.country), + line1: address + .address + .as_ref() + .and_then(|value| value.line1.clone()) + .async_lift(|inner| types::encrypt_optional(inner, key)) + .await?, + line2: address + .address + .as_ref() + .and_then(|value| value.line2.clone()) + .async_lift(|inner| types::encrypt_optional(inner, key)) + .await?, + line3: address + .address + .as_ref() + .and_then(|value| value.line3.clone()) + .async_lift(|inner| types::encrypt_optional(inner, key)) + .await?, + state: address + .address + .as_ref() + .and_then(|value| value.state.clone()) + .async_lift(|inner| types::encrypt_optional(inner, key)) + .await?, + zip: address + .address + .as_ref() + .and_then(|value| value.zip.clone()) + .async_lift(|inner| types::encrypt_optional(inner, key)) + .await?, + first_name: address + .address + .as_ref() + .and_then(|value| value.first_name.clone()) + .async_lift(|inner| types::encrypt_optional(inner, key)) + .await?, + last_name: address + .address + .as_ref() + .and_then(|value| value.last_name.clone()) + .async_lift(|inner| types::encrypt_optional(inner, key)) + .await?, + phone_number: address + .phone + .as_ref() + .and_then(|value| value.number.clone()) + .async_lift(|inner| types::encrypt_optional(inner, key)) + .await?, + country_code: address + .phone + .as_ref() + .and_then(|value| value.country_code.clone()), + updated_by: storage_scheme.to_string(), + email: address + .email + .as_ref() + .cloned() + .async_lift(|inner| { + types::encrypt_optional(inner.map(|inner| inner.expose()), key) + }) + .await?, + }, + ) } .await .change_context(errors::ApiErrorResponse::InternalServerError) @@ -769,11 +766,11 @@ pub fn validate_card_data( message: "Invalid card_cvc length".to_string() }))? } - let card_cvc = cvc.parse::().into_report().change_context( - errors::ApiErrorResponse::InvalidDataValue { - field_name: "card_cvc", - }, - )?; + let card_cvc = + cvc.parse::() + .change_context(errors::ApiErrorResponse::InvalidDataValue { + field_name: "card_cvc", + })?; ::cards::CardSecurityCode::try_from(card_cvc).change_context( errors::ApiErrorResponse::PreconditionFailed { message: "Invalid Card CVC".to_string(), @@ -785,7 +782,6 @@ pub fn validate_card_data( .peek() .to_string() .parse::() - .into_report() .change_context(errors::ApiErrorResponse::InvalidDataValue { field_name: "card_exp_month", })?; @@ -798,11 +794,12 @@ pub fn validate_card_data( if year_str.len() == 2 { year_str = format!("20{}", year_str); } - let exp_year = year_str.parse::().into_report().change_context( - errors::ApiErrorResponse::InvalidDataValue { - field_name: "card_exp_year", - }, - )?; + let exp_year = + year_str + .parse::() + .change_context(errors::ApiErrorResponse::InvalidDataValue { + field_name: "card_exp_year", + })?; let year = ::cards::CardExpirationYear::try_from(exp_year).change_context( errors::ApiErrorResponse::PreconditionFailed { message: "Invalid Expiry Year".to_string(), @@ -941,8 +938,8 @@ pub fn validate_customer_id_mandatory_cases( match (has_setup_future_usage, customer_id) { (true, None) => Err(errors::ApiErrorResponse::PreconditionFailed { message: "customer_id is mandatory when setup_future_usage is given".to_string(), - }) - .into_report(), + } + .into()), _ => Ok(()), } } @@ -1148,7 +1145,6 @@ where ); super::reset_process_sync_task(&*state.store, payment_attempt, stime) .await - .into_report() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Failed while updating task in process tracker") } @@ -1424,34 +1420,36 @@ pub async fn create_customer_if_not_exist<'a, F: Clone, R, Ctx>( { let key = key_store.key.get_inner().peek(); let customer_update = async { - Ok(Update { - name: request_customer_details - .name - .async_lift(|inner| types::encrypt_optional(inner, key)) - .await?, - email: request_customer_details - .email - .clone() - .async_lift(|inner| { - types::encrypt_optional( - inner.map(|inner| inner.expose()), - key, - ) - }) - .await?, - phone: Box::new( - request_customer_details - .phone - .clone() + Ok::<_, error_stack::Report>( + Update { + name: request_customer_details + .name .async_lift(|inner| types::encrypt_optional(inner, key)) .await?, - ), - phone_country_code: request_customer_details.phone_country_code, - description: None, - connector_customer: None, - metadata: None, - address_id: None, - }) + email: request_customer_details + .email + .clone() + .async_lift(|inner| { + types::encrypt_optional( + inner.map(|inner| inner.expose()), + key, + ) + }) + .await?, + phone: Box::new( + request_customer_details + .phone + .clone() + .async_lift(|inner| types::encrypt_optional(inner, key)) + .await?, + ), + phone_country_code: request_customer_details.phone_country_code, + description: None, + connector_customer: None, + metadata: None, + address_id: None, + }, + ) } .await .change_context(errors::StorageError::SerializationFailed) @@ -1471,35 +1469,42 @@ pub async fn create_customer_if_not_exist<'a, F: Clone, R, Ctx>( None => { let new_customer = async { let key = key_store.key.get_inner().peek(); - Ok(domain::Customer { - customer_id: customer_id.to_string(), - merchant_id: merchant_id.to_string(), - name: request_customer_details - .name - .async_lift(|inner| types::encrypt_optional(inner, key)) - .await?, - email: request_customer_details - .email - .clone() - .async_lift(|inner| { - types::encrypt_optional(inner.map(|inner| inner.expose()), key) - }) - .await?, - phone: request_customer_details - .phone - .clone() - .async_lift(|inner| types::encrypt_optional(inner, key)) - .await?, - phone_country_code: request_customer_details.phone_country_code.clone(), - description: None, - created_at: common_utils::date_time::now(), - id: None, - metadata: None, - modified_at: common_utils::date_time::now(), - connector_customer: None, - address_id: None, - default_payment_method_id: None, - }) + Ok::<_, error_stack::Report>( + domain::Customer { + customer_id: customer_id.to_string(), + merchant_id: merchant_id.to_string(), + name: request_customer_details + .name + .async_lift(|inner| types::encrypt_optional(inner, key)) + .await?, + email: request_customer_details + .email + .clone() + .async_lift(|inner| { + types::encrypt_optional( + inner.map(|inner| inner.expose()), + key, + ) + }) + .await?, + phone: request_customer_details + .phone + .clone() + .async_lift(|inner| types::encrypt_optional(inner, key)) + .await?, + phone_country_code: request_customer_details + .phone_country_code + .clone(), + description: None, + created_at: common_utils::date_time::now(), + id: None, + metadata: None, + modified_at: common_utils::date_time::now(), + connector_customer: None, + address_id: None, + default_payment_method_id: None, + }, + ) } .await .change_context(errors::StorageError::SerializationFailed) @@ -1633,7 +1638,6 @@ pub async fn retrieve_payment_method_with_temporary_token( } Some(_) => Err(errors::ApiErrorResponse::InternalServerError) - .into_report() .attach_printable("Payment method received from locker is unsupported by locker")?, None => None, @@ -2326,7 +2330,6 @@ pub fn make_merchant_url_with_response( let payment_client_secret = client_secret .ok_or(errors::ApiErrorResponse::InternalServerError) - .into_report() .attach_printable("Expected client secret to be `Some`")?; let merchant_url_with_response = if business_profile.redirect_to_merchant_with_http_post { @@ -2344,7 +2347,6 @@ pub fn make_merchant_url_with_response( ), ], ) - .into_report() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Unable to parse the url with param")? } else { @@ -2364,7 +2366,6 @@ pub fn make_merchant_url_with_response( ), ], ) - .into_report() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Unable to parse the url with param")? }; @@ -2426,7 +2427,6 @@ pub fn make_url_with_signature( business_profile: &diesel_models::business_profile::BusinessProfile, ) -> RouterResult { let mut url = url::Url::parse(redirect_url) - .into_report() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Unable to parse the url")?; @@ -2754,8 +2754,7 @@ pub fn get_business_details( pub(crate) fn get_payment_id_from_client_secret(cs: &str) -> RouterResult { let (payment_id, _) = cs .rsplit_once("_secret_") - .ok_or(errors::ApiErrorResponse::ClientSecretInvalid) - .into_report()?; + .ok_or(errors::ApiErrorResponse::ClientSecretInvalid)?; Ok(payment_id.to_string()) } @@ -3203,7 +3202,6 @@ pub fn get_attempt_type( )], ); Err(errors::ApiErrorResponse::InternalServerError) - .into_report() .attach_printable("Payment Attempt unexpected state") } @@ -3700,7 +3698,6 @@ impl ApplePayData { let symmetric_key = self.symmetric_key(&merchant_id, &shared_secret)?; let decrypted = self.decrypt_ciphertext(&symmetric_key)?; let parsed_decrypted: serde_json::Value = serde_json::from_str(&decrypted) - .into_report() .change_context(errors::ApplePayDecryptionError::DecryptionFailed)?; Ok(parsed_decrypted) } @@ -3719,12 +3716,10 @@ impl ApplePayData { let base64_decode_cert_data = BASE64_ENGINE .decode(cert_data) - .into_report() .change_context(errors::ApplePayDecryptionError::Base64DecodingFailed)?; // Parsing the certificate using x509-parser let (_, certificate) = parse_x509_certificate(&base64_decode_cert_data) - .into_report() .change_context(errors::ApplePayDecryptionError::CertificateParsingFailed) .attach_printable("Error parsing apple pay PPC")?; @@ -3747,7 +3742,6 @@ impl ApplePayData { merchant_id }) .ok_or(errors::ApplePayDecryptionError::MissingMerchantId) - .into_report() .attach_printable("Unable to find merchant ID extension in the certificate")?; Ok(apple_pay_m_id) @@ -3759,11 +3753,9 @@ impl ApplePayData { ) -> CustomResult, errors::ApplePayDecryptionError> { let public_ec_bytes = BASE64_ENGINE .decode(self.header.ephemeral_public_key.peek().as_bytes()) - .into_report() .change_context(errors::ApplePayDecryptionError::Base64DecodingFailed)?; let public_key = PKey::public_key_from_der(&public_ec_bytes) - .into_report() .change_context(errors::ApplePayDecryptionError::KeyDeserializationFailed) .attach_printable("Failed to deserialize the public key")?; @@ -3777,26 +3769,22 @@ impl ApplePayData { // Create PKey objects from EcKey let private_key = PKey::private_key_from_pem(decrypted_apple_pay_ppc_key.as_bytes()) - .into_report() .change_context(errors::ApplePayDecryptionError::KeyDeserializationFailed) .attach_printable("Failed to deserialize the private key")?; // Create the Deriver object and set the peer public key let mut deriver = Deriver::new(&private_key) - .into_report() .change_context(errors::ApplePayDecryptionError::DerivingSharedSecretKeyFailed) .attach_printable("Failed to create a deriver for the private key")?; deriver .set_peer(&public_key) - .into_report() .change_context(errors::ApplePayDecryptionError::DerivingSharedSecretKeyFailed) .attach_printable("Failed to set the peer key for the secret derivation")?; // Compute the shared secret let shared_secret = deriver .derive_to_vec() - .into_report() .change_context(errors::ApplePayDecryptionError::DerivingSharedSecretKeyFailed) .attach_printable("Final key derivation failed")?; Ok(shared_secret) @@ -3809,7 +3797,6 @@ impl ApplePayData { ) -> CustomResult, errors::ApplePayDecryptionError> { let kdf_algorithm = b"\x0did-aes256-GCM"; let kdf_party_v = hex::decode(merchant_id) - .into_report() .change_context(errors::ApplePayDecryptionError::Base64DecodingFailed)?; let kdf_party_u = b"Apple"; let kdf_info = [&kdf_algorithm[..], kdf_party_u, &kdf_party_v[..]].concat(); @@ -3829,7 +3816,6 @@ impl ApplePayData { ) -> CustomResult { let data = BASE64_ENGINE .decode(self.data.peek().as_bytes()) - .into_report() .change_context(errors::ApplePayDecryptionError::Base64DecodingFailed)?; let iv = [0u8; 16]; //Initialization vector IV is typically used in AES-GCM (Galois/Counter Mode) encryption for randomizing the encryption process. let ciphertext = data @@ -3840,10 +3826,8 @@ impl ApplePayData { .ok_or(errors::ApplePayDecryptionError::DecryptionFailed)?; let cipher = Cipher::aes_256_gcm(); let decrypted_data = decrypt_aead(cipher, symmetric_key, Some(&iv), &[], ciphertext, tag) - .into_report() .change_context(errors::ApplePayDecryptionError::DecryptionFailed)?; let decrypted = String::from_utf8(decrypted_data) - .into_report() .change_context(errors::ApplePayDecryptionError::DecryptionFailed)?; Ok(decrypted) @@ -4128,7 +4112,6 @@ pub async fn get_payment_method_details_from_payment_token( }; let token = hyperswitch_token .ok_or(errors::ApiErrorResponse::InternalServerError) - .into_report() .attach_printable("missing hyperswitch_token")?; match token { storage::PaymentTokenData::TemporaryGeneric(generic_token) => { diff --git a/crates/router/src/core/payments/operations/payment_approve.rs b/crates/router/src/core/payments/operations/payment_approve.rs index a2132bed8c1e..e25ef7ed4a48 100644 --- a/crates/router/src/core/payments/operations/payment_approve.rs +++ b/crates/router/src/core/payments/operations/payment_approve.rs @@ -2,7 +2,7 @@ use std::marker::PhantomData; use api_models::enums::FrmSuggestion; use async_trait::async_trait; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use router_derive::PaymentOperation; use router_env::{instrument, tracing}; @@ -255,10 +255,10 @@ impl Box::new(self), operations::ValidateResult { merchant_id: &merchant_account.merchant_id, - payment_id: api::PaymentIdType::PaymentIntentId( - crate::core::utils::validate_id(request.payment_id.clone(), "payment_id") - .into_report()?, - ), + payment_id: api::PaymentIdType::PaymentIntentId(crate::core::utils::validate_id( + request.payment_id.clone(), + "payment_id", + )?), mandate_type: None, storage_scheme: merchant_account.storage_scheme, requeue: false, diff --git a/crates/router/src/core/payments/operations/payment_complete_authorize.rs b/crates/router/src/core/payments/operations/payment_complete_authorize.rs index b788ebc95f72..9d0971982a64 100644 --- a/crates/router/src/core/payments/operations/payment_complete_authorize.rs +++ b/crates/router/src/core/payments/operations/payment_complete_authorize.rs @@ -2,7 +2,7 @@ use std::marker::PhantomData; use api_models::enums::FrmSuggestion; use async_trait::async_trait; -use error_stack::{report, IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use router_derive::PaymentOperation; use router_env::{instrument, tracing}; @@ -467,9 +467,7 @@ impl ValidateRequest Domain ValidateRequest PostUpdateTracker, types::PaymentsIncrementalAu } } _ => Err(errors::ApiErrorResponse::InternalServerError) - .into_report() .attach_printable("unexpected response in incremental_authorization flow")?, }; //payment_attempt update @@ -178,7 +177,6 @@ impl PostUpdateTracker, types::PaymentsIncrementalAu connector_authorization_id: connector_authorization_id.clone(), }), Ok(_) => Err(errors::ApiErrorResponse::InternalServerError) - .into_report() .attach_printable("unexpected response in incremental_authorization flow"), }?; let authorization_id = incremental_authorization_details diff --git a/crates/router/src/core/payments/operations/payment_update.rs b/crates/router/src/core/payments/operations/payment_update.rs index 684f7c4b6983..a6a41732f1bd 100644 --- a/crates/router/src/core/payments/operations/payment_update.rs +++ b/crates/router/src/core/payments/operations/payment_update.rs @@ -5,7 +5,7 @@ use api_models::{ }; use async_trait::async_trait; use common_utils::ext_traits::{AsyncExt, Encode, ValueExt}; -use error_stack::{report, IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use router_derive::PaymentOperation; use router_env::{instrument, tracing}; @@ -760,9 +760,7 @@ impl ValidateRequest }); } None => Err(errors::ApiErrorResponse::InternalServerError) - .into_report() .attach_printable("missing incremental_authorization_details in payment_data")?, } Ok((Box::new(self), payment_data)) diff --git a/crates/router/src/core/payments/retry.rs b/crates/router/src/core/payments/retry.rs index 2c0183922b1a..09400bb750b1 100644 --- a/crates/router/src/core/payments/retry.rs +++ b/crates/router/src/core/payments/retry.rs @@ -2,7 +2,7 @@ use std::{str::FromStr, vec::IntoIter}; use common_utils::ext_traits::Encode; use diesel_models::enums as storage_enums; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use router_env::{ logger, tracing::{self, instrument}, @@ -142,12 +142,11 @@ where retries = retries.map(|i| i - 1); } api_models::gsm::GsmDecision::Requeue => { - Err(errors::ApiErrorResponse::NotImplemented { + Err(report!(errors::ApiErrorResponse::NotImplemented { message: errors::api_error_response::NotImplementedMessage::Reason( "Requeue not implemented".to_string(), ), - }) - .into_report()? + }))? } api_models::gsm::GsmDecision::DoDefault => break, } @@ -170,7 +169,6 @@ pub async fn is_step_up_enabled_for_merchant_connector( .change_context(errors::ApiErrorResponse::InternalServerError) .and_then(|step_up_config| { serde_json::from_str::>(&step_up_config.config) - .into_report() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Step-up config parsing failed") }) @@ -200,7 +198,6 @@ pub async fn get_retries( retries_config .config .parse::() - .into_report() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Retries config parsing failed") }) @@ -236,9 +233,8 @@ pub fn get_gsm_decision( let option_gsm_decision = option_gsm .and_then(|gsm| { api_models::gsm::GsmDecision::from_str(gsm.decision.as_str()) - .into_report() .map_err(|err| { - let api_error = err.change_context(errors::ApiErrorResponse::InternalServerError) + let api_error = report!(err).change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("gsm decision parsing failed"); logger::warn!(get_gsm_decision_parse_error=?api_error, "error fetching gsm decision"); api_error @@ -259,7 +255,6 @@ fn get_flow_name() -> RouterResult { .rsplit("::") .next() .ok_or(errors::ApiErrorResponse::InternalServerError) - .into_report() .attach_printable("Flow stringify failed")? .to_string()) } diff --git a/crates/router/src/core/payments/routing.rs b/crates/router/src/core/payments/routing.rs index d8a23ce9161e..e2502e2ecb6e 100644 --- a/crates/router/src/core/payments/routing.rs +++ b/crates/router/src/core/payments/routing.rs @@ -14,7 +14,7 @@ use api_models::{ }; use common_utils::static_cache::StaticCache; use diesel_models::enums as storage_enums; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use euclid::{ backend::{self, inputs as dsl_inputs, EuclidBackend}, dssa::graph::{self as euclid_graph, Memoization}, @@ -310,7 +310,6 @@ pub async fn perform_static_routing_v1( .await?; let cached_algorithm: Arc = ROUTING_CACHE .retrieve(&key) - .into_report() .change_context(errors::RoutingError::CacheMiss) .attach_printable("Unable to retrieve cached routing algorithm even after refresh")?; @@ -375,13 +374,11 @@ async fn ensure_algorithm_cached_v1( let present = ROUTING_CACHE .present(&key) - .into_report() .change_context(errors::RoutingError::DslCachePoisoned) .attach_printable("Error checking presence of DSL")?; let expired = ROUTING_CACHE .expired(&key, timestamp) - .into_report() .change_context(errors::RoutingError::DslCachePoisoned) .attach_printable("Error checking expiry of DSL in cache")?; @@ -429,7 +426,6 @@ fn execute_dsl_and_get_connector_v1( let routing_output: routing_types::RoutingAlgorithm = interpreter .execute(backend_input) .map(|out| out.connector_selection.foreign_into()) - .into_report() .change_context(errors::RoutingError::DslExecutionError)?; Ok(match routing_output { @@ -439,7 +435,6 @@ fn execute_dsl_and_get_connector_v1( .change_context(errors::RoutingError::DslFinalConnectorSelectionFailed)?, _ => Err(errors::RoutingError::DslIncorrectSelectionAlgorithm) - .into_report() .attach_printable("Unsupported algorithm received as a result of static routing")?, }) } @@ -492,7 +487,6 @@ pub async fn refresh_routing_cache_v1( } routing_types::RoutingAlgorithm::Advanced(program) => { let interpreter = backend::VirInterpreterBackend::with_program(program) - .into_report() .change_context(errors::RoutingError::DslBackendInitError) .attach_printable("Error initializing DSL interpreter backend")?; @@ -502,7 +496,6 @@ pub async fn refresh_routing_cache_v1( ROUTING_CACHE .save(key, cached_algorithm, timestamp) - .into_report() .change_context(errors::RoutingError::DslCachePoisoned) .attach_printable("Error saving DSL to cache")?; @@ -515,7 +508,6 @@ pub fn perform_volume_split( ) -> RoutingResult> { let weights: Vec = splits.iter().map(|sp| sp.split).collect(); let weighted_index = distributions::WeightedIndex::new(weights) - .into_report() .change_context(errors::RoutingError::VolumeSplitFailed) .attach_printable("Error creating weighted distribution for volume split")?; @@ -534,7 +526,6 @@ pub fn perform_volume_split( splits .get(idx) .ok_or(errors::RoutingError::VolumeSplitFailed) - .into_report() .attach_printable("Volume split index lookup failed")?; // Panic Safety: We have performed a `get(idx)` operation just above which will @@ -578,13 +569,11 @@ pub async fn get_merchant_kgraph<'a>( let kgraph_present = KGRAPH_CACHE .present(&key) - .into_report() .change_context(errors::RoutingError::KgraphCacheFailure) .attach_printable("when checking kgraph presence")?; let kgraph_expired = KGRAPH_CACHE .expired(&key, merchant_last_modified) - .into_report() .change_context(errors::RoutingError::KgraphCacheFailure) .attach_printable("when checking kgraph expiry")?; @@ -603,7 +592,6 @@ pub async fn get_merchant_kgraph<'a>( let cached_kgraph = KGRAPH_CACHE .retrieve(&key) - .into_report() .change_context(errors::RoutingError::CacheMiss) .attach_printable("when retrieving kgraph")?; @@ -650,20 +638,18 @@ pub async fn refresh_kgraph_cache( profile_id, ); - let api_mcas: Vec = merchant_connector_accounts + let api_mcas = merchant_connector_accounts .into_iter() - .map(|acct| acct.try_into()) - .collect::>() + .map(admin_api::MerchantConnectorResponse::try_from) + .collect::, _>>() .change_context(errors::RoutingError::KgraphCacheRefreshFailed)?; let kgraph = mca_graph::make_mca_graph(api_mcas) - .into_report() .change_context(errors::RoutingError::KgraphCacheRefreshFailed) .attach_printable("when construction kgraph")?; KGRAPH_CACHE .save(key, kgraph, timestamp) - .into_report() .change_context(errors::RoutingError::KgraphCacheRefreshFailed) .attach_printable("when saving kgraph to cache")?; @@ -684,7 +670,6 @@ async fn perform_kgraph_filtering( let context = euclid_graph::AnalysisContext::from_dir_values( backend_input .into_context() - .into_report() .change_context(errors::RoutingError::KgraphAnalysisError)?, ); let cached_kgraph = get_merchant_kgraph( @@ -703,11 +688,9 @@ async fn perform_kgraph_filtering( let euclid_choice: ast::ConnectorChoice = choice.clone().foreign_into(); let dir_val = euclid_choice .into_dir_value() - .into_report() .change_context(errors::RoutingError::KgraphAnalysisError)?; let kgraph_eligible = cached_kgraph .check_value_validity(dir_val, &context, &mut Memoization::new()) - .into_report() .change_context(errors::RoutingError::KgraphAnalysisError)?; let filter_eligible = @@ -1031,7 +1014,6 @@ async fn perform_session_routing_for_pm_type( let cached_algorithm = ROUTING_CACHE .retrieve(&key) - .into_report() .change_context(errors::RoutingError::CacheMiss) .attach_printable("unable to retrieve cached routing algorithm")?; diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs index e6bac7e4aa75..d686d741c880 100644 --- a/crates/router/src/core/payments/transformers.rs +++ b/crates/router/src/core/payments/transformers.rs @@ -6,7 +6,7 @@ use api_models::payouts::PayoutAttemptResponse; use common_enums::RequestIncrementalAuthorization; use common_utils::{consts::X_HS_LATENCY, fp_utils}; use diesel_models::ephemeral_key; -use error_stack::{report, IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use masking::Maskable; use router_env::{instrument, tracing}; @@ -102,7 +102,6 @@ where .multiple_api_version_supported_connectors .supported_connectors; let connector_enum = api_models::enums::Connector::from_str(connector_id) - .into_report() .change_context(errors::ConnectorError::InvalidConnectorName) .change_context(errors::ApiErrorResponse::InvalidDataValue { field_name: "connector", @@ -374,7 +373,6 @@ where .get_required_value("currency")?; let amount = currency .to_currency_base_unit(payment_attempt.amount) - .into_report() .change_context(errors::ApiErrorResponse::InvalidDataValue { field_name: "amount", })?; diff --git a/crates/router/src/core/payments/types.rs b/crates/router/src/core/payments/types.rs index ac54e1b7aa3b..738255580687 100644 --- a/crates/router/src/core/payments/types.rs +++ b/crates/router/src/core/payments/types.rs @@ -9,7 +9,7 @@ use common_utils::{ }; use data_models::payments::payment_attempt::PaymentAttempt; use diesel_models::business_profile::BusinessProfile; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use redis_interface::errors::RedisError; use router_env::{instrument, tracing}; @@ -42,7 +42,6 @@ impl MultipleCaptureData { let latest_capture = captures .last() .ok_or(errors::ApiErrorResponse::InternalServerError) - .into_report() .attach_printable("Cannot create MultipleCaptureData with empty captures list")? .clone(); let multiple_capture_data = Self { @@ -105,7 +104,6 @@ impl MultipleCaptureData { } pub fn get_captures_count(&self) -> RouterResult { i16::try_from(self.all_captures.len()) - .into_report() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Error while converting from usize to i16") } diff --git a/crates/router/src/core/payouts.rs b/crates/router/src/core/payouts.rs index 5f47c5251edd..566caa7acc58 100644 --- a/crates/router/src/core/payouts.rs +++ b/crates/router/src/core/payouts.rs @@ -10,7 +10,7 @@ use common_utils::{crypto::Encryptable, ext_traits::ValueExt, pii}; #[cfg(feature = "olap")] use data_models::errors::StorageError; use diesel_models::enums as storage_enums; -use error_stack::{report, IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; #[cfg(feature = "olap")] use futures::future::join_all; #[cfg(feature = "olap")] @@ -58,7 +58,6 @@ pub fn get_next_connector( connectors .next() .ok_or(errors::ApiErrorResponse::InternalServerError) - .into_report() .attach_printable("Connector not found in connectors iterator") } @@ -82,7 +81,6 @@ pub async fn get_connector_choice( match connector_choice { api::ConnectorChoice::SessionMultiple(_) => { Err(errors::ApiErrorResponse::InternalServerError) - .into_report() .attach_printable("Invalid connector choice - SessionMultiple")? } @@ -539,7 +537,6 @@ pub async fn payouts_cancel_core( _ => Err(errors::ApplicationError::InvalidConfigurationValueError( "Connector not found in payout_attempt - should not reach here".to_string(), )) - .into_report() .change_context(errors::ApiErrorResponse::MissingRequiredField { field_name: "connector", }) @@ -610,7 +607,6 @@ pub async fn payouts_fulfill_core( _ => Err(errors::ApplicationError::InvalidConfigurationValueError( "Connector not found in payout_attempt - should not reach here.".to_string(), )) - .into_report() .change_context(errors::ApiErrorResponse::MissingRequiredField { field_name: "connector", }) diff --git a/crates/router/src/core/payouts/helpers.rs b/crates/router/src/core/payouts/helpers.rs index f7ee340249d7..1a94186a86f2 100644 --- a/crates/router/src/core/payouts/helpers.rs +++ b/crates/router/src/core/payouts/helpers.rs @@ -4,7 +4,7 @@ use common_utils::{ ext_traits::{AsyncExt, StringExt}, }; use diesel_models::encryption::Encryption; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::{ExposeInterface, PeekInterface, Secret}; use router_env::logger; @@ -231,7 +231,6 @@ pub async fn save_payout_data_to_locker( let key = key_store.key.get_inner().peek(); let enc_data = async { serde_json::to_value(payout_method_data.to_owned()) - .into_report() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Unable to encode payout method data") .ok() @@ -503,7 +502,6 @@ pub async fn decide_payout_connector( let first_connector_choice = connectors .first() .ok_or(errors::ApiErrorResponse::IncorrectPaymentMethodConfiguration) - .into_report() .attach_printable("Empty connector list returned")? .clone(); @@ -563,7 +561,6 @@ pub async fn decide_payout_connector( let first_connector_choice = connectors .first() .ok_or(errors::ApiErrorResponse::IncorrectPaymentMethodConfiguration) - .into_report() .attach_printable("Empty connector list returned")? .clone(); diff --git a/crates/router/src/core/payouts/retry.rs b/crates/router/src/core/payouts/retry.rs index a1a9d0b2713c..fbb7ca0ba728 100644 --- a/crates/router/src/core/payouts/retry.rs +++ b/crates/router/src/core/payouts/retry.rs @@ -1,7 +1,7 @@ use std::{cmp::Ordering, str::FromStr, vec::IntoIter}; use api_models::payouts::PayoutCreateRequest; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use router_env::{ logger, tracing::{self, instrument}, @@ -83,12 +83,11 @@ pub async fn do_gsm_multiple_connector_actions( retries = retries.map(|i| i - 1); } api_models::gsm::GsmDecision::Requeue => { - Err(errors::ApiErrorResponse::NotImplemented { + Err(report!(errors::ApiErrorResponse::NotImplemented { message: errors::api_error_response::NotImplementedMessage::Reason( "Requeue not implemented".to_string(), ), - }) - .into_report()? + }))? } api_models::gsm::GsmDecision::DoDefault => break, } @@ -150,12 +149,11 @@ pub async fn do_gsm_single_connector_actions( retries = retries.map(|i| i - 1); } api_models::gsm::GsmDecision::Requeue => { - Err(errors::ApiErrorResponse::NotImplemented { + Err(report!(errors::ApiErrorResponse::NotImplemented { message: errors::api_error_response::NotImplementedMessage::Reason( "Requeue not implemented".to_string(), ), - }) - .into_report()? + }))? } api_models::gsm::GsmDecision::DoDefault => break, } @@ -189,7 +187,6 @@ pub async fn get_retries( retries_config .config .parse::() - .into_report() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Retries config parsing failed") }) @@ -226,9 +223,8 @@ pub fn get_gsm_decision( let option_gsm_decision = option_gsm .and_then(|gsm| { api_models::gsm::GsmDecision::from_str(gsm.decision.as_str()) - .into_report() .map_err(|err| { - let api_error = err.change_context(errors::ApiErrorResponse::InternalServerError) + let api_error = report!(err).change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("gsm decision parsing failed"); logger::warn!(get_gsm_decision_parse_error=?api_error, "error fetching gsm decision"); api_error diff --git a/crates/router/src/core/pm_auth.rs b/crates/router/src/core/pm_auth.rs index 20db03a26a63..715a7ae12a8d 100644 --- a/crates/router/src/core/pm_auth.rs +++ b/crates/router/src/core/pm_auth.rs @@ -17,7 +17,7 @@ use common_utils::{ generate_id, }; use data_models::payments::PaymentIntent; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use helpers::PaymentAuthConnectorDataExt; use masking::{ExposeInterface, PeekInterface, Secret}; use pm_auth::{ @@ -86,8 +86,7 @@ pub async fn create_link_token( }) .ok_or(ApiErrorResponse::GenericNotFoundError { message: "payment method auth connector name not found".to_string(), - }) - .into_report()?; + })?; let connector_name = selected_config.connector_name.as_str(); @@ -323,7 +322,6 @@ async fn store_bank_details_in_payment_methods( .map(|x| x.into_inner().expose()) .map(|v| { serde_json::from_value::(v) - .into_report() .change_context(errors::StorageError::DeserializationFailed) .attach_printable("Failed to deserialize Payment Method Auth config") }) @@ -631,8 +629,7 @@ async fn get_selected_config_from_redis( }) .ok_or(ApiErrorResponse::GenericNotFoundError { message: "payment method auth connector name not found".to_string(), - }) - .into_report()? + })? .clone(); Ok(selected_config) @@ -694,7 +691,6 @@ pub async fn retrieve_payment_method_from_auth_service( && acc.payment_method == auth_token.payment_method }) .ok_or(errors::ApiErrorResponse::InternalServerError) - .into_report() .attach_printable("Bank account details not found")?; let mut bank_type = None; @@ -720,7 +716,6 @@ pub async fn retrieve_payment_method_from_auth_service( .ok_or(errors::ApiErrorResponse::GenericNotFoundError { message: "billing_first_name not found".to_string(), }) - .into_report() .attach_printable("billing_first_name not found")?; let address_details = address.clone().map(|addr| { diff --git a/crates/router/src/core/pm_auth/helpers.rs b/crates/router/src/core/pm_auth/helpers.rs index 43d30705a803..82663169000c 100644 --- a/crates/router/src/core/pm_auth/helpers.rs +++ b/crates/router/src/core/pm_auth/helpers.rs @@ -1,5 +1,5 @@ use common_utils::ext_traits::ValueExt; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use pm_auth::types::{self as pm_auth_types, api::BoxedPaymentAuthConnector}; use crate::{ @@ -27,7 +27,6 @@ pub fn get_connector_auth_type( })?; pm_auth_types::ConnectorAuthType::foreign_try_from(auth_type) - .into_report() .change_context(ApiErrorResponse::InternalServerError) .attach_printable("Failed while converting ConnectorAuthType") } diff --git a/crates/router/src/core/refunds.rs b/crates/router/src/core/refunds.rs index 5c2a3070bde9..2d6cac3f6e0d 100644 --- a/crates/router/src/core/refunds.rs +++ b/crates/router/src/core/refunds.rs @@ -1,7 +1,7 @@ pub mod validator; use common_utils::ext_traits::AsyncExt; -use error_stack::{report, IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use router_env::{instrument, tracing}; use scheduler::{consumer::types::process_data, utils as process_tracker_utils}; @@ -68,7 +68,6 @@ pub async fn refund_create_core( .amount .or(payment_intent.amount_captured) .ok_or(errors::ApiErrorResponse::InternalServerError) - .into_report() .attach_printable("amount captured is none in a successful payment")?; //[#299]: Can we change the flow based on some workflow idea @@ -134,7 +133,6 @@ pub async fn trigger_refund_to_gateway( .connector .clone() .ok_or(errors::ApiErrorResponse::InternalServerError) - .into_report() .attach_printable("Failed to retrieve connector from payment attempt")?; let storage_scheme = merchant_account.storage_scheme; @@ -637,7 +635,6 @@ pub async fn validate_and_create_refund( .connector .clone() .ok_or(errors::ApiErrorResponse::InternalServerError) - .into_report() .attach_printable("No connector populated in payment attempt")?; let refund_create_req = storage::RefundNew::default() @@ -879,7 +876,6 @@ pub async fn sync_refund_with_gateway_workflow( ) -> Result<(), errors::ProcessTrackerError> { let refund_core = serde_json::from_value::(refund_tracker.tracking_data.clone()) - .into_report() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable_lazy(|| { format!( @@ -966,7 +962,6 @@ pub async fn trigger_refund_execute_workflow( let db = &*state.store; let refund_core = serde_json::from_value::(refund_tracker.tracking_data.clone()) - .into_report() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable_lazy(|| { format!( diff --git a/crates/router/src/core/refunds/validator.rs b/crates/router/src/core/refunds/validator.rs index cae8f0494bee..43d44ebe41d2 100644 --- a/crates/router/src/core/refunds/validator.rs +++ b/crates/router/src/core/refunds/validator.rs @@ -1,4 +1,4 @@ -use error_stack::{report, IntoReport}; +use error_stack::report; use router_env::{instrument, tracing}; use time::PrimitiveDateTime; @@ -136,10 +136,10 @@ pub fn validate_for_valid_refunds( || { Err(errors::ApiErrorResponse::RefundNotPossible { connector: connector.to_string(), - }) + } + .into()) }, ) - .into_report() } _ => Ok(()), } diff --git a/crates/router/src/core/routing.rs b/crates/router/src/core/routing.rs index d4e8530de165..31825617398a 100644 --- a/crates/router/src/core/routing.rs +++ b/crates/router/src/core/routing.rs @@ -13,14 +13,14 @@ use common_utils::ext_traits::{Encode, StringExt}; use diesel_models::configs; #[cfg(feature = "business_profile_routing")] use diesel_models::routing_algorithm::RoutingAlgorithm; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use rustc_hash::FxHashSet; use super::payments; #[cfg(feature = "payouts")] use super::payouts; #[cfg(feature = "business_profile_routing")] -use crate::types::transformers::{ForeignInto, ForeignTryInto}; +use crate::types::transformers::{ForeignInto, ForeignTryFrom}; use crate::{ consts, core::{ @@ -203,7 +203,6 @@ pub async fn create_routing_config( Err(errors::ApiErrorResponse::PreconditionFailed { message: format!("Reached the maximum number of routing configs ({}), please delete some to create new ones", consts::MAX_ROUTING_CONFIGS_PER_MERCHANT), }) - .into_report() }, )?; let timestamp = common_utils::date_time::now_unix_timestamp(); @@ -304,7 +303,6 @@ pub async fn link_routing_config( Err(errors::ApiErrorResponse::PreconditionFailed { message: "Algorithm is already active".to_string(), }) - .into_report() }, )?; @@ -342,7 +340,6 @@ pub async fn link_routing_config( Err(errors::ApiErrorResponse::PreconditionFailed { message: "Algorithm is already active".to_string(), }) - .into_report() }, )?; let mut merchant_dictionary = @@ -354,7 +351,6 @@ pub async fn link_routing_config( .iter_mut() .find(|rec| rec.id == algorithm_id) .ok_or(errors::ApiErrorResponse::ResourceIdNotFound) - .into_report() .attach_printable("Record with given ID not found for routing config activation")?; record.modified_at = modified_at; @@ -400,8 +396,7 @@ pub async fn retrieve_routing_config( .get_required_value("BusinessProfile") .change_context(errors::ApiErrorResponse::ResourceIdNotFound)?; - let response = routing_algorithm - .foreign_try_into() + let response = routing_types::MerchantRoutingAlgorithm::foreign_try_from(routing_algorithm) .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("unable to parse routing algorithm")?; @@ -419,7 +414,6 @@ pub async fn retrieve_routing_config( .into_iter() .find(|rec| rec.id == algorithm_id.0) .ok_or(errors::ApiErrorResponse::ResourceIdNotFound) - .into_report() .attach_printable("Algorithm with the given ID not found in the merchant dictionary")?; let algorithm_config = db @@ -528,8 +522,7 @@ pub async fn unlink_routing_config( } None => Err(errors::ApiErrorResponse::PreconditionFailed { message: "Algorithm is already inactive".to_string(), - }) - .into_report()?, + })?, } } None => Err(errors::ApiErrorResponse::InvalidRequestData { @@ -560,7 +553,6 @@ pub async fn unlink_routing_config( Err(errors::ApiErrorResponse::PreconditionFailed { message: "Algorithm is already inactive".to_string(), }) - .into_report() })?; let routing_algorithm: routing_types::RoutingAlgorithmRef = routing_types::RoutingAlgorithmRef { @@ -576,15 +568,13 @@ pub async fn unlink_routing_config( .ok_or(errors::ApiErrorResponse::PreconditionFailed { // When the merchant_dictionary doesn't have any active algorithm and merchant_account doesn't have any routing_algorithm configured message: "Algorithm is already inactive".to_string(), - }) - .into_report()?; + })?; let record = merchant_dictionary .records .iter_mut() .find(|rec| rec.id == active_algorithm_id) .ok_or(errors::ApiErrorResponse::ResourceIdNotFound) - .into_report() .attach_printable("Record with the given ID not found for de-activation")?; let response = record.clone(); @@ -655,7 +645,6 @@ pub async fn update_default_routing_config( Err(errors::ApiErrorResponse::PreconditionFailed { message: "current config and updated config have different lengths".to_string(), }) - .into_report() })?; let existing_set: FxHashSet = @@ -675,7 +664,6 @@ pub async fn update_default_routing_config( symmetric_diff.join(", ") ), }) - .into_report() })?; helpers::update_merchant_default_config( @@ -781,7 +769,6 @@ pub async fn retrieve_linked_routing_config( .into_iter() .find(|rec| rec.id == algorithm_id) .ok_or(errors::ApiErrorResponse::ResourceIdNotFound) - .into_report() .attach_printable("record for active algorithm not found in merchant dictionary")?; let config = db @@ -885,7 +872,6 @@ pub async fn update_default_routing_config_for_profile( Err(errors::ApiErrorResponse::PreconditionFailed { message: "current config and updated config have different lengths".to_string(), }) - .into_report() })?; let existing_set = FxHashSet::from_iter(default_config.iter().map(|c| { @@ -923,7 +909,6 @@ pub async fn update_default_routing_config_for_profile( Err(errors::ApiErrorResponse::InvalidRequestData { message: format!("connector mismatch between old and new configs ({error_str})"), }) - .into_report() })?; helpers::update_merchant_default_config( diff --git a/crates/router/src/core/surcharge_decision_config.rs b/crates/router/src/core/surcharge_decision_config.rs index a17be6ce36e5..b489b92cdf1f 100644 --- a/crates/router/src/core/surcharge_decision_config.rs +++ b/crates/router/src/core/surcharge_decision_config.rs @@ -7,7 +7,7 @@ use api_models::{ }; use common_utils::ext_traits::{Encode, StringExt, ValueExt}; use diesel_models::configs; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use euclid::frontend::ast; use super::routing::helpers::{ @@ -53,7 +53,6 @@ pub async fn upsert_surcharge_decision_config( let read_config_key = db.find_config_by_key(&key).await; ast::lowering::lower_program(program.clone()) - .into_report() .change_context(errors::ApiErrorResponse::InvalidRequestData { message: "Invalid Request Data".to_string(), }) diff --git a/crates/router/src/core/user.rs b/crates/router/src/core/user.rs index 703c64431602..2702cec8eb50 100644 --- a/crates/router/src/core/user.rs +++ b/crates/router/src/core/user.rs @@ -2,9 +2,7 @@ use api_models::user::{self as user_api, InviteMultipleUserResponse}; #[cfg(feature = "email")] use diesel_models::user_role::UserRoleUpdate; use diesel_models::{enums::UserStatus, user as storage_user, user_role::UserRoleNew}; -#[cfg(feature = "email")] -use error_stack::IntoReport; -use error_stack::ResultExt; +use error_stack::{report, ResultExt}; use masking::ExposeInterface; #[cfg(feature = "email")] use router_env::env; @@ -219,7 +217,7 @@ pub async fn connect_account( .unwrap_or(false) { if matches!(env::which(), env::Env::Production) { - return Err(UserErrors::InvalidCredentials).into_report(); + return Err(report!(UserErrors::InvalidCredentials)); } let new_user = domain::NewUser::try_from(request)?; @@ -455,7 +453,7 @@ pub async fn invite_user( .to_not_found_response(UserErrors::InvalidRoleId)?; if !role_info.is_invitable() { - return Err(UserErrors::InvalidRoleId.into()) + return Err(report!(UserErrors::InvalidRoleId)) .attach_printable(format!("role_id = {} is not invitable", request.role_id)); } @@ -618,7 +616,7 @@ pub async fn invite_user( }, })) } else { - Err(UserErrors::InternalServerError.into()) + Err(report!(UserErrors::InternalServerError)) } } @@ -628,7 +626,7 @@ pub async fn invite_multiple_user( requests: Vec, ) -> UserResponse> { if requests.len() > 10 { - return Err(UserErrors::MaxInvitationsError.into()) + return Err(report!(UserErrors::MaxInvitationsError)) .attach_printable("Number of invite requests must not exceed 10"); } @@ -672,7 +670,7 @@ async fn handle_invitation( .to_not_found_response(UserErrors::InvalidRoleId)?; if !role_info.is_invitable() { - return Err(UserErrors::InvalidRoleId.into()) + return Err(report!(UserErrors::InvalidRoleId)) .attach_printable(format!("role_id = {} is not invitable", request.role_id)); } @@ -896,7 +894,7 @@ pub async fn resend_invite( })?; if !matches!(user_role.status, UserStatus::InvitationSent) { - return Err(UserErrors::InvalidRoleOperation.into()) + return Err(report!(UserErrors::InvalidRoleOperation)) .attach_printable("User status is not InvitationSent".to_string()); } @@ -1122,7 +1120,7 @@ pub async fn switch_merchant_id( let user_role = active_user_roles .iter() .find(|role| role.merchant_id == request.merchant_id) - .ok_or(UserErrors::InvalidRoleOperation.into()) + .ok_or(report!(UserErrors::InvalidRoleOperation)) .attach_printable("User doesn't have access to switch")?; let token = utils::user::generate_jwt_auth_token(&state, &user, user_role).await?; diff --git a/crates/router/src/core/user/dashboard_metadata.rs b/crates/router/src/core/user/dashboard_metadata.rs index 3f6180158a50..328a54c540b6 100644 --- a/crates/router/src/core/user/dashboard_metadata.rs +++ b/crates/router/src/core/user/dashboard_metadata.rs @@ -2,7 +2,7 @@ use api_models::user::dashboard_metadata::{self as api, GetMultipleMetaDataPaylo use diesel_models::{ enums::DashboardMetadata as DBEnum, user::dashboard_metadata::DashboardMetadata, }; -use error_stack::ResultExt; +use error_stack::{report, ResultExt}; #[cfg(feature = "email")] use masking::ExposeInterface; #[cfg(feature = "email")] @@ -61,7 +61,7 @@ fn parse_set_request(data_enum: api::SetMetaDataRequest) -> UserResult { let ip_address = req .ip_address - .ok_or(UserErrors::InternalServerError.into()) + .ok_or(report!(UserErrors::InternalServerError)) .attach_printable("Error Getting Ip Address")?; Ok(types::MetaData::ProductionAgreement( types::ProductionAgreementValue { diff --git a/crates/router/src/core/user_role.rs b/crates/router/src/core/user_role.rs index 587e0e044358..2939c7d51b3c 100644 --- a/crates/router/src/core/user_role.rs +++ b/crates/router/src/core/user_role.rs @@ -1,6 +1,6 @@ use api_models::{user as user_api, user_role as user_role_api}; use diesel_models::{enums::UserStatus, user_role::UserRoleUpdate}; -use error_stack::ResultExt; +use error_stack::{report, ResultExt}; use masking::ExposeInterface; use router_env::logger; @@ -61,7 +61,7 @@ pub async fn update_user_role( .to_not_found_response(UserErrors::InvalidRoleId)?; if !role_info.is_updatable() { - return Err(UserErrors::InvalidRoleOperation.into()) + return Err(report!(UserErrors::InvalidRoleOperation)) .attach_printable(format!("User role cannot be updated to {}", req.role_id)); } @@ -72,7 +72,7 @@ pub async fn update_user_role( .attach_printable("User not found in our records".to_string())?; if user_from_token.user_id == user_to_be_updated.get_user_id() { - return Err(UserErrors::InvalidRoleOperation.into()) + return Err(report!(UserErrors::InvalidRoleOperation)) .attach_printable("User Changing their own role"); } @@ -91,7 +91,7 @@ pub async fn update_user_role( .change_context(UserErrors::InternalServerError)?; if !role_to_be_updated.is_updatable() { - return Err(UserErrors::InvalidRoleOperation.into()).attach_printable(format!( + return Err(report!(UserErrors::InvalidRoleOperation)).attach_printable(format!( "User role cannot be updated from {}", role_to_be_updated.get_role_id() )); @@ -122,7 +122,7 @@ pub async fn transfer_org_ownership( req: user_role_api::TransferOrgOwnershipRequest, ) -> UserResponse { if user_from_token.role_id != consts::user_role::ROLE_ID_ORGANIZATION_ADMIN { - return Err(UserErrors::InvalidRoleOperation.into()).attach_printable(format!( + return Err(report!(UserErrors::InvalidRoleOperation)).attach_printable(format!( "role_id = {} is not org_admin", user_from_token.role_id )); @@ -135,7 +135,7 @@ pub async fn transfer_org_ownership( .attach_printable("User not found in our records".to_string())?; if user_from_token.user_id == user_to_be_updated.get_user_id() { - return Err(UserErrors::InvalidRoleOperation.into()) + return Err(report!(UserErrors::InvalidRoleOperation)) .attach_printable("User transferring ownership to themselves".to_string()); } @@ -244,7 +244,7 @@ pub async fn delete_user_role( .into(); if user_from_db.get_user_id() == user_from_token.user_id { - return Err(UserErrors::InvalidDeleteOperation.into()) + return Err(report!(UserErrors::InvalidDeleteOperation)) .attach_printable("User deleting himself"); } @@ -268,12 +268,12 @@ pub async fn delete_user_role( .await .change_context(UserErrors::InternalServerError)?; if !role_info.is_deletable() { - return Err(UserErrors::InvalidDeleteOperation.into()) + return Err(report!(UserErrors::InvalidDeleteOperation)) .attach_printable(format!("role_id = {} is not deletable", user_role.role_id)); } } None => { - return Err(UserErrors::InvalidDeleteOperation.into()) + return Err(report!(UserErrors::InvalidDeleteOperation)) .attach_printable("User is not associated with the merchant"); } }; diff --git a/crates/router/src/core/user_role/role.rs b/crates/router/src/core/user_role/role.rs index 6aa226cd933c..a0cf5a6caf96 100644 --- a/crates/router/src/core/user_role/role.rs +++ b/crates/router/src/core/user_role/role.rs @@ -2,7 +2,7 @@ use api_models::user_role::role::{self as role_api}; use common_enums::RoleScope; use common_utils::generate_id_with_default_len; use diesel_models::role::{RoleNew, RoleUpdate}; -use error_stack::ResultExt; +use error_stack::{report, ResultExt}; use crate::{ consts, @@ -73,7 +73,7 @@ pub async fn create_role( if matches!(req.role_scope, RoleScope::Organization) && user_from_token.role_id != consts::user_role::ROLE_ID_ORGANIZATION_ADMIN { - return Err(UserErrors::InvalidRoleOperation.into()) + return Err(report!(UserErrors::InvalidRoleOperation)) .attach_printable("Non org admin user creating org level role"); } @@ -292,7 +292,7 @@ pub async fn update_role( if matches!(role_info.get_scope(), RoleScope::Organization) && user_from_token.role_id != consts::user_role::ROLE_ID_ORGANIZATION_ADMIN { - return Err(UserErrors::InvalidRoleOperation.into()) + return Err(report!(UserErrors::InvalidRoleOperation)) .attach_printable("Non org admin user changing org level role"); } diff --git a/crates/router/src/core/utils.rs b/crates/router/src/core/utils.rs index a64a846930f8..3423ace6e5bc 100644 --- a/crates/router/src/core/utils.rs +++ b/crates/router/src/core/utils.rs @@ -5,7 +5,7 @@ use common_enums::RequestIncrementalAuthorization; #[cfg(feature = "payouts")] use common_utils::{crypto::Encryptable, pii::Email}; use common_utils::{errors::CustomResult, ext_traits::AsyncExt}; -use error_stack::{report, IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use router_env::{instrument, tracing}; use uuid::Uuid; @@ -254,7 +254,6 @@ pub async fn construct_refund_router_data<'a, F>( .multiple_api_version_supported_connectors .supported_connectors; let connector_enum = api_models::enums::Connector::from_str(connector_id) - .into_report() .change_context(errors::ConnectorError::InvalidConnectorName) .change_context(errors::ApiErrorResponse::InvalidDataValue { field_name: "connector", @@ -880,7 +879,6 @@ pub async fn construct_retrieve_file_router_data<'a>( .ok_or(errors::ApiErrorResponse::MissingRequiredField { field_name: "profile_id", }) - .into_report() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("profile_id is not set in file_metadata")?; @@ -924,7 +922,6 @@ pub async fn construct_retrieve_file_router_data<'a>( .provider_file_id .clone() .ok_or(errors::ApiErrorResponse::InternalServerError) - .into_report() .attach_printable("Missing provider file id")?, }, response: Err(types::ErrorResponse::default()), @@ -1000,13 +997,13 @@ pub async fn validate_and_get_business_profile( if business_profile.merchant_id.ne(merchant_id) { Err(errors::ApiErrorResponse::AccessForbidden { resource: business_profile.profile_id, - }) + } + .into()) } else { Ok(business_profile) } }) .transpose() - .into_report() } fn connector_needs_business_sub_label(connector_name: &str) -> bool { @@ -1100,7 +1097,6 @@ pub fn get_flow_name() -> RouterResult { .rsplit("::") .next() .ok_or(errors::ApiErrorResponse::InternalServerError) - .into_report() .attach_printable("Flow stringify failed")? .to_string()) } @@ -1113,7 +1109,7 @@ pub fn get_request_incremental_authorization_value( .map(|request_incremental_authorization| { if request_incremental_authorization { if capture_method == Some(common_enums::CaptureMethod::Automatic) { - Err(errors::ApiErrorResponse::NotSupported { message: "incremental authorization is not supported when capture_method is automatic".to_owned() }).into_report()? + Err(errors::ApiErrorResponse::NotSupported { message: "incremental authorization is not supported when capture_method is automatic".to_owned() })? } Ok(RequestIncrementalAuthorization::True) } else { diff --git a/crates/router/src/core/verify_connector.rs b/crates/router/src/core/verify_connector.rs index e837e8b8b259..17cedd1e2d02 100644 --- a/crates/router/src/core/verify_connector.rs +++ b/crates/router/src/core/verify_connector.rs @@ -1,5 +1,5 @@ use api_models::{enums::Connector, verify_connector::VerifyConnectorRequest}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use crate::{ connector, @@ -25,12 +25,12 @@ pub async fn verify_connector_credentials( ) .change_context(errors::ApiErrorResponse::IncorrectConnectorNameGiven)?; - let card_details = utils::get_test_card_details(req.connector_name)? - .ok_or(errors::ApiErrorResponse::FlowNotSupported { + let card_details = utils::get_test_card_details(req.connector_name)?.ok_or( + errors::ApiErrorResponse::FlowNotSupported { flow: "Verify credentials".to_string(), connector: req.connector_name.to_string(), - }) - .into_report()?; + }, + )?; match req.connector_name { Connector::Stripe => { @@ -57,7 +57,7 @@ pub async fn verify_connector_credentials( _ => Err(errors::ApiErrorResponse::FlowNotSupported { flow: "Verify credentials".to_string(), connector: req.connector_name.to_string(), - }) - .into_report(), + } + .into()), } } diff --git a/crates/router/src/core/webhooks.rs b/crates/router/src/core/webhooks.rs index 6049c8c5081b..143d9d8e2682 100644 --- a/crates/router/src/core/webhooks.rs +++ b/crates/router/src/core/webhooks.rs @@ -14,7 +14,7 @@ use api_models::{ use common_utils::{ errors::ReportSwitchExt, events::ApiEventsType, ext_traits::Encode, request::RequestContent, }; -use error_stack::{report, IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use masking::{ExposeInterface, Mask, PeekInterface, Secret}; use router_env::{ instrument, @@ -45,7 +45,7 @@ use crate::{ api::{self, mandates::MandateResponseExt}, domain::{self, types as domain_types}, storage::{self, enums}, - transformers::{ForeignInto, ForeignTryInto}, + transformers::{ForeignInto, ForeignTryFrom}, }, utils::{self as helper_utils, generate_id, OptionExt, ValueExt}, workflows::outgoing_webhook_retry, @@ -150,11 +150,9 @@ pub async fn payments_incoming_webhook_flow( error @ Err(_) => error?, } } - _ => Err(errors::ApiErrorResponse::WebhookProcessingFailure) - .into_report() - .attach_printable( - "Did not get payment id as object reference id in webhook payments flow", - )?, + _ => Err(errors::ApiErrorResponse::WebhookProcessingFailure).attach_printable( + "Did not get payment id as object reference id in webhook payments flow", + )?, }; match payments_response { @@ -194,7 +192,6 @@ pub async fn payments_incoming_webhook_flow( } _ => Err(errors::ApiErrorResponse::WebhookProcessingFailure) - .into_report() .attach_printable("received non-json response from payments core")?, } } @@ -236,7 +233,6 @@ pub async fn refunds_incoming_webhook_flow( .attach_printable("Failed to fetch the refund")?, }, _ => Err(errors::ApiErrorResponse::WebhookProcessingFailure) - .into_report() .attach_printable("received a non-refund id when processing refund webhooks")?, }; let refund_id = refund.refund_id.to_owned(); @@ -245,9 +241,7 @@ pub async fn refunds_incoming_webhook_flow( let refund_update = storage::RefundUpdate::StatusUpdate { connector_refund_id: None, sent_to_gateway: true, - refund_status: event_type - .foreign_try_into() - .into_report() + refund_status: common_enums::RefundStatus::foreign_try_from(event_type) .change_context(errors::ApiErrorResponse::WebhookProcessingFailure) .attach_printable("failed refund status mapping from event type")?, updated_by: merchant_account.storage_scheme.to_string(), @@ -335,7 +329,6 @@ pub async fn get_payment_attempt_from_object_reference_id( .await .to_not_found_response(errors::ApiErrorResponse::WebhookResourceNotFound), _ => Err(errors::ApiErrorResponse::WebhookProcessingFailure) - .into_report() .attach_printable("received a non-payment id for retrieving payment")?, } } @@ -361,9 +354,7 @@ pub async fn get_or_update_dispute_object( amount: dispute_details.amount.clone(), currency: dispute_details.currency, dispute_stage: dispute_details.dispute_stage, - dispute_status: event_type - .foreign_try_into() - .into_report() + dispute_status: common_enums::DisputeStatus::foreign_try_from(event_type) .change_context(errors::ApiErrorResponse::WebhookProcessingFailure) .attach_printable("event type to dispute status mapping failed")?, payment_id: payment_attempt.payment_id.to_owned(), @@ -391,9 +382,7 @@ pub async fn get_or_update_dispute_object( Some(dispute) => { logger::info!("Dispute Already exists, Updating the dispute details"); metrics::INCOMING_DISPUTE_WEBHOOK_UPDATE_RECORD_METRIC.add(&metrics::CONTEXT, 1, &[]); - let dispute_status: diesel_models::enums::DisputeStatus = event_type - .foreign_try_into() - .into_report() + let dispute_status = diesel_models::enums::DisputeStatus::foreign_try_from(event_type) .change_context(errors::ApiErrorResponse::WebhookProcessingFailure) .attach_printable("event type to dispute state conversion failure")?; crate::core::utils::validate_dispute_stage_and_dispute_status( @@ -451,12 +440,9 @@ pub async fn mandates_incoming_webhook_flow( .await .to_not_found_response(errors::ApiErrorResponse::MandateNotFound)?, _ => Err(errors::ApiErrorResponse::WebhookProcessingFailure) - .into_report() .attach_printable("received a non-mandate id for retrieving mandate")?, }; - let mandate_status = event_type - .foreign_try_into() - .into_report() + let mandate_status = common_enums::MandateStatus::foreign_try_from(event_type) .change_context(errors::ApiErrorResponse::WebhookProcessingFailure) .attach_printable("event type to mandate status mapping failed")?; let updated_mandate = db @@ -497,7 +483,9 @@ pub async fn mandates_incoming_webhook_flow( }) } else { logger::error!("Webhook source verification failed for mandates webhook flow"); - Err(errors::ApiErrorResponse::WebhookAuthenticationFailed).into_report() + Err(report!( + errors::ApiErrorResponse::WebhookAuthenticationFailed + )) } } @@ -567,7 +555,9 @@ pub async fn disputes_incoming_webhook_flow( }) } else { metrics::INCOMING_DISPUTE_WEBHOOK_SIGNATURE_FAILURE_METRIC.add(&metrics::CONTEXT, 1, &[]); - Err(errors::ApiErrorResponse::WebhookAuthenticationFailed).into_report() + Err(report!( + errors::ApiErrorResponse::WebhookAuthenticationFailed + )) } } @@ -653,7 +643,6 @@ async fn bank_transfer_webhook_flow( } _ => Err(errors::ApiErrorResponse::WebhookProcessingFailure) - .into_report() .attach_printable("received non-json response from payments core")?, } } @@ -1108,7 +1097,7 @@ async fn trigger_webhook_to_merchant( } enums::WebhookDeliveryAttempt::ManualRetry => { // Will be updated when manual retry is implemented - Err(errors::WebhooksFlowError::NotReceivedByMerchant).into_report()? + Err(errors::WebhooksFlowError::NotReceivedByMerchant)? } } @@ -1126,7 +1115,6 @@ fn raise_webhooks_analytics_event( logger::error!(?error, "Failed to send webhook to merchant"); serde_json::to_value(error.current_context()) - .into_report() .change_context(errors::ApiErrorResponse::WebhookProcessingFailure) .map_err(|error| { logger::error!(?error, "Failed to serialize outgoing webhook error as JSON"); @@ -1178,7 +1166,6 @@ pub async fn webhooks_wrapper Err(errors::ApiErrorResponse::InternalServerError) - .into_report() .attach_printable("Unsupported Flow Type received in incoming webhooks")?, } } else { @@ -1542,7 +1525,6 @@ pub async fn webhooks_core database_call().await, @@ -377,8 +368,7 @@ mod storage { let conn = connection::pg_connection_write(self).await?; storage_types::Address::update_by_address_id(&conn, address_id, address.into()) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) .async_and_then(|address| async { address .convert(key_store.key.get_inner()) @@ -406,8 +396,7 @@ mod storage { address .update(&conn, address_update.into()) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) .async_and_then(|address| async { address .convert(key_store.key.get_inner()) @@ -422,7 +411,6 @@ mod storage { let updated_address = AddressUpdateInternal::from(address_update.clone()) .create_address(address.clone()); let redis_value = serde_json::to_string(&updated_address) - .into_report() .change_context(errors::StorageError::KVError)?; let redis_entry = kv::TypedSql { @@ -477,8 +465,7 @@ mod storage { address_new .insert(&conn) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) .async_and_then(|address| async { address .convert(key_store.key.get_inner()) @@ -535,8 +522,8 @@ mod storage { Ok(HsetnxReply::KeyNotSet) => Err(errors::StorageError::DuplicateValue { entity: "address", key: Some(created_address.address_id), - }) - .into_report(), + } + .into()), Ok(HsetnxReply::KeySet) => Ok(created_address .convert(key_store.key.get_inner()) .await @@ -560,8 +547,7 @@ mod storage { .change_context(errors::StorageError::EncryptionError)? .insert(&conn) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) .async_and_then(|address| async { address .convert(key_store.key.get_inner()) @@ -587,8 +573,7 @@ mod storage { address.into(), ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) .async_and_then(|addresses| async { let mut output = Vec::with_capacity(addresses.len()); for address in addresses.into_iter() { diff --git a/crates/router/src/db/api_keys.rs b/crates/router/src/db/api_keys.rs index c0d9ea364102..a23b3f0f7af1 100644 --- a/crates/router/src/db/api_keys.rs +++ b/crates/router/src/db/api_keys.rs @@ -1,4 +1,4 @@ -use error_stack::IntoReport; +use error_stack::report; use router_env::{instrument, tracing}; #[cfg(feature = "accounts_cache")] use storage_impl::redis::cache::CacheKind; @@ -62,8 +62,7 @@ impl ApiKeyInterface for Store { api_key .insert(&conn) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -79,8 +78,7 @@ impl ApiKeyInterface for Store { let update_call = || async { storage::ApiKey::update_by_merchant_id_key_id(&conn, merchant_id, key_id, api_key) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) }; #[cfg(not(feature = "accounts_cache"))] @@ -101,8 +99,7 @@ impl ApiKeyInterface for Store { &_key_id, ) .await - .map_err(Into::into) - .into_report()? + .map_err(|error| report!(errors::StorageError::from(error)))? .ok_or(report!(errors::StorageError::ValueNotFound(format!( "ApiKey of {_key_id} not found" ))))?; @@ -126,8 +123,7 @@ impl ApiKeyInterface for Store { let delete_call = || async { storage::ApiKey::revoke_by_merchant_id_key_id(&conn, merchant_id, key_id) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) }; #[cfg(not(feature = "accounts_cache"))] { @@ -145,8 +141,7 @@ impl ApiKeyInterface for Store { let api_key = storage::ApiKey::find_optional_by_merchant_id_key_id(&conn, merchant_id, key_id) .await - .map_err(Into::into) - .into_report()? + .map_err(|error| report!(errors::StorageError::from(error)))? .ok_or(report!(errors::StorageError::ValueNotFound(format!( "ApiKey of {key_id} not found" ))))?; @@ -169,8 +164,7 @@ impl ApiKeyInterface for Store { let conn = connection::pg_connection_read(self).await?; storage::ApiKey::find_optional_by_merchant_id_key_id(&conn, merchant_id, key_id) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -183,8 +177,7 @@ impl ApiKeyInterface for Store { let conn = connection::pg_connection_read(self).await?; storage::ApiKey::find_optional_by_hashed_api_key(&conn, hashed_api_key) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) }; #[cfg(not(feature = "accounts_cache"))] @@ -214,8 +207,7 @@ impl ApiKeyInterface for Store { let conn = connection::pg_connection_read(self).await?; storage::ApiKey::find_by_merchant_id(&conn, merchant_id, limit, offset) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } } diff --git a/crates/router/src/db/authentication.rs b/crates/router/src/db/authentication.rs index 14604684863a..a2c7f050052d 100644 --- a/crates/router/src/db/authentication.rs +++ b/crates/router/src/db/authentication.rs @@ -1,5 +1,5 @@ use diesel_models::authentication::AuthenticationUpdateInternal; -use error_stack::IntoReport; +use error_stack::report; use router_env::{instrument, tracing}; use super::{MockDb, Store}; @@ -40,8 +40,7 @@ impl AuthenticationInterface for Store { authentication .insert(&conn) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -57,8 +56,7 @@ impl AuthenticationInterface for Store { &authentication_id, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -75,8 +73,7 @@ impl AuthenticationInterface for Store { authentication_update, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } } diff --git a/crates/router/src/db/authorization.rs b/crates/router/src/db/authorization.rs index 322be5fc6db6..7b7802d64e5c 100644 --- a/crates/router/src/db/authorization.rs +++ b/crates/router/src/db/authorization.rs @@ -1,5 +1,5 @@ use diesel_models::authorization::AuthorizationUpdateInternal; -use error_stack::IntoReport; +use error_stack::report; use router_env::{instrument, tracing}; use super::{MockDb, Store}; @@ -41,8 +41,7 @@ impl AuthorizationInterface for Store { authorization .insert(&conn) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -54,8 +53,7 @@ impl AuthorizationInterface for Store { let conn = connection::pg_connection_read(self).await?; storage::Authorization::find_by_merchant_id_payment_id(&conn, merchant_id, payment_id) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -73,8 +71,7 @@ impl AuthorizationInterface for Store { authorization, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } } diff --git a/crates/router/src/db/blocklist.rs b/crates/router/src/db/blocklist.rs index 083c988b8d5b..4a7236c95a7a 100644 --- a/crates/router/src/db/blocklist.rs +++ b/crates/router/src/db/blocklist.rs @@ -1,4 +1,4 @@ -use error_stack::IntoReport; +use error_stack::report; use router_env::{instrument, tracing}; use storage_impl::MockDb; @@ -54,8 +54,7 @@ impl BlocklistInterface for Store { pm_blocklist .insert(&conn) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -67,8 +66,7 @@ impl BlocklistInterface for Store { let conn = connection::pg_connection_write(self).await?; storage::Blocklist::find_by_merchant_id_fingerprint_id(&conn, merchant_id, fingerprint_id) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -79,8 +77,7 @@ impl BlocklistInterface for Store { let conn = connection::pg_connection_write(self).await?; storage::Blocklist::list_by_merchant_id(&conn, merchant_id) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -100,8 +97,7 @@ impl BlocklistInterface for Store { offset, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -113,8 +109,7 @@ impl BlocklistInterface for Store { let conn = connection::pg_connection_write(self).await?; storage::Blocklist::delete_by_merchant_id_fingerprint_id(&conn, merchant_id, fingerprint_id) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } } diff --git a/crates/router/src/db/blocklist_fingerprint.rs b/crates/router/src/db/blocklist_fingerprint.rs index 1be6f60e8770..65671555c7f8 100644 --- a/crates/router/src/db/blocklist_fingerprint.rs +++ b/crates/router/src/db/blocklist_fingerprint.rs @@ -1,4 +1,4 @@ -use error_stack::IntoReport; +use error_stack::report; use router_env::{instrument, tracing}; use storage_impl::MockDb; @@ -35,8 +35,7 @@ impl BlocklistFingerprintInterface for Store { pm_fingerprint_new .insert(&conn) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -52,8 +51,7 @@ impl BlocklistFingerprintInterface for Store { fingerprint_id, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } } diff --git a/crates/router/src/db/blocklist_lookup.rs b/crates/router/src/db/blocklist_lookup.rs index ad8315b757d5..0f796946beb5 100644 --- a/crates/router/src/db/blocklist_lookup.rs +++ b/crates/router/src/db/blocklist_lookup.rs @@ -1,4 +1,4 @@ -use error_stack::IntoReport; +use error_stack::report; use router_env::{instrument, tracing}; use storage_impl::MockDb; @@ -41,8 +41,7 @@ impl BlocklistLookupInterface for Store { blocklist_lookup_entry .insert(&conn) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -54,8 +53,7 @@ impl BlocklistLookupInterface for Store { let conn = connection::pg_connection_read(self).await?; storage::BlocklistLookup::find_by_merchant_id_fingerprint(&conn, merchant_id, fingerprint) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -67,8 +65,7 @@ impl BlocklistLookupInterface for Store { let conn = connection::pg_connection_write(self).await?; storage::BlocklistLookup::delete_by_merchant_id_fingerprint(&conn, merchant_id, fingerprint) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } } diff --git a/crates/router/src/db/business_profile.rs b/crates/router/src/db/business_profile.rs index e0e004645410..4d5a94b370a6 100644 --- a/crates/router/src/db/business_profile.rs +++ b/crates/router/src/db/business_profile.rs @@ -1,4 +1,4 @@ -use error_stack::IntoReport; +use error_stack::report; use router_env::{instrument, tracing}; use super::Store; @@ -56,8 +56,7 @@ impl BusinessProfileInterface for Store { business_profile .insert(&conn) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -68,8 +67,7 @@ impl BusinessProfileInterface for Store { let conn = connection::pg_connection_read(self).await?; storage::business_profile::BusinessProfile::find_by_profile_id(&conn, profile_id) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -85,8 +83,7 @@ impl BusinessProfileInterface for Store { merchant_id, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -102,8 +99,7 @@ impl BusinessProfileInterface for Store { business_profile_update, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -119,8 +115,7 @@ impl BusinessProfileInterface for Store { merchant_id, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -134,8 +129,7 @@ impl BusinessProfileInterface for Store { merchant_id, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } } diff --git a/crates/router/src/db/capture.rs b/crates/router/src/db/capture.rs index 1373b45c2cd7..48aad6a9e3f0 100644 --- a/crates/router/src/db/capture.rs +++ b/crates/router/src/db/capture.rs @@ -32,7 +32,7 @@ pub trait CaptureInterface { #[cfg(feature = "kv_store")] mod storage { - use error_stack::IntoReport; + use error_stack::report; use router_env::{instrument, tracing}; use super::CaptureInterface; @@ -56,8 +56,7 @@ mod storage { capture .insert(&conn) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) }; db_call().await } @@ -73,8 +72,7 @@ mod storage { let conn = connection::pg_connection_write(self).await?; this.update_with_capture_id(&conn, capture) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) }; db_call().await } @@ -96,8 +94,7 @@ mod storage { &conn, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) }; db_call().await } @@ -106,7 +103,7 @@ mod storage { #[cfg(not(feature = "kv_store"))] mod storage { - use error_stack::IntoReport; + use error_stack::report; use router_env::{instrument, tracing}; use super::CaptureInterface; @@ -130,8 +127,7 @@ mod storage { capture .insert(&conn) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) }; db_call().await } @@ -147,8 +143,7 @@ mod storage { let conn = connection::pg_connection_write(self).await?; this.update_with_capture_id(&conn, capture) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) }; db_call().await } @@ -170,8 +165,7 @@ mod storage { &conn, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) }; db_call().await } diff --git a/crates/router/src/db/cards_info.rs b/crates/router/src/db/cards_info.rs index 97a0c6c7c7f7..68bd90946b61 100644 --- a/crates/router/src/db/cards_info.rs +++ b/crates/router/src/db/cards_info.rs @@ -1,4 +1,4 @@ -use error_stack::IntoReport; +use error_stack::report; use router_env::{instrument, tracing}; use crate::{ @@ -27,8 +27,7 @@ impl CardsInfoInterface for Store { let conn = connection::pg_connection_read(self).await?; CardInfo::find_by_iin(&conn, card_iin) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } } diff --git a/crates/router/src/db/configs.rs b/crates/router/src/db/configs.rs index 3f49254ae446..8deb4bdf6f66 100644 --- a/crates/router/src/db/configs.rs +++ b/crates/router/src/db/configs.rs @@ -1,6 +1,6 @@ use common_utils::ext_traits::AsyncExt; use diesel_models::configs::ConfigUpdateInternal; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use router_env::{instrument, tracing}; use storage_impl::redis::{ cache::{CacheKind, CONFIG_CACHE}, @@ -65,7 +65,10 @@ impl ConfigInterface for Store { config: storage::ConfigNew, ) -> CustomResult { let conn = connection::pg_connection_write(self).await?; - config.insert(&conn).await.map_err(Into::into).into_report() + config + .insert(&conn) + .await + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -77,8 +80,7 @@ impl ConfigInterface for Store { let conn = connection::pg_connection_write(self).await?; storage::Config::update_by_key(&conn, key, config_update) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } //update in DB and remove in redis and cache @@ -102,8 +104,7 @@ impl ConfigInterface for Store { let conn = connection::pg_connection_write(self).await?; storage::Config::find_by_key(&conn, key) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } //check in cache, then redis then finally DB, and on the way back populate redis and cache @@ -116,8 +117,7 @@ impl ConfigInterface for Store { let conn = connection::pg_connection_write(self).await?; storage::Config::find_by_key(&conn, key) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) }; cache::get_or_populate_in_memory(self, key, find_config_by_key_from_db, &CONFIG_CACHE).await } @@ -133,8 +133,7 @@ impl ConfigInterface for Store { let conn = connection::pg_connection_write(self).await?; match storage::Config::find_by_key(&conn, key) .await - .map_err(Into::::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) { Ok(a) => Ok(a), Err(err) => { @@ -148,8 +147,7 @@ impl ConfigInterface for Store { } .insert(&conn) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) }) .await } else { @@ -170,8 +168,7 @@ impl ConfigInterface for Store { let conn = connection::pg_connection_write(self).await?; let deleted = storage::Config::delete_by_key(&conn, key) .await - .map_err(Into::into) - .into_report()?; + .map_err(|error| report!(errors::StorageError::from(error)))?; self.get_redis_conn() .map_err(Into::::into)? @@ -193,11 +190,7 @@ impl ConfigInterface for MockDb { let mut configs = self.configs.lock().await; let config_new = storage::Config { - id: configs - .len() - .try_into() - .into_report() - .change_context(errors::StorageError::MockDbError)?, + id: i32::try_from(configs.len()).change_context(errors::StorageError::MockDbError)?, key: config.key, config: config.config, }; diff --git a/crates/router/src/db/customers.rs b/crates/router/src/db/customers.rs index 9385e237e695..081a41e00734 100644 --- a/crates/router/src/db/customers.rs +++ b/crates/router/src/db/customers.rs @@ -1,5 +1,5 @@ use common_utils::ext_traits::AsyncExt; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use futures::future::try_join_all; use masking::PeekInterface; use router_env::{instrument, tracing}; @@ -83,8 +83,7 @@ impl CustomerInterface for Store { merchant_id, ) .await - .map_err(Into::into) - .into_report()? + .map_err(|error| report!(errors::StorageError::from(error)))? .async_map(|c| async { c.convert(key_store.key.get_inner()) .await @@ -120,8 +119,7 @@ impl CustomerInterface for Store { customer.into(), ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) .async_and_then(|c| async { c.convert(key_store.key.get_inner()) .await @@ -141,8 +139,7 @@ impl CustomerInterface for Store { let customer: domain::Customer = storage::Customer::find_by_customer_id_merchant_id(&conn, customer_id, merchant_id) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) .async_and_then(|c| async { c.convert(key_store.key.get_inner()) .await @@ -167,8 +164,7 @@ impl CustomerInterface for Store { let encrypted_customers = storage::Customer::list_by_merchant_id(&conn, merchant_id) .await - .map_err(Into::into) - .into_report()?; + .map_err(|error| report!(errors::StorageError::from(error)))?; let customers = try_join_all(encrypted_customers.into_iter().map( |encrypted_customer| async { @@ -196,8 +192,7 @@ impl CustomerInterface for Store { .change_context(errors::StorageError::EncryptionError)? .insert(&conn) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) .async_and_then(|c| async { c.convert(key_store.key.get_inner()) .await @@ -215,8 +210,7 @@ impl CustomerInterface for Store { let conn = connection::pg_connection_write(self).await?; storage::Customer::delete_by_customer_id_merchant_id(&conn, customer_id, merchant_id) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } } diff --git a/crates/router/src/db/dashboard_metadata.rs b/crates/router/src/db/dashboard_metadata.rs index fee09870d597..5267985e1acd 100644 --- a/crates/router/src/db/dashboard_metadata.rs +++ b/crates/router/src/db/dashboard_metadata.rs @@ -1,5 +1,5 @@ use diesel_models::{enums, user::dashboard_metadata as storage}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use router_env::{instrument, tracing}; use storage_impl::MockDb; @@ -65,8 +65,7 @@ impl DashboardMetadataInterface for Store { metadata .insert(&conn) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -88,8 +87,7 @@ impl DashboardMetadataInterface for Store { dashboard_metadata_update, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -109,8 +107,7 @@ impl DashboardMetadataInterface for Store { data_keys, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -128,8 +125,7 @@ impl DashboardMetadataInterface for Store { data_keys, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -145,8 +141,7 @@ impl DashboardMetadataInterface for Store { merchant_id.to_owned(), ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -164,8 +159,7 @@ impl DashboardMetadataInterface for Store { data_key, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } } @@ -188,10 +182,7 @@ impl DashboardMetadataInterface for MockDb { })? } let metadata_new = storage::DashboardMetadata { - id: dashboard_metadata - .len() - .try_into() - .into_report() + id: i32::try_from(dashboard_metadata.len()) .change_context(errors::StorageError::MockDbError)?, user_id: metadata.user_id, merchant_id: metadata.merchant_id, diff --git a/crates/router/src/db/dispute.rs b/crates/router/src/db/dispute.rs index b0d0594c0135..0fe5f3d76664 100644 --- a/crates/router/src/db/dispute.rs +++ b/crates/router/src/db/dispute.rs @@ -1,4 +1,4 @@ -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use router_env::{instrument, tracing}; use super::{MockDb, Store}; @@ -58,8 +58,7 @@ impl DisputeInterface for Store { dispute .insert(&conn) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -77,8 +76,7 @@ impl DisputeInterface for Store { connector_dispute_id, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -90,8 +88,7 @@ impl DisputeInterface for Store { let conn = connection::pg_connection_read(self).await?; storage::Dispute::find_by_merchant_id_dispute_id(&conn, merchant_id, dispute_id) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -103,8 +100,7 @@ impl DisputeInterface for Store { let conn = connection::pg_connection_read(self).await?; storage::Dispute::filter_by_constraints(&conn, merchant_id, dispute_constraints) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -116,8 +112,7 @@ impl DisputeInterface for Store { let conn = connection::pg_connection_read(self).await?; storage::Dispute::find_by_merchant_id_payment_id(&conn, merchant_id, payment_id) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -129,8 +124,7 @@ impl DisputeInterface for Store { let conn = connection::pg_connection_write(self).await?; this.update(&conn, dispute) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } } @@ -154,10 +148,7 @@ impl DisputeInterface for MockDb { let now = common_utils::date_time::now(); let new_dispute = storage::Dispute { - id: locked_disputes - .len() - .try_into() - .into_report() + id: i32::try_from(locked_disputes.len()) .change_context(errors::StorageError::MockDbError)?, dispute_id: dispute.dispute_id, amount: dispute.amount, diff --git a/crates/router/src/db/events.rs b/crates/router/src/db/events.rs index f3df72780297..53480ed431b6 100644 --- a/crates/router/src/db/events.rs +++ b/crates/router/src/db/events.rs @@ -1,5 +1,5 @@ use common_utils::ext_traits::AsyncExt; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use router_env::{instrument, tracing}; use super::{MockDb, Store}; @@ -106,8 +106,7 @@ impl EventInterface for Store { .change_context(errors::StorageError::EncryptionError)? .insert(&conn) .await - .map_err(Into::into) - .into_report()? + .map_err(|error| report!(errors::StorageError::from(error)))? .convert(merchant_key_store.key.get_inner()) .await .change_context(errors::StorageError::DecryptionError) @@ -123,8 +122,7 @@ impl EventInterface for Store { let conn = connection::pg_connection_read(self).await?; storage::Event::find_by_merchant_id_event_id(&conn, merchant_id, event_id) .await - .map_err(Into::into) - .into_report()? + .map_err(|error| report!(errors::StorageError::from(error)))? .convert(merchant_key_store.key.get_inner()) .await .change_context(errors::StorageError::DecryptionError) @@ -144,8 +142,7 @@ impl EventInterface for Store { primary_object_id, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) .async_and_then(|events| async { let mut domain_events = Vec::with_capacity(events.len()); for event in events.into_iter() { @@ -181,8 +178,7 @@ impl EventInterface for Store { offset, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) .async_and_then(|events| async { let mut domain_events = Vec::with_capacity(events.len()); for event in events.into_iter() { @@ -212,8 +208,7 @@ impl EventInterface for Store { initial_attempt_id, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) .async_and_then(|events| async { let mut domain_events = Vec::with_capacity(events.len()); for event in events.into_iter() { @@ -243,8 +238,7 @@ impl EventInterface for Store { primary_object_id, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) .async_and_then(|events| async { let mut domain_events = Vec::with_capacity(events.len()); for event in events.into_iter() { @@ -280,8 +274,7 @@ impl EventInterface for Store { offset, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) .async_and_then(|events| async { let mut domain_events = Vec::with_capacity(events.len()); for event in events.into_iter() { @@ -307,8 +300,7 @@ impl EventInterface for Store { let conn = connection::pg_connection_read(self).await?; storage::Event::list_by_profile_id_initial_attempt_id(&conn, profile_id, initial_attempt_id) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) .async_and_then(|events| async { let mut domain_events = Vec::with_capacity(events.len()); for event in events.into_iter() { @@ -335,8 +327,7 @@ impl EventInterface for Store { let conn = connection::pg_connection_write(self).await?; storage::Event::update_by_merchant_id_event_id(&conn, merchant_id, event_id, event.into()) .await - .map_err(Into::into) - .into_report()? + .map_err(|error| report!(errors::StorageError::from(error)))? .convert(merchant_key_store.key.get_inner()) .await .change_context(errors::StorageError::DecryptionError) diff --git a/crates/router/src/db/file.rs b/crates/router/src/db/file.rs index ffd18336efa2..da28404971d4 100644 --- a/crates/router/src/db/file.rs +++ b/crates/router/src/db/file.rs @@ -1,4 +1,4 @@ -use error_stack::IntoReport; +use error_stack::report; use router_env::{instrument, tracing}; use super::{MockDb, Store}; @@ -42,7 +42,9 @@ impl FileMetadataInterface for Store { file: storage::FileMetadataNew, ) -> CustomResult { let conn = connection::pg_connection_write(self).await?; - file.insert(&conn).await.map_err(Into::into).into_report() + file.insert(&conn) + .await + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -54,8 +56,7 @@ impl FileMetadataInterface for Store { let conn = connection::pg_connection_read(self).await?; storage::FileMetadata::find_by_merchant_id_file_id(&conn, merchant_id, file_id) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -67,8 +68,7 @@ impl FileMetadataInterface for Store { let conn = connection::pg_connection_write(self).await?; storage::FileMetadata::delete_by_merchant_id_file_id(&conn, merchant_id, file_id) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -80,8 +80,7 @@ impl FileMetadataInterface for Store { let conn = connection::pg_connection_write(self).await?; this.update(&conn, file_metadata) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } } diff --git a/crates/router/src/db/fraud_check.rs b/crates/router/src/db/fraud_check.rs index 656cac0adb54..348182603645 100644 --- a/crates/router/src/db/fraud_check.rs +++ b/crates/router/src/db/fraud_check.rs @@ -1,5 +1,5 @@ use diesel_models::fraud_check::{self as storage, FraudCheck, FraudCheckUpdate}; -use error_stack::IntoReport; +use error_stack::report; use router_env::{instrument, tracing}; use super::MockDb; @@ -43,7 +43,9 @@ impl FraudCheckInterface for Store { new: storage::FraudCheckNew, ) -> CustomResult { let conn = connection::pg_connection_write(self).await?; - new.insert(&conn).await.map_err(Into::into).into_report() + new.insert(&conn) + .await + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -55,8 +57,7 @@ impl FraudCheckInterface for Store { let conn = connection::pg_connection_write(self).await?; this.update_with_attempt_id(&conn, fraud_check) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -68,8 +69,7 @@ impl FraudCheckInterface for Store { let conn = connection::pg_connection_write(self).await?; FraudCheck::get_with_payment_id(&conn, payment_id, merchant_id) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -81,8 +81,7 @@ impl FraudCheckInterface for Store { let conn = connection::pg_connection_write(self).await?; FraudCheck::get_with_payment_id_if_present(&conn, payment_id, merchant_id) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } } diff --git a/crates/router/src/db/gsm.rs b/crates/router/src/db/gsm.rs index 4a9cf651d2b4..1aa96e14c187 100644 --- a/crates/router/src/db/gsm.rs +++ b/crates/router/src/db/gsm.rs @@ -1,5 +1,5 @@ use diesel_models::gsm as storage; -use error_stack::IntoReport; +use error_stack::report; use router_env::{instrument, tracing}; use super::MockDb; @@ -59,7 +59,9 @@ impl GsmInterface for Store { rule: storage::GatewayStatusMappingNew, ) -> CustomResult { let conn = connection::pg_connection_write(self).await?; - rule.insert(&conn).await.map_err(Into::into).into_report() + rule.insert(&conn) + .await + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -76,8 +78,7 @@ impl GsmInterface for Store { &conn, connector, flow, sub_flow, code, message, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -92,8 +93,7 @@ impl GsmInterface for Store { let conn = connection::pg_connection_read(self).await?; storage::GatewayStatusMap::find(&conn, connector, flow, sub_flow, code, message) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -109,8 +109,7 @@ impl GsmInterface for Store { let conn = connection::pg_connection_write(self).await?; storage::GatewayStatusMap::update(&conn, connector, flow, sub_flow, code, message, data) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -125,8 +124,7 @@ impl GsmInterface for Store { let conn = connection::pg_connection_write(self).await?; storage::GatewayStatusMap::delete(&conn, connector, flow, sub_flow, code, message) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } } diff --git a/crates/router/src/db/locker_mock_up.rs b/crates/router/src/db/locker_mock_up.rs index d70c6baa815c..ea0e70c5bb90 100644 --- a/crates/router/src/db/locker_mock_up.rs +++ b/crates/router/src/db/locker_mock_up.rs @@ -1,4 +1,4 @@ -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use router_env::{instrument, tracing}; use super::{MockDb, Store}; @@ -36,8 +36,7 @@ impl LockerMockUpInterface for Store { let conn = connection::pg_connection_read(self).await?; storage::LockerMockUp::find_by_card_id(&conn, card_id) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -46,7 +45,9 @@ impl LockerMockUpInterface for Store { new: storage::LockerMockUpNew, ) -> CustomResult { let conn = connection::pg_connection_write(self).await?; - new.insert(&conn).await.map_err(Into::into).into_report() + new.insert(&conn) + .await + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -57,8 +58,7 @@ impl LockerMockUpInterface for Store { let conn = connection::pg_connection_write(self).await?; storage::LockerMockUp::delete_by_card_id(&conn, card_id) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } } @@ -88,10 +88,7 @@ impl LockerMockUpInterface for MockDb { } let created_locker = storage::LockerMockUp { - id: locked_lockers - .len() - .try_into() - .into_report() + id: i32::try_from(locked_lockers.len()) .change_context(errors::StorageError::MockDbError)?, card_id: new.card_id, external_id: new.external_id, diff --git a/crates/router/src/db/mandate.rs b/crates/router/src/db/mandate.rs index 936344f5af5e..273d34a68af8 100644 --- a/crates/router/src/db/mandate.rs +++ b/crates/router/src/db/mandate.rs @@ -1,4 +1,4 @@ -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use router_env::{instrument, tracing}; use super::{MockDb, Store}; @@ -58,8 +58,7 @@ impl MandateInterface for Store { let conn = connection::pg_connection_read(self).await?; storage::Mandate::find_by_merchant_id_mandate_id(&conn, merchant_id, mandate_id) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -75,8 +74,7 @@ impl MandateInterface for Store { connector_mandate_id, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -88,8 +86,7 @@ impl MandateInterface for Store { let conn = connection::pg_connection_read(self).await?; storage::Mandate::find_by_merchant_id_customer_id(&conn, merchant_id, customer_id) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -102,8 +99,7 @@ impl MandateInterface for Store { let conn = connection::pg_connection_write(self).await?; storage::Mandate::update_by_merchant_id_mandate_id(&conn, merchant_id, mandate_id, mandate) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -115,8 +111,7 @@ impl MandateInterface for Store { let conn = connection::pg_connection_read(self).await?; storage::Mandate::filter_by_constraints(&conn, merchant_id, mandate_constraints) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -128,8 +123,7 @@ impl MandateInterface for Store { mandate .insert(&conn) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } } @@ -288,11 +282,7 @@ impl MandateInterface for MockDb { ) -> CustomResult { let mut mandates = self.mandates.lock().await; let mandate = storage::Mandate { - id: mandates - .len() - .try_into() - .into_report() - .change_context(errors::StorageError::MockDbError)?, + id: i32::try_from(mandates.len()).change_context(errors::StorageError::MockDbError)?, mandate_id: mandate_new.mandate_id.clone(), customer_id: mandate_new.customer_id, merchant_id: mandate_new.merchant_id, diff --git a/crates/router/src/db/merchant_account.rs b/crates/router/src/db/merchant_account.rs index 3ecf897148e7..08d0c2790473 100644 --- a/crates/router/src/db/merchant_account.rs +++ b/crates/router/src/db/merchant_account.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use common_utils::ext_traits::AsyncExt; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use router_env::{instrument, tracing}; #[cfg(feature = "accounts_cache")] use storage_impl::redis::cache::{CacheKind, ACCOUNTS_CACHE}; @@ -92,8 +92,7 @@ impl MerchantAccountInterface for Store { .change_context(errors::StorageError::EncryptionError)? .insert(&conn) .await - .map_err(Into::into) - .into_report()? + .map_err(|error| report!(errors::StorageError::from(error)))? .convert(merchant_key_store.key.get_inner()) .await .change_context(errors::StorageError::DecryptionError) @@ -109,8 +108,7 @@ impl MerchantAccountInterface for Store { let conn = connection::pg_connection_read(self).await?; storage::MerchantAccount::find_by_merchant_id(&conn, merchant_id) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) }; #[cfg(not(feature = "accounts_cache"))] @@ -146,8 +144,7 @@ impl MerchantAccountInterface for Store { .change_context(errors::StorageError::EncryptionError)? .update(&conn, merchant_account.into()) .await - .map_err(Into::into) - .into_report()?; + .map_err(|error| report!(errors::StorageError::from(error)))?; #[cfg(feature = "accounts_cache")] { @@ -173,8 +170,7 @@ impl MerchantAccountInterface for Store { merchant_account.into(), ) .await - .map_err(Into::into) - .into_report()?; + .map_err(|error| report!(errors::StorageError::from(error)))?; #[cfg(feature = "accounts_cache")] { @@ -196,8 +192,7 @@ impl MerchantAccountInterface for Store { storage::MerchantAccount::find_by_publishable_key(&conn, publishable_key) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) }; let merchant_account; @@ -245,8 +240,7 @@ impl MerchantAccountInterface for Store { let encrypted_merchant_accounts = storage::MerchantAccount::list_by_organization_id(&conn, organization_id) .await - .map_err(Into::into) - .into_report()?; + .map_err(|error| report!(errors::StorageError::from(error)))?; let db_master_key = self.get_master_key().to_vec().into(); @@ -285,8 +279,7 @@ impl MerchantAccountInterface for Store { let is_deleted_func = || async { storage::MerchantAccount::delete_by_merchant_id(&conn, merchant_id) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) }; let is_deleted; @@ -301,8 +294,7 @@ impl MerchantAccountInterface for Store { let merchant_account = storage::MerchantAccount::find_by_merchant_id(&conn, merchant_id) .await - .map_err(Into::into) - .into_report()?; + .map_err(|error| report!(errors::StorageError::from(error)))?; is_deleted = is_deleted_func().await?; @@ -323,8 +315,7 @@ impl MerchantAccountInterface for Store { let encrypted_merchant_accounts = storage::MerchantAccount::list_multiple_merchant_accounts(&conn, merchant_ids) .await - .map_err(Into::into) - .into_report()?; + .map_err(|error| report!(errors::StorageError::from(error)))?; let db_master_key = self.get_master_key().to_vec().into(); @@ -375,11 +366,7 @@ impl MerchantAccountInterface for MockDb { ) -> CustomResult { let mut accounts = self.merchant_accounts.lock().await; merchant_account.id.get_or_insert( - accounts - .len() - .try_into() - .into_report() - .change_context(errors::StorageError::MockDbError)?, + i32::try_from(accounts.len()).change_context(errors::StorageError::MockDbError)?, ); let account = Conversion::convert(merchant_account) .await diff --git a/crates/router/src/db/merchant_connector_account.rs b/crates/router/src/db/merchant_connector_account.rs index e4cad30ec29e..b7c855608044 100644 --- a/crates/router/src/db/merchant_connector_account.rs +++ b/crates/router/src/db/merchant_connector_account.rs @@ -1,5 +1,5 @@ use common_utils::ext_traits::{AsyncExt, ByteSliceExt, Encode}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use router_env::{instrument, tracing}; #[cfg(feature = "accounts_cache")] use storage_impl::redis::cache; @@ -183,8 +183,7 @@ impl MerchantConnectorAccountInterface for Store { connector_label, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) }; #[cfg(not(feature = "accounts_cache"))] @@ -229,8 +228,7 @@ impl MerchantConnectorAccountInterface for Store { connector_name, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) }; #[cfg(not(feature = "accounts_cache"))] @@ -274,8 +272,7 @@ impl MerchantConnectorAccountInterface for Store { connector_name, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) .async_and_then(|items| async { let mut output = Vec::with_capacity(items.len()); for item in items.into_iter() { @@ -305,8 +302,7 @@ impl MerchantConnectorAccountInterface for Store { merchant_connector_id, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) }; #[cfg(not(feature = "accounts_cache"))] @@ -345,8 +341,7 @@ impl MerchantConnectorAccountInterface for Store { .change_context(errors::StorageError::EncryptionError)? .insert(&conn) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) .async_and_then(|item| async { item.convert(key_store.key.get_inner()) .await @@ -365,8 +360,7 @@ impl MerchantConnectorAccountInterface for Store { let conn = connection::pg_connection_read(self).await?; storage::MerchantConnectorAccount::find_by_merchant_id(&conn, merchant_id, get_disabled) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) .async_and_then(|items| async { let mut output = Vec::with_capacity(items.len()); for item in items.into_iter() { @@ -406,8 +400,7 @@ impl MerchantConnectorAccountInterface for Store { .change_context(errors::StorageError::EncryptionError)? .update(&conn, merchant_connector_account) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) .async_and_then(|item| async { item.convert(key_store.key.get_inner()) .await @@ -454,8 +447,7 @@ impl MerchantConnectorAccountInterface for Store { merchant_connector_id, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) }; #[cfg(feature = "accounts_cache")] @@ -471,8 +463,7 @@ impl MerchantConnectorAccountInterface for Store { merchant_connector_id, ) .await - .map_err(Into::into) - .into_report()?; + .map_err(|error| report!(errors::StorageError::from(error)))?; let _profile_id = mca.profile_id.ok_or(errors::StorageError::ValueNotFound( "profile_id".to_string(), @@ -628,11 +619,7 @@ impl MerchantConnectorAccountInterface for MockDb { ) -> CustomResult { let mut accounts = self.merchant_connector_accounts.lock().await; let account = storage::MerchantConnectorAccount { - id: accounts - .len() - .try_into() - .into_report() - .change_context(errors::StorageError::MockDbError)?, + id: i32::try_from(accounts.len()).change_context(errors::StorageError::MockDbError)?, merchant_id: t.merchant_id, connector_name: t.connector_name, connector_account_details: t.connector_account_details.into(), diff --git a/crates/router/src/db/merchant_key_store.rs b/crates/router/src/db/merchant_key_store.rs index e3d81302cb95..f857ab9d61e0 100644 --- a/crates/router/src/db/merchant_key_store.rs +++ b/crates/router/src/db/merchant_key_store.rs @@ -1,4 +1,4 @@ -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use masking::Secret; use router_env::{instrument, tracing}; #[cfg(feature = "accounts_cache")] @@ -57,8 +57,7 @@ impl MerchantKeyStoreInterface for Store { .change_context(errors::StorageError::EncryptionError)? .insert(&conn) .await - .map_err(Into::into) - .into_report()? + .map_err(|error| report!(errors::StorageError::from(error)))? .convert(key) .await .change_context(errors::StorageError::DecryptionError) @@ -78,8 +77,7 @@ impl MerchantKeyStoreInterface for Store { merchant_id, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) }; #[cfg(not(feature = "accounts_cache"))] @@ -119,8 +117,7 @@ impl MerchantKeyStoreInterface for Store { merchant_id, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) }; #[cfg(not(feature = "accounts_cache"))] @@ -155,8 +152,7 @@ impl MerchantKeyStoreInterface for Store { merchant_ids, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) }; futures::future::try_join_all(fetch_func().await?.into_iter().map(|key_store| async { diff --git a/crates/router/src/db/organization.rs b/crates/router/src/db/organization.rs index 63e4a0e8cd37..0fe9ea9a1803 100644 --- a/crates/router/src/db/organization.rs +++ b/crates/router/src/db/organization.rs @@ -1,6 +1,6 @@ use common_utils::errors::CustomResult; use diesel_models::organization as storage; -use error_stack::IntoReport; +use error_stack::report; use router_env::{instrument, tracing}; use crate::{connection, core::errors, services::Store}; @@ -35,8 +35,7 @@ impl OrganizationInterface for Store { organization .insert(&conn) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -47,8 +46,7 @@ impl OrganizationInterface for Store { let conn = connection::pg_connection_read(self).await?; storage::Organization::find_by_org_id(&conn, org_id.to_string()) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -61,8 +59,7 @@ impl OrganizationInterface for Store { storage::Organization::update_by_org_id(&conn, org_id.to_string(), update) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } } diff --git a/crates/router/src/db/payment_link.rs b/crates/router/src/db/payment_link.rs index 1a85de9e8826..c3f787679313 100644 --- a/crates/router/src/db/payment_link.rs +++ b/crates/router/src/db/payment_link.rs @@ -1,4 +1,4 @@ -use error_stack::IntoReport; +use error_stack::report; use router_env::{instrument, tracing}; use crate::{ @@ -38,8 +38,7 @@ impl PaymentLinkInterface for Store { let conn = connection::pg_connection_read(self).await?; storage::PaymentLink::find_link_by_payment_link_id(&conn, payment_link_id) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -51,8 +50,7 @@ impl PaymentLinkInterface for Store { payment_link_config .insert(&conn) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -64,8 +62,7 @@ impl PaymentLinkInterface for Store { let conn = connection::pg_connection_read(self).await?; storage::PaymentLink::filter_by_constraints(&conn, merchant_id, payment_link_constraints) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } } diff --git a/crates/router/src/db/payment_method.rs b/crates/router/src/db/payment_method.rs index 94ebee178934..14f650127dd6 100644 --- a/crates/router/src/db/payment_method.rs +++ b/crates/router/src/db/payment_method.rs @@ -1,5 +1,5 @@ use diesel_models::payment_method::PaymentMethodUpdateInternal; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use router_env::{instrument, tracing}; use super::{MockDb, Store}; @@ -71,8 +71,7 @@ impl PaymentMethodInterface for Store { let conn = connection::pg_connection_read(self).await?; storage::PaymentMethod::find_by_payment_method_id(&conn, payment_method_id) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -83,8 +82,7 @@ impl PaymentMethodInterface for Store { let conn = connection::pg_connection_read(self).await?; storage::PaymentMethod::find_by_locker_id(&conn, locker_id) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -102,8 +100,7 @@ impl PaymentMethodInterface for Store { status, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -115,8 +112,7 @@ impl PaymentMethodInterface for Store { payment_method_new .insert(&conn) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -129,8 +125,7 @@ impl PaymentMethodInterface for Store { payment_method .update_with_payment_method_id(&conn, payment_method_update) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -148,8 +143,7 @@ impl PaymentMethodInterface for Store { limit, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -169,8 +163,7 @@ impl PaymentMethodInterface for Store { limit, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } async fn delete_payment_method_by_merchant_id_payment_method_id( @@ -185,8 +178,7 @@ impl PaymentMethodInterface for Store { payment_method_id, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } } @@ -245,10 +237,7 @@ impl PaymentMethodInterface for MockDb { && pm.status == status }) .count(); - count - .try_into() - .into_report() - .change_context(errors::StorageError::MockDbError) + i64::try_from(count).change_context(errors::StorageError::MockDbError) } async fn insert_payment_method( @@ -258,10 +247,7 @@ impl PaymentMethodInterface for MockDb { let mut payment_methods = self.payment_methods.lock().await; let payment_method = storage::PaymentMethod { - id: payment_methods - .len() - .try_into() - .into_report() + id: i32::try_from(payment_methods.len()) .change_context(errors::StorageError::MockDbError)?, customer_id: payment_method_new.customer_id, merchant_id: payment_method_new.merchant_id, @@ -336,10 +322,10 @@ impl PaymentMethodInterface for MockDb { .collect(); if payment_methods_found.is_empty() { - Err(errors::StorageError::ValueNotFound( - "cannot find payment methods".to_string(), - )) - .into_report() + Err( + errors::StorageError::ValueNotFound("cannot find payment methods".to_string()) + .into(), + ) } else { Ok(payment_methods_found) } diff --git a/crates/router/src/db/refund.rs b/crates/router/src/db/refund.rs index cc2d7e8b7b98..c62f8469515a 100644 --- a/crates/router/src/db/refund.rs +++ b/crates/router/src/db/refund.rs @@ -2,7 +2,7 @@ use std::collections::HashSet; use diesel_models::{errors::DatabaseError, refund::RefundUpdateInternal}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use super::MockDb; use crate::{ @@ -93,7 +93,7 @@ pub trait RefundInterface { #[cfg(not(feature = "kv_store"))] mod storage { - use error_stack::IntoReport; + use error_stack::report; use router_env::{instrument, tracing}; use super::RefundInterface; @@ -120,8 +120,7 @@ mod storage { merchant_id, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -131,7 +130,9 @@ mod storage { _storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult { let conn = connection::pg_connection_write(self).await?; - new.insert(&conn).await.map_err(Into::into).into_report() + new.insert(&conn) + .await + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -148,8 +149,7 @@ mod storage { connector_transaction_id, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -162,8 +162,7 @@ mod storage { let conn = connection::pg_connection_write(self).await?; this.update(&conn, refund) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -176,8 +175,7 @@ mod storage { let conn = connection::pg_connection_read(self).await?; storage_types::Refund::find_by_merchant_id_refund_id(&conn, merchant_id, refund_id) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -196,8 +194,7 @@ mod storage { connector, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -210,8 +207,7 @@ mod storage { let conn = connection::pg_connection_read(self).await?; storage_types::Refund::find_by_payment_id_merchant_id(&conn, payment_id, merchant_id) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[cfg(feature = "olap")] @@ -233,8 +229,7 @@ mod storage { offset, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[cfg(feature = "olap")] @@ -252,8 +247,7 @@ mod storage { refund_details, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error|report!(errors::StorageError::from(error))) } #[cfg(feature = "olap")] #[instrument(skip_all)] @@ -270,8 +264,7 @@ mod storage { refund_details, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } } } @@ -279,7 +272,7 @@ mod storage { #[cfg(feature = "kv_store")] mod storage { use common_utils::{date_time, ext_traits::Encode, fallback_reverse_lookup_not_found}; - use error_stack::{IntoReport, ResultExt}; + use error_stack::{report, ResultExt}; use redis_interface::HsetnxReply; use router_env::{instrument, tracing}; use storage_impl::redis::kv_store::{kv_wrapper, KvOperation}; @@ -310,8 +303,7 @@ mod storage { merchant_id, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) }; match storage_scheme { enums::MerchantStorageScheme::PostgresOnly => database_call().await, @@ -350,7 +342,9 @@ mod storage { match storage_scheme { enums::MerchantStorageScheme::PostgresOnly => { let conn = connection::pg_connection_write(self).await?; - new.insert(&conn).await.map_err(Into::into).into_report() + new.insert(&conn) + .await + .map_err(|error| report!(errors::StorageError::from(error))) } enums::MerchantStorageScheme::RedisKv => { let key = format!("mid_{}_pid_{}", new.merchant_id, new.payment_id); @@ -457,8 +451,8 @@ mod storage { Ok(HsetnxReply::KeyNotSet) => Err(errors::StorageError::DuplicateValue { entity: "refund", key: Some(created_refund.refund_id), - }) - .into_report(), + } + .into()), Ok(HsetnxReply::KeySet) => Ok(created_refund), Err(er) => Err(er).change_context(errors::StorageError::KVError), } @@ -481,8 +475,7 @@ mod storage { connector_transaction_id, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) }; match storage_scheme { enums::MerchantStorageScheme::PostgresOnly => database_call().await, @@ -528,8 +521,7 @@ mod storage { let conn = connection::pg_connection_write(self).await?; this.update(&conn, refund) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } enums::MerchantStorageScheme::RedisKv => { let key = format!("mid_{}_pid_{}", this.merchant_id, this.payment_id); @@ -578,8 +570,7 @@ mod storage { let conn = connection::pg_connection_read(self).await?; storage_types::Refund::find_by_merchant_id_refund_id(&conn, merchant_id, refund_id) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) }; match storage_scheme { enums::MerchantStorageScheme::PostgresOnly => database_call().await, @@ -626,8 +617,7 @@ mod storage { connector, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) }; match storage_scheme { enums::MerchantStorageScheme::PostgresOnly => database_call().await, @@ -673,8 +663,7 @@ mod storage { merchant_id, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) }; match storage_scheme { enums::MerchantStorageScheme::PostgresOnly => database_call().await, @@ -716,8 +705,7 @@ mod storage { offset, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[cfg(feature = "olap")] @@ -731,8 +719,7 @@ mod storage { let conn = connection::pg_connection_read(self).await?; ::filter_by_meta_constraints(&conn, merchant_id, refund_details) .await - .map_err(Into::into) - .into_report() + .map_err(|error|report!(errors::StorageError::from(error))) } #[cfg(feature = "olap")] @@ -750,8 +737,7 @@ mod storage { refund_details, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } } } @@ -786,11 +772,7 @@ impl RefundInterface for MockDb { let current_time = common_utils::date_time::now(); let refund = storage_types::Refund { - id: refunds - .len() - .try_into() - .into_report() - .change_context(errors::StorageError::MockDbError)?, + id: i32::try_from(refunds.len()).change_context(errors::StorageError::MockDbError)?, internal_reference_id: new.internal_reference_id, refund_id: new.refund_id, payment_id: new.payment_id, diff --git a/crates/router/src/db/reverse_lookup.rs b/crates/router/src/db/reverse_lookup.rs index ccb77571cfd8..852d6359c976 100644 --- a/crates/router/src/db/reverse_lookup.rs +++ b/crates/router/src/db/reverse_lookup.rs @@ -23,7 +23,7 @@ pub trait ReverseLookupInterface { #[cfg(not(feature = "kv_store"))] mod storage { - use error_stack::IntoReport; + use error_stack::report; use router_env::{instrument, tracing}; use super::{ReverseLookupInterface, Store}; @@ -45,7 +45,9 @@ mod storage { _storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult { let conn = connection::pg_connection_write(self).await?; - new.insert(&conn).await.map_err(Into::into).into_report() + new.insert(&conn) + .await + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -57,15 +59,14 @@ mod storage { let conn = connection::pg_connection_read(self).await?; ReverseLookup::find_by_lookup_id(id, &conn) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } } } #[cfg(feature = "kv_store")] mod storage { - use error_stack::{IntoReport, ResultExt}; + use error_stack::{report, ResultExt}; use redis_interface::SetnxReply; use router_env::{instrument, tracing}; use storage_impl::redis::kv_store::{kv_wrapper, KvOperation}; @@ -93,7 +94,9 @@ mod storage { match storage_scheme { enums::MerchantStorageScheme::PostgresOnly => { let conn = connection::pg_connection_write(self).await?; - new.insert(&conn).await.map_err(Into::into).into_report() + new.insert(&conn) + .await + .map_err(|error| report!(errors::StorageError::from(error))) } enums::MerchantStorageScheme::RedisKv => { let created_rev_lookup = ReverseLookup { @@ -122,8 +125,8 @@ mod storage { Ok(SetnxReply::KeyNotSet) => Err(errors::StorageError::DuplicateValue { entity: "reverse_lookup", key: Some(created_rev_lookup.lookup_id.clone()), - }) - .into_report(), + } + .into()), Err(er) => Err(er).change_context(errors::StorageError::KVError), } } @@ -140,8 +143,7 @@ mod storage { let conn = connection::pg_connection_read(self).await?; ReverseLookup::find_by_lookup_id(id, &conn) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) }; match storage_scheme { diff --git a/crates/router/src/db/role.rs b/crates/router/src/db/role.rs index c8777e3112cc..54b7f6e38d43 100644 --- a/crates/router/src/db/role.rs +++ b/crates/router/src/db/role.rs @@ -1,6 +1,6 @@ use common_enums::enums; use diesel_models::role as storage; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use router_env::{instrument, tracing}; use super::MockDb; @@ -55,7 +55,9 @@ impl RoleInterface for Store { role: storage::RoleNew, ) -> CustomResult { let conn = connection::pg_connection_write(self).await?; - role.insert(&conn).await.map_err(Into::into).into_report() + role.insert(&conn) + .await + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -66,8 +68,7 @@ impl RoleInterface for Store { let conn = connection::pg_connection_write(self).await?; storage::Role::find_by_role_id(&conn, role_id) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -80,8 +81,7 @@ impl RoleInterface for Store { let conn = connection::pg_connection_write(self).await?; storage::Role::find_by_role_id_in_merchant_scope(&conn, role_id, merchant_id, org_id) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -93,8 +93,7 @@ impl RoleInterface for Store { let conn = connection::pg_connection_write(self).await?; storage::Role::update_by_role_id(&conn, role_id, role_update) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -105,8 +104,7 @@ impl RoleInterface for Store { let conn = connection::pg_connection_write(self).await?; storage::Role::delete_by_role_id(&conn, role_id) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -118,8 +116,7 @@ impl RoleInterface for Store { let conn = connection::pg_connection_write(self).await?; storage::Role::list_roles(&conn, merchant_id, org_id) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } } @@ -140,11 +137,7 @@ impl RoleInterface for MockDb { })? } let role = storage::Role { - id: roles - .len() - .try_into() - .into_report() - .change_context(errors::StorageError::MockDbError)?, + id: i32::try_from(roles.len()).change_context(errors::StorageError::MockDbError)?, role_name: role.role_name, role_id: role.role_id, merchant_id: role.merchant_id, diff --git a/crates/router/src/db/routing_algorithm.rs b/crates/router/src/db/routing_algorithm.rs index e0f74358b97a..f65933d8982b 100644 --- a/crates/router/src/db/routing_algorithm.rs +++ b/crates/router/src/db/routing_algorithm.rs @@ -1,5 +1,5 @@ use diesel_models::routing_algorithm as routing_storage; -use error_stack::IntoReport; +use error_stack::report; use router_env::{instrument, tracing}; use storage_impl::mock_db::MockDb; @@ -70,8 +70,7 @@ impl RoutingAlgorithmInterface for Store { routing_algorithm .insert(&conn) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -87,8 +86,7 @@ impl RoutingAlgorithmInterface for Store { profile_id, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -104,8 +102,7 @@ impl RoutingAlgorithmInterface for Store { merchant_id, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -121,8 +118,7 @@ impl RoutingAlgorithmInterface for Store { profile_id, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -137,8 +133,7 @@ impl RoutingAlgorithmInterface for Store { &conn, profile_id, limit, offset, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -156,8 +151,7 @@ impl RoutingAlgorithmInterface for Store { offset, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } async fn list_routing_algorithm_metadata_by_merchant_id_transaction_type( @@ -176,8 +170,7 @@ impl RoutingAlgorithmInterface for Store { offset, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } } diff --git a/crates/router/src/db/user.rs b/crates/router/src/db/user.rs index 6148e67b2940..a96829a756e7 100644 --- a/crates/router/src/db/user.rs +++ b/crates/router/src/db/user.rs @@ -1,5 +1,5 @@ use diesel_models::{user as storage, user_role::UserRole}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use masking::Secret; use router_env::{instrument, tracing}; @@ -62,8 +62,7 @@ impl UserInterface for Store { user_data .insert(&conn) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -74,8 +73,7 @@ impl UserInterface for Store { let conn = connection::pg_connection_write(self).await?; storage::User::find_by_user_email(&conn, user_email) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -86,8 +84,7 @@ impl UserInterface for Store { let conn = connection::pg_connection_write(self).await?; storage::User::find_by_user_id(&conn, user_id) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -99,8 +96,7 @@ impl UserInterface for Store { let conn = connection::pg_connection_write(self).await?; storage::User::update_by_user_id(&conn, user_id, user) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -112,8 +108,7 @@ impl UserInterface for Store { let conn = connection::pg_connection_write(self).await?; storage::User::update_by_user_email(&conn, user_email, user) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -124,8 +119,7 @@ impl UserInterface for Store { let conn = connection::pg_connection_write(self).await?; storage::User::delete_by_user_id(&conn, user_id) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -136,8 +130,7 @@ impl UserInterface for Store { let conn = connection::pg_connection_write(self).await?; storage::User::find_joined_users_and_roles_by_merchant_id(&conn, merchant_id) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } } @@ -159,11 +152,7 @@ impl UserInterface for MockDb { } let time_now = common_utils::date_time::now(); let user = storage::User { - id: users - .len() - .try_into() - .into_report() - .change_context(errors::StorageError::MockDbError)?, + id: i32::try_from(users.len()).change_context(errors::StorageError::MockDbError)?, user_id: user_data.user_id, email: user_data.email, name: user_data.name, diff --git a/crates/router/src/db/user_role.rs b/crates/router/src/db/user_role.rs index ae2c85db0417..2f61f70b2a82 100644 --- a/crates/router/src/db/user_role.rs +++ b/crates/router/src/db/user_role.rs @@ -2,7 +2,7 @@ use std::{collections::HashSet, ops::Not}; use async_bb8_diesel::AsyncConnection; use diesel_models::{enums, user_role as storage}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use router_env::{instrument, tracing}; use super::MockDb; @@ -74,8 +74,7 @@ impl UserRoleInterface for Store { user_role .insert(&conn) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -86,8 +85,7 @@ impl UserRoleInterface for Store { let conn = connection::pg_connection_write(self).await?; storage::UserRole::find_by_user_id(&conn, user_id.to_owned()) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -103,8 +101,7 @@ impl UserRoleInterface for Store { merchant_id.to_owned(), ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -122,8 +119,7 @@ impl UserRoleInterface for Store { update, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -141,8 +137,7 @@ impl UserRoleInterface for Store { update, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -158,8 +153,7 @@ impl UserRoleInterface for Store { merchant_id.to_owned(), ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -170,8 +164,7 @@ impl UserRoleInterface for Store { let conn = connection::pg_connection_write(self).await?; storage::UserRole::list_by_user_id(&conn, user_id.to_owned()) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } #[instrument(skip_all)] @@ -248,9 +241,7 @@ impl UserRoleInterface for Store { Ok::<_, errors::DatabaseError>(()) }) .await - .into_report() - .map_err(Into::into) - .into_report()?; + .map_err(|error| report!(errors::StorageError::from(report!(error))))?; Ok(()) } @@ -273,10 +264,7 @@ impl UserRoleInterface for MockDb { })? } let user_role = storage::UserRole { - id: user_roles - .len() - .try_into() - .into_report() + id: i32::try_from(user_roles.len()) .change_context(errors::StorageError::MockDbError)?, user_id: user_role.user_id, merchant_id: user_role.merchant_id, diff --git a/crates/router/src/routes/disputes/utils.rs b/crates/router/src/routes/disputes/utils.rs index 33000bbd98d2..9ad5a55c9c8d 100644 --- a/crates/router/src/routes/disputes/utils.rs +++ b/crates/router/src/routes/disputes/utils.rs @@ -1,7 +1,7 @@ use actix_multipart::{Field, Multipart}; use actix_web::web::Bytes; use common_utils::{errors::CustomResult, ext_traits::StringExt, fp_utils}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use futures::{StreamExt, TryStreamExt}; use crate::{ @@ -48,7 +48,6 @@ pub async fn get_attach_evidence_request( match chunk { Ok(bytes) => file_data.push(bytes), Err(err) => Err(errors::ApiErrorResponse::InternalServerError) - .into_report() .attach_printable_lazy(|| format!("File parsing error: {err}"))?, } } @@ -67,16 +66,12 @@ pub async fn get_attach_evidence_request( let evidence_type = option_evidence_type.get_required_value("evidence_type")?; let file = file_content.get_required_value("file")?.concat().to_vec(); //Get and validate file size - let file_size: i32 = file - .len() - .try_into() - .into_report() + let file_size = i32::try_from(file.len()) .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("File size error")?; // Check if empty file and throw error fp_utils::when(file_size <= 0, || { Err(errors::ApiErrorResponse::MissingFile) - .into_report() .attach_printable("Missing / Invalid file in the request") })?; // Get file mime type using 'infer' @@ -84,7 +79,6 @@ pub async fn get_attach_evidence_request( let file_type = kind .mime_type() .parse::() - .into_report() .change_context(errors::ApiErrorResponse::MissingFileContentType) .attach_printable("File content type error")?; let create_file_request = files::CreateFileRequest { diff --git a/crates/router/src/routes/dummy_connector/utils.rs b/crates/router/src/routes/dummy_connector/utils.rs index 1bf13df599cb..8bba182ad0a5 100644 --- a/crates/router/src/routes/dummy_connector/utils.rs +++ b/crates/router/src/routes/dummy_connector/utils.rs @@ -1,7 +1,7 @@ use std::fmt::Debug; use common_utils::ext_traits::AsyncExt; -use error_stack::{report, IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use masking::PeekInterface; use maud::html; use rand::{distributions::Uniform, prelude::Distribution}; @@ -222,7 +222,7 @@ impl ProcessPaymentAttempt for types::DummyConnectorCard { match self.get_flow_from_card_number()? { types::DummyConnectorCardFlow::NoThreeDS(status, error) => { if let Some(error) = error { - Err(error).into_report()?; + Err(error)?; } Ok(payment_attempt.build_payment_data(status, None, None)) } diff --git a/crates/router/src/routes/files/transformers.rs b/crates/router/src/routes/files/transformers.rs index c49f6892b571..7feb73353bc2 100644 --- a/crates/router/src/routes/files/transformers.rs +++ b/crates/router/src/routes/files/transformers.rs @@ -1,7 +1,7 @@ use actix_multipart::Multipart; use actix_web::web::Bytes; use common_utils::errors::CustomResult; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use futures::{StreamExt, TryStreamExt}; use crate::{ @@ -37,7 +37,6 @@ pub async fn get_create_file_request( match chunk { Ok(bytes) => file_data.push(bytes), Err(err) => Err(errors::ApiErrorResponse::InternalServerError) - .into_report() .attach_printable(format!("{}{}", "File parsing error: ", err))?, } } @@ -54,20 +53,15 @@ pub async fn get_create_file_request( let file = match file_content { Some(valid_file_content) => valid_file_content.concat().to_vec(), None => Err(errors::ApiErrorResponse::MissingFile) - .into_report() .attach_printable("Missing / Invalid file in the request")?, }; //Get and validate file size - let file_size: i32 = file - .len() - .try_into() - .into_report() + let file_size = i32::try_from(file.len()) .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("File size error")?; // Check if empty file and throw error if file_size <= 0 { Err(errors::ApiErrorResponse::MissingFile) - .into_report() .attach_printable("Missing / Invalid file in the request")? } // Get file mime type using 'infer' @@ -75,7 +69,6 @@ pub async fn get_create_file_request( let file_type = kind .mime_type() .parse::() - .into_report() .change_context(errors::ApiErrorResponse::MissingFileContentType) .attach_printable("File content type error")?; Ok(CreateFileRequest { diff --git a/crates/router/src/routes/payments.rs b/crates/router/src/routes/payments.rs index 73d891c89843..eda181f5a8bb 100644 --- a/crates/router/src/routes/payments.rs +++ b/crates/router/src/routes/payments.rs @@ -6,7 +6,7 @@ pub mod helpers; use actix_web::{web, Responder}; use api_models::payments::HeaderPayload; -use error_stack::{report, IntoReport}; +use error_stack::report; use router_env::{env, instrument, tracing, types, Flow}; use crate::{ @@ -1332,8 +1332,7 @@ pub fn get_or_generate_payment_id( }) .transpose()?; - let payment_id = - core_utils::get_or_generate_id("payment_id", &given_payment_id, "pay").into_report()?; + let payment_id = core_utils::get_or_generate_id("payment_id", &given_payment_id, "pay")?; payload.payment_id = Some(api_models::payments::PaymentIdType::PaymentIntentId( payment_id, diff --git a/crates/router/src/routes/recon.rs b/crates/router/src/routes/recon.rs index 22c886e13581..faa41d9d1d25 100644 --- a/crates/router/src/routes/recon.rs +++ b/crates/router/src/routes/recon.rs @@ -209,11 +209,11 @@ pub async fn recon_merchant_account_update( } Ok(service_api::ApplicationResponse::Json( - response - .try_into() - .change_context(errors::ApiErrorResponse::InvalidDataValue { + api_types::MerchantAccountResponse::try_from(response).change_context( + errors::ApiErrorResponse::InvalidDataValue { field_name: "merchant_account", - })?, + }, + )?, )) } diff --git a/crates/router/src/services.rs b/crates/router/src/services.rs index 617b9df71224..6b604498c713 100644 --- a/crates/router/src/services.rs +++ b/crates/router/src/services.rs @@ -14,7 +14,7 @@ pub mod recon; pub mod email; use data_models::errors::StorageResult; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::{ExposeInterface, StrongSecret}; #[cfg(feature = "kv_store")] use storage_impl::KVRouterStore; @@ -91,7 +91,6 @@ pub fn generate_aes256_key() -> errors::CustomResult<[u8; 32], common_utils::err let rng = ring::rand::SystemRandom::new(); let mut key: [u8; 256 / 8] = [0_u8; 256 / 8]; rng.fill(&mut key) - .into_report() .change_context(common_utils::errors::CryptoError::EncodingFailed)?; Ok(key) } diff --git a/crates/router/src/services/api.rs b/crates/router/src/services/api.rs index 40a9713a8cf0..95eb4a44c8a8 100644 --- a/crates/router/src/services/api.rs +++ b/crates/router/src/services/api.rs @@ -22,7 +22,7 @@ use common_utils::{ errors::{ErrorSwitch, ReportSwitchExt}, request::RequestContent, }; -use error_stack::{report, IntoReport, Report, ResultExt}; +use error_stack::{report, Report, ResultExt}; use masking::{Maskable, PeekInterface, Secret}; use router_env::{instrument, tracing, tracing_actix_web::RequestId, Tag}; use serde::Serialize; @@ -579,7 +579,6 @@ pub async fn send_request( logger::info!(method=?request.method, headers=?request.headers, payload=?request.body, ?request); let url = reqwest::Url::parse(&request.url) - .into_report() .change_context(errors::ApiClientError::UrlEncodingFailed)?; #[cfg(feature = "dummy_connector")] @@ -612,7 +611,6 @@ pub async fn send_request( Some(RequestContent::FormUrlEncoded(payload)) => client.form(&payload), Some(RequestContent::Xml(payload)) => { let body = quick_xml::se::to_string(&payload) - .into_report() .change_context(errors::ApiClientError::BodySerializationFailed)?; client.body(body).header("Content-Type", "application/xml") } @@ -628,7 +626,6 @@ pub async fn send_request( Some(RequestContent::FormUrlEncoded(payload)) => client.form(&payload), Some(RequestContent::Xml(payload)) => { let body = quick_xml::se::to_string(&payload) - .into_report() .change_context(errors::ApiClientError::BodySerializationFailed)?; client.body(body).header("Content-Type", "application/xml") } @@ -644,7 +641,6 @@ pub async fn send_request( Some(RequestContent::FormUrlEncoded(payload)) => client.form(&payload), Some(RequestContent::Xml(payload)) => { let body = quick_xml::se::to_string(&payload) - .into_report() .change_context(errors::ApiClientError::BodySerializationFailed)?; client.body(body).header("Content-Type", "application/xml") } @@ -676,7 +672,6 @@ pub async fn send_request( } _ => errors::ApiClientError::RequestNotSent(error.to_string()), }) - .into_report() .attach_printable("Unable to send request to connector") }); @@ -695,7 +690,6 @@ pub async fn send_request( } _ => errors::ApiClientError::RequestNotSent(error.to_string()), }) - .into_report() .attach_printable("Unable to send request to connector") }; @@ -774,7 +768,6 @@ async fn handle_response( let response = response .bytes() .await - .into_report() .change_context(errors::ApiClientError::ResponseDecodingFailed) .attach_printable("Error while waiting for response")?; Ok(Ok(types::Response { @@ -972,7 +965,6 @@ where { let request_id = RequestId::extract(request) .await - .into_report() .attach_printable("Unable to extract request id from request") .change_context(errors::ApiErrorResponse::InternalServerError.switch())?; @@ -981,7 +973,6 @@ where request_state.add_request_id(request_id); let start_instant = Instant::now(); let serialized_request = masking::masked_serialize(&payload) - .into_report() .attach_printable("Failed to serialize json request") .change_context(errors::ApiErrorResponse::InternalServerError.switch())?; @@ -1032,14 +1023,12 @@ where if let ApplicationResponse::Json(data) = res { serialized_response.replace( masking::masked_serialize(&data) - .into_report() .attach_printable("Failed to serialize json response") .change_context(errors::ApiErrorResponse::InternalServerError.switch())?, ); } else if let ApplicationResponse::JsonWithHeaders((data, headers)) = res { serialized_response.replace( masking::masked_serialize(&data) - .into_report() .attach_printable("Failed to serialize json response") .change_context(errors::ApiErrorResponse::InternalServerError.switch())?, ); @@ -1057,7 +1046,6 @@ where Err(err) => { error.replace( serde_json::to_value(err.current_context()) - .into_report() .attach_printable("Failed to serialize json response") .change_context(errors::ApiErrorResponse::InternalServerError.switch()) .ok() @@ -1499,7 +1487,6 @@ pub fn build_redirection_form( "#)) - h3 style="text-align: center;" { "Please wait while we process your payment..." } form action=(PreEscaped(endpoint)) method=(method.to_string()) #payment_form { @for (field, value) in form_fields { @@ -1557,7 +1544,6 @@ pub fn build_redirection_form( "#)) - h3 style="text-align: center;" { "Please wait while we process your payment..." } } @@ -1613,7 +1599,6 @@ pub fn build_redirection_form( "#)) - h3 style="text-align: center;" { "Please wait while we process your payment..." } } @@ -1666,7 +1651,6 @@ pub fn build_redirection_form( "#)) - h3 style="text-align: center;" { "Please wait while we process your payment..." } } @@ -1745,7 +1729,6 @@ pub fn build_redirection_form( "#)) - h3 style="text-align: center;" { "Please wait while we process your payment..." } } diff --git a/crates/router/src/services/api/client.rs b/crates/router/src/services/api/client.rs index a2cf65ce66bf..816269c086f5 100644 --- a/crates/router/src/services/api/client.rs +++ b/crates/router/src/services/api/client.rs @@ -1,6 +1,6 @@ use std::time::Duration; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use http::{HeaderValue, Method}; use masking::PeekInterface; use once_cell::sync::OnceCell; @@ -41,7 +41,6 @@ fn get_client_builder( if let Some(url) = proxy_config.https_url.as_ref() { client_builder = client_builder.proxy( reqwest::Proxy::https(url) - .into_report() .change_context(ApiClientError::InvalidProxyConfiguration) .attach_printable("HTTPS proxy configuration error")?, ); @@ -51,7 +50,6 @@ fn get_client_builder( if let Some(url) = proxy_config.http_url.as_ref() { client_builder = client_builder.proxy( reqwest::Proxy::http(url) - .into_report() .change_context(ApiClientError::InvalidProxyConfiguration) .attach_printable("HTTP proxy configuration error")?, ); @@ -74,7 +72,6 @@ fn get_base_client( .get_or_try_init(|| { get_client_builder(proxy_config, should_bypass_proxy)? .build() - .into_report() .change_context(ApiClientError::ClientConstructionFailed) .attach_printable("Failed to construct base client") })? @@ -101,7 +98,6 @@ pub(super) fn create_client( client_builder .identity(identity) .build() - .into_report() .change_context(ApiClientError::ClientConstructionFailed) .attach_printable("Failed to construct client with certificate and certificate key") } @@ -194,7 +190,6 @@ impl ProxyClient { let non_proxy_client = reqwest::Client::builder() .redirect(reqwest::redirect::Policy::none()) .build() - .into_report() .change_context(ApiClientError::ClientConstructionFailed)?; let mut proxy_builder = @@ -203,7 +198,6 @@ impl ProxyClient { if let Some(url) = proxy_config.https_url.as_ref() { proxy_builder = proxy_builder.proxy( reqwest::Proxy::https(url) - .into_report() .change_context(ApiClientError::InvalidProxyConfiguration)?, ); } @@ -211,14 +205,12 @@ impl ProxyClient { if let Some(url) = proxy_config.http_url.as_ref() { proxy_builder = proxy_builder.proxy( reqwest::Proxy::http(url) - .into_report() .change_context(ApiClientError::InvalidProxyConfiguration)?, ); } let proxy_client = proxy_builder .build() - .into_report() .change_context(ApiClientError::InvalidProxyConfiguration)?; Ok(Self { proxy_client, @@ -245,7 +237,6 @@ impl ProxyClient { Ok(client_builder .identity(identity) .build() - .into_report() .change_context(ApiClientError::ClientConstructionFailed) .attach_printable( "Failed to construct client with certificate and certificate key", @@ -295,7 +286,6 @@ impl RequestBuilder for RouterRequestBuilder { }), Maskable::Normal(hvalue) => HeaderValue::from_str(&hvalue), } - .into_report() .change_context(ApiClientError::HeaderMapConstructionFailed)?; self.inner = self.inner.take().map(|r| r.header(key, header_value)); diff --git a/crates/router/src/services/api/request.rs b/crates/router/src/services/api/request.rs index 1f672b0f0ded..ed53da0d9711 100644 --- a/crates/router/src/services/api/request.rs +++ b/crates/router/src/services/api/request.rs @@ -2,7 +2,7 @@ use std::str::FromStr; pub use common_utils::request::ContentType; use common_utils::request::Headers; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; pub use masking::{Mask, Maskable}; use router_env::{instrument, tracing}; @@ -24,11 +24,9 @@ impl HeaderExt for Headers { HeaderMap::new(), |mut header_map, (header_name, header_value)| { let header_name = HeaderName::from_str(&header_name) - .into_report() .change_context(errors::ApiClientError::HeaderMapConstructionFailed)?; let header_value = header_value.into_inner(); let header_value = HeaderValue::from_str(&header_value) - .into_report() .change_context(errors::ApiClientError::HeaderMapConstructionFailed)?; header_map.append(header_name, header_value); Ok(header_map) diff --git a/crates/router/src/services/authentication.rs b/crates/router/src/services/authentication.rs index ca8378080cf0..d2247150d3c5 100644 --- a/crates/router/src/services/authentication.rs +++ b/crates/router/src/services/authentication.rs @@ -2,7 +2,7 @@ use actix_web::http::header::HeaderMap; use api_models::{payment_methods::PaymentMethodListRequest, payments}; use async_trait::async_trait; use common_utils::date_time; -use error_stack::{report, IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use jsonwebtoken::{decode, Algorithm, DecodingKey, Validation}; use masking::PeekInterface; use serde::Serialize; @@ -214,7 +214,6 @@ where .trim(); if api_key.is_empty() { return Err(errors::ApiErrorResponse::Unauthorized) - .into_report() .attach_printable("API key is empty"); } @@ -927,7 +926,6 @@ where let key = DecodingKey::from_secret(secret); decode::(token, &key, &Validation::new(Algorithm::HS256)) .map(|decoded| decoded.claims) - .into_report() .change_context(errors::ApiErrorResponse::InvalidJwtToken) } @@ -941,7 +939,6 @@ pub fn get_header_value_by_key(key: String, headers: &HeaderMap) -> RouterResult .map(|source_str| { source_str .to_str() - .into_report() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable(format!( "Failed to convert header value to string for header key: {}", @@ -956,7 +953,6 @@ pub fn get_jwt_from_authorization_header(headers: &HeaderMap) -> RouterResult<&s .get(crate::headers::AUTHORIZATION) .get_required_value(crate::headers::AUTHORIZATION)? .to_str() - .into_report() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Failed to convert JWT token to string")? .strip_prefix("Bearer ") diff --git a/crates/router/src/services/authentication/blacklist.rs b/crates/router/src/services/authentication/blacklist.rs index 2ee8302be636..7c1cbf27e105 100644 --- a/crates/router/src/services/authentication/blacklist.rs +++ b/crates/router/src/services/authentication/blacklist.rs @@ -2,7 +2,7 @@ use std::sync::Arc; #[cfg(feature = "olap")] use common_utils::date_time; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use redis_interface::RedisConnectionPool; use super::{AuthToken, UserAuthToken}; @@ -131,10 +131,7 @@ fn get_redis_connection(state: &A) -> RouterResult RouterResult { - expiry - .try_into() - .into_report() - .change_context(ApiErrorResponse::InternalServerError) + i64::try_from(expiry).change_context(ApiErrorResponse::InternalServerError) } #[async_trait::async_trait] diff --git a/crates/router/src/services/authorization.rs b/crates/router/src/services/authorization.rs index dc6d82d4e92e..33edb173255f 100644 --- a/crates/router/src/services/authorization.rs +++ b/crates/router/src/services/authorization.rs @@ -1,7 +1,7 @@ use std::sync::Arc; use common_enums::PermissionGroup; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use redis_interface::RedisConnectionPool; use router_env::logger; @@ -39,11 +39,8 @@ where let permissions = get_permissions_from_db(state, &token.role_id, &token.merchant_id, &token.org_id).await?; - let token_expiry: i64 = token - .exp - .try_into() - .into_report() - .change_context(ApiErrorResponse::InternalServerError)?; + let token_expiry = + i64::try_from(token.exp).change_context(ApiErrorResponse::InternalServerError)?; let cache_ttl = token_expiry - common_utils::date_time::now_unix_timestamp(); set_permissions_in_cache(state, &token.role_id, &permissions, cache_ttl) diff --git a/crates/router/src/services/encryption.rs b/crates/router/src/services/encryption.rs index 9a8a5f4af4a9..dc7e5db079a6 100644 --- a/crates/router/src/services/encryption.rs +++ b/crates/router/src/services/encryption.rs @@ -1,6 +1,6 @@ use std::str; -use error_stack::{report, IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use josekit::{jwe, jws}; use serde::{Deserialize, Serialize}; @@ -37,12 +37,10 @@ pub async fn encrypt_jwe( src_header.set_token_type("JWT"); let encrypter = alg .encrypter_from_pem(public_key) - .into_report() .change_context(errors::EncryptionError) .attach_printable("Error getting JweEncryptor")?; jwe::serialize_compact(payload, &src_header, &encrypter) - .into_report() .change_context(errors::EncryptionError) .attach_printable("Error getting jwt string") } @@ -67,17 +65,14 @@ pub async fn decrypt_jwe( let decrypter = alg .decrypter_from_pem(private_key) - .into_report() .change_context(errors::EncryptionError) .attach_printable("Error getting JweDecryptor")?; let (dst_payload, _dst_header) = jwe::deserialize_compact(jwt, &decrypter) - .into_report() .change_context(errors::EncryptionError) .attach_printable("Error getting Decrypted jwe")?; String::from_utf8(dst_payload) - .into_report() .change_context(errors::EncryptionError) .attach_printable("Could not decode JWE payload from UTF-8") } @@ -92,11 +87,9 @@ pub async fn jws_sign_payload( src_header.set_key_id(kid); let signer = alg .signer_from_pem(private_key) - .into_report() .change_context(errors::EncryptionError) .attach_printable("Error getting signer")?; let jwt = jws::serialize_compact(payload, &src_header, &signer) - .into_report() .change_context(errors::EncryptionError) .attach_printable("Error getting signed jwt string")?; Ok(jwt) @@ -110,15 +103,12 @@ pub fn verify_sign( let input = jws_body.as_bytes(); let verifier = alg .verifier_from_pem(key) - .into_report() .change_context(errors::EncryptionError) .attach_printable("Error getting verifier")?; let (dst_payload, _dst_header) = jws::deserialize_compact(input, &verifier) - .into_report() .change_context(errors::EncryptionError) .attach_printable("Error getting Decrypted jws")?; let resp = String::from_utf8(dst_payload) - .into_report() .change_context(errors::EncryptionError) .attach_printable("Could not convert to UTF-8")?; Ok(resp) diff --git a/crates/router/src/services/jwt.rs b/crates/router/src/services/jwt.rs index 6a78e2232a95..aec9ae85e63e 100644 --- a/crates/router/src/services/jwt.rs +++ b/crates/router/src/services/jwt.rs @@ -1,5 +1,5 @@ use common_utils::errors::CustomResult; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use jsonwebtoken::{encode, EncodingKey, Header}; use masking::PeekInterface; @@ -12,7 +12,6 @@ pub fn generate_exp( .checked_add(exp_duration) .ok_or(UserErrors::InternalServerError)? .duration_since(std::time::UNIX_EPOCH) - .into_report() .change_context(UserErrors::InternalServerError) } @@ -29,6 +28,5 @@ where claims_data, &EncodingKey::from_secret(jwt_secret.peek().as_bytes()), ) - .into_report() .change_context(UserErrors::InternalServerError) } diff --git a/crates/router/src/services/kafka.rs b/crates/router/src/services/kafka.rs index 77f179a533b2..373c268f85b7 100644 --- a/crates/router/src/services/kafka.rs +++ b/crates/router/src/services/kafka.rs @@ -1,7 +1,7 @@ use std::sync::Arc; use common_utils::errors::CustomResult; -use error_stack::{report, IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use rdkafka::{ config::FromClientConfig, producer::{BaseRecord, DefaultProducerContext, Producer, ThreadedProducer}, @@ -31,9 +31,7 @@ where { fn value(&self) -> MQResult> { // Add better error logging here - serde_json::to_vec(&self) - .into_report() - .change_context(KafkaError::GenericError) + serde_json::to_vec(&self).change_context(KafkaError::GenericError) } fn key(&self) -> String; @@ -201,7 +199,6 @@ impl KafkaProducer { ThreadedProducer::from_config( rdkafka::ClientConfig::new().set("bootstrap.servers", conf.brokers.join(",")), ) - .into_report() .change_context(KafkaError::InitializationError)?, )), diff --git a/crates/router/src/types.rs b/crates/router/src/types.rs index 6f73efa832e4..4a2a676672c1 100644 --- a/crates/router/src/types.rs +++ b/crates/router/src/types.rs @@ -25,7 +25,7 @@ use common_enums::MandateStatus; pub use common_utils::request::RequestContent; use common_utils::{pii, pii::Email}; use data_models::mandates::{CustomerAcceptance, MandateData}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::Secret; use serde::Serialize; @@ -982,7 +982,6 @@ impl ResponseId { _ => Err(errors::ValidationError::IncorrectValueProvided { field_name: "connector_transaction_id", }) - .into_report() .attach_printable("Expected connector transaction ID not found"), } } diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rs index 95a0989ac2be..4b72c7ac2e63 100644 --- a/crates/router/src/types/api.rs +++ b/crates/router/src/types/api.rs @@ -27,7 +27,7 @@ pub mod webhooks; use std::{fmt::Debug, str::FromStr}; -use error_stack::{report, IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; #[cfg(feature = "frm")] pub use self::fraud_check::*; @@ -280,7 +280,6 @@ impl ConnectorData { ) -> CustomResult { let connector = Self::convert_connector(connectors, name)?; let connector_name = api_enums::Connector::from_str(name) - .into_report() .change_context(errors::ConnectorError::InvalidConnectorName) .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable_lazy(|| format!("unable to parse connector name {connector:?}"))?; @@ -301,7 +300,6 @@ impl ConnectorData { ) -> CustomResult { let connector = Self::convert_connector(connectors, name)?; let payout_connector_name = api_enums::PayoutConnectors::from_str(name) - .into_report() .change_context(errors::ConnectorError::InvalidConnectorName) .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable_lazy(|| { diff --git a/crates/router/src/types/api/authentication.rs b/crates/router/src/types/api/authentication.rs index d0c6884450ac..b69533db5a28 100644 --- a/crates/router/src/types/api/authentication.rs +++ b/crates/router/src/types/api/authentication.rs @@ -2,7 +2,7 @@ use std::str::FromStr; use api_models::enums; use common_utils::errors::CustomResult; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use super::BoxedConnector; use crate::core::errors; @@ -91,7 +91,6 @@ pub struct AuthenticationConnectorData { impl AuthenticationConnectorData { pub fn get_connector_by_name(name: &str) -> CustomResult { let connector_name = enums::AuthenticationConnectors::from_str(name) - .into_report() .change_context(errors::ApiErrorResponse::IncorrectConnectorNameGiven) .attach_printable_lazy(|| format!("unable to parse connector: {name}"))?; let connector = Self::convert_connector(connector_name)?; diff --git a/crates/router/src/types/api/connector_onboarding/paypal.rs b/crates/router/src/types/api/connector_onboarding/paypal.rs index dbfdd6f50075..22bab6968a80 100644 --- a/crates/router/src/types/api/connector_onboarding/paypal.rs +++ b/crates/router/src/types/api/connector_onboarding/paypal.rs @@ -1,5 +1,5 @@ use api_models::connector_onboarding as api; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use crate::core::errors::{ApiErrorResponse, RouterResult}; @@ -181,7 +181,6 @@ impl SellerStatusResponse { .and_then(|link| link.href.strip_prefix('/')) .map(|link| format!("{}{}", paypal_base_url, link)) .ok_or(ApiErrorResponse::InternalServerError) - .into_report() .attach_printable("Merchant details not received in onboarding status") } } @@ -240,7 +239,6 @@ impl PartnerReferralResponse { .into_iter() .find(|hateoas_link| hateoas_link.rel == "action_url") .ok_or(ApiErrorResponse::InternalServerError) - .into_report() .attach_printable("Failed to get action_url from paypal response")? .href) } diff --git a/crates/router/src/types/api/fraud_check.rs b/crates/router/src/types/api/fraud_check.rs index e871cbc5d330..45c79930e80c 100644 --- a/crates/router/src/types/api/fraud_check.rs +++ b/crates/router/src/types/api/fraud_check.rs @@ -2,7 +2,7 @@ use std::str::FromStr; use api_models::enums; use common_utils::errors::CustomResult; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use super::{BoxedConnector, ConnectorData, SessionConnectorData}; use crate::{ @@ -69,7 +69,6 @@ pub enum ConnectorCallType { impl FraudCheckConnectorData { pub fn get_connector_by_name(name: &str) -> CustomResult { let connector_name = enums::FrmConnectors::from_str(name) - .into_report() .change_context(errors::ApiErrorResponse::IncorrectConnectorNameGiven) .attach_printable_lazy(|| { format!("unable to parse connector: {:?}", name.to_string()) diff --git a/crates/router/src/types/api/payments.rs b/crates/router/src/types/api/payments.rs index d465300dd61b..370e0ca35097 100644 --- a/crates/router/src/types/api/payments.rs +++ b/crates/router/src/types/api/payments.rs @@ -13,7 +13,7 @@ pub use api_models::payments::{ PgRedirectResponse, PhoneDetails, RedirectionResponse, SessionToken, TimeRange, UrlDetails, VerifyRequest, VerifyResponse, WalletData, }; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use crate::{ core::errors, @@ -99,7 +99,6 @@ impl PaymentIdTypeExt for PaymentIdType { | Self::PreprocessingId(_) => Err(errors::ValidationError::IncorrectValueProvided { field_name: "payment_id", }) - .into_report() .attach_printable("Expected payment intent ID but got connector transaction ID"), } } @@ -120,8 +119,8 @@ impl MandateValidationFieldsExt for MandateValidationFields { (Some(_), Some(_)) => Err(errors::ValidationError::InvalidValue { message: "Expected one out of recurring_details and mandate_data but got both" .to_string(), - }) - .into_report(), + } + .into()), (_, Some(_)) => Ok(Some(MandateTransactionType::RecurringMandateTransaction)), (Some(_), _) => Ok(Some(MandateTransactionType::NewMandateTransaction)), } diff --git a/crates/router/src/types/api/verify_connector.rs b/crates/router/src/types/api/verify_connector.rs index d05a2b8a8e29..85bb9bf72afb 100644 --- a/crates/router/src/types/api/verify_connector.rs +++ b/crates/router/src/types/api/verify_connector.rs @@ -1,7 +1,7 @@ pub mod paypal; pub mod stripe; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use crate::{ consts, @@ -167,8 +167,8 @@ pub trait VerifyConnector { .change_context(errors::ApiErrorResponse::InternalServerError)?; Err(errors::ApiErrorResponse::InvalidRequestData { message: error.reason.unwrap_or(error.message), - }) - .into_report() + } + .into()) } async fn handle_access_token_error_response( @@ -183,7 +183,7 @@ pub trait VerifyConnector { .change_context(errors::ApiErrorResponse::InternalServerError)?; Err(errors::ApiErrorResponse::InvalidRequestData { message: error.reason.unwrap_or(error.message), - }) - .into_report() + } + .into()) } } diff --git a/crates/router/src/types/api/verify_connector/stripe.rs b/crates/router/src/types/api/verify_connector/stripe.rs index 3fc55291d9c8..9dc7a2c244aa 100644 --- a/crates/router/src/types/api/verify_connector/stripe.rs +++ b/crates/router/src/types/api/verify_connector/stripe.rs @@ -1,4 +1,4 @@ -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use router_env::env; use super::VerifyConnector; @@ -29,8 +29,8 @@ impl VerifyConnector for connector::Stripe { (env::Env::Production, "card_declined") => Ok(services::ApplicationResponse::StatusOk), _ => Err(errors::ApiErrorResponse::InvalidRequestData { message: error.reason.unwrap_or(error.message), - }) - .into_report(), + } + .into()), } } } diff --git a/crates/router/src/types/domain/address.rs b/crates/router/src/types/domain/address.rs index c657aaf97ea1..458ccb8114de 100644 --- a/crates/router/src/types/domain/address.rs +++ b/crates/router/src/types/domain/address.rs @@ -79,7 +79,7 @@ impl behaviour::Conversion for Address { async { let inner_decrypt = |inner| types::decrypt(inner, key.peek()); let inner_decrypt_email = |inner| types::decrypt(inner, key.peek()); - Ok(Self { + Ok::>(Self { id: other.id, address_id: other.address_id, city: other.city, diff --git a/crates/router/src/types/domain/customer.rs b/crates/router/src/types/domain/customer.rs index d5f05944d6cd..de95251d9d4e 100644 --- a/crates/router/src/types/domain/customer.rs +++ b/crates/router/src/types/domain/customer.rs @@ -60,7 +60,7 @@ impl super::behaviour::Conversion for Customer { async { let inner_decrypt = |inner| types::decrypt(inner, key.peek()); let inner_decrypt_email = |inner| types::decrypt(inner, key.peek()); - Ok(Self { + Ok::>(Self { id: Some(item.id), customer_id: item.customer_id, merchant_id: item.merchant_id, diff --git a/crates/router/src/types/domain/event.rs b/crates/router/src/types/domain/event.rs index 1c39be5a3d24..5e198261169f 100644 --- a/crates/router/src/types/domain/event.rs +++ b/crates/router/src/types/domain/event.rs @@ -85,7 +85,7 @@ impl super::behaviour::Conversion for Event { Self: Sized, { async { - Ok(Self { + Ok::>(Self { event_id: item.event_id, event_type: item.event_type, event_class: item.event_class, diff --git a/crates/router/src/types/domain/merchant_account.rs b/crates/router/src/types/domain/merchant_account.rs index 3832ffb3da7e..99553e26157f 100644 --- a/crates/router/src/types/domain/merchant_account.rs +++ b/crates/router/src/types/domain/merchant_account.rs @@ -195,7 +195,7 @@ impl super::behaviour::Conversion for MerchantAccount { Self: Sized, { async { - Ok(Self { + Ok::>(Self { id: Some(item.id), merchant_id: item.merchant_id, return_url: item.return_url, diff --git a/crates/router/src/types/domain/types.rs b/crates/router/src/types/domain/types.rs index d80b8d0cba6b..0ef4e8579d36 100644 --- a/crates/router/src/types/domain/types.rs +++ b/crates/router/src/types/domain/types.rs @@ -5,7 +5,7 @@ use common_utils::{ ext_traits::AsyncExt, }; use diesel_models::encryption::Encryption; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::{PeekInterface, Secret}; use router_env::{instrument, tracing}; @@ -58,7 +58,6 @@ impl< let data = crypt_algo.decode_message(key, encrypted.clone())?; let value: String = std::str::from_utf8(&data) - .into_report() .change_context(errors::CryptoError::DecodingFailed)? .to_string(); @@ -80,7 +79,6 @@ impl< crypt_algo: V, ) -> CustomResult { let data = serde_json::to_vec(&masked_data.peek()) - .into_report() .change_context(errors::CryptoError::DecodingFailed)?; let encrypted_data = crypt_algo.encode_message(key, &data)?; @@ -96,9 +94,8 @@ impl< let encrypted = encrypted_data.into_inner(); let data = crypt_algo.decode_message(key, encrypted.clone())?; - let value: serde_json::Value = serde_json::from_slice(&data) - .into_report() - .change_context(errors::CryptoError::DecodingFailed)?; + let value: serde_json::Value = + serde_json::from_slice(&data).change_context(errors::CryptoError::DecodingFailed)?; Ok(Self::new(value.into(), encrypted)) } diff --git a/crates/router/src/types/domain/user.rs b/crates/router/src/types/domain/user.rs index 176b58101585..4625a72f5dd6 100644 --- a/crates/router/src/types/domain/user.rs +++ b/crates/router/src/types/domain/user.rs @@ -11,7 +11,7 @@ use diesel_models::{ user as storage_user, user_role::{UserRole, UserRoleNew}, }; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use masking::{ExposeInterface, PeekInterface, Secret}; use once_cell::sync::Lazy; use router_env::env; @@ -319,8 +319,8 @@ impl NewUserMerchant { return Err(UserErrors::MerchantAccountCreationError(format!( "Merchant with {} already exists", self.get_merchant_id() - ))) - .into_report(); + )) + .into()); } Ok(()) } @@ -499,9 +499,9 @@ impl NewUser { Ok(user) => Ok(user.into()), Err(e) => { if e.current_context().is_db_unique_violation() { - return Err(e.change_context(UserErrors::UserExists)); + Err(e.change_context(UserErrors::UserExists)) } else { - return Err(e.change_context(UserErrors::InternalServerError)); + Err(e.change_context(UserErrors::InternalServerError)) } } } @@ -515,7 +515,7 @@ impl NewUser { .await .is_ok() { - return Err(UserErrors::UserExists).into_report(); + return Err(report!(UserErrors::UserExists)); } Ok(()) } diff --git a/crates/router/src/types/pm_auth.rs b/crates/router/src/types/pm_auth.rs index e2d08c6afeac..555e8351ecf7 100644 --- a/crates/router/src/types/pm_auth.rs +++ b/crates/router/src/types/pm_auth.rs @@ -1,6 +1,6 @@ use std::str::FromStr; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use pm_auth::{ connector::plaid, types::{ @@ -17,7 +17,6 @@ use crate::core::{ impl PaymentAuthConnectorDataExt for PaymentAuthConnectorData { fn get_connector_by_name(name: &str) -> errors::CustomResult { let connector_name = pm_auth_types::PaymentMethodAuthConnectors::from_str(name) - .into_report() .change_context(ApiErrorResponse::IncorrectConnectorNameGiven) .attach_printable_lazy(|| { format!("unable to parse connector: {:?}", name.to_string()) diff --git a/crates/router/src/types/storage/dispute.rs b/crates/router/src/types/storage/dispute.rs index 84a1f748bee9..b76325acfc10 100644 --- a/crates/router/src/types/storage/dispute.rs +++ b/crates/router/src/types/storage/dispute.rs @@ -3,7 +3,7 @@ use common_utils::errors::CustomResult; use diesel::{associations::HasTable, ExpressionMethods, QueryDsl}; pub use diesel_models::dispute::{Dispute, DisputeNew, DisputeUpdate}; use diesel_models::{errors, query::generics::db_metrics, schema::dispute::dsl}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use crate::{connection::PgPooledConn, logger}; @@ -69,7 +69,6 @@ impl DisputeDbExt for Dispute { db_metrics::DatabaseOperation::Filter, ) .await - .into_report() .change_context(errors::DatabaseError::NotFound) .attach_printable_lazy(|| "Error filtering records by predicate") } diff --git a/crates/router/src/types/storage/mandate.rs b/crates/router/src/types/storage/mandate.rs index 05a5733053fb..648011ade313 100644 --- a/crates/router/src/types/storage/mandate.rs +++ b/crates/router/src/types/storage/mandate.rs @@ -5,7 +5,7 @@ pub use diesel_models::mandate::{ Mandate, MandateNew, MandateUpdate, MandateUpdateInternal, SingleUseMandate, }; use diesel_models::{errors, schema::mandate::dsl}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use crate::{connection::PgPooledConn, logger}; @@ -63,7 +63,6 @@ impl MandateDbExt for Mandate { filter .get_results_async(conn) .await - .into_report() // The query built here returns an empty Vec when no records are found, and if any error does occur, // it would be an internal database error, due to which we are raising a DatabaseError::Unknown error .change_context(errors::DatabaseError::Others) diff --git a/crates/router/src/types/storage/payment_link.rs b/crates/router/src/types/storage/payment_link.rs index 4dd9e06b4b41..6b4869817cc8 100644 --- a/crates/router/src/types/storage/payment_link.rs +++ b/crates/router/src/types/storage/payment_link.rs @@ -4,7 +4,7 @@ pub use diesel_models::{ payment_link::{PaymentLink, PaymentLinkNew}, schema::payment_link::dsl, }; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use crate::{ connection::PgPooledConn, @@ -57,7 +57,6 @@ impl PaymentLinkDbExt for PaymentLink { filter .get_results_async(conn) .await - .into_report() // The query built here returns an empty Vec when no records are found, and if any error does occur, // it would be an internal database error, due to which we are raising a DatabaseError::Unknown error .change_context(errors::DatabaseError::Others) diff --git a/crates/router/src/types/storage/refund.rs b/crates/router/src/types/storage/refund.rs index bb05233173c8..76bdf8655f6f 100644 --- a/crates/router/src/types/storage/refund.rs +++ b/crates/router/src/types/storage/refund.rs @@ -10,7 +10,7 @@ use diesel_models::{ query::generics::db_metrics, schema::refund::dsl, }; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use crate::{connection::PgPooledConn, logger}; @@ -123,7 +123,6 @@ impl RefundDbExt for Refund { db_metrics::DatabaseOperation::Filter, ) .await - .into_report() .change_context(errors::DatabaseError::NotFound) .attach_printable_lazy(|| "Error filtering records by predicate") } @@ -152,7 +151,6 @@ impl RefundDbExt for Refund { .order_by(dsl::connector.asc()) .get_results_async(conn) .await - .into_report() .change_context(errors::DatabaseError::Others) .attach_printable("Error filtering records by connector")?; @@ -163,7 +161,6 @@ impl RefundDbExt for Refund { .order_by(dsl::currency.asc()) .get_results_async(conn) .await - .into_report() .change_context(errors::DatabaseError::Others) .attach_printable("Error filtering records by currency")?; @@ -173,7 +170,6 @@ impl RefundDbExt for Refund { .order_by(dsl::refund_status.asc()) .get_results_async(conn) .await - .into_report() .change_context(errors::DatabaseError::Others) .attach_printable("Error filtering records by refund status")?; @@ -248,7 +244,6 @@ impl RefundDbExt for Refund { filter .get_result_async::(conn) .await - .into_report() .change_context(errors::DatabaseError::NotFound) .attach_printable_lazy(|| "Error filtering count of refunds") } diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rs index 2f0c94799140..8a53a58aabd9 100644 --- a/crates/router/src/types/transformers.rs +++ b/crates/router/src/types/transformers.rs @@ -9,7 +9,7 @@ use common_utils::{ pii, }; use diesel_models::enums as storage_enums; -use error_stack::{report, IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use masking::{ExposeInterface, PeekInterface}; use super::domain; @@ -221,8 +221,7 @@ impl ForeignTryFrom for common_enums::RoutableConnectors { api_enums::Connector::Plaid => { Err(common_utils::errors::ValidationError::InvalidValue { message: "plaid is not a routable connector".to_string(), - }) - .into_report()? + })? } api_enums::Connector::Powertranz => Self::Powertranz, api_enums::Connector::Prophetpay => Self::Prophetpay, @@ -231,14 +230,12 @@ impl ForeignTryFrom for common_enums::RoutableConnectors { api_enums::Connector::Signifyd => { Err(common_utils::errors::ValidationError::InvalidValue { message: "signifyd is not a routable connector".to_string(), - }) - .into_report()? + })? } api_enums::Connector::Riskified => { Err(common_utils::errors::ValidationError::InvalidValue { message: "riskified is not a routable connector".to_string(), - }) - .into_report()? + })? } api_enums::Connector::Square => Self::Square, api_enums::Connector::Stax => Self::Stax, @@ -267,8 +264,7 @@ impl ForeignTryFrom for common_enums::RoutableConnectors { api_enums::Connector::Threedsecureio => { Err(common_utils::errors::ValidationError::InvalidValue { message: "threedsecureio is not a routable connector".to_string(), - }) - .into_report()? + })? } }) } diff --git a/crates/router/src/utils.rs b/crates/router/src/utils.rs index bfd3609d50f3..56f68e33d3b0 100644 --- a/crates/router/src/utils.rs +++ b/crates/router/src/utils.rs @@ -24,7 +24,7 @@ pub use common_utils::{ validation::validate_email, }; use data_models::payments::PaymentIntent; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use image::Luma; use masking::ExposeInterface; use nanoid::nanoid; @@ -127,32 +127,28 @@ impl ConnectorResponseExt for Result, error_stack::Report> { fn get_error_response(self) -> RouterResult { - self.change_context(errors::ApiErrorResponse::InternalServerError) + self.map_err(|error| error.change_context(errors::ApiErrorResponse::InternalServerError)) .attach_printable("Error while receiving response") .and_then(|inner| match inner { Ok(res) => { logger::error!(response=?res); - Err(errors::ApiErrorResponse::InternalServerError) - .into_report() - .attach_printable(format!( - "Expecting error response, received response: {res:?}" - )) + Err(errors::ApiErrorResponse::InternalServerError).attach_printable(format!( + "Expecting error response, received response: {res:?}" + )) } Err(err_res) => Ok(err_res), }) } fn get_response(self) -> RouterResult { - self.change_context(errors::ApiErrorResponse::InternalServerError) + self.map_err(|error| error.change_context(errors::ApiErrorResponse::InternalServerError)) .attach_printable("Error while receiving response") .and_then(|inner| match inner { Err(err_res) => { logger::error!(error_response=?err_res); - Err(errors::ApiErrorResponse::InternalServerError) - .into_report() - .attach_printable(format!( - "Expecting response, received error response: {err_res:?}" - )) + Err(errors::ApiErrorResponse::InternalServerError).attach_printable(format!( + "Expecting response, received error response: {err_res:?}" + )) } Ok(res) => Ok(res), }) @@ -174,7 +170,6 @@ impl QrImage { data: String, ) -> Result> { let qr_code = qrcode::QrCode::new(data.as_bytes()) - .into_report() .change_context(common_utils::errors::QrCodeError::FailedToCreateQrCode)?; // Renders the QR code into an image. @@ -318,7 +313,6 @@ pub async fn find_payment_intent_from_mandate_id_type( &mandate .original_payment_id .ok_or(errors::ApiErrorResponse::InternalServerError) - .into_report() .attach_printable("original_payment_id not present in mandate record")?, &merchant_account.merchant_id, merchant_account.storage_scheme, @@ -434,7 +428,6 @@ pub fn handle_json_response_deserialization_failure( ); let response_data = String::from_utf8(res.response.to_vec()) - .into_report() .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; // check for whether the response is in json format @@ -467,7 +460,6 @@ pub fn get_http_status_code_type( 400..=499 => "4xx", 500..=599 => "5xx", _ => Err(errors::ApiErrorResponse::InternalServerError) - .into_report() .attach_printable("Invalid http status code")?, }; Ok(status_code_type.to_string()) @@ -842,7 +834,6 @@ pub async fn flatten_join_error(handle: Handle) -> RouterResult { Ok(Ok(t)) => Ok(t), Ok(Err(err)) => Err(err), Err(err) => Err(err) - .into_report() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Join Error"), } diff --git a/crates/router/src/utils/connector_onboarding/paypal.rs b/crates/router/src/utils/connector_onboarding/paypal.rs index ff9b5ab59e7b..708763a44409 100644 --- a/crates/router/src/utils/connector_onboarding/paypal.rs +++ b/crates/router/src/utils/connector_onboarding/paypal.rs @@ -1,5 +1,5 @@ use common_utils::request::{Method, Request, RequestBuilder, RequestContent}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use http::header; use crate::{ @@ -28,17 +28,16 @@ pub async fn generate_access_token(state: AppState) -> RouterResult for ExchangeRates { let mut conversion_usable: HashMap = HashMap::new(); for (curr, conversion) in value.conversion { let enum_curr = enums::Currency::from_str(curr.as_str()) - .into_report() .change_context(ForexCacheError::ConversionError)?; conversion_usable.insert(enum_curr, CurrencyFactors::from(conversion)); } let base_curr = enums::Currency::from_str(value.base_currency.as_str()) - .into_report() .change_context(ForexCacheError::ConversionError)?; Ok(Self { base_currency: base_curr, @@ -342,7 +340,6 @@ async fn fetch_forex_rates( let forex_response = response .json::() .await - .into_report() .change_context(ForexCacheError::ParsingError)?; logger::info!("{:?}", forex_response); @@ -399,7 +396,6 @@ pub async fn fallback_fetch_forex_rates( let fallback_forex_response = response .json::() .await - .into_report() .change_context(ForexCacheError::ParsingError)?; logger::info!("{:?}", fallback_forex_response); @@ -463,11 +459,11 @@ async fn acquire_redis_lock(app_state: &AppState) -> CustomResult UserResult { let now = common_utils::date_time::now(); let data_value = serde_json::to_value(metadata_value) - .into_report() .change_context(UserErrors::InternalServerError) .attach_printable("Error Converting Struct To Serde Value")?; state @@ -60,7 +59,6 @@ pub async fn insert_user_scoped_metadata_to_db( ) -> UserResult { let now = common_utils::date_time::now(); let data_value = serde_json::to_value(metadata_value) - .into_report() .change_context(UserErrors::InternalServerError) .attach_printable("Error Converting Struct To Serde Value")?; state @@ -131,7 +129,6 @@ pub async fn update_merchant_scoped_metadata( metadata_value: impl serde::Serialize, ) -> UserResult { let data_value = serde_json::to_value(metadata_value) - .into_report() .change_context(UserErrors::InternalServerError) .attach_printable("Error Converting Struct To Serde Value")?; @@ -160,7 +157,6 @@ pub async fn update_user_scoped_metadata( metadata_value: impl serde::Serialize, ) -> UserResult { let data_value = serde_json::to_value(metadata_value) - .into_report() .change_context(UserErrors::InternalServerError) .attach_printable("Error Converting Struct To Serde Value")?; @@ -187,7 +183,7 @@ where { data.map(|metadata| serde_json::from_value(metadata.data_value.clone())) .transpose() - .map_err(|_| UserErrors::InternalServerError.into()) + .change_context(UserErrors::InternalServerError) .attach_printable("Error Serializing Metadata from DB") } @@ -248,10 +244,10 @@ pub fn set_ip_address_if_required( if let SetMetaDataRequest::ProductionAgreement(req) = request { let ip_address_from_request: Secret = headers .get(headers::X_FORWARDED_FOR) - .ok_or(UserErrors::IpAddressParsingFailed.into()) + .ok_or(report!(UserErrors::IpAddressParsingFailed)) .attach_printable("X-Forwarded-For header not found")? .to_str() - .map_err(|_| UserErrors::IpAddressParsingFailed.into()) + .change_context(UserErrors::IpAddressParsingFailed) .attach_printable("Error converting Header Value to Str")? .split(',') .next() @@ -259,7 +255,7 @@ pub fn set_ip_address_if_required( let ip_addr: Result = ip.parse(); ip_addr.ok() }) - .ok_or(UserErrors::IpAddressParsingFailed.into()) + .ok_or(report!(UserErrors::IpAddressParsingFailed)) .attach_printable("Error Parsing header value to ip")? .to_string() .into(); @@ -274,7 +270,7 @@ pub fn parse_string_to_enums(query: String) -> UserResult, _>>() - .map_err(|_| UserErrors::InvalidMetadataRequest.into()) + .change_context(UserErrors::InvalidMetadataRequest) .attach_printable("Error Parsing to DashboardMetadata enums")?, }) } diff --git a/crates/router/src/utils/user/password.rs b/crates/router/src/utils/user/password.rs index cff17863c32d..5ed8d83658de 100644 --- a/crates/router/src/utils/user/password.rs +++ b/crates/router/src/utils/user/password.rs @@ -6,7 +6,7 @@ use argon2::{ Argon2, }; use common_utils::errors::CustomResult; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::{ExposeInterface, Secret}; use crate::core::errors::UserErrors; @@ -19,7 +19,6 @@ pub fn generate_password_hash( let argon2 = Argon2::default(); let password_hash = argon2 .hash_password(password.expose().as_bytes(), &salt) - .into_report() .change_context(UserErrors::InternalServerError)?; Ok(Secret::new(password_hash.to_string())) } @@ -29,15 +28,13 @@ pub fn is_correct_password( password: Secret, ) -> CustomResult { let password = password.expose(); - let parsed_hash = PasswordHash::new(&password) - .into_report() - .change_context(UserErrors::InternalServerError)?; + let parsed_hash = + PasswordHash::new(&password).change_context(UserErrors::InternalServerError)?; let result = Argon2::default().verify_password(candidate.expose().as_bytes(), &parsed_hash); match result { Ok(_) => Ok(true), Err(argon2Err::Password) => Ok(false), Err(e) => Err(e), } - .into_report() .change_context(UserErrors::InternalServerError) } diff --git a/crates/router/src/utils/user/sample_data.rs b/crates/router/src/utils/user/sample_data.rs index 8a09900c9587..8469bf770d2b 100644 --- a/crates/router/src/utils/user/sample_data.rs +++ b/crates/router/src/utils/user/sample_data.rs @@ -4,7 +4,7 @@ use api_models::{ }; use data_models::payments::payment_intent::PaymentIntentNew; use diesel_models::{user::sample_data::PaymentAttemptBatchNew, RefundNew}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use rand::{prelude::SliceRandom, thread_rng, Rng}; use time::OffsetDateTime; @@ -44,7 +44,6 @@ pub async fn generate_sample_data( let merchant_parsed_details: Vec = serde_json::from_value(merchant_from_db.primary_business_details.clone()) - .into_report() .change_context(SampleDataError::InternalServerError) .attach_printable("Error while parsing primary business details")?; @@ -84,7 +83,6 @@ pub async fn generate_sample_data( // 10 percent payments should be failed #[allow(clippy::as_conversions)] let failure_attempts = usize::try_from((sample_data_size as f32 / 10.0).round() as i64) - .into_report() .change_context(SampleDataError::InvalidParameters)?; let failure_after_attempts = sample_data_size / failure_attempts; @@ -92,7 +90,6 @@ pub async fn generate_sample_data( // 20 percent refunds for payments #[allow(clippy::as_conversions)] let number_of_refunds = usize::try_from((sample_data_size as f32 / 5.0).round() as i64) - .into_report() .change_context(SampleDataError::InvalidParameters)?; let mut refunds_count = 0; diff --git a/crates/router/src/utils/user_role.rs b/crates/router/src/utils/user_role.rs index 23b5bcf0f388..1fb58f983af7 100644 --- a/crates/router/src/utils/user_role.rs +++ b/crates/router/src/utils/user_role.rs @@ -3,7 +3,7 @@ use std::collections::HashSet; use api_models::user_role as user_role_api; use common_enums::PermissionGroup; use diesel_models::user_role::UserRole; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use router_env::logger; use crate::{ @@ -52,19 +52,19 @@ impl From for user_role_api::Permission { pub fn validate_role_groups(groups: &[PermissionGroup]) -> UserResult<()> { if groups.is_empty() { - return Err(UserErrors::InvalidRoleOperation.into()) + return Err(report!(UserErrors::InvalidRoleOperation)) .attach_printable("Role groups cannot be empty"); } let unique_groups: HashSet<_> = groups.iter().cloned().collect(); if unique_groups.contains(&PermissionGroup::OrganizationManage) { - return Err(UserErrors::InvalidRoleOperation.into()) + return Err(report!(UserErrors::InvalidRoleOperation)) .attach_printable("Organization manage group cannot be added to role"); } if unique_groups.len() != groups.len() { - return Err(UserErrors::InvalidRoleOperation.into()) + return Err(report!(UserErrors::InvalidRoleOperation)) .attach_printable("Duplicate permission group found"); } @@ -133,9 +133,7 @@ pub async fn set_role_permissions_in_cache_if_required( state, role_id, &role_info.get_permissions_set().into_iter().collect(), - consts::JWT_TOKEN_TIME_IN_SECS - .try_into() - .into_report() + i64::try_from(consts::JWT_TOKEN_TIME_IN_SECS) .change_context(UserErrors::InternalServerError)?, ) .await diff --git a/crates/router/src/utils/verify_connector.rs b/crates/router/src/utils/verify_connector.rs index 060f92d0e5a8..acb2f6096317 100644 --- a/crates/router/src/utils/verify_connector.rs +++ b/crates/router/src/utils/verify_connector.rs @@ -1,5 +1,5 @@ use api_models::enums::Connector; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use crate::{core::errors, types::api}; @@ -11,8 +11,7 @@ pub fn generate_card_from_details( ) -> errors::RouterResult { Ok(api::Card { card_number: card_number - .parse() - .into_report() + .parse::() .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Error while parsing card number")?, card_issuer: None, diff --git a/crates/router_env/Cargo.toml b/crates/router_env/Cargo.toml index a028dfb8e563..c161d02b8d21 100644 --- a/crates/router_env/Cargo.toml +++ b/crates/router_env/Cargo.toml @@ -10,7 +10,7 @@ license.workspace = true [dependencies] cargo_metadata = "0.18.1" config = { version = "0.13.3", features = ["toml"] } -error-stack = "0.3.1" +error-stack = "0.4.1" gethostname = "0.4.3" once_cell = "1.18.0" opentelemetry = { version = "0.19.0", features = ["rt-tokio-current-thread", "metrics"] } diff --git a/crates/scheduler/Cargo.toml b/crates/scheduler/Cargo.toml index cad5dec6283a..4f2a423709fb 100644 --- a/crates/scheduler/Cargo.toml +++ b/crates/scheduler/Cargo.toml @@ -12,7 +12,7 @@ email = ["external_services/email"] [dependencies] # Third party crates async-trait = "0.1.68" -error-stack = "0.3.1" +error-stack = "0.4.1" futures = "0.3.28" num_cpus = "1.15.0" once_cell = "1.18.0" diff --git a/crates/scheduler/src/consumer.rs b/crates/scheduler/src/consumer.rs index 471f689ffc81..a95ac4932471 100644 --- a/crates/scheduler/src/consumer.rs +++ b/crates/scheduler/src/consumer.rs @@ -7,7 +7,7 @@ pub mod workflows; use common_utils::{errors::CustomResult, signals::get_allowed_signals}; use diesel_models::enums; pub use diesel_models::{self, process_tracker as storage}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use futures::future; use redis_interface::{RedisConnectionPool, RedisEntryId}; use router_env::{ @@ -48,7 +48,6 @@ pub async fn start_consumer( #[allow(unknown_lints)] #[allow(clippy::unnecessary_fallible_conversions)] let timeout = Uniform::try_from(0..=settings.loop_interval) - .into_report() .change_context(errors::ProcessTrackerError::ConfigurationError)?; tokio::time::sleep(Duration::from_millis(timeout.sample(&mut rng))).await; @@ -64,7 +63,6 @@ pub async fn start_consumer( logger::error!(?error, "Signal Handler Error"); errors::ProcessTrackerError::ConfigurationError }) - .into_report() .attach_printable("Failed while creating a signals handler")?; let handle = signal.handle(); let task_handle = @@ -112,7 +110,6 @@ pub async fn start_consumer( handle.close(); task_handle .await - .into_report() .change_context(errors::ProcessTrackerError::UnexpectedFlow)?; Ok(()) diff --git a/crates/scheduler/src/consumer/types/batch.rs b/crates/scheduler/src/consumer/types/batch.rs index b9748e1ecac0..50c6f39465f9 100644 --- a/crates/scheduler/src/consumer/types/batch.rs +++ b/crates/scheduler/src/consumer/types/batch.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use common_utils::{errors::CustomResult, ext_traits::OptionExt}; use diesel_models::process_tracker::ProcessTracker; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use time::PrimitiveDateTime; use crate::errors; @@ -35,7 +35,6 @@ impl ProcessTrackerBatch { ( "trackers", serde_json::to_string(&self.trackers) - .into_report() .change_context(errors::ProcessTrackerError::SerializationFailed) .attach_printable_lazy(|| { format!("Unable to stringify trackers: {:?}", self.trackers) @@ -79,12 +78,10 @@ impl ProcessTrackerBatch { let offset_date_time = time::OffsetDateTime::from_unix_timestamp( created_time .as_str() - .parse() - .into_report() + .parse::() .change_context(errors::ParsingError::UnknownError) .change_context(errors::ProcessTrackerError::DeserializationFailed)?, ) - .into_report() .attach_printable_lazy(|| format!("Unable to parse time {}", &created_time)) .change_context(errors::ProcessTrackerError::MissingRequiredField)?; PrimitiveDateTime::new(offset_date_time.date(), offset_date_time.time()) @@ -102,12 +99,12 @@ impl ProcessTrackerBatch { .change_context(errors::ProcessTrackerError::MissingRequiredField)?; let trackers = serde_json::from_str::>(trackers.as_str()) - .into_report() .change_context(errors::ParsingError::UnknownError) .attach_printable_lazy(|| { format!("Unable to parse trackers from JSON string: {trackers:?}") }) - .change_context(errors::ProcessTrackerError::DeserializationFailed)?; + .change_context(errors::ProcessTrackerError::DeserializationFailed) + .attach_printable("Error parsing ProcessTracker from redis stream entry")?; Ok(Self { id, @@ -118,6 +115,5 @@ impl ProcessTrackerBatch { rule, trackers, }) - .attach_printable("Error parsing ProcessTracker from redis stream entry") } } diff --git a/crates/scheduler/src/db/process_tracker.rs b/crates/scheduler/src/db/process_tracker.rs index ac20d4b293f0..feb201f8b756 100644 --- a/crates/scheduler/src/db/process_tracker.rs +++ b/crates/scheduler/src/db/process_tracker.rs @@ -1,7 +1,7 @@ use common_utils::errors::CustomResult; pub use diesel_models as storage; use diesel_models::enums as storage_enums; -use error_stack::{IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use storage_impl::{connection, errors, mock_db::MockDb}; use time::PrimitiveDateTime; @@ -73,8 +73,7 @@ impl ProcessTrackerInterface for Store { let conn = connection::pg_connection_read(self).await?; storage::ProcessTracker::find_process_by_id(&conn, id) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } async fn reinitialize_limbo_processes( @@ -85,8 +84,7 @@ impl ProcessTrackerInterface for Store { let conn = connection::pg_connection_write(self).await?; storage::ProcessTracker::reinitialize_limbo_processes(&conn, ids, schedule_time) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } async fn find_processes_by_time_status( @@ -105,8 +103,7 @@ impl ProcessTrackerInterface for Store { limit, ) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } async fn insert_process( @@ -116,8 +113,7 @@ impl ProcessTrackerInterface for Store { let conn = connection::pg_connection_write(self).await?; new.insert_process(&conn) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } async fn update_process( @@ -128,8 +124,7 @@ impl ProcessTrackerInterface for Store { let conn = connection::pg_connection_write(self).await?; this.update(&conn, process) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } async fn reset_process( @@ -194,8 +189,7 @@ impl ProcessTrackerInterface for Store { let conn = connection::pg_connection_write(self).await?; storage::ProcessTracker::update_process_status_by_ids(&conn, task_ids, task_update) .await - .map_err(Into::into) - .into_report() + .map_err(|error| report!(errors::StorageError::from(error))) } } diff --git a/crates/scheduler/src/producer.rs b/crates/scheduler/src/producer.rs index b8081c2b9ae4..fd2b9b654a45 100644 --- a/crates/scheduler/src/producer.rs +++ b/crates/scheduler/src/producer.rs @@ -2,7 +2,7 @@ use std::sync::Arc; use common_utils::errors::CustomResult; use diesel_models::enums::ProcessTrackerStatus; -use error_stack::{report, IntoReport, ResultExt}; +use error_stack::{report, ResultExt}; use router_env::{ instrument, tracing::{self, Instrument}, @@ -39,7 +39,6 @@ where #[allow(unknown_lints)] #[allow(clippy::unnecessary_fallible_conversions)] let timeout = Uniform::try_from(0..=scheduler_settings.loop_interval) - .into_report() .change_context(errors::ProcessTrackerError::ConfigurationError)?; tokio::time::sleep(Duration::from_millis(timeout.sample(&mut rng))).await; @@ -57,7 +56,6 @@ where logger::error!("Signal Handler Error: {:?}", error); errors::ProcessTrackerError::ConfigurationError }) - .into_report() .attach_printable("Failed while creating a signals handler")?; let handle = signal.handle(); let task_handle = @@ -89,7 +87,6 @@ where handle.close(); task_handle .await - .into_report() .change_context(errors::ProcessTrackerError::UnexpectedFlow)?; Ok(()) diff --git a/crates/storage_impl/Cargo.toml b/crates/storage_impl/Cargo.toml index 0bffd846506a..d7107cdccfa3 100644 --- a/crates/storage_impl/Cargo.toml +++ b/crates/storage_impl/Cargo.toml @@ -35,7 +35,7 @@ config = { version = "0.13.3", features = ["toml"] } crc32fast = "1.3.2" diesel = { version = "2.1.0", default-features = false, features = ["postgres"] } dyn-clone = "1.0.12" -error-stack = "0.3.1" +error-stack = "0.4.1" futures = "0.3.28" http = "0.2.9" mime = "0.3.17" diff --git a/crates/storage_impl/src/connection.rs b/crates/storage_impl/src/connection.rs index 2ac90521ba4a..4d19f3820e91 100644 --- a/crates/storage_impl/src/connection.rs +++ b/crates/storage_impl/src/connection.rs @@ -1,7 +1,7 @@ use bb8::PooledConnection; use common_utils::errors; use diesel::PgConnection; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; pub type PgPool = bb8::Pool>; @@ -43,7 +43,6 @@ pub async fn pg_connection_read( pool.get() .await - .into_report() .change_context(crate::errors::StorageError::DatabaseConnectionError) } @@ -58,6 +57,5 @@ pub async fn pg_connection_write( pool.get() .await - .into_report() .change_context(crate::errors::StorageError::DatabaseConnectionError) } diff --git a/crates/storage_impl/src/database/store.rs b/crates/storage_impl/src/database/store.rs index 75c34af14ac1..92ba8910bfbc 100644 --- a/crates/storage_impl/src/database/store.rs +++ b/crates/storage_impl/src/database/store.rs @@ -2,7 +2,7 @@ use async_bb8_diesel::{AsyncConnection, ConnectionError}; use bb8::CustomizeConnection; use data_models::errors::{StorageError, StorageResult}; use diesel::PgConnection; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use masking::PeekInterface; use crate::config::Database; @@ -99,7 +99,6 @@ pub async fn diesel_make_pg_pool( pool.build(manager) .await - .into_report() .change_context(StorageError::InitializationError) .attach_printable("Failed to create PostgreSQL connection pool") } diff --git a/crates/storage_impl/src/lookup.rs b/crates/storage_impl/src/lookup.rs index c96e24515772..12d91ba5e953 100644 --- a/crates/storage_impl/src/lookup.rs +++ b/crates/storage_impl/src/lookup.rs @@ -6,7 +6,7 @@ use diesel_models::{ ReverseLookup as DieselReverseLookup, ReverseLookupNew as DieselReverseLookupNew, }, }; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use redis_interface::SetnxReply; use crate::{ @@ -42,7 +42,6 @@ impl ReverseLookupInterface for RouterStore { .get_master_pool() .get() .await - .into_report() .change_context(errors::StorageError::DatabaseConnectionError)?; new.insert(&conn).await.map_err(|er| { let new_err = diesel_error_to_data_error(er.current_context()); @@ -105,8 +104,8 @@ impl ReverseLookupInterface for KVRouterStore { Ok(SetnxReply::KeyNotSet) => Err(errors::StorageError::DuplicateValue { entity: "reverse_lookup", key: Some(created_rev_lookup.lookup_id.clone()), - }) - .into_report(), + } + .into()), Err(er) => Err(er).change_context(errors::StorageError::KVError), } } diff --git a/crates/storage_impl/src/mock_db/payment_intent.rs b/crates/storage_impl/src/mock_db/payment_intent.rs index 03e6539f162a..a693eb5e2613 100644 --- a/crates/storage_impl/src/mock_db/payment_intent.rs +++ b/crates/storage_impl/src/mock_db/payment_intent.rs @@ -8,7 +8,7 @@ use data_models::{ }, }; use diesel_models::enums as storage_enums; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use super::MockDb; use crate::DataModelExt; @@ -66,11 +66,7 @@ impl PaymentIntentInterface for MockDb { let time = common_utils::date_time::now(); let payment_intent = PaymentIntent { #[allow(clippy::as_conversions)] - id: payment_intents - .len() - .try_into() - .into_report() - .change_context(StorageError::MockDbError)?, + id: i32::try_from(payment_intents.len()).change_context(StorageError::MockDbError)?, payment_id: new.payment_id, merchant_id: new.merchant_id, status: new.status, diff --git a/crates/storage_impl/src/payments/payment_attempt.rs b/crates/storage_impl/src/payments/payment_attempt.rs index 04e755fa4303..b8b97628db78 100644 --- a/crates/storage_impl/src/payments/payment_attempt.rs +++ b/crates/storage_impl/src/payments/payment_attempt.rs @@ -23,7 +23,7 @@ use diesel_models::{ }, reverse_lookup::{ReverseLookup, ReverseLookupNew}, }; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use redis_interface::HsetnxReply; use router_env::{instrument, tracing}; @@ -299,7 +299,6 @@ impl PaymentAttemptInterface for RouterStore { .get_replica_pool() .get() .await - .into_report() .change_context(errors::StorageError::DatabaseConnectionError)?; let connector_strings = connector.as_ref().map(|connector| { connector @@ -449,8 +448,8 @@ impl PaymentAttemptInterface for KVRouterStore { Ok(HsetnxReply::KeyNotSet) => Err(errors::StorageError::DuplicateValue { entity: "payment attempt", key: Some(key), - }) - .into_report(), + } + .into()), Ok(HsetnxReply::KeySet) => Ok(created_attempt), Err(error) => Err(error.change_context(errors::StorageError::KVError)), } @@ -483,7 +482,6 @@ impl PaymentAttemptInterface for KVRouterStore { ); // Check for database presence as well Maybe use a read replica here ? let redis_value = serde_json::to_string(&updated_attempt) - .into_report() .change_context(errors::StorageError::KVError)?; let field = format!("pa_{}", updated_attempt.attempt_id); diff --git a/crates/storage_impl/src/payments/payment_intent.rs b/crates/storage_impl/src/payments/payment_intent.rs index 40627d1eeba3..6323c9a98502 100644 --- a/crates/storage_impl/src/payments/payment_intent.rs +++ b/crates/storage_impl/src/payments/payment_intent.rs @@ -28,7 +28,7 @@ use diesel_models::{ query::generics::db_metrics, schema::{payment_attempt::dsl as pa_dsl, payment_intent::dsl as pi_dsl}, }; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use redis_interface::HsetnxReply; #[cfg(feature = "olap")] use router_env::logger; @@ -128,8 +128,8 @@ impl PaymentIntentInterface for KVRouterStore { Ok(HsetnxReply::KeyNotSet) => Err(StorageError::DuplicateValue { entity: "payment_intent", key: Some(key), - }) - .into_report(), + } + .into()), Ok(HsetnxReply::KeySet) => Ok(created_intent), Err(error) => Err(error.change_context(StorageError::KVError)), } @@ -508,8 +508,8 @@ impl PaymentIntentInterface for crate::RouterStore { error_stack::report!(diesel_models::errors::DatabaseError::from(er)) .attach_printable("Error filtering payment records"), ) + .into() }) - .into_report() } #[cfg(feature = "olap")] @@ -663,8 +663,8 @@ impl PaymentIntentInterface for crate::RouterStore { error_stack::report!(diesel_models::errors::DatabaseError::from(er)) .attach_printable("Error filtering payment records"), ) + .into() }) - .into_report() } #[cfg(feature = "olap")] @@ -731,8 +731,8 @@ impl PaymentIntentInterface for crate::RouterStore { error_stack::report!(diesel_models::errors::DatabaseError::from(er)) .attach_printable("Error filtering payment records"), ) + .into() }) - .into_report() } } diff --git a/crates/storage_impl/src/payouts/payout_attempt.rs b/crates/storage_impl/src/payouts/payout_attempt.rs index c52291253ef5..1f6c02c1fbad 100644 --- a/crates/storage_impl/src/payouts/payout_attempt.rs +++ b/crates/storage_impl/src/payouts/payout_attempt.rs @@ -21,7 +21,7 @@ use diesel_models::{ }, ReverseLookupNew, }; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use redis_interface::HsetnxReply; use router_env::{instrument, logger, tracing}; @@ -115,8 +115,8 @@ impl PayoutAttemptInterface for KVRouterStore { Ok(HsetnxReply::KeyNotSet) => Err(errors::StorageError::DuplicateValue { entity: "payout attempt", key: Some(key), - }) - .into_report(), + } + .into()), Ok(HsetnxReply::KeySet) => Ok(created_attempt), Err(error) => Err(error.change_context(errors::StorageError::KVError)), } diff --git a/crates/storage_impl/src/payouts/payouts.rs b/crates/storage_impl/src/payouts/payouts.rs index c42ed1201786..c6ff6250d486 100644 --- a/crates/storage_impl/src/payouts/payouts.rs +++ b/crates/storage_impl/src/payouts/payouts.rs @@ -23,7 +23,7 @@ use diesel_models::{ query::generics::db_metrics, schema::{payout_attempt::dsl as poa_dsl, payouts::dsl as po_dsl}, }; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use redis_interface::HsetnxReply; #[cfg(feature = "olap")] use router_env::logger; @@ -100,8 +100,8 @@ impl PayoutsInterface for KVRouterStore { Ok(HsetnxReply::KeyNotSet) => Err(StorageError::DuplicateValue { entity: "payouts", key: Some(key), - }) - .into_report(), + } + .into()), Ok(HsetnxReply::KeySet) => Ok(created_payout), Err(error) => Err(error.change_context(StorageError::KVError)), } @@ -474,8 +474,8 @@ impl PayoutsInterface for crate::RouterStore { error_stack::report!(diesel_models::errors::DatabaseError::from(er)) .attach_printable("Error filtering payout records"), ) + .into() }) - .into_report() } #[cfg(feature = "olap")] @@ -603,8 +603,8 @@ impl PayoutsInterface for crate::RouterStore { error_stack::report!(diesel_models::errors::DatabaseError::from(er)) .attach_printable("Error filtering payout records"), ) + .into() }) - .into_report() } #[cfg(feature = "olap")] diff --git a/crates/storage_impl/src/redis.rs b/crates/storage_impl/src/redis.rs index be82d4cc293c..d431b4582917 100644 --- a/crates/storage_impl/src/redis.rs +++ b/crates/storage_impl/src/redis.rs @@ -4,7 +4,7 @@ pub mod pub_sub; use std::sync::{atomic, Arc}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use redis_interface::PubsubInterface; use router_env::{logger, tracing::Instrument}; @@ -53,7 +53,6 @@ impl RedisStore { .subscriber .subscribe::<(), _>(channel) .await - .into_report() .change_context(redis_interface::errors::RedisError::SubscribeError)?; let redis_clone = self.redis_conn.clone(); diff --git a/crates/storage_impl/src/redis/kv_store.rs b/crates/storage_impl/src/redis/kv_store.rs index 310e6e2dc5cc..c7e6efc0b3b5 100644 --- a/crates/storage_impl/src/redis/kv_store.rs +++ b/crates/storage_impl/src/redis/kv_store.rs @@ -1,7 +1,7 @@ use std::{fmt::Debug, sync::Arc}; use common_utils::errors::CustomResult; -use error_stack::IntoReport; +use error_stack::report; use redis_interface::errors::RedisError; use router_derive::TryGetEnumVariant; use router_env::logger; @@ -136,7 +136,7 @@ where .await .and_then(|result| { if result.is_empty() { - Err(RedisError::NotFound).into_report() + Err(report!(RedisError::NotFound)) } else { Ok(result) } @@ -159,7 +159,7 @@ where .await?; Ok(KvResult::HSetNx(result)) } else { - Err(RedisError::SetNxFailed).into_report() + Err(report!(RedisError::SetNxFailed)) } } @@ -178,7 +178,7 @@ where .await?; Ok(KvResult::SetNx(result)) } else { - Err(RedisError::SetNxFailed).into_report() + Err(report!(RedisError::SetNxFailed)) } } diff --git a/crates/storage_impl/src/redis/pub_sub.rs b/crates/storage_impl/src/redis/pub_sub.rs index c00ed13facfd..349d1872d2ab 100644 --- a/crates/storage_impl/src/redis/pub_sub.rs +++ b/crates/storage_impl/src/redis/pub_sub.rs @@ -1,4 +1,4 @@ -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use redis_interface::{errors as redis_errors, PubsubInterface, RedisValue}; use router_env::logger; @@ -27,7 +27,6 @@ impl PubSubInterface for redis_interface::RedisConnectionPool { self.subscriber .subscribe(channel) .await - .into_report() .change_context(redis_errors::RedisError::SubscribeError) } @@ -40,7 +39,6 @@ impl PubSubInterface for redis_interface::RedisConnectionPool { self.publisher .publish(channel, RedisValue::from(key).into_inner()) .await - .into_report() .change_context(redis_errors::RedisError::SubscribeError) } @@ -50,8 +48,7 @@ impl PubSubInterface for redis_interface::RedisConnectionPool { let mut rx = self.subscriber.on_message(); while let Ok(message) = rx.recv().await { logger::debug!("Invalidating {message:?}"); - let key: CacheKind<'_> = match RedisValue::new(message.value) - .try_into() + let key = match CacheKind::try_from(RedisValue::new(message.value)) .change_context(redis_errors::RedisError::OnMessageError) { Ok(value) => value, diff --git a/crates/storage_impl/src/utils.rs b/crates/storage_impl/src/utils.rs index 6d69f02593fd..78198e927532 100644 --- a/crates/storage_impl/src/utils.rs +++ b/crates/storage_impl/src/utils.rs @@ -1,7 +1,7 @@ use bb8::PooledConnection; use data_models::errors::StorageError; use diesel::PgConnection; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use crate::{errors::RedisErrorExt, metrics, DatabaseStore}; @@ -28,7 +28,6 @@ pub async fn pg_connection_read( pool.get() .await - .into_report() .change_context(StorageError::DatabaseConnectionError) } @@ -43,7 +42,6 @@ pub async fn pg_connection_write( pool.get() .await - .into_report() .change_context(StorageError::DatabaseConnectionError) } From 78befb42a35b1f98b1bd47b253d3c06e50bb2ee4 Mon Sep 17 00:00:00 2001 From: Bernard Eugine <114725419+bernard-eugine@users.noreply.github.com> Date: Mon, 1 Apr 2024 12:59:54 +0530 Subject: [PATCH 08/19] docs(README): remove link to outdated early access form --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 90398bf6d15b..2be649b1db6e 100644 --- a/README.md +++ b/README.md @@ -70,8 +70,6 @@ The fastest and easiest way to try Hyperswitch is via our CDK scripts 3. Follow the instructions provided on the console to successfully deploy Hyperswitch -For an early access to the production-ready setup fill this Early Access Form - ### Run it on your system You can run Hyperswitch on your system using Docker Compose after cloning this repository: From a843713126cea102064b342b6fc82429d89d758a Mon Sep 17 00:00:00 2001 From: Prajjwal Kumar Date: Mon, 1 Apr 2024 12:44:39 +0530 Subject: [PATCH 09/19] refactor(core): removed the processing status for payment_method_status (#4213) --- crates/common_enums/src/enums.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs index bbabab3a4e74..548e721f0d39 100644 --- a/crates/common_enums/src/enums.rs +++ b/crates/common_enums/src/enums.rs @@ -1253,7 +1253,6 @@ pub enum PaymentMethodStatus { impl From for PaymentMethodStatus { fn from(attempt_status: AttemptStatus) -> Self { match attempt_status { - AttemptStatus::Charged | AttemptStatus::Authorized => Self::Active, AttemptStatus::Failure => Self::Inactive, AttemptStatus::Voided | AttemptStatus::Started @@ -1275,7 +1274,9 @@ impl From for PaymentMethodStatus { | AttemptStatus::PartialCharged | AttemptStatus::PartialChargedAndChargeable | AttemptStatus::ConfirmationAwaited - | AttemptStatus::DeviceDataCollectionPending => Self::Processing, + | AttemptStatus::DeviceDataCollectionPending + | AttemptStatus::Charged + | AttemptStatus::Authorized => Self::Active, } } } From 740749e18ae4458726cdf2501f3d3b789c819f7a Mon Sep 17 00:00:00 2001 From: Hrithikesh <61539176+hrithikesh026@users.noreply.github.com> Date: Mon, 1 Apr 2024 18:49:55 +0530 Subject: [PATCH 10/19] feat: return customer details in payments response body (#4237) --- crates/api_models/src/payments.rs | 5 ++++- .../router/src/core/payments/transformers.rs | 4 ++++ crates/router/src/types/transformers.rs | 18 ++++++++++++++++++ openapi/openapi_spec.json | 8 ++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs index 72592ec3cad7..63b293061139 100644 --- a/crates/api_models/src/payments.rs +++ b/crates/api_models/src/payments.rs @@ -169,7 +169,7 @@ mod client_secret_tests { } } -#[derive(Default, Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema)] +#[derive(Default, Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema, PartialEq)] pub struct CustomerDetails { /// The identifier for the customer. pub id: String, @@ -2935,6 +2935,9 @@ pub struct PaymentsResponse { #[schema(max_length = 255, example = "cus_y3oqhf46pyzuxjbcn2giaqnb44")] pub customer_id: Option, + /// Details of customer attached to this payment + pub customer: Option, + /// A description of the payment #[schema(example = "It's my first payment request")] pub description: Option, diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs index d686d741c880..9aa552b86d8c 100644 --- a/crates/router/src/core/payments/transformers.rs +++ b/crates/router/src/core/payments/transformers.rs @@ -490,6 +490,8 @@ where )) } + let customer_details_response = customer.as_ref().map(ForeignInto::foreign_into); + headers.extend( external_latency .map(|latency| { @@ -779,6 +781,7 @@ where .set_payment_method_status( payment_data.payment_method_info.map(|info| info.status), ) + .set_customer(customer_details_response.clone()) .to_owned(), headers, )) @@ -849,6 +852,7 @@ where expires_on: payment_intent.session_expiry, external_3ds_authentication_attempted: payment_attempt .external_three_ds_authentication_attempted, + customer: customer_details_response, ..Default::default() }, headers, diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rs index 8a53a58aabd9..237dea196d68 100644 --- a/crates/router/src/types/transformers.rs +++ b/crates/router/src/types/transformers.rs @@ -1130,6 +1130,24 @@ impl ForeignFrom for gsm_api_types::GsmResponse { } } +impl ForeignFrom<&domain::Customer> for api_models::payments::CustomerDetails { + fn foreign_from(customer: &domain::Customer) -> Self { + Self { + id: customer.customer_id.clone(), + name: customer + .name + .as_ref() + .map(|name| name.get_inner().to_owned()), + email: customer.email.clone().map(Into::into), + phone: customer + .phone + .as_ref() + .map(|phone| phone.get_inner().to_owned()), + phone_country_code: customer.phone_country_code.clone(), + } + } +} + #[cfg(feature = "olap")] impl ForeignTryFrom for api_types::webhook_events::EventListConstraintsInternal diff --git a/openapi/openapi_spec.json b/openapi/openapi_spec.json index fa9c7435632d..1e16d0724718 100644 --- a/openapi/openapi_spec.json +++ b/openapi/openapi_spec.json @@ -14338,6 +14338,14 @@ "nullable": true, "maxLength": 255 }, + "customer": { + "allOf": [ + { + "$ref": "#/components/schemas/CustomerDetails" + } + ], + "nullable": true + }, "description": { "type": "string", "description": "A description of the payment", From aecf4aeacce33c3dc03e089ef6d62af93e29ca9a Mon Sep 17 00:00:00 2001 From: SamraatBansal <55536657+SamraatBansal@users.noreply.github.com> Date: Mon, 1 Apr 2024 19:33:51 +0530 Subject: [PATCH 11/19] feat(connector): [billwerk] implement payment and refund flows (#4245) Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> --- config/config.example.toml | 2 + config/deployments/integration_test.toml | 2 + config/deployments/production.toml | 2 + config/deployments/sandbox.toml | 2 + config/development.toml | 2 + config/docker_compose.toml | 2 + crates/api_models/src/enums.rs | 6 +- crates/common_enums/src/enums.rs | 2 +- crates/connector_configs/src/connector.rs | 2 +- .../connector_configs/toml/development.toml | 43 ++- crates/connector_configs/toml/production.toml | 43 ++- crates/connector_configs/toml/sandbox.toml | 43 ++- crates/router/src/connector/billwerk.rs | 310 ++++++++++++++-- .../src/connector/billwerk/transformers.rs | 349 +++++++++++++----- crates/router/src/connector/utils.rs | 96 +++++ crates/router/src/core/admin.rs | 8 +- crates/router/src/types/api.rs | 2 +- crates/router/src/types/transformers.rs | 2 +- loadtest/config/development.toml | 2 + openapi/openapi_spec.json | 2 + 20 files changed, 778 insertions(+), 144 deletions(-) diff --git a/config/config.example.toml b/config/config.example.toml index ee868beb092b..c1ba88db0195 100644 --- a/config/config.example.toml +++ b/config/config.example.toml @@ -171,6 +171,7 @@ authorizedotnet.base_url = "https://apitest.authorize.net/xml/v1/request.api" bambora.base_url = "https://api.na.bambora.com" bankofamerica.base_url = "https://apitest.merchant-services.bankofamerica.com/" billwerk.base_url = "https://api.reepay.com/" +billwerk.secondary_base_url = "https://card.reepay.com/" bitpay.base_url = "https://test.bitpay.com" bluesnap.base_url = "https://sandbox.bluesnap.com/" bluesnap.secondary_base_url = "https://sandpay.bluesnap.com/" @@ -349,6 +350,7 @@ stax = { long_lived_token = true, payment_method = "card,bank_debit" } square = { long_lived_token = false, payment_method = "card" } braintree = { long_lived_token = false, payment_method = "card" } gocardless = { long_lived_token = true, payment_method = "bank_debit" } +billwerk = {long_lived_token = false, payment_method = "card"} [temp_locker_enable_config] stripe = { payment_method = "bank_transfer" } diff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.toml index 10776c766789..77040f79a4a1 100644 --- a/config/deployments/integration_test.toml +++ b/config/deployments/integration_test.toml @@ -21,6 +21,7 @@ authorizedotnet.base_url = "https://apitest.authorize.net/xml/v1/request.api" bambora.base_url = "https://api.na.bambora.com" bankofamerica.base_url = "https://apitest.merchant-services.bankofamerica.com/" billwerk.base_url = "https://api.reepay.com/" +billwerk.secondary_base_url = "https://card.reepay.com/" bitpay.base_url = "https://test.bitpay.com" bluesnap.base_url = "https://sandbox.bluesnap.com/" bluesnap.secondary_base_url = "https://sandpay.bluesnap.com/" @@ -292,6 +293,7 @@ payme = { long_lived_token = false, payment_method = "card" } square = { long_lived_token = false, payment_method = "card" } stax = { long_lived_token = true, payment_method = "card,bank_debit" } stripe = { long_lived_token = false, payment_method = "wallet", payment_method_type = { list = "google_pay", type = "disable_only" } } +billwerk = {long_lived_token = false, payment_method = "card"} [webhooks] outgoing_enabled = true diff --git a/config/deployments/production.toml b/config/deployments/production.toml index a6405e4a3b2d..23df14862b9b 100644 --- a/config/deployments/production.toml +++ b/config/deployments/production.toml @@ -25,6 +25,7 @@ authorizedotnet.base_url = "https://api.authorize.net/xml/v1/request.api" bambora.base_url = "https://api.na.bambora.com" bankofamerica.base_url = "https://api.merchant-services.bankofamerica.com/" billwerk.base_url = "https://api.reepay.com/" +billwerk.secondary_base_url = "https://card.reepay.com/" bitpay.base_url = "https://bitpay.com" bluesnap.base_url = "https://ws.bluesnap.com/" bluesnap.secondary_base_url = "https://pay.bluesnap.com/" @@ -306,6 +307,7 @@ payme = { long_lived_token = false, payment_method = "card" } square = { long_lived_token = false, payment_method = "card" } stax = { long_lived_token = true, payment_method = "card,bank_debit" } stripe = { long_lived_token = false, payment_method = "wallet", payment_method_type = { list = "google_pay", type = "disable_only" } } +billwerk = {long_lived_token = false, payment_method = "card"} [webhooks] outgoing_enabled = true diff --git a/config/deployments/sandbox.toml b/config/deployments/sandbox.toml index 035c90af3789..8ae12dc54a62 100644 --- a/config/deployments/sandbox.toml +++ b/config/deployments/sandbox.toml @@ -25,6 +25,7 @@ authorizedotnet.base_url = "https://apitest.authorize.net/xml/v1/request.api" bambora.base_url = "https://api.na.bambora.com" bankofamerica.base_url = "https://apitest.merchant-services.bankofamerica.com/" billwerk.base_url = "https://api.reepay.com/" +billwerk.secondary_base_url = "https://card.reepay.com/" bitpay.base_url = "https://test.bitpay.com" bluesnap.base_url = "https://sandbox.bluesnap.com/" bluesnap.secondary_base_url = "https://sandpay.bluesnap.com/" @@ -308,6 +309,7 @@ payme = { long_lived_token = false, payment_method = "card" } square = { long_lived_token = false, payment_method = "card" } stax = { long_lived_token = true, payment_method = "card,bank_debit" } stripe = { long_lived_token = false, payment_method = "wallet", payment_method_type = { list = "google_pay", type = "disable_only" } } +billwerk = {long_lived_token = false, payment_method = "card"} [webhooks] outgoing_enabled = true diff --git a/config/development.toml b/config/development.toml index 5c063acf2f71..8ba5c076071a 100644 --- a/config/development.toml +++ b/config/development.toml @@ -167,6 +167,7 @@ authorizedotnet.base_url = "https://apitest.authorize.net/xml/v1/request.api" bambora.base_url = "https://api.na.bambora.com" bankofamerica.base_url = "https://apitest.merchant-services.bankofamerica.com/" billwerk.base_url = "https://api.reepay.com/" +billwerk.secondary_base_url = "https://card.reepay.com/" bitpay.base_url = "https://test.bitpay.com" bluesnap.base_url = "https://sandbox.bluesnap.com/" bluesnap.secondary_base_url = "https://sandpay.bluesnap.com/" @@ -450,6 +451,7 @@ square = { long_lived_token = false, payment_method = "card" } braintree = { long_lived_token = false, payment_method = "card" } 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"} [temp_locker_enable_config] stripe = { payment_method = "bank_transfer" } diff --git a/config/docker_compose.toml b/config/docker_compose.toml index 0e034f2e1457..eb32b47e3b41 100644 --- a/config/docker_compose.toml +++ b/config/docker_compose.toml @@ -105,6 +105,7 @@ authorizedotnet.base_url = "https://apitest.authorize.net/xml/v1/request.api" bambora.base_url = "https://api.na.bambora.com" bankofamerica.base_url = "https://apitest.merchant-services.bankofamerica.com/" billwerk.base_url = "https://api.reepay.com/" +billwerk.secondary_base_url = "https://card.reepay.com/" bitpay.base_url = "https://test.bitpay.com" bluesnap.base_url = "https://sandbox.bluesnap.com/" bluesnap.secondary_base_url = "https://sandpay.bluesnap.com/" @@ -251,6 +252,7 @@ stax = { long_lived_token = true, payment_method = "card,bank_debit" } square = { long_lived_token = false, payment_method = "card" } braintree = { long_lived_token = false, payment_method = "card" } gocardless = { long_lived_token = true, payment_method = "bank_debit" } +billwerk = {long_lived_token = false, payment_method = "card"} [temp_locker_enable_config] stripe = { payment_method = "bank_transfer" } diff --git a/crates/api_models/src/enums.rs b/crates/api_models/src/enums.rs index b29377886d5e..354dec29237b 100644 --- a/crates/api_models/src/enums.rs +++ b/crates/api_models/src/enums.rs @@ -78,7 +78,7 @@ pub enum Connector { Authorizedotnet, Bambora, Bankofamerica, - // Billwerk, Added as template code for future usage + Billwerk, Bitpay, Bluesnap, Boku, @@ -166,7 +166,7 @@ impl Connector { | Self::Authorizedotnet | Self::Bambora | Self::Bankofamerica - // | Self::Billwerk Added as template code for future usage + | Self::Billwerk | Self::Bitpay | Self::Bluesnap | Self::Boku @@ -223,7 +223,7 @@ impl Connector { | Self::Authorizedotnet | Self::Bambora | Self::Bankofamerica - // | Self::Billwerk Added as template for future usage + | Self::Billwerk | Self::Bitpay | Self::Bluesnap | Self::Boku diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs index 548e721f0d39..497f1f58729d 100644 --- a/crates/common_enums/src/enums.rs +++ b/crates/common_enums/src/enums.rs @@ -115,7 +115,7 @@ pub enum RoutableConnectors { Airwallex, Authorizedotnet, Bankofamerica, - // Billwerk, Added as template code for future usage + Billwerk, Bitpay, Bambora, Bluesnap, diff --git a/crates/connector_configs/src/connector.rs b/crates/connector_configs/src/connector.rs index 74317319f500..5a67847a9e51 100644 --- a/crates/connector_configs/src/connector.rs +++ b/crates/connector_configs/src/connector.rs @@ -228,7 +228,7 @@ impl ConnectorConfig { Connector::Airwallex => Ok(connector_data.airwallex), Connector::Authorizedotnet => Ok(connector_data.authorizedotnet), Connector::Bankofamerica => Ok(connector_data.bankofamerica), - // Connector::Billwerk => Ok(connector_data.billwerk), Added as template code for future usage + Connector::Billwerk => Ok(connector_data.billwerk), Connector::Bitpay => Ok(connector_data.bitpay), Connector::Bluesnap => Ok(connector_data.bluesnap), Connector::Boku => Ok(connector_data.boku), diff --git a/crates/connector_configs/toml/development.toml b/crates/connector_configs/toml/development.toml index 0e18bb33ed29..0233b916668c 100644 --- a/crates/connector_configs/toml/development.toml +++ b/crates/connector_configs/toml/development.toml @@ -2587,4 +2587,45 @@ api_key="Api Key" [threedsecureio.metadata] mcc="MCC" merchant_country_code="3 digit numeric country code" -merchant_name="Name of the merchant" \ No newline at end of file +merchant_name="Name of the merchant" + +[billwerk] +[[billwerk.credit]] + payment_method_type = "Mastercard" +[[billwerk.credit]] + payment_method_type = "Visa" +[[billwerk.credit]] + payment_method_type = "Interac" +[[billwerk.credit]] + payment_method_type = "AmericanExpress" +[[billwerk.credit]] + payment_method_type = "JCB" +[[billwerk.credit]] + payment_method_type = "DinersClub" +[[billwerk.credit]] + payment_method_type = "Discover" +[[billwerk.credit]] + payment_method_type = "CartesBancaires" +[[billwerk.credit]] + payment_method_type = "UnionPay" +[[billwerk.debit]] + payment_method_type = "Mastercard" +[[billwerk.debit]] + payment_method_type = "Visa" +[[billwerk.debit]] + payment_method_type = "Interac" +[[billwerk.debit]] + payment_method_type = "AmericanExpress" +[[billwerk.debit]] + payment_method_type = "JCB" +[[billwerk.debit]] + payment_method_type = "DinersClub" +[[billwerk.debit]] + payment_method_type = "Discover" +[[billwerk.debit]] + payment_method_type = "CartesBancaires" +[[billwerk.debit]] + payment_method_type = "UnionPay" +[billwerk.connector_auth.BodyKey] +api_key="Private Api Key" +key1="Public Api Key" \ No newline at end of file diff --git a/crates/connector_configs/toml/production.toml b/crates/connector_configs/toml/production.toml index 079ead7e4ced..58f9ccfa2c39 100644 --- a/crates/connector_configs/toml/production.toml +++ b/crates/connector_configs/toml/production.toml @@ -1913,4 +1913,45 @@ terminal_uuid="Terminal UUID" pay_wall_secret="Pay Wall Secret" [zen.metadata.google_pay] terminal_uuid="Terminal UUID" -pay_wall_secret="Pay Wall Secret" \ No newline at end of file +pay_wall_secret="Pay Wall Secret" + +[billwerk] +[[billwerk.credit]] + payment_method_type = "Mastercard" +[[billwerk.credit]] + payment_method_type = "Visa" +[[billwerk.credit]] + payment_method_type = "Interac" +[[billwerk.credit]] + payment_method_type = "AmericanExpress" +[[billwerk.credit]] + payment_method_type = "JCB" +[[billwerk.credit]] + payment_method_type = "DinersClub" +[[billwerk.credit]] + payment_method_type = "Discover" +[[billwerk.credit]] + payment_method_type = "CartesBancaires" +[[billwerk.credit]] + payment_method_type = "UnionPay" +[[billwerk.debit]] + payment_method_type = "Mastercard" +[[billwerk.debit]] + payment_method_type = "Visa" +[[billwerk.debit]] + payment_method_type = "Interac" +[[billwerk.debit]] + payment_method_type = "AmericanExpress" +[[billwerk.debit]] + payment_method_type = "JCB" +[[billwerk.debit]] + payment_method_type = "DinersClub" +[[billwerk.debit]] + payment_method_type = "Discover" +[[billwerk.debit]] + payment_method_type = "CartesBancaires" +[[billwerk.debit]] + payment_method_type = "UnionPay" +[billwerk.connector_auth.BodyKey] +api_key="Private Api Key" +key1="Public Api Key" \ No newline at end of file diff --git a/crates/connector_configs/toml/sandbox.toml b/crates/connector_configs/toml/sandbox.toml index f484e9145318..9103c548e658 100644 --- a/crates/connector_configs/toml/sandbox.toml +++ b/crates/connector_configs/toml/sandbox.toml @@ -2589,4 +2589,45 @@ api_key="Api Key" [threedsecureio.metadata] mcc="MCC" merchant_country_code="3 digit numeric country code" -merchant_name="Name of the merchant" \ No newline at end of file +merchant_name="Name of the merchant" + +[billwerk] +[[billwerk.credit]] + payment_method_type = "Mastercard" +[[billwerk.credit]] + payment_method_type = "Visa" +[[billwerk.credit]] + payment_method_type = "Interac" +[[billwerk.credit]] + payment_method_type = "AmericanExpress" +[[billwerk.credit]] + payment_method_type = "JCB" +[[billwerk.credit]] + payment_method_type = "DinersClub" +[[billwerk.credit]] + payment_method_type = "Discover" +[[billwerk.credit]] + payment_method_type = "CartesBancaires" +[[billwerk.credit]] + payment_method_type = "UnionPay" +[[billwerk.debit]] + payment_method_type = "Mastercard" +[[billwerk.debit]] + payment_method_type = "Visa" +[[billwerk.debit]] + payment_method_type = "Interac" +[[billwerk.debit]] + payment_method_type = "AmericanExpress" +[[billwerk.debit]] + payment_method_type = "JCB" +[[billwerk.debit]] + payment_method_type = "DinersClub" +[[billwerk.debit]] + payment_method_type = "Discover" +[[billwerk.debit]] + payment_method_type = "CartesBancaires" +[[billwerk.debit]] + payment_method_type = "UnionPay" +[billwerk.connector_auth.BodyKey] +api_key="Private Api Key" +key1="Public Api Key" diff --git a/crates/router/src/connector/billwerk.rs b/crates/router/src/connector/billwerk.rs index 154b729abc9a..b6839f5de24d 100644 --- a/crates/router/src/connector/billwerk.rs +++ b/crates/router/src/connector/billwerk.rs @@ -2,12 +2,15 @@ pub mod transformers; use std::fmt::Debug; +use base64::Engine; use error_stack::{report, ResultExt}; -use masking::ExposeInterface; +use masking::PeekInterface; use transformers as billwerk; +use super::utils::RefundsRequestData; use crate::{ configs::settings, + consts, core::errors::{self, CustomResult}, events::connector_api_logs::ConnectorEvent, headers, @@ -40,16 +43,6 @@ impl api::RefundExecute for Billwerk {} impl api::RefundSync for Billwerk {} impl api::PaymentToken for Billwerk {} -impl - ConnectorIntegration< - api::PaymentMethodToken, - types::PaymentMethodTokenizationData, - types::PaymentsResponseData, - > for Billwerk -{ - // Not Implemented (R) -} - impl ConnectorCommonExt for Billwerk where Self: ConnectorIntegration, @@ -92,9 +85,10 @@ impl ConnectorCommon for Billwerk { ) -> CustomResult)>, errors::ConnectorError> { let auth = billwerk::BillwerkAuthType::try_from(auth_type) .change_context(errors::ConnectorError::FailedToObtainAuthType)?; + let encoded_api_key = consts::BASE64_ENGINE.encode(format!("{}:", auth.api_key.peek())); Ok(vec![( headers::AUTHORIZATION.to_string(), - auth.api_key.expose().into_masked(), + format!("Basic {encoded_api_key}").into_masked(), )]) } @@ -113,9 +107,13 @@ impl ConnectorCommon for Billwerk { Ok(ErrorResponse { status_code: res.status_code, - code: response.code, - message: response.message, - reason: response.reason, + code: response + .code + .map_or(consts::NO_ERROR_CODE.to_string(), |code| code.to_string()), + message: response + .message + .unwrap_or(consts::NO_ERROR_MESSAGE.to_string()), + reason: Some(response.error), attempt_status: None, connector_transaction_id: None, }) @@ -123,7 +121,20 @@ impl ConnectorCommon for Billwerk { } impl ConnectorValidation for Billwerk { - //TODO: implement functions when support enabled + fn validate_capture_method( + &self, + capture_method: Option, + _pmt: Option, + ) -> CustomResult<(), errors::ConnectorError> { + let capture_method = capture_method.unwrap_or_default(); + match capture_method { + common_enums::CaptureMethod::Automatic | common_enums::CaptureMethod::Manual => Ok(()), + common_enums::CaptureMethod::ManualMultiple + | common_enums::CaptureMethod::Scheduled => Err( + super::utils::construct_not_implemented_error_report(capture_method, self.id()), + ), + } + } } impl ConnectorIntegration @@ -146,6 +157,105 @@ impl { } +impl + ConnectorIntegration< + api::PaymentMethodToken, + types::PaymentMethodTokenizationData, + types::PaymentsResponseData, + > for Billwerk +{ + fn get_headers( + &self, + req: &types::TokenizationRouterData, + connectors: &settings::Connectors, + ) -> CustomResult)>, errors::ConnectorError> { + self.build_headers(req, connectors) + } + + fn get_content_type(&self) -> &'static str { + self.common_get_content_type() + } + + fn get_url( + &self, + _req: &types::TokenizationRouterData, + connectors: &settings::Connectors, + ) -> CustomResult { + let base_url = connectors + .billwerk + .secondary_base_url + .as_ref() + .ok_or(errors::ConnectorError::FailedToObtainIntegrationUrl)?; + Ok(format!("{base_url}v1/token")) + } + + fn get_request_body( + &self, + req: &types::TokenizationRouterData, + _connectors: &settings::Connectors, + ) -> CustomResult { + let connector_req = billwerk::BillwerkTokenRequest::try_from(req)?; + Ok(RequestContent::Json(Box::new(connector_req))) + } + + fn build_request( + &self, + req: &types::TokenizationRouterData, + connectors: &settings::Connectors, + ) -> CustomResult, errors::ConnectorError> { + Ok(Some( + services::RequestBuilder::new() + .method(services::Method::Post) + .url(&types::TokenizationType::get_url(self, req, connectors)?) + .attach_default_headers() + .headers(types::TokenizationType::get_headers(self, req, connectors)?) + .set_body(types::TokenizationType::get_request_body( + self, req, connectors, + )?) + .build(), + )) + } + + fn handle_response( + &self, + data: &types::TokenizationRouterData, + event_builder: Option<&mut ConnectorEvent>, + res: Response, + ) -> CustomResult + where + types::PaymentsResponseData: Clone, + { + let response: billwerk::BillwerkTokenResponse = res + .response + .parse_struct("BillwerkTokenResponse") + .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; + event_builder.map(|i| i.set_response_body(&response)); + router_env::logger::info!(connector_response=?response); + types::RouterData::try_from(types::ResponseRouterData { + response, + data: data.clone(), + http_code: res.status_code, + }) + .change_context(errors::ConnectorError::ResponseHandlingFailed) + } + + fn get_error_response( + &self, + res: Response, + event_builder: Option<&mut ConnectorEvent>, + ) -> CustomResult { + self.build_error_response(res, event_builder) + } + + fn get_5xx_error_response( + &self, + res: Response, + event_builder: Option<&mut ConnectorEvent>, + ) -> CustomResult { + self.build_error_response(res, event_builder) + } +} + impl ConnectorIntegration for Billwerk { @@ -164,9 +274,9 @@ impl ConnectorIntegration CustomResult { - Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into()) + Ok(format!("{}v1/charge", self.base_url(connectors))) } fn get_request_body( @@ -214,7 +324,7 @@ impl ConnectorIntegration CustomResult { let response: billwerk::BillwerkPaymentsResponse = res .response - .parse_struct("Billwerk PaymentsAuthorizeResponse") + .parse_struct("Billwerk BillwerkPaymentsResponse") .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; event_builder.map(|i| i.set_response_body(&response)); router_env::logger::info!(connector_response=?response); @@ -232,6 +342,14 @@ impl ConnectorIntegration CustomResult { self.build_error_response(res, event_builder) } + + fn get_5xx_error_response( + &self, + res: Response, + event_builder: Option<&mut ConnectorEvent>, + ) -> CustomResult { + self.build_error_response(res, event_builder) + } } impl ConnectorIntegration @@ -251,10 +369,14 @@ impl ConnectorIntegration CustomResult { - Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into()) + Ok(format!( + "{}v1/charge/{}", + self.base_url(connectors), + req.connector_request_reference_id + )) } fn build_request( @@ -280,7 +402,7 @@ impl ConnectorIntegration CustomResult { let response: billwerk::BillwerkPaymentsResponse = res .response - .parse_struct("billwerk PaymentsSyncResponse") + .parse_struct("billwerk BillwerkPaymentsResponse") .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; event_builder.map(|i| i.set_response_body(&response)); router_env::logger::info!(connector_response=?response); @@ -298,6 +420,14 @@ impl ConnectorIntegration CustomResult { self.build_error_response(res, event_builder) } + + fn get_5xx_error_response( + &self, + res: Response, + event_builder: Option<&mut ConnectorEvent>, + ) -> CustomResult { + self.build_error_response(res, event_builder) + } } impl ConnectorIntegration @@ -317,18 +447,29 @@ impl ConnectorIntegration CustomResult { - Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into()) + let connector_transaction_id = &req.request.connector_transaction_id; + Ok(format!( + "{}v1/charge/{connector_transaction_id}/settle", + self.base_url(connectors) + )) } fn get_request_body( &self, - _req: &types::PaymentsCaptureRouterData, + req: &types::PaymentsCaptureRouterData, _connectors: &settings::Connectors, ) -> CustomResult { - Err(errors::ConnectorError::NotImplemented("get_request_body method".to_string()).into()) + let connector_router_data = billwerk::BillwerkRouterData::try_from(( + &self.get_currency_unit(), + req.request.currency, + req.request.amount_to_capture, + req, + ))?; + let connector_req = billwerk::BillwerkCaptureRequest::try_from(&connector_router_data)?; + Ok(RequestContent::Json(Box::new(connector_req))) } fn build_request( @@ -359,7 +500,7 @@ impl ConnectorIntegration CustomResult { let response: billwerk::BillwerkPaymentsResponse = res .response - .parse_struct("Billwerk PaymentsCaptureResponse") + .parse_struct("Billwerk BillwerkPaymentsResponse") .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; event_builder.map(|i| i.set_response_body(&response)); router_env::logger::info!(connector_response=?response); @@ -377,11 +518,92 @@ impl ConnectorIntegration CustomResult { self.build_error_response(res, event_builder) } + + fn get_5xx_error_response( + &self, + res: Response, + event_builder: Option<&mut ConnectorEvent>, + ) -> CustomResult { + self.build_error_response(res, event_builder) + } } impl ConnectorIntegration for Billwerk { + fn get_headers( + &self, + req: &types::PaymentsCancelRouterData, + connectors: &settings::Connectors, + ) -> CustomResult)>, errors::ConnectorError> { + self.build_headers(req, connectors) + } + + fn get_content_type(&self) -> &'static str { + self.common_get_content_type() + } + + fn get_url( + &self, + req: &types::PaymentsCancelRouterData, + connectors: &settings::Connectors, + ) -> CustomResult { + let connector_transaction_id = &req.request.connector_transaction_id; + Ok(format!( + "{}v1/charge/{connector_transaction_id}/cancel", + self.base_url(connectors) + )) + } + + fn build_request( + &self, + req: &types::PaymentsCancelRouterData, + connectors: &settings::Connectors, + ) -> CustomResult, errors::ConnectorError> { + Ok(Some( + services::RequestBuilder::new() + .method(services::Method::Post) + .url(&types::PaymentsVoidType::get_url(self, req, connectors)?) + .attach_default_headers() + .headers(types::PaymentsVoidType::get_headers(self, req, connectors)?) + .build(), + )) + } + + fn handle_response( + &self, + data: &types::PaymentsCancelRouterData, + event_builder: Option<&mut ConnectorEvent>, + res: Response, + ) -> CustomResult { + let response: billwerk::BillwerkPaymentsResponse = res + .response + .parse_struct("Billwerk BillwerkPaymentsResponse") + .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; + event_builder.map(|i| i.set_response_body(&response)); + router_env::logger::info!(connector_response=?response); + types::RouterData::try_from(types::ResponseRouterData { + response, + data: data.clone(), + http_code: res.status_code, + }) + } + + fn get_error_response( + &self, + res: Response, + event_builder: Option<&mut ConnectorEvent>, + ) -> CustomResult { + self.build_error_response(res, event_builder) + } + + fn get_5xx_error_response( + &self, + res: Response, + event_builder: Option<&mut ConnectorEvent>, + ) -> CustomResult { + self.build_error_response(res, event_builder) + } } impl ConnectorIntegration @@ -402,9 +624,9 @@ impl ConnectorIntegration, - _connectors: &settings::Connectors, + connectors: &settings::Connectors, ) -> CustomResult { - Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into()) + Ok(format!("{}v1/refund", self.base_url(connectors))) } fn get_request_body( @@ -467,6 +689,14 @@ impl ConnectorIntegration CustomResult { self.build_error_response(res, event_builder) } + + fn get_5xx_error_response( + &self, + res: Response, + event_builder: Option<&mut ConnectorEvent>, + ) -> CustomResult { + self.build_error_response(res, event_builder) + } } impl ConnectorIntegration for Billwerk { @@ -484,10 +714,14 @@ impl ConnectorIntegration CustomResult { - Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into()) + let refund_id = req.request.get_connector_refund_id()?; + Ok(format!( + "{}v1/refund/{refund_id}", + self.base_url(connectors) + )) } fn build_request( @@ -534,6 +768,14 @@ impl ConnectorIntegration CustomResult { self.build_error_response(res, event_builder) } + + fn get_5xx_error_response( + &self, + res: Response, + event_builder: Option<&mut ConnectorEvent>, + ) -> CustomResult { + self.build_error_response(res, event_builder) + } } #[async_trait::async_trait] diff --git a/crates/router/src/connector/billwerk/transformers.rs b/crates/router/src/connector/billwerk/transformers.rs index c6f025b78986..ffcd14bf05f9 100644 --- a/crates/router/src/connector/billwerk/transformers.rs +++ b/crates/router/src/connector/billwerk/transformers.rs @@ -1,15 +1,16 @@ -use masking::Secret; +use common_utils::pii::{Email, SecretSerdeValue}; +use masking::{ExposeInterface, Secret}; use serde::{Deserialize, Serialize}; use crate::{ - connector::utils::PaymentsAuthorizeRequestData, + connector::utils::{self, CardData, PaymentsAuthorizeRequestData, RouterData}, + consts, core::errors, types::{self, api, storage::enums}, }; -//TODO: Fill the struct with respective fields pub struct BillwerkRouterData { - pub amount: i64, // The type of amount that a connector accepts, for example, String, i64, f64, etc. + pub amount: i64, pub router_data: T, } @@ -30,7 +31,6 @@ impl T, ), ) -> Result { - //Todo : use utils to convert the amount to the type of amount that a connector accepts Ok(Self { amount, router_data: item, @@ -38,89 +38,213 @@ impl } } -//TODO: Fill the struct with respective fields -#[derive(Default, Debug, Serialize, Eq, PartialEq)] -pub struct BillwerkPaymentsRequest { - amount: i64, - card: BillwerkCard, +pub struct BillwerkAuthType { + pub(super) api_key: Secret, + pub(super) public_api_key: Secret, } -#[derive(Default, Debug, Serialize, Eq, PartialEq)] -pub struct BillwerkCard { +impl TryFrom<&types::ConnectorAuthType> for BillwerkAuthType { + type Error = error_stack::Report; + fn try_from(auth_type: &types::ConnectorAuthType) -> Result { + match auth_type { + types::ConnectorAuthType::BodyKey { api_key, key1 } => Ok(Self { + api_key: api_key.to_owned(), + public_api_key: key1.to_owned(), + }), + _ => Err(errors::ConnectorError::FailedToObtainAuthType.into()), + } + } +} + +#[derive(Debug, Serialize)] +#[serde(rename_all = "SCREAMING_SNAKE_CASE")] +pub enum BillwerkTokenRequestIntent { + ChargeAndStore, +} + +#[derive(Debug, Serialize)] +#[serde(rename_all = "SCREAMING_SNAKE_CASE")] +pub enum BillwerkStrongAuthRule { + UseScaIfAvailableAuth, +} + +#[derive(Debug, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct BillwerkTokenRequest { number: cards::CardNumber, - expiry_month: Secret, - expiry_year: Secret, - cvc: Secret, - complete: bool, + month: Secret, + year: Secret, + cvv: Secret, + pkey: Secret, + recurring: Option, + intent: Option, + strong_authentication_rule: Option, } -impl TryFrom<&BillwerkRouterData<&types::PaymentsAuthorizeRouterData>> for BillwerkPaymentsRequest { +impl TryFrom<&types::TokenizationRouterData> for BillwerkTokenRequest { type Error = error_stack::Report; - fn try_from( - item: &BillwerkRouterData<&types::PaymentsAuthorizeRouterData>, - ) -> Result { - match item.router_data.request.payment_method_data.clone() { - api::PaymentMethodData::Card(req_card) => { - let card = BillwerkCard { - number: req_card.card_number, - expiry_month: req_card.card_exp_month, - expiry_year: req_card.card_exp_year, - cvc: req_card.card_cvc, - complete: item.router_data.request.is_auto_capture()?, - }; + fn try_from(item: &types::TokenizationRouterData) -> Result { + match item.request.payment_method_data.clone() { + api::PaymentMethodData::Card(ccard) => { + let connector_auth = &item.connector_auth_type; + let auth_type = BillwerkAuthType::try_from(connector_auth)?; Ok(Self { - amount: item.amount.to_owned(), - card, + number: ccard.card_number.clone(), + month: ccard.card_exp_month.clone(), + year: ccard.get_card_expiry_year_2_digit()?, + cvv: ccard.card_cvc, + pkey: auth_type.public_api_key, + recurring: None, + intent: None, + strong_authentication_rule: None, }) } - _ => Err(errors::ConnectorError::NotImplemented("Payment methods".to_string()).into()), + api_models::payments::PaymentMethodData::Wallet(_) + | api_models::payments::PaymentMethodData::CardRedirect(_) + | api_models::payments::PaymentMethodData::PayLater(_) + | api_models::payments::PaymentMethodData::BankRedirect(_) + | api_models::payments::PaymentMethodData::BankDebit(_) + | api_models::payments::PaymentMethodData::BankTransfer(_) + | api_models::payments::PaymentMethodData::Crypto(_) + | api_models::payments::PaymentMethodData::MandatePayment + | api_models::payments::PaymentMethodData::Reward + | api_models::payments::PaymentMethodData::Upi(_) + | api_models::payments::PaymentMethodData::Voucher(_) + | api_models::payments::PaymentMethodData::GiftCard(_) + | api_models::payments::PaymentMethodData::CardToken(_) => { + Err(errors::ConnectorError::NotImplemented( + utils::get_unimplemented_payment_method_error_message("billwerk"), + ) + .into()) + } } } } -//TODO: Fill the struct with respective fields -// Auth Struct -pub struct BillwerkAuthType { - pub(super) api_key: Secret, +#[derive(Debug, Deserialize, Serialize)] +pub struct BillwerkTokenResponse { + id: Secret, + recurring: Option, } -impl TryFrom<&types::ConnectorAuthType> for BillwerkAuthType { +impl + TryFrom< + types::ResponseRouterData< + api::PaymentMethodToken, + BillwerkTokenResponse, + T, + types::PaymentsResponseData, + >, + > for types::RouterData +{ type Error = error_stack::Report; - fn try_from(auth_type: &types::ConnectorAuthType) -> Result { - match auth_type { - types::ConnectorAuthType::HeaderKey { api_key } => Ok(Self { - api_key: api_key.to_owned(), + fn try_from( + item: types::ResponseRouterData< + api::PaymentMethodToken, + BillwerkTokenResponse, + T, + types::PaymentsResponseData, + >, + ) -> Result { + Ok(Self { + response: Ok(types::PaymentsResponseData::TokenizationResponse { + token: item.response.id.expose(), }), - _ => Err(errors::ConnectorError::FailedToObtainAuthType.into()), - } + ..item.data + }) + } +} + +#[derive(Debug, Serialize)] +pub struct BillwerkCustomerObject { + handle: Option, + email: Option, + address: Option>, + address2: Option>, + city: Option, + country: Option, + first_name: Option>, + last_name: Option>, +} + +#[derive(Debug, Serialize)] +pub struct BillwerkPaymentsRequest { + handle: String, + amount: i64, + source: Secret, + currency: common_enums::Currency, + customer: BillwerkCustomerObject, + metadata: Option, + settle: bool, +} + +impl TryFrom<&BillwerkRouterData<&types::PaymentsAuthorizeRouterData>> for BillwerkPaymentsRequest { + type Error = error_stack::Report; + fn try_from( + item: &BillwerkRouterData<&types::PaymentsAuthorizeRouterData>, + ) -> Result { + if item.router_data.is_three_ds() { + return Err(errors::ConnectorError::NotImplemented( + "Three_ds payments through Billwerk".to_string(), + ) + .into()); + }; + let source = match item.router_data.get_payment_method_token()? { + types::PaymentMethodToken::Token(pm_token) => Ok(Secret::new(pm_token)), + _ => Err(errors::ConnectorError::MissingRequiredField { + field_name: "payment_method_token", + }), + }?; + Ok(Self { + handle: item.router_data.connector_request_reference_id.clone(), + amount: item.amount, + source, + currency: item.router_data.request.currency, + customer: BillwerkCustomerObject { + handle: item.router_data.customer_id.clone(), + email: item.router_data.request.email.clone(), + address: item.router_data.get_optional_billing_line1(), + address2: item.router_data.get_optional_billing_line2(), + city: item.router_data.get_optional_billing_city(), + country: item.router_data.get_optional_billing_country(), + first_name: item.router_data.get_optional_billing_first_name(), + last_name: item.router_data.get_optional_billing_last_name(), + }, + metadata: item.router_data.request.metadata.clone(), + settle: item.router_data.request.is_auto_capture()?, + }) } } -// PaymentsResponse -//TODO: Append the remaining status flags -#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq)] + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "lowercase")] -pub enum BillwerkPaymentStatus { - Succeeded, +pub enum BillwerkPaymentState { + Created, + Authorized, + Pending, + Settled, Failed, - #[default] - Processing, + Cancelled, } -impl From for enums::AttemptStatus { - fn from(item: BillwerkPaymentStatus) -> Self { +impl From for enums::AttemptStatus { + fn from(item: BillwerkPaymentState) -> Self { match item { - BillwerkPaymentStatus::Succeeded => Self::Charged, - BillwerkPaymentStatus::Failed => Self::Failure, - BillwerkPaymentStatus::Processing => Self::Authorizing, + BillwerkPaymentState::Created | BillwerkPaymentState::Pending => Self::Pending, + BillwerkPaymentState::Authorized => Self::Authorized, + BillwerkPaymentState::Settled => Self::Charged, + BillwerkPaymentState::Failed => Self::Failure, + BillwerkPaymentState::Cancelled => Self::Voided, } } } -//TODO: Fill the struct with respective fields -#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)] +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] pub struct BillwerkPaymentsResponse { - status: BillwerkPaymentStatus, - id: String, + state: BillwerkPaymentState, + handle: String, + error: Option, + error_state: Option, } impl @@ -136,28 +260,65 @@ impl types::PaymentsResponseData, >, ) -> Result { + let error_response = if item.response.error.is_some() || item.response.error_state.is_some() + { + Some(types::ErrorResponse { + code: item + .response + .error_state + .clone() + .unwrap_or(consts::NO_ERROR_CODE.to_string()), + message: item + .response + .error_state + .unwrap_or(consts::NO_ERROR_MESSAGE.to_string()), + reason: item.response.error, + status_code: item.http_code, + attempt_status: None, + connector_transaction_id: Some(item.response.handle.clone()), + }) + } else { + None + }; + let payments_response = types::PaymentsResponseData::TransactionResponse { + resource_id: types::ResponseId::ConnectorTransactionId(item.response.handle.clone()), + redirection_data: None, + mandate_reference: None, + connector_metadata: None, + network_txn_id: None, + connector_response_reference_id: Some(item.response.handle), + incremental_authorization_allowed: None, + }; Ok(Self { - status: enums::AttemptStatus::from(item.response.status), - response: Ok(types::PaymentsResponseData::TransactionResponse { - resource_id: types::ResponseId::ConnectorTransactionId(item.response.id), - redirection_data: None, - mandate_reference: None, - connector_metadata: None, - network_txn_id: None, - connector_response_reference_id: None, - incremental_authorization_allowed: None, - }), + status: enums::AttemptStatus::from(item.response.state), + response: error_response.map_or_else(|| Ok(payments_response), Err), ..item.data }) } } -//TODO: Fill the struct with respective fields -// REFUND : +#[derive(Debug, Serialize)] +pub struct BillwerkCaptureRequest { + amount: i64, +} + +impl TryFrom<&BillwerkRouterData<&types::PaymentsCaptureRouterData>> for BillwerkCaptureRequest { + type Error = error_stack::Report; + fn try_from( + item: &BillwerkRouterData<&types::PaymentsCaptureRouterData>, + ) -> Result { + Ok(Self { + amount: item.amount, + }) + } +} + // Type definition for RefundRequest -#[derive(Default, Debug, Serialize)] +#[derive(Debug, Serialize)] pub struct BillwerkRefundRequest { + pub invoice: String, pub amount: i64, + pub text: Option, } impl TryFrom<&BillwerkRouterData<&types::RefundsRouterData>> for BillwerkRefundRequest { @@ -166,38 +327,36 @@ impl TryFrom<&BillwerkRouterData<&types::RefundsRouterData>> for BillwerkR item: &BillwerkRouterData<&types::RefundsRouterData>, ) -> Result { Ok(Self { - amount: item.amount.to_owned(), + amount: item.amount, + invoice: item.router_data.request.connector_transaction_id.clone(), + text: item.router_data.request.reason.clone(), }) } } // Type definition for Refund Response - -#[allow(dead_code)] -#[derive(Debug, Serialize, Default, Deserialize, Clone)] -pub enum RefundStatus { - Succeeded, +#[derive(Debug, Serialize, Deserialize)] +#[serde(rename_all = "lowercase")] +pub enum RefundState { + Refunded, Failed, - #[default] Processing, } -impl From for enums::RefundStatus { - fn from(item: RefundStatus) -> Self { +impl From for enums::RefundStatus { + fn from(item: RefundState) -> Self { match item { - RefundStatus::Succeeded => Self::Success, - RefundStatus::Failed => Self::Failure, - RefundStatus::Processing => Self::Pending, - //TODO: Review mapping + RefundState::Refunded => Self::Success, + RefundState::Failed => Self::Failure, + RefundState::Processing => Self::Pending, } } } -//TODO: Fill the struct with respective fields -#[derive(Default, Debug, Clone, Serialize, Deserialize)] +#[derive(Debug, Serialize, Deserialize)] pub struct RefundResponse { id: String, - status: RefundStatus, + state: RefundState, } impl TryFrom> @@ -210,7 +369,7 @@ impl TryFrom> Ok(Self { response: Ok(types::RefundsResponseData { connector_refund_id: item.response.id.to_string(), - refund_status: enums::RefundStatus::from(item.response.status), + refund_status: enums::RefundStatus::from(item.response.state), }), ..item.data }) @@ -227,18 +386,16 @@ impl TryFrom> Ok(Self { response: Ok(types::RefundsResponseData { connector_refund_id: item.response.id.to_string(), - refund_status: enums::RefundStatus::from(item.response.status), + refund_status: enums::RefundStatus::from(item.response.state), }), ..item.data }) } } -//TODO: Fill the struct with respective fields -#[derive(Default, Debug, Serialize, Deserialize, PartialEq)] +#[derive(Debug, Serialize, Deserialize)] pub struct BillwerkErrorResponse { - pub status_code: u16, - pub code: String, - pub message: String, - pub reason: Option, + pub code: Option, + pub error: String, + pub message: Option, } diff --git a/crates/router/src/connector/utils.rs b/crates/router/src/connector/utils.rs index 89b88243057c..804ad3ef3d00 100644 --- a/crates/router/src/connector/utils.rs +++ b/crates/router/src/connector/utils.rs @@ -88,6 +88,14 @@ pub trait RouterData { fn get_optional_billing(&self) -> Option<&api::Address>; fn get_optional_shipping(&self) -> Option<&api::Address>; + fn get_optional_billing_line1(&self) -> Option>; + fn get_optional_billing_line2(&self) -> Option>; + fn get_optional_billing_city(&self) -> Option; + fn get_optional_billing_country(&self) -> Option; + fn get_optional_billing_zip(&self) -> Option>; + fn get_optional_billing_state(&self) -> Option>; + fn get_optional_billing_first_name(&self) -> Option>; + fn get_optional_billing_last_name(&self) -> Option>; } pub trait PaymentResponseRouterData { @@ -202,6 +210,94 @@ impl RouterData for types::RouterData Option> { + self.address + .get_payment_method_billing() + .and_then(|billing_address| { + billing_address + .clone() + .address + .and_then(|billing_address_details| billing_address_details.line1) + }) + } + + fn get_optional_billing_line2(&self) -> Option> { + self.address + .get_payment_method_billing() + .and_then(|billing_address| { + billing_address + .clone() + .address + .and_then(|billing_address_details| billing_address_details.line2) + }) + } + + fn get_optional_billing_city(&self) -> Option { + self.address + .get_payment_method_billing() + .and_then(|billing_address| { + billing_address + .clone() + .address + .and_then(|billing_address_details| billing_address_details.city) + }) + } + + fn get_optional_billing_country(&self) -> Option { + self.address + .get_payment_method_billing() + .and_then(|billing_address| { + billing_address + .clone() + .address + .and_then(|billing_address_details| billing_address_details.country) + }) + } + + fn get_optional_billing_zip(&self) -> Option> { + self.address + .get_payment_method_billing() + .and_then(|billing_address| { + billing_address + .clone() + .address + .and_then(|billing_address_details| billing_address_details.zip) + }) + } + + fn get_optional_billing_state(&self) -> Option> { + self.address + .get_payment_method_billing() + .and_then(|billing_address| { + billing_address + .clone() + .address + .and_then(|billing_address_details| billing_address_details.state) + }) + } + + fn get_optional_billing_first_name(&self) -> Option> { + self.address + .get_payment_method_billing() + .and_then(|billing_address| { + billing_address + .clone() + .address + .and_then(|billing_address_details| billing_address_details.first_name) + }) + } + + fn get_optional_billing_last_name(&self) -> Option> { + self.address + .get_payment_method_billing() + .and_then(|billing_address| { + billing_address + .clone() + .address + .and_then(|billing_address_details| billing_address_details.last_name) + }) + } + fn to_connector_meta(&self) -> Result where T: serde::de::DeserializeOwned, diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rs index f48227b926ef..ab402f3a891f 100644 --- a/crates/router/src/core/admin.rs +++ b/crates/router/src/core/admin.rs @@ -1731,10 +1731,10 @@ pub(crate) fn validate_auth_and_metadata_type( bankofamerica::transformers::BankOfAmericaAuthType::try_from(val)?; Ok(()) } - // api_enums::Connector::Billwerk => { - // billwerk::transformers::BillwerkAuthType::try_from(val)?; - // Ok(()) - // } Added as template code for future usage + api_enums::Connector::Billwerk => { + billwerk::transformers::BillwerkAuthType::try_from(val)?; + Ok(()) + } api_enums::Connector::Bitpay => { bitpay::transformers::BitpayAuthType::try_from(val)?; Ok(()) diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rs index 4b72c7ac2e63..b5a4d04c9271 100644 --- a/crates/router/src/types/api.rs +++ b/crates/router/src/types/api.rs @@ -326,7 +326,7 @@ impl ConnectorData { enums::Connector::Authorizedotnet => Ok(Box::new(&connector::Authorizedotnet)), enums::Connector::Bambora => Ok(Box::new(&connector::Bambora)), enums::Connector::Bankofamerica => Ok(Box::new(&connector::Bankofamerica)), - // enums::Connector::Billwerk => Ok(Box::new(&connector::Billwerk)), Added as template code for future usage + enums::Connector::Billwerk => Ok(Box::new(&connector::Billwerk)), enums::Connector::Bitpay => Ok(Box::new(&connector::Bitpay)), enums::Connector::Bluesnap => Ok(Box::new(&connector::Bluesnap)), enums::Connector::Boku => Ok(Box::new(&connector::Boku)), diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rs index 237dea196d68..3362aad6fc55 100644 --- a/crates/router/src/types/transformers.rs +++ b/crates/router/src/types/transformers.rs @@ -188,7 +188,7 @@ impl ForeignTryFrom for common_enums::RoutableConnectors { api_enums::Connector::Authorizedotnet => Self::Authorizedotnet, api_enums::Connector::Bambora => Self::Bambora, api_enums::Connector::Bankofamerica => Self::Bankofamerica, - // api_enums::Connector::Billwerk => Self::Billwerk, Added as template code for future usage + api_enums::Connector::Billwerk => Self::Billwerk, api_enums::Connector::Bitpay => Self::Bitpay, api_enums::Connector::Bluesnap => Self::Bluesnap, api_enums::Connector::Boku => Self::Boku, diff --git a/loadtest/config/development.toml b/loadtest/config/development.toml index 9a9a7606ca1d..72eb6f255595 100644 --- a/loadtest/config/development.toml +++ b/loadtest/config/development.toml @@ -72,6 +72,7 @@ authorizedotnet.base_url = "https://apitest.authorize.net/xml/v1/request.api" bambora.base_url = "https://api.na.bambora.com" bankofamerica.base_url = "https://apitest.merchant-services.bankofamerica.com/" billwerk.base_url = "https://api.reepay.com/" +billwerk.secondary_base_url = "https://card.reepay.com/" bitpay.base_url = "https://test.bitpay.com" bluesnap.base_url = "https://sandbox.bluesnap.com/" bluesnap.secondary_base_url = "https://sandpay.bluesnap.com/" @@ -219,6 +220,7 @@ checkout = { long_lived_token = false, payment_method = "wallet", apple_pay_pre_ mollie = {long_lived_token = false, payment_method = "card"} braintree = { long_lived_token = false, payment_method = "card" } gocardless = {long_lived_token = true, payment_method = "bank_debit"} +billwerk = {long_lived_token = false, payment_method = "card"} [connector_customer] connector_list = "gocardless,stax,stripe" diff --git a/openapi/openapi_spec.json b/openapi/openapi_spec.json index 1e16d0724718..595b18307220 100644 --- a/openapi/openapi_spec.json +++ b/openapi/openapi_spec.json @@ -7067,6 +7067,7 @@ "authorizedotnet", "bambora", "bankofamerica", + "billwerk", "bitpay", "bluesnap", "boku", @@ -16813,6 +16814,7 @@ "airwallex", "authorizedotnet", "bankofamerica", + "billwerk", "bitpay", "bambora", "bluesnap", From 5587a126844abd580c67c8e2b05c26502cd6d844 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 2 Apr 2024 00:05:32 +0000 Subject: [PATCH 12/19] chore(version): 2024.04.02.0 --- CHANGELOG.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ead87751c49..e6c3c091a71e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,29 @@ All notable changes to HyperSwitch will be documented here. - - - +## 2024.04.02.0 + +### Features + +- **connector:** [billwerk] implement payment and refund flows ([#4245](https://github.com/juspay/hyperswitch/pull/4245)) ([`aecf4ae`](https://github.com/juspay/hyperswitch/commit/aecf4aeacce33c3dc03e089ef6d62af93e29ca9a)) +- Return customer details in payments response body ([#4237](https://github.com/juspay/hyperswitch/pull/4237)) ([`740749e`](https://github.com/juspay/hyperswitch/commit/740749e18ae4458726cdf2501f3d3b789c819f7a)) + +### Refactors + +- **core:** Removed the processing status for payment_method_status ([#4213](https://github.com/juspay/hyperswitch/pull/4213)) ([`a843713`](https://github.com/juspay/hyperswitch/commit/a843713126cea102064b342b6fc82429d89d758a)) + +### Documentation + +- **README:** Remove link to outdated early access form ([`78befb4`](https://github.com/juspay/hyperswitch/commit/78befb42a35b1f98b1bd47b253d3c06e50bb2ee4)) + +### Build System / Dependencies + +- **deps:** Bump `error-stack` from version `0.3.1` to `0.4.1` ([#4188](https://github.com/juspay/hyperswitch/pull/4188)) ([`ea730d4`](https://github.com/juspay/hyperswitch/commit/ea730d4ffc712cdf264492db109836fcde9b2b03)) + +**Full Changelog:** [`2024.04.01.0...2024.04.02.0`](https://github.com/juspay/hyperswitch/compare/2024.04.01.0...2024.04.02.0) + +- - - + ## 2024.04.01.0 ### Features From 9cce1520e3b0c7c1d1ae70ca8cc30787ff96dded Mon Sep 17 00:00:00 2001 From: Narayan Bhat <48803246+Narayanbhat166@users.noreply.github.com> Date: Tue, 2 Apr 2024 13:46:20 +0530 Subject: [PATCH 13/19] refactor(payment_methods): add a new domain type for payment method data to be used in connector module (#4140) Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> --- crates/api_models/src/payments.rs | 67 ++- crates/common_enums/src/enums.rs | 164 +++++++ crates/diesel_models/src/enums.rs | 135 ------ crates/router/build.rs | 4 +- .../router/src/connector/aci/transformers.rs | 46 +- .../src/connector/adyen/transformers.rs | 111 +++-- .../src/connector/airwallex/transformers.rs | 36 +- .../connector/authorizedotnet/transformers.rs | 57 +-- .../src/connector/bambora/transformers.rs | 4 +- .../connector/bankofamerica/transformers.rs | 121 +++--- .../src/connector/billwerk/transformers.rs | 30 +- .../src/connector/bluesnap/transformers.rs | 64 +-- .../router/src/connector/boku/transformers.rs | 32 +- .../braintree_graphql_transformers.rs | 100 ++--- .../src/connector/braintree/transformers.rs | 36 +- .../src/connector/checkout/transformers.rs | 64 +-- .../src/connector/cryptopay/transformers.rs | 30 +- .../src/connector/cybersource/transformers.rs | 149 +++---- .../src/connector/dlocal/transformers.rs | 38 +- .../connector/dummyconnector/transformers.rs | 12 +- .../src/connector/fiserv/transformers.rs | 30 +- .../src/connector/forte/transformers.rs | 30 +- .../src/connector/globalpay/transformers.rs | 10 +- .../src/connector/globepay/transformers.rs | 36 +- .../src/connector/gocardless/transformers.rs | 101 ++--- .../src/connector/helcim/transformers.rs | 74 ++-- .../src/connector/iatapay/transformers.rs | 30 +- crates/router/src/connector/klarna.rs | 36 +- .../src/connector/mollie/transformers.rs | 12 +- .../connector/multisafepay/transformers.rs | 80 ++-- .../src/connector/nexinets/transformers.rs | 8 +- .../router/src/connector/nmi/transformers.rs | 52 +-- .../router/src/connector/noon/transformers.rs | 44 +- .../src/connector/nuvei/transformers.rs | 65 +-- .../src/connector/opayo/transformers.rs | 38 +- .../src/connector/payeezy/transformers.rs | 30 +- .../src/connector/payme/transformers.rs | 97 +++-- .../src/connector/paypal/transformers.rs | 48 +-- .../router/src/connector/payu/transformers.rs | 6 +- .../src/connector/placetopay/transformers.rs | 31 +- .../src/connector/powertranz/transformers.rs | 43 +- .../src/connector/prophetpay/transformers.rs | 6 +- .../src/connector/rapyd/transformers.rs | 6 +- .../src/connector/shift4/transformers.rs | 62 +-- .../src/connector/square/transformers.rs | 74 ++-- .../router/src/connector/stax/transformers.rs | 74 ++-- crates/router/src/connector/stripe.rs | 7 +- .../src/connector/stripe/transformers.rs | 203 +++++---- .../connector/threedsecureio/transformers.rs | 7 +- .../src/connector/trustpay/transformers.rs | 40 +- .../router/src/connector/tsys/transformers.rs | 36 +- crates/router/src/connector/utils.rs | 19 +- .../router/src/connector/volt/transformers.rs | 30 +- .../src/connector/worldline/transformers.rs | 37 +- .../src/connector/worldpay/transformers.rs | 40 +- crates/router/src/connector/zen.rs | 4 +- .../router/src/connector/zen/transformers.rs | 59 +-- .../src/core/authentication/transformers.rs | 2 +- crates/router/src/core/mandate.rs | 6 +- crates/router/src/core/payments.rs | 42 +- .../src/core/payments/flows/authorize_flow.rs | 2 +- .../core/payments/flows/setup_mandate_flow.rs | 2 +- crates/router/src/core/payments/helpers.rs | 6 +- .../payments/operations/payment_create.rs | 1 + .../router/src/core/payments/transformers.rs | 27 +- crates/router/src/types.rs | 29 +- .../router/src/types/api/verify_connector.rs | 6 +- crates/router/src/types/authentication.rs | 5 +- crates/router/src/types/domain.rs | 2 + crates/router/src/types/domain/payments.rs | 405 ++++++++++++++++++ crates/router/src/utils/verify_connector.rs | 10 +- crates/router/tests/connectors/aci.rs | 4 +- crates/router/tests/connectors/adyen.rs | 28 +- crates/router/tests/connectors/airwallex.rs | 12 +- .../tests/connectors/authorizedotnet.rs | 46 +- crates/router/tests/connectors/bambora.rs | 13 +- .../router/tests/connectors/bankofamerica.rs | 8 +- crates/router/tests/connectors/billwerk.rs | 8 +- crates/router/tests/connectors/bitpay.rs | 2 +- crates/router/tests/connectors/bluesnap.rs | 8 +- crates/router/tests/connectors/boku.rs | 8 +- crates/router/tests/connectors/cashtocode.rs | 8 +- crates/router/tests/connectors/checkout.rs | 8 +- crates/router/tests/connectors/coinbase.rs | 2 +- crates/router/tests/connectors/cryptopay.rs | 2 +- crates/router/tests/connectors/cybersource.rs | 8 +- crates/router/tests/connectors/dlocal.rs | 10 +- .../router/tests/connectors/dummyconnector.rs | 10 +- crates/router/tests/connectors/fiserv.rs | 12 +- crates/router/tests/connectors/forte.rs | 12 +- crates/router/tests/connectors/globalpay.rs | 8 +- crates/router/tests/connectors/globepay.rs | 8 +- crates/router/tests/connectors/gocardless.rs | 8 +- crates/router/tests/connectors/helcim.rs | 8 +- .../router/tests/connectors/multisafepay.rs | 8 +- crates/router/tests/connectors/nexinets.rs | 10 +- crates/router/tests/connectors/nmi.rs | 4 +- crates/router/tests/connectors/noon.rs | 10 +- crates/router/tests/connectors/nuvei.rs | 12 +- crates/router/tests/connectors/opayo.rs | 10 +- crates/router/tests/connectors/opennode.rs | 2 +- crates/router/tests/connectors/payeezy.rs | 12 +- crates/router/tests/connectors/payme.rs | 10 +- crates/router/tests/connectors/paypal.rs | 10 +- crates/router/tests/connectors/payu.rs | 2 +- crates/router/tests/connectors/placetopay.rs | 8 +- crates/router/tests/connectors/powertranz.rs | 8 +- crates/router/tests/connectors/prophetpay.rs | 8 +- crates/router/tests/connectors/rapyd.rs | 8 +- crates/router/tests/connectors/shift4.rs | 10 +- crates/router/tests/connectors/square.rs | 10 +- crates/router/tests/connectors/stax.rs | 10 +- crates/router/tests/connectors/stripe.rs | 12 +- crates/router/tests/connectors/trustpay.rs | 8 +- crates/router/tests/connectors/tsys.rs | 10 +- crates/router/tests/connectors/utils.rs | 14 +- crates/router/tests/connectors/volt.rs | 8 +- crates/router/tests/connectors/worldline.rs | 2 +- crates/router/tests/connectors/worldpay.rs | 4 +- crates/router/tests/connectors/zen.rs | 10 +- 120 files changed, 2232 insertions(+), 1679 deletions(-) create mode 100644 crates/router/src/types/domain/payments.rs diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs index 63b293061139..b719d1f7d111 100644 --- a/crates/api_models/src/payments.rs +++ b/crates/api_models/src/payments.rs @@ -1292,26 +1292,14 @@ pub trait GetAddressFromPaymentMethodData { impl GetAddressFromPaymentMethodData for PaymentMethodData { fn get_billing_address(&self) -> Option
{ match self { - Self::Card(card_data) => { - card_data - .card_holder_name - .as_ref() - .map(|card_holder_name| Address { - address: Some(AddressDetails { - first_name: Some(card_holder_name.clone()), - ..AddressDetails::default() - }), - email: None, - phone: None, - }) - } + Self::Card(_) => None, Self::CardRedirect(_) => None, - Self::Wallet(wallet_data) => wallet_data.get_billing_address(), - Self::PayLater(pay_later_data) => pay_later_data.get_billing_address(), - Self::BankRedirect(bank_redirect_data) => bank_redirect_data.get_billing_address(), - Self::BankDebit(bank_debit_data) => bank_debit_data.get_billing_address(), - Self::BankTransfer(bank_transfer_data) => bank_transfer_data.get_billing_address(), - Self::Voucher(voucher_data) => voucher_data.get_billing_address(), + Self::Wallet(_) => None, + Self::PayLater(_) => None, + Self::BankRedirect(_) => None, + Self::BankDebit(_) => None, + Self::BankTransfer(_) => None, + Self::Voucher(_) => None, Self::Crypto(_) | Self::Reward | Self::Upi(_) @@ -2597,6 +2585,21 @@ pub struct Address { pub email: Option, } +impl Address { + /// Unify the address, giving priority to `self` when details are present in both + pub fn unify_address(self, other: Option<&Self>) -> Self { + let other_address_details = other.and_then(|address| address.address.as_ref()); + Self { + address: self + .address + .map(|address| address.unify_address_details(other_address_details)) + .or(other_address_details.cloned()), + email: self.email.or(other.and_then(|other| other.email.clone())), + phone: self.phone.or(other.and_then(|other| other.phone.clone())), + } + } +} + // used by customers also, could be moved outside /// Address details #[derive(Clone, Default, Debug, Eq, serde::Deserialize, serde::Serialize, PartialEq, ToSchema)] @@ -2639,6 +2642,32 @@ pub struct AddressDetails { pub last_name: Option>, } +impl AddressDetails { + pub fn unify_address_details(self, other: Option<&Self>) -> Self { + if let Some(other) = other { + let (first_name, last_name) = if self.first_name.is_some() { + (self.first_name, self.last_name) + } else { + (other.first_name.clone(), other.last_name.clone()) + }; + + Self { + first_name, + last_name, + city: self.city.or(other.city.clone()), + country: self.country.or(other.country), + line1: self.line1.or(other.line1.clone()), + line2: self.line2.or(other.line2.clone()), + line3: self.line3.or(other.line3.clone()), + zip: self.zip.or(other.zip.clone()), + state: self.state.or(other.state.clone()), + } + } else { + self + } + } +} + #[derive(Debug, Clone, Default, Eq, PartialEq, ToSchema, serde::Deserialize, serde::Serialize)] pub struct PhoneDetails { /// The contact number diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs index 497f1f58729d..571449b98722 100644 --- a/crates/common_enums/src/enums.rs +++ b/crates/common_enums/src/enums.rs @@ -2485,3 +2485,167 @@ pub enum PermissionGroup { MerchantDetailsManage, OrganizationManage, } + +/// Name of banks supported by Hyperswitch +#[derive( + Clone, + Copy, + Debug, + Eq, + Hash, + PartialEq, + serde::Deserialize, + serde::Serialize, + strum::Display, + strum::EnumString, + ToSchema, +)] +#[strum(serialize_all = "snake_case")] +#[serde(rename_all = "snake_case")] +pub enum BankNames { + AmericanExpress, + AffinBank, + AgroBank, + AllianceBank, + AmBank, + BankOfAmerica, + BankIslam, + BankMuamalat, + BankRakyat, + BankSimpananNasional, + Barclays, + BlikPSP, + CapitalOne, + Chase, + Citi, + CimbBank, + Discover, + NavyFederalCreditUnion, + PentagonFederalCreditUnion, + SynchronyBank, + WellsFargo, + AbnAmro, + AsnBank, + Bunq, + Handelsbanken, + HongLeongBank, + HsbcBank, + Ing, + Knab, + KuwaitFinanceHouse, + Moneyou, + Rabobank, + Regiobank, + Revolut, + SnsBank, + TriodosBank, + VanLanschot, + ArzteUndApothekerBank, + AustrianAnadiBankAg, + BankAustria, + Bank99Ag, + BankhausCarlSpangler, + BankhausSchelhammerUndSchatteraAg, + BankMillennium, + BankPEKAOSA, + BawagPskAg, + BksBankAg, + BrullKallmusBankAg, + BtvVierLanderBank, + CapitalBankGraweGruppeAg, + CeskaSporitelna, + Dolomitenbank, + EasybankAg, + EPlatbyVUB, + ErsteBankUndSparkassen, + FrieslandBank, + HypoAlpeadriabankInternationalAg, + HypoNoeLbFurNiederosterreichUWien, + HypoOberosterreichSalzburgSteiermark, + HypoTirolBankAg, + HypoVorarlbergBankAg, + HypoBankBurgenlandAktiengesellschaft, + KomercniBanka, + MBank, + MarchfelderBank, + Maybank, + OberbankAg, + OsterreichischeArzteUndApothekerbank, + OcbcBank, + PayWithING, + PlaceZIPKO, + PlatnoscOnlineKartaPlatnicza, + PosojilnicaBankEGen, + PostovaBanka, + PublicBank, + RaiffeisenBankengruppeOsterreich, + RhbBank, + SchelhammerCapitalBankAg, + StandardCharteredBank, + SchoellerbankAg, + SpardaBankWien, + SporoPay, + SantanderPrzelew24, + TatraPay, + Viamo, + VolksbankGruppe, + VolkskreditbankAg, + VrBankBraunau, + UobBank, + PayWithAliorBank, + BankiSpoldzielcze, + PayWithInteligo, + BNPParibasPoland, + BankNowySA, + CreditAgricole, + PayWithBOS, + PayWithCitiHandlowy, + PayWithPlusBank, + ToyotaBank, + VeloBank, + ETransferPocztowy24, + PlusBank, + EtransferPocztowy24, + BankiSpbdzielcze, + BankNowyBfgSa, + GetinBank, + Blik, + NoblePay, + IdeaBank, + EnveloBank, + NestPrzelew, + MbankMtransfer, + Inteligo, + PbacZIpko, + BnpParibas, + BankPekaoSa, + VolkswagenBank, + AliorBank, + Boz, + BangkokBank, + KrungsriBank, + KrungThaiBank, + TheSiamCommercialBank, + KasikornBank, + OpenBankSuccess, + OpenBankFailure, + OpenBankCancelled, + Aib, + BankOfScotland, + DanskeBank, + FirstDirect, + FirstTrust, + Halifax, + Lloyds, + Monzo, + NatWest, + NationwideBank, + RoyalBankOfScotland, + Starling, + TsbBank, + TescoBank, + UlsterBank, + Yoursafe, + N26, + NationaleNederlanden, +} diff --git a/crates/diesel_models/src/enums.rs b/crates/diesel_models/src/enums.rs index 865524c64553..7d9b6eb57e54 100644 --- a/crates/diesel_models/src/enums.rs +++ b/crates/diesel_models/src/enums.rs @@ -222,141 +222,6 @@ pub struct MandateAmountData { pub metadata: Option, } -#[derive( - Clone, - Copy, - Debug, - Eq, - Hash, - PartialEq, - serde::Deserialize, - serde::Serialize, - strum::Display, - strum::EnumString, -)] -#[diesel_enum(storage_type = "text")] -#[strum(serialize_all = "snake_case")] -#[serde(rename_all = "snake_case")] -pub enum BankNames { - AmericanExpress, - BankOfAmerica, - Barclays, - CapitalOne, - Chase, - Citi, - Discover, - NavyFederalCreditUnion, - PentagonFederalCreditUnion, - SynchronyBank, - WellsFargo, - AbnAmro, - AsnBank, - Bunq, - Handelsbanken, - Ing, - Knab, - Moneyou, - Rabobank, - Regiobank, - Revolut, - SnsBank, - TriodosBank, - VanLanschot, - ArzteUndApothekerBank, - AustrianAnadiBankAg, - BankAustria, - Bank99Ag, - BankhausCarlSpangler, - BankhausSchelhammerUndSchatteraAg, - BawagPskAg, - BksBankAg, - BrullKallmusBankAg, - BtvVierLanderBank, - CapitalBankGraweGruppeAg, - Dolomitenbank, - EasybankAg, - ErsteBankUndSparkassen, - HypoAlpeadriabankInternationalAg, - HypoNoeLbFurNiederosterreichUWien, - HypoOberosterreichSalzburgSteiermark, - HypoTirolBankAg, - HypoVorarlbergBankAg, - HypoBankBurgenlandAktiengesellschaft, - MarchfelderBank, - OberbankAg, - OsterreichischeArzteUndApothekerbank, - PosojilnicaBankEGen, - RaiffeisenBankengruppeOsterreich, - SchelhammerCapitalBankAg, - SchoellerbankAg, - SpardaBankWien, - VolksbankGruppe, - VolkskreditbankAg, - VrBankBraunau, - PlusBank, - EtransferPocztowy24, - BankiSpbdzielcze, - BankNowyBfgSa, - GetinBank, - Blik, - NoblePay, - IdeaBank, - EnveloBank, - NestPrzelew, - MbankMtransfer, - Inteligo, - PbacZIpko, - BnpParibas, - BankPekaoSa, - VolkswagenBank, - AliorBank, - Boz, - AffinBank, - AgroBank, - AllianceBank, - AmBank, - BankIslam, - BankMuamalat, - BankRakyat, - BankSimpananNasional, - CimbBank, - HongLeongBank, - HsbcBank, - KuwaitFinanceHouse, - Maybank, - OcbcBank, - PublicBank, - RhbBank, - StandardCharteredBank, - UobBank, - BangkokBank, - KrungsriBank, - KrungThaiBank, - TheSiamCommercialBank, - KasikornBank, - OpenBankSuccess, - OpenBankFailure, - OpenBankCancelled, - Aib, - BankOfScotland, - DanskeBank, - FirstDirect, - FirstTrust, - Halifax, - Lloyds, - Monzo, - NatWest, - NationwideBank, - RoyalBankOfScotland, - Starling, - TsbBank, - TescoBank, - UlsterBank, - Yoursafe, - N26, - NationaleNederlanden, -} - #[derive( Clone, Copy, diff --git a/crates/router/build.rs b/crates/router/build.rs index 167ca9184074..b33c168833d2 100644 --- a/crates/router/build.rs +++ b/crates/router/build.rs @@ -1,8 +1,8 @@ fn main() { - // Set thread stack size to 4 MiB for debug builds + // Set thread stack size to 8 MiB for debug builds // Reference: https://doc.rust-lang.org/std/thread/#stack-size #[cfg(debug_assertions)] - println!("cargo:rustc-env=RUST_MIN_STACK=6291456"); // 6 * 1024 * 1024 = 6 MiB + println!("cargo:rustc-env=RUST_MIN_STACK=8388608"); // 8 * 1024 * 1024 = 8 MiB #[cfg(feature = "vergen")] router_env::vergen::generate_cargo_instructions(); diff --git a/crates/router/src/connector/aci/transformers.rs b/crates/router/src/connector/aci/transformers.rs index 7fb3ba7c4119..a478201f96b8 100644 --- a/crates/router/src/connector/aci/transformers.rs +++ b/crates/router/src/connector/aci/transformers.rs @@ -12,7 +12,7 @@ use crate::{ connector::utils::{self, RouterData}, core::errors, services, - types::{self, api, storage::enums}, + types::{self, domain, storage::enums}, }; type Error = error_stack::Report; @@ -302,9 +302,9 @@ impl } } -impl TryFrom for PaymentDetails { +impl TryFrom for PaymentDetails { type Error = Error; - fn try_from(card_data: api_models::payments::Card) -> Result { + fn try_from(card_data: domain::payments::Card) -> Result { Ok(Self::AciCard(Box::new(CardDetails { card_number: card_data.card_number, card_holder: card_data @@ -441,15 +441,17 @@ impl TryFrom<&AciRouterData<&types::PaymentsAuthorizeRouterData>> for AciPayment item: &AciRouterData<&types::PaymentsAuthorizeRouterData>, ) -> Result { match item.router_data.request.payment_method_data.clone() { - api::PaymentMethodData::Card(ref card_data) => Self::try_from((item, card_data)), - api::PaymentMethodData::Wallet(ref wallet_data) => Self::try_from((item, wallet_data)), - api::PaymentMethodData::PayLater(ref pay_later_data) => { + domain::PaymentMethodData::Card(ref card_data) => Self::try_from((item, card_data)), + domain::PaymentMethodData::Wallet(ref wallet_data) => { + Self::try_from((item, wallet_data)) + } + domain::PaymentMethodData::PayLater(ref pay_later_data) => { Self::try_from((item, pay_later_data)) } - api::PaymentMethodData::BankRedirect(ref bank_redirect_data) => { + domain::PaymentMethodData::BankRedirect(ref bank_redirect_data) => { Self::try_from((item, bank_redirect_data)) } - api::PaymentMethodData::MandatePayment => { + domain::PaymentMethodData::MandatePayment => { let mandate_id = item.router_data.request.mandate_id.clone().ok_or( errors::ConnectorError::MissingRequiredField { field_name: "mandate_id", @@ -457,17 +459,19 @@ impl TryFrom<&AciRouterData<&types::PaymentsAuthorizeRouterData>> for AciPayment )?; Self::try_from((item, mandate_id)) } - api::PaymentMethodData::Crypto(_) - | api::PaymentMethodData::BankDebit(_) - | api::PaymentMethodData::BankTransfer(_) - | api::PaymentMethodData::Reward - | api::PaymentMethodData::GiftCard(_) - | api::PaymentMethodData::CardRedirect(_) - | api::PaymentMethodData::Upi(_) - | api::PaymentMethodData::Voucher(_) - | api::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented( - utils::get_unimplemented_payment_method_error_message("Aci"), - ))?, + domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::CardToken(_) => { + Err(errors::ConnectorError::NotImplemented( + utils::get_unimplemented_payment_method_error_message("Aci"), + ))? + } } } } @@ -553,14 +557,14 @@ impl impl TryFrom<( &AciRouterData<&types::PaymentsAuthorizeRouterData>, - &api::Card, + &domain::Card, )> for AciPaymentsRequest { type Error = Error; fn try_from( value: ( &AciRouterData<&types::PaymentsAuthorizeRouterData>, - &api::Card, + &domain::Card, ), ) -> Result { let (item, card_data) = value; diff --git a/crates/router/src/connector/adyen/transformers.rs b/crates/router/src/connector/adyen/transformers.rs index b301be7f577f..5a1abb147edf 100644 --- a/crates/router/src/connector/adyen/transformers.rs +++ b/crates/router/src/connector/adyen/transformers.rs @@ -21,6 +21,7 @@ use crate::{ types::{ self, api::{self, enums as api_enums}, + domain, storage::enums as storage_enums, transformers::{ForeignFrom, ForeignTryFrom}, PaymentsAuthorizeData, @@ -1553,38 +1554,38 @@ impl<'a> TryFrom<&AdyenRouterData<&types::PaymentsAuthorizeRouterData>> { Some(mandate_ref) => AdyenPaymentRequest::try_from((item, mandate_ref)), None => match item.router_data.request.payment_method_data { - api_models::payments::PaymentMethodData::Card(ref card) => { + domain::PaymentMethodData::Card(ref card) => { AdyenPaymentRequest::try_from((item, card)) } - api_models::payments::PaymentMethodData::Wallet(ref wallet) => { + domain::PaymentMethodData::Wallet(ref wallet) => { AdyenPaymentRequest::try_from((item, wallet)) } - api_models::payments::PaymentMethodData::PayLater(ref pay_later) => { + domain::PaymentMethodData::PayLater(ref pay_later) => { AdyenPaymentRequest::try_from((item, pay_later)) } - api_models::payments::PaymentMethodData::BankRedirect(ref bank_redirect) => { + domain::PaymentMethodData::BankRedirect(ref bank_redirect) => { AdyenPaymentRequest::try_from((item, bank_redirect)) } - api_models::payments::PaymentMethodData::BankDebit(ref bank_debit) => { + domain::PaymentMethodData::BankDebit(ref bank_debit) => { AdyenPaymentRequest::try_from((item, bank_debit)) } - api_models::payments::PaymentMethodData::BankTransfer(ref bank_transfer) => { + domain::PaymentMethodData::BankTransfer(ref bank_transfer) => { AdyenPaymentRequest::try_from((item, bank_transfer.as_ref())) } - api_models::payments::PaymentMethodData::CardRedirect(ref card_redirect_data) => { + domain::PaymentMethodData::CardRedirect(ref card_redirect_data) => { AdyenPaymentRequest::try_from((item, card_redirect_data)) } - api_models::payments::PaymentMethodData::Voucher(ref voucher_data) => { + domain::PaymentMethodData::Voucher(ref voucher_data) => { AdyenPaymentRequest::try_from((item, voucher_data)) } - api_models::payments::PaymentMethodData::GiftCard(ref gift_card_data) => { + domain::PaymentMethodData::GiftCard(ref gift_card_data) => { AdyenPaymentRequest::try_from((item, gift_card_data.as_ref())) } - payments::PaymentMethodData::Crypto(_) - | payments::PaymentMethodData::MandatePayment - | payments::PaymentMethodData::Reward - | payments::PaymentMethodData::Upi(_) - | payments::PaymentMethodData::CardToken(_) => { + domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::CardToken(_) => { Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("Adyen"), ))? @@ -1598,7 +1599,7 @@ impl<'a> TryFrom<&types::PaymentsPreProcessingRouterData> for AdyenBalanceReques type Error = Error; fn try_from(item: &types::PaymentsPreProcessingRouterData) -> Result { let payment_method = match &item.request.payment_method_data { - Some(payments::PaymentMethodData::GiftCard(gift_card_data)) => { + Some(domain::PaymentMethodData::GiftCard(gift_card_data)) => { match gift_card_data.as_ref() { payments::GiftCardData::Givex(gift_card_data) => { let balance_pm = BalancePmData { @@ -1962,9 +1963,9 @@ impl<'a> TryFrom<&api_models::payments::GiftCardData> for AdyenPaymentMethod<'a> } } -impl<'a> TryFrom<&api::Card> for AdyenPaymentMethod<'a> { +impl<'a> TryFrom<&domain::Card> for AdyenPaymentMethod<'a> { type Error = Error; - fn try_from(card: &api::Card) -> Result { + fn try_from(card: &domain::Card) -> Result { let adyen_card = AdyenCard { payment_type: PaymentType::Scheme, number: card.card_number.clone(), @@ -2505,16 +2506,16 @@ impl<'a> TryFrom<&api_models::payments::BankTransferData> for AdyenPaymentMethod } } -impl<'a> TryFrom<&api_models::payments::CardRedirectData> for AdyenPaymentMethod<'a> { +impl<'a> TryFrom<&domain::payments::CardRedirectData> for AdyenPaymentMethod<'a> { type Error = Error; fn try_from( - card_redirect_data: &api_models::payments::CardRedirectData, + card_redirect_data: &domain::payments::CardRedirectData, ) -> Result { match card_redirect_data { - payments::CardRedirectData::Knet {} => Ok(AdyenPaymentMethod::Knet), - payments::CardRedirectData::Benefit {} => Ok(AdyenPaymentMethod::Benefit), - payments::CardRedirectData::MomoAtm {} => Ok(AdyenPaymentMethod::MomoAtm), - payments::CardRedirectData::CardRedirect {} => { + domain::CardRedirectData::Knet {} => Ok(AdyenPaymentMethod::Knet), + domain::CardRedirectData::Benefit {} => Ok(AdyenPaymentMethod::Benefit), + domain::CardRedirectData::MomoAtm {} => Ok(AdyenPaymentMethod::MomoAtm), + domain::CardRedirectData::CardRedirect {} => { Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("Adyen"), ) @@ -2566,7 +2567,7 @@ impl<'a> } payments::MandateReferenceId::NetworkMandateId(network_mandate_id) => { match item.router_data.request.payment_method_data { - api::PaymentMethodData::Card(ref card) => { + domain::PaymentMethodData::Card(ref card) => { let card_issuer = card.get_card_issuer()?; let brand = CardBrand::try_from(&card_issuer)?; let adyen_card = AdyenCard { @@ -2581,19 +2582,19 @@ impl<'a> }; Ok(AdyenPaymentMethod::AdyenCard(Box::new(adyen_card))) } - payments::PaymentMethodData::CardRedirect(_) - | payments::PaymentMethodData::Wallet(_) - | payments::PaymentMethodData::PayLater(_) - | payments::PaymentMethodData::BankRedirect(_) - | payments::PaymentMethodData::BankDebit(_) - | payments::PaymentMethodData::BankTransfer(_) - | payments::PaymentMethodData::Crypto(_) - | payments::PaymentMethodData::MandatePayment - | payments::PaymentMethodData::Reward - | payments::PaymentMethodData::Upi(_) - | payments::PaymentMethodData::Voucher(_) - | payments::PaymentMethodData::GiftCard(_) - | api::PaymentMethodData::CardToken(_) => { + domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::Wallet(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { Err(errors::ConnectorError::NotSupported { message: "Network tokenization for payment method".to_string(), connector: "Adyen", @@ -2633,14 +2634,14 @@ impl<'a> impl<'a> TryFrom<( &AdyenRouterData<&types::PaymentsAuthorizeRouterData>, - &api::Card, + &domain::Card, )> for AdyenPaymentRequest<'a> { type Error = Error; fn try_from( value: ( &AdyenRouterData<&types::PaymentsAuthorizeRouterData>, - &api::Card, + &domain::Card, ), ) -> Result { let (item, card_data) = value; @@ -2960,22 +2961,20 @@ fn get_redirect_extra_details( item: &types::PaymentsAuthorizeRouterData, ) -> Result<(Option, Option), errors::ConnectorError> { match item.request.payment_method_data { - api_models::payments::PaymentMethodData::BankRedirect(ref redirect_data) => { - match redirect_data { - api_models::payments::BankRedirectData::Sofort { - country, - preferred_language, - .. - } => Ok((preferred_language.clone(), *country)), - api_models::payments::BankRedirectData::OpenBankingUk { country, .. } => { - let country = country.ok_or(errors::ConnectorError::MissingRequiredField { - field_name: "country", - })?; - Ok((None, Some(country))) - } - _ => Ok((None, None)), + domain::PaymentMethodData::BankRedirect(ref redirect_data) => match redirect_data { + api_models::payments::BankRedirectData::Sofort { + country, + preferred_language, + .. + } => Ok((preferred_language.clone(), *country)), + api_models::payments::BankRedirectData::OpenBankingUk { country, .. } => { + let country = country.ok_or(errors::ConnectorError::MissingRequiredField { + field_name: "country", + })?; + Ok((None, Some(country))) } - } + _ => Ok((None, None)), + }, _ => Ok((None, None)), } } @@ -3131,14 +3130,14 @@ impl<'a> impl<'a> TryFrom<( &AdyenRouterData<&types::PaymentsAuthorizeRouterData>, - &api_models::payments::CardRedirectData, + &domain::payments::CardRedirectData, )> for AdyenPaymentRequest<'a> { type Error = Error; fn try_from( value: ( &AdyenRouterData<&types::PaymentsAuthorizeRouterData>, - &api_models::payments::CardRedirectData, + &domain::payments::CardRedirectData, ), ) -> Result { let (item, card_redirect_data) = value; diff --git a/crates/router/src/connector/airwallex/transformers.rs b/crates/router/src/connector/airwallex/transformers.rs index ee52884817b1..6d17707355b1 100644 --- a/crates/router/src/connector/airwallex/transformers.rs +++ b/crates/router/src/connector/airwallex/transformers.rs @@ -10,7 +10,7 @@ use crate::{ core::errors, pii::Secret, services, - types::{self, api, storage::enums, PaymentsSyncData}, + types::{self, api, domain, storage::enums, PaymentsSyncData}, }; pub struct AirwallexAuthType { @@ -167,7 +167,7 @@ impl TryFrom<&AirwallexRouterData<&types::PaymentsAuthorizeRouterData>> let mut payment_method_options = None; let request = &item.router_data.request; let payment_method = match request.payment_method_data.clone() { - api::PaymentMethodData::Card(ccard) => { + domain::PaymentMethodData::Card(ccard) => { payment_method_options = Some(AirwallexPaymentOptions::Card(AirwallexCardPaymentOptions { auto_capture: matches!( @@ -185,21 +185,23 @@ impl TryFrom<&AirwallexRouterData<&types::PaymentsAuthorizeRouterData>> payment_method_type: AirwallexPaymentType::Card, })) } - api::PaymentMethodData::Wallet(ref wallet_data) => get_wallet_details(wallet_data), - api::PaymentMethodData::PayLater(_) - | api::PaymentMethodData::BankRedirect(_) - | api::PaymentMethodData::BankDebit(_) - | api::PaymentMethodData::BankTransfer(_) - | api::PaymentMethodData::CardRedirect(_) - | api::PaymentMethodData::Crypto(_) - | api::PaymentMethodData::MandatePayment - | api::PaymentMethodData::Reward - | api::PaymentMethodData::Upi(_) - | api::PaymentMethodData::Voucher(_) - | api::PaymentMethodData::GiftCard(_) - | api::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented( - utils::get_unimplemented_payment_method_error_message("airwallex"), - )), + domain::PaymentMethodData::Wallet(ref wallet_data) => get_wallet_details(wallet_data), + domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { + Err(errors::ConnectorError::NotImplemented( + utils::get_unimplemented_payment_method_error_message("airwallex"), + )) + } }?; Ok(Self { diff --git a/crates/router/src/connector/authorizedotnet/transformers.rs b/crates/router/src/connector/authorizedotnet/transformers.rs index 2e5a9f3bbcba..3156f01ebcf8 100644 --- a/crates/router/src/connector/authorizedotnet/transformers.rs +++ b/crates/router/src/connector/authorizedotnet/transformers.rs @@ -15,6 +15,7 @@ use crate::{ types::{ self, api::{self, enums as api_enums}, + domain, storage::enums, transformers::ForeignFrom, }, @@ -163,7 +164,7 @@ fn get_pm_and_subsequent_auth_detail( reason: Reason::Resubmission, }); match item.router_data.request.payment_method_data { - api::PaymentMethodData::Card(ref ccard) => { + domain::PaymentMethodData::Card(ref ccard) => { let payment_details = PaymentDetails::CreditCard(CreditCardDetails { card_number: (*ccard.card_number).clone(), expiration_date: ccard.get_expiry_date_as_yyyymm("-"), @@ -171,19 +172,19 @@ fn get_pm_and_subsequent_auth_detail( }); Ok((payment_details, processing_options, subseuent_auth_info)) } - api::PaymentMethodData::CardRedirect(_) - | api::PaymentMethodData::Wallet(_) - | api::PaymentMethodData::PayLater(_) - | api::PaymentMethodData::BankRedirect(_) - | api::PaymentMethodData::BankDebit(_) - | api::PaymentMethodData::BankTransfer(_) - | api::PaymentMethodData::Crypto(_) - | api::PaymentMethodData::MandatePayment - | api::PaymentMethodData::Reward - | api::PaymentMethodData::Upi(_) - | api::PaymentMethodData::Voucher(_) - | api::PaymentMethodData::GiftCard(_) - | api::PaymentMethodData::CardToken(_) => { + domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::Wallet(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("authorizedotnet"), ))? @@ -192,7 +193,7 @@ fn get_pm_and_subsequent_auth_detail( } Some(api_models::payments::MandateReferenceId::ConnectorMandateId(_)) | None => { match item.router_data.request.payment_method_data { - api::PaymentMethodData::Card(ref ccard) => { + domain::PaymentMethodData::Card(ref ccard) => { Ok(( PaymentDetails::CreditCard(CreditCardDetails { card_number: (*ccard.card_number).clone(), @@ -206,7 +207,7 @@ fn get_pm_and_subsequent_auth_detail( None, )) } - api::PaymentMethodData::Wallet(ref wallet_data) => Ok(( + domain::PaymentMethodData::Wallet(ref wallet_data) => Ok(( get_wallet_data( wallet_data, &item.router_data.request.complete_authorize_url, @@ -214,18 +215,18 @@ fn get_pm_and_subsequent_auth_detail( None, None, )), - api::PaymentMethodData::CardRedirect(_) - | api::PaymentMethodData::PayLater(_) - | api::PaymentMethodData::BankRedirect(_) - | api::PaymentMethodData::BankDebit(_) - | api::PaymentMethodData::BankTransfer(_) - | api::PaymentMethodData::Crypto(_) - | api::PaymentMethodData::MandatePayment - | api::PaymentMethodData::Reward - | api::PaymentMethodData::Upi(_) - | api::PaymentMethodData::Voucher(_) - | api::PaymentMethodData::GiftCard(_) - | api::PaymentMethodData::CardToken(_) => { + domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("authorizedotnet"), ))? diff --git a/crates/router/src/connector/bambora/transformers.rs b/crates/router/src/connector/bambora/transformers.rs index 40c3219d353e..42420cb34037 100644 --- a/crates/router/src/connector/bambora/transformers.rs +++ b/crates/router/src/connector/bambora/transformers.rs @@ -9,7 +9,7 @@ use crate::{ consts, core::errors, services, - types::{self, api, storage::enums}, + types::{self, api, domain, storage::enums}, }; #[derive(Default, Debug, Serialize, Eq, PartialEq)] @@ -106,7 +106,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for BamboraPaymentsRequest { type Error = error_stack::Report; fn try_from(item: &types::PaymentsAuthorizeRouterData) -> Result { match item.request.payment_method_data.clone() { - api::PaymentMethodData::Card(req_card) => { + domain::PaymentMethodData::Card(req_card) => { let three_ds = match item.auth_type { enums::AuthenticationType::ThreeDs => Some(ThreeDSecure { enabled: true, diff --git a/crates/router/src/connector/bankofamerica/transformers.rs b/crates/router/src/connector/bankofamerica/transformers.rs index c5a4f0b317aa..b9456982f2a2 100644 --- a/crates/router/src/connector/bankofamerica/transformers.rs +++ b/crates/router/src/connector/bankofamerica/transformers.rs @@ -18,6 +18,7 @@ use crate::{ types::{ self, api::{self, enums as api_enums}, + domain, storage::enums, transformers::ForeignFrom, ApplePayPredecryptData, @@ -462,14 +463,14 @@ pub struct Avs { impl TryFrom<( &BankOfAmericaRouterData<&types::PaymentsCompleteAuthorizeRouterData>, - payments::Card, + domain::Card, )> for BankOfAmericaPaymentsRequest { type Error = error_stack::Report; fn try_from( (item, ccard): ( &BankOfAmericaRouterData<&types::PaymentsCompleteAuthorizeRouterData>, - payments::Card, + domain::Card, ), ) -> Result { let email = item.router_data.request.get_email()?; @@ -539,14 +540,14 @@ impl impl TryFrom<( &BankOfAmericaRouterData<&types::PaymentsAuthorizeRouterData>, - payments::Card, + domain::Card, )> for BankOfAmericaPaymentsRequest { type Error = error_stack::Report; fn try_from( (item, ccard): ( &BankOfAmericaRouterData<&types::PaymentsAuthorizeRouterData>, - payments::Card, + domain::Card, ), ) -> Result { let email = item.router_data.request.get_email()?; @@ -700,8 +701,8 @@ impl TryFrom<&BankOfAmericaRouterData<&types::PaymentsAuthorizeRouterData>> item: &BankOfAmericaRouterData<&types::PaymentsAuthorizeRouterData>, ) -> Result { match item.router_data.request.payment_method_data.clone() { - payments::PaymentMethodData::Card(ccard) => Self::try_from((item, ccard)), - payments::PaymentMethodData::Wallet(wallet_data) => match wallet_data { + domain::PaymentMethodData::Card(ccard) => Self::try_from((item, ccard)), + domain::PaymentMethodData::Wallet(wallet_data) => match wallet_data { payments::WalletData::ApplePay(apple_pay_data) => { match item.router_data.payment_method_token.clone() { Some(payment_method_token) => match payment_method_token { @@ -803,18 +804,18 @@ impl TryFrom<&BankOfAmericaRouterData<&types::PaymentsAuthorizeRouterData>> ) .into()), }, - payments::PaymentMethodData::CardRedirect(_) - | payments::PaymentMethodData::PayLater(_) - | payments::PaymentMethodData::BankRedirect(_) - | payments::PaymentMethodData::BankDebit(_) - | payments::PaymentMethodData::BankTransfer(_) - | payments::PaymentMethodData::Crypto(_) - | payments::PaymentMethodData::MandatePayment - | payments::PaymentMethodData::Reward - | payments::PaymentMethodData::Upi(_) - | payments::PaymentMethodData::Voucher(_) - | payments::PaymentMethodData::GiftCard(_) - | payments::PaymentMethodData::CardToken(_) => { + domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("Bank of America"), ) @@ -839,7 +840,7 @@ impl TryFrom<&BankOfAmericaRouterData<&types::PaymentsAuthorizeRouterData>> item: &BankOfAmericaRouterData<&types::PaymentsAuthorizeRouterData>, ) -> Result { match item.router_data.request.payment_method_data.clone() { - payments::PaymentMethodData::Card(ccard) => { + domain::PaymentMethodData::Card(ccard) => { let card_issuer = ccard.get_card_issuer(); let card_type = match card_issuer { Ok(issuer) => Some(String::from(issuer)), @@ -860,19 +861,19 @@ impl TryFrom<&BankOfAmericaRouterData<&types::PaymentsAuthorizeRouterData>> client_reference_information, }) } - payments::PaymentMethodData::Wallet(_) - | payments::PaymentMethodData::CardRedirect(_) - | payments::PaymentMethodData::PayLater(_) - | payments::PaymentMethodData::BankRedirect(_) - | payments::PaymentMethodData::BankDebit(_) - | payments::PaymentMethodData::BankTransfer(_) - | payments::PaymentMethodData::Crypto(_) - | payments::PaymentMethodData::MandatePayment - | payments::PaymentMethodData::Reward - | payments::PaymentMethodData::Upi(_) - | payments::PaymentMethodData::Voucher(_) - | payments::PaymentMethodData::GiftCard(_) - | payments::PaymentMethodData::CardToken(_) => { + domain::PaymentMethodData::Wallet(_) + | domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("BankOfAmerica"), ) @@ -1232,7 +1233,7 @@ impl TryFrom<&BankOfAmericaRouterData<&types::PaymentsPreProcessingRouterData>> }, )?; let payment_information = match payment_method_data { - payments::PaymentMethodData::Card(ccard) => { + domain::PaymentMethodData::Card(ccard) => { let card_issuer = ccard.get_card_issuer(); let card_type = match card_issuer { Ok(issuer) => Some(String::from(issuer)), @@ -1248,19 +1249,19 @@ impl TryFrom<&BankOfAmericaRouterData<&types::PaymentsPreProcessingRouterData>> }, })) } - payments::PaymentMethodData::Wallet(_) - | payments::PaymentMethodData::CardRedirect(_) - | payments::PaymentMethodData::PayLater(_) - | payments::PaymentMethodData::BankRedirect(_) - | payments::PaymentMethodData::BankDebit(_) - | payments::PaymentMethodData::BankTransfer(_) - | payments::PaymentMethodData::Crypto(_) - | payments::PaymentMethodData::MandatePayment - | payments::PaymentMethodData::Reward - | payments::PaymentMethodData::Upi(_) - | payments::PaymentMethodData::Voucher(_) - | payments::PaymentMethodData::GiftCard(_) - | payments::PaymentMethodData::CardToken(_) => { + domain::PaymentMethodData::Wallet(_) + | domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("BankOfAmerica"), )) @@ -1348,20 +1349,20 @@ impl TryFrom<&BankOfAmericaRouterData<&types::PaymentsCompleteAuthorizeRouterDat }, )?; match payment_method_data { - payments::PaymentMethodData::Card(ccard) => Self::try_from((item, ccard)), - payments::PaymentMethodData::Wallet(_) - | payments::PaymentMethodData::CardRedirect(_) - | payments::PaymentMethodData::PayLater(_) - | payments::PaymentMethodData::BankRedirect(_) - | payments::PaymentMethodData::BankDebit(_) - | payments::PaymentMethodData::BankTransfer(_) - | payments::PaymentMethodData::Crypto(_) - | payments::PaymentMethodData::MandatePayment - | payments::PaymentMethodData::Reward - | payments::PaymentMethodData::Upi(_) - | payments::PaymentMethodData::Voucher(_) - | payments::PaymentMethodData::GiftCard(_) - | payments::PaymentMethodData::CardToken(_) => { + domain::PaymentMethodData::Card(ccard) => Self::try_from((item, ccard)), + domain::PaymentMethodData::Wallet(_) + | domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("BankOfAmerica"), ) diff --git a/crates/router/src/connector/billwerk/transformers.rs b/crates/router/src/connector/billwerk/transformers.rs index ffcd14bf05f9..4e91a2c9ffbc 100644 --- a/crates/router/src/connector/billwerk/transformers.rs +++ b/crates/router/src/connector/billwerk/transformers.rs @@ -6,7 +6,7 @@ use crate::{ connector::utils::{self, CardData, PaymentsAuthorizeRequestData, RouterData}, consts, core::errors, - types::{self, api, storage::enums}, + types::{self, api, domain, storage::enums}, }; pub struct BillwerkRouterData { @@ -85,7 +85,7 @@ impl TryFrom<&types::TokenizationRouterData> for BillwerkTokenRequest { type Error = error_stack::Report; fn try_from(item: &types::TokenizationRouterData) -> Result { match item.request.payment_method_data.clone() { - api::PaymentMethodData::Card(ccard) => { + domain::PaymentMethodData::Card(ccard) => { let connector_auth = &item.connector_auth_type; let auth_type = BillwerkAuthType::try_from(connector_auth)?; Ok(Self { @@ -99,19 +99,19 @@ impl TryFrom<&types::TokenizationRouterData> for BillwerkTokenRequest { strong_authentication_rule: None, }) } - api_models::payments::PaymentMethodData::Wallet(_) - | api_models::payments::PaymentMethodData::CardRedirect(_) - | api_models::payments::PaymentMethodData::PayLater(_) - | api_models::payments::PaymentMethodData::BankRedirect(_) - | api_models::payments::PaymentMethodData::BankDebit(_) - | api_models::payments::PaymentMethodData::BankTransfer(_) - | api_models::payments::PaymentMethodData::Crypto(_) - | api_models::payments::PaymentMethodData::MandatePayment - | api_models::payments::PaymentMethodData::Reward - | api_models::payments::PaymentMethodData::Upi(_) - | api_models::payments::PaymentMethodData::Voucher(_) - | api_models::payments::PaymentMethodData::GiftCard(_) - | api_models::payments::PaymentMethodData::CardToken(_) => { + domain::payments::PaymentMethodData::Wallet(_) + | domain::payments::PaymentMethodData::CardRedirect(_) + | domain::payments::PaymentMethodData::PayLater(_) + | domain::payments::PaymentMethodData::BankRedirect(_) + | domain::payments::PaymentMethodData::BankDebit(_) + | domain::payments::PaymentMethodData::BankTransfer(_) + | domain::payments::PaymentMethodData::Crypto(_) + | domain::payments::PaymentMethodData::MandatePayment + | domain::payments::PaymentMethodData::Reward + | domain::payments::PaymentMethodData::Upi(_) + | domain::payments::PaymentMethodData::Voucher(_) + | domain::payments::PaymentMethodData::GiftCard(_) + | domain::payments::PaymentMethodData::CardToken(_) => { Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("billwerk"), ) diff --git a/crates/router/src/connector/bluesnap/transformers.rs b/crates/router/src/connector/bluesnap/transformers.rs index e22d27e4b833..518fb3f80094 100644 --- a/crates/router/src/connector/bluesnap/transformers.rs +++ b/crates/router/src/connector/bluesnap/transformers.rs @@ -21,7 +21,7 @@ use crate::{ core::errors, pii::Secret, types::{ - self, api, + self, api, domain, storage::enums, transformers::{ForeignFrom, ForeignTryFrom}, }, @@ -230,23 +230,23 @@ impl TryFrom<&BluesnapRouterData<&types::PaymentsAuthorizeRouterData>> item: &BluesnapRouterData<&types::PaymentsAuthorizeRouterData>, ) -> Result { match item.router_data.request.payment_method_data { - api::PaymentMethodData::Card(ref ccard) => Ok(Self { + domain::PaymentMethodData::Card(ref ccard) => Ok(Self { cc_number: ccard.card_number.clone(), exp_date: ccard.get_expiry_date_as_mmyyyy("/"), }), - api::PaymentMethodData::Wallet(_) - | payments::PaymentMethodData::PayLater(_) - | payments::PaymentMethodData::BankRedirect(_) - | payments::PaymentMethodData::BankDebit(_) - | payments::PaymentMethodData::BankTransfer(_) - | payments::PaymentMethodData::Crypto(_) - | payments::PaymentMethodData::MandatePayment - | payments::PaymentMethodData::Reward - | payments::PaymentMethodData::Upi(_) - | payments::PaymentMethodData::CardRedirect(_) - | payments::PaymentMethodData::Voucher(_) - | payments::PaymentMethodData::GiftCard(_) - | payments::PaymentMethodData::CardToken(_) => { + domain::PaymentMethodData::Wallet(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { Err(errors::ConnectorError::NotImplemented( "Selected payment method via Token flow through bluesnap".to_string(), ) @@ -280,7 +280,7 @@ impl TryFrom<&BluesnapRouterData<&types::PaymentsAuthorizeRouterData>> for Blues .payment_method_data .clone() { - api::PaymentMethodData::Card(ref ccard) => Ok(( + domain::PaymentMethodData::Card(ref ccard) => Ok(( PaymentMethodDetails::CreditCard(Card { card_number: ccard.card_number.clone(), expiration_month: ccard.card_exp_month.clone(), @@ -292,7 +292,7 @@ impl TryFrom<&BluesnapRouterData<&types::PaymentsAuthorizeRouterData>> for Blues item.router_data.request.get_email()?, )?, )), - api::PaymentMethodData::Wallet(wallet_data) => match wallet_data { + domain::PaymentMethodData::Wallet(wallet_data) => match wallet_data { api_models::payments::WalletData::GooglePay(payment_method_data) => { let gpay_object = BluesnapGooglePayObject { payment_method_data: utils::GooglePayWalletData::from(payment_method_data), @@ -399,20 +399,22 @@ impl TryFrom<&BluesnapRouterData<&types::PaymentsAuthorizeRouterData>> for Blues )) } }, - payments::PaymentMethodData::PayLater(_) - | payments::PaymentMethodData::BankRedirect(_) - | payments::PaymentMethodData::BankDebit(_) - | payments::PaymentMethodData::BankTransfer(_) - | payments::PaymentMethodData::Crypto(_) - | payments::PaymentMethodData::MandatePayment - | payments::PaymentMethodData::Reward - | payments::PaymentMethodData::Upi(_) - | payments::PaymentMethodData::CardRedirect(_) - | payments::PaymentMethodData::Voucher(_) - | payments::PaymentMethodData::GiftCard(_) - | api::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented( - utils::get_unimplemented_payment_method_error_message("bluesnap"), - )), + domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { + Err(errors::ConnectorError::NotImplemented( + utils::get_unimplemented_payment_method_error_message("bluesnap"), + )) + } }?; Ok(Self { amount: item.amount.to_owned(), diff --git a/crates/router/src/connector/boku/transformers.rs b/crates/router/src/connector/boku/transformers.rs index 5f36225fd40a..c2b805b5de09 100644 --- a/crates/router/src/connector/boku/transformers.rs +++ b/crates/router/src/connector/boku/transformers.rs @@ -9,7 +9,7 @@ use crate::{ connector::utils::{self, AddressDetailsData, RouterData}, core::errors, services::{self, RedirectForm}, - types::{self, api, storage::enums}, + types::{self, api, domain, storage::enums}, }; #[derive(Debug, Clone, Serialize)] @@ -78,22 +78,20 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for BokuPaymentsRequest { type Error = error_stack::Report; fn try_from(item: &types::PaymentsAuthorizeRouterData) -> Result { match item.request.payment_method_data.clone() { - api_models::payments::PaymentMethodData::Wallet(wallet_data) => { - Self::try_from((item, &wallet_data)) - } - api_models::payments::PaymentMethodData::Card(_) - | api_models::payments::PaymentMethodData::CardRedirect(_) - | api_models::payments::PaymentMethodData::PayLater(_) - | api_models::payments::PaymentMethodData::BankRedirect(_) - | api_models::payments::PaymentMethodData::BankDebit(_) - | api_models::payments::PaymentMethodData::BankTransfer(_) - | api_models::payments::PaymentMethodData::Crypto(_) - | api_models::payments::PaymentMethodData::MandatePayment - | api_models::payments::PaymentMethodData::Reward - | api_models::payments::PaymentMethodData::Upi(_) - | api_models::payments::PaymentMethodData::Voucher(_) - | api_models::payments::PaymentMethodData::GiftCard(_) - | api_models::payments::PaymentMethodData::CardToken(_) => { + domain::PaymentMethodData::Wallet(wallet_data) => Self::try_from((item, &wallet_data)), + domain::PaymentMethodData::Card(_) + | domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("boku"), ))? diff --git a/crates/router/src/connector/braintree/braintree_graphql_transformers.rs b/crates/router/src/connector/braintree/braintree_graphql_transformers.rs index 1f933392f2b3..0399a5d4285a 100644 --- a/crates/router/src/connector/braintree/braintree_graphql_transformers.rs +++ b/crates/router/src/connector/braintree/braintree_graphql_transformers.rs @@ -9,7 +9,7 @@ use crate::{ consts, core::errors, services, - types::{self, api, storage::enums}, + types::{self, api, domain, storage::enums}, unimplemented_payment_method, }; @@ -119,7 +119,7 @@ impl TryFrom<&BraintreeRouterData<&types::PaymentsAuthorizeRouterData>> )?; match item.router_data.request.payment_method_data.clone() { - api::PaymentMethodData::Card(_) => { + domain::PaymentMethodData::Card(_) => { if item.router_data.is_three_ds() { Ok(Self::CardThreeDs(BraintreeClientTokenRequest::try_from( metadata, @@ -128,19 +128,19 @@ impl TryFrom<&BraintreeRouterData<&types::PaymentsAuthorizeRouterData>> Ok(Self::Card(CardPaymentRequest::try_from((item, metadata))?)) } } - api_models::payments::PaymentMethodData::CardRedirect(_) - | api_models::payments::PaymentMethodData::Wallet(_) - | api_models::payments::PaymentMethodData::PayLater(_) - | api_models::payments::PaymentMethodData::BankRedirect(_) - | api_models::payments::PaymentMethodData::BankDebit(_) - | api_models::payments::PaymentMethodData::BankTransfer(_) - | api_models::payments::PaymentMethodData::Crypto(_) - | api_models::payments::PaymentMethodData::MandatePayment - | api_models::payments::PaymentMethodData::Reward - | api_models::payments::PaymentMethodData::Upi(_) - | api_models::payments::PaymentMethodData::Voucher(_) - | api_models::payments::PaymentMethodData::GiftCard(_) - | api_models::payments::PaymentMethodData::CardToken(_) => { + domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::Wallet(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("braintree"), ) @@ -860,7 +860,7 @@ impl TryFrom<&types::TokenizationRouterData> for BraintreeTokenRequest { type Error = error_stack::Report; fn try_from(item: &types::TokenizationRouterData) -> Result { match item.request.payment_method_data.clone() { - api::PaymentMethodData::Card(card_data) => { + domain::PaymentMethodData::Card(card_data) => { let query = TOKENIZE_CREDIT_CARD.to_string(); let input = InputData { credit_card: CreditCardData { @@ -878,22 +878,24 @@ impl TryFrom<&types::TokenizationRouterData> for BraintreeTokenRequest { variables: VariableInput { input }, }) } - api_models::payments::PaymentMethodData::CardRedirect(_) - | api_models::payments::PaymentMethodData::Wallet(_) - | api_models::payments::PaymentMethodData::PayLater(_) - | api_models::payments::PaymentMethodData::BankRedirect(_) - | api_models::payments::PaymentMethodData::BankDebit(_) - | api_models::payments::PaymentMethodData::BankTransfer(_) - | api_models::payments::PaymentMethodData::Crypto(_) - | api_models::payments::PaymentMethodData::MandatePayment - | api_models::payments::PaymentMethodData::Reward - | api_models::payments::PaymentMethodData::Upi(_) - | api_models::payments::PaymentMethodData::Voucher(_) - | api_models::payments::PaymentMethodData::GiftCard(_) - | api::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented( - utils::get_unimplemented_payment_method_error_message("braintree"), - ) - .into()), + domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::Wallet(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { + Err(errors::ConnectorError::NotImplemented( + utils::get_unimplemented_payment_method_error_message("braintree"), + ) + .into()) + } } } } @@ -1406,7 +1408,7 @@ impl TryFrom<&BraintreeRouterData<&types::PaymentsCompleteAuthorizeRouterData>> fn get_braintree_redirect_form( client_token_data: ClientTokenResponse, payment_method_token: types::PaymentMethodToken, - card_details: api_models::payments::PaymentMethodData, + card_details: domain::PaymentMethodData, ) -> Result> { Ok(services::RedirectForm::Braintree { client_token: client_token_data @@ -1423,24 +1425,24 @@ fn get_braintree_redirect_form( ))?, }, bin: match card_details { - api_models::payments::PaymentMethodData::Card(card_details) => { + domain::PaymentMethodData::Card(card_details) => { card_details.card_number.get_card_isin() } - api_models::payments::PaymentMethodData::CardRedirect(_) - | api_models::payments::PaymentMethodData::Wallet(_) - | api_models::payments::PaymentMethodData::PayLater(_) - | api_models::payments::PaymentMethodData::BankRedirect(_) - | api_models::payments::PaymentMethodData::BankDebit(_) - | api_models::payments::PaymentMethodData::BankTransfer(_) - | api_models::payments::PaymentMethodData::Crypto(_) - | api_models::payments::PaymentMethodData::MandatePayment - | api_models::payments::PaymentMethodData::Reward - | api_models::payments::PaymentMethodData::Upi(_) - | api_models::payments::PaymentMethodData::Voucher(_) - | api_models::payments::PaymentMethodData::GiftCard(_) - | api::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented( - "given payment method".to_owned(), - ))?, + domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::Wallet(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => Err( + errors::ConnectorError::NotImplemented("given payment method".to_owned()), + )?, }, }) } diff --git a/crates/router/src/connector/braintree/transformers.rs b/crates/router/src/connector/braintree/transformers.rs index 4e8a15dfea2d..d9000ade25e5 100644 --- a/crates/router/src/connector/braintree/transformers.rs +++ b/crates/router/src/connector/braintree/transformers.rs @@ -7,7 +7,7 @@ use crate::{ connector::utils::{self}, consts, core::errors, - types::{self, api, storage::enums}, + types::{self, api, domain, storage::enums}, }; #[derive(Default, Debug, Serialize, Eq, PartialEq)] @@ -115,7 +115,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for BraintreePaymentsRequest { let kind = "sale".to_string(); let payment_method_data_type = match item.request.payment_method_data.clone() { - api::PaymentMethodData::Card(ccard) => Ok(PaymentMethodType::CreditCard(Card { + domain::PaymentMethodData::Card(ccard) => Ok(PaymentMethodType::CreditCard(Card { credit_card: CardDetails { number: ccard.card_number, expiration_month: ccard.card_exp_month, @@ -123,7 +123,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for BraintreePaymentsRequest { cvv: ccard.card_cvc, }, })), - api::PaymentMethodData::Wallet(ref wallet_data) => { + domain::PaymentMethodData::Wallet(ref wallet_data) => { Ok(PaymentMethodType::PaymentMethodNonce(Nonce { payment_method_nonce: match wallet_data { api_models::payments::WalletData::PaypalSdk(wallet_data) => { @@ -162,20 +162,22 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for BraintreePaymentsRequest { .into(), })) } - api::PaymentMethodData::PayLater(_) - | api::PaymentMethodData::BankRedirect(_) - | api::PaymentMethodData::BankDebit(_) - | api::PaymentMethodData::BankTransfer(_) - | api::PaymentMethodData::Crypto(_) - | api::PaymentMethodData::CardRedirect(_) - | api::PaymentMethodData::MandatePayment - | api::PaymentMethodData::Reward - | api::PaymentMethodData::Upi(_) - | api::PaymentMethodData::Voucher(_) - | api::PaymentMethodData::GiftCard(_) - | api::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented( - utils::get_unimplemented_payment_method_error_message("braintree"), - )), + domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { + Err(errors::ConnectorError::NotImplemented( + utils::get_unimplemented_payment_method_error_message("braintree"), + )) + } }?; let braintree_transaction_body = TransactionBody { amount, diff --git a/crates/router/src/connector/checkout/transformers.rs b/crates/router/src/connector/checkout/transformers.rs index 1a031eaa7ca4..899ea345a3d7 100644 --- a/crates/router/src/connector/checkout/transformers.rs +++ b/crates/router/src/connector/checkout/transformers.rs @@ -13,7 +13,7 @@ use crate::{ consts, core::errors, services, - types::{self, api, storage::enums, transformers::ForeignFrom}, + types::{self, api, domain, storage::enums, transformers::ForeignFrom}, unimplemented_payment_method, }; @@ -90,7 +90,7 @@ impl TryFrom<&types::TokenizationRouterData> for TokenRequest { type Error = error_stack::Report; fn try_from(item: &types::TokenizationRouterData) -> Result { match item.request.payment_method_data.clone() { - api::PaymentMethodData::Wallet(wallet_data) => match wallet_data.clone() { + domain::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("Google Pay".to_string())?; @@ -131,19 +131,19 @@ impl TryFrom<&types::TokenizationRouterData> for TokenRequest { .into()) } }, - api_models::payments::PaymentMethodData::Card(_) - | api_models::payments::PaymentMethodData::PayLater(_) - | api_models::payments::PaymentMethodData::BankRedirect(_) - | api_models::payments::PaymentMethodData::BankDebit(_) - | api_models::payments::PaymentMethodData::BankTransfer(_) - | api_models::payments::PaymentMethodData::Crypto(_) - | api_models::payments::PaymentMethodData::MandatePayment - | api_models::payments::PaymentMethodData::Reward - | api_models::payments::PaymentMethodData::Upi(_) - | api_models::payments::PaymentMethodData::Voucher(_) - | api_models::payments::PaymentMethodData::CardRedirect(_) - | api_models::payments::PaymentMethodData::GiftCard(_) - | api_models::payments::PaymentMethodData::CardToken(_) => { + domain::PaymentMethodData::Card(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("checkout"), ) @@ -292,7 +292,7 @@ impl TryFrom<&CheckoutRouterData<&types::PaymentsAuthorizeRouterData>> for Payme item: &CheckoutRouterData<&types::PaymentsAuthorizeRouterData>, ) -> Result { let source_var = match item.router_data.request.payment_method_data.clone() { - api::PaymentMethodData::Card(ccard) => { + domain::PaymentMethodData::Card(ccard) => { let a = PaymentSource::Card(CardSource { source_type: CheckoutSourceTypes::Card, number: ccard.card_number.clone(), @@ -302,7 +302,7 @@ impl TryFrom<&CheckoutRouterData<&types::PaymentsAuthorizeRouterData>> for Payme }); Ok(a) } - api::PaymentMethodData::Wallet(wallet_data) => match wallet_data { + domain::PaymentMethodData::Wallet(wallet_data) => match wallet_data { api_models::payments::WalletData::GooglePay(_) => { Ok(PaymentSource::Wallets(WalletSource { source_type: CheckoutSourceTypes::Token, @@ -374,20 +374,22 @@ impl TryFrom<&CheckoutRouterData<&types::PaymentsAuthorizeRouterData>> for Payme } }, - api_models::payments::PaymentMethodData::PayLater(_) - | api_models::payments::PaymentMethodData::BankRedirect(_) - | api_models::payments::PaymentMethodData::BankDebit(_) - | api_models::payments::PaymentMethodData::BankTransfer(_) - | api_models::payments::PaymentMethodData::Crypto(_) - | api_models::payments::PaymentMethodData::MandatePayment - | api_models::payments::PaymentMethodData::Reward - | api_models::payments::PaymentMethodData::Upi(_) - | api_models::payments::PaymentMethodData::Voucher(_) - | api_models::payments::PaymentMethodData::CardRedirect(_) - | api_models::payments::PaymentMethodData::GiftCard(_) - | api::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented( - utils::get_unimplemented_payment_method_error_message("checkout"), - )), + domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { + Err(errors::ConnectorError::NotImplemented( + utils::get_unimplemented_payment_method_error_message("checkout"), + )) + } }?; let authentication_data = item.router_data.request.authentication_data.as_ref(); diff --git a/crates/router/src/connector/cryptopay/transformers.rs b/crates/router/src/connector/cryptopay/transformers.rs index 707cfd8f06b6..aaf21af05825 100644 --- a/crates/router/src/connector/cryptopay/transformers.rs +++ b/crates/router/src/connector/cryptopay/transformers.rs @@ -8,7 +8,7 @@ use crate::{ consts, core::errors, services, - types::{self, api, storage::enums}, + types::{self, domain, storage::enums}, }; #[derive(Debug, Serialize)] @@ -62,7 +62,7 @@ impl TryFrom<&CryptopayRouterData<&types::PaymentsAuthorizeRouterData>> item: &CryptopayRouterData<&types::PaymentsAuthorizeRouterData>, ) -> Result { let cryptopay_request = match item.router_data.request.payment_method_data { - api::PaymentMethodData::Crypto(ref cryptodata) => { + domain::PaymentMethodData::Crypto(ref cryptodata) => { let pay_currency = cryptodata.get_pay_currency()?; Ok(Self { price_amount: item.amount.to_owned(), @@ -74,19 +74,19 @@ impl TryFrom<&CryptopayRouterData<&types::PaymentsAuthorizeRouterData>> custom_id: item.router_data.connector_request_reference_id.clone(), }) } - api_models::payments::PaymentMethodData::Card(_) - | api_models::payments::PaymentMethodData::CardRedirect(_) - | api_models::payments::PaymentMethodData::Wallet(_) - | api_models::payments::PaymentMethodData::PayLater(_) - | api_models::payments::PaymentMethodData::BankRedirect(_) - | api_models::payments::PaymentMethodData::BankDebit(_) - | api_models::payments::PaymentMethodData::BankTransfer(_) - | api_models::payments::PaymentMethodData::MandatePayment {} - | api_models::payments::PaymentMethodData::Reward {} - | api_models::payments::PaymentMethodData::Upi(_) - | api_models::payments::PaymentMethodData::Voucher(_) - | api_models::payments::PaymentMethodData::GiftCard(_) - | api_models::payments::PaymentMethodData::CardToken(_) => { + domain::PaymentMethodData::Card(_) + | domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::Wallet(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::MandatePayment {} + | domain::PaymentMethodData::Reward {} + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("CryptoPay"), )) diff --git a/crates/router/src/connector/cybersource/transformers.rs b/crates/router/src/connector/cybersource/transformers.rs index d58f51e1d789..2dc832841cfa 100644 --- a/crates/router/src/connector/cybersource/transformers.rs +++ b/crates/router/src/connector/cybersource/transformers.rs @@ -19,6 +19,7 @@ use crate::{ types::{ self, api::{self, enums as api_enums}, + domain, storage::enums, transformers::ForeignFrom, ApplePayPredecryptData, @@ -98,7 +99,7 @@ impl TryFrom<&types::SetupMandateRouterData> for CybersourceZeroMandateRequest { }; let (payment_information, solution) = match item.request.payment_method_data.clone() { - api::PaymentMethodData::Card(ccard) => { + domain::PaymentMethodData::Card(ccard) => { let card_issuer = ccard.get_card_issuer(); let card_type = match card_issuer { Ok(issuer) => Some(String::from(issuer)), @@ -118,7 +119,7 @@ impl TryFrom<&types::SetupMandateRouterData> for CybersourceZeroMandateRequest { ) } - api::PaymentMethodData::Wallet(wallet_data) => match wallet_data { + domain::PaymentMethodData::Wallet(wallet_data) => match wallet_data { payments::WalletData::ApplePay(apple_pay_data) => { match item.payment_method_token.clone() { Some(payment_method_token) => match payment_method_token { @@ -195,18 +196,18 @@ impl TryFrom<&types::SetupMandateRouterData> for CybersourceZeroMandateRequest { utils::get_unimplemented_payment_method_error_message("Cybersource"), ))?, }, - payments::PaymentMethodData::CardRedirect(_) - | payments::PaymentMethodData::PayLater(_) - | payments::PaymentMethodData::BankRedirect(_) - | payments::PaymentMethodData::BankDebit(_) - | payments::PaymentMethodData::BankTransfer(_) - | payments::PaymentMethodData::Crypto(_) - | payments::PaymentMethodData::MandatePayment - | payments::PaymentMethodData::Reward - | payments::PaymentMethodData::Upi(_) - | payments::PaymentMethodData::Voucher(_) - | payments::PaymentMethodData::GiftCard(_) - | payments::PaymentMethodData::CardToken(_) => { + domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("Cybersource"), ))? @@ -727,14 +728,14 @@ impl ForeignFrom for Vec { impl TryFrom<( &CybersourceRouterData<&types::PaymentsAuthorizeRouterData>, - payments::Card, + domain::Card, )> for CybersourcePaymentsRequest { type Error = error_stack::Report; fn try_from( (item, ccard): ( &CybersourceRouterData<&types::PaymentsAuthorizeRouterData>, - payments::Card, + domain::Card, ), ) -> Result { let email = item.router_data.request.get_email()?; @@ -778,14 +779,14 @@ impl impl TryFrom<( &CybersourceRouterData<&types::PaymentsCompleteAuthorizeRouterData>, - payments::Card, + domain::Card, )> for CybersourcePaymentsRequest { type Error = error_stack::Report; fn try_from( (item, ccard): ( &CybersourceRouterData<&types::PaymentsCompleteAuthorizeRouterData>, - payments::Card, + domain::Card, ), ) -> Result { let email = item.router_data.request.get_email()?; @@ -972,8 +973,8 @@ impl TryFrom<&CybersourceRouterData<&types::PaymentsAuthorizeRouterData>> Some(connector_mandate_id) => Self::try_from((item, connector_mandate_id)), None => { match item.router_data.request.payment_method_data.clone() { - payments::PaymentMethodData::Card(ccard) => Self::try_from((item, ccard)), - payments::PaymentMethodData::Wallet(wallet_data) => match wallet_data { + domain::PaymentMethodData::Card(ccard) => Self::try_from((item, ccard)), + domain::PaymentMethodData::Wallet(wallet_data) => match wallet_data { payments::WalletData::ApplePay(apple_pay_data) => { match item.router_data.payment_method_token.clone() { Some(payment_method_token) => match payment_method_token { @@ -1084,7 +1085,7 @@ impl TryFrom<&CybersourceRouterData<&types::PaymentsAuthorizeRouterData>> }, // If connector_mandate_id is present MandatePayment will be the PMD, the case will be handled in the first `if` clause. // This is a fallback implementation in the event of catastrophe. - payments::PaymentMethodData::MandatePayment => { + domain::PaymentMethodData::MandatePayment => { let connector_mandate_id = item.router_data.request.connector_mandate_id().ok_or( errors::ConnectorError::MissingRequiredField { @@ -1093,17 +1094,17 @@ impl TryFrom<&CybersourceRouterData<&types::PaymentsAuthorizeRouterData>> )?; Self::try_from((item, connector_mandate_id)) } - payments::PaymentMethodData::CardRedirect(_) - | payments::PaymentMethodData::PayLater(_) - | payments::PaymentMethodData::BankRedirect(_) - | payments::PaymentMethodData::BankDebit(_) - | payments::PaymentMethodData::BankTransfer(_) - | payments::PaymentMethodData::Crypto(_) - | payments::PaymentMethodData::Reward - | payments::PaymentMethodData::Upi(_) - | payments::PaymentMethodData::Voucher(_) - | payments::PaymentMethodData::GiftCard(_) - | payments::PaymentMethodData::CardToken(_) => { + domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("Cybersource"), ) @@ -1168,7 +1169,7 @@ impl TryFrom<&CybersourceRouterData<&types::PaymentsAuthorizeRouterData>> item: &CybersourceRouterData<&types::PaymentsAuthorizeRouterData>, ) -> Result { match item.router_data.request.payment_method_data.clone() { - payments::PaymentMethodData::Card(ccard) => { + domain::PaymentMethodData::Card(ccard) => { let card_issuer = ccard.get_card_issuer(); let card_type = match card_issuer { Ok(issuer) => Some(String::from(issuer)), @@ -1189,19 +1190,19 @@ impl TryFrom<&CybersourceRouterData<&types::PaymentsAuthorizeRouterData>> client_reference_information, }) } - payments::PaymentMethodData::Wallet(_) - | payments::PaymentMethodData::CardRedirect(_) - | payments::PaymentMethodData::PayLater(_) - | payments::PaymentMethodData::BankRedirect(_) - | payments::PaymentMethodData::BankDebit(_) - | payments::PaymentMethodData::BankTransfer(_) - | payments::PaymentMethodData::Crypto(_) - | payments::PaymentMethodData::MandatePayment - | payments::PaymentMethodData::Reward - | payments::PaymentMethodData::Upi(_) - | payments::PaymentMethodData::Voucher(_) - | payments::PaymentMethodData::GiftCard(_) - | payments::PaymentMethodData::CardToken(_) => { + domain::PaymentMethodData::Wallet(_) + | domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("Cybersource"), ) @@ -1853,7 +1854,7 @@ impl TryFrom<&CybersourceRouterData<&types::PaymentsPreProcessingRouterData>> }, )?; let payment_information = match payment_method_data { - payments::PaymentMethodData::Card(ccard) => { + domain::PaymentMethodData::Card(ccard) => { let card_issuer = ccard.get_card_issuer(); let card_type = match card_issuer { Ok(issuer) => Some(String::from(issuer)), @@ -1869,19 +1870,19 @@ impl TryFrom<&CybersourceRouterData<&types::PaymentsPreProcessingRouterData>> }, })) } - payments::PaymentMethodData::Wallet(_) - | payments::PaymentMethodData::CardRedirect(_) - | payments::PaymentMethodData::PayLater(_) - | payments::PaymentMethodData::BankRedirect(_) - | payments::PaymentMethodData::BankDebit(_) - | payments::PaymentMethodData::BankTransfer(_) - | payments::PaymentMethodData::Crypto(_) - | payments::PaymentMethodData::MandatePayment - | payments::PaymentMethodData::Reward - | payments::PaymentMethodData::Upi(_) - | payments::PaymentMethodData::Voucher(_) - | payments::PaymentMethodData::GiftCard(_) - | payments::PaymentMethodData::CardToken(_) => { + domain::PaymentMethodData::Wallet(_) + | domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("Cybersource"), )) @@ -1969,20 +1970,20 @@ impl TryFrom<&CybersourceRouterData<&types::PaymentsCompleteAuthorizeRouterData> }, )?; match payment_method_data { - payments::PaymentMethodData::Card(ccard) => Self::try_from((item, ccard)), - payments::PaymentMethodData::Wallet(_) - | payments::PaymentMethodData::CardRedirect(_) - | payments::PaymentMethodData::PayLater(_) - | payments::PaymentMethodData::BankRedirect(_) - | payments::PaymentMethodData::BankDebit(_) - | payments::PaymentMethodData::BankTransfer(_) - | payments::PaymentMethodData::Crypto(_) - | payments::PaymentMethodData::MandatePayment - | payments::PaymentMethodData::Reward - | payments::PaymentMethodData::Upi(_) - | payments::PaymentMethodData::Voucher(_) - | payments::PaymentMethodData::GiftCard(_) - | payments::PaymentMethodData::CardToken(_) => { + domain::PaymentMethodData::Card(ccard) => Self::try_from((item, ccard)), + domain::PaymentMethodData::Wallet(_) + | domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("Cybersource"), ) diff --git a/crates/router/src/connector/dlocal/transformers.rs b/crates/router/src/connector/dlocal/transformers.rs index c1b8731ee893..20997f3a24d6 100644 --- a/crates/router/src/connector/dlocal/transformers.rs +++ b/crates/router/src/connector/dlocal/transformers.rs @@ -9,7 +9,7 @@ use crate::{ connector::utils::{AddressDetailsData, PaymentsAuthorizeRequestData, RouterData}, core::errors, services, - types::{self, api, storage::enums}, + types::{self, api, domain, storage::enums}, }; #[derive(Debug, Default, Eq, PartialEq, Serialize)] @@ -107,7 +107,7 @@ impl TryFrom<&DlocalRouterData<&types::PaymentsAuthorizeRouterData>> for DlocalP let country = address.get_country()?; let name = get_payer_name(address); match item.router_data.request.payment_method_data { - api::PaymentMethodData::Card(ref ccard) => { + domain::PaymentMethodData::Card(ref ccard) => { let should_capture = matches!( item.router_data.request.capture_method, Some(enums::CaptureMethod::Automatic) @@ -160,21 +160,25 @@ impl TryFrom<&DlocalRouterData<&types::PaymentsAuthorizeRouterData>> for DlocalP }; Ok(payment_request) } - api::PaymentMethodData::CardRedirect(_) - | api::PaymentMethodData::Wallet(_) - | api::PaymentMethodData::PayLater(_) - | api::PaymentMethodData::BankRedirect(_) - | api::PaymentMethodData::BankDebit(_) - | api::PaymentMethodData::BankTransfer(_) - | api::PaymentMethodData::Crypto(_) - | api::PaymentMethodData::MandatePayment - | api::PaymentMethodData::Reward - | api::PaymentMethodData::Upi(_) - | api::PaymentMethodData::Voucher(_) - | api::PaymentMethodData::GiftCard(_) - | api::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented( - crate::connector::utils::get_unimplemented_payment_method_error_message("Dlocal"), - ))?, + domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::Wallet(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { + Err(errors::ConnectorError::NotImplemented( + crate::connector::utils::get_unimplemented_payment_method_error_message( + "Dlocal", + ), + ))? + } } } } diff --git a/crates/router/src/connector/dummyconnector/transformers.rs b/crates/router/src/connector/dummyconnector/transformers.rs index 5c20d353583e..0d4ff3b8508a 100644 --- a/crates/router/src/connector/dummyconnector/transformers.rs +++ b/crates/router/src/connector/dummyconnector/transformers.rs @@ -6,7 +6,7 @@ use url::Url; use crate::{ core::errors, services, - types::{self, api, storage::enums}, + types::{self, api, domain, storage::enums}, }; #[derive(Debug, Serialize, strum::Display, Eq, PartialEq)] @@ -83,9 +83,9 @@ pub struct DummyConnectorCard { cvc: Secret, } -impl TryFrom for DummyConnectorCard { +impl TryFrom for DummyConnectorCard { type Error = error_stack::Report; - fn try_from(value: api_models::payments::Card) -> Result { + fn try_from(value: domain::Card) -> Result { Ok(Self { name: value .card_holder_name @@ -153,13 +153,13 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> .request .payment_method_data { - api::PaymentMethodData::Card(ref req_card) => { + domain::PaymentMethodData::Card(ref req_card) => { Ok(PaymentMethodData::Card(req_card.clone().try_into()?)) } - api::PaymentMethodData::Wallet(ref wallet_data) => { + domain::PaymentMethodData::Wallet(ref wallet_data) => { Ok(PaymentMethodData::Wallet(wallet_data.clone().try_into()?)) } - api::PaymentMethodData::PayLater(ref pay_later_data) => Ok( + domain::PaymentMethodData::PayLater(ref pay_later_data) => Ok( PaymentMethodData::PayLater(pay_later_data.clone().try_into()?), ), _ => Err(errors::ConnectorError::NotImplemented("Payment methods".to_string()).into()), diff --git a/crates/router/src/connector/fiserv/transformers.rs b/crates/router/src/connector/fiserv/transformers.rs index dac2a3b2fbac..fcb808c67005 100644 --- a/crates/router/src/connector/fiserv/transformers.rs +++ b/crates/router/src/connector/fiserv/transformers.rs @@ -9,7 +9,7 @@ use crate::{ }, core::errors, pii::Secret, - types::{self, api, storage::enums}, + types::{self, api, domain, storage::enums}, }; #[derive(Debug, Serialize)] @@ -173,7 +173,7 @@ impl TryFrom<&FiservRouterData<&types::PaymentsAuthorizeRouterData>> for FiservP pos_condition_code: TransactionInteractionPosConditionCode::CardNotPresentEcom, }; let source = match item.router_data.request.payment_method_data.clone() { - api::PaymentMethodData::Card(ref ccard) => { + domain::PaymentMethodData::Card(ref ccard) => { let card = CardData { card_data: ccard.card_number.clone(), expiration_month: ccard.card_exp_month.clone(), @@ -182,19 +182,19 @@ impl TryFrom<&FiservRouterData<&types::PaymentsAuthorizeRouterData>> for FiservP }; Source::PaymentCard { card } } - api::PaymentMethodData::Wallet(_) - | api::PaymentMethodData::PayLater(_) - | api::PaymentMethodData::BankRedirect(_) - | api::PaymentMethodData::BankDebit(_) - | api::PaymentMethodData::CardRedirect(_) - | api::PaymentMethodData::BankTransfer(_) - | api::PaymentMethodData::Crypto(_) - | api::PaymentMethodData::MandatePayment - | api::PaymentMethodData::Reward - | api::PaymentMethodData::Upi(_) - | api::PaymentMethodData::Voucher(_) - | api::PaymentMethodData::GiftCard(_) - | api::PaymentMethodData::CardToken(_) => { + domain::PaymentMethodData::Wallet(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("fiserv"), )) diff --git a/crates/router/src/connector/forte/transformers.rs b/crates/router/src/connector/forte/transformers.rs index 00efbefe2871..35f003233d4e 100644 --- a/crates/router/src/connector/forte/transformers.rs +++ b/crates/router/src/connector/forte/transformers.rs @@ -7,7 +7,7 @@ use crate::{ self, AddressDetailsData, CardData, PaymentsAuthorizeRequestData, RouterData, }, core::errors, - types::{self, api, storage::enums, transformers::ForeignFrom}, + types::{self, api, domain, storage::enums, transformers::ForeignFrom}, }; #[derive(Debug, Serialize)] @@ -71,7 +71,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for FortePaymentsRequest { ))? } match item.request.payment_method_data { - api_models::payments::PaymentMethodData::Card(ref ccard) => { + domain::PaymentMethodData::Card(ref ccard) => { let action = match item.request.is_auto_capture()? { true => ForteAction::Sale, false => ForteAction::Authorize, @@ -102,19 +102,19 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for FortePaymentsRequest { card, }) } - api_models::payments::PaymentMethodData::CardRedirect(_) - | api_models::payments::PaymentMethodData::Wallet(_) - | api_models::payments::PaymentMethodData::PayLater(_) - | api_models::payments::PaymentMethodData::BankRedirect(_) - | api_models::payments::PaymentMethodData::BankDebit(_) - | api_models::payments::PaymentMethodData::BankTransfer(_) - | api_models::payments::PaymentMethodData::Crypto(_) - | api_models::payments::PaymentMethodData::MandatePayment {} - | api_models::payments::PaymentMethodData::Reward {} - | api_models::payments::PaymentMethodData::Upi(_) - | api_models::payments::PaymentMethodData::Voucher(_) - | api_models::payments::PaymentMethodData::GiftCard(_) - | api_models::payments::PaymentMethodData::CardToken(_) => { + domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::Wallet(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment {} + | domain::PaymentMethodData::Reward {} + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("Forte"), ))? diff --git a/crates/router/src/connector/globalpay/transformers.rs b/crates/router/src/connector/globalpay/transformers.rs index ae6f8d3966a8..bc39a3222065 100644 --- a/crates/router/src/connector/globalpay/transformers.rs +++ b/crates/router/src/connector/globalpay/transformers.rs @@ -17,7 +17,7 @@ use crate::{ consts, core::errors, services::{self, RedirectForm}, - types::{self, api, storage::enums, ErrorResponse}, + types::{self, api, domain, storage::enums, ErrorResponse}, }; type Error = error_stack::Report; @@ -380,7 +380,7 @@ fn get_payment_method_data( brand_reference: Option, ) -> Result { match &item.request.payment_method_data { - api::PaymentMethodData::Card(ccard) => Ok(PaymentMethodData::Card(requests::Card { + domain::PaymentMethodData::Card(ccard) => Ok(PaymentMethodData::Card(requests::Card { number: ccard.card_number.clone(), expiry_month: ccard.card_exp_month.clone(), expiry_year: ccard.get_card_expiry_year_2_digit()?, @@ -396,8 +396,8 @@ fn get_payment_method_data( tag: None, track: None, })), - api::PaymentMethodData::Wallet(wallet_data) => get_wallet_data(wallet_data), - api::PaymentMethodData::BankRedirect(bank_redirect) => { + domain::PaymentMethodData::Wallet(wallet_data) => get_wallet_data(wallet_data), + domain::PaymentMethodData::BankRedirect(bank_redirect) => { PaymentMethodData::try_from(bank_redirect) } _ => Err(errors::ConnectorError::NotImplemented( @@ -408,7 +408,7 @@ fn get_payment_method_data( fn get_return_url(item: &types::PaymentsAuthorizeRouterData) -> Option { match item.request.payment_method_data.clone() { - api::PaymentMethodData::Wallet(api_models::payments::WalletData::PaypalRedirect(_)) => { + domain::PaymentMethodData::Wallet(api_models::payments::WalletData::PaypalRedirect(_)) => { item.request.complete_authorize_url.clone() } _ => item.request.router_return_url.clone(), diff --git a/crates/router/src/connector/globepay/transformers.rs b/crates/router/src/connector/globepay/transformers.rs index c988bff52ea4..bdb3b6ef5c51 100644 --- a/crates/router/src/connector/globepay/transformers.rs +++ b/crates/router/src/connector/globepay/transformers.rs @@ -7,7 +7,7 @@ use crate::{ connector::utils::{self, RouterData}, consts, core::errors, - types::{self, api, storage::enums}, + types::{self, api, domain, storage::enums}, }; type Error = error_stack::Report; @@ -29,7 +29,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for GlobepayPaymentsRequest { type Error = Error; fn try_from(item: &types::PaymentsAuthorizeRouterData) -> Result { let channel: GlobepayChannel = match &item.request.payment_method_data { - api::PaymentMethodData::Wallet(ref wallet_data) => match wallet_data { + domain::PaymentMethodData::Wallet(ref wallet_data) => match wallet_data { api::WalletData::AliPayQr(_) => GlobepayChannel::Alipay, api::WalletData::WeChatPayQr(_) => GlobepayChannel::Wechat, api::WalletData::AliPayRedirect(_) @@ -59,21 +59,23 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for GlobepayPaymentsRequest { utils::get_unimplemented_payment_method_error_message("globepay"), ))?, }, - api::PaymentMethodData::Card(_) - | api::PaymentMethodData::CardRedirect(_) - | api::PaymentMethodData::PayLater(_) - | api::PaymentMethodData::BankRedirect(_) - | api::PaymentMethodData::BankDebit(_) - | api::PaymentMethodData::BankTransfer(_) - | api::PaymentMethodData::Crypto(_) - | api::PaymentMethodData::MandatePayment - | api::PaymentMethodData::Reward - | api::PaymentMethodData::Upi(_) - | api::PaymentMethodData::Voucher(_) - | api::PaymentMethodData::GiftCard(_) - | api::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented( - utils::get_unimplemented_payment_method_error_message("globepay"), - ))?, + domain::PaymentMethodData::Card(_) + | domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { + Err(errors::ConnectorError::NotImplemented( + utils::get_unimplemented_payment_method_error_message("globepay"), + ))? + } }; let description = item.get_description()?; Ok(Self { diff --git a/crates/router/src/connector/gocardless/transformers.rs b/crates/router/src/connector/gocardless/transformers.rs index 21fc44fe84fe..b8c9f9feee74 100644 --- a/crates/router/src/connector/gocardless/transformers.rs +++ b/crates/router/src/connector/gocardless/transformers.rs @@ -14,7 +14,8 @@ use crate::{ }, core::errors, types::{ - self, api, storage::enums, transformers::ForeignTryFrom, MandateReference, ResponseId, + self, api, domain, storage::enums, transformers::ForeignTryFrom, MandateReference, + ResponseId, }, }; @@ -79,7 +80,7 @@ impl TryFrom<&types::ConnectorCustomerRouterData> for GocardlessCustomerRequest fn try_from(item: &types::ConnectorCustomerRouterData) -> Result { let email = item.request.get_email()?; let billing_details = match &item.request.payment_method_data { - api_models::payments::PaymentMethodData::BankDebit(bank_debit_data) => { + domain::PaymentMethodData::BankDebit(bank_debit_data) => { match bank_debit_data.clone() { BankDebitData::AchBankDebit { billing_details, .. @@ -97,19 +98,19 @@ impl TryFrom<&types::ConnectorCustomerRouterData> for GocardlessCustomerRequest } } } - api_models::payments::PaymentMethodData::Card(_) - | api_models::payments::PaymentMethodData::CardRedirect(_) - | api_models::payments::PaymentMethodData::Wallet(_) - | api_models::payments::PaymentMethodData::PayLater(_) - | api_models::payments::PaymentMethodData::BankRedirect(_) - | api_models::payments::PaymentMethodData::BankTransfer(_) - | api_models::payments::PaymentMethodData::Crypto(_) - | api_models::payments::PaymentMethodData::MandatePayment - | api_models::payments::PaymentMethodData::Reward - | api_models::payments::PaymentMethodData::Upi(_) - | api_models::payments::PaymentMethodData::Voucher(_) - | api_models::payments::PaymentMethodData::GiftCard(_) - | api_models::payments::PaymentMethodData::CardToken(_) => { + domain::PaymentMethodData::Card(_) + | domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::Wallet(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("Gocardless"), )) @@ -284,25 +285,27 @@ impl TryFrom<&types::TokenizationRouterData> for CustomerBankAccount { type Error = error_stack::Report; fn try_from(item: &types::TokenizationRouterData) -> Result { match &item.request.payment_method_data { - api_models::payments::PaymentMethodData::BankDebit(bank_debit_data) => { + domain::PaymentMethodData::BankDebit(bank_debit_data) => { Self::try_from(bank_debit_data) } - api_models::payments::PaymentMethodData::Card(_) - | api_models::payments::PaymentMethodData::CardRedirect(_) - | api_models::payments::PaymentMethodData::Wallet(_) - | api_models::payments::PaymentMethodData::PayLater(_) - | api_models::payments::PaymentMethodData::BankRedirect(_) - | api_models::payments::PaymentMethodData::BankTransfer(_) - | api_models::payments::PaymentMethodData::Crypto(_) - | api_models::payments::PaymentMethodData::MandatePayment - | api_models::payments::PaymentMethodData::Reward - | api_models::payments::PaymentMethodData::Upi(_) - | api_models::payments::PaymentMethodData::Voucher(_) - | api_models::payments::PaymentMethodData::GiftCard(_) - | api::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented( - utils::get_unimplemented_payment_method_error_message("Gocardless"), - ) - .into()), + domain::PaymentMethodData::Card(_) + | domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::Wallet(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { + Err(errors::ConnectorError::NotImplemented( + utils::get_unimplemented_payment_method_error_message("Gocardless"), + ) + .into()) + } } } } @@ -465,28 +468,30 @@ impl TryFrom<&types::SetupMandateRouterData> for GocardlessMandateRequest { type Error = error_stack::Report; fn try_from(item: &types::SetupMandateRouterData) -> Result { let (scheme, payer_ip_address) = match &item.request.payment_method_data { - api_models::payments::PaymentMethodData::BankDebit(bank_debit_data) => { + domain::PaymentMethodData::BankDebit(bank_debit_data) => { let payer_ip_address = get_ip_if_required(bank_debit_data, item)?; Ok(( GocardlessScheme::try_from(bank_debit_data)?, payer_ip_address, )) } - api_models::payments::PaymentMethodData::Card(_) - | api_models::payments::PaymentMethodData::CardRedirect(_) - | api_models::payments::PaymentMethodData::Wallet(_) - | api_models::payments::PaymentMethodData::PayLater(_) - | api_models::payments::PaymentMethodData::BankRedirect(_) - | api_models::payments::PaymentMethodData::BankTransfer(_) - | api_models::payments::PaymentMethodData::Crypto(_) - | api_models::payments::PaymentMethodData::MandatePayment - | api_models::payments::PaymentMethodData::Reward - | api_models::payments::PaymentMethodData::Upi(_) - | api_models::payments::PaymentMethodData::Voucher(_) - | api_models::payments::PaymentMethodData::GiftCard(_) - | api::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented( - "Setup Mandate flow for selected payment method through Gocardless".to_string(), - )), + domain::PaymentMethodData::Card(_) + | domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::Wallet(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { + Err(errors::ConnectorError::NotImplemented( + "Setup Mandate flow for selected payment method through Gocardless".to_string(), + )) + } }?; let payment_method_token = item.get_payment_method_token()?; let customer_bank_account = match payment_method_token { diff --git a/crates/router/src/connector/helcim/transformers.rs b/crates/router/src/connector/helcim/transformers.rs index 66cb26660387..2dc44c8a19bf 100644 --- a/crates/router/src/connector/helcim/transformers.rs +++ b/crates/router/src/connector/helcim/transformers.rs @@ -10,7 +10,7 @@ use crate::{ RefundsRequestData, RouterData, }, core::errors, - types::{self, api, storage::enums}, + types::{self, api, domain, storage::enums}, }; #[derive(Debug, Serialize)] @@ -121,9 +121,11 @@ pub struct HelcimCard { card_c_v_v: Secret, } -impl TryFrom<(&types::SetupMandateRouterData, &api::Card)> for HelcimVerifyRequest { +impl TryFrom<(&types::SetupMandateRouterData, &domain::Card)> for HelcimVerifyRequest { type Error = error_stack::Report; - fn try_from(value: (&types::SetupMandateRouterData, &api::Card)) -> Result { + fn try_from( + value: (&types::SetupMandateRouterData, &domain::Card), + ) -> Result { let (item, req_card) = value; let card_data = HelcimCard { card_expiry: req_card @@ -157,22 +159,22 @@ impl TryFrom<&types::SetupMandateRouterData> for HelcimVerifyRequest { type Error = error_stack::Report; fn try_from(item: &types::SetupMandateRouterData) -> Result { match item.request.payment_method_data.clone() { - api::PaymentMethodData::Card(req_card) => Self::try_from((item, &req_card)), - api_models::payments::PaymentMethodData::BankTransfer(_) => { + domain::PaymentMethodData::Card(req_card) => Self::try_from((item, &req_card)), + domain::PaymentMethodData::BankTransfer(_) => { Err(errors::ConnectorError::NotImplemented("Payment Method".to_string()).into()) } - api_models::payments::PaymentMethodData::CardRedirect(_) - | api_models::payments::PaymentMethodData::Wallet(_) - | api_models::payments::PaymentMethodData::PayLater(_) - | api_models::payments::PaymentMethodData::BankRedirect(_) - | api_models::payments::PaymentMethodData::BankDebit(_) - | api_models::payments::PaymentMethodData::Crypto(_) - | api_models::payments::PaymentMethodData::MandatePayment - | api_models::payments::PaymentMethodData::Reward - | api_models::payments::PaymentMethodData::Upi(_) - | api_models::payments::PaymentMethodData::Voucher(_) - | api_models::payments::PaymentMethodData::GiftCard(_) - | api_models::payments::PaymentMethodData::CardToken(_) => { + domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::Wallet(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("Helcim"), ))? @@ -184,14 +186,14 @@ impl TryFrom<&types::SetupMandateRouterData> for HelcimVerifyRequest { impl TryFrom<( &HelcimRouterData<&types::PaymentsAuthorizeRouterData>, - &api::Card, + &domain::Card, )> for HelcimPaymentsRequest { type Error = error_stack::Report; fn try_from( value: ( &HelcimRouterData<&types::PaymentsAuthorizeRouterData>, - &api::Card, + &domain::Card, ), ) -> Result { let (item, req_card) = value; @@ -258,24 +260,26 @@ impl TryFrom<&HelcimRouterData<&types::PaymentsAuthorizeRouterData>> for HelcimP item: &HelcimRouterData<&types::PaymentsAuthorizeRouterData>, ) -> Result { match item.router_data.request.payment_method_data.clone() { - api::PaymentMethodData::Card(req_card) => Self::try_from((item, &req_card)), - api_models::payments::PaymentMethodData::BankTransfer(_) => { + domain::PaymentMethodData::Card(req_card) => Self::try_from((item, &req_card)), + domain::PaymentMethodData::BankTransfer(_) => { Err(errors::ConnectorError::NotImplemented("Payment Method".to_string()).into()) } - api_models::payments::PaymentMethodData::CardRedirect(_) - | api_models::payments::PaymentMethodData::Wallet(_) - | api_models::payments::PaymentMethodData::PayLater(_) - | api_models::payments::PaymentMethodData::BankRedirect(_) - | api_models::payments::PaymentMethodData::BankDebit(_) - | api_models::payments::PaymentMethodData::Crypto(_) - | api_models::payments::PaymentMethodData::MandatePayment - | api_models::payments::PaymentMethodData::Reward - | api_models::payments::PaymentMethodData::Upi(_) - | api_models::payments::PaymentMethodData::Voucher(_) - | api_models::payments::PaymentMethodData::GiftCard(_) - | api::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented( - utils::get_unimplemented_payment_method_error_message("Helcim"), - ))?, + domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::Wallet(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { + Err(errors::ConnectorError::NotImplemented( + utils::get_unimplemented_payment_method_error_message("Helcim"), + ))? + } } } } diff --git a/crates/router/src/connector/iatapay/transformers.rs b/crates/router/src/connector/iatapay/transformers.rs index 0a5f592c7658..8e45b96e69ce 100644 --- a/crates/router/src/connector/iatapay/transformers.rs +++ b/crates/router/src/connector/iatapay/transformers.rs @@ -12,7 +12,7 @@ use crate::{ consts, core::errors, services, - types::{self, api, storage::enums, PaymentsAuthorizeData}, + types::{self, api, domain, storage::enums, PaymentsAuthorizeData}, }; type Error = error_stack::Report; @@ -149,22 +149,22 @@ impl }; let return_url = item.router_data.get_return_url()?; let payer_info = match item.router_data.request.payment_method_data.clone() { - api::PaymentMethodData::Upi(upi_data) => upi_data.vpa_id.map(|id| PayerInfo { + domain::PaymentMethodData::Upi(upi_data) => upi_data.vpa_id.map(|id| PayerInfo { token_id: id.switch_strategy(), }), - api::PaymentMethodData::Card(_) - | api::PaymentMethodData::CardRedirect(_) - | api::PaymentMethodData::Wallet(_) - | api::PaymentMethodData::PayLater(_) - | api::PaymentMethodData::BankRedirect(_) - | api::PaymentMethodData::BankDebit(_) - | api::PaymentMethodData::BankTransfer(_) - | api::PaymentMethodData::Crypto(_) - | api::PaymentMethodData::MandatePayment - | api::PaymentMethodData::Reward - | api::PaymentMethodData::Voucher(_) - | api::PaymentMethodData::GiftCard(_) - | api::PaymentMethodData::CardToken(_) => None, + domain::PaymentMethodData::Card(_) + | domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::Wallet(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => None, }; let payload = Self { merchant_id: IatapayAuthType::try_from(&item.router_data.connector_auth_type)? diff --git a/crates/router/src/connector/klarna.rs b/crates/router/src/connector/klarna.rs index 91ef719e5e05..0d1a37d1a44f 100644 --- a/crates/router/src/connector/klarna.rs +++ b/crates/router/src/connector/klarna.rs @@ -1,7 +1,6 @@ pub mod transformers; use std::fmt::Debug; -use api_models::payments as api_payments; use common_utils::request::RequestContent; use error_stack::{report, ResultExt}; use transformers as klarna; @@ -21,6 +20,7 @@ use crate::{ types::{ self, api::{self, ConnectorCommon}, + domain, storage::enums as storage_enums, }, utils::BytesExt, @@ -307,9 +307,9 @@ impl .ok_or_else(connector_utils::missing_field_err("payment_method_type"))?; match payment_method_data { - api_payments::PaymentMethodData::PayLater(api_payments::PayLaterData::KlarnaSdk { - token, - }) => match (payment_experience, payment_method_type) { + domain::PaymentMethodData::PayLater( + api_models::payments::PayLaterData::KlarnaSdk { token }, + ) => match (payment_experience, payment_method_type) { ( storage_enums::PaymentExperience::InvokeSdkClient, storage_enums::PaymentMethodType::Klarna, @@ -415,20 +415,20 @@ impl })), }, - api_payments::PaymentMethodData::Card(_) - | api_payments::PaymentMethodData::CardRedirect(_) - | api_payments::PaymentMethodData::Wallet(_) - | api_payments::PaymentMethodData::PayLater(_) - | api_payments::PaymentMethodData::BankRedirect(_) - | api_payments::PaymentMethodData::BankDebit(_) - | api_payments::PaymentMethodData::BankTransfer(_) - | api_payments::PaymentMethodData::Crypto(_) - | api_payments::PaymentMethodData::MandatePayment - | api_payments::PaymentMethodData::Reward - | api_payments::PaymentMethodData::Upi(_) - | api_payments::PaymentMethodData::Voucher(_) - | api_payments::PaymentMethodData::GiftCard(_) - | api_payments::PaymentMethodData::CardToken(_) => Err(error_stack::report!( + domain::PaymentMethodData::Card(_) + | domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::Wallet(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => Err(error_stack::report!( errors::ConnectorError::MismatchedPaymentData )), } diff --git a/crates/router/src/connector/mollie/transformers.rs b/crates/router/src/connector/mollie/transformers.rs index 7acf81db295a..30856035fde2 100644 --- a/crates/router/src/connector/mollie/transformers.rs +++ b/crates/router/src/connector/mollie/transformers.rs @@ -13,7 +13,7 @@ use crate::{ }, core::errors, services, types, - types::storage::enums as storage_enums, + types::{domain, storage::enums as storage_enums}, unimplemented_payment_method, }; @@ -169,7 +169,7 @@ impl TryFrom<&MollieRouterData<&types::PaymentsAuthorizeRouterData>> for MollieP { enums::CaptureMethod::Automatic => { match &item.router_data.request.payment_method_data { - api_models::payments::PaymentMethodData::Card(_) => { + domain::PaymentMethodData::Card(_) => { let pm_token = item.router_data.get_payment_method_token()?; Ok(PaymentMethodData::CreditCard(Box::new( CreditCardMethodData { @@ -188,13 +188,13 @@ impl TryFrom<&MollieRouterData<&types::PaymentsAuthorizeRouterData>> for MollieP }, ))) } - api_models::payments::PaymentMethodData::BankRedirect(ref redirect_data) => { + domain::PaymentMethodData::BankRedirect(ref redirect_data) => { PaymentMethodData::try_from(redirect_data) } - api_models::payments::PaymentMethodData::Wallet(ref wallet_data) => { + domain::PaymentMethodData::Wallet(ref wallet_data) => { get_payment_method_for_wallet(item.router_data, wallet_data) } - api_models::payments::PaymentMethodData::BankDebit(ref directdebit_data) => { + domain::PaymentMethodData::BankDebit(ref directdebit_data) => { PaymentMethodData::try_from(directdebit_data) } _ => Err( @@ -287,7 +287,7 @@ impl TryFrom<&types::TokenizationRouterData> for MollieCardTokenRequest { type Error = error_stack::Report; fn try_from(item: &types::TokenizationRouterData) -> Result { match item.request.payment_method_data.clone() { - api_models::payments::PaymentMethodData::Card(ccard) => { + domain::PaymentMethodData::Card(ccard) => { let auth = MollieAuthType::try_from(&item.connector_auth_type)?; let card_holder = ccard .card_holder_name diff --git a/crates/router/src/connector/multisafepay/transformers.rs b/crates/router/src/connector/multisafepay/transformers.rs index f6051ea05de2..8c6d23ca47ed 100644 --- a/crates/router/src/connector/multisafepay/transformers.rs +++ b/crates/router/src/connector/multisafepay/transformers.rs @@ -10,7 +10,7 @@ use crate::{ core::errors, pii::Secret, services, - types::{self, api, storage::enums}, + types::{self, api, domain, storage::enums}, }; #[derive(Debug, Serialize)] @@ -278,9 +278,9 @@ impl TryFrom<&MultisafepayRouterData<&types::PaymentsAuthorizeRouterData>> item: &MultisafepayRouterData<&types::PaymentsAuthorizeRouterData>, ) -> Result { let payment_type = match item.router_data.request.payment_method_data { - api::PaymentMethodData::Card(ref _ccard) => Type::Direct, - api::PaymentMethodData::MandatePayment => Type::Direct, - api::PaymentMethodData::Wallet(ref wallet_data) => match wallet_data { + domain::PaymentMethodData::Card(ref _ccard) => Type::Direct, + domain::PaymentMethodData::MandatePayment => Type::Direct, + domain::PaymentMethodData::Wallet(ref wallet_data) => match wallet_data { api::WalletData::GooglePay(_) => Type::Direct, api::WalletData::PaypalRedirect(_) => Type::Redirect, api::WalletData::AliPayQr(_) @@ -310,15 +310,15 @@ impl TryFrom<&MultisafepayRouterData<&types::PaymentsAuthorizeRouterData>> utils::get_unimplemented_payment_method_error_message("multisafepay"), ))?, }, - api::PaymentMethodData::PayLater(ref _paylater) => Type::Redirect, + domain::PaymentMethodData::PayLater(ref _paylater) => Type::Redirect, _ => Type::Redirect, }; let gateway = match item.router_data.request.payment_method_data { - api::PaymentMethodData::Card(ref ccard) => { + domain::PaymentMethodData::Card(ref ccard) => { Some(Gateway::try_from(ccard.get_card_issuer()?)?) } - api::PaymentMethodData::Wallet(ref wallet_data) => Some(match wallet_data { + domain::PaymentMethodData::Wallet(ref wallet_data) => Some(match wallet_data { api::WalletData::GooglePay(_) => Gateway::Googlepay, api::WalletData::PaypalRedirect(_) => Gateway::Paypal, api::WalletData::AliPayQr(_) @@ -348,26 +348,28 @@ impl TryFrom<&MultisafepayRouterData<&types::PaymentsAuthorizeRouterData>> utils::get_unimplemented_payment_method_error_message("multisafepay"), ))?, }), - api::PaymentMethodData::PayLater( + domain::PaymentMethodData::PayLater( api_models::payments::PayLaterData::KlarnaRedirect { billing_email: _, billing_country: _, }, ) => Some(Gateway::Klarna), - api::PaymentMethodData::MandatePayment => None, - api::PaymentMethodData::CardRedirect(_) - | api::PaymentMethodData::PayLater(_) - | api::PaymentMethodData::BankRedirect(_) - | api::PaymentMethodData::BankDebit(_) - | api::PaymentMethodData::BankTransfer(_) - | api::PaymentMethodData::Crypto(_) - | api::PaymentMethodData::Reward - | api::PaymentMethodData::Upi(_) - | api::PaymentMethodData::Voucher(_) - | api::PaymentMethodData::GiftCard(_) - | api::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented( - utils::get_unimplemented_payment_method_error_message("multisafepay"), - ))?, + domain::PaymentMethodData::MandatePayment => None, + domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { + Err(errors::ConnectorError::NotImplemented( + utils::get_unimplemented_payment_method_error_message("multisafepay"), + ))? + } }; let description = item.router_data.get_description()?; let payment_options = PaymentOptions { @@ -421,7 +423,7 @@ impl TryFrom<&MultisafepayRouterData<&types::PaymentsAuthorizeRouterData>> }; let gateway_info = match item.router_data.request.payment_method_data { - api::PaymentMethodData::Card(ref ccard) => Some(GatewayInfo::Card(CardInfo { + domain::PaymentMethodData::Card(ref ccard) => Some(GatewayInfo::Card(CardInfo { card_number: Some(ccard.card_number.clone()), card_expiry_date: Some(Secret::new( (format!( @@ -438,7 +440,7 @@ impl TryFrom<&MultisafepayRouterData<&types::PaymentsAuthorizeRouterData>> moto: None, term_url: None, })), - api::PaymentMethodData::Wallet(ref wallet_data) => match wallet_data { + domain::PaymentMethodData::Wallet(ref wallet_data) => match wallet_data { api::WalletData::GooglePay(ref google_pay) => { Some(GatewayInfo::Wallet(WalletInfo::GooglePay({ GpayInfo { @@ -476,7 +478,7 @@ impl TryFrom<&MultisafepayRouterData<&types::PaymentsAuthorizeRouterData>> utils::get_unimplemented_payment_method_error_message("multisafepay"), ))?, }, - api::PaymentMethodData::PayLater(ref paylater) => { + domain::PaymentMethodData::PayLater(ref paylater) => { Some(GatewayInfo::PayLater(PayLaterInfo { email: Some(match paylater { api_models::payments::PayLaterData::KlarnaRedirect { @@ -502,19 +504,21 @@ impl TryFrom<&MultisafepayRouterData<&types::PaymentsAuthorizeRouterData>> }), })) } - api::PaymentMethodData::MandatePayment => None, - api::PaymentMethodData::CardRedirect(_) - | api::PaymentMethodData::BankRedirect(_) - | api::PaymentMethodData::BankDebit(_) - | api::PaymentMethodData::BankTransfer(_) - | api::PaymentMethodData::Crypto(_) - | api::PaymentMethodData::Reward - | api::PaymentMethodData::Upi(_) - | api::PaymentMethodData::Voucher(_) - | api::PaymentMethodData::GiftCard(_) - | api::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented( - utils::get_unimplemented_payment_method_error_message("multisafepay"), - ))?, + domain::PaymentMethodData::MandatePayment => None, + domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { + Err(errors::ConnectorError::NotImplemented( + utils::get_unimplemented_payment_method_error_message("multisafepay"), + ))? + } }; Ok(Self { diff --git a/crates/router/src/connector/nexinets/transformers.rs b/crates/router/src/connector/nexinets/transformers.rs index 703c24e56e94..210910d3e750 100644 --- a/crates/router/src/connector/nexinets/transformers.rs +++ b/crates/router/src/connector/nexinets/transformers.rs @@ -1,7 +1,7 @@ -use api_models::payments::PaymentMethodData; use base64::Engine; use cards::CardNumber; use common_utils::errors::CustomResult; +use domain::PaymentMethodData; use error_stack::ResultExt; use masking::{ExposeInterface, PeekInterface, Secret}; use serde::{Deserialize, Serialize}; @@ -14,7 +14,7 @@ use crate::{ consts, core::errors, services, - types::{self, api, storage::enums, transformers::ForeignFrom}, + types::{self, api, domain, storage::enums, transformers::ForeignFrom}, }; #[derive(Debug, Serialize)] @@ -633,7 +633,7 @@ fn get_payment_details_and_product( fn get_card_data( item: &types::PaymentsAuthorizeRouterData, - card: &api_models::payments::Card, + card: &domain::payments::Card, ) -> Result { let (card_data, cof_contract) = match item.request.is_mandate_payment() { true => { @@ -676,7 +676,7 @@ fn get_applepay_details( } fn get_card_details( - req_card: &api_models::payments::Card, + req_card: &domain::payments::Card, ) -> Result { Ok(CardDetails { card_number: req_card.card_number.clone(), diff --git a/crates/router/src/connector/nmi/transformers.rs b/crates/router/src/connector/nmi/transformers.rs index 2358e0f6cc06..79e71ca72d85 100644 --- a/crates/router/src/connector/nmi/transformers.rs +++ b/crates/router/src/connector/nmi/transformers.rs @@ -17,7 +17,7 @@ use crate::{ }, core::errors, services, - types::{self, api, storage::enums, transformers::ForeignFrom, ConnectorAuthType}, + types::{self, api, domain, storage::enums, transformers::ForeignFrom, ConnectorAuthType}, }; type Error = Report; @@ -136,10 +136,10 @@ impl TryFrom<&types::PaymentsPreProcessingRouterData> for NmiVaultRequest { } fn get_card_details( - payment_method_data: Option, + payment_method_data: Option, ) -> CustomResult<(CardNumber, Secret, Secret), errors::ConnectorError> { match payment_method_data { - Some(api::PaymentMethodData::Card(ref card_details)) => Ok(( + Some(domain::PaymentMethodData::Card(ref card_details)) => Ok(( card_details.card_number.clone(), utils::CardData::get_card_expiry_month_year_2_digit_with_delimiter( card_details, @@ -513,14 +513,12 @@ impl TryFrom<&NmiRouterData<&types::PaymentsAuthorizeRouterData>> for NmiPayment } } -impl TryFrom<&api_models::payments::PaymentMethodData> for PaymentMethod { +impl TryFrom<&domain::PaymentMethodData> for PaymentMethod { type Error = Error; - fn try_from( - payment_method_data: &api_models::payments::PaymentMethodData, - ) -> Result { + fn try_from(payment_method_data: &domain::PaymentMethodData) -> Result { match &payment_method_data { - api::PaymentMethodData::Card(ref card) => Ok(Self::try_from(card)?), - api::PaymentMethodData::Wallet(ref wallet_type) => match wallet_type { + domain::PaymentMethodData::Card(ref card) => Ok(Self::try_from(card)?), + domain::PaymentMethodData::Wallet(ref wallet_type) => match wallet_type { api_models::payments::WalletData::GooglePay(ref googlepay_data) => { Ok(Self::from(googlepay_data)) } @@ -557,28 +555,30 @@ impl TryFrom<&api_models::payments::PaymentMethodData> for PaymentMethod { .into()) } }, - api::PaymentMethodData::CardRedirect(_) - | api::PaymentMethodData::PayLater(_) - | api::PaymentMethodData::BankRedirect(_) - | api::PaymentMethodData::BankDebit(_) - | api::PaymentMethodData::BankTransfer(_) - | api::PaymentMethodData::Crypto(_) - | api::PaymentMethodData::MandatePayment - | api::PaymentMethodData::Reward - | api::PaymentMethodData::Upi(_) - | api::PaymentMethodData::Voucher(_) - | api::PaymentMethodData::GiftCard(_) - | api::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented( - utils::get_unimplemented_payment_method_error_message("nmi"), - ) - .into()), + domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { + Err(errors::ConnectorError::NotImplemented( + utils::get_unimplemented_payment_method_error_message("nmi"), + ) + .into()) + } } } } -impl TryFrom<&api_models::payments::Card> for PaymentMethod { +impl TryFrom<&domain::payments::Card> for PaymentMethod { type Error = Error; - fn try_from(card: &api_models::payments::Card) -> Result { + fn try_from(card: &domain::payments::Card) -> Result { let ccexp = utils::CardData::get_card_expiry_month_year_2_digit_with_delimiter( card, "".to_string(), diff --git a/crates/router/src/connector/noon/transformers.rs b/crates/router/src/connector/noon/transformers.rs index 38202291b41f..c2031fd89541 100644 --- a/crates/router/src/connector/noon/transformers.rs +++ b/crates/router/src/connector/noon/transformers.rs @@ -10,7 +10,7 @@ use crate::{ }, core::{errors, mandate::MandateBehaviour}, services, - types::{self, api, storage::enums, transformers::ForeignFrom, ErrorResponse}, + types::{self, api, domain, storage::enums, transformers::ForeignFrom, ErrorResponse}, }; // These needs to be accepted from SDK, need to be done after 1.0.0 stability as API contract will change @@ -239,14 +239,16 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for NoonPaymentsRequest { ), _ => ( match item.request.payment_method_data.clone() { - api::PaymentMethodData::Card(req_card) => Ok(NoonPaymentData::Card(NoonCard { - name_on_card: req_card.card_holder_name.clone(), - number_plain: req_card.card_number.clone(), - expiry_month: req_card.card_exp_month.clone(), - expiry_year: req_card.get_expiry_year_4_digit(), - cvv: req_card.card_cvc, - })), - api::PaymentMethodData::Wallet(wallet_data) => match wallet_data.clone() { + domain::PaymentMethodData::Card(req_card) => { + Ok(NoonPaymentData::Card(NoonCard { + name_on_card: req_card.card_holder_name.clone(), + number_plain: req_card.card_number.clone(), + expiry_month: req_card.card_exp_month.clone(), + expiry_year: req_card.get_expiry_year_4_digit(), + cvv: req_card.card_cvc, + })) + } + domain::PaymentMethodData::Wallet(wallet_data) => match wallet_data.clone() { api_models::payments::WalletData::GooglePay(google_pay_data) => { Ok(NoonPaymentData::GooglePay(NoonGooglePay { api_version_minor: GOOGLEPAY_API_VERSION_MINOR, @@ -312,18 +314,18 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for NoonPaymentsRequest { )) } }, - api::PaymentMethodData::CardRedirect(_) - | api::PaymentMethodData::PayLater(_) - | api::PaymentMethodData::BankRedirect(_) - | api::PaymentMethodData::BankDebit(_) - | api::PaymentMethodData::BankTransfer(_) - | api::PaymentMethodData::Crypto(_) - | api::PaymentMethodData::MandatePayment {} - | api::PaymentMethodData::Reward {} - | api::PaymentMethodData::Upi(_) - | api::PaymentMethodData::Voucher(_) - | api::PaymentMethodData::GiftCard(_) - | api::PaymentMethodData::CardToken(_) => { + domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment {} + | domain::PaymentMethodData::Reward {} + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { Err(errors::ConnectorError::NotImplemented( conn_utils::get_unimplemented_payment_method_error_message("Noon"), )) diff --git a/crates/router/src/connector/nuvei/transformers.rs b/crates/router/src/connector/nuvei/transformers.rs index 6753dfe203f2..00da2b9ae5f1 100644 --- a/crates/router/src/connector/nuvei/transformers.rs +++ b/crates/router/src/connector/nuvei/transformers.rs @@ -20,7 +20,7 @@ use crate::{ consts, core::errors, services, - types::{self, api, storage::enums, transformers::ForeignTryFrom, BrowserInformation}, + types::{self, api, domain, storage::enums, transformers::ForeignTryFrom, BrowserInformation}, utils::OptionExt, }; @@ -424,11 +424,12 @@ impl } } -#[derive(Debug, Default)] +#[derive(Debug)] pub struct NuveiCardDetails { - card: payments::Card, + card: domain::Card, three_d: Option, } + impl TryFrom for NuveiPaymentsRequest { type Error = error_stack::Report; fn try_from(gpay_data: payments::GooglePayWalletData) -> Result { @@ -748,9 +749,9 @@ impl ) -> Result { let item = data.0; let request_data = match item.request.payment_method_data.clone() { - api::PaymentMethodData::Card(card) => get_card_info(item, &card), - api::PaymentMethodData::MandatePayment => Self::try_from(item), - api::PaymentMethodData::Wallet(wallet) => match wallet { + domain::PaymentMethodData::Card(card) => get_card_info(item, &card), + domain::PaymentMethodData::MandatePayment => Self::try_from(item), + domain::PaymentMethodData::Wallet(wallet) => match wallet { payments::WalletData::GooglePay(gpay_data) => Self::try_from(gpay_data), payments::WalletData::ApplePay(apple_pay_data) => Ok(Self::from(apple_pay_data)), payments::WalletData::PaypalRedirect(_) => Self::foreign_try_from(( @@ -787,7 +788,7 @@ impl .into()) } }, - api::PaymentMethodData::BankRedirect(redirect) => match redirect { + domain::PaymentMethodData::BankRedirect(redirect) => match redirect { payments::BankRedirectData::Eps { .. } => Self::foreign_try_from(( AlternativePaymentMethodType::Eps, Some(redirect), @@ -827,7 +828,7 @@ impl .into()) } }, - api::PaymentMethodData::PayLater(pay_later_data) => match pay_later_data { + domain::PaymentMethodData::PayLater(pay_later_data) => match pay_later_data { payments::PayLaterData::KlarnaRedirect { .. } => { get_pay_later_info(AlternativePaymentMethodType::Klarna, item) } @@ -846,15 +847,15 @@ impl .into()) } }, - payments::PaymentMethodData::BankDebit(_) - | payments::PaymentMethodData::BankTransfer(_) - | payments::PaymentMethodData::Crypto(_) - | payments::PaymentMethodData::Reward - | payments::PaymentMethodData::Upi(_) - | payments::PaymentMethodData::Voucher(_) - | payments::PaymentMethodData::CardRedirect(_) - | payments::PaymentMethodData::GiftCard(_) - | payments::PaymentMethodData::CardToken(_) => { + domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("nuvei"), ) @@ -890,7 +891,7 @@ impl fn get_card_info( item: &types::RouterData, - card_details: &payments::Card, + card_details: &domain::Card, ) -> Result> { let browser_information = item.request.browser_info.clone(); let related_transaction_id = if item.is_three_ds() { @@ -1026,26 +1027,26 @@ impl TryFrom<(&types::PaymentsCompleteAuthorizeRouterData, Secret)> ) -> Result { let item = data.0; let request_data = match item.request.payment_method_data.clone() { - Some(api::PaymentMethodData::Card(card)) => Ok(Self { + Some(domain::PaymentMethodData::Card(card)) => Ok(Self { payment_option: PaymentOption::from(NuveiCardDetails { card, three_d: None, }), ..Default::default() }), - Some(api::PaymentMethodData::Wallet(..)) - | Some(api::PaymentMethodData::PayLater(..)) - | Some(api::PaymentMethodData::BankDebit(..)) - | Some(api::PaymentMethodData::BankRedirect(..)) - | Some(api::PaymentMethodData::BankTransfer(..)) - | Some(api::PaymentMethodData::Crypto(..)) - | Some(api::PaymentMethodData::MandatePayment) - | Some(api::PaymentMethodData::GiftCard(..)) - | Some(api::PaymentMethodData::Voucher(..)) - | Some(api::PaymentMethodData::CardRedirect(..)) - | Some(api::PaymentMethodData::Reward) - | Some(api::PaymentMethodData::Upi(..)) - | Some(api::PaymentMethodData::CardToken(..)) + Some(domain::PaymentMethodData::Wallet(..)) + | Some(domain::PaymentMethodData::PayLater(..)) + | Some(domain::PaymentMethodData::BankDebit(..)) + | Some(domain::PaymentMethodData::BankRedirect(..)) + | Some(domain::PaymentMethodData::BankTransfer(..)) + | Some(domain::PaymentMethodData::Crypto(..)) + | Some(domain::PaymentMethodData::MandatePayment) + | Some(domain::PaymentMethodData::GiftCard(..)) + | Some(domain::PaymentMethodData::Voucher(..)) + | Some(domain::PaymentMethodData::CardRedirect(..)) + | Some(domain::PaymentMethodData::Reward) + | Some(domain::PaymentMethodData::Upi(..)) + | Some(domain::PaymentMethodData::CardToken(..)) | None => Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("nuvei"), )), diff --git a/crates/router/src/connector/opayo/transformers.rs b/crates/router/src/connector/opayo/transformers.rs index 94ab62b4f7f1..008643f1433c 100644 --- a/crates/router/src/connector/opayo/transformers.rs +++ b/crates/router/src/connector/opayo/transformers.rs @@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize}; use crate::{ connector::utils::{self, PaymentsAuthorizeRequestData}, core::errors, - types::{self, api, storage::enums}, + types::{self, api, domain, storage::enums}, }; #[derive(Default, Debug, Serialize, Eq, PartialEq)] @@ -27,7 +27,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for OpayoPaymentsRequest { type Error = error_stack::Report; fn try_from(item: &types::PaymentsAuthorizeRouterData) -> Result { match item.request.payment_method_data.clone() { - api::PaymentMethodData::Card(req_card) => { + domain::PaymentMethodData::Card(req_card) => { let card = OpayoCard { name: req_card .card_holder_name @@ -43,22 +43,24 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for OpayoPaymentsRequest { card, }) } - api::PaymentMethodData::CardRedirect(_) - | api::PaymentMethodData::Wallet(_) - | api::PaymentMethodData::PayLater(_) - | api::PaymentMethodData::BankRedirect(_) - | api::PaymentMethodData::BankDebit(_) - | api::PaymentMethodData::BankTransfer(_) - | api::PaymentMethodData::Crypto(_) - | api::PaymentMethodData::MandatePayment - | api::PaymentMethodData::Reward - | api::PaymentMethodData::Upi(_) - | api::PaymentMethodData::Voucher(_) - | api::PaymentMethodData::GiftCard(_) - | api::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented( - utils::get_unimplemented_payment_method_error_message("Opayo"), - ) - .into()), + domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::Wallet(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { + Err(errors::ConnectorError::NotImplemented( + utils::get_unimplemented_payment_method_error_message("Opayo"), + ) + .into()) + } } } } diff --git a/crates/router/src/connector/payeezy/transformers.rs b/crates/router/src/connector/payeezy/transformers.rs index 6d5d6db9dcf0..2b19b10b4363 100644 --- a/crates/router/src/connector/payeezy/transformers.rs +++ b/crates/router/src/connector/payeezy/transformers.rs @@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize}; use crate::{ connector::utils::{self, CardData}, core::errors, - types::{self, api, storage::enums, transformers::ForeignFrom}, + types::{self, api, domain, storage::enums, transformers::ForeignFrom}, }; #[derive(Debug, Serialize)] pub struct PayeezyRouterData { @@ -237,7 +237,7 @@ fn get_payment_method_data( item: &PayeezyRouterData<&types::PaymentsAuthorizeRouterData>, ) -> Result> { match item.router_data.request.payment_method_data { - api::PaymentMethodData::Card(ref card) => { + domain::PaymentMethodData::Card(ref card) => { let card_type = PayeezyCardType::try_from(card.get_card_issuer()?)?; let payeezy_card = PayeezyCard { card_type, @@ -252,19 +252,19 @@ fn get_payment_method_data( Ok(PayeezyPaymentMethod::PayeezyCard(payeezy_card)) } - api::PaymentMethodData::CardRedirect(_) - | api::PaymentMethodData::Wallet(_) - | api::PaymentMethodData::PayLater(_) - | api::PaymentMethodData::BankRedirect(_) - | api::PaymentMethodData::BankDebit(_) - | api::PaymentMethodData::BankTransfer(_) - | api::PaymentMethodData::Crypto(_) - | api::PaymentMethodData::MandatePayment - | api::PaymentMethodData::Reward - | api::PaymentMethodData::Upi(_) - | api::PaymentMethodData::Voucher(_) - | api::PaymentMethodData::GiftCard(_) - | api::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented( + domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::Wallet(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("Payeezy"), ))?, } diff --git a/crates/router/src/connector/payme/transformers.rs b/crates/router/src/connector/payme/transformers.rs index b577ae9f20ad..d3b9e72e9897 100644 --- a/crates/router/src/connector/payme/transformers.rs +++ b/crates/router/src/connector/payme/transformers.rs @@ -1,9 +1,6 @@ use std::collections::HashMap; -use api_models::{ - enums::{AuthenticationType, PaymentMethod}, - payments::PaymentMethodData, -}; +use api_models::enums::{AuthenticationType, PaymentMethod}; use common_utils::pii; use error_stack::ResultExt; use masking::{ExposeInterface, Secret}; @@ -20,7 +17,7 @@ use crate::{ consts, core::errors, services, - types::{self, api, storage::enums, MandateReference}, + types::{self, api, domain, domain::PaymentMethodData, storage::enums, MandateReference}, unimplemented_payment_method, }; @@ -640,7 +637,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for PayRequest { type Error = error_stack::Report; fn try_from(item: &types::PaymentsAuthorizeRouterData) -> Result { match item.request.payment_method_data.clone() { - api::PaymentMethodData::Card(req_card) => { + domain::PaymentMethodData::Card(req_card) => { let card = PaymeCard { credit_card_cvv: req_card.card_cvc.clone(), credit_card_exp: req_card @@ -662,21 +659,23 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for PayRequest { language: LANGUAGE.to_string(), }) } - api::PaymentMethodData::CardRedirect(_) - | api::PaymentMethodData::Wallet(_) - | api::PaymentMethodData::PayLater(_) - | api::PaymentMethodData::BankRedirect(_) - | api::PaymentMethodData::BankDebit(_) - | api::PaymentMethodData::BankTransfer(_) - | api::PaymentMethodData::Crypto(_) - | api::PaymentMethodData::MandatePayment - | api::PaymentMethodData::Reward - | api::PaymentMethodData::Upi(_) - | api::PaymentMethodData::Voucher(_) - | api::PaymentMethodData::GiftCard(_) - | api::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented( - utils::get_unimplemented_payment_method_error_message("payme"), - ))?, + domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::Wallet(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { + Err(errors::ConnectorError::NotImplemented( + utils::get_unimplemented_payment_method_error_message("payme"), + ))? + } } } } @@ -689,7 +688,7 @@ impl TryFrom<&types::PaymentsCompleteAuthorizeRouterData> for Pay3dsRequest { type Error = error_stack::Report; fn try_from(item: &types::PaymentsCompleteAuthorizeRouterData) -> Result { match item.request.payment_method_data.clone() { - Some(api::PaymentMethodData::Card(_)) => { + Some(domain::PaymentMethodData::Card(_)) => { let buyer_email = item.request.get_email()?; let buyer_name = item.get_billing_address()?.get_full_name()?; @@ -720,19 +719,19 @@ impl TryFrom<&types::PaymentsCompleteAuthorizeRouterData> for Pay3dsRequest { meta_data_jwt: Secret::new(jwt_data.meta_data), }) } - Some(api::PaymentMethodData::CardRedirect(_)) - | Some(api::PaymentMethodData::Wallet(_)) - | Some(api::PaymentMethodData::PayLater(_)) - | Some(api::PaymentMethodData::BankRedirect(_)) - | Some(api::PaymentMethodData::BankDebit(_)) - | Some(api::PaymentMethodData::BankTransfer(_)) - | Some(api::PaymentMethodData::Crypto(_)) - | Some(api::PaymentMethodData::MandatePayment) - | Some(api::PaymentMethodData::Reward) - | Some(api::PaymentMethodData::Upi(_)) - | Some(api::PaymentMethodData::Voucher(_)) - | Some(api::PaymentMethodData::GiftCard(_)) - | Some(api::PaymentMethodData::CardToken(_)) + Some(domain::PaymentMethodData::CardRedirect(_)) + | Some(domain::PaymentMethodData::Wallet(_)) + | Some(domain::PaymentMethodData::PayLater(_)) + | Some(domain::PaymentMethodData::BankRedirect(_)) + | Some(domain::PaymentMethodData::BankDebit(_)) + | Some(domain::PaymentMethodData::BankTransfer(_)) + | Some(domain::PaymentMethodData::Crypto(_)) + | Some(domain::PaymentMethodData::MandatePayment) + | Some(domain::PaymentMethodData::Reward) + | Some(domain::PaymentMethodData::Upi(_)) + | Some(domain::PaymentMethodData::Voucher(_)) + | Some(domain::PaymentMethodData::GiftCard(_)) + | Some(domain::PaymentMethodData::CardToken(_)) | None => { Err(errors::ConnectorError::NotImplemented("Tokenize Flow".to_string()).into()) } @@ -744,7 +743,7 @@ impl TryFrom<&types::TokenizationRouterData> for CaptureBuyerRequest { type Error = error_stack::Report; fn try_from(item: &types::TokenizationRouterData) -> Result { match item.request.payment_method_data.clone() { - api::PaymentMethodData::Card(req_card) => { + domain::PaymentMethodData::Card(req_card) => { let seller_payme_id = PaymeAuthType::try_from(&item.connector_auth_type)?.seller_payme_id; let card = PaymeCard { @@ -758,19 +757,19 @@ impl TryFrom<&types::TokenizationRouterData> for CaptureBuyerRequest { seller_payme_id, }) } - api::PaymentMethodData::Wallet(_) - | api::PaymentMethodData::CardRedirect(_) - | api::PaymentMethodData::PayLater(_) - | api::PaymentMethodData::BankRedirect(_) - | api::PaymentMethodData::BankDebit(_) - | api::PaymentMethodData::BankTransfer(_) - | api::PaymentMethodData::Crypto(_) - | api::PaymentMethodData::MandatePayment - | api::PaymentMethodData::Reward - | api::PaymentMethodData::Upi(_) - | api::PaymentMethodData::Voucher(_) - | api::PaymentMethodData::GiftCard(_) - | api::PaymentMethodData::CardToken(_) => { + domain::PaymentMethodData::Wallet(_) + | domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { Err(errors::ConnectorError::NotImplemented("Tokenize Flow".to_string()).into()) } } diff --git a/crates/router/src/connector/paypal/transformers.rs b/crates/router/src/connector/paypal/transformers.rs index 439184cafca7..aff3be9bd224 100644 --- a/crates/router/src/connector/paypal/transformers.rs +++ b/crates/router/src/connector/paypal/transformers.rs @@ -16,8 +16,8 @@ use crate::{ core::errors, services, types::{ - self, api, storage::enums as storage_enums, transformers::ForeignFrom, ConnectorAuthType, - VerifyWebhookSourceResponseData, + self, api, domain, storage::enums as storage_enums, transformers::ForeignFrom, + ConnectorAuthType, VerifyWebhookSourceResponseData, }, }; @@ -425,7 +425,7 @@ impl TryFrom<&PaypalRouterData<&types::PaymentsAuthorizeRouterData>> for PaypalP PaypalAuthType::try_from(&item.router_data.connector_auth_type)?; let payee = get_payee(&paypal_auth); match item.router_data.request.payment_method_data { - api_models::payments::PaymentMethodData::Card(ref ccard) => { + domain::PaymentMethodData::Card(ref ccard) => { let intent = if item.router_data.request.is_auto_capture()? { PaypalPaymentIntent::Capture } else { @@ -476,7 +476,7 @@ impl TryFrom<&PaypalRouterData<&types::PaymentsAuthorizeRouterData>> for PaypalP payment_source, }) } - api::PaymentMethodData::Wallet(ref wallet_data) => match wallet_data { + domain::PaymentMethodData::Wallet(ref wallet_data) => match wallet_data { api_models::payments::WalletData::PaypalRedirect(_) => { let intent = if item.router_data.request.is_auto_capture()? { PaypalPaymentIntent::Capture @@ -553,7 +553,7 @@ impl TryFrom<&PaypalRouterData<&types::PaymentsAuthorizeRouterData>> for PaypalP ))? } }, - api::PaymentMethodData::BankRedirect(ref bank_redirection_data) => { + domain::PaymentMethodData::BankRedirect(ref bank_redirection_data) => { let intent = if item.router_data.request.is_auto_capture()? { PaypalPaymentIntent::Capture } else { @@ -586,34 +586,30 @@ impl TryFrom<&PaypalRouterData<&types::PaymentsAuthorizeRouterData>> for PaypalP payment_source, }) } - api_models::payments::PaymentMethodData::CardRedirect(ref card_redirect_data) => { + domain::PaymentMethodData::CardRedirect(ref card_redirect_data) => { Self::try_from(card_redirect_data) } - api_models::payments::PaymentMethodData::PayLater(ref paylater_data) => { - Self::try_from(paylater_data) - } - api_models::payments::PaymentMethodData::BankDebit(ref bank_debit_data) => { + domain::PaymentMethodData::PayLater(ref paylater_data) => Self::try_from(paylater_data), + domain::PaymentMethodData::BankDebit(ref bank_debit_data) => { Self::try_from(bank_debit_data) } - api_models::payments::PaymentMethodData::BankTransfer(ref bank_transfer_data) => { + domain::PaymentMethodData::BankTransfer(ref bank_transfer_data) => { Self::try_from(bank_transfer_data.as_ref()) } - api_models::payments::PaymentMethodData::Voucher(ref voucher_data) => { - Self::try_from(voucher_data) - } - api_models::payments::PaymentMethodData::GiftCard(ref giftcard_data) => { + domain::PaymentMethodData::Voucher(ref voucher_data) => Self::try_from(voucher_data), + domain::PaymentMethodData::GiftCard(ref giftcard_data) => { Self::try_from(giftcard_data.as_ref()) } - api_models::payments::PaymentMethodData::MandatePayment => { + domain::PaymentMethodData::MandatePayment => { Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("Paypal"), ) .into()) } - api_models::payments::PaymentMethodData::Reward - | api_models::payments::PaymentMethodData::Crypto(_) - | api_models::payments::PaymentMethodData::Upi(_) - | api_models::payments::PaymentMethodData::CardToken(_) => { + domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::CardToken(_) => { Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("Paypal"), ) @@ -623,14 +619,14 @@ impl TryFrom<&PaypalRouterData<&types::PaymentsAuthorizeRouterData>> for PaypalP } } -impl TryFrom<&api_models::payments::CardRedirectData> for PaypalPaymentsRequest { +impl TryFrom<&domain::payments::CardRedirectData> for PaypalPaymentsRequest { type Error = error_stack::Report; - fn try_from(value: &api_models::payments::CardRedirectData) -> Result { + fn try_from(value: &domain::payments::CardRedirectData) -> Result { match value { - api_models::payments::CardRedirectData::Knet {} - | api_models::payments::CardRedirectData::Benefit {} - | api_models::payments::CardRedirectData::MomoAtm {} - | api_models::payments::CardRedirectData::CardRedirect {} => { + domain::payments::CardRedirectData::Knet {} + | domain::payments::CardRedirectData::Benefit {} + | domain::payments::CardRedirectData::MomoAtm {} + | domain::payments::CardRedirectData::CardRedirect {} => { Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("Paypal"), ) diff --git a/crates/router/src/connector/payu/transformers.rs b/crates/router/src/connector/payu/transformers.rs index 9484749ff22a..93add6f296bd 100644 --- a/crates/router/src/connector/payu/transformers.rs +++ b/crates/router/src/connector/payu/transformers.rs @@ -8,7 +8,7 @@ use crate::{ consts, core::errors, pii::Secret, - types::{self, api, storage::enums}, + types::{self, api, domain, storage::enums}, }; const WALLET_IDENTIFIER: &str = "PBL"; @@ -70,7 +70,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for PayuPaymentsRequest { fn try_from(item: &types::PaymentsAuthorizeRouterData) -> Result { let auth_type = PayuAuthType::try_from(&item.connector_auth_type)?; let payment_method = match item.request.payment_method_data.clone() { - api::PaymentMethodData::Card(ccard) => Ok(PayuPaymentMethod { + domain::PaymentMethodData::Card(ccard) => Ok(PayuPaymentMethod { pay_method: PayuPaymentMethodData::Card(PayuCard::Card { number: ccard.card_number, expiration_month: ccard.card_exp_month, @@ -78,7 +78,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for PayuPaymentsRequest { cvv: ccard.card_cvc, }), }), - api::PaymentMethodData::Wallet(wallet_data) => match wallet_data { + domain::PaymentMethodData::Wallet(wallet_data) => match wallet_data { api_models::payments::WalletData::GooglePay(data) => Ok(PayuPaymentMethod { pay_method: PayuPaymentMethodData::Wallet({ PayuWallet { diff --git a/crates/router/src/connector/placetopay/transformers.rs b/crates/router/src/connector/placetopay/transformers.rs index 152e315de18f..6ad3d3c20396 100644 --- a/crates/router/src/connector/placetopay/transformers.rs +++ b/crates/router/src/connector/placetopay/transformers.rs @@ -1,4 +1,3 @@ -use api_models::payments; use common_utils::date_time; use diesel_models::enums; use error_stack::ResultExt; @@ -13,7 +12,7 @@ use crate::{ }, consts, core::errors, - types::{self, api, storage::enums as storage_enums}, + types::{self, api, domain, storage::enums as storage_enums}, }; pub struct PlacetopayRouterData { @@ -126,7 +125,7 @@ impl TryFrom<&PlacetopayRouterData<&types::PaymentsAuthorizeRouterData>> }, }; match item.router_data.request.payment_method_data.clone() { - payments::PaymentMethodData::Card(req_card) => { + domain::PaymentMethodData::Card(req_card) => { let card = PlacetopayCard { number: req_card.card_number.clone(), expiration: req_card @@ -144,19 +143,19 @@ impl TryFrom<&PlacetopayRouterData<&types::PaymentsAuthorizeRouterData>> }, }) } - payments::PaymentMethodData::Wallet(_) - | payments::PaymentMethodData::CardRedirect(_) - | payments::PaymentMethodData::PayLater(_) - | payments::PaymentMethodData::BankRedirect(_) - | payments::PaymentMethodData::BankDebit(_) - | payments::PaymentMethodData::BankTransfer(_) - | payments::PaymentMethodData::Crypto(_) - | payments::PaymentMethodData::MandatePayment - | payments::PaymentMethodData::Reward - | payments::PaymentMethodData::Upi(_) - | payments::PaymentMethodData::Voucher(_) - | payments::PaymentMethodData::GiftCard(_) - | payments::PaymentMethodData::CardToken(_) => { + domain::PaymentMethodData::Wallet(_) + | domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("Placetopay"), ) diff --git a/crates/router/src/connector/powertranz/transformers.rs b/crates/router/src/connector/powertranz/transformers.rs index 26a8e4fc69e0..b8c20cf0fcce 100644 --- a/crates/router/src/connector/powertranz/transformers.rs +++ b/crates/router/src/connector/powertranz/transformers.rs @@ -1,4 +1,3 @@ -use api_models::payments::Card; use common_utils::pii::{Email, IpAddress}; use diesel_models::enums::RefundStatus; use masking::{ExposeInterface, Secret}; @@ -10,7 +9,7 @@ use crate::{ consts, core::errors, services, - types::{self, api, storage::enums, transformers::ForeignFrom}, + types::{self, api, domain, storage::enums, transformers::ForeignFrom}, }; const ISO_SUCCESS_CODES: [&str; 7] = ["00", "3D0", "3D1", "HP0", "TK0", "SP4", "FC0"]; @@ -100,24 +99,26 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for PowertranzPaymentsRequest type Error = error_stack::Report; fn try_from(item: &types::PaymentsAuthorizeRouterData) -> Result { let source = match item.request.payment_method_data.clone() { - api::PaymentMethodData::Card(card) => Source::try_from(&card), - api::PaymentMethodData::Wallet(_) - | api::PaymentMethodData::CardRedirect(_) - | api::PaymentMethodData::PayLater(_) - | api::PaymentMethodData::BankRedirect(_) - | api::PaymentMethodData::BankDebit(_) - | api::PaymentMethodData::BankTransfer(_) - | api::PaymentMethodData::Crypto(_) - | api::PaymentMethodData::MandatePayment - | api::PaymentMethodData::Reward - | api::PaymentMethodData::Upi(_) - | api::PaymentMethodData::Voucher(_) - | api::PaymentMethodData::GiftCard(_) - | api::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotSupported { - message: utils::SELECTED_PAYMENT_METHOD.to_string(), - connector: "powertranz", + domain::PaymentMethodData::Card(card) => Source::try_from(&card), + domain::PaymentMethodData::Wallet(_) + | domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { + Err(errors::ConnectorError::NotSupported { + message: utils::SELECTED_PAYMENT_METHOD.to_string(), + connector: "powertranz", + } + .into()) } - .into()), }?; // let billing_address = get_address_details(&item.address.billing, &item.request.email); // let shipping_address = get_address_details(&item.address.shipping, &item.request.email); @@ -212,9 +213,9 @@ impl TryFrom<&types::BrowserInformation> for BrowserInfo { }) }*/ -impl TryFrom<&Card> for Source { +impl TryFrom<&domain::Card> for Source { type Error = error_stack::Report; - fn try_from(card: &Card) -> Result { + fn try_from(card: &domain::Card) -> Result { let card = PowertranzCard { cardholder_name: card .card_holder_name diff --git a/crates/router/src/connector/prophetpay/transformers.rs b/crates/router/src/connector/prophetpay/transformers.rs index 06d23af33aff..570bf8d2b3a2 100644 --- a/crates/router/src/connector/prophetpay/transformers.rs +++ b/crates/router/src/connector/prophetpay/transformers.rs @@ -11,7 +11,7 @@ use crate::{ consts as const_val, core::errors, services, - types::{self, api, storage::enums}, + types::{self, api, domain, storage::enums}, }; pub struct ProphetpayRouterData { @@ -136,8 +136,8 @@ impl TryFrom<&ProphetpayRouterData<&types::PaymentsAuthorizeRouterData>> ) -> Result { if item.router_data.request.currency == api_models::enums::Currency::USD { match item.router_data.request.payment_method_data.clone() { - api::PaymentMethodData::CardRedirect( - api_models::payments::CardRedirectData::CardRedirect {}, + domain::PaymentMethodData::CardRedirect( + domain::payments::CardRedirectData::CardRedirect {}, ) => { let auth_data = ProphetpayAuthType::try_from(&item.router_data.connector_auth_type)?; diff --git a/crates/router/src/connector/rapyd/transformers.rs b/crates/router/src/connector/rapyd/transformers.rs index d51a322635cb..5d46148b01d0 100644 --- a/crates/router/src/connector/rapyd/transformers.rs +++ b/crates/router/src/connector/rapyd/transformers.rs @@ -9,7 +9,7 @@ use crate::{ core::errors, pii::Secret, services, - types::{self, api, storage::enums, transformers::ForeignFrom}, + types::{self, api, domain, storage::enums, transformers::ForeignFrom}, utils::OptionExt, }; @@ -124,7 +124,7 @@ impl TryFrom<&RapydRouterData<&types::PaymentsAuthorizeRouterData>> for RapydPay _ => (None, None), }; let payment_method = match item.router_data.request.payment_method_data { - api_models::payments::PaymentMethodData::Card(ref ccard) => { + domain::PaymentMethodData::Card(ref ccard) => { Some(PaymentMethod { pm_type: "in_amex_card".to_owned(), //[#369] Map payment method type based on country fields: Some(PaymentFields { @@ -141,7 +141,7 @@ impl TryFrom<&RapydRouterData<&types::PaymentsAuthorizeRouterData>> for RapydPay digital_wallet: None, }) } - api_models::payments::PaymentMethodData::Wallet(ref wallet_data) => { + domain::PaymentMethodData::Wallet(ref wallet_data) => { let digital_wallet = match wallet_data { api_models::payments::WalletData::GooglePay(data) => Some(RapydWallet { payment_type: "google_pay".to_string(), diff --git a/crates/router/src/connector/shift4/transformers.rs b/crates/router/src/connector/shift4/transformers.rs index 416dd8fd9d77..72a8e299b923 100644 --- a/crates/router/src/connector/shift4/transformers.rs +++ b/crates/router/src/connector/shift4/transformers.rs @@ -13,7 +13,7 @@ use crate::{ }, core::errors, pii, services, - types::{self, api, storage::enums, transformers::ForeignFrom}, + types::{self, api, domain, storage::enums, transformers::ForeignFrom}, }; type Error = error_stack::Report; @@ -148,26 +148,26 @@ impl TryFrom<&types::RouterData, ) -> Result { match item.request.payment_method_data { - payments::PaymentMethodData::Card(ref ccard) => Self::try_from((item, ccard)), - payments::PaymentMethodData::BankRedirect(ref redirect) => { + domain::PaymentMethodData::Card(ref ccard) => Self::try_from((item, ccard)), + domain::PaymentMethodData::BankRedirect(ref redirect) => { Self::try_from((item, redirect)) } - payments::PaymentMethodData::Wallet(ref wallet_data) => Self::try_from(wallet_data), - payments::PaymentMethodData::BankTransfer(ref bank_transfer_data) => { + domain::PaymentMethodData::Wallet(ref wallet_data) => Self::try_from(wallet_data), + domain::PaymentMethodData::BankTransfer(ref bank_transfer_data) => { Self::try_from(bank_transfer_data.as_ref()) } - payments::PaymentMethodData::Voucher(ref voucher_data) => Self::try_from(voucher_data), - payments::PaymentMethodData::GiftCard(ref giftcard_data) => { + domain::PaymentMethodData::Voucher(ref voucher_data) => Self::try_from(voucher_data), + domain::PaymentMethodData::GiftCard(ref giftcard_data) => { Self::try_from(giftcard_data.as_ref()) } - payments::PaymentMethodData::CardRedirect(_) - | payments::PaymentMethodData::PayLater(_) - | payments::PaymentMethodData::BankDebit(_) - | payments::PaymentMethodData::Crypto(_) - | payments::PaymentMethodData::MandatePayment - | payments::PaymentMethodData::Reward - | payments::PaymentMethodData::Upi(_) - | payments::PaymentMethodData::CardToken(_) => { + domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::CardToken(_) => { Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("Shift4"), ) @@ -282,14 +282,14 @@ impl TryFrom<&api_models::payments::GiftCardData> for Shift4PaymentMethod { impl TryFrom<( &types::RouterData, - &api_models::payments::Card, + &domain::Card, )> for Shift4PaymentMethod { type Error = Error; fn try_from( (item, card): ( &types::RouterData, - &api_models::payments::Card, + &domain::Card, ), ) -> Result { let card_object = Card { @@ -356,7 +356,7 @@ impl TryFrom<&types::RouterData, ) -> Result { match &item.request.payment_method_data { - Some(api::PaymentMethodData::Card(_)) => { + Some(domain::PaymentMethodData::Card(_)) => { let card_token: Shift4CardToken = to_connector_meta(item.request.connector_meta.clone())?; Ok(Self { @@ -371,19 +371,19 @@ impl TryFrom<&types::RouterData Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("Shift4"), ) diff --git a/crates/router/src/connector/square/transformers.rs b/crates/router/src/connector/square/transformers.rs index 064e8457403c..eb44cb2c919b 100644 --- a/crates/router/src/connector/square/transformers.rs +++ b/crates/router/src/connector/square/transformers.rs @@ -7,7 +7,7 @@ use crate::{ connector::utils::{self, CardData, PaymentsAuthorizeRequestData, RouterData}, core::errors, types::{ - self, api, + self, api, domain, storage::{self, enums}, }, unimplemented_payment_method, @@ -30,10 +30,10 @@ impl TryFrom<(&types::TokenizationRouterData, BankDebitData)> for SquareTokenReq } } -impl TryFrom<(&types::TokenizationRouterData, api_models::payments::Card)> for SquareTokenRequest { +impl TryFrom<(&types::TokenizationRouterData, domain::Card)> for SquareTokenRequest { type Error = error_stack::Report; fn try_from( - value: (&types::TokenizationRouterData, api_models::payments::Card), + value: (&types::TokenizationRouterData, domain::Card), ) -> Result { let (item, card_data) = value; let auth = SquareAuthType::try_from(&item.connector_auth_type) @@ -153,26 +153,28 @@ impl TryFrom<&types::TokenizationRouterData> for SquareTokenRequest { type Error = error_stack::Report; fn try_from(item: &types::TokenizationRouterData) -> Result { match item.request.payment_method_data.clone() { - api::PaymentMethodData::BankDebit(bank_debit_data) => { + domain::PaymentMethodData::BankDebit(bank_debit_data) => { Self::try_from((item, bank_debit_data)) } - api::PaymentMethodData::Card(card_data) => Self::try_from((item, card_data)), - api::PaymentMethodData::Wallet(wallet_data) => Self::try_from((item, wallet_data)), - api::PaymentMethodData::PayLater(pay_later_data) => { + domain::PaymentMethodData::Card(card_data) => Self::try_from((item, card_data)), + domain::PaymentMethodData::Wallet(wallet_data) => Self::try_from((item, wallet_data)), + domain::PaymentMethodData::PayLater(pay_later_data) => { Self::try_from((item, pay_later_data)) } - api::PaymentMethodData::GiftCard(_) - | api::PaymentMethodData::BankRedirect(_) - | api::PaymentMethodData::BankTransfer(_) - | api::PaymentMethodData::CardRedirect(_) - | api::PaymentMethodData::Crypto(_) - | api::PaymentMethodData::MandatePayment - | api::PaymentMethodData::Reward - | api::PaymentMethodData::Upi(_) - | api::PaymentMethodData::Voucher(_) - | api::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented( - utils::get_unimplemented_payment_method_error_message("Square"), - ))?, + domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::CardToken(_) => { + Err(errors::ConnectorError::NotImplemented( + utils::get_unimplemented_payment_method_error_message("Square"), + ))? + } } } } @@ -250,7 +252,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for SquarePaymentsRequest { fn try_from(item: &types::PaymentsAuthorizeRouterData) -> Result { let autocomplete = item.request.is_auto_capture()?; match item.request.payment_method_data.clone() { - api::PaymentMethodData::Card(_) => { + domain::PaymentMethodData::Card(_) => { let pm_token = item.get_payment_method_token()?; Ok(Self { idempotency_key: Secret::new(item.attempt_id.clone()), @@ -271,21 +273,23 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for SquarePaymentsRequest { }, }) } - api::PaymentMethodData::BankDebit(_) - | api::PaymentMethodData::GiftCard(_) - | api::PaymentMethodData::PayLater(_) - | api::PaymentMethodData::Wallet(_) - | api::PaymentMethodData::BankRedirect(_) - | api::PaymentMethodData::BankTransfer(_) - | api::PaymentMethodData::CardRedirect(_) - | api::PaymentMethodData::Crypto(_) - | api::PaymentMethodData::MandatePayment - | api::PaymentMethodData::Reward - | api::PaymentMethodData::Upi(_) - | api::PaymentMethodData::Voucher(_) - | api::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented( - utils::get_unimplemented_payment_method_error_message("Square"), - ))?, + domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::Wallet(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::CardToken(_) => { + Err(errors::ConnectorError::NotImplemented( + utils::get_unimplemented_payment_method_error_message("Square"), + ))? + } } } } diff --git a/crates/router/src/connector/stax/transformers.rs b/crates/router/src/connector/stax/transformers.rs index 1d7cc63a9379..b8ba6416a024 100644 --- a/crates/router/src/connector/stax/transformers.rs +++ b/crates/router/src/connector/stax/transformers.rs @@ -8,7 +8,7 @@ use crate::{ self, missing_field_err, CardData, PaymentsAuthorizeRequestData, RouterData, }, core::errors, - types::{self, api, storage::enums}, + types::{self, api, domain, storage::enums}, unimplemented_payment_method, }; @@ -71,7 +71,7 @@ impl TryFrom<&StaxRouterData<&types::PaymentsAuthorizeRouterData>> for StaxPayme let total = item.amount; match item.router_data.request.payment_method_data.clone() { - api::PaymentMethodData::Card(_) => { + domain::PaymentMethodData::Card(_) => { let pm_token = item.router_data.get_payment_method_token()?; let pre_auth = !item.router_data.request.is_auto_capture()?; Ok(Self { @@ -88,7 +88,7 @@ impl TryFrom<&StaxRouterData<&types::PaymentsAuthorizeRouterData>> for StaxPayme idempotency_id: Some(item.router_data.connector_request_reference_id.clone()), }) } - api::PaymentMethodData::BankDebit( + domain::PaymentMethodData::BankDebit( api_models::payments::BankDebitData::AchBankDebit { .. }, ) => { let pm_token = item.router_data.get_payment_method_token()?; @@ -107,21 +107,23 @@ impl TryFrom<&StaxRouterData<&types::PaymentsAuthorizeRouterData>> for StaxPayme idempotency_id: Some(item.router_data.connector_request_reference_id.clone()), }) } - api::PaymentMethodData::BankDebit(_) - | api::PaymentMethodData::Wallet(_) - | api::PaymentMethodData::PayLater(_) - | api::PaymentMethodData::BankRedirect(_) - | api::PaymentMethodData::BankTransfer(_) - | api::PaymentMethodData::Crypto(_) - | api::PaymentMethodData::MandatePayment - | api::PaymentMethodData::Reward - | api::PaymentMethodData::Voucher(_) - | api::PaymentMethodData::GiftCard(_) - | api::PaymentMethodData::CardRedirect(_) - | api::PaymentMethodData::Upi(_) - | api::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented( - utils::get_unimplemented_payment_method_error_message("Stax"), - ))?, + domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::Wallet(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::CardToken(_) => { + Err(errors::ConnectorError::NotImplemented( + utils::get_unimplemented_payment_method_error_message("Stax"), + ))? + } } } } @@ -223,7 +225,7 @@ impl TryFrom<&types::TokenizationRouterData> for StaxTokenRequest { fn try_from(item: &types::TokenizationRouterData) -> Result { let customer_id = item.get_connector_customer_id()?; match item.request.payment_method_data.clone() { - api::PaymentMethodData::Card(card_data) => { + domain::PaymentMethodData::Card(card_data) => { let stax_card_data = StaxTokenizeData { card_exp: card_data .get_card_expiry_month_year_2_digit_with_delimiter("".to_string())?, @@ -236,7 +238,7 @@ impl TryFrom<&types::TokenizationRouterData> for StaxTokenRequest { }; Ok(Self::Card(stax_card_data)) } - api_models::payments::PaymentMethodData::BankDebit( + domain::PaymentMethodData::BankDebit( api_models::payments::BankDebitData::AchBankDebit { billing_details, account_number, @@ -259,21 +261,23 @@ impl TryFrom<&types::TokenizationRouterData> for StaxTokenRequest { }; Ok(Self::Bank(stax_bank_data)) } - api::PaymentMethodData::BankDebit(_) - | api::PaymentMethodData::Wallet(_) - | api::PaymentMethodData::PayLater(_) - | api::PaymentMethodData::BankRedirect(_) - | api::PaymentMethodData::BankTransfer(_) - | api::PaymentMethodData::Crypto(_) - | api::PaymentMethodData::MandatePayment - | api::PaymentMethodData::Reward - | api::PaymentMethodData::Voucher(_) - | api::PaymentMethodData::GiftCard(_) - | api::PaymentMethodData::CardRedirect(_) - | api::PaymentMethodData::Upi(_) - | api::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented( - utils::get_unimplemented_payment_method_error_message("Stax"), - ))?, + domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::Wallet(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::CardToken(_) => { + Err(errors::ConnectorError::NotImplemented( + utils::get_unimplemented_payment_method_error_message("Stax"), + ))? + } } } } diff --git a/crates/router/src/connector/stripe.rs b/crates/router/src/connector/stripe.rs index a3cf0d5c8379..c966a224611d 100644 --- a/crates/router/src/connector/stripe.rs +++ b/crates/router/src/connector/stripe.rs @@ -28,6 +28,7 @@ use crate::{ types::{ self, api::{self, ConnectorCommon}, + domain, }, utils::{crypto, ByteSliceExt, BytesExt, OptionExt}, }; @@ -822,7 +823,7 @@ impl connectors: &settings::Connectors, ) -> CustomResult { match &req.request.payment_method_data { - api_models::payments::PaymentMethodData::BankTransfer(bank_transfer_data) => { + domain::payments::PaymentMethodData::BankTransfer(bank_transfer_data) => { match bank_transfer_data.deref() { api_models::payments::BankTransferData::AchBankTransfer { .. } | api_models::payments::BankTransferData::MultibancoBankTransfer { .. } => { @@ -849,7 +850,7 @@ impl _connectors: &settings::Connectors, ) -> CustomResult { match &req.request.payment_method_data { - api_models::payments::PaymentMethodData::BankTransfer(bank_transfer_data) => { + domain::payments::PaymentMethodData::BankTransfer(bank_transfer_data) => { stripe::get_bank_transfer_request_data(req, bank_transfer_data.deref()) } _ => { @@ -889,7 +890,7 @@ impl res: types::Response, ) -> CustomResult { match &data.request.payment_method_data { - api_models::payments::PaymentMethodData::BankTransfer(bank_transfer_data) => { + domain::payments::PaymentMethodData::BankTransfer(bank_transfer_data) => { match bank_transfer_data.deref() { api_models::payments::BankTransferData::AchBankTransfer { .. } | api_models::payments::BankTransferData::MultibancoBankTransfer { .. } => { diff --git a/crates/router/src/connector/stripe/transformers.rs b/crates/router/src/connector/stripe/transformers.rs index 95d9b6dd9063..4673cce4d814 100644 --- a/crates/router/src/connector/stripe/transformers.rs +++ b/crates/router/src/connector/stripe/transformers.rs @@ -25,7 +25,7 @@ use crate::{ core::errors, services, types::{ - self, api, + self, api, domain, storage::enums, transformers::{ForeignFrom, ForeignTryFrom}, }, @@ -1273,7 +1273,7 @@ fn get_bank_debit_data( } fn create_stripe_payment_method( - payment_method_data: &api_models::payments::PaymentMethodData, + payment_method_data: &domain::PaymentMethodData, auth_type: enums::AuthenticationType, payment_method_token: Option, is_customer_initiated_mandate_payment: Option, @@ -1287,7 +1287,7 @@ fn create_stripe_payment_method( error_stack::Report, > { match payment_method_data { - payments::PaymentMethodData::Card(card_details) => { + domain::PaymentMethodData::Card(card_details) => { let payment_method_auth_type = match auth_type { enums::AuthenticationType::ThreeDs => Auth3ds::Any, enums::AuthenticationType::NoThreeDs => Auth3ds::Automatic, @@ -1298,7 +1298,7 @@ fn create_stripe_payment_method( billing_address, )) } - payments::PaymentMethodData::PayLater(pay_later_data) => { + domain::PaymentMethodData::PayLater(pay_later_data) => { let stripe_pm_type = StripePaymentMethodType::try_from(pay_later_data)?; let billing_address = StripeBillingAddress::try_from((pay_later_data, stripe_pm_type))?; Ok(( @@ -1309,7 +1309,7 @@ fn create_stripe_payment_method( billing_address, )) } - payments::PaymentMethodData::BankRedirect(bank_redirect_data) => { + domain::PaymentMethodData::BankRedirect(bank_redirect_data) => { let billing_address = StripeBillingAddress::try_from(( bank_redirect_data, is_customer_initiated_mandate_payment, @@ -1319,7 +1319,7 @@ fn create_stripe_payment_method( Ok((bank_redirect_data, Some(pm_type), billing_address)) } - payments::PaymentMethodData::Wallet(wallet_data) => { + domain::PaymentMethodData::Wallet(wallet_data) => { let pm_type = ForeignTryFrom::foreign_try_from(wallet_data)?; let wallet_specific_data = StripePaymentMethodData::try_from((wallet_data, payment_method_token))?; @@ -1329,7 +1329,7 @@ fn create_stripe_payment_method( StripeBillingAddress::default(), )) } - payments::PaymentMethodData::BankDebit(bank_debit_data) => { + domain::PaymentMethodData::BankDebit(bank_debit_data) => { let (pm_type, bank_debit_data, billing_address) = get_bank_debit_data(bank_debit_data); let pm_data = StripePaymentMethodData::BankDebit(StripeBankDebitData { @@ -1338,7 +1338,7 @@ fn create_stripe_payment_method( Ok((pm_data, Some(pm_type), billing_address)) } - payments::PaymentMethodData::BankTransfer(bank_transfer_data) => { + domain::PaymentMethodData::BankTransfer(bank_transfer_data) => { match bank_transfer_data.deref() { payments::BankTransferData::AchBankTransfer { billing_details } => Ok(( StripePaymentMethodData::BankTransfer(StripeBankTransferData::AchBankTransfer( @@ -1427,12 +1427,12 @@ fn create_stripe_payment_method( } } } - payments::PaymentMethodData::Crypto(_) => Err(errors::ConnectorError::NotImplemented( + domain::PaymentMethodData::Crypto(_) => Err(errors::ConnectorError::NotImplemented( connector_util::get_unimplemented_payment_method_error_message("stripe"), ) .into()), - payments::PaymentMethodData::GiftCard(giftcard_data) => match giftcard_data.deref() { + domain::PaymentMethodData::GiftCard(giftcard_data) => match giftcard_data.deref() { payments::GiftCardData::Givex(_) | payments::GiftCardData::PaySafeCard {} => { Err(errors::ConnectorError::NotImplemented( connector_util::get_unimplemented_payment_method_error_message("stripe"), @@ -1440,24 +1440,23 @@ fn create_stripe_payment_method( .into()) } }, - - payments::PaymentMethodData::CardRedirect(cardredirect_data) => match cardredirect_data { - payments::CardRedirectData::Knet {} - | payments::CardRedirectData::Benefit {} - | payments::CardRedirectData::MomoAtm {} - | payments::CardRedirectData::CardRedirect {} => { + domain::PaymentMethodData::CardRedirect(cardredirect_data) => match cardredirect_data { + domain::CardRedirectData::Knet {} + | domain::CardRedirectData::Benefit {} + | domain::CardRedirectData::MomoAtm {} + | domain::CardRedirectData::CardRedirect {} => { Err(errors::ConnectorError::NotImplemented( connector_util::get_unimplemented_payment_method_error_message("stripe"), ) .into()) } }, - payments::PaymentMethodData::Reward => Err(errors::ConnectorError::NotImplemented( + domain::PaymentMethodData::Reward => Err(errors::ConnectorError::NotImplemented( connector_util::get_unimplemented_payment_method_error_message("stripe"), ) .into()), - payments::PaymentMethodData::Voucher(voucher_data) => match voucher_data { + domain::PaymentMethodData::Voucher(voucher_data) => match voucher_data { payments::VoucherData::Boleto(_) | payments::VoucherData::Oxxo => { Err(errors::ConnectorError::NotImplemented( connector_util::get_unimplemented_payment_method_error_message("stripe"), @@ -1481,19 +1480,19 @@ fn create_stripe_payment_method( .into()), }, - payments::PaymentMethodData::Upi(_) - | payments::PaymentMethodData::MandatePayment - | payments::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented( + domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented( connector_util::get_unimplemented_payment_method_error_message("stripe"), ) .into()), } } -impl TryFrom<(&payments::Card, Auth3ds)> for StripePaymentMethodData { +impl TryFrom<(&domain::Card, Auth3ds)> for StripePaymentMethodData { type Error = errors::ConnectorError; fn try_from( - (card, payment_method_auth_type): (&payments::Card, Auth3ds), + (card, payment_method_auth_type): (&domain::Card, Auth3ds), ) -> Result { Ok(Self::Card(StripeCardData { payment_method_data_type: StripePaymentMethodType::Card, @@ -1858,7 +1857,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for PaymentIntentRequest { }; payment_data = match item.request.payment_method_data { - payments::PaymentMethodData::Wallet(payments::WalletData::ApplePay(_)) => { + domain::PaymentMethodData::Wallet(payments::WalletData::ApplePay(_)) => { let payment_method_token = item .payment_method_token .to_owned() @@ -3188,7 +3187,7 @@ impl TryFrom<&types::PaymentsPreProcessingRouterData> for StripeCreditTransferSo let currency = item.request.get_currency()?; match &item.request.payment_method_data { - Some(payments::PaymentMethodData::BankTransfer(bank_transfer_data)) => { + Some(domain::PaymentMethodData::BankTransfer(bank_transfer_data)) => { match **bank_transfer_data { payments::BankTransferData::MultibancoBankTransfer { .. } => Ok( Self::MultibancoBankTansfer(MultibancoCreditTransferSourceRequest { @@ -3230,19 +3229,19 @@ impl TryFrom<&types::PaymentsPreProcessingRouterData> for StripeCreditTransferSo } } } - Some(payments::PaymentMethodData::Card(..)) - | Some(payments::PaymentMethodData::Wallet(..)) - | Some(payments::PaymentMethodData::BankDebit(..)) - | Some(payments::PaymentMethodData::BankRedirect(..)) - | Some(payments::PaymentMethodData::PayLater(..)) - | Some(payments::PaymentMethodData::Crypto(..)) - | Some(payments::PaymentMethodData::Reward) - | Some(payments::PaymentMethodData::MandatePayment) - | Some(payments::PaymentMethodData::Upi(..)) - | Some(payments::PaymentMethodData::GiftCard(..)) - | Some(payments::PaymentMethodData::CardRedirect(..)) - | Some(payments::PaymentMethodData::Voucher(..)) - | Some(payments::PaymentMethodData::CardToken(..)) + Some(domain::PaymentMethodData::Card(..)) + | Some(domain::PaymentMethodData::Wallet(..)) + | Some(domain::PaymentMethodData::BankDebit(..)) + | Some(domain::PaymentMethodData::BankRedirect(..)) + | Some(domain::PaymentMethodData::PayLater(..)) + | Some(domain::PaymentMethodData::Crypto(..)) + | Some(domain::PaymentMethodData::Reward) + | Some(domain::PaymentMethodData::MandatePayment) + | Some(domain::PaymentMethodData::Upi(..)) + | Some(domain::PaymentMethodData::GiftCard(..)) + | Some(domain::PaymentMethodData::CardRedirect(..)) + | Some(domain::PaymentMethodData::Voucher(..)) + | Some(domain::PaymentMethodData::CardToken(..)) | None => Err(errors::ConnectorError::NotImplemented( connector_util::get_unimplemented_payment_method_error_message("stripe"), ) @@ -3595,7 +3594,7 @@ pub struct EvidenceDetails { impl TryFrom<( - api::PaymentMethodData, + domain::PaymentMethodData, enums::AuthenticationType, StripePaymentMethodType, )> for StripePaymentMethodData @@ -3603,98 +3602,98 @@ impl type Error = error_stack::Report; fn try_from( (pm_data, auth_type, pm_type): ( - api::PaymentMethodData, + domain::PaymentMethodData, enums::AuthenticationType, StripePaymentMethodType, ), ) -> Result { match pm_data { - api::PaymentMethodData::Card(ref ccard) => { + domain::PaymentMethodData::Card(ref ccard) => { let payment_method_auth_type = match auth_type { enums::AuthenticationType::ThreeDs => Auth3ds::Any, enums::AuthenticationType::NoThreeDs => Auth3ds::Automatic, }; Ok(Self::try_from((ccard, payment_method_auth_type))?) } - api::PaymentMethodData::PayLater(_) => Ok(Self::PayLater(StripePayLaterData { + domain::PaymentMethodData::PayLater(_) => Ok(Self::PayLater(StripePayLaterData { payment_method_data_type: pm_type, })), - api::PaymentMethodData::BankRedirect(ref bank_redirect_data) => { + domain::PaymentMethodData::BankRedirect(ref bank_redirect_data) => { Ok(Self::try_from(bank_redirect_data)?) } - payments::PaymentMethodData::Wallet(ref wallet_data) => { + domain::PaymentMethodData::Wallet(ref wallet_data) => { Ok(Self::try_from((wallet_data, None))?) } - api::PaymentMethodData::BankDebit(bank_debit_data) => { + domain::PaymentMethodData::BankDebit(bank_debit_data) => { let (_pm_type, bank_data, _) = get_bank_debit_data(&bank_debit_data); Ok(Self::BankDebit(StripeBankDebitData { bank_specific_data: bank_data, })) } - api::PaymentMethodData::BankTransfer(bank_transfer_data) => { - match bank_transfer_data.deref() { - payments::BankTransferData::AchBankTransfer { billing_details } => { - Ok(Self::BankTransfer(StripeBankTransferData::AchBankTransfer( - Box::new(AchTransferData { - email: billing_details.email.to_owned(), - }), - ))) - } - payments::BankTransferData::MultibancoBankTransfer { billing_details } => Ok( - Self::BankTransfer(StripeBankTransferData::MultibancoBankTransfers( - Box::new(MultibancoTransferData { - email: billing_details.email.to_owned(), - }), - )), - ), - payments::BankTransferData::SepaBankTransfer { country, .. } => Ok( - Self::BankTransfer(StripeBankTransferData::SepaBankTransfer(Box::new( - SepaBankTransferData { - payment_method_data_type: StripePaymentMethodType::CustomerBalance, - bank_transfer_type: BankTransferType::EuBankTransfer, - balance_funding_type: BankTransferType::BankTransfers, - payment_method_type: StripePaymentMethodType::CustomerBalance, - country: country.to_owned(), - }, - ))), - ), - payments::BankTransferData::BacsBankTransfer { .. } => Ok(Self::BankTransfer( - StripeBankTransferData::BacsBankTransfers(Box::new(BacsBankTransferData { + domain::PaymentMethodData::BankTransfer(bank_transfer_data) => match bank_transfer_data + .deref() + { + payments::BankTransferData::AchBankTransfer { billing_details } => { + Ok(Self::BankTransfer(StripeBankTransferData::AchBankTransfer( + Box::new(AchTransferData { + email: billing_details.email.to_owned(), + }), + ))) + } + payments::BankTransferData::MultibancoBankTransfer { billing_details } => Ok( + Self::BankTransfer(StripeBankTransferData::MultibancoBankTransfers(Box::new( + MultibancoTransferData { + email: billing_details.email.to_owned(), + }, + ))), + ), + payments::BankTransferData::SepaBankTransfer { country, .. } => { + Ok(Self::BankTransfer( + StripeBankTransferData::SepaBankTransfer(Box::new(SepaBankTransferData { payment_method_data_type: StripePaymentMethodType::CustomerBalance, - bank_transfer_type: BankTransferType::GbBankTransfer, + bank_transfer_type: BankTransferType::EuBankTransfer, balance_funding_type: BankTransferType::BankTransfers, payment_method_type: StripePaymentMethodType::CustomerBalance, + country: country.to_owned(), })), - )), - payments::BankTransferData::Pix {} - | payments::BankTransferData::Pse {} - | payments::BankTransferData::PermataBankTransfer { .. } - | payments::BankTransferData::BcaBankTransfer { .. } - | payments::BankTransferData::BniVaBankTransfer { .. } - | payments::BankTransferData::BriVaBankTransfer { .. } - | payments::BankTransferData::CimbVaBankTransfer { .. } - | payments::BankTransferData::DanamonVaBankTransfer { .. } - | payments::BankTransferData::MandiriVaBankTransfer { .. } => { - Err(errors::ConnectorError::NotImplemented( - connector_util::get_unimplemented_payment_method_error_message( - "stripe", - ), - ) - .into()) - } + )) + } + payments::BankTransferData::BacsBankTransfer { .. } => Ok(Self::BankTransfer( + StripeBankTransferData::BacsBankTransfers(Box::new(BacsBankTransferData { + payment_method_data_type: StripePaymentMethodType::CustomerBalance, + bank_transfer_type: BankTransferType::GbBankTransfer, + balance_funding_type: BankTransferType::BankTransfers, + payment_method_type: StripePaymentMethodType::CustomerBalance, + })), + )), + payments::BankTransferData::Pix {} + | payments::BankTransferData::Pse {} + | payments::BankTransferData::PermataBankTransfer { .. } + | payments::BankTransferData::BcaBankTransfer { .. } + | payments::BankTransferData::BniVaBankTransfer { .. } + | payments::BankTransferData::BriVaBankTransfer { .. } + | payments::BankTransferData::CimbVaBankTransfer { .. } + | payments::BankTransferData::DanamonVaBankTransfer { .. } + | payments::BankTransferData::MandiriVaBankTransfer { .. } => { + Err(errors::ConnectorError::NotImplemented( + connector_util::get_unimplemented_payment_method_error_message("stripe"), + ) + .into()) } + }, + domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::CardToken(_) => { + Err(errors::ConnectorError::NotImplemented( + connector_util::get_unimplemented_payment_method_error_message("stripe"), + ))? } - api::PaymentMethodData::MandatePayment - | api::PaymentMethodData::Crypto(_) - | api::PaymentMethodData::Reward - | api::PaymentMethodData::GiftCard(_) - | api::PaymentMethodData::Upi(_) - | api::PaymentMethodData::CardRedirect(_) - | api::PaymentMethodData::Voucher(_) - | api::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented( - connector_util::get_unimplemented_payment_method_error_message("stripe"), - ))?, } } } diff --git a/crates/router/src/connector/threedsecureio/transformers.rs b/crates/router/src/connector/threedsecureio/transformers.rs index 2d662e5e30f8..f119be9ccf43 100644 --- a/crates/router/src/connector/threedsecureio/transformers.rs +++ b/crates/router/src/connector/threedsecureio/transformers.rs @@ -18,6 +18,7 @@ use crate::{ self, api::{self, MessageCategory}, authentication::ChallengeParams, + domain, }, utils::OptionExt, }; @@ -244,10 +245,10 @@ impl TryFrom<&types::ConnectorAuthType> for ThreedsecureioAuthType { } fn get_card_details( - payment_method_data: api_models::payments::PaymentMethodData, -) -> Result { + payment_method_data: domain::PaymentMethodData, +) -> Result { match payment_method_data { - api_models::payments::PaymentMethodData::Card(details) => Ok(details), + domain::PaymentMethodData::Card(details) => Ok(details), _ => Err(errors::ConnectorError::NotSupported { message: SELECTED_PAYMENT_METHOD.to_string(), connector: "threedsecureio", diff --git a/crates/router/src/connector/trustpay/transformers.rs b/crates/router/src/connector/trustpay/transformers.rs index d898bd248967..e7e9a759d57b 100644 --- a/crates/router/src/connector/trustpay/transformers.rs +++ b/crates/router/src/connector/trustpay/transformers.rs @@ -18,7 +18,7 @@ use crate::{ consts, core::errors, services, - types::{self, api, storage::enums, BrowserInformation}, + types::{self, domain, storage::enums, BrowserInformation}, }; type Error = error_stack::Report; @@ -281,7 +281,7 @@ fn get_card_request_data( browser_info: &BrowserInformation, params: TrustpayMandatoryParams, amount: String, - ccard: &api_models::payments::Card, + ccard: &domain::payments::Card, return_url: String, ) -> Result { let email = item.request.get_email()?; @@ -418,7 +418,7 @@ impl TryFrom<&TrustpayRouterData<&types::PaymentsAuthorizeRouterData>> for Trust let auth = TrustpayAuthType::try_from(&item.router_data.connector_auth_type) .change_context(errors::ConnectorError::FailedToObtainAuthType)?; match item.router_data.request.payment_method_data { - api::PaymentMethodData::Card(ref ccard) => Ok(get_card_request_data( + domain::PaymentMethodData::Card(ref ccard) => Ok(get_card_request_data( item.router_data, &default_browser_info, params, @@ -426,7 +426,7 @@ impl TryFrom<&TrustpayRouterData<&types::PaymentsAuthorizeRouterData>> for Trust ccard, item.router_data.request.get_return_url()?, )?), - api::PaymentMethodData::BankRedirect(ref bank_redirection_data) => { + domain::PaymentMethodData::BankRedirect(ref bank_redirection_data) => { get_bank_redirection_request_data( item.router_data, bank_redirection_data, @@ -435,21 +435,23 @@ impl TryFrom<&TrustpayRouterData<&types::PaymentsAuthorizeRouterData>> for Trust auth, ) } - api::PaymentMethodData::CardRedirect(_) - | api::PaymentMethodData::Wallet(_) - | api::PaymentMethodData::PayLater(_) - | api::PaymentMethodData::BankDebit(_) - | api::PaymentMethodData::BankTransfer(_) - | api::PaymentMethodData::Crypto(_) - | api::PaymentMethodData::MandatePayment - | api::PaymentMethodData::Reward - | api::PaymentMethodData::Upi(_) - | api::PaymentMethodData::Voucher(_) - | api::PaymentMethodData::GiftCard(_) - | api::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented( - utils::get_unimplemented_payment_method_error_message("trustpay"), - ) - .into()), + domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::Wallet(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { + Err(errors::ConnectorError::NotImplemented( + utils::get_unimplemented_payment_method_error_message("trustpay"), + ) + .into()) + } } } } diff --git a/crates/router/src/connector/tsys/transformers.rs b/crates/router/src/connector/tsys/transformers.rs index a01576bbb202..6ffe1f1ed7f8 100644 --- a/crates/router/src/connector/tsys/transformers.rs +++ b/crates/router/src/connector/tsys/transformers.rs @@ -6,7 +6,7 @@ use crate::{ connector::utils::{self, CardData, PaymentsAuthorizeRequestData, RefundsRequestData}, core::errors, types::{ - self, api, + self, api, domain, storage::{self, enums}, }, }; @@ -41,7 +41,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for TsysPaymentsRequest { type Error = error_stack::Report; fn try_from(item: &types::PaymentsAuthorizeRouterData) -> Result { match item.request.payment_method_data.clone() { - api::PaymentMethodData::Card(ccard) => { + domain::PaymentMethodData::Card(ccard) => { let connector_auth: TsysAuthType = TsysAuthType::try_from(&item.connector_auth_type)?; let auth_data: TsysPaymentAuthSaleRequest = TsysPaymentAuthSaleRequest { @@ -66,21 +66,23 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for TsysPaymentsRequest { Ok(Self::Auth(auth_data)) } } - api::PaymentMethodData::CardRedirect(_) - | api::PaymentMethodData::Wallet(_) - | api::PaymentMethodData::PayLater(_) - | api::PaymentMethodData::BankRedirect(_) - | api::PaymentMethodData::BankDebit(_) - | api::PaymentMethodData::BankTransfer(_) - | api::PaymentMethodData::Crypto(_) - | api::PaymentMethodData::MandatePayment - | api::PaymentMethodData::Reward - | api::PaymentMethodData::Upi(_) - | api::PaymentMethodData::Voucher(_) - | api::PaymentMethodData::GiftCard(_) - | api::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented( - utils::get_unimplemented_payment_method_error_message("tsys"), - ))?, + domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::Wallet(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { + Err(errors::ConnectorError::NotImplemented( + utils::get_unimplemented_payment_method_error_message("tsys"), + ))? + } } } } diff --git a/crates/router/src/connector/utils.rs b/crates/router/src/connector/utils.rs index 804ad3ef3d00..37f06ad9ce1b 100644 --- a/crates/router/src/connector/utils.rs +++ b/crates/router/src/connector/utils.rs @@ -29,8 +29,8 @@ use crate::{ }, pii::PeekInterface, types::{ - self, api, transformers::ForeignTryFrom, ApplePayPredecryptData, BrowserInformation, - PaymentsCancelData, ResponseId, + self, api, domain, transformers::ForeignTryFrom, ApplePayPredecryptData, + BrowserInformation, PaymentsCancelData, ResponseId, }, utils::{OptionExt, ValueExt}, }; @@ -477,7 +477,7 @@ pub trait PaymentsAuthorizeRequestData { fn get_email(&self) -> Result; fn get_browser_info(&self) -> Result; fn get_order_details(&self) -> Result, Error>; - fn get_card(&self) -> Result; + fn get_card(&self) -> Result; fn get_return_url(&self) -> Result; fn connector_mandate_id(&self) -> Option; fn is_mandate_payment(&self) -> bool; @@ -530,9 +530,9 @@ impl PaymentsAuthorizeRequestData for types::PaymentsAuthorizeData { .ok_or_else(missing_field_err("order_details")) } - fn get_card(&self) -> Result { + fn get_card(&self) -> Result { match self.payment_method_data.clone() { - api::PaymentMethodData::Card(card) => Ok(card), + domain::PaymentMethodData::Card(card) => Ok(card), _ => Err(missing_field_err("card")()), } } @@ -577,10 +577,13 @@ impl PaymentsAuthorizeRequestData for types::PaymentsAuthorizeData { .ok_or_else(missing_field_err("return_url")) } fn is_wallet(&self) -> bool { - matches!(self.payment_method_data, api::PaymentMethodData::Wallet(_)) + matches!( + self.payment_method_data, + domain::PaymentMethodData::Wallet(_) + ) } fn is_card(&self) -> bool { - matches!(self.payment_method_data, api::PaymentMethodData::Card(_)) + matches!(self.payment_method_data, domain::PaymentMethodData::Card(_)) } fn get_payment_method_type(&self) -> Result { @@ -903,7 +906,7 @@ pub trait CardData { fn get_expiry_year_as_i32(&self) -> Result, Error>; } -impl CardData for api::Card { +impl CardData for domain::Card { fn get_card_expiry_year_2_digit(&self) -> Result, errors::ConnectorError> { let binding = self.card_exp_year.clone(); let year = binding.peek(); diff --git a/crates/router/src/connector/volt/transformers.rs b/crates/router/src/connector/volt/transformers.rs index 317f40216f8b..47c29767d82e 100644 --- a/crates/router/src/connector/volt/transformers.rs +++ b/crates/router/src/connector/volt/transformers.rs @@ -8,7 +8,7 @@ use crate::{ consts, core::errors, services, - types::{self, api, storage::enums as storage_enums}, + types::{self, api, domain, storage::enums as storage_enums}, }; const PASSWORD: &str = "password"; @@ -87,7 +87,7 @@ impl TryFrom<&VoltRouterData<&types::PaymentsAuthorizeRouterData>> for VoltPayme item: &VoltRouterData<&types::PaymentsAuthorizeRouterData>, ) -> Result { match item.router_data.request.payment_method_data.clone() { - api::PaymentMethodData::BankRedirect(ref bank_redirect) => match bank_redirect { + domain::PaymentMethodData::BankRedirect(ref bank_redirect) => match bank_redirect { api_models::payments::BankRedirectData::OpenBankingUk { .. } => { let amount = item.amount; let currency_code = item.router_data.request.currency; @@ -140,19 +140,19 @@ impl TryFrom<&VoltRouterData<&types::PaymentsAuthorizeRouterData>> for VoltPayme .into()) } }, - api_models::payments::PaymentMethodData::Card(_) - | api_models::payments::PaymentMethodData::CardRedirect(_) - | api_models::payments::PaymentMethodData::Wallet(_) - | api_models::payments::PaymentMethodData::PayLater(_) - | api_models::payments::PaymentMethodData::BankDebit(_) - | api_models::payments::PaymentMethodData::BankTransfer(_) - | api_models::payments::PaymentMethodData::Crypto(_) - | api_models::payments::PaymentMethodData::MandatePayment - | api_models::payments::PaymentMethodData::Reward - | api_models::payments::PaymentMethodData::Upi(_) - | api_models::payments::PaymentMethodData::Voucher(_) - | api_models::payments::PaymentMethodData::GiftCard(_) - | api_models::payments::PaymentMethodData::CardToken(_) => { + domain::PaymentMethodData::Card(_) + | domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::Wallet(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("Volt"), ) diff --git a/crates/router/src/connector/worldline/transformers.rs b/crates/router/src/connector/worldline/transformers.rs index 85d7afd8e4a3..9a8297dd3253 100644 --- a/crates/router/src/connector/worldline/transformers.rs +++ b/crates/router/src/connector/worldline/transformers.rs @@ -11,6 +11,7 @@ use crate::{ types::{ self, api::{self, enums as api_enums}, + domain, storage::enums, transformers::ForeignFrom, PaymentsAuthorizeData, PaymentsResponseData, @@ -236,31 +237,33 @@ impl >, ) -> Result { let payment_data = match &item.router_data.request.payment_method_data { - api::PaymentMethodData::Card(card) => { + domain::PaymentMethodData::Card(card) => { WorldlinePaymentMethod::CardPaymentMethodSpecificInput(Box::new(make_card_request( &item.router_data.request, card, )?)) } - api::PaymentMethodData::BankRedirect(bank_redirect) => { + domain::PaymentMethodData::BankRedirect(bank_redirect) => { WorldlinePaymentMethod::RedirectPaymentMethodSpecificInput(Box::new( make_bank_redirect_request(&item.router_data.request, bank_redirect)?, )) } - api::PaymentMethodData::CardRedirect(_) - | api::PaymentMethodData::Wallet(_) - | api::PaymentMethodData::PayLater(_) - | api::PaymentMethodData::BankDebit(_) - | api::PaymentMethodData::BankTransfer(_) - | api::PaymentMethodData::Crypto(_) - | api::PaymentMethodData::MandatePayment - | api::PaymentMethodData::Reward - | api::PaymentMethodData::Upi(_) - | api::PaymentMethodData::Voucher(_) - | api::PaymentMethodData::GiftCard(_) - | api::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented( - utils::get_unimplemented_payment_method_error_message("worldline"), - ))?, + domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::Wallet(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { + Err(errors::ConnectorError::NotImplemented( + utils::get_unimplemented_payment_method_error_message("worldline"), + ))? + } }; let billing_address = item.router_data.get_billing()?; @@ -339,7 +342,7 @@ impl TryFrom<&api_models::enums::BankNames> for WorldlineBic { fn make_card_request( req: &PaymentsAuthorizeData, - ccard: &payments::Card, + ccard: &domain::Card, ) -> Result> { let expiry_year = ccard.card_exp_year.peek(); let secret_value = format!( diff --git a/crates/router/src/connector/worldpay/transformers.rs b/crates/router/src/connector/worldpay/transformers.rs index dd92984eb995..1cbdb71f8b5c 100644 --- a/crates/router/src/connector/worldpay/transformers.rs +++ b/crates/router/src/connector/worldpay/transformers.rs @@ -9,7 +9,7 @@ use crate::{ connector::utils, consts, core::errors, - types::{self, api, PaymentsAuthorizeData, PaymentsResponseData}, + types::{self, domain, PaymentsAuthorizeData, PaymentsResponseData}, }; #[derive(Debug, Serialize)] @@ -41,10 +41,10 @@ impl } } fn fetch_payment_instrument( - payment_method: api::PaymentMethodData, + payment_method: domain::PaymentMethodData, ) -> CustomResult { match payment_method { - api::PaymentMethodData::Card(card) => Ok(PaymentInstrument::Card(CardPayment { + domain::PaymentMethodData::Card(card) => Ok(PaymentInstrument::Card(CardPayment { card_expiry_date: CardExpiryDate { month: utils::CardData::get_expiry_month_as_i8(&card)?, year: utils::CardData::get_expiry_year_as_i32(&card)?, @@ -52,7 +52,7 @@ fn fetch_payment_instrument( card_number: card.card_number, ..CardPayment::default() })), - api::PaymentMethodData::Wallet(wallet) => match wallet { + domain::PaymentMethodData::Wallet(wallet) => match wallet { api_models::payments::WalletData::GooglePay(data) => { Ok(PaymentInstrument::Googlepay(WalletPayment { payment_type: PaymentType::Googlepay, @@ -97,23 +97,21 @@ fn fetch_payment_instrument( .into()) } }, - api_models::payments::PaymentMethodData::PayLater(_) - | api_models::payments::PaymentMethodData::BankRedirect(_) - | api_models::payments::PaymentMethodData::BankDebit(_) - | api_models::payments::PaymentMethodData::BankTransfer(_) - | api_models::payments::PaymentMethodData::Crypto(_) - | api_models::payments::PaymentMethodData::MandatePayment - | api_models::payments::PaymentMethodData::Reward - | api_models::payments::PaymentMethodData::Upi(_) - | api_models::payments::PaymentMethodData::Voucher(_) - | api_models::payments::PaymentMethodData::CardRedirect(_) - | api_models::payments::PaymentMethodData::GiftCard(_) - | api_models::payments::PaymentMethodData::CardToken(_) => { - Err(errors::ConnectorError::NotImplemented( - utils::get_unimplemented_payment_method_error_message("worldpay"), - ) - .into()) - } + domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented( + utils::get_unimplemented_payment_method_error_message("worldpay"), + ) + .into()), } } diff --git a/crates/router/src/connector/zen.rs b/crates/router/src/connector/zen.rs index 7c28dfcc43a7..540c3320c208 100644 --- a/crates/router/src/connector/zen.rs +++ b/crates/router/src/connector/zen.rs @@ -197,7 +197,7 @@ impl ConnectorIntegration CustomResult)>, errors::ConnectorError> { let mut headers = self.build_headers(req, connectors)?; let api_headers = match req.request.payment_method_data { - api_models::payments::PaymentMethodData::Wallet(_) => None, + domain::payments::PaymentMethodData::Wallet(_) => None, _ => Some(Self::get_default_header()), }; if let Some(api_header) = api_headers { @@ -216,7 +216,7 @@ impl ConnectorIntegration CustomResult { let endpoint = match &req.request.payment_method_data { - api_models::payments::PaymentMethodData::Wallet(_) => { + domain::payments::PaymentMethodData::Wallet(_) => { let base_url = connectors .zen .secondary_base_url diff --git a/crates/router/src/connector/zen/transformers.rs b/crates/router/src/connector/zen/transformers.rs index 3e527423578b..ec44150ec9de 100644 --- a/crates/router/src/connector/zen/transformers.rs +++ b/crates/router/src/connector/zen/transformers.rs @@ -1,4 +1,3 @@ -use api_models::payments::Card; use cards::CardNumber; use common_utils::{ext_traits::ValueExt, pii}; use error_stack::ResultExt; @@ -14,7 +13,7 @@ use crate::{ consts, core::errors::{self, CustomResult}, services::{self, Method}, - types::{self, api, storage::enums, transformers::ForeignTryFrom}, + types::{self, api, domain, storage::enums, transformers::ForeignTryFrom}, utils::OptionExt, }; @@ -204,10 +203,18 @@ pub struct WalletSessionData { pub pay_wall_secret: Option>, } -impl TryFrom<(&ZenRouterData<&types::PaymentsAuthorizeRouterData>, &Card)> for ZenPaymentsRequest { +impl + TryFrom<( + &ZenRouterData<&types::PaymentsAuthorizeRouterData>, + &domain::Card, + )> for ZenPaymentsRequest +{ type Error = error_stack::Report; fn try_from( - value: (&ZenRouterData<&types::PaymentsAuthorizeRouterData>, &Card), + value: ( + &ZenRouterData<&types::PaymentsAuthorizeRouterData>, + &domain::Card, + ), ) -> Result { let (item, ccard) = value; let browser_info = item.router_data.request.get_browser_info()?; @@ -685,36 +692,32 @@ impl TryFrom<&ZenRouterData<&types::PaymentsAuthorizeRouterData>> for ZenPayment item: &ZenRouterData<&types::PaymentsAuthorizeRouterData>, ) -> Result { match &item.router_data.request.payment_method_data { - api_models::payments::PaymentMethodData::Card(card) => Self::try_from((item, card)), - api_models::payments::PaymentMethodData::Wallet(wallet_data) => { - Self::try_from((item, wallet_data)) - } - api_models::payments::PaymentMethodData::Voucher(voucher_data) => { + domain::PaymentMethodData::Card(card) => Self::try_from((item, card)), + domain::PaymentMethodData::Wallet(wallet_data) => Self::try_from((item, wallet_data)), + domain::PaymentMethodData::Voucher(voucher_data) => { Self::try_from((item, voucher_data)) } - api_models::payments::PaymentMethodData::BankTransfer(bank_transfer_data) => { + domain::PaymentMethodData::BankTransfer(bank_transfer_data) => { Self::try_from((item, bank_transfer_data)) } - api_models::payments::PaymentMethodData::BankRedirect(bank_redirect_data) => { + domain::PaymentMethodData::BankRedirect(bank_redirect_data) => { Self::try_from(bank_redirect_data) } - api_models::payments::PaymentMethodData::PayLater(paylater_data) => { - Self::try_from(paylater_data) - } - api_models::payments::PaymentMethodData::BankDebit(bank_debit_data) => { + domain::PaymentMethodData::PayLater(paylater_data) => Self::try_from(paylater_data), + domain::PaymentMethodData::BankDebit(bank_debit_data) => { Self::try_from(bank_debit_data) } - api_models::payments::PaymentMethodData::CardRedirect(car_redirect_data) => { + domain::PaymentMethodData::CardRedirect(car_redirect_data) => { Self::try_from(car_redirect_data) } - api_models::payments::PaymentMethodData::GiftCard(gift_card_data) => { + domain::PaymentMethodData::GiftCard(gift_card_data) => { Self::try_from(gift_card_data.as_ref()) } - api_models::payments::PaymentMethodData::Crypto(_) - | api_models::payments::PaymentMethodData::MandatePayment - | api_models::payments::PaymentMethodData::Reward - | api_models::payments::PaymentMethodData::Upi(_) - | api_models::payments::PaymentMethodData::CardToken(_) => { + domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::CardToken(_) => { Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("Zen"), ))? @@ -791,14 +794,14 @@ impl TryFrom<&api_models::payments::BankDebitData> for ZenPaymentsRequest { } } -impl TryFrom<&api_models::payments::CardRedirectData> for ZenPaymentsRequest { +impl TryFrom<&domain::payments::CardRedirectData> for ZenPaymentsRequest { type Error = error_stack::Report; - fn try_from(value: &api_models::payments::CardRedirectData) -> Result { + fn try_from(value: &domain::payments::CardRedirectData) -> Result { match value { - api_models::payments::CardRedirectData::Knet {} - | api_models::payments::CardRedirectData::Benefit {} - | api_models::payments::CardRedirectData::MomoAtm {} - | api_models::payments::CardRedirectData::CardRedirect {} => { + domain::payments::CardRedirectData::Knet {} + | domain::payments::CardRedirectData::Benefit {} + | domain::payments::CardRedirectData::MomoAtm {} + | domain::payments::CardRedirectData::CardRedirect {} => { Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("Zen"), ) diff --git a/crates/router/src/core/authentication/transformers.rs b/crates/router/src/core/authentication/transformers.rs index 6ade1b37e946..3c19c0630e85 100644 --- a/crates/router/src/core/authentication/transformers.rs +++ b/crates/router/src/core/authentication/transformers.rs @@ -56,7 +56,7 @@ pub fn construct_authentication_router_data( }) .attach_printable("Error while parsing authentication_details from merchant_account")?; let router_request = types::authentication::ConnectorAuthenticationRequestData { - payment_method_data, + payment_method_data: From::from(payment_method_data), billing_address, shipping_address, browser_details, diff --git a/crates/router/src/core/mandate.rs b/crates/router/src/core/mandate.rs index 0ad13f0703c7..e3eb9b0c9760 100644 --- a/crates/router/src/core/mandate.rs +++ b/crates/router/src/core/mandate.rs @@ -236,12 +236,12 @@ pub async fn get_customer_mandates( fn get_insensitive_payment_method_data_if_exists( router_data: &types::RouterData, -) -> Option +) -> Option where FData: MandateBehaviour, { match &router_data.request.get_payment_method_data() { - api_models::payments::PaymentMethodData::Card(_) => None, + domain::PaymentMethodData::Card(_) => None, _ => Some(router_data.request.get_payment_method_data()), } } @@ -495,7 +495,7 @@ pub trait MandateBehaviour { fn get_setup_future_usage(&self) -> Option; fn get_mandate_id(&self) -> Option<&api_models::payments::MandateIds>; fn set_mandate_id(&mut self, new_mandate_id: Option); - fn get_payment_method_data(&self) -> api_models::payments::PaymentMethodData; + fn get_payment_method_data(&self) -> domain::payments::PaymentMethodData; fn get_setup_mandate_details(&self) -> Option<&data_models::mandates::MandateData>; fn get_customer_acceptance(&self) -> Option; } diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs index b996677f7e67..96f5a2833d0e 100644 --- a/crates/router/src/core/payments.rs +++ b/crates/router/src/core/payments.rs @@ -2170,21 +2170,22 @@ pub mod payment_address { billing: Option, payment_method_billing: Option, ) -> Self { + // billing -> .billing, this is the billing details passed in the root of payments request + // payment_method_billing -> .payment_method_data.billing + // Merge the billing details field from both `payment.billing` and `payment.payment_method_data.billing` // The unified payment_method_billing will be used as billing address and passed to the connector module // This unification is required in order to provide backwards compatibility // so that if `payment.billing` is passed it should be sent to the connector module - let unified_payment_method_billing = - match (payment_method_billing.clone(), billing.clone()) { - (Some(payment_method_billing), Some(order_billing)) => Some(api::Address { - address: payment_method_billing.address.or(order_billing.address), - phone: payment_method_billing.phone.or(order_billing.phone), - email: payment_method_billing.email.or(order_billing.email), - }), - (Some(payment_method_billing), None) => Some(payment_method_billing), - (None, Some(order_billing)) => Some(order_billing), - (None, None) => None, - }; + // Unify the billing details with `payment_method_data.billing` + let unified_payment_method_billing = payment_method_billing + .as_ref() + .map(|payment_method_billing| { + payment_method_billing + .clone() + .unify_address(billing.as_ref()) + }) + .or(billing.clone()); Self { shipping, @@ -2202,6 +2203,25 @@ pub mod payment_address { self.unified_payment_method_billing.as_ref() } + pub fn unify_with_payment_method_data_billing( + self, + payment_method_data_billing: Option, + ) -> Self { + // Unify the billing details with `payment_method_data.billing_details` + let unified_payment_method_billing = payment_method_data_billing + .map(|payment_method_data_billing| { + payment_method_data_billing.unify_address(self.get_payment_method_billing()) + }) + .or(self.get_payment_method_billing().cloned()); + + Self { + shipping: self.shipping, + billing: self.billing, + unified_payment_method_billing, + payment_method_billing: self.payment_method_billing, + } + } + pub fn get_request_payment_method_billing(&self) -> Option<&api::Address> { self.payment_method_billing.as_ref() } diff --git a/crates/router/src/core/payments/flows/authorize_flow.rs b/crates/router/src/core/payments/flows/authorize_flow.rs index 7757313d8676..bc43839fdcb2 100644 --- a/crates/router/src/core/payments/flows/authorize_flow.rs +++ b/crates/router/src/core/payments/flows/authorize_flow.rs @@ -294,7 +294,7 @@ impl mandate::MandateBehaviour for types::PaymentsAuthorizeData { fn get_mandate_id(&self) -> Option<&api_models::payments::MandateIds> { self.mandate_id.as_ref() } - fn get_payment_method_data(&self) -> api_models::payments::PaymentMethodData { + fn get_payment_method_data(&self) -> domain::payments::PaymentMethodData { self.payment_method_data.clone() } fn get_setup_future_usage(&self) -> Option { diff --git a/crates/router/src/core/payments/flows/setup_mandate_flow.rs b/crates/router/src/core/payments/flows/setup_mandate_flow.rs index 0d663df29808..27204450a0a8 100644 --- a/crates/router/src/core/payments/flows/setup_mandate_flow.rs +++ b/crates/router/src/core/payments/flows/setup_mandate_flow.rs @@ -429,7 +429,7 @@ impl mandate::MandateBehaviour for types::SetupMandateRequestData { self.mandate_id = new_mandate_id; } - fn get_payment_method_data(&self) -> api_models::payments::PaymentMethodData { + fn get_payment_method_data(&self) -> domain::payments::PaymentMethodData { self.payment_method_data.clone() } diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs index 0f80b6a52ea2..d96469b640e8 100644 --- a/crates/router/src/core/payments/helpers.rs +++ b/crates/router/src/core/payments/helpers.rs @@ -1167,7 +1167,7 @@ where #[instrument(skip_all)] pub(crate) async fn get_payment_method_create_request( - payment_method_data: Option<&api::PaymentMethodData>, + payment_method_data: Option<&domain::PaymentMethodData>, payment_method: Option, payment_method_type: Option, customer: &domain::Customer, @@ -1175,7 +1175,7 @@ pub(crate) async fn get_payment_method_create_request( match payment_method_data { Some(pm_data) => match payment_method { Some(payment_method) => match pm_data { - api::PaymentMethodData::Card(card) => { + domain::PaymentMethodData::Card(card) => { let card_detail = api::CardDetail { card_number: card.card_number.clone(), card_exp_month: card.card_exp_month.clone(), @@ -2507,7 +2507,7 @@ pub fn generate_mandate( payment_method_id: String, connector_mandate_id: Option, network_txn_id: Option, - payment_method_data_option: Option, + payment_method_data_option: Option, mandate_reference: Option, merchant_connector_id: Option, ) -> CustomResult, errors::ApiErrorResponse> { diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rs index 6dce6db9d9b9..f66c28c555d1 100644 --- a/crates/router/src/core/payments/operations/payment_create.rs +++ b/crates/router/src/core/payments/operations/payment_create.rs @@ -388,6 +388,7 @@ impl }); let amount = payment_attempt.get_total_amount().into(); + let payment_data = PaymentData { flow: PhantomData, payment_intent, diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs index 9aa552b86d8c..3e06bb0a34db 100644 --- a/crates/router/src/core/payments/transformers.rs +++ b/crates/router/src/core/payments/transformers.rs @@ -1,6 +1,6 @@ use std::{fmt::Debug, marker::PhantomData, str::FromStr}; -use api_models::payments::{FrmMessage, RequestSurchargeDetails}; +use api_models::payments::{FrmMessage, GetAddressFromPaymentMethodData, RequestSurchargeDetails}; #[cfg(feature = "payouts")] use api_models::payouts::PayoutAttemptResponse; use common_enums::RequestIncrementalAuthorization; @@ -124,6 +124,11 @@ where Some(merchant_connector_account), ); + let payment_method_data_billing = payment_data + .payment_method_data + .as_ref() + .and_then(|payment_method_data| payment_method_data.get_billing_address()); + router_data = types::RouterData { flow: PhantomData, merchant_id: merchant_account.merchant_id.clone(), @@ -137,7 +142,9 @@ where description: payment_data.payment_intent.description.clone(), return_url: payment_data.payment_intent.return_url.clone(), payment_method_id: payment_data.payment_attempt.payment_method_id.clone(), - address: payment_data.address.clone(), + address: payment_data + .address + .unify_with_payment_method_data_billing(payment_method_data_billing), auth_type: payment_data .payment_attempt .authentication_type @@ -1220,7 +1227,9 @@ impl TryFrom> for types::PaymentsAuthoriz }); Ok(Self { - payment_method_data: payment_method_data.get_required_value("payment_method_data")?, + payment_method_data: From::from( + payment_method_data.get_required_value("payment_method_data")?, + ), setup_future_usage: payment_data.payment_intent.setup_future_usage, mandate_id: payment_data.mandate_id.clone(), off_session: payment_data.mandate_id.as_ref().map(|_| true), @@ -1552,9 +1561,11 @@ impl TryFrom> for types::SetupMandateRequ currency: payment_data.currency, confirm: true, amount: Some(payment_data.amount.into()), - payment_method_data: payment_data - .payment_method_data - .get_required_value("payment_method_data")?, + payment_method_data: From::from( + payment_data + .payment_method_data + .get_required_value("payment_method_data")?, + ), statement_descriptor_suffix: payment_data.payment_intent.statement_descriptor_suffix, setup_future_usage: payment_data.payment_intent.setup_future_usage, off_session: payment_data.mandate_id.as_ref().map(|_| true), @@ -1665,7 +1676,7 @@ impl TryFrom> for types::CompleteAuthoriz currency: payment_data.currency, browser_info, email: payment_data.email, - payment_method_data: payment_data.payment_method_data, + payment_method_data: payment_data.payment_method_data.map(From::from), connector_transaction_id: payment_data.payment_attempt.connector_transaction_id, redirect_response, connector_meta: payment_data.payment_attempt.connector_metadata, @@ -1735,7 +1746,7 @@ impl TryFrom> for types::PaymentsPreProce .unwrap_or(payment_data.amount.into()); Ok(Self { - payment_method_data, + payment_method_data: payment_method_data.map(From::from), email: payment_data.email, currency: Some(payment_data.currency), amount: Some(amount), diff --git a/crates/router/src/types.rs b/crates/router/src/types.rs index 4a2a676672c1..1bc8319235e7 100644 --- a/crates/router/src/types.rs +++ b/crates/router/src/types.rs @@ -29,18 +29,17 @@ use error_stack::ResultExt; use masking::Secret; use serde::Serialize; -use self::{api::payments, storage::enums as storage_enums}; +use self::storage::enums as storage_enums; pub use crate::core::payments::{payment_address::PaymentAddress, CustomerDetails}; #[cfg(feature = "payouts")] use crate::core::utils::IRRELEVANT_CONNECTOR_REQUEST_REFERENCE_ID_IN_DISPUTE_FLOW; use crate::{ core::{ - errors::{self, RouterResult}, + errors::{self}, payments::{types, PaymentData, RecurringMandatePaymentData}, }, services, types::{transformers::ForeignFrom, types::AuthenticationData}, - utils::OptionExt, }; pub type PaymentsAuthorizeRouterData = RouterData; @@ -412,7 +411,7 @@ pub struct PayoutsFulfillResponseData { #[derive(Debug, Clone)] pub struct PaymentsAuthorizeData { - pub payment_method_data: payments::PaymentMethodData, + pub payment_method_data: domain::payments::PaymentMethodData, /// total amount (original_amount + surcharge_amount + tax_on_surcharge_amount) /// If connector supports separate field for surcharge amount, consider using below functions defined on `PaymentsAuthorizeData` to fetch original amount and surcharge amount separately /// ``` @@ -497,12 +496,12 @@ pub struct ConnectorCustomerData { pub phone: Option>, pub name: Option>, pub preprocessing_id: Option, - pub payment_method_data: payments::PaymentMethodData, + pub payment_method_data: domain::PaymentMethodData, } #[derive(Debug, Clone)] pub struct PaymentMethodTokenizationData { - pub payment_method_data: payments::PaymentMethodData, + pub payment_method_data: domain::payments::PaymentMethodData, pub browser_info: Option, pub currency: storage_enums::Currency, pub amount: Option, @@ -510,7 +509,7 @@ pub struct PaymentMethodTokenizationData { #[derive(Debug, Clone)] pub struct PaymentsPreProcessingData { - pub payment_method_data: Option, + pub payment_method_data: Option, pub amount: Option, pub email: Option, pub currency: Option, @@ -529,7 +528,7 @@ pub struct PaymentsPreProcessingData { #[derive(Debug, Clone)] pub struct CompleteAuthorizeData { - pub payment_method_data: Option, + pub payment_method_data: Option, pub amount: i64, pub email: Option, pub currency: storage_enums::Currency, @@ -610,7 +609,7 @@ pub struct PaymentsSessionData { #[derive(Debug, Clone)] pub struct SetupMandateRequestData { pub currency: storage_enums::Currency, - pub payment_method_data: payments::PaymentMethodData, + pub payment_method_data: domain::PaymentMethodData, pub amount: Option, pub confirm: bool, pub statement_descriptor_suffix: Option, @@ -1393,32 +1392,20 @@ impl From<&RouterData> } pub trait Tokenizable { - fn get_pm_data(&self) -> RouterResult; fn set_session_token(&mut self, token: Option); } impl Tokenizable for SetupMandateRequestData { - fn get_pm_data(&self) -> RouterResult { - Ok(self.payment_method_data.clone()) - } fn set_session_token(&mut self, _token: Option) {} } impl Tokenizable for PaymentsAuthorizeData { - fn get_pm_data(&self) -> RouterResult { - Ok(self.payment_method_data.clone()) - } fn set_session_token(&mut self, token: Option) { self.session_token = token; } } impl Tokenizable for CompleteAuthorizeData { - fn get_pm_data(&self) -> RouterResult { - self.payment_method_data - .clone() - .get_required_value("payment_method_data") - } fn set_session_token(&mut self, _token: Option) {} } diff --git a/crates/router/src/types/api/verify_connector.rs b/crates/router/src/types/api/verify_connector.rs index 85bb9bf72afb..55dc4a2bf04f 100644 --- a/crates/router/src/types/api/verify_connector.rs +++ b/crates/router/src/types/api/verify_connector.rs @@ -8,7 +8,7 @@ use crate::{ core::errors, services, services::ConnectorIntegration, - types::{self, api, storage::enums as storage_enums}, + types::{self, api, domain, storage::enums as storage_enums}, AppState, }; @@ -16,13 +16,13 @@ use crate::{ pub struct VerifyConnectorData { pub connector: &'static (dyn types::api::Connector + Sync), pub connector_auth: types::ConnectorAuthType, - pub card_details: api::Card, + pub card_details: domain::Card, } impl VerifyConnectorData { fn get_payment_authorize_data(&self) -> types::PaymentsAuthorizeData { types::PaymentsAuthorizeData { - payment_method_data: api::PaymentMethodData::Card(self.card_details.clone()), + payment_method_data: domain::PaymentMethodData::Card(self.card_details.clone()), email: None, customer_name: None, amount: 1000, diff --git a/crates/router/src/types/authentication.rs b/crates/router/src/types/authentication.rs index 4cd1f3faebc0..1de7d110a6f1 100644 --- a/crates/router/src/types/authentication.rs +++ b/crates/router/src/types/authentication.rs @@ -1,11 +1,10 @@ -use api_models::payments; use cards::CardNumber; use common_utils::pii::Email; use serde::{Deserialize, Serialize}; use super::{ api::{self, authentication}, - BrowserInformation, RouterData, + domain, BrowserInformation, RouterData, }; use crate::services; @@ -101,7 +100,7 @@ pub struct PreAuthNRequestData { #[derive(Clone, Debug)] pub struct ConnectorAuthenticationRequestData { - pub payment_method_data: payments::PaymentMethodData, + pub payment_method_data: domain::PaymentMethodData, pub billing_address: api_models::payments::Address, pub shipping_address: Option, pub browser_details: Option, diff --git a/crates/router/src/types/domain.rs b/crates/router/src/types/domain.rs index 3b6633defcfb..e5f6b8c96606 100644 --- a/crates/router/src/types/domain.rs +++ b/crates/router/src/types/domain.rs @@ -5,6 +5,7 @@ mod event; mod merchant_account; mod merchant_connector_account; mod merchant_key_store; +pub mod payments; pub mod types; #[cfg(feature = "olap")] pub mod user; @@ -15,5 +16,6 @@ pub use event::*; pub use merchant_account::*; pub use merchant_connector_account::*; pub use merchant_key_store::*; +pub use payments::*; #[cfg(feature = "olap")] pub use user::*; diff --git a/crates/router/src/types/domain/payments.rs b/crates/router/src/types/domain/payments.rs new file mode 100644 index 000000000000..633193677a4a --- /dev/null +++ b/crates/router/src/types/domain/payments.rs @@ -0,0 +1,405 @@ +use common_utils::pii::Email; +use masking::Secret; +use serde::{Deserialize, Serialize}; + +// We need to derive Serialize and Deserialize because some parts of payment method data are being +// stored in the database as serde_json::Value +#[derive(Eq, PartialEq, Clone, Debug, Serialize, Deserialize)] +pub enum PaymentMethodData { + Card(Card), + CardRedirect(CardRedirectData), + Wallet(api_models::payments::WalletData), + PayLater(api_models::payments::PayLaterData), + BankRedirect(api_models::payments::BankRedirectData), + BankDebit(api_models::payments::BankDebitData), + BankTransfer(Box), + Crypto(api_models::payments::CryptoData), + MandatePayment, + Reward, + Upi(api_models::payments::UpiData), + Voucher(api_models::payments::VoucherData), + GiftCard(Box), + CardToken(api_models::payments::CardToken), +} + +impl PaymentMethodData { + pub fn get_payment_method(&self) -> Option { + match self { + Self::Card(_) => Some(common_enums::PaymentMethod::Card), + Self::CardRedirect(_) => Some(common_enums::PaymentMethod::CardRedirect), + Self::Wallet(_) => Some(common_enums::PaymentMethod::Wallet), + Self::PayLater(_) => Some(common_enums::PaymentMethod::PayLater), + Self::BankRedirect(_) => Some(common_enums::PaymentMethod::BankRedirect), + Self::BankDebit(_) => Some(common_enums::PaymentMethod::BankDebit), + Self::BankTransfer(_) => Some(common_enums::PaymentMethod::BankTransfer), + Self::Crypto(_) => Some(common_enums::PaymentMethod::Crypto), + Self::Reward => Some(common_enums::PaymentMethod::Reward), + Self::Upi(_) => Some(common_enums::PaymentMethod::Upi), + Self::Voucher(_) => Some(common_enums::PaymentMethod::Voucher), + Self::GiftCard(_) => Some(common_enums::PaymentMethod::GiftCard), + Self::CardToken(_) | Self::MandatePayment => None, + } + } +} + +#[derive(Eq, PartialEq, Clone, Debug, Serialize, Deserialize, Default)] +pub struct Card { + pub card_number: cards::CardNumber, + pub card_exp_month: Secret, + pub card_exp_year: Secret, + pub card_holder_name: Option>, + pub card_cvc: Secret, + pub card_issuer: Option, + pub card_network: Option, + pub card_type: Option, + pub card_issuing_country: Option, + pub bank_code: Option, + pub nick_name: Option>, +} + +#[derive(Eq, PartialEq, Clone, Debug, Serialize, Deserialize)] +pub enum CardRedirectData { + Knet {}, + Benefit {}, + MomoAtm {}, + CardRedirect {}, +} + +#[derive(Eq, PartialEq, Clone, Debug)] +pub enum PayLaterData { + KlarnaRedirect { + billing_email: Email, + billing_country: common_enums::CountryAlpha2, + }, + KlarnaSdk { + token: String, + }, + AffirmRedirect {}, + AfterpayClearpayRedirect { + billing_email: Email, + billing_name: Secret, + }, + PayBrightRedirect {}, + WalleyRedirect {}, + AlmaRedirect {}, + AtomeRedirect {}, +} + +#[derive(Eq, PartialEq, Clone, Debug)] + +pub enum WalletData { + AliPayQr(Box), + AliPayRedirect(AliPayRedirection), + AliPayHkRedirect(AliPayHkRedirection), + MomoRedirect(MomoRedirection), + KakaoPayRedirect(KakaoPayRedirection), + GoPayRedirect(GoPayRedirection), + GcashRedirect(GcashRedirection), + ApplePay(ApplePayWalletData), + ApplePayRedirect(Box), + ApplePayThirdPartySdk(Box), + DanaRedirect {}, + GooglePay(GooglePayWalletData), + GooglePayRedirect(Box), + GooglePayThirdPartySdk(Box), + MbWayRedirect(Box), + MobilePayRedirect(Box), + PaypalRedirect(PaypalRedirection), + PaypalSdk(PayPalWalletData), + SamsungPay(Box), + TwintRedirect {}, + VippsRedirect {}, + TouchNGoRedirect(Box), + WeChatPayRedirect(Box), + WeChatPayQr(Box), + CashappQr(Box), + SwishQr(SwishQrData), +} + +#[derive(Eq, PartialEq, Clone, Debug)] + +pub struct SamsungPayWalletData { + /// The encrypted payment token from Samsung + pub token: Secret, +} + +#[derive(Eq, PartialEq, Clone, Debug)] + +pub struct GooglePayWalletData { + /// The type of payment method + pub pm_type: String, + /// User-facing message to describe the payment method that funds this transaction. + pub description: String, + /// The information of the payment method + pub info: GooglePayPaymentMethodInfo, + /// The tokenization data of Google pay + pub tokenization_data: GpayTokenizationData, +} + +#[derive(Eq, PartialEq, Clone, Debug)] +pub struct ApplePayRedirectData {} + +#[derive(Eq, PartialEq, Clone, Debug)] +pub struct GooglePayRedirectData {} + +#[derive(Eq, PartialEq, Clone, Debug)] +pub struct GooglePayThirdPartySdkData {} + +#[derive(Eq, PartialEq, Clone, Debug)] +pub struct ApplePayThirdPartySdkData {} + +#[derive(Eq, PartialEq, Clone, Debug)] +pub struct WeChatPayRedirection {} + +#[derive(Eq, PartialEq, Clone, Debug)] +pub struct WeChatPay {} + +#[derive(Eq, PartialEq, Clone, Debug)] +pub struct WeChatPayQr {} + +#[derive(Eq, PartialEq, Clone, Debug)] +pub struct CashappQr {} + +#[derive(Eq, PartialEq, Clone, Debug)] +pub struct PaypalRedirection { + /// paypal's email address + pub email: Option, +} + +#[derive(Eq, PartialEq, Clone, Debug)] +pub struct AliPayQr {} + +#[derive(Eq, PartialEq, Clone, Debug)] +pub struct AliPayRedirection {} + +#[derive(Eq, PartialEq, Clone, Debug)] +pub struct AliPayHkRedirection {} + +#[derive(Eq, PartialEq, Clone, Debug)] +pub struct MomoRedirection {} + +#[derive(Eq, PartialEq, Clone, Debug)] +pub struct KakaoPayRedirection {} + +#[derive(Eq, PartialEq, Clone, Debug)] +pub struct GoPayRedirection {} + +#[derive(Eq, PartialEq, Clone, Debug)] +pub struct GcashRedirection {} + +#[derive(Eq, PartialEq, Clone, Debug)] +pub struct MobilePayRedirection {} + +#[derive(Eq, PartialEq, Clone, Debug)] +pub struct MbWayRedirection { + /// Telephone number of the shopper. Should be Portuguese phone number. + pub telephone_number: Secret, +} + +#[derive(Eq, PartialEq, Clone, Debug)] + +pub struct GooglePayPaymentMethodInfo { + /// The name of the card network + pub card_network: String, + /// The details of the card + pub card_details: String, +} + +#[derive(Eq, PartialEq, Clone, Debug)] +pub struct PayPalWalletData { + /// Token generated for the Apple pay + pub token: String, +} + +#[derive(Eq, PartialEq, Clone, Debug)] +pub struct TouchNGoRedirection {} + +#[derive(Eq, PartialEq, Clone, Debug)] +pub struct SwishQrData {} + +#[derive(Eq, PartialEq, Clone, Debug)] +pub struct GpayTokenizationData { + /// The type of the token + pub token_type: String, + /// Token generated for the wallet + pub token: String, +} + +#[derive(Eq, PartialEq, Clone, Debug)] +pub struct ApplePayWalletData { + /// The payment data of Apple pay + pub payment_data: String, + /// The payment method of Apple pay + pub payment_method: ApplepayPaymentMethod, + /// The unique identifier for the transaction + pub transaction_identifier: String, +} + +#[derive(Eq, PartialEq, Clone, Debug)] +pub struct ApplepayPaymentMethod { + pub display_name: String, + pub network: String, + pub pm_type: String, +} + +#[derive(Debug, Clone, Eq, PartialEq)] + +pub enum BankRedirectData { + BancontactCard { + card_number: Option, + card_exp_month: Option>, + card_exp_year: Option>, + card_holder_name: Option>, + billing_details: Option, + }, + Bizum {}, + Blik { + blik_code: Option, + }, + Eps { + billing_details: Option, + bank_name: Option, + country: Option, + }, + Giropay { + billing_details: Option, + bank_account_bic: Option>, + bank_account_iban: Option>, + country: Option, + }, + Ideal { + billing_details: Option, + bank_name: Option, + country: Option, + }, + Interac { + country: common_enums::CountryAlpha2, + email: Email, + }, + OnlineBankingCzechRepublic { + issuer: common_enums::BankNames, + }, + OnlineBankingFinland { + email: Option, + }, + OnlineBankingPoland { + issuer: common_enums::BankNames, + }, + OnlineBankingSlovakia { + issuer: common_enums::BankNames, + }, + OpenBankingUk { + issuer: Option, + country: Option, + }, + Przelewy24 { + bank_name: Option, + billing_details: BankRedirectBilling, + }, + Sofort { + billing_details: Option, + country: Option, + preferred_language: Option, + }, + Trustly { + country: common_enums::CountryAlpha2, + }, + OnlineBankingFpx { + issuer: common_enums::BankNames, + }, + OnlineBankingThailand { + issuer: common_enums::BankNames, + }, +} + +#[derive(Debug, Clone, Eq, PartialEq)] +pub struct BankRedirectBilling { + pub billing_name: Option>, + pub email: Option, +} + +impl From for PaymentMethodData { + fn from(api_model_payment_method_data: api_models::payments::PaymentMethodData) -> Self { + match api_model_payment_method_data { + api_models::payments::PaymentMethodData::Card(card_data) => { + Self::Card(Card::from(card_data)) + } + api_models::payments::PaymentMethodData::CardRedirect(card_redirect) => { + Self::CardRedirect(From::from(card_redirect)) + } + api_models::payments::PaymentMethodData::Wallet(wallet_data) => { + Self::Wallet(wallet_data) + } + api_models::payments::PaymentMethodData::PayLater(pay_later_data) => { + Self::PayLater(pay_later_data) + } + api_models::payments::PaymentMethodData::BankRedirect(bank_redirect_data) => { + Self::BankRedirect(bank_redirect_data) + } + api_models::payments::PaymentMethodData::BankDebit(bank_debit_data) => { + Self::BankDebit(bank_debit_data) + } + api_models::payments::PaymentMethodData::BankTransfer(bank_transfer_data) => { + Self::BankTransfer(bank_transfer_data) + } + api_models::payments::PaymentMethodData::Crypto(crypto_data) => { + Self::Crypto(crypto_data) + } + api_models::payments::PaymentMethodData::MandatePayment => Self::MandatePayment, + api_models::payments::PaymentMethodData::Reward => Self::Reward, + api_models::payments::PaymentMethodData::Upi(upi_data) => Self::Upi(upi_data), + api_models::payments::PaymentMethodData::Voucher(voucher_data) => { + Self::Voucher(voucher_data) + } + api_models::payments::PaymentMethodData::GiftCard(gift_card) => { + Self::GiftCard(gift_card) + } + api_models::payments::PaymentMethodData::CardToken(card_token) => { + Self::CardToken(card_token) + } + } + } +} + +impl From for Card { + fn from(value: api_models::payments::Card) -> Self { + let api_models::payments::Card { + card_number, + card_exp_month, + card_exp_year, + card_holder_name, + card_cvc, + card_issuer, + card_network, + card_type, + card_issuing_country, + bank_code, + nick_name, + } = value; + + Self { + card_number, + card_exp_month, + card_exp_year, + card_holder_name, + card_cvc, + card_issuer, + card_network, + card_type, + card_issuing_country, + bank_code, + nick_name, + } + } +} + +impl From for CardRedirectData { + fn from(value: api_models::payments::CardRedirectData) -> Self { + match value { + api_models::payments::CardRedirectData::Knet {} => Self::Knet {}, + api_models::payments::CardRedirectData::Benefit {} => Self::Benefit {}, + api_models::payments::CardRedirectData::MomoAtm {} => Self::MomoAtm {}, + api_models::payments::CardRedirectData::CardRedirect {} => Self::CardRedirect {}, + } + } +} diff --git a/crates/router/src/utils/verify_connector.rs b/crates/router/src/utils/verify_connector.rs index acb2f6096317..0d1deeaaedc6 100644 --- a/crates/router/src/utils/verify_connector.rs +++ b/crates/router/src/utils/verify_connector.rs @@ -1,15 +1,15 @@ use api_models::enums::Connector; use error_stack::ResultExt; -use crate::{core::errors, types::api}; +use crate::{core::errors, types::domain}; pub fn generate_card_from_details( card_number: String, card_exp_year: String, card_exp_month: String, card_cvv: String, -) -> errors::RouterResult { - Ok(api::Card { +) -> errors::RouterResult { + Ok(domain::Card { card_number: card_number .parse::() .change_context(errors::ApiErrorResponse::InternalServerError) @@ -27,7 +27,9 @@ pub fn generate_card_from_details( }) } -pub fn get_test_card_details(connector_name: Connector) -> errors::RouterResult> { +pub fn get_test_card_details( + connector_name: Connector, +) -> errors::RouterResult> { match connector_name { Connector::Stripe => Some(generate_card_from_details( "4242424242424242".to_string(), diff --git a/crates/router/tests/connectors/aci.rs b/crates/router/tests/connectors/aci.rs index a2c05a1a67a4..6cf8fe9994cd 100644 --- a/crates/router/tests/connectors/aci.rs +++ b/crates/router/tests/connectors/aci.rs @@ -36,7 +36,7 @@ fn construct_payment_router_data() -> types::PaymentsAuthorizeRouterData { request: types::PaymentsAuthorizeData { amount: 1000, currency: enums::Currency::USD, - payment_method_data: types::api::PaymentMethodData::Card(types::api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(types::domain::Card { card_number: cards::CardNumber::from_str("4200000000000000").unwrap(), card_exp_month: Secret::new("10".to_string()), card_exp_year: Secret::new("2025".to_string()), @@ -240,7 +240,7 @@ async fn payments_create_failure() { > = connector.connector.get_connector_integration(); let mut request = construct_payment_router_data(); request.request.payment_method_data = - types::api::PaymentMethodData::Card(types::api::Card { + types::domain::PaymentMethodData::Card(types::domain::Card { card_number: cards::CardNumber::from_str("4200000000000000").unwrap(), card_exp_month: Secret::new("10".to_string()), card_exp_year: Secret::new("2025".to_string()), diff --git a/crates/router/tests/connectors/adyen.rs b/crates/router/tests/connectors/adyen.rs index d1b0a3858e37..8a7b1370d4c9 100644 --- a/crates/router/tests/connectors/adyen.rs +++ b/crates/router/tests/connectors/adyen.rs @@ -2,7 +2,7 @@ use std::str::FromStr; use api_models::payments::{Address, AddressDetails}; use masking::Secret; -use router::types::{self, api, storage::enums, PaymentAddress}; +use router::types::{self, storage::enums, PaymentAddress}; use crate::{ connector_auth, @@ -97,16 +97,16 @@ impl AdyenTest { None, )), payout_method_data: match payout_type { - enums::PayoutType::Card => { - Some(api::PayoutMethodData::Card(api::payouts::CardPayout { + enums::PayoutType::Card => Some(types::api::PayoutMethodData::Card( + types::api::payouts::CardPayout { card_number: cards::CardNumber::from_str("4111111111111111").unwrap(), expiry_month: Secret::new("3".to_string()), expiry_year: Secret::new("2030".to_string()), card_holder_name: Some(Secret::new("John Doe".to_string())), - })) - } - enums::PayoutType::Bank => Some(api::PayoutMethodData::Bank( - api::payouts::BankPayout::Sepa(api::SepaBankTransfer { + }, + )), + enums::PayoutType::Bank => Some(types::api::PayoutMethodData::Bank( + types::api::payouts::BankPayout::Sepa(types::api::SepaBankTransfer { iban: "NL46TEST0136169112".to_string().into(), bic: Some("ABNANL2A".to_string().into()), bank_name: Some("Deutsche Bank".to_string()), @@ -114,8 +114,8 @@ impl AdyenTest { bank_city: Some("Amsterdam".to_string()), }), )), - enums::PayoutType::Wallet => Some(api::PayoutMethodData::Wallet( - api::payouts::WalletPayout::Paypal(api_models::payouts::Paypal { + enums::PayoutType::Wallet => Some(types::api::PayoutMethodData::Wallet( + types::api::payouts::WalletPayout::Paypal(api_models::payouts::Paypal { email: Email::from_str("EmailUsedForPayPalAccount@example.com").ok(), }), )), @@ -134,7 +134,7 @@ impl AdyenTest { Some(types::PaymentsAuthorizeData { amount: 3500, currency: enums::Currency::USD, - payment_method_data: types::api::PaymentMethodData::Card(types::api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(types::domain::Card { card_number: cards::CardNumber::from_str(card_number).unwrap(), card_exp_month: Secret::new(card_exp_month.to_string()), card_exp_year: Secret::new(card_exp_year.to_string()), @@ -445,7 +445,7 @@ async fn should_fail_payment_for_incorrect_card_number() { .make_payment( Some(types::PaymentsAuthorizeData { router_return_url: Some(String::from("http://localhost:8080")), - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(types::domain::Card { card_number: cards::CardNumber::from_str("4024007134364842").unwrap(), ..utils::CCardType::default().0 }), @@ -465,7 +465,7 @@ async fn should_fail_payment_for_incorrect_cvc() { .make_payment( Some(types::PaymentsAuthorizeData { router_return_url: Some(String::from("http://localhost:8080")), - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(types::domain::Card { card_cvc: Secret::new("12345".to_string()), ..utils::CCardType::default().0 }), @@ -488,7 +488,7 @@ async fn should_fail_payment_for_invalid_exp_month() { .make_payment( Some(types::PaymentsAuthorizeData { router_return_url: Some(String::from("http://localhost:8080")), - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(types::domain::Card { card_exp_month: Secret::new("20".to_string()), ..utils::CCardType::default().0 }), @@ -509,7 +509,7 @@ async fn should_fail_payment_for_incorrect_expiry_year() { .make_payment( Some(types::PaymentsAuthorizeData { router_return_url: Some(String::from("http://localhost:8080")), - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(types::domain::Card { card_exp_year: Secret::new("2000".to_string()), ..utils::CCardType::default().0 }), diff --git a/crates/router/tests/connectors/airwallex.rs b/crates/router/tests/connectors/airwallex.rs index cfc4c0c003d2..aa0da693504b 100644 --- a/crates/router/tests/connectors/airwallex.rs +++ b/crates/router/tests/connectors/airwallex.rs @@ -1,7 +1,7 @@ use std::str::FromStr; use masking::{PeekInterface, Secret}; -use router::types::{self, api, storage::enums, AccessToken}; +use router::types::{self, domain, storage::enums, AccessToken}; use crate::{ connector_auth, @@ -56,7 +56,7 @@ fn get_default_payment_info() -> Option { } fn payment_method_details() -> Option { Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_number: cards::CardNumber::from_str("4035501000000008").unwrap(), card_exp_month: Secret::new("02".to_string()), card_exp_year: Secret::new("2035".to_string()), @@ -357,7 +357,7 @@ async fn should_fail_payment_for_incorrect_card_number() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_number: cards::CardNumber::from_str("1234567891011").unwrap(), ..utils::CCardType::default().0 }), @@ -380,7 +380,7 @@ async fn should_fail_payment_for_incorrect_cvc() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_cvc: Secret::new("12345".to_string()), ..utils::CCardType::default().0 }), @@ -403,7 +403,7 @@ async fn should_fail_payment_for_invalid_exp_month() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_month: Secret::new("20".to_string()), ..utils::CCardType::default().0 }), @@ -426,7 +426,7 @@ async fn should_fail_payment_for_incorrect_expiry_year() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_year: Secret::new("2000".to_string()), ..utils::CCardType::default().0 }), diff --git a/crates/router/tests/connectors/authorizedotnet.rs b/crates/router/tests/connectors/authorizedotnet.rs index 3ae4298e8360..0020653916bf 100644 --- a/crates/router/tests/connectors/authorizedotnet.rs +++ b/crates/router/tests/connectors/authorizedotnet.rs @@ -1,7 +1,7 @@ use std::str::FromStr; use masking::Secret; -use router::types::{self, api, storage::enums}; +use router::types::{self, domain, storage::enums}; use crate::{ connector_auth, @@ -37,8 +37,8 @@ impl utils::Connector for AuthorizedotnetTest { } static CONNECTOR: AuthorizedotnetTest = AuthorizedotnetTest {}; -fn get_payment_method_data() -> api::Card { - api::Card { +fn get_payment_method_data() -> domain::Card { + domain::Card { card_number: cards::CardNumber::from_str("5424000000000015").unwrap(), card_exp_month: Secret::new("02".to_string()), card_exp_year: Secret::new("2035".to_string()), @@ -56,7 +56,9 @@ async fn should_only_authorize_payment() { .authorize_payment( Some(types::PaymentsAuthorizeData { amount: 300, - payment_method_data: types::api::PaymentMethodData::Card(get_payment_method_data()), + payment_method_data: types::domain::PaymentMethodData::Card( + get_payment_method_data(), + ), capture_method: Some(diesel_models::enums::CaptureMethod::Manual), ..utils::PaymentAuthorizeType::default().0 }), @@ -91,7 +93,9 @@ async fn should_capture_authorized_payment() { .authorize_payment( Some(types::PaymentsAuthorizeData { amount: 301, - payment_method_data: types::api::PaymentMethodData::Card(get_payment_method_data()), + payment_method_data: types::domain::PaymentMethodData::Card( + get_payment_method_data(), + ), capture_method: Some(diesel_models::enums::CaptureMethod::Manual), ..utils::PaymentAuthorizeType::default().0 }), @@ -153,7 +157,9 @@ async fn should_partially_capture_authorized_payment() { .authorize_payment( Some(types::PaymentsAuthorizeData { amount: 302, - payment_method_data: types::api::PaymentMethodData::Card(get_payment_method_data()), + payment_method_data: types::domain::PaymentMethodData::Card( + get_payment_method_data(), + ), capture_method: Some(diesel_models::enums::CaptureMethod::Manual), ..utils::PaymentAuthorizeType::default().0 }), @@ -215,7 +221,9 @@ async fn should_sync_authorized_payment() { .authorize_payment( Some(types::PaymentsAuthorizeData { amount: 303, - payment_method_data: types::api::PaymentMethodData::Card(get_payment_method_data()), + payment_method_data: types::domain::PaymentMethodData::Card( + get_payment_method_data(), + ), capture_method: Some(diesel_models::enums::CaptureMethod::Manual), ..utils::PaymentAuthorizeType::default().0 }), @@ -249,7 +257,9 @@ async fn should_void_authorized_payment() { .authorize_payment( Some(types::PaymentsAuthorizeData { amount: 304, - payment_method_data: types::api::PaymentMethodData::Card(get_payment_method_data()), + payment_method_data: types::domain::PaymentMethodData::Card( + get_payment_method_data(), + ), capture_method: Some(diesel_models::enums::CaptureMethod::Manual), ..utils::PaymentAuthorizeType::default().0 }), @@ -298,7 +308,9 @@ async fn should_make_payment() { .make_payment( Some(types::PaymentsAuthorizeData { amount: 310, - payment_method_data: types::api::PaymentMethodData::Card(get_payment_method_data()), + payment_method_data: types::domain::PaymentMethodData::Card( + get_payment_method_data(), + ), capture_method: Some(diesel_models::enums::CaptureMethod::Manual), ..utils::PaymentAuthorizeType::default().0 }), @@ -336,7 +348,9 @@ async fn should_sync_auto_captured_payment() { .make_payment( Some(types::PaymentsAuthorizeData { amount: 311, - payment_method_data: types::api::PaymentMethodData::Card(get_payment_method_data()), + payment_method_data: types::domain::PaymentMethodData::Card( + get_payment_method_data(), + ), capture_method: Some(diesel_models::enums::CaptureMethod::Manual), ..utils::PaymentAuthorizeType::default().0 }), @@ -389,7 +403,7 @@ async fn should_fail_payment_for_empty_card_number() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_number: cards::CardNumber::from_str("").unwrap(), ..utils::CCardType::default().0 }), @@ -412,7 +426,7 @@ async fn should_fail_payment_for_incorrect_cvc() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_cvc: Secret::new("12345".to_string()), ..utils::CCardType::default().0 }), @@ -435,7 +449,7 @@ async fn should_fail_payment_for_invalid_exp_month() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_month: Secret::new("20".to_string()), ..utils::CCardType::default().0 }), @@ -457,7 +471,7 @@ async fn should_fail_payment_for_incorrect_expiry_year() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_year: Secret::new("2000".to_string()), ..utils::CCardType::default().0 }), @@ -480,7 +494,9 @@ async fn should_fail_void_payment_for_auto_capture() { .make_payment( Some(types::PaymentsAuthorizeData { amount: 307, - payment_method_data: types::api::PaymentMethodData::Card(get_payment_method_data()), + payment_method_data: types::domain::PaymentMethodData::Card( + get_payment_method_data(), + ), capture_method: Some(diesel_models::enums::CaptureMethod::Manual), ..utils::PaymentAuthorizeType::default().0 }), diff --git a/crates/router/tests/connectors/bambora.rs b/crates/router/tests/connectors/bambora.rs index 9da29bb3033a..e613696bd921 100644 --- a/crates/router/tests/connectors/bambora.rs +++ b/crates/router/tests/connectors/bambora.rs @@ -1,8 +1,7 @@ use std::str::FromStr; -use api_models::payments::PaymentMethodData; use masking::Secret; -use router::types::{self, api, storage::enums}; +use router::types::{self, domain, storage::enums}; use crate::{ connector_auth, @@ -41,7 +40,7 @@ static CONNECTOR: BamboraTest = BamboraTest {}; fn get_default_payment_authorize_data() -> Option { Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_number: cards::CardNumber::from_str("4030000010001234").unwrap(), card_exp_year: Secret::new("25".to_string()), card_cvc: Secret::new("123".to_string()), @@ -295,7 +294,7 @@ async fn should_fail_payment_for_incorrect_card_number() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_number: cards::CardNumber::from_str("1234567891011").unwrap(), card_exp_year: Secret::new("25".to_string()), ..utils::CCardType::default().0 @@ -318,7 +317,7 @@ async fn should_fail_payment_for_incorrect_cvc() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_year: Secret::new("25".to_string()), card_cvc: Secret::new("12345".to_string()), ..utils::CCardType::default().0 @@ -341,7 +340,7 @@ async fn should_fail_payment_for_invalid_exp_month() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_month: Secret::new("20".to_string()), card_number: cards::CardNumber::from_str("4030000010001234").unwrap(), card_exp_year: Secret::new("25".to_string()), @@ -366,7 +365,7 @@ async fn should_fail_payment_for_incorrect_expiry_year() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_year: Secret::new("2000".to_string()), card_number: cards::CardNumber::from_str("4030000010001234").unwrap(), card_cvc: Secret::new("123".to_string()), diff --git a/crates/router/tests/connectors/bankofamerica.rs b/crates/router/tests/connectors/bankofamerica.rs index 766078fa19c0..938a5eaf830a 100644 --- a/crates/router/tests/connectors/bankofamerica.rs +++ b/crates/router/tests/connectors/bankofamerica.rs @@ -1,5 +1,5 @@ use masking::Secret; -use router::types::{self, api, storage::enums}; +use router::types::{self, domain, storage::enums}; use test_utils::connector_auth; use crate::utils::{self, ConnectorActions}; @@ -303,7 +303,7 @@ async fn should_fail_payment_for_incorrect_cvc() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_cvc: Secret::new("12345".to_string()), ..utils::CCardType::default().0 }), @@ -325,7 +325,7 @@ async fn should_fail_payment_for_invalid_exp_month() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_month: Secret::new("20".to_string()), ..utils::CCardType::default().0 }), @@ -347,7 +347,7 @@ async fn should_fail_payment_for_incorrect_expiry_year() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_year: Secret::new("2000".to_string()), ..utils::CCardType::default().0 }), diff --git a/crates/router/tests/connectors/billwerk.rs b/crates/router/tests/connectors/billwerk.rs index 1dec066e5d26..b1062478bf9e 100644 --- a/crates/router/tests/connectors/billwerk.rs +++ b/crates/router/tests/connectors/billwerk.rs @@ -1,5 +1,5 @@ use masking::Secret; -use router::types::{self, api, storage::enums}; +use router::types::{self, domain, storage::enums}; use test_utils::connector_auth; use crate::utils::{self, ConnectorActions}; @@ -303,7 +303,7 @@ async fn should_fail_payment_for_incorrect_cvc() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: domain::PaymentMethodData::Card(domain::Card { card_cvc: Secret::new("12345".to_string()), ..utils::CCardType::default().0 }), @@ -325,7 +325,7 @@ async fn should_fail_payment_for_invalid_exp_month() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: domain::PaymentMethodData::Card(domain::Card { card_exp_month: Secret::new("20".to_string()), ..utils::CCardType::default().0 }), @@ -347,7 +347,7 @@ async fn should_fail_payment_for_incorrect_expiry_year() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: domain::PaymentMethodData::Card(domain::Card { card_exp_year: Secret::new("2000".to_string()), ..utils::CCardType::default().0 }), diff --git a/crates/router/tests/connectors/bitpay.rs b/crates/router/tests/connectors/bitpay.rs index d26a4c0cd6bc..9a3bbeb8a297 100644 --- a/crates/router/tests/connectors/bitpay.rs +++ b/crates/router/tests/connectors/bitpay.rs @@ -68,7 +68,7 @@ fn payment_method_details() -> Option { Some(types::PaymentsAuthorizeData { amount: 1, currency: enums::Currency::USD, - payment_method_data: types::api::PaymentMethodData::Crypto(CryptoData { + payment_method_data: types::domain::PaymentMethodData::Crypto(CryptoData { pay_currency: None, }), confirm: true, diff --git a/crates/router/tests/connectors/bluesnap.rs b/crates/router/tests/connectors/bluesnap.rs index ac89e4e6ea58..475953ce1563 100644 --- a/crates/router/tests/connectors/bluesnap.rs +++ b/crates/router/tests/connectors/bluesnap.rs @@ -3,7 +3,7 @@ use std::str::FromStr; use api_models::payments::{Address, AddressDetails}; use common_utils::pii::Email; use masking::Secret; -use router::types::{self, api, storage::enums, ConnectorAuthType, PaymentAddress}; +use router::types::{self, domain, storage::enums, ConnectorAuthType, PaymentAddress}; use crate::{ connector_auth, @@ -401,7 +401,7 @@ async fn should_fail_payment_for_incorrect_cvc() { .make_payment( Some(types::PaymentsAuthorizeData { email: Some(Email::from_str("test@gmail.com").unwrap()), - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_holder_name: Some(masking::Secret::new("John Doe".to_string())), card_cvc: Secret::new("12345".to_string()), ..utils::CCardType::default().0 @@ -427,7 +427,7 @@ async fn should_fail_payment_for_invalid_exp_month() { .make_payment( Some(types::PaymentsAuthorizeData { email: Some(Email::from_str("test@gmail.com").unwrap()), - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_holder_name: Some(masking::Secret::new("John Doe".to_string())), card_exp_month: Secret::new("20".to_string()), ..utils::CCardType::default().0 @@ -453,7 +453,7 @@ async fn should_fail_payment_for_incorrect_expiry_year() { .make_payment( Some(types::PaymentsAuthorizeData { email: Some(Email::from_str("test@gmail.com").unwrap()), - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_holder_name: Some(masking::Secret::new("John Doe".to_string())), card_exp_year: Secret::new("2000".to_string()), ..utils::CCardType::default().0 diff --git a/crates/router/tests/connectors/boku.rs b/crates/router/tests/connectors/boku.rs index 9c8ac961cacc..995cae5a2311 100644 --- a/crates/router/tests/connectors/boku.rs +++ b/crates/router/tests/connectors/boku.rs @@ -1,5 +1,5 @@ use masking::Secret; -use router::types::{self, api, storage::enums}; +use router::types::{self, domain, storage::enums}; use test_utils::connector_auth; use crate::utils::{self, ConnectorActions}; @@ -302,7 +302,7 @@ async fn should_fail_payment_for_incorrect_cvc() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_cvc: Secret::new("12345".to_string()), ..utils::CCardType::default().0 }), @@ -324,7 +324,7 @@ async fn should_fail_payment_for_invalid_exp_month() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_month: Secret::new("20".to_string()), ..utils::CCardType::default().0 }), @@ -346,7 +346,7 @@ async fn should_fail_payment_for_incorrect_expiry_year() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_year: Secret::new("2000".to_string()), ..utils::CCardType::default().0 }), diff --git a/crates/router/tests/connectors/cashtocode.rs b/crates/router/tests/connectors/cashtocode.rs index c8dd4abff234..616a080699bd 100644 --- a/crates/router/tests/connectors/cashtocode.rs +++ b/crates/router/tests/connectors/cashtocode.rs @@ -1,5 +1,5 @@ use api_models::payments::{Address, AddressDetails}; -use router::types::{self, storage::enums}; +use router::types::{self, domain, storage::enums}; use crate::{ connector_auth, @@ -39,7 +39,7 @@ static CONNECTOR: CashtocodeTest = CashtocodeTest {}; impl CashtocodeTest { fn get_payment_authorize_data( payment_method_type: Option, - payment_method_data: types::api::PaymentMethodData, + payment_method_data: types::domain::PaymentMethodData, ) -> Option { Some(types::PaymentsAuthorizeData { amount: 1000, @@ -102,7 +102,7 @@ async fn should_fetch_pay_url_classic() { .make_payment( CashtocodeTest::get_payment_authorize_data( Some(enums::PaymentMethodType::ClassicReward), - api_models::payments::PaymentMethodData::Reward, + domain::payments::PaymentMethodData::Reward, ), CashtocodeTest::get_payment_info(), ) @@ -120,7 +120,7 @@ async fn should_fetch_pay_url_evoucher() { .make_payment( CashtocodeTest::get_payment_authorize_data( Some(enums::PaymentMethodType::Evoucher), - api_models::payments::PaymentMethodData::Reward, + domain::payments::PaymentMethodData::Reward, ), CashtocodeTest::get_payment_info(), ) diff --git a/crates/router/tests/connectors/checkout.rs b/crates/router/tests/connectors/checkout.rs index 1c369332ef2c..5e2592eaa30c 100644 --- a/crates/router/tests/connectors/checkout.rs +++ b/crates/router/tests/connectors/checkout.rs @@ -1,5 +1,5 @@ use masking::Secret; -use router::types::{self, api, storage::enums}; +use router::types::{self, domain, storage::enums}; use crate::{ connector_auth, @@ -320,7 +320,7 @@ async fn should_fail_payment_for_incorrect_cvc() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_cvc: Secret::new("12345".to_string()), ..utils::CCardType::default().0 }), @@ -343,7 +343,7 @@ async fn should_fail_payment_for_invalid_exp_month() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_month: Secret::new("20".to_string()), ..utils::CCardType::default().0 }), @@ -366,7 +366,7 @@ async fn should_fail_payment_for_incorrect_expiry_year() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_year: Secret::new("2000".to_string()), ..utils::CCardType::default().0 }), diff --git a/crates/router/tests/connectors/coinbase.rs b/crates/router/tests/connectors/coinbase.rs index a88f13809449..d580b50fb575 100644 --- a/crates/router/tests/connectors/coinbase.rs +++ b/crates/router/tests/connectors/coinbase.rs @@ -70,7 +70,7 @@ fn payment_method_details() -> Option { Some(types::PaymentsAuthorizeData { amount: 1, currency: enums::Currency::USD, - payment_method_data: types::api::PaymentMethodData::Crypto(CryptoData { + payment_method_data: types::domain::PaymentMethodData::Crypto(CryptoData { pay_currency: None, }), confirm: true, diff --git a/crates/router/tests/connectors/cryptopay.rs b/crates/router/tests/connectors/cryptopay.rs index 4d7825f7deca..014f7a7e3d1d 100644 --- a/crates/router/tests/connectors/cryptopay.rs +++ b/crates/router/tests/connectors/cryptopay.rs @@ -69,7 +69,7 @@ fn payment_method_details() -> Option { Some(types::PaymentsAuthorizeData { amount: 1, currency: enums::Currency::USD, - payment_method_data: types::api::PaymentMethodData::Crypto(CryptoData { + payment_method_data: types::domain::PaymentMethodData::Crypto(CryptoData { pay_currency: Some("XRP".to_string()), }), confirm: true, diff --git a/crates/router/tests/connectors/cybersource.rs b/crates/router/tests/connectors/cybersource.rs index d438ff45f625..98ec44abd8ad 100644 --- a/crates/router/tests/connectors/cybersource.rs +++ b/crates/router/tests/connectors/cybersource.rs @@ -3,7 +3,7 @@ use std::str::FromStr; use common_utils::pii::Email; use masking::Secret; use router::types::{ - self, api, + self, api, domain, storage::{self, enums}, }; @@ -160,7 +160,7 @@ async fn should_fail_payment_for_invalid_exp_month() { let response = Cybersource {} .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_month: Secret::new("13".to_string()), ..utils::CCardType::default().0 }), @@ -185,7 +185,7 @@ async fn should_fail_payment_for_invalid_exp_year() { let response = Cybersource {} .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_year: Secret::new("2022".to_string()), ..utils::CCardType::default().0 }), @@ -203,7 +203,7 @@ async fn should_fail_payment_for_invalid_card_cvc() { let response = Cybersource {} .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_cvc: Secret::new("2131233213".to_string()), ..utils::CCardType::default().0 }), diff --git a/crates/router/tests/connectors/dlocal.rs b/crates/router/tests/connectors/dlocal.rs index 0767bb9ac3c3..b42e7d2f51ea 100644 --- a/crates/router/tests/connectors/dlocal.rs +++ b/crates/router/tests/connectors/dlocal.rs @@ -2,7 +2,7 @@ use std::str::FromStr; use api_models::payments::Address; use masking::Secret; -use router::types::{self, api, storage::enums, PaymentAddress}; +use router::types::{self, api, domain, storage::enums, PaymentAddress}; use crate::{ connector_auth, @@ -289,7 +289,7 @@ async fn should_fail_payment_for_incorrect_card_number() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_number: cards::CardNumber::from_str("1891011").unwrap(), ..utils::CCardType::default().0 }), @@ -310,7 +310,7 @@ async fn should_fail_payment_for_incorrect_cvc() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_cvc: Secret::new("1ad2345".to_string()), ..utils::CCardType::default().0 }), @@ -331,7 +331,7 @@ async fn should_fail_payment_for_invalid_exp_month() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_month: Secret::new("201".to_string()), ..utils::CCardType::default().0 }), @@ -352,7 +352,7 @@ async fn should_fail_payment_for_incorrect_expiry_year() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_year: Secret::new("20001".to_string()), ..utils::CCardType::default().0 }), diff --git a/crates/router/tests/connectors/dummyconnector.rs b/crates/router/tests/connectors/dummyconnector.rs index 75252e85edc2..34a351241b1d 100644 --- a/crates/router/tests/connectors/dummyconnector.rs +++ b/crates/router/tests/connectors/dummyconnector.rs @@ -2,7 +2,7 @@ use std::str::FromStr; use cards::CardNumber; use masking::Secret; -use router::types::{self, api, storage::enums}; +use router::types::{self, domain, storage::enums}; use test_utils::connector_auth; use crate::utils::{self, ConnectorActions}; @@ -305,7 +305,7 @@ async fn should_fail_payment_for_incorrect_card_number() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_number: CardNumber::from_str("1234567891011").unwrap(), ..utils::CCardType::default().0 }), @@ -327,7 +327,7 @@ async fn should_fail_payment_for_incorrect_cvc() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_cvc: Secret::new("12345".to_string()), ..utils::CCardType::default().0 }), @@ -349,7 +349,7 @@ async fn should_fail_payment_for_invalid_exp_month() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_month: Secret::new("20".to_string()), ..utils::CCardType::default().0 }), @@ -371,7 +371,7 @@ async fn should_fail_payment_for_incorrect_expiry_year() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_year: Secret::new("2000".to_string()), ..utils::CCardType::default().0 }), diff --git a/crates/router/tests/connectors/fiserv.rs b/crates/router/tests/connectors/fiserv.rs index 36d5f66dbccd..f564f31df12b 100644 --- a/crates/router/tests/connectors/fiserv.rs +++ b/crates/router/tests/connectors/fiserv.rs @@ -1,7 +1,7 @@ use std::str::FromStr; use masking::Secret; -use router::types::{self, api, storage::enums}; +use router::types::{self, domain, storage::enums}; use serde_json::json; use crate::{ @@ -42,7 +42,7 @@ impl utils::Connector for FiservTest { fn payment_method_details() -> Option { Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_number: cards::CardNumber::from_str("4005550000000019").unwrap(), card_exp_month: Secret::new("02".to_string()), card_exp_year: Secret::new("2035".to_string()), @@ -348,7 +348,7 @@ async fn should_fail_payment_for_incorrect_card_number() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_number: cards::CardNumber::from_str("1234567891011").unwrap(), ..utils::CCardType::default().0 }), @@ -371,7 +371,7 @@ async fn should_fail_payment_for_incorrect_cvc() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_cvc: Secret::new("12345".to_string()), ..utils::CCardType::default().0 }), @@ -394,7 +394,7 @@ async fn should_fail_payment_for_invalid_exp_month() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_month: Secret::new("20".to_string()), ..utils::CCardType::default().0 }), @@ -417,7 +417,7 @@ async fn should_fail_payment_for_incorrect_expiry_year() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_year: Secret::new("2000".to_string()), ..utils::CCardType::default().0 }), diff --git a/crates/router/tests/connectors/forte.rs b/crates/router/tests/connectors/forte.rs index 19dbaa26f350..d09255182e26 100644 --- a/crates/router/tests/connectors/forte.rs +++ b/crates/router/tests/connectors/forte.rs @@ -2,7 +2,7 @@ use std::{str::FromStr, time::Duration}; use cards::CardNumber; use masking::Secret; -use router::types::{self, api, storage::enums}; +use router::types::{self, api, domain, storage::enums}; use crate::{ connector_auth, @@ -41,7 +41,7 @@ static CONNECTOR: ForteTest = ForteTest {}; fn get_payment_data() -> Option { Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_number: CardNumber::from_str("4111111111111111").unwrap(), ..utils::CCardType::default().0 }), @@ -466,7 +466,7 @@ async fn should_fail_payment_for_incorrect_cvc() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_cvc: Secret::new("12345".to_string()), ..utils::CCardType::default().0 }), @@ -488,7 +488,7 @@ async fn should_fail_payment_for_invalid_exp_month() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_month: Secret::new("20".to_string()), ..utils::CCardType::default().0 }), @@ -511,7 +511,7 @@ async fn should_fail_payment_for_incorrect_expiry_year() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_year: Secret::new("2000".to_string()), ..utils::CCardType::default().0 }), @@ -629,7 +629,7 @@ async fn should_fail_for_refund_amount_higher_than_payment_amount() { #[actix_web::test] async fn should_throw_not_implemented_for_unsupported_issuer() { let authorize_data = Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_number: CardNumber::from_str("6759649826438453").unwrap(), ..utils::CCardType::default().0 }), diff --git a/crates/router/tests/connectors/globalpay.rs b/crates/router/tests/connectors/globalpay.rs index 8afa2f0ccf5a..e2ca19869f5b 100644 --- a/crates/router/tests/connectors/globalpay.rs +++ b/crates/router/tests/connectors/globalpay.rs @@ -1,7 +1,7 @@ use std::str::FromStr; use masking::Secret; -use router::types::{self, api, storage::enums, AccessToken, ConnectorAuthType}; +use router::types::{self, api, domain, storage::enums, AccessToken, ConnectorAuthType}; use serde_json::json; use crate::{ @@ -137,7 +137,7 @@ async fn should_fail_payment_for_incorrect_cvc() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_number: cards::CardNumber::from_str("4024007134364842").unwrap(), ..utils::CCardType::default().0 }), @@ -345,7 +345,7 @@ async fn should_fail_payment_for_incorrect_expiry_year() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_year: Secret::new("2000".to_string()), ..utils::CCardType::default().0 }), @@ -367,7 +367,7 @@ async fn should_fail_payment_for_invalid_exp_month() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_month: Secret::new("20".to_string()), ..utils::CCardType::default().0 }), diff --git a/crates/router/tests/connectors/globepay.rs b/crates/router/tests/connectors/globepay.rs index fcf61dd6b33d..7fedcf85dedf 100644 --- a/crates/router/tests/connectors/globepay.rs +++ b/crates/router/tests/connectors/globepay.rs @@ -1,5 +1,5 @@ use masking::Secret; -use router::types::{self, api, storage::enums}; +use router::types::{self, domain, storage::enums}; use crate::{ connector_auth, @@ -304,7 +304,7 @@ async fn should_fail_payment_for_incorrect_cvc() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_cvc: Secret::new("12345".to_string()), ..utils::CCardType::default().0 }), @@ -326,7 +326,7 @@ async fn should_fail_payment_for_invalid_exp_month() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_month: Secret::new("20".to_string()), ..utils::CCardType::default().0 }), @@ -348,7 +348,7 @@ async fn should_fail_payment_for_incorrect_expiry_year() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_year: Secret::new("2000".to_string()), ..utils::CCardType::default().0 }), diff --git a/crates/router/tests/connectors/gocardless.rs b/crates/router/tests/connectors/gocardless.rs index f19e90941b2e..3efb86446d9e 100644 --- a/crates/router/tests/connectors/gocardless.rs +++ b/crates/router/tests/connectors/gocardless.rs @@ -1,5 +1,5 @@ use masking::Secret; -use router::types::{self, api, storage::enums}; +use router::types::{self, domain, storage::enums}; use test_utils::connector_auth; use crate::utils::{self, ConnectorActions}; @@ -302,7 +302,7 @@ async fn should_fail_payment_for_incorrect_cvc() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_cvc: Secret::new("12345".to_string()), ..utils::CCardType::default().0 }), @@ -324,7 +324,7 @@ async fn should_fail_payment_for_invalid_exp_month() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_month: Secret::new("20".to_string()), ..utils::CCardType::default().0 }), @@ -346,7 +346,7 @@ async fn should_fail_payment_for_incorrect_expiry_year() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_year: Secret::new("2000".to_string()), ..utils::CCardType::default().0 }), diff --git a/crates/router/tests/connectors/helcim.rs b/crates/router/tests/connectors/helcim.rs index c9a891988f3b..f434f3b8a65d 100644 --- a/crates/router/tests/connectors/helcim.rs +++ b/crates/router/tests/connectors/helcim.rs @@ -1,5 +1,5 @@ use masking::Secret; -use router::types::{self, api, storage::enums}; +use router::types::{self, domain, storage::enums}; use test_utils::connector_auth; use crate::utils::{self, ConnectorActions}; @@ -302,7 +302,7 @@ async fn should_fail_payment_for_incorrect_cvc() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_cvc: Secret::new("12345".to_string()), ..utils::CCardType::default().0 }), @@ -324,7 +324,7 @@ async fn should_fail_payment_for_invalid_exp_month() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_month: Secret::new("20".to_string()), ..utils::CCardType::default().0 }), @@ -346,7 +346,7 @@ async fn should_fail_payment_for_incorrect_expiry_year() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_year: Secret::new("2000".to_string()), ..utils::CCardType::default().0 }), diff --git a/crates/router/tests/connectors/multisafepay.rs b/crates/router/tests/connectors/multisafepay.rs index 98b615b80341..eafc8a22fff2 100644 --- a/crates/router/tests/connectors/multisafepay.rs +++ b/crates/router/tests/connectors/multisafepay.rs @@ -1,6 +1,6 @@ use api_models::payments::{Address, AddressDetails}; use masking::Secret; -use router::types::{self, api, storage::enums, PaymentAddress}; +use router::types::{self, domain, storage::enums, PaymentAddress}; use crate::{ connector_auth, @@ -331,7 +331,7 @@ async fn should_fail_payment_for_incorrect_cvc() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_cvc: Secret::new("123498765".to_string()), ..utils::CCardType::default().0 }), @@ -350,7 +350,7 @@ async fn should_fail_payment_for_invalid_exp_month() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_month: Secret::new("20".to_string()), ..utils::CCardType::default().0 }), @@ -369,7 +369,7 @@ async fn should_fail_payment_for_incorrect_expiry_year() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_year: Secret::new("2000".to_string()), ..utils::CCardType::default().0 }), diff --git a/crates/router/tests/connectors/nexinets.rs b/crates/router/tests/connectors/nexinets.rs index 174e49fbc82f..7f42048c981e 100644 --- a/crates/router/tests/connectors/nexinets.rs +++ b/crates/router/tests/connectors/nexinets.rs @@ -2,7 +2,7 @@ use std::str::FromStr; use cards::CardNumber; use masking::Secret; -use router::types::{self, api, storage::enums, PaymentsAuthorizeData}; +use router::types::{self, domain, storage::enums, PaymentsAuthorizeData}; use crate::{ connector_auth, @@ -41,7 +41,7 @@ impl utils::Connector for NexinetsTest { fn payment_method_details() -> Option { Some(PaymentsAuthorizeData { currency: diesel_models::enums::Currency::EUR, - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_number: CardNumber::from_str("374111111111111").unwrap(), ..utils::CCardType::default().0 }), @@ -505,7 +505,7 @@ async fn should_fail_payment_for_incorrect_cvc() { let response = CONNECTOR .make_payment( Some(PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_cvc: Secret::new("12345".to_string()), ..utils::CCardType::default().0 }), @@ -527,7 +527,7 @@ async fn should_fail_payment_for_invalid_exp_month() { let response = CONNECTOR .make_payment( Some(PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_month: Secret::new("20".to_string()), ..utils::CCardType::default().0 }), @@ -549,7 +549,7 @@ async fn should_fail_payment_for_incorrect_expiry_year() { let response = CONNECTOR .make_payment( Some(PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_year: Secret::new("2000".to_string()), ..utils::CCardType::default().0 }), diff --git a/crates/router/tests/connectors/nmi.rs b/crates/router/tests/connectors/nmi.rs index 24e1d69a6009..5b569fa497ff 100644 --- a/crates/router/tests/connectors/nmi.rs +++ b/crates/router/tests/connectors/nmi.rs @@ -1,6 +1,6 @@ use std::{str::FromStr, time::Duration}; -use router::types::{self, api, storage::enums}; +use router::types::{self, domain, storage::enums}; use crate::{ connector_auth, @@ -38,7 +38,7 @@ static CONNECTOR: NmiTest = NmiTest {}; fn get_payment_authorize_data() -> Option { Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_number: cards::CardNumber::from_str("4111111111111111").unwrap(), ..utils::CCardType::default().0 }), diff --git a/crates/router/tests/connectors/noon.rs b/crates/router/tests/connectors/noon.rs index 0f736e3e528e..13453580240b 100644 --- a/crates/router/tests/connectors/noon.rs +++ b/crates/router/tests/connectors/noon.rs @@ -2,7 +2,7 @@ use std::str::FromStr; use masking::Secret; use router::types::{ - self, api, + self, storage::{self, enums}, }; @@ -312,7 +312,7 @@ async fn should_fail_payment_for_incorrect_card_number() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(types::domain::Card { card_number: cards::CardNumber::from_str("1234567891011").unwrap(), ..utils::CCardType::default().0 }), @@ -334,7 +334,7 @@ async fn should_fail_payment_for_incorrect_cvc() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(types::domain::Card { card_cvc: Secret::new("12345".to_string()), ..utils::CCardType::default().0 }), @@ -356,7 +356,7 @@ async fn should_fail_payment_for_invalid_exp_month() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(types::domain::Card { card_exp_month: Secret::new("20".to_string()), ..utils::CCardType::default().0 }), @@ -378,7 +378,7 @@ async fn should_fail_payment_for_incorrect_expiry_year() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(types::domain::Card { card_exp_year: Secret::new("2000".to_string()), ..utils::CCardType::default().0 }), diff --git a/crates/router/tests/connectors/nuvei.rs b/crates/router/tests/connectors/nuvei.rs index 5d266fb46fe9..26e141d81627 100644 --- a/crates/router/tests/connectors/nuvei.rs +++ b/crates/router/tests/connectors/nuvei.rs @@ -2,7 +2,7 @@ use std::str::FromStr; use masking::Secret; use router::types::{ - self, api, + self, storage::{self, enums}, }; use serde_json::json; @@ -44,7 +44,7 @@ static CONNECTOR: NuveiTest = NuveiTest {}; fn get_payment_data() -> Option { Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(types::domain::Card { card_number: cards::CardNumber::from_str("4444 3333 2222 1111").unwrap(), ..utils::CCardType::default().0 }), @@ -249,7 +249,7 @@ async fn should_fail_payment_for_incorrect_card_number() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(types::domain::Card { card_number: cards::CardNumber::from_str("1234567891011").unwrap(), ..utils::CCardType::default().0 }), @@ -271,7 +271,7 @@ async fn should_fail_payment_for_incorrect_cvc() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(types::domain::Card { card_cvc: Secret::new("12345".to_string()), ..utils::CCardType::default().0 }), @@ -293,7 +293,7 @@ async fn should_fail_payment_for_invalid_exp_month() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(types::domain::Card { card_exp_month: Secret::new("20".to_string()), ..utils::CCardType::default().0 }), @@ -315,7 +315,7 @@ async fn should_succeed_payment_for_incorrect_expiry_year() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(types::domain::Card { card_number: cards::CardNumber::from_str("4000027891380961").unwrap(), card_exp_year: Secret::new("2000".to_string()), ..utils::CCardType::default().0 diff --git a/crates/router/tests/connectors/opayo.rs b/crates/router/tests/connectors/opayo.rs index 97d744d1e9db..d05bcef11027 100644 --- a/crates/router/tests/connectors/opayo.rs +++ b/crates/router/tests/connectors/opayo.rs @@ -1,7 +1,7 @@ use std::str::FromStr; use masking::Secret; -use router::types::{self, api, storage::enums}; +use router::types::{self, domain, storage::enums}; use crate::{ connector_auth, @@ -307,7 +307,7 @@ async fn should_fail_payment_for_incorrect_card_number() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_number: cards::CardNumber::from_str("1234567891011").unwrap(), ..utils::CCardType::default().0 }), @@ -329,7 +329,7 @@ async fn should_fail_payment_for_incorrect_cvc() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_cvc: Secret::new("12345".to_string()), ..utils::CCardType::default().0 }), @@ -351,7 +351,7 @@ async fn should_fail_payment_for_invalid_exp_month() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_month: Secret::new("20".to_string()), ..utils::CCardType::default().0 }), @@ -373,7 +373,7 @@ async fn should_fail_payment_for_incorrect_expiry_year() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_year: Secret::new("2000".to_string()), ..utils::CCardType::default().0 }), diff --git a/crates/router/tests/connectors/opennode.rs b/crates/router/tests/connectors/opennode.rs index b01b251b24df..9875fdfa23b4 100644 --- a/crates/router/tests/connectors/opennode.rs +++ b/crates/router/tests/connectors/opennode.rs @@ -69,7 +69,7 @@ fn payment_method_details() -> Option { Some(types::PaymentsAuthorizeData { amount: 1, currency: enums::Currency::USD, - payment_method_data: types::api::PaymentMethodData::Crypto(CryptoData { + payment_method_data: types::domain::PaymentMethodData::Crypto(CryptoData { pay_currency: None, }), confirm: true, diff --git a/crates/router/tests/connectors/payeezy.rs b/crates/router/tests/connectors/payeezy.rs index 0cdf709f3626..320db9c776f5 100644 --- a/crates/router/tests/connectors/payeezy.rs +++ b/crates/router/tests/connectors/payeezy.rs @@ -5,7 +5,7 @@ use cards::CardNumber; use masking::Secret; use router::{ core::errors, - types::{self, api, storage::enums, PaymentsAuthorizeData}, + types::{self, storage::enums, PaymentsAuthorizeData}, }; use crate::{ @@ -46,7 +46,7 @@ impl utils::Connector for PayeezyTest { impl PayeezyTest { fn get_payment_data() -> Option { Some(PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(types::domain::Card { card_number: CardNumber::from_str("4012000033330026").unwrap(), ..utils::CCardType::default().0 }), @@ -371,7 +371,7 @@ async fn should_sync_refund() {} #[actix_web::test] async fn should_throw_not_implemented_for_unsupported_issuer() { let authorize_data = Some(PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(types::domain::Card { card_number: CardNumber::from_str("630495060000000000").unwrap(), ..utils::CCardType::default().0 }), @@ -396,7 +396,7 @@ async fn should_fail_payment_for_incorrect_cvc() { let response = CONNECTOR .make_payment( Some(PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(types::domain::Card { card_cvc: Secret::new("12345d".to_string()), ..utils::CCardType::default().0 }), @@ -418,7 +418,7 @@ async fn should_fail_payment_for_invalid_exp_month() { let response = CONNECTOR .make_payment( Some(PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(types::domain::Card { card_exp_month: Secret::new("20".to_string()), ..utils::CCardType::default().0 }), @@ -440,7 +440,7 @@ async fn should_fail_payment_for_incorrect_expiry_year() { let response = CONNECTOR .make_payment( Some(PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(types::domain::Card { card_exp_year: Secret::new("2000".to_string()), ..utils::CCardType::default().0 }), diff --git a/crates/router/tests/connectors/payme.rs b/crates/router/tests/connectors/payme.rs index 62c1bac94d66..0e53f096ef4d 100644 --- a/crates/router/tests/connectors/payme.rs +++ b/crates/router/tests/connectors/payme.rs @@ -3,7 +3,7 @@ use std::str::FromStr; use api_models::payments::{Address, AddressDetails, OrderDetailsWithAmount}; use common_utils::pii::Email; use masking::Secret; -use router::types::{self, api, storage::enums, PaymentAddress}; +use router::types::{self, domain, storage::enums, PaymentAddress}; use crate::{ connector_auth, @@ -90,7 +90,7 @@ fn payment_method_details() -> Option { router_return_url: Some("https://hyperswitch.io".to_string()), webhook_url: Some("https://hyperswitch.io".to_string()), email: Some(Email::from_str("test@gmail.com").unwrap()), - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_number: cards::CardNumber::from_str("4111111111111111").unwrap(), card_cvc: Secret::new("123".to_string()), card_exp_month: Secret::new("10".to_string()), @@ -372,7 +372,7 @@ async fn should_fail_payment_for_incorrect_cvc() { Some(types::PaymentsAuthorizeData { amount: 100, currency: enums::Currency::ILS, - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_cvc: Secret::new("12345".to_string()), ..utils::CCardType::default().0 }), @@ -410,7 +410,7 @@ async fn should_fail_payment_for_invalid_exp_month() { Some(types::PaymentsAuthorizeData { amount: 100, currency: enums::Currency::ILS, - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_month: Secret::new("20".to_string()), ..utils::CCardType::default().0 }), @@ -448,7 +448,7 @@ async fn should_fail_payment_for_incorrect_expiry_year() { Some(types::PaymentsAuthorizeData { amount: 100, currency: enums::Currency::ILS, - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_year: Secret::new("2012".to_string()), ..utils::CCardType::default().0 }), diff --git a/crates/router/tests/connectors/paypal.rs b/crates/router/tests/connectors/paypal.rs index 874f6cda1d9f..adef1d202ae1 100644 --- a/crates/router/tests/connectors/paypal.rs +++ b/crates/router/tests/connectors/paypal.rs @@ -1,7 +1,7 @@ use std::str::FromStr; use masking::Secret; -use router::types::{self, api, storage::enums, AccessToken, ConnectorAuthType}; +use router::types::{self, domain, storage::enums, AccessToken, ConnectorAuthType}; use crate::{ connector_auth, @@ -56,7 +56,7 @@ fn get_default_payment_info() -> Option { fn get_payment_data() -> Option { Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_number: cards::CardNumber::from_str("4000020000000000").unwrap(), ..utils::CCardType::default().0 }), @@ -448,7 +448,7 @@ async fn should_fail_payment_for_incorrect_cvc() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_cvc: Secret::new("12345".to_string()), ..utils::CCardType::default().0 }), @@ -474,7 +474,7 @@ async fn should_fail_payment_for_invalid_exp_month() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_month: Secret::new("20".to_string()), ..utils::CCardType::default().0 }), @@ -500,7 +500,7 @@ async fn should_fail_payment_for_incorrect_expiry_year() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_year: Secret::new("2000".to_string()), ..utils::CCardType::default().0 }), diff --git a/crates/router/tests/connectors/payu.rs b/crates/router/tests/connectors/payu.rs index c73205d9fd35..34d7d1199534 100644 --- a/crates/router/tests/connectors/payu.rs +++ b/crates/router/tests/connectors/payu.rs @@ -89,7 +89,7 @@ async fn should_authorize_gpay_payment() { let authorize_response = Payu {} .authorize_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Wallet(api::WalletData::GooglePay( + payment_method_data: types::domain::PaymentMethodData::Wallet(api::WalletData::GooglePay( api_models::payments::GooglePayWalletData { pm_type: "CARD".to_string(), description: "Visa1234567890".to_string(), diff --git a/crates/router/tests/connectors/placetopay.rs b/crates/router/tests/connectors/placetopay.rs index b7c70c789da2..2290e7b2f323 100644 --- a/crates/router/tests/connectors/placetopay.rs +++ b/crates/router/tests/connectors/placetopay.rs @@ -1,5 +1,5 @@ use masking::Secret; -use router::types::{self, api, storage::enums}; +use router::types::{self, domain, storage::enums}; use test_utils::connector_auth; use crate::utils::{self, ConnectorActions}; @@ -302,7 +302,7 @@ async fn should_fail_payment_for_incorrect_cvc() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_cvc: Secret::new("12345".to_string()), ..utils::CCardType::default().0 }), @@ -324,7 +324,7 @@ async fn should_fail_payment_for_invalid_exp_month() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_month: Secret::new("20".to_string()), ..utils::CCardType::default().0 }), @@ -346,7 +346,7 @@ async fn should_fail_payment_for_incorrect_expiry_year() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_year: Secret::new("2000".to_string()), ..utils::CCardType::default().0 }), diff --git a/crates/router/tests/connectors/powertranz.rs b/crates/router/tests/connectors/powertranz.rs index eca3f86b5690..75d6f7fe1df3 100644 --- a/crates/router/tests/connectors/powertranz.rs +++ b/crates/router/tests/connectors/powertranz.rs @@ -1,5 +1,5 @@ use masking::Secret; -use router::types::{self, api, storage::enums}; +use router::types::{self, domain, storage::enums}; use crate::{ connector_auth, @@ -310,7 +310,7 @@ async fn should_fail_payment_for_incorrect_cvc() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_cvc: Secret::new("12345".to_string()), ..utils::CCardType::default().0 }), @@ -332,7 +332,7 @@ async fn should_fail_payment_for_invalid_exp_month() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_month: Secret::new("20".to_string()), ..utils::CCardType::default().0 }), @@ -354,7 +354,7 @@ async fn should_fail_payment_for_incorrect_expiry_year() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_year: Secret::new("2000".to_string()), ..utils::CCardType::default().0 }), diff --git a/crates/router/tests/connectors/prophetpay.rs b/crates/router/tests/connectors/prophetpay.rs index 94220c11a6aa..9443ae0850bb 100644 --- a/crates/router/tests/connectors/prophetpay.rs +++ b/crates/router/tests/connectors/prophetpay.rs @@ -1,5 +1,5 @@ use masking::Secret; -use router::types::{self, api, storage::enums}; +use router::types::{self, domain, storage::enums}; use test_utils::connector_auth; use crate::utils::{self, ConnectorActions}; @@ -302,7 +302,7 @@ async fn should_fail_payment_for_incorrect_cvc() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_cvc: Secret::new("12345".to_string()), ..utils::CCardType::default().0 }), @@ -324,7 +324,7 @@ async fn should_fail_payment_for_invalid_exp_month() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_month: Secret::new("20".to_string()), ..utils::CCardType::default().0 }), @@ -346,7 +346,7 @@ async fn should_fail_payment_for_incorrect_expiry_year() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_year: Secret::new("2000".to_string()), ..utils::CCardType::default().0 }), diff --git a/crates/router/tests/connectors/rapyd.rs b/crates/router/tests/connectors/rapyd.rs index c53f4e8d8b1f..5cfb8900ecc3 100644 --- a/crates/router/tests/connectors/rapyd.rs +++ b/crates/router/tests/connectors/rapyd.rs @@ -2,7 +2,7 @@ use std::str::FromStr; use futures::future::OptionFuture; use masking::Secret; -use router::types::{self, api, storage::enums}; +use router::types::{self, domain, storage::enums}; use serial_test::serial; use crate::{ @@ -42,7 +42,7 @@ async fn should_only_authorize_payment() { let response = Rapyd {} .authorize_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_number: cards::CardNumber::from_str("4111111111111111").unwrap(), card_exp_month: Secret::new("02".to_string()), card_exp_year: Secret::new("2024".to_string()), @@ -70,7 +70,7 @@ async fn should_authorize_and_capture_payment() { let response = Rapyd {} .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_number: cards::CardNumber::from_str("4111111111111111").unwrap(), card_exp_month: Secret::new("02".to_string()), card_exp_year: Secret::new("2024".to_string()), @@ -153,7 +153,7 @@ async fn should_fail_payment_for_incorrect_card_number() { let response = Rapyd {} .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_number: cards::CardNumber::from_str("0000000000000000").unwrap(), ..utils::CCardType::default().0 }), diff --git a/crates/router/tests/connectors/shift4.rs b/crates/router/tests/connectors/shift4.rs index fe7a232b3e50..2e3349546055 100644 --- a/crates/router/tests/connectors/shift4.rs +++ b/crates/router/tests/connectors/shift4.rs @@ -1,7 +1,7 @@ use std::str::FromStr; use masking::Secret; -use router::types::{self, api, storage::enums}; +use router::types::{self, domain, storage::enums}; use crate::{ connector_auth, @@ -151,7 +151,7 @@ async fn should_fail_payment_for_incorrect_card_number() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_number: cards::CardNumber::from_str("4024007134364842").unwrap(), ..utils::CCardType::default().0 }), @@ -173,7 +173,7 @@ async fn should_succeed_payment_for_incorrect_cvc() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_cvc: Secret::new("asdasd".to_string()), //shift4 accept invalid CVV as it doesn't accept CVV ..utils::CCardType::default().0 }), @@ -192,7 +192,7 @@ async fn should_fail_payment_for_invalid_exp_month() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_month: Secret::new("20".to_string()), ..utils::CCardType::default().0 }), @@ -214,7 +214,7 @@ async fn should_fail_payment_for_incorrect_expiry_year() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_year: Secret::new("2000".to_string()), ..utils::CCardType::default().0 }), diff --git a/crates/router/tests/connectors/square.rs b/crates/router/tests/connectors/square.rs index 62aa8b6d2467..597510d6f91a 100644 --- a/crates/router/tests/connectors/square.rs +++ b/crates/router/tests/connectors/square.rs @@ -2,7 +2,7 @@ use std::{str::FromStr, time::Duration}; use masking::Secret; use router::types::{ - self, api, + self, storage::{self, enums}, PaymentsResponseData, }; @@ -62,7 +62,7 @@ fn payment_method_details() -> Option { fn token_details() -> Option { Some(types::PaymentMethodTokenizationData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(types::domain::Card { card_number: cards::CardNumber::from_str("4111111111111111").unwrap(), card_exp_month: Secret::new("04".to_string()), card_exp_year: Secret::new("2027".to_string()), @@ -435,7 +435,7 @@ async fn should_fail_payment_for_incorrect_cvc() { let token_response = CONNECTOR .create_connector_pm_token( Some(types::PaymentMethodTokenizationData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(types::domain::Card { card_number: cards::CardNumber::from_str("4111111111111111").unwrap(), card_exp_month: Secret::new("11".to_string()), card_exp_year: Secret::new("2027".to_string()), @@ -466,7 +466,7 @@ async fn should_fail_payment_for_invalid_exp_month() { let token_response = CONNECTOR .create_connector_pm_token( Some(types::PaymentMethodTokenizationData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(types::domain::Card { card_number: cards::CardNumber::from_str("4111111111111111").unwrap(), card_exp_month: Secret::new("20".to_string()), card_exp_year: Secret::new("2027".to_string()), @@ -497,7 +497,7 @@ async fn should_fail_payment_for_incorrect_expiry_year() { let token_response = CONNECTOR .create_connector_pm_token( Some(types::PaymentMethodTokenizationData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(types::domain::Card { card_number: cards::CardNumber::from_str("4111111111111111").unwrap(), card_exp_month: Secret::new("11".to_string()), card_exp_year: Secret::new("2000".to_string()), diff --git a/crates/router/tests/connectors/stax.rs b/crates/router/tests/connectors/stax.rs index a1d41f9a92b0..75ff364e3125 100644 --- a/crates/router/tests/connectors/stax.rs +++ b/crates/router/tests/connectors/stax.rs @@ -1,7 +1,7 @@ use std::{str::FromStr, time::Duration}; use masking::Secret; -use router::types::{self, api, storage::enums, PaymentsResponseData}; +use router::types::{self, domain, storage::enums, PaymentsResponseData}; use test_utils::connector_auth; use crate::utils::{self, ConnectorActions}; @@ -63,7 +63,7 @@ fn customer_details() -> Option { fn token_details() -> Option { Some(types::PaymentMethodTokenizationData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_number: cards::CardNumber::from_str("4111111111111111").unwrap(), card_exp_month: Secret::new("04".to_string()), card_exp_year: Secret::new("2027".to_string()), @@ -473,7 +473,7 @@ async fn should_fail_payment_for_incorrect_cvc() { let token_response = CONNECTOR .create_connector_pm_token( Some(types::PaymentMethodTokenizationData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_number: cards::CardNumber::from_str("4111111111111111").unwrap(), card_exp_month: Secret::new("11".to_string()), card_exp_year: Secret::new("2027".to_string()), @@ -511,7 +511,7 @@ async fn should_fail_payment_for_invalid_exp_month() { let token_response = CONNECTOR .create_connector_pm_token( Some(types::PaymentMethodTokenizationData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_number: cards::CardNumber::from_str("4111111111111111").unwrap(), card_exp_month: Secret::new("20".to_string()), card_exp_year: Secret::new("2027".to_string()), @@ -549,7 +549,7 @@ async fn should_fail_payment_for_incorrect_expiry_year() { let token_response = CONNECTOR .create_connector_pm_token( Some(types::PaymentMethodTokenizationData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_number: cards::CardNumber::from_str("4111111111111111").unwrap(), card_exp_month: Secret::new("04".to_string()), card_exp_year: Secret::new("2000".to_string()), diff --git a/crates/router/tests/connectors/stripe.rs b/crates/router/tests/connectors/stripe.rs index 735dedeffbac..3dcaeba45b07 100644 --- a/crates/router/tests/connectors/stripe.rs +++ b/crates/router/tests/connectors/stripe.rs @@ -1,7 +1,7 @@ use std::str::FromStr; use masking::Secret; -use router::types::{self, api, storage::enums}; +use router::types::{self, domain, storage::enums}; use crate::{ connector_auth, @@ -37,7 +37,7 @@ impl utils::Connector for Stripe { fn get_payment_authorize_data() -> Option { Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_number: cards::CardNumber::from_str("4242424242424242").unwrap(), ..utils::CCardType::default().0 }), @@ -158,7 +158,7 @@ async fn should_fail_payment_for_incorrect_card_number() { let response = Stripe {} .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_number: cards::CardNumber::from_str("4024007134364842").unwrap(), ..utils::CCardType::default().0 }), @@ -180,7 +180,7 @@ async fn should_fail_payment_for_invalid_exp_month() { let response = Stripe {} .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_month: Secret::new("13".to_string()), ..utils::CCardType::default().0 }), @@ -202,7 +202,7 @@ async fn should_fail_payment_for_invalid_exp_year() { let response = Stripe {} .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_year: Secret::new("2022".to_string()), ..utils::CCardType::default().0 }), @@ -221,7 +221,7 @@ async fn should_fail_payment_for_invalid_card_cvc() { let response = Stripe {} .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_cvc: Secret::new("12".to_string()), ..utils::CCardType::default().0 }), diff --git a/crates/router/tests/connectors/trustpay.rs b/crates/router/tests/connectors/trustpay.rs index cf659e349dc8..50856b3bd57a 100644 --- a/crates/router/tests/connectors/trustpay.rs +++ b/crates/router/tests/connectors/trustpay.rs @@ -1,7 +1,7 @@ use std::str::FromStr; use masking::Secret; -use router::types::{self, api, storage::enums, BrowserInformation}; +use router::types::{self, api, domain, storage::enums, BrowserInformation}; use crate::{ connector_auth, @@ -53,7 +53,7 @@ fn get_default_browser_info() -> BrowserInformation { fn get_default_payment_authorize_data() -> Option { Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_number: cards::CardNumber::from_str("4200000000000000").unwrap(), card_exp_year: Secret::new("25".to_string()), card_cvc: Secret::new("123".to_string()), @@ -182,7 +182,7 @@ async fn should_sync_refund() { #[actix_web::test] async fn should_fail_payment_for_incorrect_card_number() { let payment_authorize_data = types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_number: cards::CardNumber::from_str("1234567891011").unwrap(), card_exp_year: Secret::new("25".to_string()), card_cvc: Secret::new("123".to_string()), @@ -205,7 +205,7 @@ async fn should_fail_payment_for_incorrect_card_number() { #[actix_web::test] async fn should_fail_payment_for_incorrect_expiry_year() { let payment_authorize_data = Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_number: cards::CardNumber::from_str("4200000000000000").unwrap(), card_exp_year: Secret::new("22".to_string()), card_cvc: Secret::new("123".to_string()), diff --git a/crates/router/tests/connectors/tsys.rs b/crates/router/tests/connectors/tsys.rs index e7a0d747f441..1200541d0251 100644 --- a/crates/router/tests/connectors/tsys.rs +++ b/crates/router/tests/connectors/tsys.rs @@ -2,7 +2,7 @@ use std::{str::FromStr, time::Duration}; use cards::CardNumber; use masking::Secret; -use router::types::{self, api, storage::enums}; +use router::types::{self, domain, storage::enums}; use crate::{ connector_auth, @@ -46,7 +46,7 @@ fn get_default_payment_info() -> Option { fn payment_method_details(amount: i64) -> Option { Some(types::PaymentsAuthorizeData { amount, - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_number: CardNumber::from_str("4111111111111111").unwrap(), ..utils::CCardType::default().0 }), @@ -346,7 +346,7 @@ async fn should_fail_payment_for_incorrect_cvc() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_cvc: Secret::new("".to_string()), ..utils::CCardType::default().0 }), @@ -368,7 +368,7 @@ async fn should_fail_payment_for_invalid_exp_month() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_month: Secret::new("20".to_string()), ..utils::CCardType::default().0 }), @@ -390,7 +390,7 @@ async fn should_fail_payment_for_incorrect_expiry_year() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_year: Secret::new("abcd".to_string()), ..utils::CCardType::default().0 }), diff --git a/crates/router/tests/connectors/utils.rs b/crates/router/tests/connectors/utils.rs index 8effc2479c1a..641253a5612f 100644 --- a/crates/router/tests/connectors/utils.rs +++ b/crates/router/tests/connectors/utils.rs @@ -11,7 +11,7 @@ use router::{ core::{errors, errors::ConnectorError, payments}, db::StorageImpl, routes, services, - types::{self, api, storage::enums, AccessToken, PaymentAddress, RouterData}, + types::{self, storage::enums, AccessToken, PaymentAddress, RouterData}, }; use test_utils::connector_auth::ConnectorAuthType; use tokio::sync::oneshot; @@ -49,7 +49,7 @@ pub struct PaymentInfo { pub connector_customer: Option, pub payment_method_token: Option, #[cfg(feature = "payouts")] - pub payout_method_data: Option, + pub payout_method_data: Option, pub currency: Option, pub country: Option, } @@ -864,14 +864,14 @@ pub struct PaymentCaptureType(pub types::PaymentsCaptureData); pub struct PaymentCancelType(pub types::PaymentsCancelData); pub struct PaymentSyncType(pub types::PaymentsSyncData); pub struct PaymentRefundType(pub types::RefundsData); -pub struct CCardType(pub api::Card); +pub struct CCardType(pub types::domain::Card); pub struct BrowserInfoType(pub types::BrowserInformation); pub struct CustomerType(pub types::ConnectorCustomerData); pub struct TokenType(pub types::PaymentMethodTokenizationData); impl Default for CCardType { fn default() -> Self { - Self(api::Card { + Self(types::domain::Card { card_number: cards::CardNumber::from_str("4200000000000000").unwrap(), card_exp_month: Secret::new("10".to_string()), card_exp_year: Secret::new("2025".to_string()), @@ -890,7 +890,7 @@ impl Default for CCardType { impl Default for PaymentAuthorizeType { fn default() -> Self { let data = types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(CCardType::default().0), + payment_method_data: types::domain::PaymentMethodData::Card(CCardType::default().0), amount: 100, currency: enums::Currency::USD, confirm: true, @@ -1003,7 +1003,7 @@ impl Default for PaymentRefundType { impl Default for CustomerType { fn default() -> Self { let data = types::ConnectorCustomerData { - payment_method_data: types::api::PaymentMethodData::Card(CCardType::default().0), + payment_method_data: types::domain::PaymentMethodData::Card(CCardType::default().0), description: None, email: Email::from_str("test@juspay.in").ok(), phone: None, @@ -1017,7 +1017,7 @@ impl Default for CustomerType { impl Default for TokenType { fn default() -> Self { let data = types::PaymentMethodTokenizationData { - payment_method_data: types::api::PaymentMethodData::Card(CCardType::default().0), + payment_method_data: types::domain::PaymentMethodData::Card(CCardType::default().0), browser_info: None, amount: Some(100), currency: enums::Currency::USD, diff --git a/crates/router/tests/connectors/volt.rs b/crates/router/tests/connectors/volt.rs index 0df21640c777..f46bbb9d49a9 100644 --- a/crates/router/tests/connectors/volt.rs +++ b/crates/router/tests/connectors/volt.rs @@ -1,5 +1,5 @@ use masking::Secret; -use router::types::{self, api, storage::enums}; +use router::types::{self, domain, storage::enums}; use test_utils::connector_auth; use crate::utils::{self, ConnectorActions}; @@ -302,7 +302,7 @@ async fn should_fail_payment_for_incorrect_cvc() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_cvc: Secret::new("12345".to_string()), ..utils::CCardType::default().0 }), @@ -324,7 +324,7 @@ async fn should_fail_payment_for_invalid_exp_month() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_month: Secret::new("20".to_string()), ..utils::CCardType::default().0 }), @@ -346,7 +346,7 @@ async fn should_fail_payment_for_incorrect_expiry_year() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_year: Secret::new("2000".to_string()), ..utils::CCardType::default().0 }), diff --git a/crates/router/tests/connectors/worldline.rs b/crates/router/tests/connectors/worldline.rs index c81dcf15bde2..ea26c6c609c5 100644 --- a/crates/router/tests/connectors/worldline.rs +++ b/crates/router/tests/connectors/worldline.rs @@ -69,7 +69,7 @@ impl WorldlineTest { Some(types::PaymentsAuthorizeData { amount: 3500, currency: enums::Currency::USD, - payment_method_data: types::api::PaymentMethodData::Card(types::api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(types::domain::Card { card_number: cards::CardNumber::from_str(card_number).unwrap(), card_exp_month: Secret::new(card_exp_month.to_string()), card_exp_year: Secret::new(card_exp_year.to_string()), diff --git a/crates/router/tests/connectors/worldpay.rs b/crates/router/tests/connectors/worldpay.rs index bf598e0b37b1..7606a63b68b7 100644 --- a/crates/router/tests/connectors/worldpay.rs +++ b/crates/router/tests/connectors/worldpay.rs @@ -62,7 +62,7 @@ async fn should_authorize_gpay_payment() { let response = conn .authorize_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Wallet( + payment_method_data: types::domain::PaymentMethodData::Wallet( api::WalletData::GooglePay(api_models::payments::GooglePayWalletData { pm_type: "CARD".to_string(), description: "Visa1234567890".to_string(), @@ -97,7 +97,7 @@ async fn should_authorize_applepay_payment() { let response = conn .authorize_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Wallet( + payment_method_data: types::domain::PaymentMethodData::Wallet( api::WalletData::ApplePay(api_models::payments::ApplePayWalletData { payment_data: "someData".to_string(), transaction_identifier: "someId".to_string(), diff --git a/crates/router/tests/connectors/zen.rs b/crates/router/tests/connectors/zen.rs index 14b52e7104e4..d56712fd77d1 100644 --- a/crates/router/tests/connectors/zen.rs +++ b/crates/router/tests/connectors/zen.rs @@ -4,7 +4,7 @@ use api_models::payments::OrderDetailsWithAmount; use cards::CardNumber; use common_utils::pii::Email; use masking::Secret; -use router::types::{self, api, storage::enums}; +use router::types::{self, domain, storage::enums}; use crate::{ connector_auth, @@ -308,7 +308,7 @@ async fn should_fail_payment_for_incorrect_card_number() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_number: CardNumber::from_str("1234567891011").unwrap(), ..utils::CCardType::default().0 }), @@ -349,7 +349,7 @@ async fn should_fail_payment_for_incorrect_cvc() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_cvc: Secret::new("12345".to_string()), ..utils::CCardType::default().0 }), @@ -390,7 +390,7 @@ async fn should_fail_payment_for_invalid_exp_month() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_month: Secret::new("20".to_string()), ..utils::CCardType::default().0 }), @@ -431,7 +431,7 @@ async fn should_fail_payment_for_incorrect_expiry_year() { let response = CONNECTOR .make_payment( Some(types::PaymentsAuthorizeData { - payment_method_data: types::api::PaymentMethodData::Card(api::Card { + payment_method_data: types::domain::PaymentMethodData::Card(domain::Card { card_exp_year: Secret::new("2000".to_string()), ..utils::CCardType::default().0 }), From 1f0d60e64fc9379d8a07a0c72970afc7b491dafa Mon Sep 17 00:00:00 2001 From: Sanchith Hegde <22217505+SanchithHegde@users.noreply.github.com> Date: Tue, 2 Apr 2024 15:43:30 +0530 Subject: [PATCH 14/19] build(deps): update dependencies (#4268) --- Cargo.lock | 3029 +++++++++-------- crates/analytics/Cargo.toml | 53 +- crates/analytics/src/sqlx.rs | 4 +- crates/api_models/Cargo.toml | 22 +- crates/api_models/src/conditional_configs.rs | 2 +- crates/api_models/src/enums.rs | 2 +- crates/cards/Cargo.toml | 8 +- crates/common_enums/Cargo.toml | 12 +- crates/common_enums/src/enums.rs | 20 +- crates/common_utils/Cargo.toml | 42 +- crates/config_importer/Cargo.toml | 12 +- crates/connector_configs/Cargo.toml | 8 +- crates/currency_conversion/Cargo.toml | 8 +- crates/data_models/Cargo.toml | 10 +- crates/diesel_models/Cargo.toml | 18 +- crates/drainer/Cargo.toml | 24 +- crates/euclid/Cargo.toml | 19 +- crates/euclid/src/enums.rs | 12 +- crates/euclid/src/frontend/dir.rs | 8 +- crates/euclid/src/frontend/dir/enums.rs | 24 +- crates/euclid/src/types.rs | 2 +- crates/euclid_macros/Cargo.toml | 9 +- crates/euclid_wasm/Cargo.toml | 13 +- crates/external_services/Cargo.toml | 20 +- crates/hyperswitch_interfaces/Cargo.toml | 8 +- crates/kgraph_utils/Cargo.toml | 7 +- crates/masking/Cargo.toml | 12 +- crates/openapi/Cargo.toml | 4 +- crates/pm_auth/Cargo.toml | 15 +- crates/redis_interface/Cargo.toml | 10 +- crates/router/Cargo.toml | 123 +- crates/router/src/types/domain/user.rs | 8 +- crates/router/src/utils.rs | 6 +- crates/router_derive/Cargo.toml | 17 +- crates/router_env/Cargo.toml | 28 +- crates/scheduler/Cargo.toml | 26 +- crates/storage_impl/Cargo.toml | 31 +- crates/storage_impl/src/errors.rs | 32 - crates/test_utils/Cargo.toml | 22 +- .../tests/connectors/adyen_uk_wh_ui.rs | 2 - .../tests/connectors/authorizedotnet_wh_ui.rs | 2 - .../tests/connectors/bluesnap_wh_ui.rs | 2 - .../tests/connectors/checkout_wh_ui.rs | 2 - .../tests/connectors/stripe_wh_ui.rs | 3 - docker/wasm-build.Dockerfile | 2 +- openapi/openapi_spec.json | 90 +- 46 files changed, 1973 insertions(+), 1860 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8f571b3b922c..f17cd0594805 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,26 +4,26 @@ version = 3 [[package]] name = "actix-codec" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "617a8268e3537fe1d8c9ead925fca49ef6400927ee7bc26750e90ecee14ce4b8" +checksum = "5f7b0a21988c1bf877cf4759ef5ddaac04c1c9fe808c9142ecb78ba97d97a28a" dependencies = [ - "bitflags 1.3.2", - "bytes 1.5.0", + "bitflags 2.5.0", + "bytes 1.6.0", "futures-core", "futures-sink", "memchr", "pin-project-lite", - "tokio 1.36.0", + "tokio 1.37.0", "tokio-util", "tracing", ] [[package]] name = "actix-cors" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b340e9cfa5b08690aae90fb61beb44e9b06f44fe3d0f93781aaa58cfba86245e" +checksum = "0346d8c1f762b41b458ed3145eea914966bb9ad20b9be0d6d463b20d45586370" dependencies = [ "actix-utils", "actix-web", @@ -31,31 +31,31 @@ dependencies = [ "futures-util", "log", "once_cell", - "smallvec 1.11.1", + "smallvec 1.13.2", ] [[package]] name = "actix-http" -version = "3.3.1" +version = "3.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2079246596c18b4a33e274ae10c0e50613f4d32a4198e09c7b93771013fed74" +checksum = "d223b13fd481fc0d1f83bb12659ae774d9e3601814c68a0bc539731698cca743" dependencies = [ "actix-codec", "actix-rt", "actix-service", "actix-utils", - "ahash 0.8.6", - "base64 0.21.5", - "bitflags 1.3.2", + "ahash 0.8.11", + "base64 0.21.7", + "bitflags 2.5.0", "brotli", - "bytes 1.5.0", + "bytes 1.6.0", "bytestring", "derive_more", "encoding_rs", "flate2", "futures-core", - "h2", - "http 0.2.9", + "h2 0.3.25", + "http 0.2.12", "httparse", "httpdate", "itoa", @@ -64,10 +64,10 @@ dependencies = [ "mime", "percent-encoding", "pin-project-lite", - "rand 0.8.5", + "rand", "sha1", - "smallvec 1.11.1", - "tokio 1.36.0", + "smallvec 1.13.2", + "tokio 1.37.0", "tokio-util", "tracing", "zstd", @@ -80,7 +80,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb" dependencies = [ "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] @@ -92,7 +92,7 @@ dependencies = [ "actix-multipart-derive", "actix-utils", "actix-web", - "bytes 1.5.0", + "bytes 1.6.0", "derive_more", "futures-core", "futures-util", @@ -105,7 +105,7 @@ dependencies = [ "serde_json", "serde_plain", "tempfile", - "tokio 1.36.0", + "tokio 1.37.0", ] [[package]] @@ -114,21 +114,21 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0a0a77f836d869f700e5b47ac7c3c8b9c8bc82e4aec861954c6198abee3ebd4d" dependencies = [ - "darling 0.20.3", + "darling 0.20.8", "parse-size", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] name = "actix-router" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d66ff4d247d2b160861fa2866457e85706833527840e4133f8f49aa423a38799" +checksum = "d22475596539443685426b6bdadb926ad0ecaefdfc5fb05e5e3441f15463c511" dependencies = [ "bytestring", - "http 0.2.9", + "http 0.2.12", "regex", "serde", "tracing", @@ -142,7 +142,7 @@ checksum = "28f32d40287d3f402ae0028a9d54bef51af15c8769492826a69d28f81893151d" dependencies = [ "actix-macros", "futures-core", - "tokio 1.36.0", + "tokio 1.37.0", ] [[package]] @@ -156,9 +156,9 @@ dependencies = [ "actix-utils", "futures-core", "futures-util", - "mio 0.8.10", - "socket2 0.5.5", - "tokio 1.36.0", + "mio 0.8.11", + "socket2", + "tokio 1.37.0", "tracing", ] @@ -175,20 +175,19 @@ dependencies = [ [[package]] name = "actix-tls" -version = "3.1.1" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72616e7fbec0aa99c6f3164677fa48ff5a60036d0799c98cab894a44f3e0efc3" +checksum = "d4cce60a2f2b477bc72e5cde0af1812a6e82d8fd85b5570a5dcf2a5bf2c5be5f" dependencies = [ "actix-rt", "actix-service", "actix-utils", "futures-core", - "http 0.2.9", + "http 0.2.12", + "http 1.1.0", "impl-more", "pin-project-lite", - "rustls 0.21.10", - "rustls-webpki", - "tokio 1.36.0", + "tokio 1.37.0", "tokio-rustls 0.23.4", "tokio-util", "tracing", @@ -207,9 +206,9 @@ dependencies = [ [[package]] name = "actix-web" -version = "4.3.1" +version = "4.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd3cb42f9566ab176e1ef0b8b3a896529062b4efc6be0123046095914c4c1c96" +checksum = "43a6556ddebb638c2358714d853257ed226ece6023ef9364f23f0c70737ea984" dependencies = [ "actix-codec", "actix-http", @@ -220,8 +219,8 @@ dependencies = [ "actix-service", "actix-utils", "actix-web-codegen", - "ahash 0.7.7", - "bytes 1.5.0", + "ahash 0.8.11", + "bytes 1.6.0", "bytestring", "cfg-if 1.0.0", "cookie 0.16.2", @@ -229,7 +228,6 @@ dependencies = [ "encoding_rs", "futures-core", "futures-util", - "http 0.2.9", "itoa", "language-tags", "log", @@ -240,8 +238,8 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", - "smallvec 1.11.1", - "socket2 0.4.9", + "smallvec 1.13.2", + "socket2", "time", "url", ] @@ -255,7 +253,7 @@ dependencies = [ "actix-router", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] @@ -273,31 +271,25 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "adler32" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" - [[package]] name = "ahash" -version = "0.7.7" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" +checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" dependencies = [ - "getrandom 0.2.11", + "getrandom", "once_cell", "version_check", ] [[package]] name = "ahash" -version = "0.8.6" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if 1.0.0", - "getrandom 0.2.11", + "getrandom", "once_cell", "version_check", "zerocopy", @@ -305,9 +297,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.1.1" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea5d730647d4fadd988536d06fecce94b7b4f2a7efdae548f1cf4b63205518ab" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] @@ -340,7 +332,7 @@ dependencies = [ "actix-web", "api_models", "async-trait", - "aws-config 1.1.8", + "aws-config 1.1.9", "aws-sdk-lambda", "aws-smithy-types 1.1.8", "bigdecimal", @@ -348,7 +340,7 @@ dependencies = [ "diesel_models", "error-stack", "external_services", - "futures 0.3.28", + "futures 0.3.30", "hyperswitch_interfaces", "masking", "once_cell", @@ -359,10 +351,10 @@ dependencies = [ "serde_json", "sqlx", "storage_impl", - "strum 0.25.0", + "strum 0.26.2", "thiserror", "time", - "tokio 1.36.0", + "tokio 1.37.0", ] [[package]] @@ -388,9 +380,9 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] name = "anstyle" -version = "1.0.0" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" [[package]] name = "anyhow" @@ -416,7 +408,7 @@ dependencies = [ "router_derive", "serde", "serde_json", - "strum 0.25.0", + "strum 0.26.2", "time", "url", "utoipa", @@ -424,15 +416,15 @@ dependencies = [ [[package]] name = "arc-swap" -version = "1.6.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6" +checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457" [[package]] name = "argon2" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17ba4cac0a46bc1d2912652a751c47f2a9f3a7fe89bcae2275d418f5270402f9" +checksum = "3c3610892ee6e0cbce8ae2700349fcf8f98adb0dbfbee85aec3c9179d29cc072" dependencies = [ "base64ct", "blake2", @@ -454,9 +446,9 @@ checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "asn1-rs" -version = "0.5.2" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f6fd5ddaf0351dff5b8da21b2fb4ff8e08ddd02857f0bf69c47639106c0fff0" +checksum = "22ad1373757efa0f70ec53939aabc7152e1591cb485208052993070ac8d2429d" dependencies = [ "asn1-rs-derive", "asn1-rs-impl", @@ -470,25 +462,25 @@ dependencies = [ [[package]] name = "asn1-rs-derive" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "726535892e8eae7e70657b4c8ea93d26b8553afb1ce617caee529ef96d7dee6c" +checksum = "7378575ff571966e99a744addeff0bff98b8ada0dedf1956d59e634db95eaac1" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", - "synstructure", + "syn 2.0.57", + "synstructure 0.13.1", ] [[package]] name = "asn1-rs-impl" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2777730b2039ac0f95f093556e61b6d26cebed5393ca6f152717777cec3a42ed" +checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.57", ] [[package]] @@ -510,32 +502,21 @@ dependencies = [ "bb8", "diesel", "thiserror", - "tokio 1.36.0", + "tokio 1.37.0", "tracing", ] -[[package]] -name = "async-channel" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" -dependencies = [ - "concurrent-queue", - "event-listener", - "futures-core", -] - [[package]] name = "async-compression" -version = "0.4.3" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb42b2197bf15ccb092b62c74515dbd8b86d0effd934795f6687c93b6e679a2c" +checksum = "a116f46a969224200a0a97f29cfd4c50e7534e4b4826bd23ea2c3c533039c82c" dependencies = [ "flate2", "futures-core", "memchr", "pin-project-lite", - "tokio 1.36.0", + "tokio 1.37.0", ] [[package]] @@ -566,25 +547,25 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] name = "async-trait" -version = "0.1.77" +version = "0.1.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" +checksum = "a507401cad91ec6a857ed5513a2073c82a9b9048762b885bb98655b306964681" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] name = "atoi" -version = "1.0.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7c57d12312ff59c811c0643f4d80830505833c9ffaebd193d819392b265be8e" +checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528" dependencies = [ "num-traits", ] @@ -595,17 +576,27 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c59bdb34bc650a32731b31bd8f0829cc15d24a708ee31559e0bb34f2bc320cba" +[[package]] +name = "atomic-write-file" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8204db279bf648d64fe845bd8840f78b39c8132ed4d6a4194c3b10d4b4cfb0b" +dependencies = [ + "nix", + "rand", +] + [[package]] name = "autocfg" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" [[package]] name = "awc" -version = "3.1.1" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87ef547a81796eb2dfe9b345aba34c2e08391a0502493711395b36dd64052b69" +checksum = "68c09cc97310b926f01621faee652f3d1b0962545a3cec6c9ac07def9ea36c2c" dependencies = [ "actix-codec", "actix-http", @@ -613,27 +604,26 @@ dependencies = [ "actix-service", "actix-tls", "actix-utils", - "ahash 0.7.7", - "base64 0.21.5", - "bytes 1.5.0", + "base64 0.21.7", + "bytes 1.6.0", "cfg-if 1.0.0", "cookie 0.16.2", "derive_more", "futures-core", "futures-util", - "h2", - "http 0.2.9", + "h2 0.3.25", + "http 0.2.12", "itoa", "log", "mime", "percent-encoding", "pin-project-lite", - "rand 0.8.5", + "rand", "rustls 0.20.9", "serde", "serde_json", "serde_urlencoded", - "tokio 1.36.0", + "tokio 1.37.0", ] [[package]] @@ -653,14 +643,14 @@ dependencies = [ "aws-smithy-json 0.55.3", "aws-smithy-types 0.55.3", "aws-types 0.55.3", - "bytes 1.5.0", + "bytes 1.6.0", "fastrand 1.9.0", "hex", - "http 0.2.9", - "hyper", + "http 0.2.12", + "hyper 0.14.28", "ring 0.16.20", "time", - "tokio 1.36.0", + "tokio 1.37.0", "tower", "tracing", "zeroize", @@ -668,31 +658,32 @@ dependencies = [ [[package]] name = "aws-config" -version = "1.1.8" +version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f4084d18094aec9f79d509f4cb6ccf6b613c5037e32f32e74312e52b836e366" +checksum = "297b64446175a73987cedc3c438d79b2a654d0fff96f65ff530fbe039347644c" dependencies = [ "aws-credential-types 1.1.8", "aws-runtime", - "aws-sdk-sso 1.17.0", + "aws-sdk-sso 1.18.0", "aws-sdk-ssooidc", - "aws-sdk-sts 1.17.0", - "aws-smithy-async 1.1.8", + "aws-sdk-sts 1.18.0", + "aws-smithy-async 1.2.0", "aws-smithy-http 0.60.7", "aws-smithy-json 0.60.7", "aws-smithy-runtime", "aws-smithy-runtime-api", "aws-smithy-types 1.1.8", "aws-types 1.1.8", - "bytes 1.5.0", - "fastrand 2.0.1", + "bytes 1.6.0", + "fastrand 2.0.2", "hex", - "http 0.2.9", - "hyper", + "http 0.2.12", + "hyper 0.14.28", "ring 0.17.8", "time", - "tokio 1.36.0", + "tokio 1.37.0", "tracing", + "url", "zeroize", ] @@ -705,7 +696,7 @@ dependencies = [ "aws-smithy-async 0.55.3", "aws-smithy-types 0.55.3", "fastrand 1.9.0", - "tokio 1.36.0", + "tokio 1.37.0", "tracing", "zeroize", ] @@ -716,7 +707,7 @@ version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa8587ae17c8e967e4b05a62d495be2fb7701bec52a97f7acfe8a29f938384c8" dependencies = [ - "aws-smithy-async 1.1.8", + "aws-smithy-async 1.2.0", "aws-smithy-runtime-api", "aws-smithy-types 1.1.8", "zeroize", @@ -731,7 +722,7 @@ dependencies = [ "aws-smithy-http 0.55.3", "aws-smithy-types 0.55.3", "aws-types 0.55.3", - "http 0.2.9", + "http 0.2.12", "regex", "tracing", ] @@ -746,9 +737,9 @@ dependencies = [ "aws-smithy-http 0.55.3", "aws-smithy-types 0.55.3", "aws-types 0.55.3", - "bytes 1.5.0", - "http 0.2.9", - "http-body", + "bytes 1.6.0", + "http 0.2.12", + "http-body 0.4.6", "lazy_static", "percent-encoding", "pin-project-lite", @@ -763,16 +754,16 @@ checksum = "b13dc54b4b49f8288532334bba8f87386a40571c47c37b1304979b556dc613c8" dependencies = [ "aws-credential-types 1.1.8", "aws-sigv4 1.2.0", - "aws-smithy-async 1.1.8", + "aws-smithy-async 1.2.0", "aws-smithy-eventstream 0.60.4", "aws-smithy-http 0.60.7", "aws-smithy-runtime-api", "aws-smithy-types 1.1.8", "aws-types 1.1.8", - "bytes 1.5.0", - "fastrand 2.0.1", - "http 0.2.9", - "http-body", + "bytes 1.6.0", + "fastrand 2.0.2", + "http 0.2.12", + "http-body 0.4.6", "percent-encoding", "pin-project-lite", "tracing", @@ -796,8 +787,8 @@ dependencies = [ "aws-smithy-json 0.55.3", "aws-smithy-types 0.55.3", "aws-types 0.55.3", - "bytes 1.5.0", - "http 0.2.9", + "bytes 1.6.0", + "http 0.2.12", "regex", "tokio-stream", "tower", @@ -806,13 +797,13 @@ dependencies = [ [[package]] name = "aws-sdk-lambda" -version = "1.17.0" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2e4c45d7ce6e957489b9be24963c7fb04a6b0d2e8c7dfcbca032f9bf25b0d4d" +checksum = "a0c5446405655a27f8f98974668f6e10b6740902afd5ab56045b464b9b9a845a" dependencies = [ "aws-credential-types 1.1.8", "aws-runtime", - "aws-smithy-async 1.1.8", + "aws-smithy-async 1.2.0", "aws-smithy-eventstream 0.60.4", "aws-smithy-http 0.60.7", "aws-smithy-json 0.60.7", @@ -820,8 +811,8 @@ dependencies = [ "aws-smithy-runtime-api", "aws-smithy-types 1.1.8", "aws-types 1.1.8", - "bytes 1.5.0", - "http 0.2.9", + "bytes 1.6.0", + "http 0.2.12", "once_cell", "regex-lite", "tracing", @@ -848,9 +839,9 @@ dependencies = [ "aws-smithy-types 0.55.3", "aws-smithy-xml 0.55.3", "aws-types 0.55.3", - "bytes 1.5.0", - "http 0.2.9", - "http-body", + "bytes 1.6.0", + "http 0.2.12", + "http-body 0.4.6", "once_cell", "percent-encoding", "regex", @@ -877,8 +868,8 @@ dependencies = [ "aws-smithy-json 0.55.3", "aws-smithy-types 0.55.3", "aws-types 0.55.3", - "bytes 1.5.0", - "http 0.2.9", + "bytes 1.6.0", + "http 0.2.12", "regex", "tokio-stream", "tower", @@ -902,8 +893,8 @@ dependencies = [ "aws-smithy-json 0.55.3", "aws-smithy-types 0.55.3", "aws-types 0.55.3", - "bytes 1.5.0", - "http 0.2.9", + "bytes 1.6.0", + "http 0.2.12", "regex", "tokio-stream", "tower", @@ -912,21 +903,21 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.17.0" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5cc34f5925899739a3f125bd3f7d37d081234a3df218feb9c9d337fd4c70e72" +checksum = "019a07902c43b03167ea5df0182f0cb63fae89f9a9682c44d18cf2e4a042cb34" dependencies = [ "aws-credential-types 1.1.8", "aws-runtime", - "aws-smithy-async 1.1.8", + "aws-smithy-async 1.2.0", "aws-smithy-http 0.60.7", "aws-smithy-json 0.60.7", "aws-smithy-runtime", "aws-smithy-runtime-api", "aws-smithy-types 1.1.8", "aws-types 1.1.8", - "bytes 1.5.0", - "http 0.2.9", + "bytes 1.6.0", + "http 0.2.12", "once_cell", "regex-lite", "tracing", @@ -934,21 +925,21 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.17.0" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7327cddd32b1a6f2aaeaadb1336b671a7975e96a999d3b1bcf5aa47932dc6ddb" +checksum = "04c46ee08a48a7f4eaa4ad201dcc1dd537b49c50859d14d4510e00ad9d3f9af2" dependencies = [ "aws-credential-types 1.1.8", "aws-runtime", - "aws-smithy-async 1.1.8", + "aws-smithy-async 1.2.0", "aws-smithy-http 0.60.7", "aws-smithy-json 0.60.7", "aws-smithy-runtime", "aws-smithy-runtime-api", "aws-smithy-types 1.1.8", "aws-types 1.1.8", - "bytes 1.5.0", - "http 0.2.9", + "bytes 1.6.0", + "http 0.2.12", "once_cell", "regex-lite", "tracing", @@ -973,8 +964,8 @@ dependencies = [ "aws-smithy-types 0.55.3", "aws-smithy-xml 0.55.3", "aws-types 0.55.3", - "bytes 1.5.0", - "http 0.2.9", + "bytes 1.6.0", + "http 0.2.12", "regex", "tower", "tracing", @@ -982,13 +973,13 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.17.0" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c11981cdb80e8e205e22beb6630a8bdec380a1256bd29efaab34aaebd07cfb9" +checksum = "f752ac730125ca6017f72f9db5ec1772c9ecc664f87aa7507a7d81b023c23713" dependencies = [ "aws-credential-types 1.1.8", "aws-runtime", - "aws-smithy-async 1.1.8", + "aws-smithy-async 1.2.0", "aws-smithy-http 0.60.7", "aws-smithy-json 0.60.7", "aws-smithy-query 0.60.7", @@ -997,7 +988,7 @@ dependencies = [ "aws-smithy-types 1.1.8", "aws-smithy-xml 0.60.7", "aws-types 1.1.8", - "http 0.2.9", + "http 0.2.12", "once_cell", "regex-lite", "tracing", @@ -1014,7 +1005,7 @@ dependencies = [ "aws-smithy-eventstream 0.55.3", "aws-smithy-http 0.55.3", "aws-types 0.55.3", - "http 0.2.9", + "http 0.2.12", "tracing", ] @@ -1026,11 +1017,11 @@ checksum = "9d2ce6f507be68e968a33485ced670111d1cbad161ddbbab1e313c03d37d8f4c" dependencies = [ "aws-smithy-eventstream 0.55.3", "aws-smithy-http 0.55.3", - "bytes 1.5.0", + "bytes 1.6.0", "form_urlencoded", "hex", "hmac", - "http 0.2.9", + "http 0.2.12", "once_cell", "percent-encoding", "regex", @@ -1050,11 +1041,11 @@ dependencies = [ "aws-smithy-http 0.60.7", "aws-smithy-runtime-api", "aws-smithy-types 1.1.8", - "bytes 1.5.0", + "bytes 1.6.0", "form_urlencoded", "hex", "hmac", - "http 0.2.9", + "http 0.2.12", "http 1.1.0", "once_cell", "percent-encoding", @@ -1071,19 +1062,19 @@ checksum = "13bda3996044c202d75b91afeb11a9afae9db9a721c6a7a427410018e286b880" dependencies = [ "futures-util", "pin-project-lite", - "tokio 1.36.0", + "tokio 1.37.0", "tokio-stream", ] [[package]] name = "aws-smithy-async" -version = "1.1.8" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d26ea8fa03025b2face2b3038a63525a10891e3d8829901d502e5384a0d8cd46" +checksum = "f7a41ccd6b74401a49ca828617049e5c23d83163d330a4f90a8081aadee0ac45" dependencies = [ "futures-util", "pin-project-lite", - "tokio 1.36.0", + "tokio 1.37.0", ] [[package]] @@ -1094,12 +1085,12 @@ checksum = "07ed8b96d95402f3f6b8b57eb4e0e45ee365f78b1a924faf20ff6e97abf1eae6" dependencies = [ "aws-smithy-http 0.55.3", "aws-smithy-types 0.55.3", - "bytes 1.5.0", + "bytes 1.6.0", "crc32c", "crc32fast", "hex", - "http 0.2.9", - "http-body", + "http 0.2.12", + "http-body 0.4.6", "md-5", "pin-project-lite", "sha1", @@ -1117,16 +1108,16 @@ dependencies = [ "aws-smithy-http 0.55.3", "aws-smithy-http-tower", "aws-smithy-types 0.55.3", - "bytes 1.5.0", + "bytes 1.6.0", "fastrand 1.9.0", - "http 0.2.9", - "http-body", - "hyper", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.28", "hyper-rustls 0.23.2", "lazy_static", "pin-project-lite", "rustls 0.20.9", - "tokio 1.36.0", + "tokio 1.37.0", "tower", "tracing", ] @@ -1138,7 +1129,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "460c8da5110835e3d9a717c61f5556b20d03c32a1dec57f8fc559b360f733bb8" dependencies = [ "aws-smithy-types 0.55.3", - "bytes 1.5.0", + "bytes 1.6.0", "crc32fast", ] @@ -1149,7 +1140,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6363078f927f612b970edf9d1903ef5cef9a64d1e8423525ebb1f0a1633c858" dependencies = [ "aws-smithy-types 1.1.8", - "bytes 1.5.0", + "bytes 1.6.0", "crc32fast", ] @@ -1161,17 +1152,17 @@ checksum = "2b3b693869133551f135e1f2c77cb0b8277d9e3e17feaf2213f735857c4f0d28" dependencies = [ "aws-smithy-eventstream 0.55.3", "aws-smithy-types 0.55.3", - "bytes 1.5.0", + "bytes 1.6.0", "bytes-utils", "futures-core", - "http 0.2.9", - "http-body", - "hyper", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.28", "once_cell", "percent-encoding", "pin-project-lite", "pin-utils", - "tokio 1.36.0", + "tokio 1.37.0", "tokio-util", "tracing", ] @@ -1185,11 +1176,11 @@ dependencies = [ "aws-smithy-eventstream 0.60.4", "aws-smithy-runtime-api", "aws-smithy-types 1.1.8", - "bytes 1.5.0", + "bytes 1.6.0", "bytes-utils", "futures-core", - "http 0.2.9", - "http-body", + "http 0.2.12", + "http-body 0.4.6", "once_cell", "percent-encoding", "pin-project-lite", @@ -1205,9 +1196,9 @@ checksum = "3ae4f6c5798a247fac98a867698197d9ac22643596dc3777f0c76b91917616b9" dependencies = [ "aws-smithy-http 0.55.3", "aws-smithy-types 0.55.3", - "bytes 1.5.0", - "http 0.2.9", - "http-body", + "bytes 1.6.0", + "http 0.2.12", + "http-body 0.4.6", "pin-project-lite", "tower", "tracing", @@ -1257,22 +1248,22 @@ version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec81002d883e5a7fd2bb063d6fb51c4999eb55d404f4fff3dd878bf4733b9f01" dependencies = [ - "aws-smithy-async 1.1.8", + "aws-smithy-async 1.2.0", "aws-smithy-http 0.60.7", "aws-smithy-runtime-api", "aws-smithy-types 1.1.8", - "bytes 1.5.0", - "fastrand 2.0.1", - "h2", - "http 0.2.9", - "http-body", - "hyper", + "bytes 1.6.0", + "fastrand 2.0.2", + "h2 0.3.25", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.28", "hyper-rustls 0.24.2", "once_cell", "pin-project-lite", "pin-utils", "rustls 0.21.10", - "tokio 1.36.0", + "tokio 1.37.0", "tracing", ] @@ -1282,13 +1273,13 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9acb931e0adaf5132de878f1398d83f8677f90ba70f01f65ff87f6d7244be1c5" dependencies = [ - "aws-smithy-async 1.1.8", + "aws-smithy-async 1.2.0", "aws-smithy-types 1.1.8", - "bytes 1.5.0", - "http 0.2.9", + "bytes 1.6.0", + "http 0.2.12", "http 1.1.0", "pin-project-lite", - "tokio 1.36.0", + "tokio 1.37.0", "tracing", "zeroize", ] @@ -1313,11 +1304,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "abe14dceea1e70101d38fbf2a99e6a34159477c0fb95e68e05c66bd7ae4c3729" dependencies = [ "base64-simd", - "bytes 1.5.0", + "bytes 1.6.0", "bytes-utils", "futures-core", - "http 0.2.9", - "http-body", + "http 0.2.12", + "http-body 0.4.6", "itoa", "num-integer", "pin-project-lite", @@ -1325,7 +1316,7 @@ dependencies = [ "ryu", "serde", "time", - "tokio 1.36.0", + "tokio 1.37.0", "tokio-util", ] @@ -1358,7 +1349,7 @@ dependencies = [ "aws-smithy-client", "aws-smithy-http 0.55.3", "aws-smithy-types 0.55.3", - "http 0.2.9", + "http 0.2.12", "rustc_version 0.4.0", "tracing", ] @@ -1370,10 +1361,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0dbf2f3da841a8930f159163175cf6a3d16ddde517c1b0fba7aa776822800f40" dependencies = [ "aws-credential-types 1.1.8", - "aws-smithy-async 1.1.8", + "aws-smithy-async 1.2.0", "aws-smithy-runtime-api", "aws-smithy-types 1.1.8", - "http 0.2.9", + "http 0.2.12", "rustc_version 0.4.0", "tracing", ] @@ -1387,11 +1378,11 @@ dependencies = [ "async-trait", "axum-core", "bitflags 1.3.2", - "bytes 1.5.0", + "bytes 1.6.0", "futures-util", - "http 0.2.9", - "http-body", - "hyper", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.28", "itoa", "matchit", "memchr", @@ -1413,10 +1404,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" dependencies = [ "async-trait", - "bytes 1.5.0", + "bytes 1.6.0", "futures-util", - "http 0.2.9", - "http-body", + "http 0.2.12", + "http-body 0.4.6", "mime", "rustversion", "tower-layer", @@ -1425,15 +1416,15 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.69" +version = "0.3.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" dependencies = [ "addr2line", "cc", "cfg-if 1.0.0", "libc", - "miniz_oxide 0.7.1", + "miniz_oxide", "object", "rustc-demangle", ] @@ -1446,9 +1437,15 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.5" +version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "base64" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" [[package]] name = "base64-simd" @@ -1468,15 +1465,15 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "bb8" -version = "0.8.1" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98b4b0f25f18bcdc3ac72bdb486ed0acf7e185221fd4dc985bc15db5800b0ba2" +checksum = "df7c2093d15d6a1d33b1f972e1c5ea3177748742b97a5f392aa83a65262c6780" dependencies = [ "async-trait", "futures-channel", "futures-util", "parking_lot 0.12.1", - "tokio 1.36.0", + "tokio 1.37.0", ] [[package]] @@ -1523,9 +1520,12 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +dependencies = [ + "serde", +] [[package]] name = "bitvec" @@ -1545,30 +1545,20 @@ version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" dependencies = [ - "digest 0.10.7", + "digest", ] [[package]] name = "blake3" -version = "1.4.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "729b71f35bd3fa1a4c86b85d32c8b9069ea7fe14f7a53cfabb65f62d4265b888" +checksum = "30cca6d3674597c30ddf2c587bf8d9d65c9a84d2326d941cc79c9842dfe0ef52" dependencies = [ "arrayref", "arrayvec", "cc", "cfg-if 1.0.0", "constant_time_eq", - "digest 0.10.7", -] - -[[package]] -name = "block-buffer" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" -dependencies = [ - "generic-array", ] [[package]] @@ -1582,9 +1572,9 @@ dependencies = [ [[package]] name = "borsh" -version = "1.2.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf617fabf5cdbdc92f774bfe5062d870f228b80056d41180797abf48bed4056e" +checksum = "f58b559fd6448c6e2fd0adb5720cd98a2506594cafa4737ff98c396f3e82f667" dependencies = [ "borsh-derive", "cfg_aliases", @@ -1592,23 +1582,23 @@ dependencies = [ [[package]] name = "borsh-derive" -version = "1.2.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f404657a7ea7b5249e36808dff544bc88a28f26e0ac40009f674b7a009d14be3" +checksum = "7aadb5b6ccbd078890f6d7003694e33816e6b784358f18e15e7e6d9f065a57cd" dependencies = [ "once_cell", - "proc-macro-crate 2.0.0", + "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", "syn_derive", ] [[package]] name = "brotli" -version = "3.4.0" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "516074a47ef4bce09577a3b379392300159ce5b1ba2e501ff1c819950066100f" +checksum = "d640d25bc63c50fb1f0b545ffd80207d2e10a4c965530809b40ba3386825c391" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -1617,9 +1607,9 @@ dependencies = [ [[package]] name = "brotli-decompressor" -version = "2.5.0" +version = "2.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da74e2b81409b1b743f8f0c62cc6254afefb8b8e50bbfe3735550f7aeefa3448" +checksum = "4e2e4afe60d7dd600fdd3de8d0f08c2b7ec039712e3b6137ff98b7004e82de4f" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -1627,9 +1617,9 @@ dependencies = [ [[package]] name = "bstr" -version = "1.6.0" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6798148dccfbff0fae41c7574d2fa8f1ef3492fba0face179de5d8d447d67b05" +checksum = "05efc5cfd9110c8416e471df0e96702d58690178e206e61b7173706673c93706" dependencies = [ "memchr", "serde", @@ -1643,9 +1633,9 @@ checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" [[package]] name = "bytecheck" -version = "0.6.11" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b6372023ac861f6e6dc89c8344a8f398fb42aaba2b5dbc649ca0c0e9dbcb627" +checksum = "23cdc57ce23ac53c931e88a43d06d070a6fd142f2617be5855eb75efc9beb1c2" dependencies = [ "bytecheck_derive", "ptr_meta", @@ -1654,9 +1644,9 @@ dependencies = [ [[package]] name = "bytecheck_derive" -version = "0.6.11" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7ec4c6f261935ad534c0c22dbef2201b45918860eb1c574b972bd213a76af61" +checksum = "3db406d29fbcd95542e92559bed4d8ad92636d1ca8b3b72ede10b4bcc010e659" dependencies = [ "proc-macro2", "quote", @@ -1665,15 +1655,15 @@ dependencies = [ [[package]] name = "bytecount" -version = "0.6.4" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad152d03a2c813c80bb94fedbf3a3f02b28f793e39e7c214c8a0bcc196343de7" +checksum = "e1e5f035d16fc623ae5f74981db80a439803888314e3a555fd6f04acd51a3205" [[package]] name = "bytemuck" -version = "1.14.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" +checksum = "5d6d68c57235a3a081186990eca2867354726650f42f7516ca50c28d6281fd15" [[package]] name = "byteorder" @@ -1693,27 +1683,27 @@ dependencies = [ [[package]] name = "bytes" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" [[package]] name = "bytes-utils" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e47d3a8076e283f3acd27400535992edb3ba4b5bb72f8891ad8fbe7932a7d4b9" +checksum = "7dafe3a8757b027e2be6e4e5601ed563c55989fcf1546e933c66c8eb3a058d35" dependencies = [ - "bytes 1.5.0", + "bytes 1.6.0", "either", ] [[package]] name = "bytestring" -version = "1.3.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "238e4886760d98c4f899360c834fa93e62cf7f721ac3c2da375cbdf4b8679aae" +checksum = "74d80203ea6b29df88012294f62733de21cfeab47f17b41af3a38bc30a03ee72" dependencies = [ - "bytes 1.5.0", + "bytes 1.6.0", ] [[package]] @@ -1742,9 +1732,9 @@ dependencies = [ [[package]] name = "cargo-platform" -version = "0.1.3" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cfa25e60aea747ec7e1124f238816749faa93759c6ff5b31f1ccdda137f4479" +checksum = "694c8807f2ae16faecc43dc17d74b3eb042482789fd0eb64b39a2e04e087053f" dependencies = [ "serde", ] @@ -1784,9 +1774,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.0.83" +version = "1.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" dependencies = [ "jobserver", "libc", @@ -1821,17 +1811,11 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" -[[package]] -name = "checked_int_cast" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17cc5e6b5ab06331c33589842070416baa137e8b0eb912b008cfd4a78ada7919" - [[package]] name = "chrono" -version = "0.4.31" +version = "0.4.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" +checksum = "8eaf5903dcbc0a39312feb77df2ff4c76387d591b9fc7b04a238dcf8bb62639a" dependencies = [ "android-tzdata", "iana-time-zone", @@ -1839,14 +1823,14 @@ dependencies = [ "num-traits", "serde", "wasm-bindgen", - "windows-targets 0.48.5", + "windows-targets 0.52.4", ] [[package]] name = "chrono-tz" -version = "0.8.3" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1369bc6b9e9a7dfdae2055f6ec151fe9c554a9d23d357c0237cee2e25eaabb7" +checksum = "d59ae0466b83e838b81a54256c39d5d7c20b9d7daa10510a242d9b75abd5936e" dependencies = [ "chrono", "chrono-tz-build", @@ -1855,9 +1839,9 @@ dependencies = [ [[package]] name = "chrono-tz-build" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2f5ebdc942f57ed96d560a6d1a459bae5851102a25d5bf89dc04ae453e31ecf" +checksum = "433e39f13c9a060046954e0592a8d0a4bcb1040125cbf91cb8ee58964cfb350f" dependencies = [ "parse-zoneinfo", "phf", @@ -1866,9 +1850,9 @@ dependencies = [ [[package]] name = "ciborium" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "effd91f6c78e5a4ace8a5d3c0b6bfaec9e2baaef55f3efc00e45fb2e477ee926" +checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e" dependencies = [ "ciborium-io", "ciborium-ll", @@ -1877,15 +1861,15 @@ dependencies = [ [[package]] name = "ciborium-io" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdf919175532b369853f5d5e20b26b43112613fd6fe7aee757e35f7a44642656" +checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757" [[package]] name = "ciborium-ll" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "defaa24ecc093c77630e6c15e17c51f5e187bf35ee514f4e2d67baaa96dae22b" +checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9" dependencies = [ "ciborium-io", "half", @@ -1893,43 +1877,41 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.2" +version = "4.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "401a4694d2bf92537b6867d94de48c4842089645fdcdf6c71865b175d836e9c2" +checksum = "1e578d6ec4194633722ccf9544794b71b1385c3c027efe0c55db226fc880865c" dependencies = [ "clap_builder", "clap_derive", - "once_cell", ] [[package]] name = "clap_builder" -version = "4.3.1" +version = "4.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72394f3339a76daf211e57d4bcb374410f3965dcc606dd0e03738c7888766980" +checksum = "4df4df40ec50c46000231c914968278b1eb05098cf8f1b3a518a95030e71d1c7" dependencies = [ "anstyle", - "bitflags 1.3.2", "clap_lex", ] [[package]] name = "clap_derive" -version = "4.3.2" +version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8cd2b2a819ad6eec39e8f1d6b53001af1e5469f8c177579cdaeb313115b825f" +checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] name = "clap_lex" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" +checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" [[package]] name = "cloudabi" @@ -1940,12 +1922,6 @@ dependencies = [ "bitflags 1.3.2", ] -[[package]] -name = "color_quant" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" - [[package]] name = "common_enums" version = "0.1.0" @@ -1954,7 +1930,7 @@ dependencies = [ "router_derive", "serde", "serde_json", - "strum 0.25.0", + "strum 0.26.2", "utoipa", ] @@ -1963,25 +1939,25 @@ name = "common_utils" version = "0.1.0" dependencies = [ "async-trait", - "bytes 1.5.0", + "bytes 1.6.0", "common_enums", "diesel", "error-stack", "fake", - "futures 0.3.28", + "futures 0.3.30", "hex", - "http 0.2.9", + "http 0.2.12", "masking", "md5", "nanoid", "once_cell", "phonenumber", "proptest", - "quick-xml 0.28.2", - "rand 0.8.5", + "quick-xml 0.31.0", + "rand", "regex", "reqwest", - "ring 0.16.20", + "ring 0.17.8", "router_env", "rustc-hash", "semver 1.0.22", @@ -1990,30 +1966,22 @@ dependencies = [ "serde_urlencoded", "signal-hook", "signal-hook-tokio", - "strum 0.24.1", + "strum 0.26.2", "test-case", "thiserror", "time", - "tokio 1.36.0", + "tokio 1.37.0", "uuid", ] -[[package]] -name = "concurrent-queue" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f057a694a54f12365049b0958a1685bb52d567f5593b355fbf685838e873d400" -dependencies = [ - "crossbeam-utils 0.8.16", -] - [[package]] name = "config" -version = "0.13.3" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d379af7f68bfc21714c6c7dea883544201741d2ce8274bb12fa54f89507f52a7" +checksum = "7328b20597b53c2454f0b1919720c25c7339051c02b72b7e05409e00b14132be" dependencies = [ "async-trait", + "convert_case 0.6.0", "json5", "lazy_static", "nom", @@ -2022,7 +1990,7 @@ dependencies = [ "rust-ini", "serde", "serde_json", - "toml 0.5.11", + "toml", "yaml-rust", ] @@ -2032,10 +2000,10 @@ version = "0.1.0" dependencies = [ "anyhow", "clap", - "indexmap 2.1.0", + "indexmap 2.2.6", "serde", "serde_json", - "toml 0.7.4", + "toml", ] [[package]] @@ -2045,15 +2013,41 @@ dependencies = [ "api_models", "serde", "serde_with", - "toml 0.7.4", + "toml", "utoipa", ] +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + +[[package]] +name = "const-random" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359" +dependencies = [ + "const-random-macro", +] + +[[package]] +name = "const-random-macro" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" +dependencies = [ + "getrandom", + "once_cell", + "tiny-keccak", +] + [[package]] name = "constant_time_eq" -version = "0.2.6" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21a53c0a4d288377e7415b53dcfc3c04da5cdc2cc95c8d5ac178b58f0b861ad6" +checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" [[package]] name = "convert_case" @@ -2061,6 +2055,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" +[[package]] +name = "convert_case" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "cookie" version = "0.16.2" @@ -2074,9 +2077,9 @@ dependencies = [ [[package]] name = "cookie" -version = "0.18.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cd91cf61412820176e137621345ee43b3f4423e589e7ae4e50d601d93e35ef8" +checksum = "4ddef33a339a91ea89fb53151bd0a4689cfce27055c291dfa69945475d22c747" dependencies = [ "time", "version_check", @@ -2084,15 +2087,18 @@ dependencies = [ [[package]] name = "cookie-factory" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396de984970346b0d9e93d1415082923c679e5ae5c3ee3dcbd104f5610af126b" +checksum = "9885fa71e26b8ab7855e2ec7cae6e9b380edff76cd052e07c683a0319d51b3a2" +dependencies = [ + "futures 0.3.30", +] [[package]] name = "core-foundation" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" dependencies = [ "core-foundation-sys", "libc", @@ -2100,15 +2106,15 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.4" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "cpufeatures" -version = "0.2.9" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" dependencies = [ "libc", ] @@ -2136,18 +2142,18 @@ checksum = "338089f42c427b86394a5ee60ff321da23a5c89c9d89514c829687b26359fcff" [[package]] name = "crc32c" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8f48d60e5b4d2c53d5c2b1d8a58c849a70ae5e5509b08a48d047e3b65714a74" +checksum = "89254598aa9b9fa608de44b3ae54c810f0f06d755e24c50177f1f8f31ff50ce2" dependencies = [ "rustc_version 0.4.0", ] [[package]] name = "crc32fast" -version = "1.3.2" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" dependencies = [ "cfg-if 1.0.0", ] @@ -2190,12 +2196,11 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.8" +version = "0.5.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" +checksum = "ab3db02a9c5b5121e1e42fbdb1aeb65f5e02624cc58c43f2884c6ccac0b82f95" dependencies = [ - "cfg-if 1.0.0", - "crossbeam-utils 0.8.16", + "crossbeam-utils 0.8.19", ] [[package]] @@ -2211,13 +2216,12 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" dependencies = [ - "cfg-if 1.0.0", - "crossbeam-epoch 0.9.15", - "crossbeam-utils 0.8.16", + "crossbeam-epoch 0.9.18", + "crossbeam-utils 0.8.19", ] [[package]] @@ -2231,21 +2235,17 @@ dependencies = [ "crossbeam-utils 0.7.2", "lazy_static", "maybe-uninit", - "memoffset 0.5.6", + "memoffset", "scopeguard", ] [[package]] name = "crossbeam-epoch" -version = "0.9.15" +version = "0.9.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" dependencies = [ - "autocfg", - "cfg-if 1.0.0", - "crossbeam-utils 0.8.16", - "memoffset 0.9.0", - "scopeguard", + "crossbeam-utils 0.8.19", ] [[package]] @@ -2261,12 +2261,11 @@ dependencies = [ [[package]] name = "crossbeam-queue" -version = "0.3.8" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add" +checksum = "df0346b5d5e76ac2fe4e327c5fd1118d6be7c51dfb18f9b7922923f287471e35" dependencies = [ - "cfg-if 1.0.0", - "crossbeam-utils 0.8.16", + "crossbeam-utils 0.8.19", ] [[package]] @@ -2282,12 +2281,15 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.16" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" -dependencies = [ - "cfg-if 1.0.0", -] +checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "crypto-common" @@ -2322,12 +2324,12 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.3" +version = "0.20.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e" +checksum = "54e36fcd13ed84ffdfda6f5be89b31287cbb80c439841fe69e04841435464391" dependencies = [ - "darling_core 0.20.3", - "darling_macro 0.20.3", + "darling_core 0.20.8", + "darling_macro 0.20.8", ] [[package]] @@ -2346,16 +2348,16 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.3" +version = "0.20.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621" +checksum = "9c2cf1c23a687a1feeb728783b993c4e1ad83d99f351801977dd809b48d0a70f" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", "strsim", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] @@ -2371,13 +2373,13 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.20.3" +version = "0.20.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" +checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" dependencies = [ - "darling_core 0.20.3", + "darling_core 0.20.8", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] @@ -2388,16 +2390,16 @@ checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" dependencies = [ "cfg-if 1.0.0", "hashbrown 0.14.3", - "lock_api 0.4.10", + "lock_api 0.4.11", "once_cell", - "parking_lot_core 0.9.8", + "parking_lot_core 0.9.9", ] [[package]] name = "data-encoding" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308" +checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" [[package]] name = "data_models" @@ -2418,15 +2420,14 @@ dependencies = [ [[package]] name = "deadpool" -version = "0.9.5" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "421fe0f90f2ab22016f32a9881be5134fdd71c65298917084b0c7477cbc3856e" +checksum = "fb84100978c1c7b37f09ed3ce3e5f843af02c2a2c431bae5b19230dad2c1b490" dependencies = [ "async-trait", "deadpool-runtime", "num_cpus", - "retain_mut", - "tokio 1.36.0", + "tokio 1.37.0", ] [[package]] @@ -2436,20 +2437,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "63dfa964fe2a66f3fde91fc70b267fe193d822c7e603e2a675a49a7f46ad3f49" [[package]] -name = "deflate" -version = "0.8.6" +name = "der" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73770f8e1fe7d64df17ca66ad28994a0a623ea497fa69486e14984e715c5d174" +checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" dependencies = [ - "adler32", - "byteorder", + "const-oid", + "pem-rfc7468", + "zeroize", ] [[package]] name = "der-parser" -version = "8.2.0" +version = "9.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbd676fbbab537128ef0278adb5576cf363cff6aa22a7b24effe97347cfab61e" +checksum = "5cd0a5c643689626bec213c4d8bd4d96acc8ffdb4ad4bb6bc16abf27d5f4b553" dependencies = [ "asn1-rs", "displaydoc", @@ -2459,6 +2461,16 @@ dependencies = [ "rusticata-macros", ] +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", + "serde", +] + [[package]] name = "derive_builder" version = "0.12.0" @@ -2507,7 +2519,7 @@ version = "0.99.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" dependencies = [ - "convert_case", + "convert_case 0.4.0", "proc-macro2", "quote", "rustc_version 0.4.0", @@ -2516,17 +2528,17 @@ dependencies = [ [[package]] name = "deunicode" -version = "0.4.4" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d95203a6a50906215a502507c0f879a0ce7ff205a6111e2db2a5ef8e4bb92e43" +checksum = "b6e854126756c496b8c81dec88f9a706b15b875c5849d4097a3854476b9fdf94" [[package]] name = "diesel" -version = "2.1.3" +version = "2.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2268a214a6f118fce1838edba3d1561cf0e78d8de785475957a580a7f8c69d33" +checksum = "03fc05c17098f21b89bc7d98fe1dd3cce2c11c2ad8e145f2a44fe08ed28eb559" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.5.0", "byteorder", "diesel_derives", "itoa", @@ -2538,14 +2550,14 @@ dependencies = [ [[package]] name = "diesel_derives" -version = "2.1.2" +version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef8337737574f55a468005a83499da720f20c65586241ffea339db9ecdfd2b44" +checksum = "5d02eecb814ae714ffe61ddc2db2dd03e6c49a42e269b5001355500d431cce0c" dependencies = [ "diesel_table_macro_syntax", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] @@ -2564,7 +2576,7 @@ dependencies = [ "router_env", "serde", "serde_json", - "strum 0.24.1", + "strum 0.26.2", "thiserror", "time", ] @@ -2575,16 +2587,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc5557efc453706fed5e4fa85006fe9817c224c3f480a34c7e5959fd700921c5" dependencies = [ - "syn 2.0.55", -] - -[[package]] -name = "digest" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" -dependencies = [ - "generic-array", + "syn 2.0.57", ] [[package]] @@ -2593,7 +2596,8 @@ version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ - "block-buffer 0.10.4", + "block-buffer", + "const-oid", "crypto-common", "subtle", ] @@ -2604,26 +2608,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af83450b771231745d43edf36dc9b7813ab83be5e8cbea344ccced1a09dfebcd" -[[package]] -name = "dirs" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" -dependencies = [ - "dirs-sys", -] - -[[package]] -name = "dirs-sys" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" -dependencies = [ - "libc", - "redox_users", - "winapi 0.3.9", -] - [[package]] name = "displaydoc" version = "0.2.4" @@ -2632,14 +2616,17 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] name = "dlv-list" -version = "0.3.0" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0688c2a7f92e427f44895cd63841bff7b29f8d7a1648b9e7e07a4a365b2e1257" +checksum = "442039f5147480ba31067cb00ada1adae6892028e40e45fc5de7b7df6dcc1b5f" +dependencies = [ + "const-random", +] [[package]] name = "dotenvy" @@ -2673,20 +2660,23 @@ dependencies = [ "serde_json", "serde_path_to_error", "thiserror", - "tokio 1.36.0", + "tokio 1.37.0", ] [[package]] name = "dyn-clone" -version = "1.0.14" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23d2f3407d9a573d666de4b5bdf10569d73ca9478087346697dcbae6244bfbcd" +checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" [[package]] name = "either" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" +dependencies = [ + "serde", +] [[package]] name = "encoding_rs" @@ -2705,9 +2695,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "erased-serde" -version = "0.3.31" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c138974f9d5e7fe373eb04df7cae98833802ae4b11c24ac7039a21d5af4b26c" +checksum = "2b73807008a3c7f171cc40312f37d95ef0396e048b5848d775f54b1a4dd4a0d3" dependencies = [ "serde", ] @@ -2742,6 +2732,17 @@ dependencies = [ "serde", ] +[[package]] +name = "etcetera" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "136d1b5283a1ab77bd9257427ffd09d8667ced0570b6f938942bc7568ed5b943" +dependencies = [ + "cfg-if 1.0.0", + "home", + "windows-sys 0.48.0", +] + [[package]] name = "euclid" version = "0.1.0" @@ -2757,7 +2758,7 @@ dependencies = [ "rustc-hash", "serde", "serde_json", - "strum 0.25.0", + "strum 0.26.2", "thiserror", "utoipa", ] @@ -2769,8 +2770,8 @@ dependencies = [ "proc-macro2", "quote", "rustc-hash", - "strum 0.24.1", - "syn 1.0.109", + "strum 0.26.2", + "syn 2.0.57", ] [[package]] @@ -2782,13 +2783,13 @@ dependencies = [ "connector_configs", "currency_conversion", "euclid", - "getrandom 0.2.11", + "getrandom", "kgraph_utils", "once_cell", "ron-parser", "serde", - "serde-wasm-bindgen", - "strum 0.25.0", + "serde-wasm-bindgen 0.6.5", + "strum 0.26.2", "wasm-bindgen", ] @@ -2809,12 +2810,12 @@ dependencies = [ "aws-sdk-sesv2", "aws-sdk-sts 0.28.0", "aws-smithy-client", - "base64 0.21.5", + "base64 0.22.0", "common_utils", "dyn-clone", "error-stack", "hex", - "hyper", + "hyper 0.14.28", "hyper-proxy", "hyperswitch_interfaces", "masking", @@ -2822,18 +2823,18 @@ dependencies = [ "router_env", "serde", "thiserror", - "tokio 1.36.0", + "tokio 1.37.0", "vaultrs", ] [[package]] name = "fake" -version = "2.8.0" +version = "2.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9af7b0c58ac9d03169e27f080616ce9f64004edca3d2ef4147a811c21b23b319" +checksum = "1c25829bde82205da46e1823b2259db6273379f626fc211f126f65654a2669be" dependencies = [ - "rand 0.8.5", - "unidecode", + "deunicode", + "rand", ] [[package]] @@ -2846,14 +2847,14 @@ dependencies = [ "cookie 0.16.2", "futures-core", "futures-util", - "http 0.2.9", - "hyper", + "http 0.2.12", + "hyper 0.14.28", "hyper-rustls 0.23.2", "mime", "serde", "serde_json", "time", - "tokio 1.36.0", + "tokio 1.37.0", "url", "webdriver", ] @@ -2869,9 +2870,18 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.0.1" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984" + +[[package]] +name = "fdeflate" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +checksum = "4f9bfee30e4dedf0ab8b422f03af778d9612b63f502710fc500a334ebe2de645" +dependencies = [ + "simd-adler32", +] [[package]] name = "finl_unicode" @@ -2881,12 +2891,12 @@ checksum = "8fcfdc7a0362c9f4444381a9e697c79d435fe65b52a37466fc2c1184cee9edc6" [[package]] name = "flate2" -version = "1.0.27" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6c98ee8095e9d1dcbf2fcc6d95acccb90d1c81db1e44725c6a984b1dbdfb010" +checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" dependencies = [ "crc32fast", - "miniz_oxide 0.7.1", + "miniz_oxide", ] [[package]] @@ -2899,8 +2909,19 @@ dependencies = [ ] [[package]] -name = "fnv" -version = "1.0.7" +name = "flume" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55ac459de2512911e4b674ce33cf20befaba382d05b62b008afc1c8b57cbf181" +dependencies = [ + "futures-core", + "futures-sink", + "spin 0.9.8", +] + +[[package]] +name = "fnv" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" @@ -2921,9 +2942,9 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "form_urlencoded" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] @@ -2936,18 +2957,18 @@ checksum = "b99c2b48934cd02a81032dd7428b7ae831a27794275bc94eba367418db8a9e55" dependencies = [ "arc-swap", "async-trait", - "bytes 1.5.0", + "bytes 1.6.0", "bytes-utils", "float-cmp", - "futures 0.3.28", + "futures 0.3.30", "lazy_static", "log", "parking_lot 0.12.1", - "rand 0.8.5", + "rand", "redis-protocol", "semver 1.0.22", - "socket2 0.5.5", - "tokio 1.36.0", + "socket2", + "tokio 1.37.0", "tokio-stream", "tokio-util", "tracing", @@ -2981,7 +3002,7 @@ checksum = "b0fa992f1656e1707946bbba340ad244f0814009ef8c0118eb7b658395f19a2e" dependencies = [ "frunk_proc_macro_helpers", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] @@ -2993,7 +3014,7 @@ dependencies = [ "frunk_core", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] @@ -3005,7 +3026,7 @@ dependencies = [ "frunk_core", "frunk_proc_macro_helpers", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] @@ -3038,9 +3059,9 @@ checksum = "3a471a38ef8ed83cd6e40aa59c1ffe17db6855c18e3604d9c4ed8c08ebc28678" [[package]] name = "futures" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" dependencies = [ "futures-channel", "futures-core", @@ -3069,9 +3090,9 @@ checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" [[package]] name = "futures-executor" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" dependencies = [ "futures-core", "futures-task", @@ -3080,13 +3101,13 @@ dependencies = [ [[package]] name = "futures-intrusive" -version = "0.4.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a604f7a68fbf8103337523b1fadc8ade7361ee3f112f7c680ad179651616aed5" +checksum = "1d930c203dd0b6ff06e0201a4a2fe9149b43c684fd4420555b26d21b1a02956f" dependencies = [ "futures-core", - "lock_api 0.4.10", - "parking_lot 0.11.2", + "lock_api 0.4.11", + "parking_lot 0.12.1", ] [[package]] @@ -3095,21 +3116,6 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" -[[package]] -name = "futures-lite" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" -dependencies = [ - "fastrand 1.9.0", - "futures-core", - "futures-io", - "memchr", - "parking", - "pin-project-lite", - "waker-fn", -] - [[package]] name = "futures-macro" version = "0.3.30" @@ -3118,7 +3124,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] @@ -3133,12 +3139,6 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" -[[package]] -name = "futures-timer" -version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" - [[package]] name = "futures-util" version = "0.3.30" @@ -3179,51 +3179,30 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.1.16" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - -[[package]] -name = "getrandom" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" dependencies = [ "cfg-if 1.0.0", "js-sys", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", "wasm-bindgen", ] -[[package]] -name = "gif" -version = "0.11.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3edd93c6756b4dfaf2709eafcc345ba2636565295c198a9cfbf75fa5e3e00b06" -dependencies = [ - "color_quant", - "weezl", -] - [[package]] name = "gimli" -version = "0.28.0" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "git2" -version = "0.17.2" +version = "0.18.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b989d6a7ca95a362cf2cfc5ad688b3a467be1f87e480b8dad07fee8c79b0044" +checksum = "232e6a7bfe35766bf715e55a88b39a700596c0ccfd88cd3680b4cdb40d66ef70" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.5.0", "libc", "libgit2-sys", "log", @@ -3238,15 +3217,15 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "globset" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "759c97c1e17c55525b57192c06a267cda0ac5210b222d6b82189a2338fa1c13d" +checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1" dependencies = [ "aho-corasick", "bstr", - "fnv", "log", - "regex", + "regex-automata 0.4.6", + "regex-syntax 0.8.3", ] [[package]] @@ -3262,28 +3241,51 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.24" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fbd2820c5e49886948654ab546d0688ff24530286bdcf8fca3cefb16d4618eb" +dependencies = [ + "bytes 1.6.0", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http 0.2.12", + "indexmap 2.2.6", + "slab", + "tokio 1.37.0", + "tokio-util", + "tracing", +] + +[[package]] +name = "h2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9" +checksum = "51ee2dd2e4f378392eeff5d51618cd9a63166a2513846bbc55f21cfacd9199d4" dependencies = [ - "bytes 1.5.0", + "bytes 1.6.0", "fnv", "futures-core", "futures-sink", "futures-util", - "http 0.2.9", - "indexmap 2.1.0", + "http 1.1.0", + "indexmap 2.2.6", "slab", - "tokio 1.36.0", + "tokio 1.37.0", "tokio-util", "tracing", ] [[package]] name = "half" -version = "1.8.2" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" +checksum = "b5eceaaeec696539ddaf7b333340f1af35a5aa87ae3e4f3ead0532f72affab2e" +dependencies = [ + "cfg-if 1.0.0", + "crunchy", +] [[package]] name = "hashbrown" @@ -3291,16 +3293,22 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash 0.7.7", + "ahash 0.7.8", ] +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" + [[package]] name = "hashbrown" version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" dependencies = [ - "ahash 0.8.6", + "ahash 0.8.11", "allocator-api2", ] @@ -3319,10 +3327,10 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06683b93020a07e3dbcf5f8c0f6d40080d725bea7936fc01ad345c01b97dc270" dependencies = [ - "base64 0.21.5", - "bytes 1.5.0", + "base64 0.21.7", + "bytes 1.6.0", "headers-core", - "http 0.2.9", + "http 0.2.12", "httpdate", "mime", "sha1", @@ -3334,7 +3342,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429" dependencies = [ - "http 0.2.9", + "http 0.2.12", ] [[package]] @@ -3348,9 +3356,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.3.3" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "hex" @@ -3360,9 +3368,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hkdf" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "791a029f6b9fc27657f6f188ec6e5e43f6911f6f878e0dc5501396e09809d437" +checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" dependencies = [ "hmac", ] @@ -3373,16 +3381,25 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" dependencies = [ - "digest 0.10.7", + "digest", +] + +[[package]] +name = "home" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +dependencies = [ + "windows-sys 0.52.0", ] [[package]] name = "http" -version = "0.2.9" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" dependencies = [ - "bytes 1.5.0", + "bytes 1.6.0", "fnv", "itoa", ] @@ -3393,41 +3410,43 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" dependencies = [ - "bytes 1.5.0", + "bytes 1.6.0", "fnv", "itoa", ] [[package]] name = "http-body" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ - "bytes 1.5.0", - "http 0.2.9", + "bytes 1.6.0", + "http 0.2.12", "pin-project-lite", ] [[package]] -name = "http-types" -version = "2.12.0" +name = "http-body" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e9b187a72d63adbfba487f48095306ac823049cb504ee195541e91c7775f5ad" +checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" dependencies = [ - "anyhow", - "async-channel", - "base64 0.13.1", - "futures-lite", - "http 0.2.9", - "infer 0.2.3", + "bytes 1.6.0", + "http 1.1.0", +] + +[[package]] +name = "http-body-util" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0475f8b2ac86659c21b64320d5d653f9efe42acd2a4e560073ec61a155a34f1d" +dependencies = [ + "bytes 1.6.0", + "futures-core", + "http 1.1.0", + "http-body 1.0.0", "pin-project-lite", - "rand 0.7.3", - "serde", - "serde_json", - "serde_qs 0.8.5", - "serde_urlencoded", - "url", ] [[package]] @@ -3453,42 +3472,63 @@ dependencies = [ [[package]] name = "hyper" -version = "0.14.27" +version = "0.14.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" +checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" dependencies = [ - "bytes 1.5.0", + "bytes 1.6.0", "futures-channel", "futures-core", "futures-util", - "h2", - "http 0.2.9", - "http-body", + "h2 0.3.25", + "http 0.2.12", + "http-body 0.4.6", "httparse", "httpdate", "itoa", "pin-project-lite", - "socket2 0.4.9", - "tokio 1.36.0", + "socket2", + "tokio 1.37.0", "tower-service", "tracing", "want", ] +[[package]] +name = "hyper" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "186548d73ac615b32a73aafe38fb4f56c0d340e110e5a200bcadbaf2e199263a" +dependencies = [ + "bytes 1.6.0", + "futures-channel", + "futures-util", + "h2 0.4.3", + "http 1.1.0", + "http-body 1.0.0", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "smallvec 1.13.2", + "tokio 1.37.0", + "want", +] + [[package]] name = "hyper-proxy" version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca815a891b24fdfb243fa3239c86154392b0953ee584aa1a2a1f66d20cbe75cc" dependencies = [ - "bytes 1.5.0", - "futures 0.3.28", + "bytes 1.6.0", + "futures 0.3.30", "headers", - "http 0.2.9", - "hyper", + "http 0.2.12", + "hyper 0.14.28", "hyper-tls", "native-tls", - "tokio 1.36.0", + "tokio 1.37.0", "tokio-native-tls", "tower-service", ] @@ -3499,12 +3539,12 @@ version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1788965e61b367cd03a62950836d5cd41560c3577d90e40e0819373194d1661c" dependencies = [ - "http 0.2.9", - "hyper", + "http 0.2.12", + "hyper 0.14.28", "log", "rustls 0.20.9", "rustls-native-certs", - "tokio 1.36.0", + "tokio 1.37.0", "tokio-rustls 0.23.4", ] @@ -3515,12 +3555,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", - "http 0.2.9", - "hyper", + "http 0.2.12", + "hyper 0.14.28", "log", "rustls 0.21.10", "rustls-native-certs", - "tokio 1.36.0", + "tokio 1.37.0", "tokio-rustls 0.24.1", ] @@ -3530,9 +3570,9 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" dependencies = [ - "hyper", + "hyper 0.14.28", "pin-project-lite", - "tokio 1.36.0", + "tokio 1.37.0", "tokio-io-timeout", ] @@ -3542,13 +3582,29 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ - "bytes 1.5.0", - "hyper", + "bytes 1.6.0", + "hyper 0.14.28", "native-tls", - "tokio 1.36.0", + "tokio 1.37.0", "tokio-native-tls", ] +[[package]] +name = "hyper-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa" +dependencies = [ + "bytes 1.6.0", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", + "hyper 1.2.0", + "pin-project-lite", + "socket2", + "tokio 1.37.0", +] + [[package]] name = "hyperswitch_interfaces" version = "0.1.0" @@ -3563,9 +3619,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.58" +version = "0.1.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -3592,9 +3648,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -3602,38 +3658,30 @@ dependencies = [ [[package]] name = "ignore" -version = "0.4.20" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbe7873dab538a9a44ad79ede1faf5f30d49f9a5c883ddbab48bce81b64b7492" +checksum = "b46810df39e66e925525d6e38ce1e7f6e1d208f72dc39757880fcb66e2c58af1" dependencies = [ + "crossbeam-deque 0.8.5", "globset", - "lazy_static", "log", "memchr", - "regex", + "regex-automata 0.4.6", "same-file", - "thread_local", "walkdir", "winapi-util", ] [[package]] name = "image" -version = "0.23.14" +version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24ffcb7e7244a9bf19d35bf2883b9c080c4ced3c07a9895572178cdb8f13f6a1" +checksum = "fd54d660e773627692c524beaad361aca785a4f9f5730ce91f42aabe5bce3d11" dependencies = [ "bytemuck", "byteorder", - "color_quant", - "gif", - "jpeg-decoder", - "num-iter", - "num-rational", "num-traits", "png", - "scoped_threadpool", - "tiff", ] [[package]] @@ -3655,9 +3703,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.1.0" +version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", "hashbrown 0.14.3", @@ -3666,15 +3714,9 @@ dependencies = [ [[package]] name = "infer" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64e9829a50b42bb782c1df523f78d332fe371b10c661e78b7a3c34b0198e9fac" - -[[package]] -name = "infer" -version = "0.13.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f551f8c3a39f68f986517db0d1759de85881894fdc7db798bd2a9df9cb04b7fc" +checksum = "cb33622da908807a06f9513c19b3c1ad50fab3e4137d82a78107d502075aa199" dependencies = [ "cfb", ] @@ -3699,19 +3741,19 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" +checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] name = "is-terminal" -version = "0.4.9" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" +checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" dependencies = [ "hermit-abi", - "rustix", - "windows-sys 0.48.0", + "libc", + "windows-sys 0.52.0", ] [[package]] @@ -3760,29 +3802,38 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + [[package]] name = "itoa" -version = "1.0.9" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "jobserver" -version = "0.1.26" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2" +checksum = "ab46a6e9526ddef3ae7f787c06f0f2600639ba80ea3eade3d8e670a2230f51d6" dependencies = [ "libc", ] [[package]] name = "josekit" -version = "0.8.3" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33a96c4f2128a6f44ecf7c36df2b03dddf5a07b060a4d5ebc0a81e9821f7c60e" +checksum = "0953340cf63354cec4a385f1fbcb3f409a5823778cae236078892f6030ed4565" dependencies = [ "anyhow", - "base64 0.21.5", + "base64 0.21.7", "flate2", "once_cell", "openssl", @@ -3793,20 +3844,11 @@ dependencies = [ "time", ] -[[package]] -name = "jpeg-decoder" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "229d53d58899083193af11e15917b5640cd40b29ff475a1fe4ef725deb02d0f2" -dependencies = [ - "rayon", -] - [[package]] name = "js-sys" -version = "0.3.64" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" dependencies = [ "wasm-bindgen", ] @@ -3824,13 +3866,14 @@ dependencies = [ [[package]] name = "jsonwebtoken" -version = "8.3.0" +version = "9.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6971da4d9c3aa03c3d8f3ff0f4155b534aad021292003895a469716b2a230378" +checksum = "5c7ea04a7c5c055c175f189b6dc6ba036fd62306b58c66c9f6389036c503a3f4" dependencies = [ - "base64 0.21.5", + "base64 0.21.7", + "js-sys", "pem", - "ring 0.16.20", + "ring 0.17.8", "serde", "serde_json", "simple_asn1", @@ -3871,18 +3914,21 @@ name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +dependencies = [ + "spin 0.5.2", +] [[package]] name = "libc" -version = "0.2.150" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libgit2-sys" -version = "0.15.2+1.6.4" +version = "0.16.2+1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a80df2e11fb4a61f4ba2ab42dbe7f74468da143f1a75c74e11dee7c813f694fa" +checksum = "ee4126d8b4ee5c9d9ea891dd875cfdc1e9d0950437179104b183d7d8a74d24e8" dependencies = [ "cc", "libc", @@ -3906,11 +3952,22 @@ dependencies = [ "libc", ] +[[package]] +name = "libsqlite3-sys" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4e226dcd58b4be396f7bd3c20da8fdee2911400705297ba7d2d7cc2c30f716" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + [[package]] name = "libz-sys" -version = "1.1.12" +version = "1.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d97137b25e321a73eef1418d1d5d2eda4d77e12813f8e6dead84bc52c5870a7b" +checksum = "5e143b5e666b2695d28f6bca6497720813f699c9602dd7f5cac91008b8ada7f9" dependencies = [ "cc", "libc", @@ -3932,9 +3989,9 @@ checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] name = "local-channel" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a493488de5f18c8ffcba89eebb8532ffc562dc400490eb65b84893fae0b178" +checksum = "b6cbc85e69b8df4b8bb8b89ec634e7189099cea8927a276b7384ce5488e53ec8" dependencies = [ "futures-core", "futures-sink", @@ -3943,9 +4000,9 @@ dependencies = [ [[package]] name = "local-waker" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e34f76eb3611940e0e7d53a9aaa4e6a3151f69541a282fd0dad5571420c53ff1" +checksum = "4d873d7c67ce09b42110d801813efbc9364414e356be9935700d368351657487" [[package]] name = "lock_api" @@ -3958,9 +4015,9 @@ dependencies = [ [[package]] name = "lock_api" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" dependencies = [ "autocfg", "scopeguard", @@ -3968,9 +4025,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.20" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "lru-cache" @@ -3990,20 +4047,11 @@ dependencies = [ "digits_iterator", ] -[[package]] -name = "mach2" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d0d1830bcd151a6fc4aea1369af235b36c1528fe976b8ff678683c9995eade8" -dependencies = [ - "libc", -] - [[package]] name = "masking" version = "0.1.0" dependencies = [ - "bytes 1.5.0", + "bytes 1.6.0", "diesel", "erased-serde", "serde", @@ -4029,9 +4077,9 @@ checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" [[package]] name = "maud" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0bab19cef8a7fe1c18a43e881793bfc9d4ea984befec3ae5bd0415abf3ecf00" +checksum = "df518b75016b4289cdddffa1b01f2122f4a49802c93191f3133f6dc2472ebcaa" dependencies = [ "actix-web", "futures-util", @@ -4041,14 +4089,14 @@ dependencies = [ [[package]] name = "maud_macros" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0be95d66c3024ffce639216058e5bae17a83ecaf266ffc6e4d060ad447c9eed2" +checksum = "fa453238ec218da0af6b11fc5978d3b5c3a45ed97b722391a2a11f3306274e18" dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.57", ] [[package]] @@ -4064,7 +4112,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" dependencies = [ "cfg-if 1.0.0", - "digest 0.10.7", + "digest", ] [[package]] @@ -4075,9 +4123,9 @@ checksum = "490cc448043f947bae3cbee9c203358d62dbee0db12107a74be5c30ccfd09771" [[package]] name = "memchr" -version = "2.6.4" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" [[package]] name = "memoffset" @@ -4088,15 +4136,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "memoffset" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" -dependencies = [ - "autocfg", -] - [[package]] name = "mimalloc" version = "0.1.39" @@ -4130,30 +4169,12 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "791daaae1ed6889560f8c4359194f56648355540573244a5448a83ba1ecc7435" -dependencies = [ - "adler32", -] - -[[package]] -name = "miniz_oxide" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" -dependencies = [ - "adler", - "autocfg", -] - -[[package]] -name = "miniz_oxide" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" dependencies = [ "adler", + "simd-adler32", ] [[package]] @@ -4177,13 +4198,13 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.10" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ "libc", "log", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", "windows-sys 0.48.0", ] @@ -4212,22 +4233,22 @@ dependencies = [ [[package]] name = "moka" -version = "0.12.1" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8017ec3548ffe7d4cef7ac0e12b044c01164a74c0f3119420faeaf13490ad8b" +checksum = "b1911e88d5831f748a4097a43862d129e3c6fca831eecac9b8db6d01d93c9de2" dependencies = [ "async-lock", "async-trait", "crossbeam-channel", - "crossbeam-epoch 0.9.15", - "crossbeam-utils 0.8.16", + "crossbeam-epoch 0.9.18", + "crossbeam-utils 0.8.19", "futures-util", "once_cell", "parking_lot 0.12.1", "quanta", "rustc_version 0.4.0", "skeptic", - "smallvec 1.11.1", + "smallvec 1.13.2", "tagptr", "thiserror", "triomphe", @@ -4246,7 +4267,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ffa00dec017b5b1a8b7cf5e2c008bfda1aa7e0697ac1508b491fdf2622fb4d8" dependencies = [ - "rand 0.8.5", + "rand", ] [[package]] @@ -4278,6 +4299,18 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "nix" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4" +dependencies = [ + "bitflags 2.5.0", + "cfg-if 1.0.0", + "cfg_aliases", + "libc", +] + [[package]] name = "nom" version = "7.1.3" @@ -4310,31 +4343,42 @@ dependencies = [ ] [[package]] -name = "num-integer" -version = "0.1.45" +name = "num-bigint-dig" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +checksum = "dc84195820f291c7697304f3cbdadd1cb7199c0efc917ff5eafd71225c136151" dependencies = [ - "autocfg", + "byteorder", + "lazy_static", + "libm", + "num-integer", + "num-iter", "num-traits", + "rand", + "smallvec 1.13.2", + "zeroize", ] [[package]] -name = "num-iter" -version = "0.1.43" +name = "num-conv" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ - "autocfg", - "num-integer", "num-traits", ] [[package]] -name = "num-rational" -version = "0.3.2" +name = "num-iter" +version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12ac428b1cb17fce6f731001d307d351ec70a6d202fc2e60f7d4c5e42d8f4f07" +checksum = "d869c01cc0c455284163fd0092f1f93835385ccab5a98a0dcc497b2f8bf055a9" dependencies = [ "autocfg", "num-integer", @@ -4343,9 +4387,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ "autocfg", "libm", @@ -4382,29 +4426,38 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "num_threads" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9" +dependencies = [ + "libc", +] + [[package]] name = "object" -version = "0.32.1" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" dependencies = [ "memchr", ] [[package]] name = "oid-registry" -version = "0.6.1" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bedf36ffb6ba96c2eb7144ef6270557b52e54b20c0a8e1eb2ff99a6c6959bff" +checksum = "1c958dd45046245b9c3c2547369bb634eb461670b2e7e0de552905801a648d1d" dependencies = [ "asn1-rs", ] [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "oncemutex" @@ -4418,12 +4471,6 @@ version = "11.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" -[[package]] -name = "opaque-debug" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" - [[package]] name = "openapi" version = "0.1.0" @@ -4443,8 +4490,8 @@ dependencies = [ "aws-sigv4 1.2.0", "aws-smithy-runtime-api", "aws-types 1.1.8", - "base64 0.21.5", - "bytes 1.5.0", + "base64 0.21.7", + "bytes 1.6.0", "dyn-clone", "lazy_static", "percent-encoding", @@ -4459,11 +4506,11 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.60" +version = "0.10.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79a4c6c3a2b158f7f8f2a2fc5a969fa3a068df6fc9dbb4a43845436e3af7c800" +checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.5.0", "cfg-if 1.0.0", "foreign-types", "libc", @@ -4480,7 +4527,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] @@ -4491,9 +4538,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.96" +version = "0.9.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3812c071ba60da8b5677cc12bcb1d42989a65553772897a7e0355545a819838f" +checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" dependencies = [ "cc", "libc", @@ -4518,14 +4565,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8af72d59a4484654ea8eb183fea5ae4eb6a41d7ac3e3bae5f4d2a282a3a7d3ca" dependencies = [ "async-trait", - "futures 0.3.28", + "futures 0.3.30", "futures-util", - "http 0.2.9", + "http 0.2.12", "opentelemetry", "opentelemetry-proto", "prost", "thiserror", - "tokio 1.36.0", + "tokio 1.37.0", "tonic", ] @@ -4535,7 +4582,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "045f8eea8c0fa19f7d48e7bc3128a39c2e5c533d5c61298c548dfefc1064474c" dependencies = [ - "futures 0.3.28", + "futures 0.3.30", "futures-util", "opentelemetry", "prost", @@ -4574,20 +4621,20 @@ dependencies = [ "once_cell", "opentelemetry_api", "percent-encoding", - "rand 0.8.5", + "rand", "thiserror", - "tokio 1.36.0", + "tokio 1.37.0", "tokio-stream", ] [[package]] name = "ordered-multimap" -version = "0.4.3" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccd746e37177e1711c20dd619a1620f34f5c8b569c53590a72dedd5344d8924a" +checksum = "4ed8acf08e98e744e5384c8bc63ceb0364e68a6854187221c18df61c4797690e" dependencies = [ "dlv-list", - "hashbrown 0.12.3", + "hashbrown 0.13.2", ] [[package]] @@ -4602,12 +4649,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" -[[package]] -name = "parking" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e52c774a4c39359c1d1c52e43f73dd91a75a614652c825408eec30c95a9b2067" - [[package]] name = "parking_lot" version = "0.9.0" @@ -4619,25 +4660,14 @@ dependencies = [ "rustc_version 0.2.3", ] -[[package]] -name = "parking_lot" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" -dependencies = [ - "instant", - "lock_api 0.4.10", - "parking_lot_core 0.8.6", -] - [[package]] name = "parking_lot" version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ - "lock_api 0.4.10", - "parking_lot_core 0.9.8", + "lock_api 0.4.11", + "parking_lot_core 0.9.9", ] [[package]] @@ -4657,28 +4687,14 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" -dependencies = [ - "cfg-if 1.0.0", - "instant", - "libc", - "redox_syscall 0.2.16", - "smallvec 1.11.1", - "winapi 0.3.9", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.8" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ "cfg-if 1.0.0", "libc", - "redox_syscall 0.3.5", - "smallvec 1.11.1", + "redox_syscall 0.4.1", + "smallvec 1.13.2", "windows-targets 0.48.5", ] @@ -4704,7 +4720,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "346f04948ba92c43e8469c1ee6736c7563d71012b17d40745260fe106aac2166" dependencies = [ "base64ct", - "rand_core 0.6.4", + "rand_core", "subtle", ] @@ -4721,25 +4737,35 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" [[package]] -name = "pem" -version = "1.1.1" +name = "pem" +version = "3.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b8fcc794035347fb64beda2d3b462595dd2753e3f268d89c5aae77e8cf2c310" +dependencies = [ + "base64 0.21.7", + "serde", +] + +[[package]] +name = "pem-rfc7468" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8835c273a76a90455d7344889b0964598e3316e2a79ede8e36f16bdcf2228b8" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" dependencies = [ - "base64 0.13.1", + "base64ct", ] [[package]] name = "percent-encoding" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.4" +version = "2.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c022f1e7b65d6a24c0dbbd5fb344c66881bc01f3e5ae74a1c8100f2f985d98a4" +checksum = "56f8023d0fb78c8e03784ea1c7f3fa36e68a723138990b8d5a47d916b651e7a8" dependencies = [ "memchr", "thiserror", @@ -4748,9 +4774,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.4" +version = "2.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35513f630d46400a977c4cb58f78e1bfbe01434316e60c37d27b9ad6139c66d8" +checksum = "b0d24f72393fd16ab6ac5738bc33cdb6a9aa73f8b902e8fe29cf4e67d7dd1026" dependencies = [ "pest", "pest_generator", @@ -4758,22 +4784,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.4" +version = "2.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc9fc1b9e7057baba189b5c626e2d6f40681ae5b6eb064dc7c7834101ec8123a" +checksum = "fdc17e2a6c7d0a492f0158d7a4bd66cc17280308bbaff78d5bef566dca35ab80" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] name = "pest_meta" -version = "2.7.4" +version = "2.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1df74e9e7ec4053ceb980e7c0c8bd3594e977fde1af91daba9c928e8e8c6708d" +checksum = "934cd7631c050f4674352a6e835d5f6711ffbfb9345c2fc0107155ac495ae293" dependencies = [ "once_cell", "pest", @@ -4806,7 +4832,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" dependencies = [ "phf_shared", - "rand 0.8.5", + "rand", ] [[package]] @@ -4841,29 +4867,29 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.1.3" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.3" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -4871,11 +4897,32 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkcs1" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" +dependencies = [ + "der", + "pkcs8", + "spki", +] + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + [[package]] name = "pkg-config" -version = "0.3.27" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "plotters" @@ -4911,33 +4958,40 @@ version = "0.1.0" dependencies = [ "api_models", "async-trait", - "bytes 1.5.0", + "bytes 1.6.0", "common_enums", "common_utils", "error-stack", - "http 0.2.9", + "http 0.2.12", "masking", "mime", "router_derive", "router_env", "serde", "serde_json", - "strum 0.24.1", + "strum 0.26.2", "thiserror", ] [[package]] name = "png" -version = "0.16.8" +version = "0.17.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c3287920cb847dee3de33d301c463fba14dda99db24214ddf93f83d3021f4c6" +checksum = "06e4b0d3d1312775e782c86c91a111aa1f910cbb65e1337f9975b5f9a554b5e1" dependencies = [ "bitflags 1.3.2", "crc32fast", - "deflate", - "miniz_oxide 0.3.7", + "fdeflate", + "flate2", + "miniz_oxide", ] +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -4960,16 +5014,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ "once_cell", - "toml_edit 0.19.14", + "toml_edit 0.19.15", ] [[package]] name = "proc-macro-crate" -version = "2.0.0" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" dependencies = [ - "toml_edit 0.20.2", + "toml_edit 0.21.1", ] [[package]] @@ -5007,19 +5061,19 @@ dependencies = [ [[package]] name = "proptest" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c003ac8c77cb07bb74f5f198bce836a689bcd5a42574612bf14d17bfd08c20e" +checksum = "31b476131c3c86cb68032fdc5cb6d5a1045e3e42d96b69fa599fd77701e1f5bf" dependencies = [ "bit-set", "bit-vec", - "bitflags 2.4.0", + "bitflags 2.5.0", "lazy_static", "num-traits", - "rand 0.8.5", - "rand_chacha 0.3.1", + "rand", + "rand_chacha", "rand_xorshift", - "regex-syntax 0.7.5", + "regex-syntax 0.8.3", "rusty-fork", "tempfile", "unarray", @@ -5031,7 +5085,7 @@ version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" dependencies = [ - "bytes 1.5.0", + "bytes 1.6.0", "prost-derive", ] @@ -5070,37 +5124,35 @@ dependencies = [ [[package]] name = "pulldown-cmark" -version = "0.9.3" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a1a2f1f0a7ecff9c31abbe177637be0e97a0aef46cf8738ece09327985d998" +checksum = "57206b407293d2bcd3af849ce869d52068623f19e1b5ff8e8778e3309439682b" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.5.0", "memchr", "unicase", ] [[package]] name = "qrcode" -version = "0.12.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16d2f1455f3630c6e5107b4f2b94e74d76dea80736de0981fd27644216cff57f" +checksum = "23e719ca51966ff9f5a8436edb00d6115b3c606a0bb27c8f8ca74a38ff2b036d" dependencies = [ - "checked_int_cast", "image", ] [[package]] name = "quanta" -version = "0.11.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17e662a7a8291a865152364c20c7abc5e60486ab2001e8ec10b24862de0b9ab" +checksum = "9ca0b7bac0b97248c40bb77288fc52029cf1459c0461ea1b05ee32ccf011de2c" dependencies = [ - "crossbeam-utils 0.8.16", + "crossbeam-utils 0.8.19", "libc", - "mach2", "once_cell", "raw-cpuid", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", "web-sys", "winapi 0.3.9", ] @@ -5118,7 +5170,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ce5e73202a820a31f8a0ee32ada5e21029c81fd9e3ebf668a40832e4219d9d1" dependencies = [ "memchr", - "serde", ] [[package]] @@ -5157,19 +5208,6 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" -[[package]] -name = "rand" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" -dependencies = [ - "getrandom 0.1.16", - "libc", - "rand_chacha 0.2.2", - "rand_core 0.5.1", - "rand_hc", -] - [[package]] name = "rand" version = "0.8.5" @@ -5177,18 +5215,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", - "rand_chacha 0.3.1", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_chacha" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" -dependencies = [ - "ppv-lite86", - "rand_core 0.5.1", + "rand_chacha", + "rand_core", ] [[package]] @@ -5198,16 +5226,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom 0.1.16", + "rand_core", ] [[package]] @@ -5216,16 +5235,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.11", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core 0.5.1", + "getrandom", ] [[package]] @@ -5234,23 +5244,23 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" dependencies = [ - "rand_core 0.6.4", + "rand_core", ] [[package]] name = "raw-cpuid" -version = "10.7.0" +version = "11.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c297679cb867470fa8c9f67dbba74a78d78e3e98d7cf2b08d6d71540f797332" +checksum = "9d86a7c4638d42c44551f4791a20e687dbb4c3de1f33c43dd71e355cd429def1" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.5.0", ] [[package]] name = "rayon" -version = "1.8.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" dependencies = [ "either", "rayon-core", @@ -5258,19 +5268,19 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.12.0" +version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" dependencies = [ - "crossbeam-deque 0.8.3", - "crossbeam-utils 0.8.16", + "crossbeam-deque 0.8.5", + "crossbeam-utils 0.8.19", ] [[package]] name = "rdkafka" -version = "0.36.0" +version = "0.36.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54f02a5a40220f8a2dfa47ddb38ba9064475a5807a69504b6f91711df2eea63" +checksum = "1beea247b9a7600a81d4cc33f659ce1a77e1988323d7d2809c7ed1c21f4c316d" dependencies = [ "futures-channel", "futures-util", @@ -5281,7 +5291,7 @@ dependencies = [ "serde_derive", "serde_json", "slab", - "tokio 1.36.0", + "tokio 1.37.0", ] [[package]] @@ -5302,7 +5312,7 @@ version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c31deddf734dc0a39d3112e73490e88b61a05e83e074d211f348404cee4d2c6" dependencies = [ - "bytes 1.5.0", + "bytes 1.6.0", "bytes-utils", "cookie-factory", "crc16", @@ -5317,11 +5327,11 @@ dependencies = [ "common_utils", "error-stack", "fred", - "futures 0.3.28", + "futures 0.3.30", "router_env", "serde", "thiserror", - "tokio 1.36.0", + "tokio 1.37.0", "tokio-stream", ] @@ -5333,43 +5343,23 @@ checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" [[package]] name = "redox_syscall" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" -dependencies = [ - "bitflags 1.3.2", -] - -[[package]] -name = "redox_syscall" -version = "0.3.5" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ "bitflags 1.3.2", ] -[[package]] -name = "redox_users" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" -dependencies = [ - "getrandom 0.2.11", - "redox_syscall 0.2.16", - "thiserror", -] - [[package]] name = "regex" -version = "1.10.3" +version = "1.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.5", - "regex-syntax 0.8.2", + "regex-automata 0.4.6", + "regex-syntax 0.8.3", ] [[package]] @@ -5383,13 +5373,13 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" +checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.2", + "regex-syntax 0.8.3", ] [[package]] @@ -5418,41 +5408,35 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" - -[[package]] -name = "regex-syntax" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" [[package]] name = "rend" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2571463863a6bd50c32f94402933f03457a3fbaf697a707c5be741e459f08fd" +checksum = "71fe3824f5629716b1589be05dacd749f6aa084c87e00e016714a8cdfccc997c" dependencies = [ "bytecheck", ] [[package]] name = "reqwest" -version = "0.11.22" +version = "0.11.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" +checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" dependencies = [ "async-compression", - "base64 0.21.5", - "bytes 1.5.0", + "base64 0.21.7", + "bytes 1.6.0", "encoding_rs", "futures-core", "futures-util", - "h2", - "http 0.2.9", - "http-body", - "hyper", + "h2 0.3.25", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.28", "hyper-rustls 0.24.2", "hyper-tls", "ipnet", @@ -5469,8 +5453,9 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", + "sync_wrapper", "system-configuration", - "tokio 1.36.0", + "tokio 1.37.0", "tokio-native-tls", "tokio-rustls 0.24.1", "tokio-util", @@ -5479,16 +5464,10 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "webpki-roots 0.25.3", + "webpki-roots 0.25.4", "winreg", ] -[[package]] -name = "retain_mut" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4389f1d5789befaf6029ebd9f7dac4af7f7e3d61b69d4f30e2ac02b57e7712b0" - [[package]] name = "ring" version = "0.16.20" @@ -5512,7 +5491,7 @@ checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ "cc", "cfg-if 1.0.0", - "getrandom 0.2.11", + "getrandom", "libc", "spin 0.9.8", "untrusted 0.9.0", @@ -5521,12 +5500,13 @@ dependencies = [ [[package]] name = "rkyv" -version = "0.7.42" +version = "0.7.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0200c8230b013893c0b2d6213d6ec64ed2b9be2e0e016682b7224ff82cff5c58" +checksum = "5cba464629b3394fc4dbc6f940ff8f5b4ff5c7aef40f29166fd4ad12acbc99c0" dependencies = [ "bitvec", "bytecheck", + "bytes 1.6.0", "hashbrown 0.12.3", "ptr_meta", "rend", @@ -5538,9 +5518,9 @@ dependencies = [ [[package]] name = "rkyv_derive" -version = "0.7.42" +version = "0.7.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2e06b915b5c230a17d7a736d1e2e63ee753c256a8614ef3f5147b13a4f5541d" +checksum = "a7dddfff8de25e6f62b9d64e6e432bf1c6736c57d20323e15ee10435fbda7c65" dependencies = [ "proc-macro2", "quote", @@ -5549,13 +5529,14 @@ dependencies = [ [[package]] name = "ron" -version = "0.7.1" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88073939a61e5b7680558e6be56b419e208420c2adb92be54921fa6b72283f1a" +checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94" dependencies = [ - "base64 0.13.1", - "bitflags 1.3.2", + "base64 0.21.7", + "bitflags 2.5.0", "serde", + "serde_derive", ] [[package]] @@ -5566,7 +5547,7 @@ checksum = "1c7280c46017fafbe4275179689e446a9b0db3bd91ea61aaee22841ef618405a" dependencies = [ "nom", "serde", - "serde-wasm-bindgen", + "serde-wasm-bindgen 0.5.0", "serde_json", "wasm-bindgen", ] @@ -5586,36 +5567,36 @@ dependencies = [ "async-bb8-diesel", "async-trait", "awc", - "base64 0.21.5", + "base64 0.22.0", "bb8", "bigdecimal", "blake3", - "bytes 1.5.0", + "bytes 1.6.0", "cards", "clap", "common_enums", "common_utils", "config", - "cookie 0.18.0", + "cookie 0.18.1", "currency_conversion", "data_models", "derive_deref", "diesel", "diesel_models", - "digest 0.9.0", + "digest", "dyn-clone", "encoding_rs", "erased-serde", "error-stack", "euclid", "external_services", - "futures 0.3.28", + "futures 0.3.30", "hex", - "http 0.2.9", - "hyper", + "http 0.2.12", + "hyper 0.14.28", "hyperswitch_interfaces", "image", - "infer 0.13.0", + "infer", "iso_currency", "isocountry", "josekit", @@ -5633,13 +5614,13 @@ dependencies = [ "pm_auth", "qrcode", "quick-xml 0.31.0", - "rand 0.8.5", - "rand_chacha 0.3.1", + "rand", + "rand_chacha", "rdkafka", "redis_interface", "regex", "reqwest", - "ring 0.16.20", + "ring 0.17.8", "router_derive", "router_env", "roxmltree", @@ -5649,19 +5630,19 @@ dependencies = [ "serde", "serde_json", "serde_path_to_error", - "serde_qs 0.12.0", + "serde_qs", "serde_urlencoded", "serde_with", "serial_test", - "sha-1", + "sha1", "sqlx", "storage_impl", - "strum 0.25.0", + "strum 0.26.2", "tera", "test_utils", "thiserror", "time", - "tokio 1.36.0", + "tokio 1.37.0", "tracing-futures", "unicode-segmentation", "url", @@ -5677,13 +5658,13 @@ name = "router_derive" version = "0.1.0" dependencies = [ "diesel", - "indexmap 2.1.0", + "indexmap 2.2.6", "proc-macro2", "quote", "serde", "serde_json", - "strum 0.24.1", - "syn 2.0.55", + "strum 0.26.2", + "syn 2.0.57", ] [[package]] @@ -5701,9 +5682,9 @@ dependencies = [ "serde", "serde_json", "serde_path_to_error", - "strum 0.24.1", + "strum 0.26.2", "time", - "tokio 1.36.0", + "tokio 1.37.0", "tracing", "tracing-actix-web", "tracing-appender", @@ -5715,18 +5696,35 @@ dependencies = [ [[package]] name = "roxmltree" -version = "0.18.1" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "862340e351ce1b271a378ec53f304a5558f7db87f3769dc655a8f6ecbb68b302" +checksum = "3cd14fd5e3b777a7422cca79358c57a8f6e3a703d9ac187448d0daf220c2407f" + +[[package]] +name = "rsa" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0e5124fcb30e76a7e79bfee683a2746db83784b86289f6251b54b7950a0dfc" dependencies = [ - "xmlparser", + "const-oid", + "digest", + "num-bigint-dig", + "num-integer", + "num-traits", + "pkcs1", + "pkcs8", + "rand_core", + "signature", + "spki", + "subtle", + "zeroize", ] [[package]] name = "rust-ini" -version = "0.18.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6d5f2436026b4f6e79dc829837d467cc7e9a55ee40e750d716713540715a2df" +checksum = "7e2a3bcec1f113553ef1c88aae6c020a369d03d55b58de9869a0908930385091" dependencies = [ "cfg-if 1.0.0", "ordered-multimap", @@ -5734,15 +5732,15 @@ dependencies = [ [[package]] name = "rust_decimal" -version = "1.33.1" +version = "1.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06676aec5ccb8fc1da723cc8c0f9a46549f21ebb8753d3915c6c41db1e7f1dc4" +checksum = "1790d1c4c0ca81211399e0e0af16333276f375209e71a37b67698a373db5b47a" dependencies = [ "arrayvec", "borsh", - "bytes 1.5.0", + "bytes 1.6.0", "num-traits", - "rand 0.8.5", + "rand", "rkyv", "serde", "serde_json", @@ -5795,8 +5793,8 @@ checksum = "e9c02e25271068de581e03ac3bb44db60165ff1a10d92b9530192ccb898bc706" dependencies = [ "anyhow", "async-trait", - "bytes 1.5.0", - "http 0.2.9", + "bytes 1.6.0", + "http 0.2.12", "reqwest", "rustify_derive", "serde", @@ -5818,16 +5816,16 @@ dependencies = [ "regex", "serde_urlencoded", "syn 1.0.109", - "synstructure", + "synstructure 0.12.6", ] [[package]] name = "rustix" -version = "0.38.28" +version = "0.38.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" +checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.5.0", "errno", "libc", "linux-raw-sys", @@ -5872,11 +5870,11 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" dependencies = [ - "base64 0.21.5", + "base64 0.21.7", ] [[package]] @@ -5917,9 +5915,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.15" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" [[package]] name = "same-file" @@ -5932,11 +5930,11 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" +checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -5957,29 +5955,23 @@ dependencies = [ "diesel_models", "error-stack", "external_services", - "futures 0.3.28", + "futures 0.3.30", "masking", "num_cpus", "once_cell", - "rand 0.8.5", + "rand", "redis_interface", "router_env", "serde", "serde_json", "storage_impl", - "strum 0.24.1", + "strum 0.26.2", "thiserror", "time", - "tokio 1.36.0", + "tokio 1.37.0", "uuid", ] -[[package]] -name = "scoped_threadpool" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8" - [[package]] name = "scopeguard" version = "1.2.0" @@ -5988,12 +5980,12 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "sct" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" dependencies = [ - "ring 0.16.20", - "untrusted 0.7.1", + "ring 0.17.8", + "untrusted 0.9.0", ] [[package]] @@ -6069,6 +6061,17 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "serde-wasm-bindgen" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8302e169f0eddcc139c70f139d19d6467353af16f9fce27e8c30158036a1e16b" +dependencies = [ + "js-sys", + "serde", + "wasm-bindgen", +] + [[package]] name = "serde_derive" version = "1.0.197" @@ -6077,16 +6080,16 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] name = "serde_json" -version = "1.0.108" +version = "1.0.115" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" dependencies = [ - "indexmap 2.1.0", + "indexmap 2.2.6", "itoa", "ryu", "serde", @@ -6094,9 +6097,9 @@ dependencies = [ [[package]] name = "serde_path_to_error" -version = "0.1.14" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4beec8bce849d58d06238cb50db2e1c417cfeafa4c63f692b15c82b7c80f8335" +checksum = "af99884400da37c88f5e9146b7f1fd0fbcae8f6eec4e9da38b67d05486f814a6" dependencies = [ "itoa", "serde", @@ -6111,17 +6114,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_qs" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7715380eec75f029a4ef7de39a9200e0a63823176b759d055b613f5a87df6a6" -dependencies = [ - "percent-encoding", - "serde", - "thiserror", -] - [[package]] name = "serde_qs" version = "0.12.0" @@ -6135,20 +6127,20 @@ dependencies = [ [[package]] name = "serde_repr" -version = "0.1.16" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8725e1dfadb3a50f7e5ce0b1a540466f6ed3fe7a0fca2ac2b8b831d31316bd00" +checksum = "0b2e6b945e9d3df726b65d6ee24060aff8e3533d431f677a9695db04eff9dfdb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] name = "serde_spanned" -version = "0.6.3" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" +checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" dependencies = [ "serde", ] @@ -6167,16 +6159,17 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.4.0" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64cd236ccc1b7a29e7e2739f27c0b2dd199804abc4290e32f59f3b68d6405c23" +checksum = "ee80b0e361bbf88fd2f6e242ccd19cfda072cb0faa6ae694ecee08199938569a" dependencies = [ - "base64 0.21.5", + "base64 0.21.7", "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.1.0", + "indexmap 2.2.6", "serde", + "serde_derive", "serde_json", "serde_with_macros", "time", @@ -6184,24 +6177,24 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.4.0" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93634eb5f75a2323b16de4748022ac4297f9e76b6dced2be287a099f41b5e788" +checksum = "6561dc161a9224638a31d876ccdfefbc1df91d3f3a8342eddb35f055d48c7655" dependencies = [ - "darling 0.20.3", + "darling 0.20.8", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] name = "serial_test" -version = "2.0.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e56dd856803e253c8f298af3f4d7eb0ae5e23a737252cd90bb4f3b435033b2d" +checksum = "953ad9342b3aaca7cb43c45c097dd008d4907070394bd0751a0aa8817e5a018d" dependencies = [ "dashmap", - "futures 0.3.28", + "futures 0.3.30", "lazy_static", "log", "parking_lot 0.12.1", @@ -6210,26 +6203,13 @@ dependencies = [ [[package]] name = "serial_test_derive" -version = "2.0.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91d129178576168c589c9ec973feedf7d3126c01ac2bf08795109aa35b69fb8f" +checksum = "b93fb4adc70021ac1b47f7d45e8cc4169baaa7ea58483bc5b721d19a26202212" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", -] - -[[package]] -name = "sha-1" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" -dependencies = [ - "block-buffer 0.9.0", - "cfg-if 1.0.0", - "cpufeatures", - "digest 0.9.0", - "opaque-debug", + "syn 2.0.57", ] [[package]] @@ -6240,7 +6220,7 @@ checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" dependencies = [ "cfg-if 1.0.0", "cpufeatures", - "digest 0.10.7", + "digest", ] [[package]] @@ -6251,7 +6231,7 @@ checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if 1.0.0", "cpufeatures", - "digest 0.10.7", + "digest", ] [[package]] @@ -6291,9 +6271,25 @@ dependencies = [ "futures-core", "libc", "signal-hook", - "tokio 1.36.0", + "tokio 1.37.0", +] + +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "digest", + "rand_core", ] +[[package]] +name = "simd-adler32" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" + [[package]] name = "simdutf8" version = "0.1.4" @@ -6344,11 +6340,12 @@ dependencies = [ [[package]] name = "slug" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3bc762e6a4b6c6fcaade73e77f9ebc6991b676f88bb2358bddb56560f073373" +checksum = "3bd94acec9c8da640005f8e135a39fc0372e74535e6b368b7a04b875f784c8c4" dependencies = [ "deunicode", + "wasm-bindgen", ] [[package]] @@ -6362,145 +6359,260 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.1" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "socket2" -version = "0.4.9" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" +checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" dependencies = [ "libc", - "winapi 0.3.9", + "windows-sys 0.52.0", ] [[package]] -name = "socket2" -version = "0.5.5" +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "spin" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" dependencies = [ - "libc", - "windows-sys 0.48.0", + "lock_api 0.4.11", +] + +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "sqlformat" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce81b7bd7c4493975347ef60d8c7e8b742d4694f4c49f93e0a12ea263938176c" +dependencies = [ + "itertools 0.12.1", + "nom", + "unicode_categories", +] + +[[package]] +name = "sqlx" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dba03c279da73694ef99763320dea58b51095dfe87d001b1d4b5fe78ba8763cf" +dependencies = [ + "sqlx-core", + "sqlx-macros", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", +] + +[[package]] +name = "sqlx-core" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d84b0a3c3739e220d94b3239fd69fb1f74bc36e16643423bd99de3b43c21bfbd" +dependencies = [ + "ahash 0.8.11", + "atoi", + "bigdecimal", + "byteorder", + "bytes 1.6.0", + "crc", + "crossbeam-queue 0.3.11", + "dotenvy", + "either", + "event-listener", + "futures-channel", + "futures-core", + "futures-intrusive", + "futures-io", + "futures-util", + "hashlink", + "hex", + "indexmap 2.2.6", + "log", + "memchr", + "native-tls", + "once_cell", + "paste", + "percent-encoding", + "serde", + "serde_json", + "sha2", + "smallvec 1.13.2", + "sqlformat", + "thiserror", + "time", + "tokio 1.37.0", + "tokio-stream", + "tracing", + "url", ] [[package]] -name = "spin" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" - -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" - -[[package]] -name = "sqlformat" -version = "0.2.2" +name = "sqlx-macros" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b7b278788e7be4d0d29c0f39497a0eef3fba6bbc8e70d8bf7fde46edeaa9e85" +checksum = "89961c00dc4d7dffb7aee214964b065072bff69e36ddb9e2c107541f75e4f2a5" dependencies = [ - "itertools 0.11.0", - "nom", - "unicode_categories", + "proc-macro2", + "quote", + "sqlx-core", + "sqlx-macros-core", + "syn 1.0.109", ] [[package]] -name = "sqlx" -version = "0.6.3" +name = "sqlx-macros-core" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8de3b03a925878ed54a954f621e64bf55a3c1bd29652d0d1a17830405350188" +checksum = "d0bd4519486723648186a08785143599760f7cc81c52334a55d6a83ea1e20841" dependencies = [ + "atomic-write-file", + "dotenvy", + "either", + "heck", + "hex", + "once_cell", + "proc-macro2", + "quote", + "serde", + "serde_json", + "sha2", "sqlx-core", - "sqlx-macros", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", + "syn 1.0.109", + "tempfile", + "tokio 1.37.0", + "url", ] [[package]] -name = "sqlx-core" -version = "0.6.3" +name = "sqlx-mysql" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa8241483a83a3f33aa5fff7e7d9def398ff9990b2752b6c6112b83c6d246029" +checksum = "e37195395df71fd068f6e2082247891bc11e3289624bbc776a0cdfa1ca7f1ea4" dependencies = [ - "ahash 0.7.7", "atoi", - "base64 0.13.1", + "base64 0.21.7", "bigdecimal", - "bitflags 1.3.2", + "bitflags 2.5.0", "byteorder", - "bytes 1.5.0", + "bytes 1.6.0", "crc", - "crossbeam-queue 0.3.8", - "dirs", + "digest", "dotenvy", "either", - "event-listener", "futures-channel", "futures-core", - "futures-intrusive", + "futures-io", "futures-util", - "hashlink", + "generic-array", "hex", "hkdf", "hmac", - "indexmap 1.9.3", "itoa", - "libc", "log", "md-5", "memchr", - "num-bigint", "once_cell", - "paste", "percent-encoding", - "rand 0.8.5", + "rand", + "rsa", "serde", - "serde_json", "sha1", "sha2", - "smallvec 1.11.1", - "sqlformat", - "sqlx-rt", + "smallvec 1.13.2", + "sqlx-core", "stringprep", "thiserror", "time", - "tokio-stream", - "url", + "tracing", "whoami", ] [[package]] -name = "sqlx-macros" -version = "0.6.3" +name = "sqlx-postgres" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9966e64ae989e7e575b19d7265cb79d7fc3cbbdf179835cb0d716f294c2049c9" +checksum = "d6ac0ac3b7ccd10cc96c7ab29791a7dd236bd94021f31eec7ba3d46a74aa1c24" dependencies = [ + "atoi", + "base64 0.21.7", + "bigdecimal", + "bitflags 2.5.0", + "byteorder", + "crc", "dotenvy", - "either", - "heck", + "etcetera", + "futures-channel", + "futures-core", + "futures-io", + "futures-util", + "hex", + "hkdf", + "hmac", + "home", + "itoa", + "log", + "md-5", + "memchr", + "num-bigint", "once_cell", - "proc-macro2", - "quote", + "rand", + "serde", + "serde_json", + "sha1", "sha2", + "smallvec 1.13.2", "sqlx-core", - "sqlx-rt", - "syn 1.0.109", - "url", + "stringprep", + "thiserror", + "time", + "tracing", + "whoami", ] [[package]] -name = "sqlx-rt" -version = "0.6.3" +name = "sqlx-sqlite" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "804d3f245f894e61b1e6263c84b23ca675d96753b5abfd5cc8597d86806e8024" +checksum = "210976b7d948c7ba9fced8ca835b11cbb2d677c59c79de41ac0d397e14547490" dependencies = [ - "native-tls", - "once_cell", - "tokio 1.36.0", - "tokio-native-tls", + "atoi", + "flume", + "futures-channel", + "futures-core", + "futures-executor", + "futures-intrusive", + "futures-util", + "libsqlite3-sys", + "log", + "percent-encoding", + "serde", + "sqlx-core", + "time", + "tracing", + "url", + "urlencoding", ] [[package]] @@ -6512,7 +6624,7 @@ dependencies = [ "async-bb8-diesel", "async-trait", "bb8", - "bytes 1.5.0", + "bytes 1.6.0", "common_utils", "config", "crc32fast", @@ -6521,20 +6633,19 @@ dependencies = [ "diesel_models", "dyn-clone", "error-stack", - "futures 0.3.28", - "http 0.2.9", + "futures 0.3.30", + "http 0.2.12", "masking", "mime", "moka", "once_cell", "redis_interface", - "ring 0.16.20", "router_derive", "router_env", "serde", "serde_json", "thiserror", - "tokio 1.36.0", + "tokio 1.37.0", ] [[package]] @@ -6574,11 +6685,11 @@ dependencies = [ [[package]] name = "strum" -version = "0.25.0" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" +checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" dependencies = [ - "strum_macros 0.25.2", + "strum_macros 0.26.2", ] [[package]] @@ -6596,22 +6707,22 @@ dependencies = [ [[package]] name = "strum_macros" -version = "0.25.2" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad8d03b598d3d0fff69bf533ee3ef19b8eeb342729596df84bcc7e1f96ec4059" +checksum = "c6cf59daf282c0a494ba14fd21610a0325f9f90ec9d1231dea26bcb1d696c946" dependencies = [ "heck", "proc-macro2", "quote", "rustversion", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] name = "subtle" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "syn" @@ -6626,9 +6737,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.55" +version = "2.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "002a1b3dbf967edfafc32655d0f377ab0bb7b994aa1d32c8cc7e9b8bf3ebb8f0" +checksum = "11a6ae1e52eb25aab8f3fb9fca13be982a373b8f1157ca14b897a825ba4a2d35" dependencies = [ "proc-macro2", "quote", @@ -6644,7 +6755,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] @@ -6665,6 +6776,17 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.57", +] + [[package]] name = "system-configuration" version = "0.5.1" @@ -6700,15 +6822,14 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.8.0" +version = "3.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" dependencies = [ "cfg-if 1.0.0", - "fastrand 2.0.1", - "redox_syscall 0.3.5", + "fastrand 2.0.2", "rustix", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -6725,7 +6846,7 @@ dependencies = [ "percent-encoding", "pest", "pest_derive", - "rand 0.8.5", + "rand", "regex", "serde", "serde_json", @@ -6735,36 +6856,34 @@ dependencies = [ [[package]] name = "test-case" -version = "3.2.1" +version = "3.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8f1e820b7f1d95a0cdbf97a5df9de10e1be731983ab943e56703ac1b8e9d425" +checksum = "eb2550dd13afcd286853192af8601920d959b14c401fcece38071d53bf0768a8" dependencies = [ "test-case-macros", ] [[package]] name = "test-case-core" -version = "3.2.1" +version = "3.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54c25e2cb8f5fcd7318157634e8838aa6f7e4715c96637f969fabaccd1ef5462" +checksum = "adcb7fd841cd518e279be3d5a3eb0636409487998a4aff22f3de87b81e88384f" dependencies = [ "cfg-if 1.0.0", - "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] name = "test-case-macros" -version = "3.2.1" +version = "3.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37cfd7bbc88a0104e304229fba519bdc45501a30b760fb72240342f1289ad257" +checksum = "5c89e72a01ed4c579669add59014b9a524d609c0c88c6a585ce37485879f6ffb" dependencies = [ - "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", "test-case-core", ] @@ -6773,10 +6892,10 @@ name = "test_utils" version = "0.1.0" dependencies = [ "async-trait", - "base64 0.21.5", + "base64 0.22.0", "clap", "masking", - "rand 0.8.5", + "rand", "regex", "reqwest", "serde", @@ -6785,8 +6904,8 @@ dependencies = [ "serial_test", "thirtyfour", "time", - "tokio 1.36.0", - "toml 0.7.4", + "tokio 1.37.0", + "toml", ] [[package]] @@ -6800,8 +6919,8 @@ dependencies = [ "chrono", "cookie 0.16.2", "fantoccini", - "futures 0.3.28", - "http 0.2.9", + "futures 0.3.30", + "http 0.2.12", "log", "parking_lot 0.12.1", "serde", @@ -6810,7 +6929,7 @@ dependencies = [ "stringmatch", "thirtyfour-macros", "thiserror", - "tokio 1.36.0", + "tokio 1.37.0", "url", "urlparse", ] @@ -6829,52 +6948,46 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.49" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" +checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.49" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" +checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] name = "thread_local" -version = "1.1.7" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" dependencies = [ "cfg-if 1.0.0", "once_cell", ] -[[package]] -name = "tiff" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a53f4706d65497df0c4349241deddf35f84cee19c87ed86ea8ca590f4464437" -dependencies = [ - "jpeg-decoder", - "miniz_oxide 0.4.4", - "weezl", -] - [[package]] name = "time" -version = "0.3.23" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59e399c068f43a5d116fedaf73b203fa4f9c519f17e2b34f63221d3792f81446" +checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" dependencies = [ + "deranged", "itoa", + "libc", + "num-conv", + "num_threads", + "powerfmt", "serde", "time-core", "time-macros", @@ -6882,19 +6995,29 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.10" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96ba15a897f3c86766b757e5ac7221554c6750054d74d5b28844fce5fb36a6c4" +checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774" dependencies = [ + "num-conv", "time-core", ] +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + [[package]] name = "tinytemplate" version = "1.2.1" @@ -6946,19 +7069,19 @@ dependencies = [ [[package]] name = "tokio" -version = "1.36.0" +version = "1.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" +checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" dependencies = [ "backtrace", - "bytes 1.5.0", + "bytes 1.6.0", "libc", - "mio 0.8.10", + "mio 0.8.11", "num_cpus", "parking_lot 0.12.1", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.5", + "socket2", "tokio-macros", "windows-sys 0.48.0", ] @@ -7023,7 +7146,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf" dependencies = [ "pin-project-lite", - "tokio 1.36.0", + "tokio 1.37.0", ] [[package]] @@ -7034,7 +7157,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] @@ -7044,7 +7167,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" dependencies = [ "native-tls", - "tokio 1.36.0", + "tokio 1.37.0", ] [[package]] @@ -7073,7 +7196,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" dependencies = [ "rustls 0.20.9", - "tokio 1.36.0", + "tokio 1.37.0", "webpki", ] @@ -7084,18 +7207,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ "rustls 0.21.10", - "tokio 1.36.0", + "tokio 1.37.0", ] [[package]] name = "tokio-stream" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" +checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" dependencies = [ "futures-core", "pin-project-lite", - "tokio 1.36.0", + "tokio 1.37.0", "tokio-util", ] @@ -7187,71 +7310,73 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.9" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d68074620f57a0b21594d9735eb2e98ab38b17f80d3fcb189fca266771ca60d" +checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" dependencies = [ - "bytes 1.5.0", + "bytes 1.6.0", "futures-core", "futures-sink", "pin-project-lite", - "tokio 1.36.0", + "tokio 1.37.0", "tracing", ] [[package]] name = "toml" -version = "0.5.11" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +checksum = "e9dd1545e8208b4a5af1aa9bbd0b4cf7e9ea08fabc5d0a5c67fcaafa17433aa3" dependencies = [ + "indexmap 2.2.6", "serde", + "serde_spanned", + "toml_datetime", + "toml_edit 0.22.9", ] [[package]] -name = "toml" -version = "0.7.4" +name = "toml_datetime" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6135d499e69981f9ff0ef2167955a5333c35e36f6937d382974566b3d5b94ec" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" dependencies = [ - "indexmap 1.9.3", "serde", - "serde_spanned", - "toml_datetime", - "toml_edit 0.19.14", ] [[package]] -name = "toml_datetime" -version = "0.6.3" +name = "toml_edit" +version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "serde", + "indexmap 2.2.6", + "toml_datetime", + "winnow 0.5.40", ] [[package]] name = "toml_edit" -version = "0.19.14" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a" +checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ - "indexmap 2.1.0", - "serde", - "serde_spanned", + "indexmap 2.2.6", "toml_datetime", - "winnow", + "winnow 0.5.40", ] [[package]] name = "toml_edit" -version = "0.20.2" +version = "0.22.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" +checksum = "8e40bb779c5187258fd7aad0eb68cb8706a0a81fa712fbea808ab43c4b8374c4" dependencies = [ - "indexmap 2.1.0", + "indexmap 2.2.6", + "serde", + "serde_spanned", "toml_datetime", - "winnow", + "winnow 0.6.5", ] [[package]] @@ -7264,19 +7389,19 @@ dependencies = [ "async-trait", "axum", "base64 0.13.1", - "bytes 1.5.0", + "bytes 1.6.0", "futures-core", "futures-util", - "h2", - "http 0.2.9", - "http-body", - "hyper", + "h2 0.3.25", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.28", "hyper-timeout", "percent-encoding", "pin-project", "prost", "prost-derive", - "tokio 1.36.0", + "tokio 1.37.0", "tokio-stream", "tokio-util", "tower", @@ -7297,9 +7422,9 @@ dependencies = [ "indexmap 1.9.3", "pin-project", "pin-project-lite", - "rand 0.8.5", + "rand", "slab", - "tokio 1.36.0", + "tokio 1.37.0", "tokio-util", "tower-layer", "tower-service", @@ -7347,11 +7472,12 @@ dependencies = [ [[package]] name = "tracing-appender" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09d48f71a791638519505cefafe162606f706c25592e4bde4d97600c0195312e" +checksum = "3566e8ce28cc0a3fe42519fc80e6b4c943cc4c8cef275620eb8dac2d3d4e06cf" dependencies = [ "crossbeam-channel", + "thiserror", "time", "tracing-subscriber", ] @@ -7364,7 +7490,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] @@ -7390,12 +7516,23 @@ dependencies = [ [[package]] name = "tracing-log" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +checksum = "f751112709b4e791d8ce53e32c4ed2d353565a795ce84da2285393f41557bdf2" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" dependencies = [ - "lazy_static", "log", + "once_cell", "tracing-core", ] @@ -7409,7 +7546,7 @@ dependencies = [ "opentelemetry", "tracing", "tracing-core", - "tracing-log", + "tracing-log 0.1.4", "tracing-subscriber", ] @@ -7425,9 +7562,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.17" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" dependencies = [ "matchers", "nu-ansi-term", @@ -7436,25 +7573,25 @@ dependencies = [ "serde", "serde_json", "sharded-slab", - "smallvec 1.11.1", + "smallvec 1.13.2", "thread_local", "tracing", "tracing-core", - "tracing-log", + "tracing-log 0.2.0", "tracing-serde", ] [[package]] name = "triomphe" -version = "0.1.9" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee8098afad3fb0c54a9007aab6804558410503ad676d4633f9c2559a00ac0f" +checksum = "859eb650cfee7434994602c3a68b25d77ad9e68c8a6cd491616ef86661382eb3" [[package]] name = "try-lock" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "typenum" @@ -7535,9 +7672,9 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.13" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" @@ -7547,18 +7684,18 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" dependencies = [ "tinyvec", ] [[package]] name = "unicode-segmentation" -version = "1.10.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-xid" @@ -7572,12 +7709,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" -[[package]] -name = "unidecode" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "402bb19d8e03f1d1a7450e2bd613980869438e0666331be3e073089124aa1adc" - [[package]] name = "untrusted" version = "0.7.1" @@ -7592,9 +7723,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" dependencies = [ "form_urlencoded", "idna", @@ -7616,11 +7747,11 @@ checksum = "110352d4e9076c67839003c7788d8604e24dcded13e0b375af3efaa8cf468517" [[package]] name = "utoipa" -version = "3.5.0" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d82b1bc5417102a73e8464c686eef947bdfb99fcdfc0a4f228e81afa9526470a" +checksum = "272ebdfbc99111033031d2f10e018836056e4d2c8e2acda76450ec7974269fa7" dependencies = [ - "indexmap 2.1.0", + "indexmap 2.2.6", "serde", "serde_json", "utoipa-gen", @@ -7628,34 +7759,34 @@ dependencies = [ [[package]] name = "utoipa-gen" -version = "3.5.0" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05d96dcd6fc96f3df9b3280ef480770af1b7c5d14bc55192baa9b067976d920c" +checksum = "d3c9f4d08338c1bfa70dde39412a040a884c6f318b3d09aaaf3437a1e52027fc" dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] name = "uuid" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" dependencies = [ "atomic", - "getrandom 0.2.11", + "getrandom", ] [[package]] name = "validator" -version = "0.16.1" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b92f40481c04ff1f4f61f304d61793c7b56ff76ac1469f1beb199b1445b253bd" +checksum = "da339118f018cc70ebf01fafc103360528aad53717e4bf311db929cb01cb9345" dependencies = [ "idna", - "lazy_static", + "once_cell", "regex", "serde", "serde_derive", @@ -7671,14 +7802,14 @@ checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" [[package]] name = "vaultrs" -version = "0.7.0" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28084ac780b443e7f3514df984a2933bd3ab39e71914d951cdf8e4d298a7c9bc" +checksum = "0bb996bb053adadc767f8b0bda2a80bc2b67d24fe89f2b959ae919e200d79a19" dependencies = [ "async-trait", - "bytes 1.5.0", + "bytes 1.6.0", "derive_builder", - "http 0.2.9", + "http 0.2.12", "reqwest", "rustify", "rustify_derive", @@ -7697,12 +7828,15 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "vergen" -version = "8.2.1" +version = "8.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b3c89c2c7e50f33e4d35527e5bf9c11d6d132226dbbd1753f0fbe9f19ef88c6" +checksum = "e27d6bdd219887a9eadd19e1c34f32e47fa332301184935c6d9bca26f3cca525" dependencies = [ "anyhow", + "cargo_metadata 0.18.1", + "cfg-if 1.0.0", "git2", + "regex", "rustc_version 0.4.0", "rustversion", "time", @@ -7735,17 +7869,11 @@ dependencies = [ "libc", ] -[[package]] -name = "waker-fn" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3c4517f54858c779bbcbf228f4fca63d121bf85fbecb2dc578cdf4a39395690" - [[package]] name = "walkdir" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" dependencies = [ "same-file", "winapi-util", @@ -7762,21 +7890,21 @@ dependencies = [ [[package]] name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" +version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" +name = "wasite" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" [[package]] name = "wasm-bindgen" -version = "0.2.87" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" dependencies = [ "cfg-if 1.0.0", "wasm-bindgen-macro", @@ -7784,24 +7912,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.87" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.37" +version = "0.4.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" +checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" dependencies = [ "cfg-if 1.0.0", "js-sys", @@ -7811,9 +7939,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.87" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -7821,28 +7949,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.87" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.87" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "web-sys" -version = "0.3.64" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" +checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" dependencies = [ "js-sys", "wasm-bindgen", @@ -7855,9 +7983,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9973cb72c8587d5ad5efdb91e663d36177dc37725e6c90ca86c626b0cc45c93f" dependencies = [ "base64 0.13.1", - "bytes 1.5.0", + "bytes 1.6.0", "cookie 0.16.2", - "http 0.2.9", + "http 0.2.12", "log", "serde", "serde_derive", @@ -7869,12 +7997,12 @@ dependencies = [ [[package]] name = "webpki" -version = "0.22.2" +version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07ecc0cd7cac091bf682ec5efa18b1cff79d617b84181f38b3951dbe135f607f" +checksum = "ed63aea5ce73d0ff405984102c42de94fc55a6b75765d621c65262469b3c9b53" dependencies = [ - "ring 0.16.20", - "untrusted 0.7.1", + "ring 0.17.8", + "untrusted 0.9.0", ] [[package]] @@ -7888,24 +8016,18 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.25.3" +version = "0.25.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10" - -[[package]] -name = "weezl" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb" +checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" [[package]] name = "whoami" -version = "1.4.1" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22fc3756b8a9133049b26c7f61ab35416c130e8c09b660f5b3958b446f52cc50" +checksum = "a44ab49fad634e88f55bf8f9bb3abd2f27d7204172a112c7c9987e01c1c94ea9" dependencies = [ - "wasm-bindgen", - "web-sys", + "redox_syscall 0.4.1", + "wasite", ] [[package]] @@ -7953,11 +8075,11 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-core" -version = "0.51.1" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.48.5", + "windows-targets 0.52.4", ] [[package]] @@ -7975,7 +8097,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.4", ] [[package]] @@ -7995,17 +8117,17 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", + "windows_aarch64_gnullvm 0.52.4", + "windows_aarch64_msvc 0.52.4", + "windows_i686_gnu 0.52.4", + "windows_i686_msvc 0.52.4", + "windows_x86_64_gnu 0.52.4", + "windows_x86_64_gnullvm 0.52.4", + "windows_x86_64_msvc 0.52.4", ] [[package]] @@ -8016,9 +8138,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" [[package]] name = "windows_aarch64_msvc" @@ -8028,9 +8150,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" [[package]] name = "windows_i686_gnu" @@ -8040,9 +8162,9 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" +checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" [[package]] name = "windows_i686_msvc" @@ -8052,9 +8174,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" +checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" [[package]] name = "windows_x86_64_gnu" @@ -8064,9 +8186,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" [[package]] name = "windows_x86_64_gnullvm" @@ -8076,9 +8198,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" [[package]] name = "windows_x86_64_msvc" @@ -8088,15 +8210,24 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.0" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" + +[[package]] +name = "winnow" +version = "0.5.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" +dependencies = [ + "memchr", +] [[package]] name = "winnow" -version = "0.5.19" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "829846f3e3db426d4cee4510841b71a8e58aa2a76b1132579487ae430ccd9c7b" +checksum = "dffa400e67ed5a4dd237983829e66475f0a4a26938c4b04c21baede6262215b8" dependencies = [ "memchr", ] @@ -8113,24 +8244,26 @@ dependencies = [ [[package]] name = "wiremock" -version = "0.5.18" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd7b0b5b253ebc0240d6aac6dd671c495c467420577bf634d3064ae7e6fa2b4c" +checksum = "ec874e1eef0df2dcac546057fe5e29186f09c378181cd7b635b4b7bcc98e9d81" dependencies = [ "assert-json-diff", "async-trait", - "base64 0.21.5", + "base64 0.21.7", "deadpool", - "futures 0.3.28", - "futures-timer", - "http-types", - "hyper", + "futures 0.3.30", + "http 1.1.0", + "http-body-util", + "hyper 1.2.0", + "hyper-util", "log", "once_cell", "regex", "serde", "serde_json", - "tokio 1.36.0", + "tokio 1.37.0", + "url", ] [[package]] @@ -8154,9 +8287,9 @@ dependencies = [ [[package]] name = "x509-parser" -version = "0.15.1" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7069fba5b66b9193bd2c5d3d4ff12b839118f6bcbef5328efafafb5395cf63da" +checksum = "fcbc162f30700d6f3f82a24bf7cc62ffe7caea42c0b2cba8bf7f3ae50cf51f69" dependencies = [ "asn1-rs", "data-encoding", @@ -8186,56 +8319,54 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.7.31" +version = "0.7.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c4061bedbb353041c12f413700357bec76df2c7e2ca8e4df8bac24c6bf68e3d" +checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.31" +version = "0.7.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3c129550b3e6de3fd0ba67ba5c81818f9805e58b8d7fee80a3a59d2c9fc601a" +checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] name = "zeroize" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" [[package]] name = "zstd" -version = "0.12.4" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a27595e173641171fc74a1232b7b1c7a7cb6e18222c11e9dfb9888fa424c53c" +checksum = "bffb3309596d527cfcba7dfc6ed6052f1d39dfbd7c867aa2e865e4a449c10110" dependencies = [ "zstd-safe", ] [[package]] name = "zstd-safe" -version = "6.0.6" +version = "7.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee98ffd0b48ee95e6c5168188e44a54550b1564d9d530ee21d5f0eaed1069581" +checksum = "43747c7422e2924c11144d5229878b98180ef8b06cca4ab5af37afc8a8d8ea3e" dependencies = [ - "libc", "zstd-sys", ] [[package]] name = "zstd-sys" -version = "2.0.8+zstd.1.5.5" +version = "2.0.9+zstd.1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5556e6ee25d32df2586c098bbfa278803692a20d0ab9565e049480d52707ec8c" +checksum = "9e16efa8a874a0481a574084d34cc26fdb3b99627480f785888deb6386506656" dependencies = [ "cc", - "libc", "pkg-config", ] diff --git a/crates/analytics/Cargo.toml b/crates/analytics/Cargo.toml index 37b13a39713a..2b1cc798a7e2 100644 --- a/crates/analytics/Cargo.toml +++ b/crates/analytics/Cargo.toml @@ -2,51 +2,40 @@ name = "analytics" version = "0.1.0" description = "Analytics / Reports / Search related functionality" -edition = "2021" +edition.workspace = true +rust-version.workspace = true +license.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] # First party crates -api_models = { version = "0.1.0", path = "../api_models", features = [ - "errors", -] } +api_models = { version = "0.1.0", path = "../api_models", features = ["errors"] } storage_impl = { version = "0.1.0", path = "../storage_impl", default-features = false } common_utils = { version = "0.1.0", path = "../common_utils" } external_services = { version = "0.1.0", path = "../external_services", default-features = false } hyperswitch_interfaces = { version = "0.1.0", path = "../hyperswitch_interfaces" } masking = { version = "0.1.0", path = "../masking" } -router_env = { version = "0.1.0", path = "../router_env", features = [ - "log_extra_implicit_fields", - "log_custom_entries_to_extra", -] } -diesel_models = { version = "0.1.0", path = "../diesel_models", features = [ - "kv_store", -] } +router_env = { version = "0.1.0", path = "../router_env", features = ["log_extra_implicit_fields", "log_custom_entries_to_extra"] } +diesel_models = { version = "0.1.0", path = "../diesel_models", features = ["kv_store"] } #Third Party dependencies -actix-web = "4.3.1" -async-trait = "0.1.68" -aws-config = { version = "1.1.6", features = ["behavior-version-latest"] } -aws-sdk-lambda = { version = "1.1.4" } -aws-smithy-types = { version = "1.1.6" } +actix-web = "4.5.1" +async-trait = "0.1.79" +aws-config = { version = "1.1.9", features = ["behavior-version-latest"] } +aws-sdk-lambda = { version = "1.18.0" } +aws-smithy-types = { version = "1.1.8" } bigdecimal = { version = "0.3.1", features = ["serde"] } error-stack = "0.4.1" -futures = "0.3.28" +futures = "0.3.30" opensearch = { version = "2.2.0", features = ["aws-auth"] } -once_cell = "1.18.0" -reqwest = { version = "0.11.18", features = ["serde_json"] } -serde = { version = "1.0.193", features = ["derive", "rc"] } -serde_json = "1.0.108" -sqlx = { version = "0.6.3", features = [ - "postgres", - "runtime-actix", - "runtime-actix-native-tls", - "time", - "bigdecimal", -] } -strum = { version = "0.25.0", features = ["derive"] } -thiserror = "1.0.43" -time = { version = "0.3.21", features = ["serde", "serde-well-known", "std"] } -tokio = { version = "1.36.0", features = ["macros", "rt-multi-thread"] } +once_cell = "1.19.0" +reqwest = { version = "0.11.27", features = ["serde_json"] } +serde = { version = "1.0.197", features = ["derive", "rc"] } +serde_json = "1.0.115" +sqlx = { version = "0.7.3", features = ["postgres", "runtime-tokio", "runtime-tokio-native-tls", "time", "bigdecimal"] } +strum = { version = "0.26.2", features = ["derive"] } +thiserror = "1.0.58" +time = { version = "0.3.34", features = ["serde", "serde-well-known", "std"] } +tokio = { version = "1.37.0", features = ["macros", "rt-multi-thread"] } diff --git a/crates/analytics/src/sqlx.rs b/crates/analytics/src/sqlx.rs index 586ec1bfb17a..86782c5f750f 100644 --- a/crates/analytics/src/sqlx.rs +++ b/crates/analytics/src/sqlx.rs @@ -100,10 +100,10 @@ where Type: DbType + FromStr + Display, { fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> sqlx::encode::IsNull { - self.0.to_string().encode(buf) + >::encode(self.0.to_string(), buf) } fn size_hint(&self) -> usize { - self.0.to_string().size_hint() + >::size_hint(&self.0.to_string()) } } diff --git a/crates/api_models/Cargo.toml b/crates/api_models/Cargo.toml index 356a29830ec5..cdcee9c506e5 100644 --- a/crates/api_models/Cargo.toml +++ b/crates/api_models/Cargo.toml @@ -23,22 +23,22 @@ openapi = ["common_enums/openapi", "olap", "backwards_compatibility", "business_ recon = [] [dependencies] -actix-web = { version = "4.3.1", optional = true } +actix-web = { version = "4.5.1", optional = true } error-stack = "0.4.1" mime = "0.3.17" -reqwest = { version = "0.11.18", optional = true } -serde = { version = "1.0.193", features = ["derive"] } -serde_json = "1.0.108" -strum = { version = "0.25", features = ["derive"] } -time = { version = "0.3.21", features = ["serde", "serde-well-known", "std"] } -url = { version = "2.4.0", features = ["serde"] } -utoipa = { version = "3.5.0", features = ["preserve_order", "preserve_path_order"] } -frunk = "0.4.1" -frunk_core = "0.4.1" +reqwest = { version = "0.11.27", optional = true } +serde = { version = "1.0.197", features = ["derive"] } +serde_json = "1.0.115" +strum = { version = "0.26", features = ["derive"] } +time = { version = "0.3.34", features = ["serde", "serde-well-known", "std"] } +url = { version = "2.5.0", features = ["serde"] } +utoipa = { version = "4.2.0", features = ["preserve_order", "preserve_path_order"] } +frunk = "0.4.2" +frunk_core = "0.4.2" # First party crates cards = { version = "0.1.0", path = "../cards" } -common_enums = { path = "../common_enums" } +common_enums = { version = "0.1.0", path = "../common_enums" } common_utils = { version = "0.1.0", path = "../common_utils" } euclid = { version = "0.1.0", path = "../euclid" } masking = { version = "0.1.0", path = "../masking", default-features = false, features = ["alloc", "serde"] } diff --git a/crates/api_models/src/conditional_configs.rs b/crates/api_models/src/conditional_configs.rs index f8ed13421ac4..46bad3e9e862 100644 --- a/crates/api_models/src/conditional_configs.rs +++ b/crates/api_models/src/conditional_configs.rs @@ -17,7 +17,7 @@ use serde::{Deserialize, Serialize}; PartialEq, Eq, strum::Display, - strum::EnumVariantNames, + strum::VariantNames, strum::EnumIter, strum::EnumString, Serialize, diff --git a/crates/api_models/src/enums.rs b/crates/api_models/src/enums.rs index 354dec29237b..e93371ef947c 100644 --- a/crates/api_models/src/enums.rs +++ b/crates/api_models/src/enums.rs @@ -35,7 +35,7 @@ pub enum RoutingAlgorithm { ToSchema, serde::Deserialize, serde::Serialize, - strum::EnumVariantNames, + strum::VariantNames, strum::EnumIter, strum::Display, strum::EnumString, diff --git a/crates/cards/Cargo.toml b/crates/cards/Cargo.toml index bb185bf2167a..ab4152893afc 100644 --- a/crates/cards/Cargo.toml +++ b/crates/cards/Cargo.toml @@ -12,9 +12,9 @@ license.workspace = true [dependencies] error-stack = "0.4.1" luhn = "1.0.1" -serde = { version = "1.0.193", features = ["derive"] } -thiserror = "1.0.40" -time = "0.3.21" +serde = { version = "1.0.197", features = ["derive"] } +thiserror = "1.0.58" +time = "0.3.34" # First party crates common_utils = { version = "0.1.0", path = "../common_utils" } @@ -24,4 +24,4 @@ masking = { version = "0.1.0", path = "../masking" } router_env = { version = "0.1.0", path = "../router_env", features = ["log_extra_implicit_fields", "log_custom_entries_to_extra"] } [dev-dependencies] -serde_json = "1.0.108" +serde_json = "1.0.115" diff --git a/crates/common_enums/Cargo.toml b/crates/common_enums/Cargo.toml index 30da73c57d21..5c88236b8ae2 100644 --- a/crates/common_enums/Cargo.toml +++ b/crates/common_enums/Cargo.toml @@ -13,14 +13,14 @@ openapi = [] payouts = [] [dependencies] -diesel = { version = "2.1.0", features = ["postgres"] } -serde = { version = "1.0.193", features = ["derive"] } -serde_json = "1.0.108" -strum = { version = "0.25", features = ["derive"] } -utoipa = { version = "3.5.0", features = ["preserve_order", "preserve_path_order"] } +diesel = { version = "2.1.5", features = ["postgres"] } +serde = { version = "1.0.197", features = ["derive"] } +serde_json = "1.0.115" +strum = { version = "0.26", features = ["derive"] } +utoipa = { version = "4.2.0", features = ["preserve_order", "preserve_path_order"] } # First party crates router_derive = { version = "0.1.0", path = "../router_derive" } [dev-dependencies] -serde_json = "1.0.108" +serde_json = "1.0.115" diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs index 571449b98722..fefe0a93af2f 100644 --- a/crates/common_enums/src/enums.rs +++ b/crates/common_enums/src/enums.rs @@ -74,7 +74,7 @@ pub enum AttemptStatus { strum::Display, strum::EnumString, strum::EnumIter, - strum::EnumVariantNames, + strum::VariantNames, ToSchema, )] #[router_derive::diesel_enum(storage_type = "db_enum")] @@ -209,7 +209,7 @@ impl AttemptStatus { serde::Deserialize, serde::Serialize, strum::Display, - strum::EnumVariantNames, + strum::VariantNames, strum::EnumIter, strum::EnumString, ToSchema, @@ -312,7 +312,7 @@ pub enum BlocklistDataKind { serde::Deserialize, serde::Serialize, strum::Display, - strum::EnumVariantNames, + strum::VariantNames, strum::EnumIter, strum::EnumString, ToSchema, @@ -386,7 +386,7 @@ pub enum ConnectorType { strum::Display, strum::EnumString, strum::EnumIter, - strum::EnumVariantNames, + strum::VariantNames, ToSchema, )] #[router_derive::diesel_enum(storage_type = "db_enum")] @@ -1181,7 +1181,7 @@ pub enum IntentStatus { serde::Deserialize, serde::Serialize, strum::Display, - strum::EnumVariantNames, + strum::VariantNames, strum::EnumIter, strum::EnumString, ToSchema, @@ -1328,7 +1328,7 @@ pub enum PaymentExperience { serde::Deserialize, serde::Serialize, strum::Display, - strum::EnumVariantNames, + strum::VariantNames, strum::EnumIter, strum::EnumString, ToSchema, @@ -1435,7 +1435,7 @@ pub enum PaymentMethodType { serde::Deserialize, serde::Serialize, strum::Display, - strum::EnumVariantNames, + strum::VariantNames, strum::EnumIter, strum::EnumString, ToSchema, @@ -1543,7 +1543,7 @@ pub enum MandateStatus { serde::Deserialize, serde::Serialize, strum::Display, - strum::EnumVariantNames, + strum::VariantNames, strum::EnumIter, strum::EnumString, ToSchema, @@ -1709,7 +1709,7 @@ pub enum CountryAlpha3 { Eq, Hash, strum::Display, - strum::EnumVariantNames, + strum::VariantNames, strum::EnumIter, strum::EnumString, Deserialize, @@ -2109,7 +2109,7 @@ pub enum PayoutStatus { serde::Deserialize, serde::Serialize, strum::Display, - strum::EnumVariantNames, + strum::VariantNames, strum::EnumIter, strum::EnumString, ToSchema, diff --git a/crates/common_utils/Cargo.toml b/crates/common_utils/Cargo.toml index bc8a3af0a436..285d423958d6 100644 --- a/crates/common_utils/Cargo.toml +++ b/crates/common_utils/Cargo.toml @@ -13,33 +13,33 @@ async_ext = ["dep:futures", "dep:async-trait"] logs = ["dep:router_env"] [dependencies] -async-trait = { version = "0.1.68", optional = true } -bytes = "1.4.0" -diesel = "2.1.0" +async-trait = { version = "0.1.79", optional = true } +bytes = "1.6.0" +diesel = "2.1.5" error-stack = "0.4.1" -futures = { version = "0.3.28", optional = true } +futures = { version = "0.3.30", optional = true } hex = "0.4.3" -http = "0.2.9" +http = "0.2.12" md5 = "0.7.0" nanoid = "0.4.0" -once_cell = "1.18.0" +once_cell = "1.19.0" phonenumber = "0.3.3" -quick-xml = { version = "0.28.2", features = ["serialize"] } +quick-xml = { version = "0.31.0", features = ["serialize"] } rand = "0.8.5" -regex = "1.8.4" -reqwest = { version = "0.11.18", features = ["json", "native-tls", "gzip", "multipart"] } -ring = { version = "0.16.20", features = ["std"] } +regex = "1.10.4" +reqwest = { version = "0.11.27", features = ["json", "native-tls", "gzip", "multipart"] } +ring = { version = "0.17.8", features = ["std", "wasm32_unknown_unknown_js"] } rustc-hash = "1.1.0" -serde = { version = "1.0.193", features = ["derive"] } -serde_json = "1.0.108" +serde = { version = "1.0.197", features = ["derive"] } +serde_json = "1.0.115" serde_urlencoded = "0.7.1" -signal-hook = { version = "0.3.15", optional = true } -strum = { version = "0.24.1", features = ["derive"] } -thiserror = "1.0.40" -time = { version = "0.3.21", features = ["serde", "serde-well-known", "std"] } -tokio = { version = "1.36.0", features = ["macros", "rt-multi-thread"], optional = true } +signal-hook = { version = "0.3.17", optional = true } +strum = { version = "0.26.2", features = ["derive"] } +thiserror = "1.0.58" +time = { version = "0.3.34", features = ["serde", "serde-well-known", "std"] } +tokio = { version = "1.37.0", features = ["macros", "rt-multi-thread"], optional = true } semver = { version = "1.0.22", features = ["serde"] } -uuid = { version = "1.7.0", features = ["v7"] } +uuid = { version = "1.8.0", features = ["v7"] } # First party crates common_enums = { version = "0.1.0", path = "../common_enums" } @@ -50,6 +50,6 @@ router_env = { version = "0.1.0", path = "../router_env", features = ["log_extra signal-hook-tokio = { version = "0.3.1", features = ["futures-v0_3"], optional = true } [dev-dependencies] -fake = "2.6.1" -proptest = "1.2.0" -test-case = "3.1.0" +fake = "2.9.2" +proptest = "1.4.0" +test-case = "3.3.1" diff --git a/crates/config_importer/Cargo.toml b/crates/config_importer/Cargo.toml index d831812cdcab..129abae15ad6 100644 --- a/crates/config_importer/Cargo.toml +++ b/crates/config_importer/Cargo.toml @@ -12,12 +12,12 @@ all-features = true rustdoc-args = ["--cfg", "docsrs"] [dependencies] -anyhow = "1.0.75" -clap = { version = "4.3.2", default-features = false, features = ["std", "derive", "help", "usage"] } -indexmap = { version = "2.1.0", optional = true } -serde = { version = "1.0.193", features = ["derive"] } -serde_json = "1.0.108" -toml = { version = "0.7.4", default-features = false, features = ["parse"] } +anyhow = "1.0.81" +clap = { version = "4.4.18", default-features = false, features = ["std", "derive", "help", "usage"] } +indexmap = { version = "2.2.6", optional = true } +serde = { version = "1.0.197", features = ["derive"] } +serde_json = "1.0.115" +toml = { version = "0.8.12", default-features = false, features = ["parse"] } [features] default = ["preserve_order"] diff --git a/crates/connector_configs/Cargo.toml b/crates/connector_configs/Cargo.toml index 7966e6a5afe9..de0c963d7b6e 100644 --- a/crates/connector_configs/Cargo.toml +++ b/crates/connector_configs/Cargo.toml @@ -16,7 +16,7 @@ payouts = ["api_models/payouts"] [dependencies] api_models = { version = "0.1.0", path = "../api_models", package = "api_models" } -serde = { version = "1.0.193", features = ["derive"] } -serde_with = "3.4.0" -toml = "0.7.3" -utoipa = { version = "3.5.0", features = ["preserve_order", "preserve_path_order"] } +serde = { version = "1.0.197", features = ["derive"] } +serde_with = "3.7.0" +toml = "0.8.12" +utoipa = { version = "4.2.0", features = ["preserve_order", "preserve_path_order"] } diff --git a/crates/currency_conversion/Cargo.toml b/crates/currency_conversion/Cargo.toml index d2c99080bf64..40129258a67d 100644 --- a/crates/currency_conversion/Cargo.toml +++ b/crates/currency_conversion/Cargo.toml @@ -3,6 +3,8 @@ name = "currency_conversion" description = "Currency conversion for cost based routing" version = "0.1.0" edition.workspace = true +rust-version.workspace = true +license.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] @@ -10,7 +12,7 @@ edition.workspace = true common_enums = { version = "0.1.0", path = "../common_enums", package = "common_enums" } # Third party crates -rust_decimal = "1.29" +rust_decimal = "1.35" rusty-money = { git = "https://github.com/varunsrin/rusty_money", rev = "bbc0150742a0fff905225ff11ee09388e9babdcc", features = ["iso", "crypto"] } -serde = { version = "1.0.193", features = ["derive"] } -thiserror = "1.0.43" +serde = { version = "1.0.197", features = ["derive"] } +thiserror = "1.0.58" diff --git a/crates/data_models/Cargo.toml b/crates/data_models/Cargo.toml index 090983246d76..6da89dc23257 100644 --- a/crates/data_models/Cargo.toml +++ b/crates/data_models/Cargo.toml @@ -21,9 +21,9 @@ masking = { version = "0.1.0", path = "../masking" } diesel_models = { version = "0.1.0", path = "../diesel_models", features = ["kv_store"] } # Third party deps -async-trait = "0.1.68" +async-trait = "0.1.79" error-stack = "0.4.1" -serde = { version = "1.0.193", features = ["derive"] } -serde_json = "1.0.108" -thiserror = "1.0.40" -time = { version = "0.3.21", features = ["serde", "serde-well-known", "std"] } +serde = { version = "1.0.197", features = ["derive"] } +serde_json = "1.0.115" +thiserror = "1.0.58" +time = { version = "0.3.34", features = ["serde", "serde-well-known", "std"] } diff --git a/crates/diesel_models/Cargo.toml b/crates/diesel_models/Cargo.toml index d0ef61693351..85533d0cf338 100644 --- a/crates/diesel_models/Cargo.toml +++ b/crates/diesel_models/Cargo.toml @@ -13,18 +13,18 @@ kv_store = [] [dependencies] async-bb8-diesel = { git = "https://github.com/jarnura/async-bb8-diesel", rev = "53b4ab901aab7635c8215fd1c2d542c8db443094" } -diesel = { version = "2.1.0", features = ["postgres", "serde_json", "time", "64-column-tables"] } +diesel = { version = "2.1.5", features = ["postgres", "serde_json", "time", "64-column-tables"] } error-stack = "0.4.1" -frunk = "0.4.1" -frunk_core = "0.4.1" -serde = { version = "1.0.193", features = ["derive"] } -serde_json = "1.0.108" -strum = { version = "0.24.1", features = ["derive"] } -thiserror = "1.0.40" -time = { version = "0.3.21", features = ["serde", "serde-well-known", "std"] } +frunk = "0.4.2" +frunk_core = "0.4.2" +serde = { version = "1.0.197", features = ["derive"] } +serde_json = "1.0.115" +strum = { version = "0.26.2", features = ["derive"] } +thiserror = "1.0.58" +time = { version = "0.3.34", features = ["serde", "serde-well-known", "std"] } # First party crates -common_enums = { path = "../common_enums" } +common_enums = { version = "0.1.0", path = "../common_enums" } common_utils = { version = "0.1.0", path = "../common_utils" } masking = { version = "0.1.0", path = "../masking" } router_derive = { version = "0.1.0", path = "../router_derive" } diff --git a/crates/drainer/Cargo.toml b/crates/drainer/Cargo.toml index 4a2f7f1720e6..424ca6588473 100644 --- a/crates/drainer/Cargo.toml +++ b/crates/drainer/Cargo.toml @@ -12,22 +12,22 @@ release = ["vergen", "external_services/aws_kms"] vergen = ["router_env/vergen"] [dependencies] -actix-web = "4.3.1" +actix-web = "4.5.1" async-bb8-diesel = { git = "https://github.com/jarnura/async-bb8-diesel", rev = "53b4ab901aab7635c8215fd1c2d542c8db443094" } bb8 = "0.8" -clap = { version = "4.3.2", default-features = false, features = ["std", "derive", "help", "usage"] } -config = { version = "0.13.3", features = ["toml"] } -diesel = { version = "2.1.0", features = ["postgres"] } +clap = { version = "4.4.18", default-features = false, features = ["std", "derive", "help", "usage"] } +config = { version = "0.14.0", features = ["toml"] } +diesel = { version = "2.1.5", features = ["postgres"] } error-stack = "0.4.1" mime = "0.3.17" -once_cell = "1.18.0" -reqwest = { version = "0.11.18" } -serde = "1.0.193" -serde_json = "1.0.108" -serde_path_to_error = "0.1.14" -thiserror = "1.0.40" -tokio = { version = "1.36.0", features = ["macros", "rt-multi-thread"] } -async-trait = "0.1.74" +once_cell = "1.19.0" +reqwest = { version = "0.11.27" } +serde = "1.0.197" +serde_json = "1.0.115" +serde_path_to_error = "0.1.16" +thiserror = "1.0.58" +tokio = { version = "1.37.0", features = ["macros", "rt-multi-thread"] } +async-trait = "0.1.79" # First Party Crates common_utils = { version = "0.1.0", path = "../common_utils", features = ["signals"] } diff --git a/crates/euclid/Cargo.toml b/crates/euclid/Cargo.toml index 256ed784512b..7de276455237 100644 --- a/crates/euclid/Cargo.toml +++ b/crates/euclid/Cargo.toml @@ -4,19 +4,20 @@ description = "DSL for static routing" version = "0.1.0" edition.workspace = true rust-version.workspace = true +license.workspace = true [dependencies] -erased-serde = "0.3.28" -frunk = "0.4.1" -frunk_core = "0.4.1" +erased-serde = "0.4.4" +frunk = "0.4.2" +frunk_core = "0.4.2" nom = { version = "7.1.3", features = ["alloc"], optional = true } -once_cell = "1.18.0" +once_cell = "1.19.0" rustc-hash = "1.1.0" -serde = { version = "1.0.193", features = ["derive", "rc"] } -serde_json = "1.0.108" -strum = { version = "0.25", features = ["derive"] } -thiserror = "1.0.43" -utoipa = { version = "3.5.0", features = ["preserve_order", "preserve_path_order"] } +serde = { version = "1.0.197", features = ["derive", "rc"] } +serde_json = "1.0.115" +strum = { version = "0.26", features = ["derive"] } +thiserror = "1.0.58" +utoipa = { version = "4.2.0", features = ["preserve_order", "preserve_path_order"] } # First party dependencies common_enums = { version = "0.1.0", path = "../common_enums" } diff --git a/crates/euclid/src/enums.rs b/crates/euclid/src/enums.rs index 7bd32d336334..f473c5980c7c 100644 --- a/crates/euclid/src/enums.rs +++ b/crates/euclid/src/enums.rs @@ -48,7 +48,7 @@ collect_variants!(PayoutWalletType); PartialEq, Eq, strum::Display, - strum::EnumVariantNames, + strum::VariantNames, strum::EnumIter, strum::EnumString, serde::Serialize, @@ -68,7 +68,7 @@ pub enum MandateAcceptanceType { PartialEq, Eq, strum::Display, - strum::EnumVariantNames, + strum::VariantNames, strum::EnumIter, strum::EnumString, serde::Serialize, @@ -88,7 +88,7 @@ pub enum PaymentType { PartialEq, Eq, strum::Display, - strum::EnumVariantNames, + strum::VariantNames, strum::EnumIter, strum::EnumString, serde::Serialize, @@ -109,7 +109,7 @@ pub enum MandateType { PartialEq, Eq, strum::Display, - strum::EnumVariantNames, + strum::VariantNames, strum::EnumIter, strum::EnumString, serde::Serialize, @@ -131,7 +131,7 @@ pub enum PayoutBankTransferType { PartialEq, Eq, strum::Display, - strum::EnumVariantNames, + strum::VariantNames, strum::EnumIter, strum::EnumString, serde::Serialize, @@ -151,7 +151,7 @@ pub enum PayoutWalletType { PartialEq, Eq, strum::Display, - strum::EnumVariantNames, + strum::VariantNames, strum::EnumIter, strum::EnumString, serde::Serialize, diff --git a/crates/euclid/src/frontend/dir.rs b/crates/euclid/src/frontend/dir.rs index 7fb12d96c3ec..e00d821a3105 100644 --- a/crates/euclid/src/frontend/dir.rs +++ b/crates/euclid/src/frontend/dir.rs @@ -113,7 +113,7 @@ impl DirKey { serde::Serialize, strum::Display, strum::EnumIter, - strum::EnumVariantNames, + strum::VariantNames, strum::EnumString, strum::EnumMessage, strum::EnumProperty, @@ -490,7 +490,7 @@ impl DirKeyKind { } #[derive( - Debug, Clone, Hash, PartialEq, Eq, serde::Serialize, strum::Display, strum::EnumVariantNames, + Debug, Clone, Hash, PartialEq, Eq, serde::Serialize, strum::Display, strum::VariantNames, )] #[serde(tag = "key", content = "value")] pub enum DirValue { @@ -677,7 +677,7 @@ impl DirValue { serde::Serialize, strum::Display, strum::EnumIter, - strum::EnumVariantNames, + strum::VariantNames, strum::EnumString, strum::EnumMessage, strum::EnumProperty, @@ -743,7 +743,7 @@ pub enum PayoutDirKeyKind { #[cfg(feature = "payouts")] #[derive( - Debug, Clone, Hash, PartialEq, Eq, serde::Serialize, strum::Display, strum::EnumVariantNames, + Debug, Clone, Hash, PartialEq, Eq, serde::Serialize, strum::Display, strum::VariantNames, )] pub enum PayoutDirValue { #[serde(rename = "business_country", alias = "country")] diff --git a/crates/euclid/src/frontend/dir/enums.rs b/crates/euclid/src/frontend/dir/enums.rs index ab33f16fb0ac..ee64c4ca3333 100644 --- a/crates/euclid/src/frontend/dir/enums.rs +++ b/crates/euclid/src/frontend/dir/enums.rs @@ -16,7 +16,7 @@ pub use crate::enums::{PayoutBankTransferType, PayoutType, PayoutWalletType}; PartialEq, Eq, strum::Display, - strum::EnumVariantNames, + strum::VariantNames, strum::EnumIter, strum::EnumString, serde::Serialize, @@ -36,7 +36,7 @@ pub enum CardType { PartialEq, Eq, strum::Display, - strum::EnumVariantNames, + strum::VariantNames, strum::EnumIter, strum::EnumString, serde::Serialize, @@ -61,7 +61,7 @@ pub enum PayLaterType { PartialEq, Eq, strum::Display, - strum::EnumVariantNames, + strum::VariantNames, strum::EnumIter, strum::EnumString, serde::Serialize, @@ -98,7 +98,7 @@ pub enum WalletType { PartialEq, Eq, strum::Display, - strum::EnumVariantNames, + strum::VariantNames, strum::EnumIter, strum::EnumString, serde::Serialize, @@ -130,7 +130,7 @@ pub enum VoucherType { PartialEq, Eq, strum::Display, - strum::EnumVariantNames, + strum::VariantNames, strum::EnumIter, strum::EnumString, serde::Serialize, @@ -164,7 +164,7 @@ pub enum BankRedirectType { PartialEq, Eq, strum::Display, - strum::EnumVariantNames, + strum::VariantNames, strum::EnumIter, strum::EnumString, serde::Serialize, @@ -195,7 +195,7 @@ pub enum BankTransferType { PartialEq, Eq, strum::Display, - strum::EnumVariantNames, + strum::VariantNames, strum::EnumIter, strum::EnumString, serde::Serialize, @@ -215,7 +215,7 @@ pub enum GiftCardType { PartialEq, Eq, strum::Display, - strum::EnumVariantNames, + strum::VariantNames, strum::EnumIter, strum::EnumString, serde::Serialize, @@ -237,7 +237,7 @@ pub enum CardRedirectType { PartialEq, Eq, strum::Display, - strum::EnumVariantNames, + strum::VariantNames, strum::EnumIter, strum::EnumString, serde::Serialize, @@ -256,7 +256,7 @@ pub enum CryptoType { PartialEq, Eq, strum::Display, - strum::EnumVariantNames, + strum::VariantNames, strum::EnumIter, strum::EnumString, serde::Serialize, @@ -275,7 +275,7 @@ pub enum UpiType { PartialEq, Eq, strum::Display, - strum::EnumVariantNames, + strum::VariantNames, strum::EnumIter, strum::EnumString, serde::Serialize, @@ -297,7 +297,7 @@ pub enum BankDebitType { PartialEq, Eq, strum::Display, - strum::EnumVariantNames, + strum::VariantNames, strum::EnumIter, strum::EnumString, serde::Serialize, diff --git a/crates/euclid/src/types.rs b/crates/euclid/src/types.rs index 59736ae65125..904525d54b73 100644 --- a/crates/euclid/src/types.rs +++ b/crates/euclid/src/types.rs @@ -23,7 +23,7 @@ pub type Metadata = std::collections::HashMap; PartialEq, Eq, strum::Display, - strum::EnumVariantNames, + strum::VariantNames, strum::EnumString, )] pub enum EuclidKey { diff --git a/crates/euclid_macros/Cargo.toml b/crates/euclid_macros/Cargo.toml index 2524887a8a0f..d3bd99bfbeed 100644 --- a/crates/euclid_macros/Cargo.toml +++ b/crates/euclid_macros/Cargo.toml @@ -4,13 +4,14 @@ description = "Macros for Euclid DSL" version = "0.1.0" edition.workspace = true rust-version.workspace = true +license.workspace = true [lib] proc-macro = true [dependencies] -proc-macro2 = "1.0.51" -quote = "1.0.23" +proc-macro2 = "1.0.79" +quote = "1.0.35" rustc-hash = "1.1.0" -strum = { version = "0.24", features = ["derive"] } -syn = "1.0.109" +strum = { version = "0.26", features = ["derive"] } +syn = "2.0.57" diff --git a/crates/euclid_wasm/Cargo.toml b/crates/euclid_wasm/Cargo.toml index d33ed2688a90..6f5d3ec9cc38 100644 --- a/crates/euclid_wasm/Cargo.toml +++ b/crates/euclid_wasm/Cargo.toml @@ -4,6 +4,7 @@ description = "WASM bindings for Euclid DSL" version = "0.1.0" edition.workspace = true rust-version.workspace = true +license.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [lib] @@ -24,15 +25,15 @@ payouts = ["api_models/payouts", "euclid/payouts"] api_models = { version = "0.1.0", path = "../api_models", package = "api_models" } currency_conversion = { version = "0.1.0", path = "../currency_conversion" } connector_configs = { version = "0.1.0", path = "../connector_configs" } -euclid = { path = "../euclid", features = [] } +euclid = { version = "0.1.0", path = "../euclid", features = [] } kgraph_utils = { version = "0.1.0", path = "../kgraph_utils" } common_enums = { version = "0.1.0", path = "../common_enums" } # Third party crates -getrandom = { version = "0.2.10", features = ["js"] } -once_cell = "1.18.0" +getrandom = { version = "0.2.12", features = ["js"] } +once_cell = "1.19.0" ron-parser = "0.1.4" serde = { version = "1.0", features = [] } -serde-wasm-bindgen = "0.5" -strum = { version = "0.25", features = ["derive"] } -wasm-bindgen = { version = "0.2.86" } +serde-wasm-bindgen = "0.6.5" +strum = { version = "0.26", features = ["derive"] } +wasm-bindgen = { version = "0.2.92" } diff --git a/crates/external_services/Cargo.toml b/crates/external_services/Cargo.toml index f19216f74d7d..31e22d4a6405 100644 --- a/crates/external_services/Cargo.toml +++ b/crates/external_services/Cargo.toml @@ -11,26 +11,26 @@ license.workspace = true aws_kms = ["dep:aws-config", "dep:aws-sdk-kms"] email = ["dep:aws-config"] aws_s3 = ["dep:aws-config", "dep:aws-sdk-s3"] -hashicorp-vault = [ "dep:vaultrs" ] +hashicorp-vault = ["dep:vaultrs"] [dependencies] -async-trait = "0.1.68" +async-trait = "0.1.79" aws-config = { version = "0.55.3", optional = true } aws-sdk-kms = { version = "0.28.0", optional = true } aws-sdk-sesv2 = "0.28.0" aws-sdk-sts = "0.28.0" aws-sdk-s3 = { version = "0.28.0", optional = true } aws-smithy-client = "0.55.3" -base64 = "0.21.2" -dyn-clone = "1.0.11" +base64 = "0.22.0" +dyn-clone = "1.0.17" error-stack = "0.4.1" -once_cell = "1.18.0" -serde = { version = "1.0.193", features = ["derive"] } -thiserror = "1.0.40" -tokio = "1.36.0" +once_cell = "1.19.0" +serde = { version = "1.0.197", features = ["derive"] } +thiserror = "1.0.58" +tokio = "1.37.0" hyper-proxy = "0.9.1" -hyper = "0.14.26" -vaultrs = { version = "0.7.0", optional = true } +hyper = "0.14.28" +vaultrs = { version = "0.7.2", optional = true } hex = "0.4.3" # First party crates diff --git a/crates/hyperswitch_interfaces/Cargo.toml b/crates/hyperswitch_interfaces/Cargo.toml index 855cf63917fc..034e0a67d92e 100644 --- a/crates/hyperswitch_interfaces/Cargo.toml +++ b/crates/hyperswitch_interfaces/Cargo.toml @@ -7,10 +7,10 @@ readme = "README.md" license.workspace = true [dependencies] -async-trait = "0.1.68" -dyn-clone = "1.0.11" -serde = { version = "1.0.193", features = ["derive"] } -thiserror = "1.0.40" +async-trait = "0.1.79" +dyn-clone = "1.0.17" +serde = { version = "1.0.197", features = ["derive"] } +thiserror = "1.0.58" # First party crates common_utils = { version = "0.1.0", path = "../common_utils" } diff --git a/crates/kgraph_utils/Cargo.toml b/crates/kgraph_utils/Cargo.toml index a07285167e4c..4ad5ef04f42c 100644 --- a/crates/kgraph_utils/Cargo.toml +++ b/crates/kgraph_utils/Cargo.toml @@ -4,6 +4,7 @@ description = "Utilities for constructing and working with Knowledge Graphs" version = "0.1.0" edition.workspace = true rust-version.workspace = true +license.workspace = true [features] dummy_connector = ["api_models/dummy_connector", "euclid/dummy_connector"] @@ -16,9 +17,9 @@ euclid = { version = "0.1.0", path = "../euclid" } masking = { version = "0.1.0", path = "../masking/" } # Third party crates -serde = "1.0.193" -serde_json = "1.0.108" -thiserror = "1.0.43" +serde = "1.0.197" +serde_json = "1.0.115" +thiserror = "1.0.58" [dev-dependencies] criterion = "0.5" diff --git a/crates/masking/Cargo.toml b/crates/masking/Cargo.toml index 23f207d63d59..e7f3550ed7e1 100644 --- a/crates/masking/Cargo.toml +++ b/crates/masking/Cargo.toml @@ -18,12 +18,12 @@ rustdoc-args = ["--cfg", "docsrs"] [dependencies] bytes = { version = "1", optional = true } -diesel = { version = "2.1.0", features = ["postgres", "serde_json", "time"], optional = true } -erased-serde = "0.3.31" +diesel = { version = "2.1.5", features = ["postgres", "serde_json", "time"], optional = true } +erased-serde = "0.4.4" serde = { version = "1", features = ["derive"], optional = true } -serde_json = { version = "1.0.108", optional = true } -subtle = "=2.4.1" -zeroize = { version = "1.6", default-features = false } +serde_json = { version = "1.0.115", optional = true } +subtle = "2.5.0" +zeroize = { version = "1.7", default-features = false } [dev-dependencies] -serde_json = "1.0.108" +serde_json = "1.0.115" diff --git a/crates/openapi/Cargo.toml b/crates/openapi/Cargo.toml index 330f5ed890f8..8cf8c156ba0c 100644 --- a/crates/openapi/Cargo.toml +++ b/crates/openapi/Cargo.toml @@ -8,7 +8,7 @@ license.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -serde_json = "1.0.96" -utoipa = { version = "3.5.0", features = ["preserve_order", "preserve_path_order", "time"] } +serde_json = "1.0.115" +utoipa = { version = "4.2.0", features = ["preserve_order", "preserve_path_order", "time"] } api_models = { version = "0.1.0", path = "../api_models", features = ["frm", "payouts", "openapi"] } diff --git a/crates/pm_auth/Cargo.toml b/crates/pm_auth/Cargo.toml index ef21539d4fa2..bb56db6f232b 100644 --- a/crates/pm_auth/Cargo.toml +++ b/crates/pm_auth/Cargo.toml @@ -5,6 +5,7 @@ version = "0.1.0" edition.workspace = true rust-version.workspace = true readme = "README.md" +license.workspace = true [dependencies] # First party crates @@ -16,12 +17,12 @@ router_derive = { version = "0.1.0", path = "../router_derive" } router_env = { version = "0.1.0", path = "../router_env", features = ["log_extra_implicit_fields", "log_custom_entries_to_extra"] } # Third party crates -async-trait = "0.1.66" -bytes = "1.4.0" +async-trait = "0.1.79" +bytes = "1.6.0" error-stack = "0.4.1" -http = "0.2.9" +http = "0.2.12" mime = "0.3.17" -serde = "1.0.193" -serde_json = "1.0.108" -strum = { version = "0.24.1", features = ["derive"] } -thiserror = "1.0.43" +serde = "1.0.197" +serde_json = "1.0.115" +strum = { version = "0.26.2", features = ["derive"] } +thiserror = "1.0.58" diff --git a/crates/redis_interface/Cargo.toml b/crates/redis_interface/Cargo.toml index 233781b52e43..1fb74be79d9b 100644 --- a/crates/redis_interface/Cargo.toml +++ b/crates/redis_interface/Cargo.toml @@ -11,14 +11,14 @@ license.workspace = true error-stack = "0.4.1" fred = { version = "7.1.2", features = ["metrics", "partial-tracing", "subscriber-client", "check-unresponsive"] } futures = "0.3" -serde = { version = "1.0.193", features = ["derive"] } -thiserror = "1.0.40" -tokio = "1.36.0" -tokio-stream = {version = "0.1.14", features = ["sync"]} +serde = { version = "1.0.197", features = ["derive"] } +thiserror = "1.0.58" +tokio = "1.37.0" +tokio-stream = {version = "0.1.15", features = ["sync"]} # First party crates common_utils = { version = "0.1.0", path = "../common_utils", features = ["async_ext"] } router_env = { version = "0.1.0", path = "../router_env", features = ["log_extra_implicit_fields", "log_custom_entries_to_extra"] } [dev-dependencies] -tokio = { version = "1.36.0", features = ["macros", "rt-multi-thread"] } +tokio = { version = "1.37.0", features = ["macros", "rt-multi-thread"] } diff --git a/crates/router/Cargo.toml b/crates/router/Cargo.toml index 288e2001876c..002e22ec4d82 100644 --- a/crates/router/Cargo.toml +++ b/crates/router/Cargo.toml @@ -26,80 +26,75 @@ dummy_connector = ["api_models/dummy_connector", "euclid/dummy_connector", "kgra connector_choice_mca_id = ["api_models/connector_choice_mca_id", "euclid/connector_choice_mca_id", "kgraph_utils/connector_choice_mca_id"] external_access_dc = ["dummy_connector"] detailed_errors = ["api_models/detailed_errors", "error-stack/serde"] -payouts = [ - "api_models/payouts", - "common_enums/payouts", - "data_models/payouts", - "storage_impl/payouts" -] +payouts = ["api_models/payouts", "common_enums/payouts", "data_models/payouts", "storage_impl/payouts"] payout_retry = ["payouts"] recon = ["email", "api_models/recon"] retry = [] [dependencies] -actix-cors = "0.6.4" -actix-multipart = "0.6.0" -actix-rt = "2.8.0" -actix-web = "4.3.1" +actix-cors = "0.6.5" +actix-multipart = "0.6.1" +actix-rt = "2.9.0" +actix-web = "4.5.1" async-bb8-diesel = { git = "https://github.com/jarnura/async-bb8-diesel", rev = "53b4ab901aab7635c8215fd1c2d542c8db443094" } -argon2 = { version = "0.5.0", features = ["std"] } -async-trait = "0.1.68" -base64 = "0.21.2" +argon2 = { version = "0.5.3", features = ["std"] } +async-trait = "0.1.79" +base64 = "0.22.0" bb8 = "0.8" bigdecimal = "0.3.1" -blake3 = "1.3.3" -bytes = "1.4.0" -clap = { version = "4.3.2", default-features = false, features = ["std", "derive", "help", "usage"] } -config = { version = "0.13.3", features = ["toml"] } -cookie = "0.18.0" -diesel = { version = "2.1.0", features = ["postgres"] } -digest = "0.9" -dyn-clone = "1.0.11" -encoding_rs = "0.8.32" +blake3 = "1.5.1" +bytes = "1.6.0" +clap = { version = "4.4.18", default-features = false, features = ["std", "derive", "help", "usage"] } +config = { version = "0.14.0", features = ["toml"] } +cookie = "0.18.1" +diesel = { version = "2.1.5", features = ["postgres"] } +digest = "0.10.7" +dyn-clone = "1.0.17" +encoding_rs = "0.8.33" error-stack = "0.4.1" -futures = "0.3.28" +futures = "0.3.30" hex = "0.4.3" -http = "0.2.9" -hyper = "0.14.27" -image = "0.23.14" -infer = "0.13.0" -josekit = "0.8.3" -jsonwebtoken = "8.3.0" -maud = { version = "0.25", features = ["actix-web"] } +http = "0.2.12" +hyper = "0.14.28" +image = { version = "0.25.1", default-features = false, features = ["png"] } +infer = "0.15.0" +josekit = "0.8.6" +jsonwebtoken = "9.2.0" +maud = { version = "0.26.0", features = ["actix-web"] } mimalloc = { version = "0.1", optional = true } mime = "0.3.17" nanoid = "0.4.0" -num_cpus = "1.15.0" -once_cell = "1.18.0" -openssl = "0.10.60" -qrcode = "0.12.0" +num_cpus = "1.16.0" +once_cell = "1.19.0" +openssl = "0.10.64" +qrcode = "0.14.0" rand = "0.8.5" rand_chacha = "0.3.1" -regex = "1.8.4" -reqwest = { version = "0.11.18", features = ["json", "native-tls", "gzip", "multipart"] } -ring = "0.16.20" -roxmltree = "0.18.0" -rust_decimal = { version = "1.30.0", features = ["serde-with-float", "serde-with-str"] } +regex = "1.10.4" +reqwest = { version = "0.11.27", features = ["json", "native-tls", "gzip", "multipart"] } +ring = "0.17.8" +roxmltree = "0.19.0" +rust_decimal = { version = "1.35.0", features = ["serde-with-float", "serde-with-str"] } rustc-hash = "1.1.0" -serde = { version = "1.0.193", features = ["derive"] } -serde_json = "1.0.108" -serde_path_to_error = "0.1.14" +serde = { version = "1.0.197", features = ["derive"] } +serde_json = "1.0.115" +serde_path_to_error = "0.1.16" serde_qs = { version = "0.12.0", optional = true } serde_urlencoded = "0.7.1" -serde_with = "3.4.0" -sha-1 = { version = "0.9" } -sqlx = { version = "0.6.3", features = ["postgres", "runtime-actix", "runtime-actix-native-tls", "time", "bigdecimal"] } -strum = { version = "0.25", features = ["derive"] } +serde_with = "3.7.0" +sha1 = { version = "0.10.6" } +sqlx = { version = "0.7.3", features = ["postgres", "runtime-tokio", "runtime-tokio-native-tls", "time", "bigdecimal"] } +strum = { version = "0.26", features = ["derive"] } tera = "1.19.1" -thiserror = "1.0.40" -time = { version = "0.3.21", features = ["serde", "serde-well-known", "std"] } -tokio = { version = "1.36.0", features = ["macros", "rt-multi-thread"] } -unicode-segmentation = "1.10.1" -url = { version = "2.4.0", features = ["serde"] } -utoipa = { version = "3.5.0", features = ["preserve_order", "preserve_path_order", "time"] } -uuid = { version = "1.7.0", features = ["v4"] } -validator = "0.16.0" -x509-parser = "0.15.0" +thiserror = "1.0.58" +time = { version = "0.3.34", features = ["serde", "serde-well-known", "std"] } +tokio = { version = "1.37.0", features = ["macros", "rt-multi-thread"] } +unicode-segmentation = "1.11.0" +url = { version = "2.5.0", features = ["serde"] } +utoipa = { version = "4.2.0", features = ["preserve_order", "preserve_path_order", "time"] } +uuid = { version = "1.8.0", features = ["v4"] } +validator = "0.17.0" +x509-parser = "0.16.0" tracing-futures = { version = "0.2.5", features = ["tokio"] } # First party crates @@ -123,25 +118,25 @@ router_env = { version = "0.1.0", path = "../router_env", features = ["log_extra scheduler = { version = "0.1.0", path = "../scheduler", default-features = false } storage_impl = { version = "0.1.0", path = "../storage_impl", default-features = false } openapi = { version = "0.1.0", path = "../openapi", optional = true } -erased-serde = "0.3.31" +erased-serde = "0.4.4" quick-xml = { version = "0.31.0", features = ["serialize"] } -rdkafka = "0.36.0" +rdkafka = "0.36.2" isocountry = "0.3.2" iso_currency = "0.4.4" -actix-http = "3.3.1" +actix-http = "3.6.0" [build-dependencies] router_env = { version = "0.1.0", path = "../router_env", default-features = false } [dev-dependencies] -actix-http = "3.3.1" -awc = { version = "3.1.1", features = ["rustls"] } +actix-http = "3.6.0" +awc = { version = "3.4.0", features = ["rustls"] } derive_deref = "1.1.1" rand = "0.8.5" -serial_test = "2.0.0" -time = { version = "0.3.21", features = ["macros"] } -tokio = "1.36.0" -wiremock = "0.5.18" +serial_test = "3.0.0" +time = { version = "0.3.34", features = ["macros"] } +tokio = "1.37.0" +wiremock = "0.6.0" # First party dev-dependencies diff --git a/crates/router/src/types/domain/user.rs b/crates/router/src/types/domain/user.rs index 4625a72f5dd6..93df373d21a5 100644 --- a/crates/router/src/types/domain/user.rs +++ b/crates/router/src/types/domain/user.rs @@ -85,11 +85,13 @@ static BLOCKED_EMAIL: Lazy> = Lazy::new(|| { impl UserEmail { pub fn new(email: Secret) -> UserResult { + use validator::ValidateEmail; + let email_string = email.expose(); let email = pii::Email::from_str(&email_string).change_context(UserErrors::EmailParsingError)?; - if validator::validate_email(&email_string) { + if email_string.validate_email() { let (_username, domain) = match email_string.as_str().split_once('@') { Some((u, d)) => (u, d), None => return Err(UserErrors::EmailParsingError.into()), @@ -105,8 +107,10 @@ impl UserEmail { } pub fn from_pii_email(email: pii::Email) -> UserResult { + use validator::ValidateEmail; + let email_string = email.peek(); - if validator::validate_email(email_string) { + if email_string.validate_email() { let (_username, domain) = match email_string.split_once('@') { Some((u, d)) => (u, d), None => return Err(UserErrors::EmailParsingError.into()), diff --git a/crates/router/src/utils.rs b/crates/router/src/utils.rs index 56f68e33d3b0..1a3eb92d2407 100644 --- a/crates/router/src/utils.rs +++ b/crates/router/src/utils.rs @@ -176,15 +176,15 @@ impl QrImage { let qrcode_image_buffer = qr_code.render::>().build(); let qrcode_dynamic_image = image::DynamicImage::ImageLuma8(qrcode_image_buffer); - let mut image_bytes = Vec::new(); + let mut image_bytes = std::io::BufWriter::new(std::io::Cursor::new(Vec::new())); // Encodes qrcode_dynamic_image and write it to image_bytes - let _ = qrcode_dynamic_image.write_to(&mut image_bytes, image::ImageOutputFormat::Png); + let _ = qrcode_dynamic_image.write_to(&mut image_bytes, image::ImageFormat::Png); let image_data_source = format!( "{},{}", consts::QR_IMAGE_DATA_SOURCE_STRING, - consts::BASE64_ENGINE.encode(image_bytes) + consts::BASE64_ENGINE.encode(image_bytes.get_ref().get_ref()) ); Ok(Self { data: image_data_source, diff --git a/crates/router_derive/Cargo.toml b/crates/router_derive/Cargo.toml index 07e95b9232c3..793784079462 100644 --- a/crates/router_derive/Cargo.toml +++ b/crates/router_derive/Cargo.toml @@ -12,14 +12,13 @@ proc-macro = true doctest = false [dependencies] -indexmap = "2.1.0" -proc-macro2 = "1.0.56" -quote = "1.0.26" -syn = { version = "2.0.5", features = ["full", "extra-traits"] } # the full feature does not seem to encompass all the features -strum = { version = "0.24.1", features = ["derive"] } +indexmap = "2.2.6" +proc-macro2 = "1.0.79" +quote = "1.0.35" +syn = { version = "2.0.57", features = ["full", "extra-traits"] } # the full feature does not seem to encompass all the features +strum = { version = "0.26.2", features = ["derive"] } [dev-dependencies] -diesel = { version = "2.1.0", features = ["postgres"] } -serde = { version = "1.0.193", features = ["derive"] } -serde_json = "1.0.108" - +diesel = { version = "2.1.5", features = ["postgres"] } +serde = { version = "1.0.197", features = ["derive"] } +serde_json = "1.0.115" diff --git a/crates/router_env/Cargo.toml b/crates/router_env/Cargo.toml index c161d02b8d21..72f0f0b39ac4 100644 --- a/crates/router_env/Cargo.toml +++ b/crates/router_env/Cargo.toml @@ -9,33 +9,33 @@ license.workspace = true [dependencies] cargo_metadata = "0.18.1" -config = { version = "0.13.3", features = ["toml"] } +config = { version = "0.14.0", features = ["toml"] } error-stack = "0.4.1" gethostname = "0.4.3" -once_cell = "1.18.0" +once_cell = "1.19.0" opentelemetry = { version = "0.19.0", features = ["rt-tokio-current-thread", "metrics"] } opentelemetry-otlp = { version = "0.12.0", features = ["metrics"] } rustc-hash = "1.1" -serde = { version = "1.0.193", features = ["derive"] } -serde_json = "1.0.108" -serde_path_to_error = "0.1.14" -strum = { version = "0.24.1", features = ["derive"] } -time = { version = "0.3.21", default-features = false, features = ["formatting"] } -tokio = { version = "1.36.0" } -tracing = { version = "0.1.37" } +serde = { version = "1.0.197", features = ["derive"] } +serde_json = "1.0.115" +serde_path_to_error = "0.1.16" +strum = { version = "0.26.2", features = ["derive"] } +time = { version = "0.3.34", default-features = false, features = ["formatting"] } +tokio = { version = "1.37.0" } +tracing = { version = "0.1.40" } tracing-actix-web = { version = "0.7.10", features = ["opentelemetry_0_19", "uuid_v7"], optional = true } -tracing-appender = { version = "0.2.2" } +tracing-appender = { version = "0.2.3" } tracing-attributes = "0.1.27" tracing-opentelemetry = { version = "0.19.0" } -tracing-subscriber = { version = "0.3.17", default-features = true, features = ["env-filter", "json", "registry"] } -vergen = { version = "8.2.1", optional = true, features = ["cargo", "git", "git2", "rustc"] } +tracing-subscriber = { version = "0.3.18", default-features = true, features = ["env-filter", "json", "registry"] } +vergen = { version = "8.3.1", optional = true, features = ["cargo", "git", "git2", "rustc"] } [dev-dependencies] -tokio = { version = "1.36.0", features = ["macros", "rt-multi-thread"] } +tokio = { version = "1.37.0", features = ["macros", "rt-multi-thread"] } [build-dependencies] cargo_metadata = "0.18.1" -vergen = { version = "8.2.1", features = ["cargo", "git", "git2", "rustc"], optional = true } +vergen = { version = "8.3.1", features = ["cargo", "git", "git2", "rustc"], optional = true } [features] default = ["actix_web", "payouts"] diff --git a/crates/scheduler/Cargo.toml b/crates/scheduler/Cargo.toml index 4f2a423709fb..f713b8f2f2b0 100644 --- a/crates/scheduler/Cargo.toml +++ b/crates/scheduler/Cargo.toml @@ -1,7 +1,9 @@ [package] name = "scheduler" version = "0.1.0" -edition = "2021" +edition.workspace = true +rust-version.workspace = true +license.workspace = true [features] default = ["kv_store", "olap"] @@ -11,19 +13,19 @@ email = ["external_services/email"] [dependencies] # Third party crates -async-trait = "0.1.68" +async-trait = "0.1.79" error-stack = "0.4.1" -futures = "0.3.28" -num_cpus = "1.15.0" -once_cell = "1.18.0" +futures = "0.3.30" +num_cpus = "1.16.0" +once_cell = "1.19.0" rand = "0.8.5" -serde = "1.0.193" -serde_json = "1.0.108" -strum = { version = "0.24.1", features = ["derive"] } -thiserror = "1.0.40" -time = { version = "0.3.21", features = ["serde", "serde-well-known", "std"] } -tokio = { version = "1.36.0", features = ["macros", "rt-multi-thread"] } -uuid = { version = "1.7.0", features = ["v4"] } +serde = "1.0.197" +serde_json = "1.0.115" +strum = { version = "0.26.2", features = ["derive"] } +thiserror = "1.0.58" +time = { version = "0.3.34", features = ["serde", "serde-well-known", "std"] } +tokio = { version = "1.37.0", features = ["macros", "rt-multi-thread"] } +uuid = { version = "1.8.0", features = ["v4"] } # First party crates common_utils = { version = "0.1.0", path = "../common_utils", features = ["signals", "async_ext"] } diff --git a/crates/storage_impl/Cargo.toml b/crates/storage_impl/Cargo.toml index d7107cdccfa3..5421e301f6af 100644 --- a/crates/storage_impl/Cargo.toml +++ b/crates/storage_impl/Cargo.toml @@ -26,23 +26,22 @@ router_derive = { version = "0.1.0", path = "../router_derive" } router_env = { version = "0.1.0", path = "../router_env" } # Third party crates -actix-web = "4.3.1" +actix-web = "4.5.1" async-bb8-diesel = { git = "https://github.com/jarnura/async-bb8-diesel", rev = "53b4ab901aab7635c8215fd1c2d542c8db443094" } -async-trait = "0.1.72" -bb8 = "0.8.1" -bytes = "1.4.0" -config = { version = "0.13.3", features = ["toml"] } -crc32fast = "1.3.2" -diesel = { version = "2.1.0", default-features = false, features = ["postgres"] } -dyn-clone = "1.0.12" +async-trait = "0.1.79" +bb8 = "0.8.3" +bytes = "1.6.0" +config = { version = "0.14.0", features = ["toml"] } +crc32fast = "1.4.0" +diesel = { version = "2.1.5", default-features = false, features = ["postgres"] } +dyn-clone = "1.0.17" error-stack = "0.4.1" -futures = "0.3.28" -http = "0.2.9" +futures = "0.3.30" +http = "0.2.12" mime = "0.3.17" moka = { version = "0.12", features = ["future"] } -once_cell = "1.18.0" -ring = "0.16.20" -serde = { version = "1.0.193", features = ["derive"] } -serde_json = "1.0.108" -thiserror = "1.0.40" -tokio = { version = "1.36.0", features = ["rt-multi-thread"] } +once_cell = "1.19.0" +serde = { version = "1.0.197", features = ["derive"] } +serde_json = "1.0.115" +thiserror = "1.0.58" +tokio = { version = "1.37.0", features = ["rt-multi-thread"] } diff --git a/crates/storage_impl/src/errors.rs b/crates/storage_impl/src/errors.rs index 7002d0946f7e..4c5f84f5b734 100644 --- a/crates/storage_impl/src/errors.rs +++ b/crates/storage_impl/src/errors.rs @@ -12,30 +12,6 @@ use crate::{errors as storage_errors, store::errors::DatabaseError}; pub type ApplicationResult = Result; -macro_rules! impl_error_display { - ($st: ident, $arg: tt) => { - impl Display for $st { - fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!( - fmt, - "{{ error_type: {:?}, error_description: {} }}", - self, $arg - ) - } - } - }; -} -macro_rules! impl_error_type { - ($name: ident, $arg: tt) => { - #[derive(Debug)] - pub struct $name; - - impl_error_display!($name, $arg); - - impl std::error::Error for $name {} - }; -} - #[derive(Debug, thiserror::Error)] pub enum StorageError { #[error("DatabaseError: {0:?}")] @@ -176,8 +152,6 @@ impl RedisErrorExt for error_stack::Report { } } -impl_error_type!(EncryptionError, "Encryption error"); - #[derive(Debug, thiserror::Error)] pub enum ApplicationError { // Display's impl can be overridden by the attribute error marco. @@ -210,12 +184,6 @@ impl From for ApplicationError { } } -impl From for EncryptionError { - fn from(_: ring::error::Unspecified) -> Self { - Self - } -} - impl From for ApplicationError { fn from(err: ConfigError) -> Self { Self::ConfigurationError(err) diff --git a/crates/test_utils/Cargo.toml b/crates/test_utils/Cargo.toml index 59ff36e6cc5c..714e34f0e959 100644 --- a/crates/test_utils/Cargo.toml +++ b/crates/test_utils/Cargo.toml @@ -13,20 +13,20 @@ dummy_connector = [] payouts = [] [dependencies] -async-trait = "0.1.68" -base64 = "0.21.2" -clap = { version = "4.3.2", default-features = false, features = ["std", "derive", "help", "usage"] } +async-trait = "0.1.79" +base64 = "0.22.0" +clap = { version = "4.4.18", default-features = false, features = ["std", "derive", "help", "usage"] } rand = "0.8.5" -regex = "1.10.3" -reqwest = { version = "0.11.18", features = ["native-tls"] } -serde = { version = "1.0.193", features = ["derive"] } -serde_json = "1.0.108" +regex = "1.10.4" +reqwest = { version = "0.11.27", features = ["native-tls"] } +serde = { version = "1.0.197", features = ["derive"] } +serde_json = "1.0.115" serde_urlencoded = "0.7.1" -serial_test = "2.0.0" +serial_test = "3.0.0" thirtyfour = "0.31.0" -time = { version = "0.3.21", features = ["macros"] } -tokio = "1.36.0" -toml = "0.7.4" +time = { version = "0.3.34", features = ["macros"] } +tokio = "1.37.0" +toml = "0.8.12" # First party crates masking = { version = "0.1.0", path = "../masking" } diff --git a/crates/test_utils/tests/connectors/adyen_uk_wh_ui.rs b/crates/test_utils/tests/connectors/adyen_uk_wh_ui.rs index 9da7f71324fa..4235d0ff17d4 100644 --- a/crates/test_utils/tests/connectors/adyen_uk_wh_ui.rs +++ b/crates/test_utils/tests/connectors/adyen_uk_wh_ui.rs @@ -1,4 +1,3 @@ -use serial_test::serial; use thirtyfour::{prelude::*, WebDriver}; use crate::{selenium::*, tester}; @@ -28,7 +27,6 @@ async fn should_make_webhook(web_driver: WebDriver) -> Result<(), WebDriverError } #[test] -#[serial] fn should_make_webhook_test() { tester!(should_make_webhook); } diff --git a/crates/test_utils/tests/connectors/authorizedotnet_wh_ui.rs b/crates/test_utils/tests/connectors/authorizedotnet_wh_ui.rs index b0cf50702c92..b17fd80b0a13 100644 --- a/crates/test_utils/tests/connectors/authorizedotnet_wh_ui.rs +++ b/crates/test_utils/tests/connectors/authorizedotnet_wh_ui.rs @@ -1,5 +1,4 @@ use rand::Rng; -use serial_test::serial; use thirtyfour::{prelude::*, WebDriver}; use crate::{selenium::*, tester}; @@ -31,7 +30,6 @@ async fn should_make_webhook(web_driver: WebDriver) -> Result<(), WebDriverError } #[test] -#[serial] fn should_make_webhook_test() { tester!(should_make_webhook); } diff --git a/crates/test_utils/tests/connectors/bluesnap_wh_ui.rs b/crates/test_utils/tests/connectors/bluesnap_wh_ui.rs index 1d3271239440..abaf3d53f50e 100644 --- a/crates/test_utils/tests/connectors/bluesnap_wh_ui.rs +++ b/crates/test_utils/tests/connectors/bluesnap_wh_ui.rs @@ -1,4 +1,3 @@ -use serial_test::serial; use thirtyfour::{prelude::*, WebDriver}; use crate::{selenium::*, tester}; @@ -28,7 +27,6 @@ async fn should_make_webhook(web_driver: WebDriver) -> Result<(), WebDriverError } #[test] -#[serial] fn should_make_webhook_test() { tester!(should_make_webhook); } diff --git a/crates/test_utils/tests/connectors/checkout_wh_ui.rs b/crates/test_utils/tests/connectors/checkout_wh_ui.rs index 1692db060728..f9d459765c77 100644 --- a/crates/test_utils/tests/connectors/checkout_wh_ui.rs +++ b/crates/test_utils/tests/connectors/checkout_wh_ui.rs @@ -1,4 +1,3 @@ -use serial_test::serial; use thirtyfour::{prelude::*, WebDriver}; use crate::{selenium::*, tester}; @@ -33,7 +32,6 @@ async fn should_make_webhook(web_driver: WebDriver) -> Result<(), WebDriverError } #[test] -#[serial] fn should_make_webhook_test() { tester!(should_make_webhook); } diff --git a/crates/test_utils/tests/connectors/stripe_wh_ui.rs b/crates/test_utils/tests/connectors/stripe_wh_ui.rs index d5f1e3717e2a..31f8e794a468 100644 --- a/crates/test_utils/tests/connectors/stripe_wh_ui.rs +++ b/crates/test_utils/tests/connectors/stripe_wh_ui.rs @@ -1,4 +1,3 @@ -use serial_test::serial; use thirtyfour::{prelude::*, WebDriver}; use crate::{selenium::*, tester}; @@ -29,8 +28,6 @@ async fn should_make_webhook(web_driver: WebDriver) -> Result<(), WebDriverError } #[test] -#[serial] - fn should_make_webhook_test() { tester!(should_make_webhook); } diff --git a/docker/wasm-build.Dockerfile b/docker/wasm-build.Dockerfile index 2ebdcec217ef..bddcacdfc64d 100644 --- a/docker/wasm-build.Dockerfile +++ b/docker/wasm-build.Dockerfile @@ -4,7 +4,7 @@ ARG RUN_ENV=sandbox ARG EXTRA_FEATURES="" RUN apt-get update \ - && apt-get install -y libssl-dev pkg-config + && apt-get install -y clang libssl-dev pkg-config ENV CARGO_INCREMENTAL=0 # Allow more retries for network requests in cargo (downloading crates) and diff --git a/openapi/openapi_spec.json b/openapi/openapi_spec.json index 595b18307220..ad360ab7dd7d 100644 --- a/openapi/openapi_spec.json +++ b/openapi/openapi_spec.json @@ -4709,7 +4709,8 @@ "type": "string", "nullable": true } - } + }, + "additionalProperties": false }, "AddressDetails": { "type": "object", @@ -4778,7 +4779,8 @@ "nullable": true, "maxLength": 255 } - } + }, + "additionalProperties": false }, "AirwallexData": { "type": "object", @@ -6560,7 +6562,8 @@ ], "nullable": true } - } + }, + "additionalProperties": false }, "BusinessProfileResponse": { "type": "object", @@ -6856,7 +6859,8 @@ "description": "Card Type", "nullable": true } - } + }, + "additionalProperties": false }, "CardDetailFromLocker": { "type": "object", @@ -7513,7 +7517,8 @@ "expiration": { "$ref": "#/components/schemas/ApiKeyExpiration" } - } + }, + "additionalProperties": false }, "CreateApiKeyResponse": { "type": "object", @@ -7752,7 +7757,8 @@ ], "nullable": true } - } + }, + "additionalProperties": false }, "CustomerDefaultPaymentMethodResponse": { "type": "object", @@ -8841,7 +8847,8 @@ }, "description": "payment methods that can be used in the payment" } - } + }, + "additionalProperties": false }, "FrmMessage": { "type": "object", @@ -8897,7 +8904,8 @@ }, "description": "payment method types(credit, debit) that can be used in the payment" } - } + }, + "additionalProperties": false }, "FrmPaymentMethodType": { "type": "object", @@ -8921,7 +8929,8 @@ "action": { "$ref": "#/components/schemas/FrmAction" } - } + }, + "additionalProperties": false }, "FrmPreferredFlowTypes": { "type": "string", @@ -9862,7 +9871,8 @@ ], "nullable": true } - } + }, + "additionalProperties": false }, "MandateResponse": { "type": "object", @@ -10120,7 +10130,8 @@ "description": "The id of the organization to which the merchant belongs to", "nullable": true } - } + }, + "additionalProperties": false }, "MerchantAccountDeleteResponse": { "type": "object", @@ -10405,7 +10416,8 @@ "nullable": true, "maxLength": 64 } - } + }, + "additionalProperties": false }, "MerchantConnectorCreate": { "type": "object", @@ -10556,7 +10568,8 @@ ], "nullable": true } - } + }, + "additionalProperties": false }, "MerchantConnectorDeleteResponse": { "type": "object", @@ -10789,7 +10802,8 @@ "status": { "$ref": "#/components/schemas/ConnectorStatus" } - } + }, + "additionalProperties": false }, "MerchantConnectorUpdate": { "type": "object", @@ -10902,7 +10916,8 @@ "status": { "$ref": "#/components/schemas/ConnectorStatus" } - } + }, + "additionalProperties": false }, "MerchantConnectorWebhookDetails": { "type": "object", @@ -10919,7 +10934,8 @@ "type": "string", "example": "12345678900987654321" } - } + }, + "additionalProperties": false }, "MerchantDetails": { "type": "object", @@ -10988,7 +11004,8 @@ ], "nullable": true } - } + }, + "additionalProperties": false }, "MerchantRoutingAlgorithm": { "type": "object", @@ -11370,7 +11387,8 @@ "type": "string", "description": "The user-agent of the customer's browser" } - } + }, + "additionalProperties": false }, "OrderDetails": { "type": "object", @@ -12203,7 +12221,8 @@ "example": "2022-09-10T10:11:12Z", "nullable": true } - } + }, + "additionalProperties": false }, "PaymentListResponse": { "type": "object", @@ -12315,7 +12334,8 @@ ], "nullable": true } - } + }, + "additionalProperties": false }, "PaymentMethodData": { "oneOf": [ @@ -12842,7 +12862,8 @@ "description": "You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.", "nullable": true } - } + }, + "additionalProperties": false }, "PaymentMethodsEnabled": { "type": "object", @@ -12865,7 +12886,8 @@ ], "nullable": true } - } + }, + "additionalProperties": false }, "PaymentRetrieveBody": { "type": "object", @@ -14246,7 +14268,8 @@ ], "nullable": true } - } + }, + "additionalProperties": false }, "PaymentsResponse": { "type": "object", @@ -15542,7 +15565,8 @@ "description": "The business profile to use for this payment, if not passed the default business profile\nassociated with the merchant account will be used.", "nullable": true } - } + }, + "additionalProperties": false }, "PayoutCreateResponse": { "type": "object", @@ -15711,7 +15735,8 @@ "description": "List of attempts", "nullable": true } - } + }, + "additionalProperties": false }, "PayoutEntityType": { "type": "string", @@ -16084,7 +16109,8 @@ "type": "string", "example": "food" } - } + }, + "additionalProperties": false }, "ProductType": { "type": "string", @@ -16386,7 +16412,8 @@ ], "nullable": true } - } + }, + "additionalProperties": false }, "RefundResponse": { "type": "object", @@ -16501,7 +16528,8 @@ "description": "You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.", "nullable": true } - } + }, + "additionalProperties": false }, "RequestPaymentMethodTypes": { "type": "object", @@ -17760,7 +17788,8 @@ ], "nullable": true } - } + }, + "additionalProperties": false }, "UpiData": { "type": "object", @@ -18429,7 +18458,8 @@ "example": true, "nullable": true } - } + }, + "additionalProperties": false } }, "securitySchemes": { From a071463b29f9794e7069d57057d3bcc3a238f89b Mon Sep 17 00:00:00 2001 From: Sakil Mostak <73734619+Sakilmostak@users.noreply.github.com> Date: Tue, 2 Apr 2024 15:53:57 +0530 Subject: [PATCH 15/19] refactor(postman): Paypal test cases for Capture (#4265) --- .../Payments - Capture/event.test.js | 4 +-- .../Payments - Retrieve/event.test.js | 4 +-- .../Payments - Capture/event.test.js | 4 +-- .../Payments - Retrieve/event.test.js | 4 +-- .../Payments - Capture/event.test.js | 4 +-- .../Payments - Retrieve/event.test.js | 4 +-- .../Payments - Capture/event.test.js | 4 +-- .../Payments - Retrieve/event.test.js | 4 +-- .../paypal.postman_collection.json | 32 +++++++++---------- 9 files changed, 32 insertions(+), 32 deletions(-) diff --git a/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario11-Create Partial Capture payment/Payments - Capture/event.test.js b/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario11-Create Partial Capture payment/Payments - Capture/event.test.js index d08e91cd6e8c..1fbef271836a 100644 --- a/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario11-Create Partial Capture payment/Payments - Capture/event.test.js +++ b/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario11-Create Partial Capture payment/Payments - Capture/event.test.js @@ -101,9 +101,9 @@ if (jsonData?.amount_received) { // Response body should have value "6540" for "amount_capturable" if (jsonData?.amount_capturable) { pm.test( - "[post]:://payments/:id/capture - Content check if value for 'amount_capturable' matches 'amount - 540'", + "[post]:://payments/:id/capture - Content check if value for 'amount_capturable' matches 6540", function () { - pm.expect(jsonData.amount_capturable).to.eql(540); + pm.expect(jsonData.amount_capturable).to.eql(6540); }, ); } diff --git a/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario11-Create Partial Capture payment/Payments - Retrieve/event.test.js b/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario11-Create Partial Capture payment/Payments - Retrieve/event.test.js index 8e84e4b38465..06abc1d37a5c 100644 --- a/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario11-Create Partial Capture payment/Payments - Retrieve/event.test.js +++ b/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario11-Create Partial Capture payment/Payments - Retrieve/event.test.js @@ -98,9 +98,9 @@ if (jsonData?.amount_received) { // Response body should have value "6540" for "amount_capturable" if (jsonData?.amount_capturable) { pm.test( - "[post]:://payments/:id/capture - Content check if value for 'amount_capturable' matches 'amount - 540'", + "[post]:://payments/:id/capture - Content check if value for 'amount_capturable' matches 'amount - 6540'", function () { - pm.expect(jsonData.amount_capturable).to.eql(540); + pm.expect(jsonData.amount_capturable).to.eql(6540); }, ); } diff --git a/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario4-Create payment with Manual capture with confirm false/Payments - Capture/event.test.js b/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario4-Create payment with Manual capture with confirm false/Payments - Capture/event.test.js index d08e91cd6e8c..6b58fbb86f06 100644 --- a/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario4-Create payment with Manual capture with confirm false/Payments - Capture/event.test.js +++ b/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario4-Create payment with Manual capture with confirm false/Payments - Capture/event.test.js @@ -101,9 +101,9 @@ if (jsonData?.amount_received) { // Response body should have value "6540" for "amount_capturable" if (jsonData?.amount_capturable) { pm.test( - "[post]:://payments/:id/capture - Content check if value for 'amount_capturable' matches 'amount - 540'", + "[post]:://payments/:id/capture - Content check if value for 'amount_capturable' matches 'amount - 6540'", function () { - pm.expect(jsonData.amount_capturable).to.eql(540); + pm.expect(jsonData.amount_capturable).to.eql(6540); }, ); } diff --git a/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario4-Create payment with Manual capture with confirm false/Payments - Retrieve/event.test.js b/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario4-Create payment with Manual capture with confirm false/Payments - Retrieve/event.test.js index 8e84e4b38465..06abc1d37a5c 100644 --- a/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario4-Create payment with Manual capture with confirm false/Payments - Retrieve/event.test.js +++ b/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario4-Create payment with Manual capture with confirm false/Payments - Retrieve/event.test.js @@ -98,9 +98,9 @@ if (jsonData?.amount_received) { // Response body should have value "6540" for "amount_capturable" if (jsonData?.amount_capturable) { pm.test( - "[post]:://payments/:id/capture - Content check if value for 'amount_capturable' matches 'amount - 540'", + "[post]:://payments/:id/capture - Content check if value for 'amount_capturable' matches 'amount - 6540'", function () { - pm.expect(jsonData.amount_capturable).to.eql(540); + pm.expect(jsonData.amount_capturable).to.eql(6540); }, ); } diff --git a/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario4-Create payment with Manual capture/Payments - Capture/event.test.js b/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario4-Create payment with Manual capture/Payments - Capture/event.test.js index d2574b4816be..0085a8a1146c 100644 --- a/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario4-Create payment with Manual capture/Payments - Capture/event.test.js +++ b/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario4-Create payment with Manual capture/Payments - Capture/event.test.js @@ -101,9 +101,9 @@ if (jsonData?.amount_received) { // Response body should have value "6540" for "amount_capturable" if (jsonData?.amount_capturable) { pm.test( - "[post]:://payments/:id/capture - Content check if value for 'amount_capturable' matches 'amount - 540'", + "[post]:://payments/:id/capture - Content check if value for 'amount_capturable' matches 6540", function () { - pm.expect(jsonData.amount_capturable).to.eql(0); + pm.expect(jsonData.amount_capturable).to.eql(6540); }, ); } diff --git a/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario4-Create payment with Manual capture/Payments - Retrieve/event.test.js b/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario4-Create payment with Manual capture/Payments - Retrieve/event.test.js index c5396fe43dab..021d1f1475c2 100644 --- a/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario4-Create payment with Manual capture/Payments - Retrieve/event.test.js +++ b/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario4-Create payment with Manual capture/Payments - Retrieve/event.test.js @@ -98,9 +98,9 @@ if (jsonData?.amount_received) { // Response body should have value "6540" for "amount_capturable" if (jsonData?.amount_capturable) { pm.test( - "[post]:://payments/:id/capture - Content check if value for 'amount_capturable' matches 'amount - 540'", + "[post]:://payments/:id/capture - Content check if value for 'amount_capturable' matches 'amount - 6540'", function () { - pm.expect(jsonData.amount_capturable).to.eql(0); + pm.expect(jsonData.amount_capturable).to.eql(6540); }, ); } diff --git a/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario8-Create payment with Manual capture with confirm false and surcharge_data/Payments - Capture/event.test.js b/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario8-Create payment with Manual capture with confirm false and surcharge_data/Payments - Capture/event.test.js index 432edf05d37b..b09744cff12c 100644 --- a/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario8-Create payment with Manual capture with confirm false and surcharge_data/Payments - Capture/event.test.js +++ b/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario8-Create payment with Manual capture with confirm false and surcharge_data/Payments - Capture/event.test.js @@ -101,9 +101,9 @@ if (jsonData?.amount_received) { // Response body should have value "6540" for "amount_capturable" if (jsonData?.amount_capturable) { pm.test( - "[post]:://payments/:id/capture - Content check if value for 'amount_capturable' matches 0", + "[post]:://payments/:id/capture - Content check if value for 'amount_capturable' matches 6550", function () { - pm.expect(jsonData.amount_capturable).to.eql(0); + pm.expect(jsonData.amount_capturable).to.eql(6550); }, ); } diff --git a/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario8-Create payment with Manual capture with confirm false and surcharge_data/Payments - Retrieve/event.test.js b/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario8-Create payment with Manual capture with confirm false and surcharge_data/Payments - Retrieve/event.test.js index 5097d1cf94a7..69fd55634604 100644 --- a/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario8-Create payment with Manual capture with confirm false and surcharge_data/Payments - Retrieve/event.test.js +++ b/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario8-Create payment with Manual capture with confirm false and surcharge_data/Payments - Retrieve/event.test.js @@ -98,9 +98,9 @@ if (jsonData?.amount_received) { // Response body should have value "6540" for "amount_capturable" if (jsonData?.amount_capturable) { pm.test( - "[post]:://payments/:id/capture - Content check if value for 'amount_capturable' matches 'amount - 540'", + "[post]:://payments/:id/capture - Content check if value for 'amount_capturable' matches 'amount - 6550'", function () { - pm.expect(jsonData.amount_capturable).to.eql(540); + pm.expect(jsonData.amount_capturable).to.eql(6550); }, ); } diff --git a/postman/collection-json/paypal.postman_collection.json b/postman/collection-json/paypal.postman_collection.json index bcb508da4c0b..9063afe7b0da 100644 --- a/postman/collection-json/paypal.postman_collection.json +++ b/postman/collection-json/paypal.postman_collection.json @@ -1116,9 +1116,9 @@ "// Response body should have value \"6540\" for \"amount_capturable\"", "if (jsonData?.amount_capturable) {", " pm.test(", - " \"[post]:://payments/:id/capture - Content check if value for 'amount_capturable' matches 0\",", + " \"[post]:://payments/:id/capture - Content check if value for 'amount_capturable' matches 6550\",", " function () {", - " pm.expect(jsonData.amount_capturable).to.eql(0);", + " pm.expect(jsonData.amount_capturable).to.eql(6550);", " },", " );", "}", @@ -1285,9 +1285,9 @@ "// Response body should have value \"6540\" for \"amount_capturable\"", "if (jsonData?.amount_capturable) {", " pm.test(", - " \"[post]:://payments/:id/capture - Content check if value for 'amount_capturable' matches 'amount - 540'\",", + " \"[post]:://payments/:id/capture - Content check if value for 'amount_capturable' matches 'amount - 6550'\",", " function () {", - " pm.expect(jsonData.amount_capturable).to.eql(540);", + " pm.expect(jsonData.amount_capturable).to.eql(6550);", " },", " );", "}", @@ -3023,9 +3023,9 @@ "// Response body should have value \"6540\" for \"amount_capturable\"", "if (jsonData?.amount_capturable) {", " pm.test(", - " \"[post]:://payments/:id/capture - Content check if value for 'amount_capturable' matches 'amount - 540'\",", + " \"[post]:://payments/:id/capture - Content check if value for 'amount_capturable' matches 'amount - 6540'\",", " function () {", - " pm.expect(jsonData.amount_capturable).to.eql(540);", + " pm.expect(jsonData.amount_capturable).to.eql(6540);", " },", " );", "}", @@ -3185,9 +3185,9 @@ "// Response body should have value \"6540\" for \"amount_capturable\"", "if (jsonData?.amount_capturable) {", " pm.test(", - " \"[post]:://payments/:id/capture - Content check if value for 'amount_capturable' matches 'amount - 540'\",", + " \"[post]:://payments/:id/capture - Content check if value for 'amount_capturable' matches 'amount - 6540'\",", " function () {", - " pm.expect(jsonData.amount_capturable).to.eql(540);", + " pm.expect(jsonData.amount_capturable).to.eql(6540);", " },", " );", "}", @@ -3500,9 +3500,9 @@ "// Response body should have value \"6540\" for \"amount_capturable\"", "if (jsonData?.amount_capturable) {", " pm.test(", - " \"[post]:://payments/:id/capture - Content check if value for 'amount_capturable' matches 'amount - 540'\",", + " \"[post]:://payments/:id/capture - Content check if value for 'amount_capturable' matches 6540\",", " function () {", - " pm.expect(jsonData.amount_capturable).to.eql(0);", + " pm.expect(jsonData.amount_capturable).to.eql(6540);", " },", " );", "}", @@ -3662,9 +3662,9 @@ "// Response body should have value \"6540\" for \"amount_capturable\"", "if (jsonData?.amount_capturable) {", " pm.test(", - " \"[post]:://payments/:id/capture - Content check if value for 'amount_capturable' matches 'amount - 540'\",", + " \"[post]:://payments/:id/capture - Content check if value for 'amount_capturable' matches 'amount - 6540'\",", " function () {", - " pm.expect(jsonData.amount_capturable).to.eql(0);", + " pm.expect(jsonData.amount_capturable).to.eql(6540);", " },", " );", "}", @@ -3977,9 +3977,9 @@ "// Response body should have value \"6540\" for \"amount_capturable\"", "if (jsonData?.amount_capturable) {", " pm.test(", - " \"[post]:://payments/:id/capture - Content check if value for 'amount_capturable' matches 'amount - 540'\",", + " \"[post]:://payments/:id/capture - Content check if value for 'amount_capturable' matches 6540\",", " function () {", - " pm.expect(jsonData.amount_capturable).to.eql(540);", + " pm.expect(jsonData.amount_capturable).to.eql(6540);", " },", " );", "}", @@ -4139,9 +4139,9 @@ "// Response body should have value \"6540\" for \"amount_capturable\"", "if (jsonData?.amount_capturable) {", " pm.test(", - " \"[post]:://payments/:id/capture - Content check if value for 'amount_capturable' matches 'amount - 540'\",", + " \"[post]:://payments/:id/capture - Content check if value for 'amount_capturable' matches 'amount - 6540'\",", " function () {", - " pm.expect(jsonData.amount_capturable).to.eql(540);", + " pm.expect(jsonData.amount_capturable).to.eql(6540);", " },", " );", "}", From 88b53b0d5ccfb16b03fc17c453f2c7afa26ec92e Mon Sep 17 00:00:00 2001 From: Vrishab Srivatsa <136090360+vsrivatsa-juspay@users.noreply.github.com> Date: Tue, 2 Apr 2024 17:39:31 +0530 Subject: [PATCH 16/19] feat(analytics): three_ds and authentication events in sdkevents (#4251) Co-authored-by: Akash Kamble <127744130+akash-c-k@users.noreply.github.com> --- crates/analytics/src/query.rs | 2 + .../analytics/src/sdk_events/accumulator.rs | 16 ++- crates/analytics/src/sdk_events/core.rs | 24 +++- crates/analytics/src/sdk_events/metrics.rs | 112 ++++++++++++++-- .../authentication_unsuccessful_count.rs | 122 +++++++++++++++++ .../sdk_events/metrics/sdk_initiated_count.rs | 2 +- .../metrics/three_ds_challenge_flow_count.rs | 124 +++++++++++++++++ .../three_ds_frictionless_flow_count.rs | 126 ++++++++++++++++++ .../metrics/three_ds_method_invoked_count.rs | 124 +++++++++++++++++ .../metrics/three_ds_method_skipped_count.rs | 124 +++++++++++++++++ ...rs => three_ds_method_successful_count.rs} | 12 +- .../three_ds_method_unsuccessful_count.rs | 122 +++++++++++++++++ crates/api_models/src/analytics/sdk_events.rs | 33 ++++- 13 files changed, 914 insertions(+), 29 deletions(-) create mode 100644 crates/analytics/src/sdk_events/metrics/authentication_unsuccessful_count.rs create mode 100644 crates/analytics/src/sdk_events/metrics/three_ds_challenge_flow_count.rs create mode 100644 crates/analytics/src/sdk_events/metrics/three_ds_frictionless_flow_count.rs create mode 100644 crates/analytics/src/sdk_events/metrics/three_ds_method_invoked_count.rs create mode 100644 crates/analytics/src/sdk_events/metrics/three_ds_method_skipped_count.rs rename crates/analytics/src/sdk_events/metrics/{payment_success_count.rs => three_ds_method_successful_count.rs} (91%) create mode 100644 crates/analytics/src/sdk_events/metrics/three_ds_method_unsuccessful_count.rs diff --git a/crates/analytics/src/query.rs b/crates/analytics/src/query.rs index a7ef0d993e89..d52961520766 100644 --- a/crates/analytics/src/query.rs +++ b/crates/analytics/src/query.rs @@ -388,6 +388,7 @@ impl_to_sql_for_to_string!(&DisputeDimensions, DisputeDimensions, DisputeStage); #[derive(Debug)] pub enum FilterTypes { Equal, + NotEqual, EqualBool, In, Gte, @@ -402,6 +403,7 @@ pub fn filter_type_to_sql(l: &String, op: &FilterTypes, r: &String) -> String { match op { FilterTypes::EqualBool => format!("{l} = {r}"), FilterTypes::Equal => format!("{l} = '{r}'"), + FilterTypes::NotEqual => format!("{l} != '{r}'"), FilterTypes::In => format!("{l} IN ({r})"), FilterTypes::Gte => format!("{l} >= '{r}'"), FilterTypes::Gt => format!("{l} > {r}"), diff --git a/crates/analytics/src/sdk_events/accumulator.rs b/crates/analytics/src/sdk_events/accumulator.rs index ab9e9309434f..fc90ae48eb3e 100644 --- a/crates/analytics/src/sdk_events/accumulator.rs +++ b/crates/analytics/src/sdk_events/accumulator.rs @@ -6,13 +6,19 @@ use super::metrics::SdkEventMetricRow; #[derive(Debug, Default)] pub struct SdkEventMetricsAccumulator { pub payment_attempts: CountAccumulator, - pub payment_success: CountAccumulator, pub payment_methods_call_count: CountAccumulator, pub average_payment_time: AverageAccumulator, pub sdk_initiated_count: CountAccumulator, pub sdk_rendered_count: CountAccumulator, pub payment_method_selected_count: CountAccumulator, pub payment_data_filled_count: CountAccumulator, + pub three_ds_method_invoked_count: CountAccumulator, + pub three_ds_method_skipped_count: CountAccumulator, + pub three_ds_method_successful_count: CountAccumulator, + pub three_ds_method_unsuccessful_count: CountAccumulator, + pub authentication_unsuccessful_count: CountAccumulator, + pub three_ds_challenge_flow_count: CountAccumulator, + pub three_ds_frictionless_flow_count: CountAccumulator, } #[derive(Debug, Default)] @@ -86,13 +92,19 @@ impl SdkEventMetricsAccumulator { pub fn collect(self) -> SdkEventMetricsBucketValue { SdkEventMetricsBucketValue { payment_attempts: self.payment_attempts.collect(), - payment_success_count: self.payment_success.collect(), payment_methods_call_count: self.payment_methods_call_count.collect(), average_payment_time: self.average_payment_time.collect(), sdk_initiated_count: self.sdk_initiated_count.collect(), sdk_rendered_count: self.sdk_rendered_count.collect(), payment_method_selected_count: self.payment_method_selected_count.collect(), payment_data_filled_count: self.payment_data_filled_count.collect(), + three_ds_method_invoked_count: self.three_ds_method_invoked_count.collect(), + three_ds_method_skipped_count: self.three_ds_method_skipped_count.collect(), + three_ds_method_successful_count: self.three_ds_method_successful_count.collect(), + three_ds_method_unsuccessful_count: self.three_ds_method_unsuccessful_count.collect(), + authentication_unsuccessful_count: self.authentication_unsuccessful_count.collect(), + three_ds_challenge_flow_count: self.three_ds_challenge_flow_count.collect(), + three_ds_frictionless_flow_count: self.three_ds_frictionless_flow_count.collect(), } } } diff --git a/crates/analytics/src/sdk_events/core.rs b/crates/analytics/src/sdk_events/core.rs index a5d2900e54d8..2ffc7f1aed6b 100644 --- a/crates/analytics/src/sdk_events/core.rs +++ b/crates/analytics/src/sdk_events/core.rs @@ -88,9 +88,6 @@ pub async fn get_metrics( SdkEventMetrics::PaymentAttempts => { metrics_builder.payment_attempts.add_metrics_bucket(&value) } - SdkEventMetrics::PaymentSuccessCount => { - metrics_builder.payment_success.add_metrics_bucket(&value) - } SdkEventMetrics::PaymentMethodsCallCount => metrics_builder .payment_methods_call_count .add_metrics_bucket(&value), @@ -109,6 +106,27 @@ pub async fn get_metrics( SdkEventMetrics::AveragePaymentTime => metrics_builder .average_payment_time .add_metrics_bucket(&value), + SdkEventMetrics::ThreeDsMethodInvokedCount => metrics_builder + .three_ds_method_invoked_count + .add_metrics_bucket(&value), + SdkEventMetrics::ThreeDsMethodSkippedCount => metrics_builder + .three_ds_method_skipped_count + .add_metrics_bucket(&value), + SdkEventMetrics::ThreeDsMethodSuccessfulCount => metrics_builder + .three_ds_method_successful_count + .add_metrics_bucket(&value), + SdkEventMetrics::ThreeDsMethodUnsuccessfulCount => metrics_builder + .three_ds_method_unsuccessful_count + .add_metrics_bucket(&value), + SdkEventMetrics::AuthenticationUnsuccessfulCount => metrics_builder + .authentication_unsuccessful_count + .add_metrics_bucket(&value), + SdkEventMetrics::ThreeDsChallengeFlowCount => metrics_builder + .three_ds_challenge_flow_count + .add_metrics_bucket(&value), + SdkEventMetrics::ThreeDsFrictionlessFlowCount => metrics_builder + .three_ds_frictionless_flow_count + .add_metrics_bucket(&value), } } diff --git a/crates/analytics/src/sdk_events/metrics.rs b/crates/analytics/src/sdk_events/metrics.rs index 354d2270d18a..70d29a2eb638 100644 --- a/crates/analytics/src/sdk_events/metrics.rs +++ b/crates/analytics/src/sdk_events/metrics.rs @@ -11,23 +11,35 @@ use crate::{ types::{AnalyticsCollection, AnalyticsDataSource, LoadRow, MetricsResult}, }; +mod authentication_unsuccessful_count; mod average_payment_time; mod payment_attempts; mod payment_data_filled_count; mod payment_method_selected_count; mod payment_methods_call_count; -mod payment_success_count; mod sdk_initiated_count; mod sdk_rendered_count; +mod three_ds_challenge_flow_count; +mod three_ds_frictionless_flow_count; +mod three_ds_method_invoked_count; +mod three_ds_method_skipped_count; +mod three_ds_method_successful_count; +mod three_ds_method_unsuccessful_count; +use authentication_unsuccessful_count::AuthenticationUnsuccessfulCount; use average_payment_time::AveragePaymentTime; use payment_attempts::PaymentAttempts; use payment_data_filled_count::PaymentDataFilledCount; use payment_method_selected_count::PaymentMethodSelectedCount; use payment_methods_call_count::PaymentMethodsCallCount; -use payment_success_count::PaymentSuccessCount; use sdk_initiated_count::SdkInitiatedCount; use sdk_rendered_count::SdkRenderedCount; +use three_ds_challenge_flow_count::ThreeDsChallengeFlowCount; +use three_ds_frictionless_flow_count::ThreeDsFrictionlessFlowCount; +use three_ds_method_invoked_count::ThreeDsMethodInvokedCount; +use three_ds_method_skipped_count::ThreeDsMethodSkippedCount; +use three_ds_method_successful_count::ThreeDsMethodSuccessfulCount; +use three_ds_method_unsuccessful_count::ThreeDsMethodUnsuccessfulCount; #[derive(Debug, PartialEq, Eq, serde::Deserialize)] pub struct SdkEventMetricRow { @@ -92,18 +104,6 @@ where ) .await } - Self::PaymentSuccessCount => { - PaymentSuccessCount - .load_metrics( - dimensions, - publishable_key, - filters, - granularity, - time_range, - pool, - ) - .await - } Self::PaymentMethodsCallCount => { PaymentMethodsCallCount .load_metrics( @@ -176,6 +176,90 @@ where ) .await } + Self::ThreeDsMethodSkippedCount => { + ThreeDsMethodSkippedCount + .load_metrics( + dimensions, + publishable_key, + filters, + granularity, + time_range, + pool, + ) + .await + } + Self::ThreeDsMethodInvokedCount => { + ThreeDsMethodInvokedCount + .load_metrics( + dimensions, + publishable_key, + filters, + granularity, + time_range, + pool, + ) + .await + } + Self::ThreeDsMethodSuccessfulCount => { + ThreeDsMethodSuccessfulCount + .load_metrics( + dimensions, + publishable_key, + filters, + granularity, + time_range, + pool, + ) + .await + } + Self::ThreeDsMethodUnsuccessfulCount => { + ThreeDsMethodUnsuccessfulCount + .load_metrics( + dimensions, + publishable_key, + filters, + granularity, + time_range, + pool, + ) + .await + } + Self::AuthenticationUnsuccessfulCount => { + AuthenticationUnsuccessfulCount + .load_metrics( + dimensions, + publishable_key, + filters, + granularity, + time_range, + pool, + ) + .await + } + Self::ThreeDsChallengeFlowCount => { + ThreeDsChallengeFlowCount + .load_metrics( + dimensions, + publishable_key, + filters, + granularity, + time_range, + pool, + ) + .await + } + Self::ThreeDsFrictionlessFlowCount => { + ThreeDsFrictionlessFlowCount + .load_metrics( + dimensions, + publishable_key, + filters, + granularity, + time_range, + pool, + ) + .await + } } } } diff --git a/crates/analytics/src/sdk_events/metrics/authentication_unsuccessful_count.rs b/crates/analytics/src/sdk_events/metrics/authentication_unsuccessful_count.rs new file mode 100644 index 000000000000..c2fe777d827c --- /dev/null +++ b/crates/analytics/src/sdk_events/metrics/authentication_unsuccessful_count.rs @@ -0,0 +1,122 @@ +use api_models::analytics::{ + sdk_events::{ + SdkEventDimensions, SdkEventFilters, SdkEventMetricsBucketIdentifier, SdkEventNames, + }, + Granularity, TimeRange, +}; +use common_utils::errors::ReportSwitchExt; +use error_stack::ResultExt; +use time::PrimitiveDateTime; + +use super::SdkEventMetricRow; +use crate::{ + query::{Aggregate, GroupByClause, QueryBuilder, QueryFilter, ToSql, Window}, + types::{AnalyticsCollection, AnalyticsDataSource, MetricsError, MetricsResult}, +}; + +#[derive(Default)] +pub(super) struct AuthenticationUnsuccessfulCount; + +#[async_trait::async_trait] +impl super::SdkEventMetric for AuthenticationUnsuccessfulCount +where + T: AnalyticsDataSource + super::SdkEventMetricAnalytics, + PrimitiveDateTime: ToSql, + AnalyticsCollection: ToSql, + Granularity: GroupByClause, + Aggregate<&'static str>: ToSql, + Window<&'static str>: ToSql, +{ + async fn load_metrics( + &self, + dimensions: &[SdkEventDimensions], + publishable_key: &str, + filters: &SdkEventFilters, + granularity: &Option, + time_range: &TimeRange, + pool: &T, + ) -> MetricsResult> { + let mut query_builder: QueryBuilder = QueryBuilder::new(AnalyticsCollection::SdkEvents); + let dimensions = dimensions.to_vec(); + + for dim in dimensions.iter() { + query_builder.add_select_column(dim).switch()?; + } + + query_builder + .add_select_column(Aggregate::Count { + field: None, + alias: Some("count"), + }) + .switch()?; + + if let Some(granularity) = granularity.as_ref() { + query_builder + .add_granularity_in_mins(granularity) + .switch()?; + } + + filters.set_filter_clause(&mut query_builder).switch()?; + + query_builder + .add_filter_clause("merchant_id", publishable_key) + .switch()?; + + query_builder + .add_filter_clause("event_name", SdkEventNames::AuthenticationCall) + .switch()?; + + query_builder + .add_filter_clause("log_type", "ERROR") + .switch()?; + + query_builder + .add_filter_clause("category", "USER_EVENT") + .switch()?; + + time_range + .set_filter_clause(&mut query_builder) + .attach_printable("Error filtering time range") + .switch()?; + + for dim in dimensions.iter() { + query_builder + .add_group_by_clause(dim) + .attach_printable("Error grouping by dimensions") + .switch()?; + } + + if let Some(_granularity) = granularity.as_ref() { + query_builder + .add_group_by_clause("time_bucket") + .attach_printable("Error adding granularity") + .switch()?; + } + + query_builder + .execute_query::(pool) + .await + .change_context(MetricsError::QueryBuildingError)? + .change_context(MetricsError::QueryExecutionFailure)? + .into_iter() + .map(|i| { + Ok(( + SdkEventMetricsBucketIdentifier::new( + i.payment_method.clone(), + i.platform.clone(), + i.browser_name.clone(), + i.source.clone(), + i.component.clone(), + i.payment_experience.clone(), + i.time_bucket.clone(), + ), + i, + )) + }) + .collect::, + crate::query::PostProcessingError, + >>() + .change_context(MetricsError::PostProcessingFailure) + } +} diff --git a/crates/analytics/src/sdk_events/metrics/sdk_initiated_count.rs b/crates/analytics/src/sdk_events/metrics/sdk_initiated_count.rs index a525e7890b75..ecbca81acf41 100644 --- a/crates/analytics/src/sdk_events/metrics/sdk_initiated_count.rs +++ b/crates/analytics/src/sdk_events/metrics/sdk_initiated_count.rs @@ -67,7 +67,7 @@ where .switch()?; query_builder - .add_filter_clause("event_name", SdkEventNames::StripeElementsCalled) + .add_filter_clause("event_name", SdkEventNames::OrcaElementsCalled) .switch()?; time_range diff --git a/crates/analytics/src/sdk_events/metrics/three_ds_challenge_flow_count.rs b/crates/analytics/src/sdk_events/metrics/three_ds_challenge_flow_count.rs new file mode 100644 index 000000000000..eb2eab604612 --- /dev/null +++ b/crates/analytics/src/sdk_events/metrics/three_ds_challenge_flow_count.rs @@ -0,0 +1,124 @@ +use api_models::analytics::{ + sdk_events::{ + SdkEventDimensions, SdkEventFilters, SdkEventMetricsBucketIdentifier, SdkEventNames, + }, + Granularity, TimeRange, +}; +use common_utils::errors::ReportSwitchExt; +use error_stack::ResultExt; +use time::PrimitiveDateTime; + +use super::SdkEventMetricRow; +use crate::{ + query::{Aggregate, GroupByClause, QueryBuilder, QueryFilter, ToSql, Window}, + types::{AnalyticsCollection, AnalyticsDataSource, MetricsError, MetricsResult}, +}; + +#[derive(Default)] +pub(super) struct ThreeDsChallengeFlowCount; + +#[async_trait::async_trait] +impl super::SdkEventMetric for ThreeDsChallengeFlowCount +where + T: AnalyticsDataSource + super::SdkEventMetricAnalytics, + PrimitiveDateTime: ToSql, + AnalyticsCollection: ToSql, + Granularity: GroupByClause, + Aggregate<&'static str>: ToSql, + Window<&'static str>: ToSql, +{ + async fn load_metrics( + &self, + dimensions: &[SdkEventDimensions], + publishable_key: &str, + filters: &SdkEventFilters, + granularity: &Option, + time_range: &TimeRange, + pool: &T, + ) -> MetricsResult> { + let mut query_builder: QueryBuilder = QueryBuilder::new(AnalyticsCollection::SdkEvents); + let dimensions = dimensions.to_vec(); + + for dim in dimensions.iter() { + query_builder.add_select_column(dim).switch()?; + } + + query_builder + .add_select_column(Aggregate::Count { + field: None, + alias: Some("count"), + }) + .switch()?; + + if let Some(granularity) = granularity.as_ref() { + query_builder + .add_granularity_in_mins(granularity) + .switch()?; + } + + filters.set_filter_clause(&mut query_builder).switch()?; + + query_builder + .add_filter_clause("merchant_id", publishable_key) + .switch()?; + + query_builder + .add_filter_clause("event_name", SdkEventNames::DisplayThreeDsSdk) + .switch()?; + + query_builder + .add_filter_clause("log_type", "INFO") + .switch()?; + + query_builder + .add_filter_clause("category", "USER_EVENT") + .switch()?; + + query_builder.add_filter_clause("value", "C").switch()?; + + time_range + .set_filter_clause(&mut query_builder) + .attach_printable("Error filtering time range") + .switch()?; + + for dim in dimensions.iter() { + query_builder + .add_group_by_clause(dim) + .attach_printable("Error grouping by dimensions") + .switch()?; + } + + if let Some(_granularity) = granularity.as_ref() { + query_builder + .add_group_by_clause("time_bucket") + .attach_printable("Error adding granularity") + .switch()?; + } + + query_builder + .execute_query::(pool) + .await + .change_context(MetricsError::QueryBuildingError)? + .change_context(MetricsError::QueryExecutionFailure)? + .into_iter() + .map(|i| { + Ok(( + SdkEventMetricsBucketIdentifier::new( + i.payment_method.clone(), + i.platform.clone(), + i.browser_name.clone(), + i.source.clone(), + i.component.clone(), + i.payment_experience.clone(), + i.time_bucket.clone(), + ), + i, + )) + }) + .collect::, + crate::query::PostProcessingError, + >>() + .change_context(MetricsError::PostProcessingFailure) + } +} diff --git a/crates/analytics/src/sdk_events/metrics/three_ds_frictionless_flow_count.rs b/crates/analytics/src/sdk_events/metrics/three_ds_frictionless_flow_count.rs new file mode 100644 index 000000000000..ec40cf50c23f --- /dev/null +++ b/crates/analytics/src/sdk_events/metrics/three_ds_frictionless_flow_count.rs @@ -0,0 +1,126 @@ +use api_models::analytics::{ + sdk_events::{ + SdkEventDimensions, SdkEventFilters, SdkEventMetricsBucketIdentifier, SdkEventNames, + }, + Granularity, TimeRange, +}; +use common_utils::errors::ReportSwitchExt; +use error_stack::ResultExt; +use time::PrimitiveDateTime; + +use super::SdkEventMetricRow; +use crate::{ + query::{Aggregate, FilterTypes, GroupByClause, QueryBuilder, QueryFilter, ToSql, Window}, + types::{AnalyticsCollection, AnalyticsDataSource, MetricsError, MetricsResult}, +}; + +#[derive(Default)] +pub(super) struct ThreeDsFrictionlessFlowCount; + +#[async_trait::async_trait] +impl super::SdkEventMetric for ThreeDsFrictionlessFlowCount +where + T: AnalyticsDataSource + super::SdkEventMetricAnalytics, + PrimitiveDateTime: ToSql, + AnalyticsCollection: ToSql, + Granularity: GroupByClause, + Aggregate<&'static str>: ToSql, + Window<&'static str>: ToSql, +{ + async fn load_metrics( + &self, + dimensions: &[SdkEventDimensions], + publishable_key: &str, + filters: &SdkEventFilters, + granularity: &Option, + time_range: &TimeRange, + pool: &T, + ) -> MetricsResult> { + let mut query_builder: QueryBuilder = QueryBuilder::new(AnalyticsCollection::SdkEvents); + let dimensions = dimensions.to_vec(); + + for dim in dimensions.iter() { + query_builder.add_select_column(dim).switch()?; + } + + query_builder + .add_select_column(Aggregate::Count { + field: None, + alias: Some("count"), + }) + .switch()?; + + if let Some(granularity) = granularity.as_ref() { + query_builder + .add_granularity_in_mins(granularity) + .switch()?; + } + + filters.set_filter_clause(&mut query_builder).switch()?; + + query_builder + .add_filter_clause("merchant_id", publishable_key) + .switch()?; + + query_builder + .add_filter_clause("event_name", SdkEventNames::DisplayThreeDsSdk) + .switch()?; + + query_builder + .add_filter_clause("log_type", "INFO") + .switch()?; + + query_builder + .add_filter_clause("category", "USER_EVENT") + .switch()?; + + query_builder + .add_custom_filter_clause("value", "C", FilterTypes::NotEqual) + .switch()?; + + time_range + .set_filter_clause(&mut query_builder) + .attach_printable("Error filtering time range") + .switch()?; + + for dim in dimensions.iter() { + query_builder + .add_group_by_clause(dim) + .attach_printable("Error grouping by dimensions") + .switch()?; + } + + if let Some(_granularity) = granularity.as_ref() { + query_builder + .add_group_by_clause("time_bucket") + .attach_printable("Error adding granularity") + .switch()?; + } + + query_builder + .execute_query::(pool) + .await + .change_context(MetricsError::QueryBuildingError)? + .change_context(MetricsError::QueryExecutionFailure)? + .into_iter() + .map(|i| { + Ok(( + SdkEventMetricsBucketIdentifier::new( + i.payment_method.clone(), + i.platform.clone(), + i.browser_name.clone(), + i.source.clone(), + i.component.clone(), + i.payment_experience.clone(), + i.time_bucket.clone(), + ), + i, + )) + }) + .collect::, + crate::query::PostProcessingError, + >>() + .change_context(MetricsError::PostProcessingFailure) + } +} diff --git a/crates/analytics/src/sdk_events/metrics/three_ds_method_invoked_count.rs b/crates/analytics/src/sdk_events/metrics/three_ds_method_invoked_count.rs new file mode 100644 index 000000000000..17368d8a74fc --- /dev/null +++ b/crates/analytics/src/sdk_events/metrics/three_ds_method_invoked_count.rs @@ -0,0 +1,124 @@ +use api_models::analytics::{ + sdk_events::{ + SdkEventDimensions, SdkEventFilters, SdkEventMetricsBucketIdentifier, SdkEventNames, + }, + Granularity, TimeRange, +}; +use common_utils::errors::ReportSwitchExt; +use error_stack::ResultExt; +use time::PrimitiveDateTime; + +use super::SdkEventMetricRow; +use crate::{ + query::{Aggregate, GroupByClause, QueryBuilder, QueryFilter, ToSql, Window}, + types::{AnalyticsCollection, AnalyticsDataSource, MetricsError, MetricsResult}, +}; + +#[derive(Default)] +pub(super) struct ThreeDsMethodInvokedCount; + +#[async_trait::async_trait] +impl super::SdkEventMetric for ThreeDsMethodInvokedCount +where + T: AnalyticsDataSource + super::SdkEventMetricAnalytics, + PrimitiveDateTime: ToSql, + AnalyticsCollection: ToSql, + Granularity: GroupByClause, + Aggregate<&'static str>: ToSql, + Window<&'static str>: ToSql, +{ + async fn load_metrics( + &self, + dimensions: &[SdkEventDimensions], + publishable_key: &str, + filters: &SdkEventFilters, + granularity: &Option, + time_range: &TimeRange, + pool: &T, + ) -> MetricsResult> { + let mut query_builder: QueryBuilder = QueryBuilder::new(AnalyticsCollection::SdkEvents); + let dimensions = dimensions.to_vec(); + + for dim in dimensions.iter() { + query_builder.add_select_column(dim).switch()?; + } + + query_builder + .add_select_column(Aggregate::Count { + field: None, + alias: Some("count"), + }) + .switch()?; + + if let Some(granularity) = granularity.as_ref() { + query_builder + .add_granularity_in_mins(granularity) + .switch()?; + } + + filters.set_filter_clause(&mut query_builder).switch()?; + + query_builder + .add_filter_clause("merchant_id", publishable_key) + .switch()?; + + query_builder + .add_filter_clause("event_name", SdkEventNames::ThreeDsMethod) + .switch()?; + + query_builder + .add_filter_clause("log_type", "INFO") + .switch()?; + + query_builder + .add_filter_clause("category", "USER_EVENT") + .switch()?; + + query_builder.add_filter_clause("value", "Y").switch()?; + + time_range + .set_filter_clause(&mut query_builder) + .attach_printable("Error filtering time range") + .switch()?; + + for dim in dimensions.iter() { + query_builder + .add_group_by_clause(dim) + .attach_printable("Error grouping by dimensions") + .switch()?; + } + + if let Some(_granularity) = granularity.as_ref() { + query_builder + .add_group_by_clause("time_bucket") + .attach_printable("Error adding granularity") + .switch()?; + } + + query_builder + .execute_query::(pool) + .await + .change_context(MetricsError::QueryBuildingError)? + .change_context(MetricsError::QueryExecutionFailure)? + .into_iter() + .map(|i| { + Ok(( + SdkEventMetricsBucketIdentifier::new( + i.payment_method.clone(), + i.platform.clone(), + i.browser_name.clone(), + i.source.clone(), + i.component.clone(), + i.payment_experience.clone(), + i.time_bucket.clone(), + ), + i, + )) + }) + .collect::, + crate::query::PostProcessingError, + >>() + .change_context(MetricsError::PostProcessingFailure) + } +} diff --git a/crates/analytics/src/sdk_events/metrics/three_ds_method_skipped_count.rs b/crates/analytics/src/sdk_events/metrics/three_ds_method_skipped_count.rs new file mode 100644 index 000000000000..9ffb2a1c696b --- /dev/null +++ b/crates/analytics/src/sdk_events/metrics/three_ds_method_skipped_count.rs @@ -0,0 +1,124 @@ +use api_models::analytics::{ + sdk_events::{ + SdkEventDimensions, SdkEventFilters, SdkEventMetricsBucketIdentifier, SdkEventNames, + }, + Granularity, TimeRange, +}; +use common_utils::errors::ReportSwitchExt; +use error_stack::ResultExt; +use time::PrimitiveDateTime; + +use super::SdkEventMetricRow; +use crate::{ + query::{Aggregate, GroupByClause, QueryBuilder, QueryFilter, ToSql, Window}, + types::{AnalyticsCollection, AnalyticsDataSource, MetricsError, MetricsResult}, +}; + +#[derive(Default)] +pub(super) struct ThreeDsMethodSkippedCount; + +#[async_trait::async_trait] +impl super::SdkEventMetric for ThreeDsMethodSkippedCount +where + T: AnalyticsDataSource + super::SdkEventMetricAnalytics, + PrimitiveDateTime: ToSql, + AnalyticsCollection: ToSql, + Granularity: GroupByClause, + Aggregate<&'static str>: ToSql, + Window<&'static str>: ToSql, +{ + async fn load_metrics( + &self, + dimensions: &[SdkEventDimensions], + publishable_key: &str, + filters: &SdkEventFilters, + granularity: &Option, + time_range: &TimeRange, + pool: &T, + ) -> MetricsResult> { + let mut query_builder: QueryBuilder = QueryBuilder::new(AnalyticsCollection::SdkEvents); + let dimensions = dimensions.to_vec(); + + for dim in dimensions.iter() { + query_builder.add_select_column(dim).switch()?; + } + + query_builder + .add_select_column(Aggregate::Count { + field: None, + alias: Some("count"), + }) + .switch()?; + + if let Some(granularity) = granularity.as_ref() { + query_builder + .add_granularity_in_mins(granularity) + .switch()?; + } + + filters.set_filter_clause(&mut query_builder).switch()?; + + query_builder + .add_filter_clause("merchant_id", publishable_key) + .switch()?; + + query_builder + .add_filter_clause("event_name", SdkEventNames::ThreeDsMethod) + .switch()?; + + query_builder + .add_filter_clause("log_type", "INFO") + .switch()?; + + query_builder + .add_filter_clause("category", "USER_EVENT") + .switch()?; + + query_builder.add_filter_clause("value", "N").switch()?; + + time_range + .set_filter_clause(&mut query_builder) + .attach_printable("Error filtering time range") + .switch()?; + + for dim in dimensions.iter() { + query_builder + .add_group_by_clause(dim) + .attach_printable("Error grouping by dimensions") + .switch()?; + } + + if let Some(_granularity) = granularity.as_ref() { + query_builder + .add_group_by_clause("time_bucket") + .attach_printable("Error adding granularity") + .switch()?; + } + + query_builder + .execute_query::(pool) + .await + .change_context(MetricsError::QueryBuildingError)? + .change_context(MetricsError::QueryExecutionFailure)? + .into_iter() + .map(|i| { + Ok(( + SdkEventMetricsBucketIdentifier::new( + i.payment_method.clone(), + i.platform.clone(), + i.browser_name.clone(), + i.source.clone(), + i.component.clone(), + i.payment_experience.clone(), + i.time_bucket.clone(), + ), + i, + )) + }) + .collect::, + crate::query::PostProcessingError, + >>() + .change_context(MetricsError::PostProcessingFailure) + } +} diff --git a/crates/analytics/src/sdk_events/metrics/payment_success_count.rs b/crates/analytics/src/sdk_events/metrics/three_ds_method_successful_count.rs similarity index 91% rename from crates/analytics/src/sdk_events/metrics/payment_success_count.rs rename to crates/analytics/src/sdk_events/metrics/three_ds_method_successful_count.rs index 3faf8213632f..5a8305e8ab8a 100644 --- a/crates/analytics/src/sdk_events/metrics/payment_success_count.rs +++ b/crates/analytics/src/sdk_events/metrics/three_ds_method_successful_count.rs @@ -15,10 +15,10 @@ use crate::{ }; #[derive(Default)] -pub(super) struct PaymentSuccessCount; +pub(super) struct ThreeDsMethodSuccessfulCount; #[async_trait::async_trait] -impl super::SdkEventMetric for PaymentSuccessCount +impl super::SdkEventMetric for ThreeDsMethodSuccessfulCount where T: AnalyticsDataSource + super::SdkEventMetricAnalytics, PrimitiveDateTime: ToSql, @@ -63,11 +63,15 @@ where .switch()?; query_builder - .add_bool_filter_clause("first_event", 1) + .add_filter_clause("event_name", SdkEventNames::ThreeDsMethodResult) .switch()?; query_builder - .add_filter_clause("event_name", SdkEventNames::PaymentSuccess) + .add_filter_clause("log_type", "INFO") + .switch()?; + + query_builder + .add_filter_clause("category", "USER_EVENT") .switch()?; time_range diff --git a/crates/analytics/src/sdk_events/metrics/three_ds_method_unsuccessful_count.rs b/crates/analytics/src/sdk_events/metrics/three_ds_method_unsuccessful_count.rs new file mode 100644 index 000000000000..b18d025bd09f --- /dev/null +++ b/crates/analytics/src/sdk_events/metrics/three_ds_method_unsuccessful_count.rs @@ -0,0 +1,122 @@ +use api_models::analytics::{ + sdk_events::{ + SdkEventDimensions, SdkEventFilters, SdkEventMetricsBucketIdentifier, SdkEventNames, + }, + Granularity, TimeRange, +}; +use common_utils::errors::ReportSwitchExt; +use error_stack::ResultExt; +use time::PrimitiveDateTime; + +use super::SdkEventMetricRow; +use crate::{ + query::{Aggregate, GroupByClause, QueryBuilder, QueryFilter, ToSql, Window}, + types::{AnalyticsCollection, AnalyticsDataSource, MetricsError, MetricsResult}, +}; + +#[derive(Default)] +pub(super) struct ThreeDsMethodUnsuccessfulCount; + +#[async_trait::async_trait] +impl super::SdkEventMetric for ThreeDsMethodUnsuccessfulCount +where + T: AnalyticsDataSource + super::SdkEventMetricAnalytics, + PrimitiveDateTime: ToSql, + AnalyticsCollection: ToSql, + Granularity: GroupByClause, + Aggregate<&'static str>: ToSql, + Window<&'static str>: ToSql, +{ + async fn load_metrics( + &self, + dimensions: &[SdkEventDimensions], + publishable_key: &str, + filters: &SdkEventFilters, + granularity: &Option, + time_range: &TimeRange, + pool: &T, + ) -> MetricsResult> { + let mut query_builder: QueryBuilder = QueryBuilder::new(AnalyticsCollection::SdkEvents); + let dimensions = dimensions.to_vec(); + + for dim in dimensions.iter() { + query_builder.add_select_column(dim).switch()?; + } + + query_builder + .add_select_column(Aggregate::Count { + field: None, + alias: Some("count"), + }) + .switch()?; + + if let Some(granularity) = granularity.as_ref() { + query_builder + .add_granularity_in_mins(granularity) + .switch()?; + } + + filters.set_filter_clause(&mut query_builder).switch()?; + + query_builder + .add_filter_clause("merchant_id", publishable_key) + .switch()?; + + query_builder + .add_filter_clause("event_name", SdkEventNames::ThreeDsMethodResult) + .switch()?; + + query_builder + .add_filter_clause("log_type", "ERROR") + .switch()?; + + query_builder + .add_filter_clause("category", "USER_EVENT") + .switch()?; + + time_range + .set_filter_clause(&mut query_builder) + .attach_printable("Error filtering time range") + .switch()?; + + for dim in dimensions.iter() { + query_builder + .add_group_by_clause(dim) + .attach_printable("Error grouping by dimensions") + .switch()?; + } + + if let Some(_granularity) = granularity.as_ref() { + query_builder + .add_group_by_clause("time_bucket") + .attach_printable("Error adding granularity") + .switch()?; + } + + query_builder + .execute_query::(pool) + .await + .change_context(MetricsError::QueryBuildingError)? + .change_context(MetricsError::QueryExecutionFailure)? + .into_iter() + .map(|i| { + Ok(( + SdkEventMetricsBucketIdentifier::new( + i.payment_method.clone(), + i.platform.clone(), + i.browser_name.clone(), + i.source.clone(), + i.component.clone(), + i.payment_experience.clone(), + i.time_bucket.clone(), + ), + i, + )) + }) + .collect::, + crate::query::PostProcessingError, + >>() + .change_context(MetricsError::PostProcessingFailure) + } +} diff --git a/crates/api_models/src/analytics/sdk_events.rs b/crates/api_models/src/analytics/sdk_events.rs index 76ccb29867f2..2eacaa655da5 100644 --- a/crates/api_models/src/analytics/sdk_events.rs +++ b/crates/api_models/src/analytics/sdk_events.rs @@ -71,8 +71,14 @@ pub enum SdkEventDimensions { #[serde(rename_all = "snake_case")] pub enum SdkEventMetrics { PaymentAttempts, - PaymentSuccessCount, PaymentMethodsCallCount, + ThreeDsMethodInvokedCount, + ThreeDsMethodSkippedCount, + ThreeDsMethodSuccessfulCount, + ThreeDsMethodUnsuccessfulCount, + AuthenticationUnsuccessfulCount, + ThreeDsChallengeFlowCount, + ThreeDsFrictionlessFlowCount, SdkRenderedCount, SdkInitiatedCount, PaymentMethodSelectedCount, @@ -95,12 +101,11 @@ pub enum SdkEventMetrics { #[strum(serialize_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")] pub enum SdkEventNames { - StripeElementsCalled, + OrcaElementsCalled, AppRendered, PaymentMethodChanged, PaymentDataFilled, PaymentAttempt, - PaymentSuccess, PaymentMethodsCall, ConfirmCall, SessionsCall, @@ -108,12 +113,24 @@ pub enum SdkEventNames { RedirectingUser, DisplayBankTransferInfoPage, DisplayQrCodeInfoPage, + AuthenticationCall, + ThreeDsMethodCall, + ThreeDsMethodResult, + ThreeDsMethod, + LoaderChanged, + DisplayThreeDsSdk, } pub mod metric_behaviour { pub struct PaymentAttempts; - pub struct PaymentSuccessCount; pub struct PaymentMethodsCallCount; + pub struct ThreeDsMethodInvokedCount; + pub struct ThreeDsMethodSkippedCount; + pub struct ThreeDsMethodSuccessfulCount; + pub struct ThreeDsMethodUnsuccessfulCount; + pub struct AuthenticationUnsuccessfulCount; + pub struct ThreeDsChallengeFlowCount; + pub struct ThreeDsFrictionlessFlowCount; pub struct SdkRenderedCount; pub struct SdkInitiatedCount; pub struct PaymentMethodSelectedCount; @@ -197,13 +214,19 @@ impl PartialEq for SdkEventMetricsBucketIdentifier { #[derive(Debug, serde::Serialize)] pub struct SdkEventMetricsBucketValue { pub payment_attempts: Option, - pub payment_success_count: Option, pub payment_methods_call_count: Option, pub average_payment_time: Option, pub sdk_rendered_count: Option, pub sdk_initiated_count: Option, pub payment_method_selected_count: Option, pub payment_data_filled_count: Option, + pub three_ds_method_invoked_count: Option, + pub three_ds_method_skipped_count: Option, + pub three_ds_method_successful_count: Option, + pub three_ds_method_unsuccessful_count: Option, + pub authentication_unsuccessful_count: Option, + pub three_ds_challenge_flow_count: Option, + pub three_ds_frictionless_flow_count: Option, } #[derive(Debug, serde::Serialize)] From 97fbc899c12a0c66ac89a7feaa6d45d39239a746 Mon Sep 17 00:00:00 2001 From: Sahkal Poddar Date: Tue, 2 Apr 2024 17:45:08 +0530 Subject: [PATCH 17/19] feat(payment_link): Add payment info metadata to payment link (#4270) Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> --- crates/api_models/src/payments.rs | 6 ++--- crates/router/src/core/payment_link.rs | 27 ++++++++++++++----- .../payment_link_initiate/payment_link.html | 1 + crates/router/src/services/api.rs | 8 ++++++ 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs index b719d1f7d111..2748ccbff40e 100644 --- a/crates/api_models/src/payments.rs +++ b/crates/api_models/src/payments.rs @@ -4376,12 +4376,12 @@ pub struct PaymentLinkInitiateRequest { #[derive(Debug, serde::Serialize)] #[serde(untagged)] -pub enum PaymentLinkData { - PaymentLinkDetails(PaymentLinkDetails), +pub enum PaymentLinkData<'a> { + PaymentLinkDetails(&'a PaymentLinkDetails), PaymentLinkStatusDetails(PaymentLinkStatusDetails), } -#[derive(Debug, serde::Serialize)] +#[derive(Debug, serde::Serialize, Clone)] pub struct PaymentLinkDetails { pub amount: String, pub currency: api_enums::Currency, diff --git a/crates/router/src/core/payment_link.rs b/crates/router/src/core/payment_link.rs index 722aad26c0db..94d82279892f 100644 --- a/crates/router/src/core/payment_link.rs +++ b/crates/router/src/core/payment_link.rs @@ -187,7 +187,7 @@ pub async fn intiate_payment_link_flow( return_url: return_url.clone(), }; let js_script = get_js_script( - api_models::payments::PaymentLinkData::PaymentLinkStatusDetails(payment_details), + &api_models::payments::PaymentLinkData::PaymentLinkStatusDetails(payment_details), )?; let payment_link_error_data = services::PaymentLinkStatusData { js_script, @@ -215,13 +215,17 @@ pub async fn intiate_payment_link_flow( sdk_layout: payment_link_config.sdk_layout.clone(), }; - let js_script = get_js_script(api_models::payments::PaymentLinkData::PaymentLinkDetails( - payment_details, + let js_script = get_js_script(&api_models::payments::PaymentLinkData::PaymentLinkDetails( + &payment_details, ))?; + + let html_meta_tags = get_meta_tags_html(payment_details); + let payment_link_data = services::PaymentLinkFormData { js_script, sdk_url: state.conf.payment_link.sdk_url.clone(), css_script, + html_meta_tags, }; Ok(services::ApplicationResponse::PaymentLinkForm(Box::new( services::api::PaymentLinkAction::PaymentLinkFormData(payment_link_data), @@ -232,8 +236,10 @@ pub async fn intiate_payment_link_flow( The get_js_script function is used to inject dynamic value to payment_link sdk, which is unique to every payment. */ -fn get_js_script(payment_details: api_models::payments::PaymentLinkData) -> RouterResult { - let payment_details_str = serde_json::to_string(&payment_details) +fn get_js_script( + payment_details: &api_models::payments::PaymentLinkData<'_>, +) -> RouterResult { + let payment_details_str = serde_json::to_string(payment_details) .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Failed to serialize PaymentLinkData")?; Ok(format!("window.__PAYMENT_DETAILS = {payment_details_str};")) @@ -248,6 +254,15 @@ fn get_color_scheme_css(payment_link_config: api_models::admin::PaymentLinkConfi ) } +fn get_meta_tags_html(payment_details: api_models::payments::PaymentLinkDetails) -> String { + format!( + r#" + "#, + payment_details.merchant_name, + payment_details.merchant_description.unwrap_or_default() + ) +} + fn validate_sdk_requirements( pub_key: Option, currency: Option, @@ -562,7 +577,7 @@ pub async fn get_payment_link_status( return_url, }; let js_script = get_js_script( - api_models::payments::PaymentLinkData::PaymentLinkStatusDetails(payment_details), + &api_models::payments::PaymentLinkData::PaymentLinkStatusDetails(payment_details), )?; let payment_link_status_data = services::PaymentLinkStatusData { js_script, diff --git a/crates/router/src/core/payment_link/payment_link_initiate/payment_link.html b/crates/router/src/core/payment_link/payment_link_initiate/payment_link.html index 732e331892ff..6b487395c62e 100644 --- a/crates/router/src/core/payment_link/payment_link_initiate/payment_link.html +++ b/crates/router/src/core/payment_link/payment_link_initiate/payment_link.html @@ -3,6 +3,7 @@ + {{rendered_meta_tag_html}} Payments requested by HyperSwitch {{ preload_link_tags }} diff --git a/crates/router/src/services/api.rs b/crates/router/src/services/api.rs index 95eb4a44c8a8..5a139d8da35e 100644 --- a/crates/router/src/services/api.rs +++ b/crates/router/src/services/api.rs @@ -853,6 +853,7 @@ pub struct PaymentLinkFormData { pub js_script: String, pub css_script: String, pub sdk_url: String, + pub html_meta_tags: String, } #[derive(Debug, Eq, PartialEq, Clone, serde::Serialize, serde::Deserialize)] @@ -1977,6 +1978,13 @@ pub fn build_payment_link_html( let _ = tera.add_raw_template("payment_link", &html_template); + context.insert("rendered_meta_tag_html", &payment_link_data.html_meta_tags); + + context.insert( + "preload_link_tags", + &get_preload_link_html_template(&payment_link_data.sdk_url), + ); + context.insert( "preload_link_tags", &get_preload_link_html_template(&payment_link_data.sdk_url), From 2f304e601607980e7e536d94411ddf0f9023c605 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger <131388445+AkshayaFoiger@users.noreply.github.com> Date: Tue, 2 Apr 2024 19:43:28 +0530 Subject: [PATCH 18/19] feat(router): [BOA] implement mandates for cards and wallets (#4232) Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> --- config/config.example.toml | 5 +- config/deployments/integration_test.toml | 8 +- config/deployments/production.toml | 8 +- config/deployments/sandbox.toml | 8 +- config/development.toml | 8 +- config/docker_compose.toml | 8 +- crates/router/src/connector/bankofamerica.rs | 142 ++- .../connector/bankofamerica/transformers.rs | 1086 +++++++++++++---- crates/router/src/connector/utils.rs | 4 + loadtest/config/development.toml | 8 +- 10 files changed, 986 insertions(+), 299 deletions(-) diff --git a/config/config.example.toml b/config/config.example.toml index c1ba88db0195..074028c208a1 100644 --- a/config/config.example.toml +++ b/config/config.example.toml @@ -383,7 +383,7 @@ slack_invite_url = "https://www.example.com/" # Slack invite url for hyperswit discord_invite_url = "https://www.example.com/" # Discord invite url for hyperswitch [mandates.supported_payment_methods] -card.credit = { connector_list = "stripe,adyen,cybersource" } # Mandate supported payment method type and connector for card +card.credit = { connector_list = "stripe,adyen,cybersource,bankofamerica"} # Mandate supported payment method type and connector for card wallet.paypal = { connector_list = "adyen" } # Mandate supported payment method type and connector for wallets pay_later.klarna = { connector_list = "adyen" } # Mandate supported payment method type and connector for pay_later bank_debit.ach = { connector_list = "gocardless" } # Mandate supported payment method type and connector for bank_debit @@ -391,7 +391,8 @@ bank_debit.becs = { connector_list = "gocardless" } # Mandat bank_debit.sepa = { connector_list = "gocardless" } # Mandate supported payment method type and connector for bank_debit bank_redirect.ideal = { connector_list = "stripe,adyen,globalpay" } # Mandate supported payment method type and connector for bank_redirect bank_redirect.sofort = { connector_list = "stripe,adyen,globalpay" } -wallet.apple_pay = { connector_list = "stripe,adyen,cybersource,noon" } +wallet.apple_pay = { connector_list = "stripe,adyen,cybersource,noon,bankofamerica" } +wallet.google_pay = { connector_list = "bankofamerica"} bank_redirect.giropay = { connector_list = "adyen,globalpay" } diff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.toml index 77040f79a4a1..50e1e63852f8 100644 --- a/config/deployments/integration_test.toml +++ b/config/deployments/integration_test.toml @@ -114,11 +114,11 @@ connectors_with_delayed_session_response = "trustpay,payme" bank_debit.ach.connector_list = "gocardless" bank_debit.becs.connector_list = "gocardless" bank_debit.sepa.connector_list = "gocardless" -card.credit.connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon" -card.debit.connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon" +card.credit.connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica" +card.debit.connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica" pay_later.klarna.connector_list = "adyen" -wallet.apple_pay.connector_list = "stripe,adyen,cybersource,noon" -wallet.google_pay.connector_list = "stripe,adyen,cybersource" +wallet.apple_pay.connector_list = "stripe,adyen,cybersource,noon,bankofamerica" +wallet.google_pay.connector_list = "stripe,adyen,cybersource,bankofamerica" wallet.paypal.connector_list = "adyen" bank_redirect.ideal.connector_list = "stripe,adyen,globalpay" bank_redirect.sofort.connector_list = "stripe,adyen,globalpay" diff --git a/config/deployments/production.toml b/config/deployments/production.toml index 23df14862b9b..d0981c0f6135 100644 --- a/config/deployments/production.toml +++ b/config/deployments/production.toml @@ -114,11 +114,11 @@ enabled = false bank_debit.ach.connector_list = "gocardless" bank_debit.becs.connector_list = "gocardless" bank_debit.sepa.connector_list = "gocardless" -card.credit.connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon" -card.debit.connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon" +card.credit.connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica" +card.debit.connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica" pay_later.klarna.connector_list = "adyen" -wallet.apple_pay.connector_list = "stripe,adyen,cybersource,noon" -wallet.google_pay.connector_list = "stripe,adyen,cybersource" +wallet.apple_pay.connector_list = "stripe,adyen,cybersource,noon,bankofamerica" +wallet.google_pay.connector_list = "stripe,adyen,cybersource,bankofamerica" wallet.paypal.connector_list = "adyen" bank_redirect.ideal.connector_list = "stripe,adyen,globalpay" bank_redirect.sofort.connector_list = "stripe,adyen,globalpay" diff --git a/config/deployments/sandbox.toml b/config/deployments/sandbox.toml index 8ae12dc54a62..1a272ad44327 100644 --- a/config/deployments/sandbox.toml +++ b/config/deployments/sandbox.toml @@ -114,11 +114,11 @@ enabled = true bank_debit.ach.connector_list = "gocardless" bank_debit.becs.connector_list = "gocardless" bank_debit.sepa.connector_list = "gocardless" -card.credit.connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon" -card.debit.connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon" +card.credit.connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica" +card.debit.connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica" pay_later.klarna.connector_list = "adyen" -wallet.apple_pay.connector_list = "stripe,adyen,cybersource,noon" -wallet.google_pay.connector_list = "stripe,adyen,cybersource" +wallet.apple_pay.connector_list = "stripe,adyen,cybersource,noon,bankofamerica" +wallet.google_pay.connector_list = "stripe,adyen,cybersource,bankofamerica" wallet.paypal.connector_list = "adyen" bank_redirect.ideal.connector_list = "stripe,adyen,globalpay" bank_redirect.sofort.connector_list = "stripe,adyen,globalpay" diff --git a/config/development.toml b/config/development.toml index 8ba5c076071a..7aaec8cc3a2b 100644 --- a/config/development.toml +++ b/config/development.toml @@ -495,11 +495,11 @@ connectors_with_webhook_source_verification_call = "paypal" [mandates.supported_payment_methods] pay_later.klarna = { connector_list = "adyen" } -wallet.google_pay = { connector_list = "stripe,adyen,cybersource" } -wallet.apple_pay = { connector_list = "stripe,adyen,cybersource,noon" } +wallet.google_pay = { connector_list = "stripe,adyen,cybersource,bankofamerica" } +wallet.apple_pay = { connector_list = "stripe,adyen,cybersource,noon,bankofamerica" } wallet.paypal = { connector_list = "adyen" } -card.credit = { connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon" } -card.debit = { connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon" } +card.credit = { connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica" } +card.debit = { connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica" } bank_debit.ach = { connector_list = "gocardless" } bank_debit.becs = { connector_list = "gocardless" } bank_debit.sepa = { connector_list = "gocardless" } diff --git a/config/docker_compose.toml b/config/docker_compose.toml index eb32b47e3b41..eaa7e92e14bf 100644 --- a/config/docker_compose.toml +++ b/config/docker_compose.toml @@ -365,11 +365,11 @@ adyen = { banks = "aib,bank_of_scotland,danske_bank,first_direct,first_trust,hal [mandates.supported_payment_methods] pay_later.klarna = { connector_list = "adyen" } -wallet.google_pay = { connector_list = "stripe,adyen" } -wallet.apple_pay = { connector_list = "stripe,adyen,cybersource,noon" } +wallet.google_pay = { connector_list = "stripe,adyen,bankofamerica" } +wallet.apple_pay = { connector_list = "stripe,adyen,cybersource,noon,bankofamerica" } wallet.paypal = { connector_list = "adyen" } -card.credit = { connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon" } -card.debit = { connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon" } +card.credit = { connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica" } +card.debit = { connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica" } bank_debit.ach = { connector_list = "gocardless" } bank_debit.becs = { connector_list = "gocardless" } bank_debit.sepa = { connector_list = "gocardless" } diff --git a/crates/router/src/connector/bankofamerica.rs b/crates/router/src/connector/bankofamerica.rs index 15c19622bc9a..0c01facf386b 100644 --- a/crates/router/src/connector/bankofamerica.rs +++ b/crates/router/src/connector/bankofamerica.rs @@ -12,7 +12,7 @@ use time::OffsetDateTime; use transformers as bankofamerica; use url::Url; -use super::utils::{PaymentsAuthorizeRequestData, RouterData}; +use super::utils::{PaymentsAuthorizeRequestData, PaymentsSetupMandateRequestData, RouterData}; use crate::{ configs::settings, connector::{utils as connector_utils, utils::RefundsRequestData}, @@ -288,19 +288,141 @@ impl types::PaymentsResponseData, > for Bankofamerica { + fn get_headers( + &self, + req: &types::SetupMandateRouterData, + connectors: &settings::Connectors, + ) -> CustomResult)>, errors::ConnectorError> { + self.build_headers(req, connectors) + } + fn get_content_type(&self) -> &'static str { + self.common_get_content_type() + } + fn get_url( + &self, + req: &types::SetupMandateRouterData, + connectors: &settings::Connectors, + ) -> CustomResult { + if req.is_three_ds() && req.request.is_card() { + Ok(format!( + "{}risk/v1/authentication-setups", + self.base_url(connectors) + )) + } else { + Ok(format!("{}pts/v2/payments/", self.base_url(connectors))) + } + } + fn get_request_body( + &self, + req: &types::SetupMandateRouterData, + _connectors: &settings::Connectors, + ) -> CustomResult { + if req.is_three_ds() && req.request.is_card() { + let connector_req = bankofamerica::BankOfAmericaAuthSetupRequest::try_from(( + &req.request.payment_method_data, + req.connector_request_reference_id.clone(), + ))?; + Ok(RequestContent::Json(Box::new(connector_req))) + } else { + let connector_req = bankofamerica::BankOfAmericaPaymentsRequest::try_from(req)?; + Ok(RequestContent::Json(Box::new(connector_req))) + } + } + fn build_request( &self, - _req: &types::RouterData< + req: &types::RouterData< api::SetupMandate, types::SetupMandateRequestData, types::PaymentsResponseData, >, - _connectors: &settings::Connectors, + connectors: &settings::Connectors, ) -> CustomResult, errors::ConnectorError> { - Err(errors::ConnectorError::NotImplemented( - "Setup Mandate flow for Bankofamerica".to_string(), - ) - .into()) + Ok(Some( + services::RequestBuilder::new() + .method(services::Method::Post) + .url(&types::SetupMandateType::get_url(self, req, connectors)?) + .attach_default_headers() + .headers(types::SetupMandateType::get_headers(self, req, connectors)?) + .set_body(types::SetupMandateType::get_request_body( + self, req, connectors, + )?) + .build(), + )) + } + fn handle_response( + &self, + data: &types::SetupMandateRouterData, + event_builder: Option<&mut ConnectorEvent>, + res: Response, + ) -> CustomResult { + if data.is_three_ds() && data.request.is_card() { + let response: bankofamerica::BankOfAmericaAuthSetupResponse = res + .response + .parse_struct("Bankofamerica AuthSetupResponse") + .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; + event_builder.map(|i| i.set_response_body(&response)); + router_env::logger::info!(connector_response=?response); + types::RouterData::try_from(types::ResponseRouterData { + response, + data: data.clone(), + http_code: res.status_code, + }) + } else { + let response: bankofamerica::BankOfAmericaSetupMandatesResponse = res + .response + .parse_struct("BankOfAmericaSetupMandatesResponse") + .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; + + event_builder.map(|i| i.set_response_body(&response)); + router_env::logger::info!(connector_response=?response); + + types::RouterData::try_from(types::ResponseRouterData { + response, + data: data.clone(), + http_code: res.status_code, + }) + } + } + + fn get_error_response( + &self, + res: Response, + event_builder: Option<&mut ConnectorEvent>, + ) -> CustomResult { + self.build_error_response(res, event_builder) + } + + fn get_5xx_error_response( + &self, + res: Response, + event_builder: Option<&mut ConnectorEvent>, + ) -> CustomResult { + let response: bankofamerica::BankOfAmericaServerErrorResponse = res + .response + .parse_struct("BankOfAmericaServerErrorResponse") + .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; + + event_builder.map(|event| event.set_response_body(&response)); + router_env::logger::info!(error_response=?response); + + let attempt_status = match response.reason { + Some(reason) => match reason { + transformers::Reason::SystemError => Some(enums::AttemptStatus::Failure), + transformers::Reason::ServerTimeout | transformers::Reason::ServiceTimeout => None, + }, + None => None, + }; + Ok(ErrorResponse { + status_code: res.status_code, + reason: response.status.clone(), + code: response.status.unwrap_or(consts::NO_ERROR_CODE.to_string()), + message: response + .message + .unwrap_or(consts::NO_ERROR_MESSAGE.to_string()), + attempt_status, + connector_transaction_id: None, + }) } } @@ -457,8 +579,10 @@ impl ConnectorIntegration>, + action_token_types: Option>, + authorization_options: Option, + commerce_indicator: String, capture: Option, + capture_options: Option, payment_solution: Option, - commerce_indicator: String, +} + +#[derive(Debug, Serialize)] +#[serde(rename_all = "SCREAMING_SNAKE_CASE")] +pub enum BankOfAmericaActionsList { + TokenCreate, +} + +#[derive(Debug, Serialize)] +#[serde(rename_all = "camelCase")] +pub enum BankOfAmericaActionsTokenType { + PaymentInstrument, +} + +#[derive(Debug, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct BankOfAmericaAuthorizationOptions { + initiator: Option, + merchant_intitiated_transaction: Option, +} + +#[derive(Debug, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct BankOfAmericaPaymentInitiator { + #[serde(rename = "type")] + initiator_type: Option, + credential_stored_on_file: Option, + stored_credential_used: Option, +} + +#[derive(Debug, Serialize)] +#[serde(rename_all = "camelCase")] +pub enum BankOfAmericaPaymentInitiatorTypes { + Customer, +} + +#[derive(Debug, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct MerchantInitiatedTransaction { + reason: Option, + //Required for recurring mandates payment + original_authorized_amount: Option, } #[derive(Debug, Serialize)] @@ -128,6 +175,11 @@ pub struct CaptureOptions { total_capture_count: u32, } +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct BankOfAmericaPaymentInstrument { + id: Secret, +} + #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] pub struct CardPaymentInformation { @@ -166,6 +218,13 @@ pub enum PaymentInformation { GooglePay(GooglePayPaymentInformation), ApplePay(ApplePayPaymentInformation), ApplePayToken(ApplePayTokenPaymentInformation), + MandatePayment(MandatePaymentInformation), +} + +#[derive(Debug, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct MandatePaymentInformation { + payment_instrument: BankOfAmericaPaymentInstrument, } #[derive(Debug, Serialize)] @@ -199,7 +258,7 @@ pub struct FluidData { #[serde(rename_all = "camelCase")] pub struct OrderInformationWithBill { amount_details: Amount, - bill_to: BillTo, + bill_to: Option, } #[derive(Debug, Serialize)] @@ -222,6 +281,138 @@ pub struct BillTo { email: pii::Email, } +impl TryFrom<&types::SetupMandateRouterData> for BankOfAmericaPaymentsRequest { + type Error = error_stack::Report; + fn try_from(item: &types::SetupMandateRouterData) -> Result { + match item.request.payment_method_data.clone() { + domain::PaymentMethodData::Card(card_data) => Self::try_from((item, card_data)), + domain::PaymentMethodData::Wallet(wallet_data) => match wallet_data { + payments::WalletData::ApplePay(apple_pay_data) => { + Self::try_from((item, apple_pay_data)) + } + payments::WalletData::GooglePay(google_pay_data) => { + Self::try_from((item, google_pay_data)) + } + payments::WalletData::AliPayQr(_) + | payments::WalletData::AliPayRedirect(_) + | payments::WalletData::AliPayHkRedirect(_) + | payments::WalletData::MomoRedirect(_) + | payments::WalletData::KakaoPayRedirect(_) + | payments::WalletData::GoPayRedirect(_) + | payments::WalletData::GcashRedirect(_) + | payments::WalletData::ApplePayRedirect(_) + | payments::WalletData::ApplePayThirdPartySdk(_) + | payments::WalletData::DanaRedirect {} + | payments::WalletData::GooglePayRedirect(_) + | payments::WalletData::GooglePayThirdPartySdk(_) + | payments::WalletData::MbWayRedirect(_) + | payments::WalletData::MobilePayRedirect(_) + | payments::WalletData::PaypalRedirect(_) + | payments::WalletData::PaypalSdk(_) + | payments::WalletData::SamsungPay(_) + | payments::WalletData::TwintRedirect {} + | payments::WalletData::VippsRedirect {} + | payments::WalletData::TouchNGoRedirect(_) + | payments::WalletData::WeChatPayRedirect(_) + | payments::WalletData::WeChatPayQr(_) + | payments::WalletData::CashappQr(_) + | payments::WalletData::SwishQr(_) => Err(errors::ConnectorError::NotImplemented( + utils::get_unimplemented_payment_method_error_message("BankOfAmerica"), + ))?, + }, + domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { + Err(errors::ConnectorError::NotImplemented( + utils::get_unimplemented_payment_method_error_message("BankOfAmerica"), + ))? + } + } + } +} + +impl + TryFrom< + types::ResponseRouterData< + F, + BankOfAmericaSetupMandatesResponse, + T, + types::PaymentsResponseData, + >, + > for types::RouterData +{ + type Error = error_stack::Report; + fn try_from( + item: types::ResponseRouterData< + F, + BankOfAmericaSetupMandatesResponse, + T, + types::PaymentsResponseData, + >, + ) -> Result { + match item.response { + BankOfAmericaSetupMandatesResponse::ClientReferenceInformation(info_response) => { + let mandate_reference = info_response.token_information.clone().map(|token_info| { + types::MandateReference { + connector_mandate_id: Some(token_info.payment_instrument.id.expose()), + payment_method_id: None, + } + }); + let mut mandate_status = + enums::AttemptStatus::foreign_from((info_response.status.clone(), false)); + if matches!(mandate_status, enums::AttemptStatus::Authorized) { + //In case of zero auth mandates we want to make the payment reach the terminal status so we are converting the authorized status to charged as well. + mandate_status = enums::AttemptStatus::Charged + } + let error_response = + get_error_response_if_failure((&info_response, mandate_status, item.http_code)); + + Ok(Self { + status: mandate_status, + response: match error_response { + Some(error) => Err(error), + None => Ok(types::PaymentsResponseData::TransactionResponse { + resource_id: types::ResponseId::ConnectorTransactionId( + info_response.id.clone(), + ), + redirection_data: None, + mandate_reference, + connector_metadata: None, + network_txn_id: None, + connector_response_reference_id: Some( + info_response + .client_reference_information + .code + .clone() + .unwrap_or(info_response.id), + ), + incremental_authorization_allowed: None, + }), + }, + ..item.data + }) + } + BankOfAmericaSetupMandatesResponse::ErrorInformation(ref error_response) => { + let response = Err(types::ErrorResponse::from((error_response, item.http_code))); + Ok(Self { + response, + status: enums::AttemptStatus::Failure, + ..item.data + }) + } + } + } +} + // for bankofamerica each item in Billing is mandatory fn build_bill_to( address_details: &payments::Address, @@ -287,13 +478,13 @@ pub enum TransactionType { impl From<( &BankOfAmericaRouterData<&types::PaymentsAuthorizeRouterData>, - BillTo, + Option, )> for OrderInformationWithBill { fn from( (item, bill_to): ( &BankOfAmericaRouterData<&types::PaymentsAuthorizeRouterData>, - BillTo, + Option, ), ) -> Self { Self { @@ -323,44 +514,86 @@ impl total_amount: item.amount.to_owned(), currency: item.router_data.request.currency, }, - bill_to, + bill_to: Some(bill_to), } } } impl - From<( + TryFrom<( &BankOfAmericaRouterData<&types::PaymentsAuthorizeRouterData>, Option, Option, )> for ProcessingInformation { - fn from( + type Error = error_stack::Report; + + fn try_from( (item, solution, network): ( &BankOfAmericaRouterData<&types::PaymentsAuthorizeRouterData>, Option, Option, ), - ) -> Self { - let commerce_indicator = match network { - Some(card_network) => match card_network.to_lowercase().as_str() { - "amex" => "aesk", - "discover" => "dipb", - "mastercard" => "spa", - "visa" => "internet", - _ => "internet", - }, - None => "internet", - } - .to_string(); - Self { + ) -> Result { + let (action_list, action_token_types, authorization_options) = if item + .router_data + .request + .setup_future_usage + .map_or(false, |future_usage| { + matches!(future_usage, common_enums::FutureUsage::OffSession) + }) + && (item.router_data.request.customer_acceptance.is_some() + || item + .router_data + .request + .setup_mandate_details + .clone() + .map_or(false, |mandate_details| { + mandate_details.customer_acceptance.is_some() + })) { + get_boa_mandate_action_details() + } else if item.router_data.request.connector_mandate_id().is_some() { + let original_amount = item + .router_data + .get_recurring_mandate_payment_data()? + .get_original_payment_amount()?; + let original_currency = item + .router_data + .get_recurring_mandate_payment_data()? + .get_original_payment_currency()?; + ( + None, + None, + Some(BankOfAmericaAuthorizationOptions { + initiator: None, + merchant_intitiated_transaction: Some(MerchantInitiatedTransaction { + reason: None, + original_authorized_amount: Some(utils::get_amount_as_string( + &types::api::CurrencyUnit::Base, + original_amount, + original_currency, + )?), + }), + }), + ) + } else { + (None, None, None) + }; + + let commerce_indicator = get_commerce_indicator(network); + + Ok(Self { capture: Some(matches!( item.router_data.request.capture_method, Some(enums::CaptureMethod::Automatic) | None )), payment_solution: solution.map(String::from), + action_list, + action_token_types, + authorization_options, + capture_options: None, commerce_indicator, - } + }) } } @@ -378,12 +611,42 @@ impl &BankOfAmericaConsumerAuthValidateResponse, ), ) -> Self { - Self { - capture: Some(matches!( + let (action_list, action_token_types, authorization_options) = + if is_customer_initiated_mandate_payment(&item.router_data.request) { + ( + Some(vec![BankOfAmericaActionsList::TokenCreate]), + Some(vec![BankOfAmericaActionsTokenType::PaymentInstrument]), + Some(BankOfAmericaAuthorizationOptions { + initiator: Some(BankOfAmericaPaymentInitiator { + initiator_type: Some(BankOfAmericaPaymentInitiatorTypes::Customer), + credential_stored_on_file: Some(true), + stored_credential_used: None, + }), + merchant_intitiated_transaction: None, + }), + ) + } else { + (None, None, None) + }; + + let is_setup_mandate_payment = is_setup_mandate_payment(&item.router_data.request); + + let capture = if is_setup_mandate_payment { + Some(false) + } else { + Some(matches!( item.router_data.request.capture_method, Some(enums::CaptureMethod::Automatic) | None - )), + )) + }; + + Self { + capture, payment_solution: solution.map(String::from), + action_list, + action_token_types, + authorization_options, + capture_options: None, commerce_indicator: three_ds_data .indicator .to_owned() @@ -412,6 +675,14 @@ impl From<&BankOfAmericaRouterData<&types::PaymentsCompleteAuthorizeRouterData>> } } +impl From<&types::SetupMandateRouterData> for ClientReferenceInformation { + fn from(item: &types::SetupMandateRouterData) -> Self { + Self { + code: Some(item.connector_request_reference_id.clone()), + } + } +} + impl ForeignFrom for Vec { fn foreign_from(metadata: Value) -> Self { let hashmap: std::collections::BTreeMap = @@ -441,7 +712,6 @@ pub struct ClientReferenceInformation { pub struct ClientProcessorInformation { avs: Option, } - #[derive(Debug, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct ClientRiskInformation { @@ -477,21 +747,7 @@ impl let bill_to = build_bill_to(item.router_data.get_billing()?, email)?; let order_information = OrderInformationWithBill::from((item, bill_to)); - let card_issuer = ccard.get_card_issuer(); - let card_type = match card_issuer { - Ok(issuer) => Some(String::from(issuer)), - Err(_) => None, - }; - - let payment_information = PaymentInformation::Cards(CardPaymentInformation { - card: Card { - number: ccard.card_number, - expiration_month: ccard.card_exp_month, - expiration_year: ccard.card_exp_year, - security_code: ccard.card_cvc, - card_type, - }, - }); + let payment_information = PaymentInformation::try_from(&ccard)?; let client_reference_information = ClientReferenceInformation::from(item); let three_ds_info: BankOfAmericaThreeDSMetadata = item @@ -552,22 +808,9 @@ impl ) -> Result { let email = item.router_data.request.get_email()?; let bill_to = build_bill_to(item.router_data.get_billing()?, email)?; - let order_information = OrderInformationWithBill::from((item, bill_to)); - let card_issuer = ccard.get_card_issuer(); - let card_type = match card_issuer { - Ok(issuer) => Some(String::from(issuer)), - Err(_) => None, - }; - let payment_information = PaymentInformation::Cards(CardPaymentInformation { - card: Card { - number: ccard.card_number, - expiration_month: ccard.card_exp_month, - expiration_year: ccard.card_exp_year, - security_code: ccard.card_cvc, - card_type, - }, - }); - let processing_information = ProcessingInformation::from((item, None, None)); + let order_information = OrderInformationWithBill::from((item, Some(bill_to))); + let payment_information = PaymentInformation::try_from(&ccard)?; + let processing_information = ProcessingInformation::try_from((item, None, None))?; let client_reference_information = ClientReferenceInformation::from(item); let merchant_defined_information = item.router_data.request.metadata.clone().map(|metadata| { @@ -602,24 +845,14 @@ impl ) -> Result { let email = item.router_data.request.get_email()?; let bill_to = build_bill_to(item.router_data.get_billing()?, email)?; - let order_information = OrderInformationWithBill::from((item, bill_to)); - let processing_information = ProcessingInformation::from(( + let order_information = OrderInformationWithBill::from((item, Some(bill_to))); + let processing_information = ProcessingInformation::try_from(( item, Some(PaymentSolution::ApplePay), Some(apple_pay_wallet_data.payment_method.network.clone()), - )); + ))?; let client_reference_information = ClientReferenceInformation::from(item); - let expiration_month = apple_pay_data.get_expiry_month()?; - let expiration_year = apple_pay_data.get_four_digit_expiry_year()?; - let payment_information = PaymentInformation::ApplePay(ApplePayPaymentInformation { - tokenized_card: TokenizedCard { - number: apple_pay_data.application_primary_account_number, - cryptogram: apple_pay_data.payment_data.online_payment_cryptogram, - transaction_type: TransactionType::ApplePay, - expiration_year, - expiration_month, - }, - }); + let payment_information = PaymentInformation::try_from(&apple_pay_data)?; let merchant_defined_information = item.router_data.request.metadata.clone().map(|metadata| { Vec::::foreign_from(metadata.peek().to_owned()) @@ -666,16 +899,10 @@ impl ) -> Result { let email = item.router_data.request.get_email()?; let bill_to = build_bill_to(item.router_data.get_billing()?, email)?; - let order_information = OrderInformationWithBill::from((item, bill_to)); - let payment_information = PaymentInformation::GooglePay(GooglePayPaymentInformation { - fluid_data: FluidData { - value: Secret::from( - consts::BASE64_ENGINE.encode(google_pay_data.tokenization_data.token), - ), - }, - }); + let order_information = OrderInformationWithBill::from((item, Some(bill_to))); + let payment_information = PaymentInformation::from(&google_pay_data); let processing_information = - ProcessingInformation::from((item, Some(PaymentSolution::GooglePay), None)); + ProcessingInformation::try_from((item, Some(PaymentSolution::GooglePay), None))?; let client_reference_information = ClientReferenceInformation::from(item); let merchant_defined_information = item.router_data.request.metadata.clone().map(|metadata| { @@ -698,128 +925,145 @@ impl TryFrom<&BankOfAmericaRouterData<&types::PaymentsAuthorizeRouterData>> { type Error = error_stack::Report; fn try_from( - item: &BankOfAmericaRouterData<&types::PaymentsAuthorizeRouterData>, - ) -> Result { - match item.router_data.request.payment_method_data.clone() { - domain::PaymentMethodData::Card(ccard) => Self::try_from((item, ccard)), - domain::PaymentMethodData::Wallet(wallet_data) => match wallet_data { - payments::WalletData::ApplePay(apple_pay_data) => { - match item.router_data.payment_method_token.clone() { - Some(payment_method_token) => match payment_method_token { - types::PaymentMethodToken::ApplePayDecrypt(decrypt_data) => { - Self::try_from((item, decrypt_data, apple_pay_data)) - } - types::PaymentMethodToken::Token(_) => { - Err(unimplemented_payment_method!( - "Apple Pay", - "Manual", - "Bank Of America" - ))? - } - }, - None => { - let email = item.router_data.request.get_email()?; - let bill_to = build_bill_to(item.router_data.get_billing()?, email)?; - let order_information = OrderInformationWithBill::from((item, bill_to)); - let processing_information = ProcessingInformation::from(( - item, - Some(PaymentSolution::ApplePay), - Some(apple_pay_data.payment_method.network.clone()), - )); - let client_reference_information = - ClientReferenceInformation::from(item); - let payment_information = PaymentInformation::ApplePayToken( - ApplePayTokenPaymentInformation { - fluid_data: FluidData { - value: Secret::from(apple_pay_data.payment_data), - }, - tokenized_card: ApplePayTokenizedCard { - transaction_type: TransactionType::ApplePay, - }, - }, - ); - let merchant_defined_information = - item.router_data.request.metadata.clone().map(|metadata| { - Vec::::foreign_from( - metadata.peek().to_owned(), - ) - }); - 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, - merchant_defined_information, - client_reference_information, - consumer_authentication_information: Some( - BankOfAmericaConsumerAuthInformation { - ucaf_collection_indicator, - cavv: None, - ucaf_authentication_data: None, - xid: None, - directory_server_transaction_id: None, - specification_version: None, - }, - ), - }) - } - } - } - payments::WalletData::GooglePay(google_pay_data) => { - Self::try_from((item, google_pay_data)) - } - payments::WalletData::AliPayQr(_) - | payments::WalletData::AliPayRedirect(_) - | payments::WalletData::AliPayHkRedirect(_) - | payments::WalletData::MomoRedirect(_) - | payments::WalletData::KakaoPayRedirect(_) - | payments::WalletData::GoPayRedirect(_) - | payments::WalletData::GcashRedirect(_) - | payments::WalletData::ApplePayRedirect(_) - | payments::WalletData::ApplePayThirdPartySdk(_) - | payments::WalletData::DanaRedirect {} - | payments::WalletData::GooglePayRedirect(_) - | payments::WalletData::GooglePayThirdPartySdk(_) - | payments::WalletData::MbWayRedirect(_) - | payments::WalletData::MobilePayRedirect(_) - | payments::WalletData::PaypalRedirect(_) - | payments::WalletData::PaypalSdk(_) - | payments::WalletData::SamsungPay(_) - | payments::WalletData::TwintRedirect {} - | payments::WalletData::VippsRedirect {} - | payments::WalletData::TouchNGoRedirect(_) - | payments::WalletData::WeChatPayRedirect(_) - | payments::WalletData::WeChatPayQr(_) - | payments::WalletData::CashappQr(_) - | payments::WalletData::SwishQr(_) => Err(errors::ConnectorError::NotImplemented( - utils::get_unimplemented_payment_method_error_message("Bank of America"), - ) - .into()), - }, - domain::PaymentMethodData::CardRedirect(_) - | domain::PaymentMethodData::PayLater(_) - | domain::PaymentMethodData::BankRedirect(_) - | domain::PaymentMethodData::BankDebit(_) - | domain::PaymentMethodData::BankTransfer(_) - | domain::PaymentMethodData::Crypto(_) - | domain::PaymentMethodData::MandatePayment - | domain::PaymentMethodData::Reward - | domain::PaymentMethodData::Upi(_) - | domain::PaymentMethodData::Voucher(_) - | domain::PaymentMethodData::GiftCard(_) - | domain::PaymentMethodData::CardToken(_) => { - Err(errors::ConnectorError::NotImplemented( - utils::get_unimplemented_payment_method_error_message("Bank of America"), - ) - .into()) + item: &BankOfAmericaRouterData<&types::PaymentsAuthorizeRouterData>, + ) -> Result { + match item.router_data.request.connector_mandate_id() { + Some(connector_mandate_id) => Self::try_from((item, connector_mandate_id)), + None => { + match item.router_data.request.payment_method_data.clone() { + domain::PaymentMethodData::Card(ccard) => Self::try_from((item, ccard)), + domain::PaymentMethodData::Wallet(wallet_data) => match wallet_data { + payments::WalletData::ApplePay(apple_pay_data) => { + match item.router_data.payment_method_token.clone() { + Some(payment_method_token) => match payment_method_token { + types::PaymentMethodToken::ApplePayDecrypt(decrypt_data) => { + Self::try_from((item, decrypt_data, apple_pay_data)) + } + types::PaymentMethodToken::Token(_) => { + Err(unimplemented_payment_method!( + "Apple Pay", + "Manual", + "Bank Of America" + ))? + } + }, + None => { + let email = item.router_data.request.get_email()?; + let bill_to = + build_bill_to(item.router_data.get_billing()?, email)?; + let order_information: OrderInformationWithBill = + 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 payment_information = + PaymentInformation::from(&apple_pay_data); + let merchant_defined_information = + item.router_data.request.metadata.clone().map(|metadata| { + Vec::::foreign_from( + metadata.peek().to_owned(), + ) + }); + 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, + merchant_defined_information, + client_reference_information, + consumer_authentication_information: Some( + BankOfAmericaConsumerAuthInformation { + ucaf_collection_indicator, + cavv: None, + ucaf_authentication_data: None, + xid: None, + directory_server_transaction_id: None, + specification_version: None, + }, + ), + }) + } + } + } + payments::WalletData::GooglePay(google_pay_data) => { + Self::try_from((item, google_pay_data)) + } + + payments::WalletData::AliPayQr(_) + | payments::WalletData::AliPayRedirect(_) + | payments::WalletData::AliPayHkRedirect(_) + | payments::WalletData::MomoRedirect(_) + | payments::WalletData::KakaoPayRedirect(_) + | payments::WalletData::GoPayRedirect(_) + | payments::WalletData::GcashRedirect(_) + | payments::WalletData::ApplePayRedirect(_) + | payments::WalletData::ApplePayThirdPartySdk(_) + | payments::WalletData::DanaRedirect {} + | payments::WalletData::GooglePayRedirect(_) + | payments::WalletData::GooglePayThirdPartySdk(_) + | payments::WalletData::MbWayRedirect(_) + | payments::WalletData::MobilePayRedirect(_) + | payments::WalletData::PaypalRedirect(_) + | payments::WalletData::PaypalSdk(_) + | payments::WalletData::SamsungPay(_) + | payments::WalletData::TwintRedirect {} + | payments::WalletData::VippsRedirect {} + | payments::WalletData::TouchNGoRedirect(_) + | payments::WalletData::WeChatPayRedirect(_) + | payments::WalletData::WeChatPayQr(_) + | payments::WalletData::CashappQr(_) + | payments::WalletData::SwishQr(_) => { + Err(errors::ConnectorError::NotImplemented( + utils::get_unimplemented_payment_method_error_message( + "Bank of America", + ), + ) + .into()) + } + }, + // If connector_mandate_id is present MandatePayment will be the PMD, the case will be handled in the first `if` clause. + // This is a fallback implementation in the event of catastrophe. + domain::PaymentMethodData::MandatePayment => { + let connector_mandate_id = + item.router_data.request.connector_mandate_id().ok_or( + errors::ConnectorError::MissingRequiredField { + field_name: "connector_mandate_id", + }, + )?; + Self::try_from((item, connector_mandate_id)) + } + domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Upi(_) + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => { + Err(errors::ConnectorError::NotImplemented( + utils::get_unimplemented_payment_method_error_message( + "Bank of America", + ), + ) + .into()) + } + } } } } @@ -832,30 +1076,18 @@ pub struct BankOfAmericaAuthSetupRequest { client_reference_information: ClientReferenceInformation, } -impl TryFrom<&BankOfAmericaRouterData<&types::PaymentsAuthorizeRouterData>> - for BankOfAmericaAuthSetupRequest -{ +impl TryFrom<(&domain::PaymentMethodData, String)> for BankOfAmericaAuthSetupRequest { type Error = error_stack::Report; fn try_from( - item: &BankOfAmericaRouterData<&types::PaymentsAuthorizeRouterData>, + (payment_method_data, connector_request_reference_id): (&domain::PaymentMethodData, String), ) -> Result { - match item.router_data.request.payment_method_data.clone() { + match payment_method_data.clone() { domain::PaymentMethodData::Card(ccard) => { - let card_issuer = ccard.get_card_issuer(); - let card_type = match card_issuer { - Ok(issuer) => Some(String::from(issuer)), - Err(_) => None, + let payment_information = PaymentInformation::try_from(&ccard)?; + let client_reference_information = ClientReferenceInformation { + code: Some(connector_request_reference_id), }; - let payment_information = PaymentInformation::Cards(CardPaymentInformation { - card: Card { - number: ccard.card_number, - expiration_month: ccard.card_exp_month, - expiration_year: ccard.card_exp_year, - security_code: ccard.card_cvc, - card_type, - }, - }); - let client_reference_information = ClientReferenceInformation::from(item); + Ok(Self { payment_information, client_reference_information, @@ -875,7 +1107,7 @@ impl TryFrom<&BankOfAmericaRouterData<&types::PaymentsAuthorizeRouterData>> | domain::PaymentMethodData::GiftCard(_) | domain::PaymentMethodData::CardToken(_) => { Err(errors::ConnectorError::NotImplemented( - utils::get_unimplemented_payment_method_error_message("BankOfAmerica"), + utils::get_unimplemented_payment_method_error_message("Bank Of America"), ) .into()) } @@ -883,6 +1115,49 @@ impl TryFrom<&BankOfAmericaRouterData<&types::PaymentsAuthorizeRouterData>> } } +impl + TryFrom<( + &BankOfAmericaRouterData<&types::PaymentsAuthorizeRouterData>, + String, + )> for BankOfAmericaPaymentsRequest +{ + type Error = error_stack::Report; + fn try_from( + (item, connector_mandate_id): ( + &BankOfAmericaRouterData<&types::PaymentsAuthorizeRouterData>, + String, + ), + ) -> Result { + let processing_information = ProcessingInformation::try_from((item, None, None))?; + let payment_instrument = BankOfAmericaPaymentInstrument { + id: connector_mandate_id.into(), + }; + let email = item.router_data.request.get_email().ok(); + let bill_to = email.and_then(|email_id| { + item.router_data + .get_billing() + .ok() + .and_then(|billing_details| build_bill_to(billing_details, email_id).ok()) + }); + let order_information = OrderInformationWithBill::from((item, bill_to)); + let payment_information = + PaymentInformation::MandatePayment(MandatePaymentInformation { payment_instrument }); + let client_reference_information = ClientReferenceInformation::from(item); + let merchant_defined_information = + item.router_data.request.metadata.clone().map(|metadata| { + Vec::::foreign_from(metadata.peek().to_owned()) + }); + Ok(Self { + processing_information, + payment_information, + order_information, + client_reference_information, + merchant_defined_information, + consumer_authentication_information: None, + }) + } +} + #[derive(Clone, Debug, Deserialize, Serialize)] #[serde(rename_all = "SCREAMING_SNAKE_CASE")] pub enum BankofamericaPaymentStatus { @@ -976,6 +1251,13 @@ pub enum BankOfAmericaPaymentsResponse { ErrorInformation(BankOfAmericaErrorInformationResponse), } +#[derive(Debug, Deserialize, Serialize)] +#[serde(untagged)] +pub enum BankOfAmericaSetupMandatesResponse { + ClientReferenceInformation(BankOfAmericaClientReferenceResponse), + ErrorInformation(BankOfAmericaErrorInformationResponse), +} + #[derive(Clone, Debug, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct BankOfAmericaClientReferenceResponse { @@ -984,9 +1266,16 @@ pub struct BankOfAmericaClientReferenceResponse { client_reference_information: ClientReferenceInformation, processor_information: Option, risk_information: Option, + token_information: Option, error_information: Option, } +#[derive(Debug, Clone, Deserialize, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct BankOfAmericaTokenInformation { + payment_instrument: BankOfAmericaPaymentInstrument, +} + #[derive(Clone, Debug, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct BankOfAmericaErrorInformationResponse { @@ -1078,10 +1367,20 @@ fn get_payment_response( let error_response = get_error_response_if_failure((info_response, status, http_code)); match error_response { Some(error) => Err(error), - None => Ok(types::PaymentsResponseData::TransactionResponse { + None => { + let mandate_reference = + info_response + .token_information + .clone() + .map(|token_info| types::MandateReference { + connector_mandate_id: Some(token_info.payment_instrument.id.expose()), + payment_method_id: None, + }); + + Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::ConnectorTransactionId(info_response.id.clone()), redirection_data: None, - mandate_reference: None, + mandate_reference, connector_metadata: info_response .processor_information .as_ref() @@ -1095,26 +1394,27 @@ fn get_payment_response( .unwrap_or(info_response.id.clone()), ), incremental_authorization_allowed: None, - }), + }) + } } } -impl +impl TryFrom< types::ResponseRouterData< F, BankOfAmericaAuthSetupResponse, - types::PaymentsAuthorizeData, + T, types::PaymentsResponseData, >, - > for types::RouterData + > for types::RouterData { type Error = error_stack::Report; fn try_from( item: types::ResponseRouterData< F, BankOfAmericaAuthSetupResponse, - types::PaymentsAuthorizeData, + T, types::PaymentsResponseData, >, ) -> Result { @@ -1233,22 +1533,7 @@ impl TryFrom<&BankOfAmericaRouterData<&types::PaymentsPreProcessingRouterData>> }, )?; let payment_information = match payment_method_data { - domain::PaymentMethodData::Card(ccard) => { - let card_issuer = ccard.get_card_issuer(); - let card_type = match card_issuer { - Ok(issuer) => Some(String::from(issuer)), - Err(_) => None, - }; - Ok(PaymentInformation::Cards(CardPaymentInformation { - card: Card { - number: ccard.card_number, - expiration_month: ccard.card_exp_month, - expiration_year: ccard.card_exp_year, - security_code: ccard.card_cvc, - card_type, - }, - })) - } + domain::PaymentMethodData::Card(ccard) => PaymentInformation::try_from(&ccard), domain::PaymentMethodData::Wallet(_) | domain::PaymentMethodData::CardRedirect(_) | domain::PaymentMethodData::PayLater(_) @@ -1264,7 +1549,8 @@ impl TryFrom<&BankOfAmericaRouterData<&types::PaymentsPreProcessingRouterData>> | domain::PaymentMethodData::CardToken(_) => { Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("BankOfAmerica"), - )) + ) + .into()) } }?; @@ -1298,7 +1584,7 @@ impl TryFrom<&BankOfAmericaRouterData<&types::PaymentsPreProcessingRouterData>> let bill_to = build_bill_to(item.router_data.get_billing()?, email)?; let order_information = OrderInformationWithBill { amount_details, - bill_to, + bill_to: Some(bill_to), }; Ok(Self::AuthEnrollment(BankOfAmericaAuthEnrollmentRequest { payment_information, @@ -1520,22 +1806,7 @@ impl } } BankOfAmericaPreProcessingResponse::ErrorInformation(ref error_response) => { - let error_reason = error_response - .error_information - .message - .to_owned() - .unwrap_or(consts::NO_ERROR_MESSAGE.to_string()); - let error_message = error_response.error_information.reason.to_owned(); - let response = Err(types::ErrorResponse { - code: error_message - .clone() - .unwrap_or(consts::NO_ERROR_CODE.to_string()), - message: error_message.unwrap_or(consts::NO_ERROR_MESSAGE.to_string()), - reason: Some(error_reason), - status_code: item.http_code, - attempt_status: None, - connector_transaction_id: Some(error_response.id.clone()), - }); + let response = Err(types::ErrorResponse::from((error_response, item.http_code))); Ok(Self { response, status: enums::AttemptStatus::AuthenticationFailed, @@ -1569,7 +1840,8 @@ impl BankOfAmericaPaymentsResponse::ClientReferenceInformation(info_response) => { let status = enums::AttemptStatus::foreign_from(( info_response.status.clone(), - item.data.request.is_auto_capture()?, + item.data.request.is_auto_capture()? + || is_setup_mandate_payment(&item.data.request), )); let response = get_payment_response((&info_response, status, item.http_code)); Ok(Self { @@ -2116,3 +2388,289 @@ impl } } } + +impl TryFrom<(&types::SetupMandateRouterData, domain::Card)> for BankOfAmericaPaymentsRequest { + type Error = error_stack::Report; + fn try_from( + (item, ccard): (&types::SetupMandateRouterData, domain::Card), + ) -> Result { + let order_information = OrderInformationWithBill::try_from(item)?; + let client_reference_information = ClientReferenceInformation::from(item); + let merchant_defined_information = item.request.metadata.clone().map(|metadata| { + Vec::::foreign_from(metadata.peek().to_owned()) + }); + let payment_information = PaymentInformation::try_from(&ccard)?; + let processing_information = ProcessingInformation::try_from((None, None))?; + Ok(Self { + processing_information, + payment_information, + order_information, + client_reference_information, + consumer_authentication_information: None, + merchant_defined_information, + }) + } +} + +impl TryFrom<(&types::SetupMandateRouterData, payments::ApplePayWalletData)> + for BankOfAmericaPaymentsRequest +{ + type Error = error_stack::Report; + fn try_from( + (item, apple_pay_data): (&types::SetupMandateRouterData, payments::ApplePayWalletData), + ) -> Result { + let order_information = OrderInformationWithBill::try_from(item)?; + let client_reference_information = ClientReferenceInformation::from(item); + let merchant_defined_information = item.request.metadata.clone().map(|metadata| { + Vec::::foreign_from(metadata.peek().to_owned()) + }); + let payment_information = match item.payment_method_token.clone() { + Some(payment_method_token) => match payment_method_token { + types::PaymentMethodToken::ApplePayDecrypt(decrypt_data) => { + PaymentInformation::try_from(&decrypt_data)? + } + types::PaymentMethodToken::Token(_) => Err(unimplemented_payment_method!( + "Apple Pay", + "Manual", + "Bank Of America" + ))?, + }, + None => PaymentInformation::from(&apple_pay_data), + }; + let processing_information = ProcessingInformation::try_from(( + Some(PaymentSolution::ApplePay), + Some(apple_pay_data.payment_method.network.clone()), + ))?; + let ucaf_collection_indicator = match apple_pay_data + .payment_method + .network + .to_lowercase() + .as_str() + { + "mastercard" => Some("2".to_string()), + _ => None, + }; + let consumer_authentication_information = Some(BankOfAmericaConsumerAuthInformation { + ucaf_collection_indicator, + cavv: None, + ucaf_authentication_data: None, + xid: None, + directory_server_transaction_id: None, + specification_version: None, + }); + + Ok(Self { + processing_information, + payment_information, + order_information, + client_reference_information, + merchant_defined_information, + consumer_authentication_information, + }) + } +} + +impl + TryFrom<( + &types::SetupMandateRouterData, + payments::GooglePayWalletData, + )> for BankOfAmericaPaymentsRequest +{ + type Error = error_stack::Report; + fn try_from( + (item, google_pay_data): ( + &types::SetupMandateRouterData, + payments::GooglePayWalletData, + ), + ) -> Result { + let order_information = OrderInformationWithBill::try_from(item)?; + let client_reference_information = ClientReferenceInformation::from(item); + let merchant_defined_information = item.request.metadata.clone().map(|metadata| { + Vec::::foreign_from(metadata.peek().to_owned()) + }); + let payment_information = PaymentInformation::from(&google_pay_data); + let processing_information = + ProcessingInformation::try_from((Some(PaymentSolution::GooglePay), None))?; + + Ok(Self { + processing_information, + payment_information, + order_information, + client_reference_information, + merchant_defined_information, + consumer_authentication_information: None, + }) + } +} + +// specific for setupMandate flow +impl TryFrom<(Option, Option)> for ProcessingInformation { + type Error = error_stack::Report; + fn try_from( + (solution, network): (Option, Option), + ) -> Result { + let (action_list, action_token_types, authorization_options) = + get_boa_mandate_action_details(); + let commerce_indicator = get_commerce_indicator(network); + + Ok(Self { + capture: Some(false), + capture_options: None, + action_list, + action_token_types, + authorization_options, + commerce_indicator, + payment_solution: solution.map(String::from), + }) + } +} + +impl TryFrom<&types::SetupMandateRouterData> for OrderInformationWithBill { + type Error = error_stack::Report; + + fn try_from(item: &types::SetupMandateRouterData) -> Result { + let email = item.request.get_email()?; + let bill_to = build_bill_to(item.get_billing()?, email)?; + + Ok(Self { + amount_details: Amount { + total_amount: "0".to_string(), + currency: item.request.currency, + }, + bill_to: Some(bill_to), + }) + } +} + +impl TryFrom<&domain::Card> for PaymentInformation { + type Error = error_stack::Report; + + fn try_from(ccard: &domain::Card) -> Result { + let card_issuer = ccard.get_card_issuer(); + let card_type = match card_issuer { + Ok(issuer) => Some(String::from(issuer)), + Err(_) => None, + }; + Ok(Self::Cards(CardPaymentInformation { + card: Card { + number: ccard.card_number.clone(), + expiration_month: ccard.card_exp_month.clone(), + expiration_year: ccard.card_exp_year.clone(), + security_code: ccard.card_cvc.clone(), + card_type, + }, + })) + } +} + +impl TryFrom<&Box> for PaymentInformation { + type Error = error_stack::Report; + + fn try_from(apple_pay_data: &Box) -> Result { + let expiration_month = apple_pay_data.get_expiry_month()?; + let expiration_year = apple_pay_data.get_four_digit_expiry_year()?; + + Ok(Self::ApplePay(ApplePayPaymentInformation { + tokenized_card: TokenizedCard { + number: apple_pay_data.application_primary_account_number.clone(), + cryptogram: apple_pay_data + .payment_data + .online_payment_cryptogram + .clone(), + transaction_type: TransactionType::ApplePay, + expiration_year, + expiration_month, + }, + })) + } +} + +impl From<&payments::ApplePayWalletData> for PaymentInformation { + fn from(apple_pay_data: &payments::ApplePayWalletData) -> Self { + Self::ApplePayToken(ApplePayTokenPaymentInformation { + fluid_data: FluidData { + value: Secret::from(apple_pay_data.payment_data.clone()), + }, + tokenized_card: ApplePayTokenizedCard { + transaction_type: TransactionType::ApplePay, + }, + }) + } +} + +impl From<&payments::GooglePayWalletData> for PaymentInformation { + fn from(google_pay_data: &payments::GooglePayWalletData) -> Self { + Self::GooglePay(GooglePayPaymentInformation { + fluid_data: FluidData { + value: Secret::from( + consts::BASE64_ENGINE.encode(google_pay_data.tokenization_data.token.clone()), + ), + }, + }) + } +} + +impl From<(&BankOfAmericaErrorInformationResponse, u16)> for types::ErrorResponse { + fn from((error_response, status_code): (&BankOfAmericaErrorInformationResponse, u16)) -> Self { + let error_reason = error_response + .error_information + .message + .to_owned() + .unwrap_or(consts::NO_ERROR_MESSAGE.to_string()); + let error_message = error_response.error_information.reason.to_owned(); + Self { + code: error_message + .clone() + .unwrap_or(consts::NO_ERROR_CODE.to_string()), + message: error_message.unwrap_or(consts::NO_ERROR_MESSAGE.to_string()), + reason: Some(error_reason), + status_code, + attempt_status: None, + connector_transaction_id: Some(error_response.id.clone()), + } + } +} + +fn get_boa_mandate_action_details() -> ( + Option>, + Option>, + Option, +) { + ( + Some(vec![BankOfAmericaActionsList::TokenCreate]), + Some(vec![BankOfAmericaActionsTokenType::PaymentInstrument]), + Some(BankOfAmericaAuthorizationOptions { + initiator: Some(BankOfAmericaPaymentInitiator { + initiator_type: Some(BankOfAmericaPaymentInitiatorTypes::Customer), + credential_stored_on_file: Some(true), + stored_credential_used: None, + }), + merchant_intitiated_transaction: None, + }), + ) +} + +fn get_commerce_indicator(network: Option) -> String { + match network { + Some(card_network) => match card_network.to_lowercase().as_str() { + "amex" => "aesk", + "discover" => "dipb", + "mastercard" => "spa", + "visa" => "internet", + _ => "internet", + }, + None => "internet", + } + .to_string() +} + +fn is_setup_mandate_payment(item: &types::CompleteAuthorizeData) -> bool { + matches!(item.amount, 0) && is_customer_initiated_mandate_payment(item) +} + +fn is_customer_initiated_mandate_payment(item: &types::CompleteAuthorizeData) -> bool { + item.setup_future_usage.map_or(false, |future_usage| { + matches!(future_usage, common_enums::FutureUsage::OffSession) + }) + // add check for customer_acceptance +} diff --git a/crates/router/src/connector/utils.rs b/crates/router/src/connector/utils.rs index 37f06ad9ce1b..5bdf8b501ad7 100644 --- a/crates/router/src/connector/utils.rs +++ b/crates/router/src/connector/utils.rs @@ -460,6 +460,7 @@ impl RevokeMandateRequestData for types::MandateRevokeRequestData { pub trait PaymentsSetupMandateRequestData { fn get_browser_info(&self) -> Result; fn get_email(&self) -> Result; + fn is_card(&self) -> bool; } impl PaymentsSetupMandateRequestData for types::SetupMandateRequestData { @@ -471,6 +472,9 @@ impl PaymentsSetupMandateRequestData for types::SetupMandateRequestData { fn get_email(&self) -> Result { self.email.clone().ok_or_else(missing_field_err("email")) } + fn is_card(&self) -> bool { + matches!(self.payment_method_data, domain::PaymentMethodData::Card(_)) + } } pub trait PaymentsAuthorizeRequestData { fn is_auto_capture(&self) -> Result; diff --git a/loadtest/config/development.toml b/loadtest/config/development.toml index 72eb6f255595..749997ef1c7a 100644 --- a/loadtest/config/development.toml +++ b/loadtest/config/development.toml @@ -254,11 +254,11 @@ supported_connectors = "braintree" [mandates.supported_payment_methods] pay_later.klarna = {connector_list = "adyen"} -wallet.google_pay = {connector_list = "stripe,adyen"} -wallet.apple_pay = {connector_list = "stripe,adyen"} +wallet.google_pay = {connector_list = "stripe,adyen,bankofamerica"} +wallet.apple_pay = {connector_list = "stripe,adyen,bankofamerica"} wallet.paypal = {connector_list = "adyen"} -card.credit = {connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon"} -card.debit = {connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon"} +card.credit = {connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica"} +card.debit = {connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica"} bank_debit.ach = { connector_list = "gocardless"} bank_debit.becs = { connector_list = "gocardless"} bank_debit.sepa = { connector_list = "gocardless"} From 1023f46c885dc2b70ccbb3931e667740695f448e Mon Sep 17 00:00:00 2001 From: Prasunna Soppa <70575890+prasunna09@users.noreply.github.com> Date: Tue, 2 Apr 2024 19:54:21 +0530 Subject: [PATCH 19/19] fix(connector): [Cryptopay]fix redirection for cryptopay (#4272) Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> --- .../router/src/connector/cryptopay/transformers.rs | 5 +++-- crates/router/src/connector/utils.rs | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/crates/router/src/connector/cryptopay/transformers.rs b/crates/router/src/connector/cryptopay/transformers.rs index aaf21af05825..e6db0cf320cc 100644 --- a/crates/router/src/connector/cryptopay/transformers.rs +++ b/crates/router/src/connector/cryptopay/transformers.rs @@ -4,7 +4,7 @@ use reqwest::Url; use serde::{Deserialize, Serialize}; use crate::{ - connector::utils::{self, is_payment_failure, CryptoData}, + connector::utils::{self, is_payment_failure, CryptoData, PaymentsAuthorizeRequestData}, consts, core::errors, services, @@ -70,7 +70,8 @@ impl TryFrom<&CryptopayRouterData<&types::PaymentsAuthorizeRouterData>> pay_currency, success_redirect_url: item.router_data.request.router_return_url.clone(), unsuccess_redirect_url: item.router_data.request.router_return_url.clone(), - metadata: item.router_data.request.metadata.clone(), + //Cryptopay only accepts metadata as Object. If any other type, payment will fail with error. + metadata: item.router_data.request.get_metadata_as_object(), custom_id: item.router_data.connector_request_reference_id.clone(), }) } diff --git a/crates/router/src/connector/utils.rs b/crates/router/src/connector/utils.rs index 5bdf8b501ad7..3edaa319fb5f 100644 --- a/crates/router/src/connector/utils.rs +++ b/crates/router/src/connector/utils.rs @@ -498,6 +498,7 @@ pub trait PaymentsAuthorizeRequestData { fn get_surcharge_amount(&self) -> Option; fn get_tax_on_surcharge_amount(&self) -> Option; fn get_total_surcharge_amount(&self) -> Option; + fn get_metadata_as_object(&self) -> Option; } pub trait PaymentMethodTokenizationRequestData { @@ -632,6 +633,19 @@ impl PaymentsAuthorizeRequestData for types::PaymentsAuthorizeData { fn is_customer_initiated_mandate_payment(&self) -> bool { self.setup_mandate_details.is_some() } + + fn get_metadata_as_object(&self) -> Option { + self.metadata + .clone() + .and_then(|meta_data| match meta_data.peek() { + serde_json::Value::Null + | serde_json::Value::Bool(_) + | serde_json::Value::Number(_) + | serde_json::Value::String(_) + | serde_json::Value::Array(_) => None, + serde_json::Value::Object(_) => Some(meta_data), + }) + } } pub trait ConnectorCustomerData {