mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 04:04:43 +08:00
refactor(email): Add recipient emails in email config (#5964)
This commit is contained in:
@ -375,10 +375,12 @@ wildcard_origin = false # If true, allows any origin to make req
|
|||||||
|
|
||||||
# EmailClient configuration. Only applicable when the `email` feature flag is enabled.
|
# EmailClient configuration. Only applicable when the `email` feature flag is enabled.
|
||||||
[email]
|
[email]
|
||||||
sender_email = "example@example.com" # Sender email
|
sender_email = "example@example.com" # Sender email
|
||||||
aws_region = "" # AWS region used by AWS SES
|
aws_region = "" # AWS region used by AWS SES
|
||||||
allowed_unverified_days = 1 # Number of days the api calls ( with jwt token ) can be made without verifying the email
|
allowed_unverified_days = 1 # Number of days the api calls ( with jwt token ) can be made without verifying the email
|
||||||
active_email_client = "SES" # The currently active email client
|
active_email_client = "SES" # The currently active email client
|
||||||
|
recon_recipient_email = "recon@example.com" # Recipient email for recon request email
|
||||||
|
prod_intent_recipient_email = "business@example.com" # Recipient email for prod intent email
|
||||||
|
|
||||||
# Configuration for aws ses, applicable when the active email client is SES
|
# Configuration for aws ses, applicable when the active email client is SES
|
||||||
[email.aws_ses]
|
[email.aws_ses]
|
||||||
@ -745,4 +747,4 @@ delete_token_url= "" # base url to delete token from token service
|
|||||||
check_token_status_url= "" # base url to check token status from token service
|
check_token_status_url= "" # base url to check token status from token service
|
||||||
|
|
||||||
[network_tokenization_supported_connectors]
|
[network_tokenization_supported_connectors]
|
||||||
connector_list = "cybersource" # Supported connectors for network tokenization
|
connector_list = "cybersource" # Supported connectors for network tokenization
|
||||||
|
|||||||
@ -60,6 +60,8 @@ sender_email = "example@example.com" # Sender email
|
|||||||
aws_region = "" # AWS region used by AWS SES
|
aws_region = "" # AWS region used by AWS SES
|
||||||
allowed_unverified_days = 1 # Number of days the api calls ( with jwt token ) can be made without verifying the email
|
allowed_unverified_days = 1 # Number of days the api calls ( with jwt token ) can be made without verifying the email
|
||||||
active_email_client = "SES" # The currently active email client
|
active_email_client = "SES" # The currently active email client
|
||||||
|
recon_recipient_email = "recon@example.com" # Recipient email for recon request email
|
||||||
|
prod_intent_recipient_email = "business@example.com" # Recipient email for prod intent email
|
||||||
|
|
||||||
# Configuration for aws ses, applicable when the active email client is SES
|
# Configuration for aws ses, applicable when the active email client is SES
|
||||||
[email.aws_ses]
|
[email.aws_ses]
|
||||||
@ -300,9 +302,6 @@ public = { name = "hyperswitch", base_url = "http://localhost:8080", schema = "p
|
|||||||
[user_auth_methods]
|
[user_auth_methods]
|
||||||
encryption_key = "user_auth_table_encryption_key" # Encryption key used for encrypting data in user_authentication_methods table
|
encryption_key = "user_auth_table_encryption_key" # Encryption key used for encrypting data in user_authentication_methods table
|
||||||
|
|
||||||
[recipient_emails]
|
|
||||||
recon = "recon@example.com"
|
|
||||||
|
|
||||||
[network_tokenization_service] # Network Tokenization Service Configuration
|
[network_tokenization_service] # Network Tokenization Service Configuration
|
||||||
generate_token_url= "" # base url to generate token
|
generate_token_url= "" # base url to generate token
|
||||||
fetch_token_url= "" # base url to fetch token
|
fetch_token_url= "" # base url to fetch token
|
||||||
@ -311,4 +310,4 @@ public_key= "" # public key to encrypt data for token service
|
|||||||
private_key= "" # private key to decrypt response payload from token service
|
private_key= "" # private key to decrypt response payload from token service
|
||||||
key_id= "" # key id to encrypt data for token service
|
key_id= "" # key id to encrypt data for token service
|
||||||
delete_token_url= "" # base url to delete token from token service
|
delete_token_url= "" # base url to delete token from token service
|
||||||
check_token_status_url= "" # base url to check token status from token service
|
check_token_status_url= "" # base url to check token status from token service
|
||||||
|
|||||||
@ -301,6 +301,8 @@ sender_email = "example@example.com"
|
|||||||
aws_region = ""
|
aws_region = ""
|
||||||
allowed_unverified_days = 1
|
allowed_unverified_days = 1
|
||||||
active_email_client = "SES"
|
active_email_client = "SES"
|
||||||
|
recon_recipient_email = "recon@example.com"
|
||||||
|
prod_intent_recipient_email = "business@example.com"
|
||||||
|
|
||||||
[email.aws_ses]
|
[email.aws_ses]
|
||||||
email_role_arn = ""
|
email_role_arn = ""
|
||||||
@ -732,11 +734,8 @@ encryption_key = "A8EF32E029BC3342E54BF2E172A4D7AA43E8EF9D2C3A624A9F04E2EF79DC69
|
|||||||
[locker_based_open_banking_connectors]
|
[locker_based_open_banking_connectors]
|
||||||
connector_list = ""
|
connector_list = ""
|
||||||
|
|
||||||
[recipient_emails]
|
|
||||||
recon = "recon@example.com"
|
|
||||||
|
|
||||||
[network_tokenization_supported_card_networks]
|
[network_tokenization_supported_card_networks]
|
||||||
card_networks = "Visa, AmericanExpress, Mastercard"
|
card_networks = "Visa, AmericanExpress, Mastercard"
|
||||||
|
|
||||||
[network_tokenization_supported_connectors]
|
[network_tokenization_supported_connectors]
|
||||||
connector_list = "cybersource"
|
connector_list = "cybersource"
|
||||||
|
|||||||
@ -591,11 +591,22 @@ ach = { country = "US", currency = "USD" }
|
|||||||
[locker_based_open_banking_connectors]
|
[locker_based_open_banking_connectors]
|
||||||
connector_list = ""
|
connector_list = ""
|
||||||
|
|
||||||
[recipient_emails]
|
|
||||||
recon = "recon@example.com"
|
|
||||||
|
|
||||||
[network_tokenization_supported_card_networks]
|
[network_tokenization_supported_card_networks]
|
||||||
card_networks = "Visa, AmericanExpress, Mastercard"
|
card_networks = "Visa, AmericanExpress, Mastercard"
|
||||||
|
|
||||||
[network_tokenization_supported_connectors]
|
[network_tokenization_supported_connectors]
|
||||||
connector_list = "cybersource"
|
connector_list = "cybersource"
|
||||||
|
|
||||||
|
# EmailClient configuration. Only applicable when the `email` feature flag is enabled.
|
||||||
|
[email]
|
||||||
|
sender_email = "example@example.com" # Sender email
|
||||||
|
aws_region = "" # AWS region used by AWS SES
|
||||||
|
allowed_unverified_days = 1 # Number of days the api calls ( with jwt token ) can be made without verifying the email
|
||||||
|
active_email_client = "SES" # The currently active email client
|
||||||
|
recon_recipient_email = "recon@example.com" # Recipient email for recon request email
|
||||||
|
prod_intent_recipient_email = "business@example.com" # Recipient email for prod intent email
|
||||||
|
|
||||||
|
# Configuration for aws ses, applicable when the active email client is SES
|
||||||
|
[email.aws_ses]
|
||||||
|
email_role_arn = "" # The amazon resource name ( arn ) of the role which has permission to send emails
|
||||||
|
sts_role_session_name = "" # An identifier for the assumed role session, used to uniquely identify a session.
|
||||||
|
|||||||
@ -137,6 +137,12 @@ pub struct EmailSettings {
|
|||||||
|
|
||||||
/// The active email client to use
|
/// The active email client to use
|
||||||
pub active_email_client: AvailableEmailClients,
|
pub active_email_client: AvailableEmailClients,
|
||||||
|
|
||||||
|
/// Recipient email for recon emails
|
||||||
|
pub recon_recipient_email: pii::Email,
|
||||||
|
|
||||||
|
/// Recipient email for recon emails
|
||||||
|
pub prod_intent_recipient_email: pii::Email,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Errors that could occur from EmailClient.
|
/// Errors that could occur from EmailClient.
|
||||||
|
|||||||
@ -498,7 +498,6 @@ pub(crate) async fn fetch_raw_secrets(
|
|||||||
decision: conf.decision,
|
decision: conf.decision,
|
||||||
locker_based_open_banking_connectors: conf.locker_based_open_banking_connectors,
|
locker_based_open_banking_connectors: conf.locker_based_open_banking_connectors,
|
||||||
grpc_client: conf.grpc_client,
|
grpc_client: conf.grpc_client,
|
||||||
recipient_emails: conf.recipient_emails,
|
|
||||||
network_tokenization_supported_card_networks: conf
|
network_tokenization_supported_card_networks: conf
|
||||||
.network_tokenization_supported_card_networks,
|
.network_tokenization_supported_card_networks,
|
||||||
network_tokenization_service,
|
network_tokenization_service,
|
||||||
|
|||||||
@ -6,7 +6,7 @@ use std::{
|
|||||||
#[cfg(feature = "olap")]
|
#[cfg(feature = "olap")]
|
||||||
use analytics::{opensearch::OpenSearchConfig, ReportConfig};
|
use analytics::{opensearch::OpenSearchConfig, ReportConfig};
|
||||||
use api_models::{enums, payment_methods::RequiredFieldInfo};
|
use api_models::{enums, payment_methods::RequiredFieldInfo};
|
||||||
use common_utils::{ext_traits::ConfigExt, pii::Email};
|
use common_utils::ext_traits::ConfigExt;
|
||||||
use config::{Environment, File};
|
use config::{Environment, File};
|
||||||
use error_stack::ResultExt;
|
use error_stack::ResultExt;
|
||||||
#[cfg(feature = "email")]
|
#[cfg(feature = "email")]
|
||||||
@ -122,7 +122,6 @@ pub struct Settings<S: SecretState> {
|
|||||||
pub decision: Option<DecisionConfig>,
|
pub decision: Option<DecisionConfig>,
|
||||||
pub locker_based_open_banking_connectors: LockerBasedRecipientConnectorList,
|
pub locker_based_open_banking_connectors: LockerBasedRecipientConnectorList,
|
||||||
pub grpc_client: GrpcClientSettings,
|
pub grpc_client: GrpcClientSettings,
|
||||||
pub recipient_emails: RecipientMails,
|
|
||||||
pub network_tokenization_supported_card_networks: NetworkTokenizationSupportedCardNetworks,
|
pub network_tokenization_supported_card_networks: NetworkTokenizationSupportedCardNetworks,
|
||||||
pub network_tokenization_service: Option<SecretStateContainer<NetworkTokenizationService, S>>,
|
pub network_tokenization_service: Option<SecretStateContainer<NetworkTokenizationService, S>>,
|
||||||
pub network_tokenization_supported_connectors: NetworkTokenizationSupportedConnectors,
|
pub network_tokenization_supported_connectors: NetworkTokenizationSupportedConnectors,
|
||||||
@ -941,11 +940,6 @@ pub struct ServerTls {
|
|||||||
pub certificate: PathBuf,
|
pub certificate: PathBuf,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Clone, Default)]
|
|
||||||
pub struct RecipientMails {
|
|
||||||
pub recon: Email,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn deserialize_hashmap_inner<K, V>(
|
fn deserialize_hashmap_inner<K, V>(
|
||||||
value: HashMap<String, String>,
|
value: HashMap<String, String>,
|
||||||
) -> Result<HashMap<K, HashSet<V>>, String>
|
) -> Result<HashMap<K, HashSet<V>>, String>
|
||||||
|
|||||||
@ -5,7 +5,6 @@ pub const MAX_NAME_LENGTH: usize = 70;
|
|||||||
/// The max length of company name and merchant should be same
|
/// The max length of company name and merchant should be same
|
||||||
/// because we are deriving the merchant name from company name
|
/// because we are deriving the merchant name from company name
|
||||||
pub const MAX_COMPANY_NAME_LENGTH: usize = MAX_ALLOWED_MERCHANT_NAME_LENGTH;
|
pub const MAX_COMPANY_NAME_LENGTH: usize = MAX_ALLOWED_MERCHANT_NAME_LENGTH;
|
||||||
pub const BUSINESS_EMAIL: &str = "neeraj.kumar@juspay.in";
|
|
||||||
|
|
||||||
pub const RECOVERY_CODES_COUNT: usize = 8;
|
pub const RECOVERY_CODES_COUNT: usize = 8;
|
||||||
pub const RECOVERY_CODE_LENGTH: usize = 8; // This is without counting the hyphen in between
|
pub const RECOVERY_CODE_LENGTH: usize = 8; // This is without counting the hyphen in between
|
||||||
|
|||||||
@ -33,7 +33,7 @@ pub async fn send_recon_request(
|
|||||||
.change_context(errors::ApiErrorResponse::InternalServerError)
|
.change_context(errors::ApiErrorResponse::InternalServerError)
|
||||||
.attach_printable("Failed to convert recipient's email to UserEmail")?,
|
.attach_printable("Failed to convert recipient's email to UserEmail")?,
|
||||||
recipient_email: domain::UserEmail::from_pii_email(
|
recipient_email: domain::UserEmail::from_pii_email(
|
||||||
state.conf.recipient_emails.recon.clone(),
|
state.conf.email.recon_recipient_email.clone(),
|
||||||
)
|
)
|
||||||
.change_context(errors::ApiErrorResponse::InternalServerError)
|
.change_context(errors::ApiErrorResponse::InternalServerError)
|
||||||
.attach_printable("Failed to convert recipient's email to UserEmail")?,
|
.attach_printable("Failed to convert recipient's email to UserEmail")?,
|
||||||
|
|||||||
@ -484,7 +484,7 @@ async fn insert_metadata(
|
|||||||
state.conf.proxy.https_url.as_ref(),
|
state.conf.proxy.https_url.as_ref(),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
logger::info!(?send_email_result);
|
logger::info!(prod_intent_email=?send_email_result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -413,9 +413,9 @@ pub struct BizEmailProd {
|
|||||||
impl BizEmailProd {
|
impl BizEmailProd {
|
||||||
pub fn new(state: &SessionState, data: ProdIntent) -> UserResult<Self> {
|
pub fn new(state: &SessionState, data: ProdIntent) -> UserResult<Self> {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
recipient_email: (domain::UserEmail::new(
|
recipient_email: domain::UserEmail::from_pii_email(
|
||||||
consts::user::BUSINESS_EMAIL.to_string().into(),
|
state.conf.email.prod_intent_recipient_email.clone(),
|
||||||
))?,
|
)?,
|
||||||
settings: state.conf.clone(),
|
settings: state.conf.clone(),
|
||||||
subject: "New Prod Intent",
|
subject: "New Prod Intent",
|
||||||
user_name: data.poc_name.unwrap_or_default().into(),
|
user_name: data.poc_name.unwrap_or_default().into(),
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
use std::{net::IpAddr, str::FromStr};
|
use std::{net::IpAddr, ops::Not, str::FromStr};
|
||||||
|
|
||||||
use actix_web::http::header::HeaderMap;
|
use actix_web::http::header::HeaderMap;
|
||||||
use api_models::user::dashboard_metadata::{
|
use api_models::user::dashboard_metadata::{
|
||||||
@ -11,6 +11,7 @@ use diesel_models::{
|
|||||||
};
|
};
|
||||||
use error_stack::{report, ResultExt};
|
use error_stack::{report, ResultExt};
|
||||||
use masking::Secret;
|
use masking::Secret;
|
||||||
|
use router_env::logger;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
core::errors::{UserErrors, UserResult},
|
core::errors::{UserErrors, UserResult},
|
||||||
@ -284,8 +285,16 @@ fn not_contains_string(value: &Option<String>, value_to_be_checked: &str) -> boo
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_prod_email_required(data: &ProdIntent, user_email: String) -> bool {
|
pub fn is_prod_email_required(data: &ProdIntent, user_email: String) -> bool {
|
||||||
not_contains_string(&data.poc_email, "juspay")
|
let poc_email_check = not_contains_string(&data.poc_email, "juspay");
|
||||||
&& not_contains_string(&data.business_website, "juspay")
|
let business_website_check = not_contains_string(&data.business_website, "juspay")
|
||||||
&& not_contains_string(&data.business_website, "hyperswitch")
|
&& not_contains_string(&data.business_website, "hyperswitch");
|
||||||
&& not_contains_string(&Some(user_email), "juspay")
|
let user_email_check = not_contains_string(&Some(user_email), "juspay");
|
||||||
|
|
||||||
|
if (poc_email_check && business_website_check && user_email_check).not() {
|
||||||
|
logger::info!(prod_intent_email = poc_email_check);
|
||||||
|
logger::info!(prod_intent_email = business_website_check);
|
||||||
|
logger::info!(prod_intent_email = user_email_check);
|
||||||
|
}
|
||||||
|
|
||||||
|
poc_email_check && business_website_check && user_email_check
|
||||||
}
|
}
|
||||||
|
|||||||
@ -368,5 +368,15 @@ global_tenant = { schema = "public", redis_key_prefix = "" }
|
|||||||
[multitenancy.tenants]
|
[multitenancy.tenants]
|
||||||
public = { name = "hyperswitch", base_url = "http://localhost:8080", schema = "public", redis_key_prefix = "", clickhouse_database = "default"}
|
public = { name = "hyperswitch", base_url = "http://localhost:8080", schema = "public", redis_key_prefix = "", clickhouse_database = "default"}
|
||||||
|
|
||||||
[recipient_emails]
|
[email]
|
||||||
recon = "recon@example.com"
|
sender_email = "example@example.com"
|
||||||
|
aws_region = ""
|
||||||
|
allowed_unverified_days = 1
|
||||||
|
active_email_client = "SES"
|
||||||
|
recon_recipient_email = "recon@example.com"
|
||||||
|
prod_intent_recipient_email = "business@example.com"
|
||||||
|
|
||||||
|
[email.aws_ses]
|
||||||
|
email_role_arn = ""
|
||||||
|
sts_role_session_name = ""
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user