Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

feat(platform): add processor_merchant_id and created_by to payouts and authentication (#11480)

Ankit Kumar Gupta19b8f61017eb
diff --git a/crates/diesel_models/src/authentication.rs b/crates/diesel_models/src/authentication.rs
index a539d874e2..476fca694f 100644
--- a/crates/diesel_models/src/authentication.rs
+++ b/crates/diesel_models/src/authentication.rs
@@ -84,6 +84,8 @@ pub struct Authentication {
pub merchant_country_code: Option<String>,
pub billing_country: Option<String>,
pub shipping_country: Option<String>,
+ pub processor_merchant_id: Option<common_utils::id_type::MerchantId>,
+ pub created_by: Option<String>,
}
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Insertable)]
@@ -162,6 +164,8 @@ pub struct AuthenticationNew {
pub modified_at: time::PrimitiveDateTime,
pub billing_country: Option<String>,
pub shipping_country: Option<String>,
+ pub processor_merchant_id: Option<common_utils::id_type::MerchantId>,
+ pub created_by: Option<String>,
}
#[derive(Debug)]
@@ -520,6 +524,8 @@ impl AuthenticationUpdateInternal {
currency: source.currency,
billing_country: billing_country.or(source.billing_country),
shipping_country: shipping_country.or(source.shipping_country),
+ processor_merchant_id: source.processor_merchant_id,
+ created_by: source.created_by,
}
}
}
diff --git a/crates/diesel_models/src/payout_attempt.rs b/crates/diesel_models/src/payout_attempt.rs
index 81fdbf45a9..0194c687f0 100644
--- a/crates/diesel_models/src/payout_attempt.rs
+++ b/crates/diesel_models/src/payout_attempt.rs
@@ -39,6 +39,8 @@ pub struct PayoutAttempt {
pub additional_payout_method_data: Option<payout_method_utils::AdditionalPayoutMethodData>,
pub merchant_order_reference_id: Option<String>,
pub payout_connector_metadata: Option<pii::SecretSerdeValue>,
+ pub processor_merchant_id: Option<common_utils::id_type::MerchantId>,
+ pub created_by: Option<String>,
}
#[derive(
@@ -80,6 +82,8 @@ pub struct PayoutAttemptNew {
pub additional_payout_method_data: Option<payout_method_utils::AdditionalPayoutMethodData>,
pub merchant_order_reference_id: Option<String>,
pub payout_connector_metadata: Option<pii::SecretSerdeValue>,
+ pub processor_merchant_id: Option<common_utils::id_type::MerchantId>,
+ pub created_by: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
diff --git a/crates/diesel_models/src/payouts.rs b/crates/diesel_models/src/payouts.rs
index 3e9fd2891c..54cd59308a 100644
--- a/crates/diesel_models/src/payouts.rs
+++ b/crates/diesel_models/src/payouts.rs
@@ -38,6 +38,8 @@ pub struct Payouts {
pub client_secret: Option<String>,
pub priority: Option<storage_enums::PayoutSendPriority>,
pub organization_id: Option<common_utils::id_type::OrganizationId>,
+ pub processor_merchant_id: Option<common_utils::id_type::MerchantId>,
+ pub created_by: Option<String>,
}
#[derive(
@@ -80,6 +82,8 @@ pub struct PayoutsNew {
pub client_secret: Option<String>,
pub priority: Option<storage_enums::PayoutSendPriority>,
pub organization_id: Option<common_utils::id_type::OrganizationId>,
+ pub processor_merchant_id: Option<common_utils::id_type::MerchantId>,
+ pub created_by: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
diff --git a/crates/diesel_models/src/schema.rs b/crates/diesel_models/src/schema.rs
index 2b420ec230..db69423716 100644
--- a/crates/diesel_models/src/schema.rs
+++ b/crates/diesel_models/src/schema.rs
@@ -177,6 +177,10 @@ diesel::table! {
billing_country -> Nullable<Varchar>,
#[max_length = 16]
shipping_country -> Nullable<Varchar>,
+ #[max_length = 64]
+ processor_merchant_id -> Nullable<Varchar>,
+ #[max_length = 255]
+ created_by -> Nullable<Varchar>,
}
}
@@ -1408,6 +1412,10 @@ diesel::table! {
#[max_length = 255]
merchant_order_reference_id -> Nullable<Varchar>,
payout_connector_metadata -> Nullable<Jsonb>,
+ #[max_length = 64]
+ processor_merchant_id -> Nullable<Varchar>,
+ #[max_length = 255]
+ created_by -> Nullable<Varchar>,
}
}
@@ -1454,6 +1462,10 @@ diesel::table! {
priority -> Nullable<Varchar>,
#[max_length = 32]
organization_id -> Nullable<Varchar>,
+ #[max_length = 64]
+ processor_merchant_id -> Nullable<Varchar>,
+ #[max_length = 255]
+ created_by -> Nullable<Varchar>,
}
}
diff --git a/crates/diesel_models/src/schema_v2.rs b/crates/diesel_models/src/schema_v2.rs
index 2ff50ef64c..e69fce241d 100644
--- a/crates/diesel_models/src/schema_v2.rs
+++ b/crates/diesel_models/src/schema_v2.rs
@@ -177,6 +177,10 @@ diesel::table! {
billing_country -> Nullable<Varchar>,
#[max_length = 16]
shipping_country -> Nullable<Varchar>,
+ #[max_length = 64]
+ processor_merchant_id -> Nullable<Varchar>,
+ #[max_length = 255]
+ created_by -> Nullable<Varchar>,
}
}
@@ -1353,6 +1357,10 @@ diesel::table! {
#[max_length = 255]
merchant_order_reference_id -> Nullable<Varchar>,
payout_connector_metadata -> Nullable<Jsonb>,
+ #[max_length = 64]
+ processor_merchant_id -> Nullable<Varchar>,
+ #[max_length = 255]
+ created_by -> Nullable<Varchar>,
}
}
@@ -1399,6 +1407,10 @@ diesel::table! {
priority -> Nullable<Varchar>,
#[max_length = 32]
organization_id -> Nullable<Varchar>,
+ #[max_length = 64]
+ processor_merchant_id -> Nullable<Varchar>,
+ #[max_length = 255]
+ created_by -> Nullable<Varchar>,
}
}
diff --git a/crates/hyperswitch_domain_models/src/authentication.rs b/crates/hyperswitch_domain_models/src/authentication.rs
index 8b964898c6..4e2ed695ef 100644
--- a/crates/hyperswitch_domain_models/src/authentication.rs
+++ b/crates/hyperswitch_domain_models/src/authentication.rs
@@ -96,6 +96,8 @@ pub struct Authentication {
pub customer_details: Option<Encryption>,
pub amount: Option<common_utils::types::MinorUnit>,
pub merchant_country_code: Option<String>,
+ pub processor_merchant_id: Option<common_utils::id_type::MerchantId>,
+ pub created_by: Option<common_utils::types::CreatedBy>,
}
impl Authentication {
@@ -211,6 +213,8 @@ impl behaviour::Conversion for Authentication {
merchant_country_code: self.merchant_country_code,
billing_country: self.billing_country,
shipping_country: self.shipping_country,
+ processor_merchant_id: self.processor_merchant_id,
+ created_by: self.created_by.map(|created_by| created_by.to_string()),
})
}
@@ -346,6 +350,10 @@ impl behaviour::Conversion for Authentication {
billing_country: other.billing_country,
shipping_country: other.shipping_country,
merchant_country_code: other.merchant_country_code,
+ processor_merchant_id: other.processor_merchant_id,
+ created_by: other
+ .created_by
+ .and_then(|created_by| created_by.parse::<common_utils::types::CreatedBy>().ok()),
})
}
@@ -424,6 +432,8 @@ impl behaviour::Conversion for Authentication {
authentication_data: __self.authentication_data,
billing_country: __self.billing_country,
shipping_country: __self.shipping_country,
+ processor_merchant_id: __self.processor_merchant_id,
+ created_by: __self.created_by.map(|created_by| created_by.to_string()),
})
}
}
diff --git a/crates/hyperswitch_domain_models/src/payouts/payout_attempt.rs b/crates/hyperswitch_domain_models/src/payouts/payout_attempt.rs
index dd113a0345..84c1b43f7b 100644
--- a/crates/hyperswitch_domain_models/src/payouts/payout_attempt.rs
+++ b/crates/hyperswitch_domain_models/src/payouts/payout_attempt.rs
@@ -2,7 +2,7 @@ use api_models::enums::PayoutConnectors;
use common_enums as storage_enums;
use common_utils::{
id_type, payout_method_utils, pii,
- types::{UnifiedCode, UnifiedMessage},
+ types::{self, UnifiedCode, UnifiedMessage},
};
use serde::{Deserialize, Serialize};
use storage_enums::MerchantStorageScheme;
@@ -93,6 +93,8 @@ pub struct PayoutAttempt {
pub additional_payout_method_data: Option<payout_method_utils::AdditionalPayoutMethodData>,
pub merchant_order_reference_id: Option<String>,
pub payout_connector_metadata: Option<pii::SecretSerdeValue>,
+ pub processor_merchant_id: Option<id_type::MerchantId>,
+ pub created_by: Option<types::CreatedBy>,
}
#[derive(Clone, Debug, PartialEq)]
@@ -121,6 +123,8 @@ pub struct PayoutAttemptNew {
pub additional_payout_method_data: Option<payout_method_utils::AdditionalPayoutMethodData>,
pub merchant_order_reference_id: Option<String>,
pub payout_connector_metadata: Option<pii::SecretSerdeValue>,
+ pub processor_merchant_id: Option<id_type::MerchantId>,
+ pub created_by: Option<types::CreatedBy>,
}
#[derive(Debug, Clone)]
diff --git a/crates/hyperswitch_domain_models/src/payouts/payouts.rs b/crates/hyperswitch_domain_models/src/payouts/payouts.rs
index 14a6b148d4..190c198f30 100644
--- a/crates/hyperswitch_domain_models/src/payouts/payouts.rs
+++ b/crates/hyperswitch_domain_models/src/payouts/payouts.rs
@@ -126,6 +126,8 @@ pub struct Payouts {
pub client_secret: Option<String>,
pub priority: Option<storage_enums::PayoutSendPriority>,
pub organization_id: Option<id_type::OrganizationId>,
+ pub processor_merchant_id: Option<id_type::MerchantId>,
+ pub created_by: Option<common_utils::types::CreatedBy>,
}
#[derive(Clone, Debug, Eq, PartialEq)]
@@ -155,6 +157,8 @@ pub struct PayoutsNew {
pub client_secret: Option<String>,
pub priority: Option<storage_enums::PayoutSendPriority>,
pub organization_id: Option<id_type::OrganizationId>,
+ pub processor_merchant_id: Option<id_type::MerchantId>,
+ pub created_by: Option<common_utils::types::CreatedBy>,
}
#[derive(Debug, Serialize, Deserialize)]
diff --git a/crates/router/src/core/authentication.rs b/crates/router/src/core/authentication.rs
index 3f6e46b367..855a7cc4d8 100644
--- a/crates/router/src/core/authentication.rs
+++ b/crates/router/src/core/authentication.rs
@@ -224,6 +224,7 @@ pub async fn perform_pre_authentication(
psd2_sca_exemption_type: Option<common_enums::ScaExemptionType>,
billing_address: Option<hyperswitch_domain_models::address::Address>,
shipping_address: Option<hyperswitch_domain_models::address::Address>,
+ initiator: Option<&domain::Initiator>,
) -> CustomResult<
hyperswitch_domain_models::router_request_types::authentication::AuthenticationStore,
ApiErrorResponse,
@@ -245,7 +246,8 @@ pub async fn perform_pre_authentication(
organization_id,
force_3ds_challenge,
psd2_sca_exemption_type,
- processor.get_key_store(),
+ processor,
+ initiator,
)
.await?;
diff --git a/crates/router/src/core/authentication/utils.rs b/crates/router/src/core/authentication/utils.rs
index ed83d7db93..e271960066 100644
--- a/crates/router/src/core/authentication/utils.rs
+++ b/crates/router/src/core/authentication/utils.rs
@@ -373,7 +373,8 @@ pub async fn create_new_authentication(
organization_id: common_utils::id_type::OrganizationId,
force_3ds_challenge: Option<bool>,
psd2_sca_exemption_type: Option<common_enums::ScaExemptionType>,
- merchant_key_store: &domain::MerchantKeyStore,
+ processor: &domain::Processor,
+ initiator: Option<&domain::Initiator>,
) -> RouterResult<authentication::Authentication> {
let authentication_id = common_utils::id_type::AuthenticationId::generate_authentication_id(
consts::AUTHENTICATION_ID_PREFIX,
@@ -461,11 +462,17 @@ pub async fn create_new_authentication(
challenge_request_key: None,
customer_details: None,
merchant_country_code: None,
+ processor_merchant_id: Some(processor.get_account().get_id().clone()),
+ created_by: initiator.and_then(|initiator| initiator.to_created_by()),
};
state
.store
- .insert_authentication(&key_manager_state, merchant_key_store, new_authentication)
+ .insert_authentication(
+ &key_manager_state,
+ processor.get_key_store(),
+ new_authentication,
+ )
.await
.to_duplicate_response(errors::ApiErrorResponse::GenericDuplicateError {
message: format!(
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs
index 01b04e57ed..fe3dd54e0c 100644
--- a/crates/router/src/core/payments.rs
+++ b/crates/router/src/core/payments.rs
@@ -904,6 +904,7 @@ where
&connector_details,
&business_profile,
platform.get_processor(),
+ platform.get_initiator(),
mandate_type,
)
.await?;
diff --git a/crates/router/src/core/payments/operations.rs b/crates/router/src/core/payments/operations.rs
index 7155aebe2e..148fbf111e 100644
--- a/crates/router/src/core/payments/operations.rs
+++ b/crates/router/src/core/payments/operations.rs
@@ -408,6 +408,7 @@ pub trait Domain<F: Clone, R, D>: Send + Sync {
_connector_call_type: &ConnectorCallType,
_business_profile: &domain::Profile,
_processor: &domain::Processor,
+ _initiator: Option<&domain::Initiator>,
_mandate_type: Option<api_models::payments::MandateTransactionType>,
) -> CustomResult<(), errors::ApiErrorResponse> {
Ok(())
diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rs
index 197003e397..fdf304fd44 100644
--- a/crates/router/src/core/payments/operations/payment_confirm.rs
+++ b/crates/router/src/core/payments/operations/payment_confirm.rs
@@ -1363,6 +1363,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
connector_call_type: &ConnectorCallType,
business_profile: &domain::Profile,
processor: &domain::Processor,
+ initiator: Option<&domain::Initiator>,
mandate_type: Option<api_models::payments::MandateTransactionType>,
) -> CustomResult<(), errors::ApiErrorResponse> {
let external_authentication_flow =
@@ -1396,6 +1397,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
payment_data.payment_intent.psd2_sca_exemption_type,
billing_address,
shipping,
+ initiator,
))
.await?;
if authentication_store
@@ -1797,7 +1799,8 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
None,
None,
None,
- platform.get_processor().get_key_store()
+ platform.get_processor(),
+ platform.get_initiator(),
)
.await?;
let authentication_store = hyperswitch_domain_models::router_request_types::authentication::AuthenticationStore {
@@ -1849,7 +1852,8 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
None,
None,
None,
- platform.get_processor().get_key_store()
+ platform.get_processor(),
+ platform.get_initiator(),
)
.await?;
let acquirer_configs = authentication
diff --git a/crates/router/src/core/payouts.rs b/crates/router/src/core/payouts.rs
index 28ea005bf5..c53f0e1229 100644
--- a/crates/router/src/core/payouts.rs
+++ b/crates/router/src/core/payouts.rs
@@ -2884,6 +2884,10 @@ pub async fn payout_create_db_entries(
status,
created_at: common_utils::date_time::now(),
last_modified_at: common_utils::date_time::now(),
+ processor_merchant_id: Some(platform.get_processor().get_account().get_id().clone()),
+ created_by: platform
+ .get_initiator()
+ .and_then(|initiator| initiator.to_created_by()),
};
let payouts = db
.insert_payout(
@@ -2941,6 +2945,10 @@ pub async fn payout_create_db_entries(
unified_code: None,
unified_message: None,
payout_connector_metadata: None,
+ processor_merchant_id: Some(platform.get_processor().get_account().get_id().clone()),
+ created_by: platform
+ .get_initiator()
+ .and_then(|initiator| initiator.to_created_by()),
};
let payout_attempt = db
.insert_payout_attempt(
diff --git a/crates/router/src/core/payouts/retry.rs b/crates/router/src/core/payouts/retry.rs
index 3e39283ce0..5d3a303ab9 100644
--- a/crates/router/src/core/payouts/retry.rs
+++ b/crates/router/src/core/payouts/retry.rs
@@ -283,6 +283,8 @@ pub async fn modify_trackers(
.additional_payout_method_data
.to_owned(),
payout_connector_metadata: None,
+ processor_merchant_id: payout_data.payout_attempt.processor_merchant_id.clone(),
+ created_by: payout_data.payout_attempt.created_by.clone(),
};
payout_data.payout_attempt = db
.insert_payout_attempt(
diff --git a/crates/router/src/core/unified_authentication_service.rs b/crates/router/src/core/unified_authentication_service.rs
index 6931831b31..48628c90e6 100644
--- a/crates/router/src/core/unified_authentication_service.rs
+++ b/crates/router/src/core/unified_authentication_service.rs
@@ -588,7 +588,8 @@ pub async fn create_new_authentication(
return_url: Option<String>,
profile_acquirer_id: Option<common_utils::id_type::ProfileAcquirerId>,
customer_details: Option<common_utils::encryption::Encryption>,
- merchant_key_store: &domain::MerchantKeyStore,
+ processor: &domain::Processor,
+ initiator: Option<&domain::Initiator>,
) -> RouterResult<hyperswitch_domain_models::authentication::Authentication> {
let service_details_value = service_details
.map(serde_json::to_value)
@@ -680,11 +681,17 @@ pub async fn create_new_authentication(
challenge_request_key: None,
customer_details,
merchant_country_code: None,
+ processor_merchant_id: Some(processor.get_account().get_id().clone()),
+ created_by: initiator.and_then(|initiator| initiator.to_created_by()),
};
state
.store
- .insert_authentication(&key_manager_state, merchant_key_store, new_authentication)
+ .insert_authentication(
+ &key_manager_state,
+ processor.get_key_store(),
+ new_authentication,
+ )
.await
.to_duplicate_response(ApiErrorResponse::GenericDuplicateError {
message: format!(
@@ -820,7 +827,8 @@ pub async fn authentication_create_core(
customer_details
.clone()
.map(common_utils::encryption::Encryption::from),
- platform.get_processor().get_key_store(),
+ platform.get_processor(),
+ platform.get_initiator(),
)
.await?;
diff --git a/crates/router/src/db/authentication.rs b/crates/router/src/db/authentication.rs
index c78d1309b7..564bb06670 100644
--- a/crates/router/src/db/authentication.rs
+++ b/crates/router/src/db/authentication.rs
@@ -256,6 +256,10 @@ impl AuthenticationInterface for MockDb {
merchant_country_code: authentication.merchant_country_code,
billing_country: authentication.billing_country,
shipping_country: authentication.shipping_country,
+ processor_merchant_id: authentication.processor_merchant_id,
+ created_by: authentication
+ .created_by
+ .map(|created_by| created_by.to_string()),
};
let authentication: hyperswitch_domain_models::authentication::Authentication =
diff --git a/crates/router/src/services/kafka/authentication.rs b/crates/router/src/services/kafka/authentication.rs
index 04d801038f..4fb5993f75 100644
--- a/crates/router/src/services/kafka/authentication.rs
+++ b/crates/router/src/services/kafka/authentication.rs
@@ -64,6 +64,8 @@ pub struct KafkaAuthentication<'a> {
pub scheme_name: Option<&'a String>,
pub exemption_requested: Option<bool>,
pub exemption_accepted: Option<bool>,
+ pub processor_merchant_id: Option<&'a common_utils::id_type::MerchantId>,
+ pub created_by: Option<&'a common_utils::types::CreatedBy>,
}
impl<'a> KafkaAuthentication<'a> {
@@ -128,6 +130,8 @@ impl<'a> KafkaAuthentication<'a> {
scheme_name: authentication.scheme_name.as_ref(),
exemption_requested: authentication.exemption_requested,
exemption_accepted: authentication.exemption_accepted,
+ processor_merchant_id: authentication.processor_merchant_id.as_ref(),
+ created_by: authentication.created_by.as_ref(),
}
}
}
diff --git a/crates/router/src/services/kafka/authentication_event.rs b/crates/router/src/services/kafka/authentication_event.rs
index 9ea95d8380..9747fa1588 100644
--- a/crates/router/src/services/kafka/authentication_event.rs
+++ b/crates/router/src/services/kafka/authentication_event.rs
@@ -43,6 +43,8 @@ pub struct KafkaAuthenticationEvent<'a> {
pub directory_server_id: Option<&'a String>,
pub acquirer_country_code: Option<&'a String>,
pub organization_id: &'a common_utils::id_type::OrganizationId,
+ pub processor_merchant_id: Option<&'a common_utils::id_type::MerchantId>,
+ pub created_by: Option<&'a common_utils::types::CreatedBy>,
}
impl<'a> KafkaAuthenticationEvent<'a> {
@@ -87,6 +89,8 @@ impl<'a> KafkaAuthenticationEvent<'a> {
directory_server_id: authentication.directory_server_id.as_ref(),
acquirer_country_code: authentication.acquirer_country_code.as_ref(),
organization_id: &authentication.organization_id,
+ processor_merchant_id: authentication.processor_merchant_id.as_ref(),
+ created_by: authentication.created_by.as_ref(),
}
}
}
diff --git a/crates/router/src/services/kafka/payout.rs b/crates/router/src/services/kafka/payout.rs
index 20857dafc2..af4099f335 100644
--- a/crates/router/src/services/kafka/payout.rs
+++ b/crates/router/src/services/kafka/payout.rs
@@ -39,6 +39,8 @@ pub struct KafkaPayout<'a> {
pub business_label: Option<&'a String>,
pub merchant_connector_id: Option<&'a id_type::MerchantConnectorAccountId>,
pub organization_id: Option<&'a id_type::OrganizationId>,
+ pub processor_merchant_id: Option<&'a id_type::MerchantId>,
+ pub created_by: Option<&'a common_utils::types::CreatedBy>,
}
impl<'a> KafkaPayout<'a> {
@@ -75,6 +77,8 @@ impl<'a> KafkaPayout<'a> {
business_label: payout_attempt.business_label.as_ref(),
merchant_connector_id: payout_attempt.merchant_connector_id.as_ref(),
organization_id: payouts.organization_id.as_ref(),
+ processor_merchant_id: payout_attempt.processor_merchant_id.as_ref(),
+ created_by: payout_attempt.created_by.as_ref(),
}
}
}
diff --git a/crates/storage_impl/src/payouts/payout_attempt.rs b/crates/storage_impl/src/payouts/payout_attempt.rs
index e94736c134..41af2db036 100644
--- a/crates/storage_impl/src/payouts/payout_attempt.rs
+++ b/crates/storage_impl/src/payouts/payout_attempt.rs
@@ -92,6 +92,8 @@ impl<T: DatabaseStore> PayoutAttemptInterface for KVRouterStore<T> {
.merchant_order_reference_id
.clone(),
payout_connector_metadata: new_payout_attempt.payout_connector_metadata.clone(),
+ processor_merchant_id: new_payout_attempt.processor_merchant_id.clone(),
+ created_by: new_payout_attempt.created_by.clone(),
};
let redis_entry = kv::TypedSql {
@@ -576,6 +578,8 @@ impl DataModelExt for PayoutAttempt {
additional_payout_method_data: self.additional_payout_method_data,
merchant_order_reference_id: self.merchant_order_reference_id,
payout_connector_metadata: self.payout_connector_metadata,
+ processor_merchant_id: self.processor_merchant_id,
+ created_by: self.created_by.map(|created_by| created_by.to_string()),
}
}
@@ -605,6 +609,10 @@ impl DataModelExt for PayoutAttempt {
additional_payout_method_data: storage_model.additional_payout_method_data,
merchant_order_reference_id: storage_model.merchant_order_reference_id,
payout_connector_metadata: storage_model.payout_connector_metadata,
+ processor_merchant_id: storage_model.processor_merchant_id,
+ created_by: storage_model
+ .created_by
+ .and_then(|created_by| created_by.parse::<common_utils::types::CreatedBy>().ok()),
}
}
}
@@ -637,6 +645,8 @@ impl DataModelExt for PayoutAttemptNew {
additional_payout_method_data: self.additional_payout_method_data,
merchant_order_reference_id: self.merchant_order_reference_id,
payout_connector_metadata: self.payout_connector_metadata,
+ processor_merchant_id: self.processor_merchant_id,
+ created_by: self.created_by.map(|created_by| created_by.to_string()),
}
}
@@ -666,6 +676,10 @@ impl DataModelExt for PayoutAttemptNew {
additional_payout_method_data: storage_model.additional_payout_method_data,
merchant_order_reference_id: storage_model.merchant_order_reference_id,
payout_connector_metadata: storage_model.payout_connector_metadata,
+ processor_merchant_id: storage_model.processor_merchant_id,
+ created_by: storage_model
+ .created_by
+ .and_then(|created_by| created_by.parse::<common_utils::types::CreatedBy>().ok()),
}
}
}
diff --git a/crates/storage_impl/src/payouts/payouts.rs b/crates/storage_impl/src/payouts/payouts.rs
index fa5f3a1c63..2bae4b43f0 100644
--- a/crates/storage_impl/src/payouts/payouts.rs
+++ b/crates/storage_impl/src/payouts/payouts.rs
@@ -107,6 +107,8 @@ impl<T: DatabaseStore> PayoutsInterface for KVRouterStore<T> {
client_secret: new.client_secret.clone(),
priority: new.priority,
organization_id: new.organization_id.clone(),
+ processor_merchant_id: new.processor_merchant_id.clone(),
+ created_by: new.created_by.clone(),
};
let redis_entry = kv::TypedSql {
@@ -981,6 +983,8 @@ impl DataModelExt for Payouts {
client_secret: self.client_secret,
priority: self.priority,
organization_id: self.organization_id,
+ processor_merchant_id: self.processor_merchant_id,
+ created_by: self.created_by.map(|created_by| created_by.to_string()),
}
}
@@ -1011,6 +1015,10 @@ impl DataModelExt for Payouts {
client_secret: storage_model.client_secret,
priority: storage_model.priority,
organization_id: storage_model.organization_id,
+ processor_merchant_id: storage_model.processor_merchant_id,
+ created_by: storage_model
+ .created_by
+ .and_then(|created_by| created_by.parse::<common_utils::types::CreatedBy>().ok()),
}
}
}
@@ -1044,6 +1052,8 @@ impl DataModelExt for PayoutsNew {
client_secret: self.client_secret,
priority: self.priority,
organization_id: self.organization_id,
+ processor_merchant_id: self.processor_merchant_id,
+ created_by: self.created_by.map(|created_by| created_by.to_string()),
}
}
@@ -1074,6 +1084,10 @@ impl DataModelExt for PayoutsNew {
client_secret: storage_model.client_secret,
priority: storage_model.priority,
organization_id: storage_model.organization_id,
+ processor_merchant_id: storage_model.processor_merchant_id,
+ created_by: storage_model
+ .created_by
+ .and_then(|created_by| created_by.parse::<common_utils::types::CreatedBy>().ok()),
}
}
}
diff --git a/migrations/2026-03-10-000001_add_processor_merchant_id_created_by_to_payouts_and_payout_attempt/down.sql b/migrations/2026-03-10-000001_add_processor_merchant_id_created_by_to_payouts_and_payout_attempt/down.sql
new file mode 100644
index 0000000000..e30808ac1f
--- /dev/null
+++ b/migrations/2026-03-10-000001_add_processor_merchant_id_created_by_to_payouts_and_payout_attempt/down.sql
@@ -0,0 +1,6 @@
+-- This file should undo anything in `up.sql`
+ALTER TABLE payouts DROP COLUMN IF EXISTS processor_merchant_id;
+ALTER TABLE payouts DROP COLUMN IF EXISTS created_by;
+
+ALTER TABLE payout_attempt DROP COLUMN IF EXISTS processor_merchant_id;
+ALTER TABLE payout_attempt DROP COLUMN IF EXISTS created_by;
diff --git a/migrations/2026-03-10-000001_add_processor_merchant_id_created_by_to_payouts_and_payout_attempt/up.sql b/migrations/2026-03-10-000001_add_processor_merchant_id_created_by_to_payouts_and_payout_attempt/up.sql
new file mode 100644
index 0000000000..71a3634443
--- /dev/null
+++ b/migrations/2026-03-10-000001_add_processor_merchant_id_created_by_to_payouts_and_payout_attempt/up.sql
@@ -0,0 +1,10 @@
+-- Your SQL goes here
+ALTER TABLE payouts ADD COLUMN IF NOT EXISTS processor_merchant_id VARCHAR(64);
+ALTER TABLE payouts ADD COLUMN IF NOT EXISTS created_by VARCHAR(255);
+
+ALTER TABLE payout_attempt ADD COLUMN IF NOT EXISTS processor_merchant_id VARCHAR(64);
+ALTER TABLE payout_attempt ADD COLUMN IF NOT EXISTS created_by VARCHAR(255);
+
+-- This backfill should be executed after deployment is complete.
+UPDATE payouts SET processor_merchant_id = merchant_id WHERE processor_merchant_id IS NULL;
+UPDATE payout_attempt SET processor_merchant_id = merchant_id WHERE processor_merchant_id IS NULL;
diff --git a/migrations/2026-03-10-000002_add_processor_merchant_id_created_by_to_authentication/down.sql b/migrations/2026-03-10-000002_add_processor_merchant_id_created_by_to_authentication/down.sql
new file mode 100644
index 0000000000..3133b4a625
--- /dev/null
+++ b/migrations/2026-03-10-000002_add_processor_merchant_id_created_by_to_authentication/down.sql
@@ -0,0 +1,3 @@
+-- This file should undo anything in `up.sql`
+ALTER TABLE authentication DROP COLUMN IF EXISTS processor_merchant_id;
+ALTER TABLE authentication DROP COLUMN IF EXISTS created_by;
diff --git a/migrations/2026-03-10-000002_add_processor_merchant_id_created_by_to_authentication/up.sql b/migrations/2026-03-10-000002_add_processor_merchant_id_created_by_to_authentication/up.sql
new file mode 100644
index 0000000000..2a284ec30b
--- /dev/null
+++ b/migrations/2026-03-10-000002_add_processor_merchant_id_created_by_to_authentication/up.sql
@@ -0,0 +1,6 @@
+-- Your SQL goes here
+ALTER TABLE authentication ADD COLUMN IF NOT EXISTS processor_merchant_id VARCHAR(64);
+ALTER TABLE authentication ADD COLUMN IF NOT EXISTS created_by VARCHAR(255);
+
+-- This backfill should be executed after deployment is complete.
+UPDATE authentication SET processor_merchant_id = merchant_id WHERE processor_merchant_id IS NULL;