mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-01 19:42:27 +08:00
feat(database): add profile & organisation id to transaction tables (#5696)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -2960,7 +2960,7 @@ mod tests {
|
||||
feature_metadata: None,
|
||||
attempt_count: 1,
|
||||
payment_link_id: None,
|
||||
profile_id: None,
|
||||
profile_id: Some(common_utils::generate_profile_id_of_default_length()),
|
||||
merchant_decision: None,
|
||||
payment_confirm_source: None,
|
||||
surcharge_applicable: None,
|
||||
@ -2982,6 +2982,7 @@ mod tests {
|
||||
merchant_order_reference_id: None,
|
||||
shipping_details: None,
|
||||
is_payment_processor_token_flow: None,
|
||||
organization_id: id_type::OrganizationId::default(),
|
||||
};
|
||||
let req_cs = Some("1".to_string());
|
||||
assert!(authenticate_client_secret(req_cs.as_ref(), &payment_intent).is_ok());
|
||||
@ -3026,7 +3027,7 @@ mod tests {
|
||||
feature_metadata: None,
|
||||
attempt_count: 1,
|
||||
payment_link_id: None,
|
||||
profile_id: None,
|
||||
profile_id: Some(common_utils::generate_profile_id_of_default_length()),
|
||||
merchant_decision: None,
|
||||
payment_confirm_source: None,
|
||||
surcharge_applicable: None,
|
||||
@ -3047,6 +3048,7 @@ mod tests {
|
||||
merchant_order_reference_id: None,
|
||||
shipping_details: None,
|
||||
is_payment_processor_token_flow: None,
|
||||
organization_id: id_type::OrganizationId::default(),
|
||||
};
|
||||
let req_cs = Some("1".to_string());
|
||||
assert!(authenticate_client_secret(req_cs.as_ref(), &payment_intent,).is_err())
|
||||
@ -3088,7 +3090,7 @@ mod tests {
|
||||
feature_metadata: None,
|
||||
attempt_count: 1,
|
||||
payment_link_id: None,
|
||||
profile_id: None,
|
||||
profile_id: Some(common_utils::generate_profile_id_of_default_length()),
|
||||
merchant_decision: None,
|
||||
payment_confirm_source: None,
|
||||
surcharge_applicable: None,
|
||||
@ -3110,6 +3112,7 @@ mod tests {
|
||||
merchant_order_reference_id: None,
|
||||
shipping_details: None,
|
||||
is_payment_processor_token_flow: None,
|
||||
organization_id: id_type::OrganizationId::default(),
|
||||
};
|
||||
let req_cs = Some("1".to_string());
|
||||
assert!(authenticate_client_secret(req_cs.as_ref(), &payment_intent).is_err())
|
||||
@ -3645,6 +3648,8 @@ impl AttemptType {
|
||||
client_source: old_payment_attempt.client_source,
|
||||
client_version: old_payment_attempt.client_version,
|
||||
customer_acceptance: old_payment_attempt.customer_acceptance,
|
||||
organization_id: old_payment_attempt.organization_id,
|
||||
profile_id: old_payment_attempt.profile_id,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -308,6 +308,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa
|
||||
let (payment_attempt_new, additional_payment_data) = Self::make_payment_attempt(
|
||||
&payment_id,
|
||||
merchant_id,
|
||||
&merchant_account.organization_id,
|
||||
money,
|
||||
payment_method,
|
||||
payment_method_type,
|
||||
@ -874,6 +875,7 @@ impl PaymentCreate {
|
||||
pub async fn make_payment_attempt(
|
||||
payment_id: &str,
|
||||
merchant_id: &common_utils::id_type::MerchantId,
|
||||
organization_id: &common_utils::id_type::OrganizationId,
|
||||
money: (api::Amount, enums::Currency),
|
||||
payment_method: Option<enums::PaymentMethod>,
|
||||
payment_method_type: Option<enums::PaymentMethodType>,
|
||||
@ -1065,6 +1067,8 @@ impl PaymentCreate {
|
||||
.change_context(errors::ApiErrorResponse::InternalServerError)
|
||||
.attach_printable("Failed to serialize customer_acceptance")?
|
||||
.map(Secret::new),
|
||||
organization_id: organization_id.clone(),
|
||||
profile_id,
|
||||
},
|
||||
additional_pm_data,
|
||||
))
|
||||
@ -1246,6 +1250,7 @@ impl PaymentCreate {
|
||||
merchant_order_reference_id: request.merchant_order_reference_id.clone(),
|
||||
shipping_details,
|
||||
is_payment_processor_token_flow,
|
||||
organization_id: merchant_account.organization_id.clone(),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -506,7 +506,6 @@ pub fn make_new_payment_attempt(
|
||||
amount: old_payment_attempt.amount,
|
||||
currency: old_payment_attempt.currency,
|
||||
save_to_locker: old_payment_attempt.save_to_locker,
|
||||
|
||||
offer_amount: old_payment_attempt.offer_amount,
|
||||
surcharge_amount: old_payment_attempt.surcharge_amount,
|
||||
tax_amount: old_payment_attempt.tax_amount,
|
||||
@ -521,7 +520,6 @@ pub fn make_new_payment_attempt(
|
||||
} else {
|
||||
old_payment_attempt.authentication_type
|
||||
},
|
||||
|
||||
amount_to_capture: old_payment_attempt.amount_to_capture,
|
||||
mandate_id: old_payment_attempt.mandate_id,
|
||||
browser_info: old_payment_attempt.browser_info,
|
||||
@ -531,7 +529,37 @@ pub fn make_new_payment_attempt(
|
||||
created_at,
|
||||
modified_at,
|
||||
last_synced,
|
||||
..storage::PaymentAttemptNew::default()
|
||||
net_amount: Default::default(),
|
||||
error_message: Default::default(),
|
||||
cancellation_reason: Default::default(),
|
||||
error_code: Default::default(),
|
||||
connector_metadata: Default::default(),
|
||||
payment_experience: Default::default(),
|
||||
payment_method_data: Default::default(),
|
||||
business_sub_label: Default::default(),
|
||||
straight_through_algorithm: Default::default(),
|
||||
preprocessing_step_id: Default::default(),
|
||||
mandate_details: Default::default(),
|
||||
error_reason: Default::default(),
|
||||
connector_response_reference_id: Default::default(),
|
||||
multiple_capture_count: Default::default(),
|
||||
amount_capturable: Default::default(),
|
||||
updated_by: Default::default(),
|
||||
authentication_data: Default::default(),
|
||||
encoded_data: Default::default(),
|
||||
merchant_connector_id: Default::default(),
|
||||
unified_code: Default::default(),
|
||||
unified_message: Default::default(),
|
||||
external_three_ds_authentication_attempted: Default::default(),
|
||||
authentication_connector: Default::default(),
|
||||
authentication_id: Default::default(),
|
||||
mandate_data: Default::default(),
|
||||
payment_method_billing_address_id: Default::default(),
|
||||
fingerprint_id: Default::default(),
|
||||
charge_id: Default::default(),
|
||||
customer_acceptance: Default::default(),
|
||||
profile_id: old_payment_attempt.profile_id,
|
||||
organization_id: old_payment_attempt.organization_id,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -798,30 +798,34 @@ pub async fn validate_and_create_refund(
|
||||
.clone()
|
||||
.ok_or(errors::ApiErrorResponse::InternalServerError)
|
||||
.attach_printable("No connector populated in payment attempt")?;
|
||||
|
||||
let refund_create_req = storage::RefundNew::default()
|
||||
.set_refund_id(refund_id.to_string())
|
||||
.set_internal_reference_id(utils::generate_id(consts::ID_LENGTH, "refid"))
|
||||
.set_external_reference_id(Some(refund_id.clone()))
|
||||
.set_payment_id(req.payment_id)
|
||||
.set_merchant_id(merchant_account.get_id().clone())
|
||||
.set_connector_transaction_id(connecter_transaction_id.to_string())
|
||||
.set_connector(connector)
|
||||
.set_refund_type(req.refund_type.unwrap_or_default().foreign_into())
|
||||
.set_total_amount(payment_attempt.amount)
|
||||
.set_refund_amount(refund_amount)
|
||||
.set_currency(currency)
|
||||
.set_created_at(common_utils::date_time::now())
|
||||
.set_modified_at(common_utils::date_time::now())
|
||||
.set_refund_status(enums::RefundStatus::Pending)
|
||||
.set_metadata(req.metadata)
|
||||
.set_description(req.reason.clone())
|
||||
.set_attempt_id(payment_attempt.attempt_id.clone())
|
||||
.set_refund_reason(req.reason)
|
||||
.set_profile_id(payment_intent.profile_id.clone())
|
||||
.set_merchant_connector_id(payment_attempt.merchant_connector_id.clone())
|
||||
.set_charges(req.charges)
|
||||
.to_owned();
|
||||
let refund_create_req = storage::RefundNew {
|
||||
refund_id: refund_id.to_string(),
|
||||
internal_reference_id: utils::generate_id(consts::ID_LENGTH, "refid"),
|
||||
external_reference_id: Some(refund_id.clone()),
|
||||
payment_id: req.payment_id,
|
||||
merchant_id: merchant_account.get_id().clone(),
|
||||
connector_transaction_id: connecter_transaction_id.to_string(),
|
||||
connector,
|
||||
refund_type: req.refund_type.unwrap_or_default().foreign_into(),
|
||||
total_amount: payment_attempt.amount,
|
||||
refund_amount,
|
||||
currency,
|
||||
created_at: common_utils::date_time::now(),
|
||||
modified_at: common_utils::date_time::now(),
|
||||
refund_status: enums::RefundStatus::Pending,
|
||||
metadata: req.metadata,
|
||||
description: req.reason.clone(),
|
||||
attempt_id: payment_attempt.attempt_id.clone(),
|
||||
refund_reason: req.reason,
|
||||
profile_id: payment_intent.profile_id.clone(),
|
||||
merchant_connector_id: payment_attempt.merchant_connector_id.clone(),
|
||||
charges: req.charges,
|
||||
connector_refund_id: None,
|
||||
sent_to_gateway: Default::default(),
|
||||
refund_arn: None,
|
||||
updated_by: Default::default(),
|
||||
organization_id: merchant_account.organization_id.clone(),
|
||||
};
|
||||
|
||||
let refund = match db
|
||||
.insert_refund(refund_create_req, merchant_account.storage_scheme)
|
||||
|
||||
@ -19,7 +19,13 @@ pub async fn generate_sample_data_for_user(
|
||||
req: SampleDataRequest,
|
||||
_req_state: ReqState,
|
||||
) -> SampleDataApiResponse<()> {
|
||||
let sample_data = generate_sample_data(&state, req, &user_from_token.merchant_id).await?;
|
||||
let sample_data = generate_sample_data(
|
||||
&state,
|
||||
req,
|
||||
&user_from_token.merchant_id,
|
||||
&user_from_token.org_id,
|
||||
)
|
||||
.await?;
|
||||
|
||||
let key_store = state
|
||||
.store
|
||||
|
||||
@ -902,6 +902,7 @@ async fn get_or_update_dispute_object(
|
||||
option_dispute: Option<diesel_models::dispute::Dispute>,
|
||||
dispute_details: api::disputes::DisputePayload,
|
||||
merchant_id: &common_utils::id_type::MerchantId,
|
||||
organization_id: &common_utils::id_type::OrganizationId,
|
||||
payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,
|
||||
event_type: webhooks::IncomingWebhookEvent,
|
||||
business_profile: &domain::BusinessProfile,
|
||||
@ -935,6 +936,7 @@ async fn get_or_update_dispute_object(
|
||||
evidence: None,
|
||||
merchant_connector_id: payment_attempt.merchant_connector_id.clone(),
|
||||
dispute_amount: dispute_details.amount.parse::<i64>().unwrap_or(0),
|
||||
organization_id: organization_id.clone(),
|
||||
};
|
||||
state
|
||||
.store
|
||||
@ -1377,6 +1379,7 @@ async fn disputes_incoming_webhook_flow(
|
||||
option_dispute,
|
||||
dispute_details,
|
||||
merchant_account.get_id(),
|
||||
&merchant_account.organization_id,
|
||||
&payment_attempt,
|
||||
event_type,
|
||||
&business_profile,
|
||||
|
||||
@ -170,6 +170,7 @@ impl DisputeInterface for MockDb {
|
||||
evidence,
|
||||
merchant_connector_id: dispute.merchant_connector_id,
|
||||
dispute_amount: dispute.dispute_amount,
|
||||
organization_id: dispute.organization_id,
|
||||
};
|
||||
|
||||
locked_disputes.push(new_dispute.clone());
|
||||
@ -404,9 +405,10 @@ mod tests {
|
||||
connector_updated_at: Some(datetime!(2019-01-03 0:00)),
|
||||
connector: "connector".into(),
|
||||
evidence: Some(Secret::from(Value::String("evidence".into()))),
|
||||
profile_id: None,
|
||||
profile_id: Some(common_utils::generate_profile_id_of_default_length()),
|
||||
merchant_connector_id: None,
|
||||
dispute_amount: 1040,
|
||||
organization_id: common_utils::id_type::OrganizationId::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -398,6 +398,7 @@ mod storage {
|
||||
updated_by: new.updated_by.clone(),
|
||||
merchant_connector_id: new.merchant_connector_id.clone(),
|
||||
charges: new.charges.clone(),
|
||||
organization_id: new.organization_id.clone(),
|
||||
};
|
||||
|
||||
let field = format!(
|
||||
@ -859,6 +860,7 @@ impl RefundInterface for MockDb {
|
||||
updated_by: new.updated_by,
|
||||
merchant_connector_id: new.merchant_connector_id,
|
||||
charges: new.charges,
|
||||
organization_id: new.organization_id,
|
||||
};
|
||||
refunds.push(refund.clone());
|
||||
Ok(refund)
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
use common_utils::id_type;
|
||||
use diesel_models::enums as storage_enums;
|
||||
use masking::Secret;
|
||||
use time::OffsetDateTime;
|
||||
@ -13,7 +14,7 @@ pub struct KafkaDispute<'a> {
|
||||
pub dispute_status: &'a storage_enums::DisputeStatus,
|
||||
pub payment_id: &'a String,
|
||||
pub attempt_id: &'a String,
|
||||
pub merchant_id: &'a common_utils::id_type::MerchantId,
|
||||
pub merchant_id: &'a id_type::MerchantId,
|
||||
pub connector_status: &'a String,
|
||||
pub connector_dispute_id: &'a String,
|
||||
pub connector_reason: Option<&'a String>,
|
||||
@ -30,8 +31,9 @@ pub struct KafkaDispute<'a> {
|
||||
pub modified_at: OffsetDateTime,
|
||||
pub connector: &'a String,
|
||||
pub evidence: &'a Secret<serde_json::Value>,
|
||||
pub profile_id: Option<&'a common_utils::id_type::ProfileId>,
|
||||
pub merchant_connector_id: Option<&'a common_utils::id_type::MerchantConnectorAccountId>,
|
||||
pub profile_id: Option<&'a id_type::ProfileId>,
|
||||
pub merchant_connector_id: Option<&'a id_type::MerchantConnectorAccountId>,
|
||||
pub organization_id: &'a id_type::OrganizationId,
|
||||
}
|
||||
|
||||
impl<'a> KafkaDispute<'a> {
|
||||
@ -58,6 +60,7 @@ impl<'a> KafkaDispute<'a> {
|
||||
evidence: &dispute.evidence,
|
||||
profile_id: dispute.profile_id.as_ref(),
|
||||
merchant_connector_id: dispute.merchant_connector_id.as_ref(),
|
||||
organization_id: &dispute.organization_id,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,6 +33,7 @@ pub struct KafkaDisputeEvent<'a> {
|
||||
pub evidence: &'a Secret<serde_json::Value>,
|
||||
pub profile_id: Option<&'a common_utils::id_type::ProfileId>,
|
||||
pub merchant_connector_id: Option<&'a common_utils::id_type::MerchantConnectorAccountId>,
|
||||
pub organization_id: &'a common_utils::id_type::OrganizationId,
|
||||
}
|
||||
|
||||
impl<'a> KafkaDisputeEvent<'a> {
|
||||
@ -59,6 +60,7 @@ impl<'a> KafkaDisputeEvent<'a> {
|
||||
evidence: &dispute.evidence,
|
||||
profile_id: dispute.profile_id.as_ref(),
|
||||
merchant_connector_id: dispute.merchant_connector_id.as_ref(),
|
||||
organization_id: &dispute.organization_id,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// use diesel_models::enums::MandateDetails;
|
||||
use common_utils::types::MinorUnit;
|
||||
use common_utils::{id_type, types::MinorUnit};
|
||||
use diesel_models::enums as storage_enums;
|
||||
use hyperswitch_domain_models::{
|
||||
mandates::MandateDetails, payments::payment_attempt::PaymentAttempt,
|
||||
@ -9,7 +9,7 @@ use time::OffsetDateTime;
|
||||
#[derive(serde::Serialize, Debug)]
|
||||
pub struct KafkaPaymentAttempt<'a> {
|
||||
pub payment_id: &'a String,
|
||||
pub merchant_id: &'a common_utils::id_type::MerchantId,
|
||||
pub merchant_id: &'a id_type::MerchantId,
|
||||
pub attempt_id: &'a String,
|
||||
pub status: storage_enums::AttemptStatus,
|
||||
pub amount: MinorUnit,
|
||||
@ -47,13 +47,16 @@ pub struct KafkaPaymentAttempt<'a> {
|
||||
pub error_reason: Option<&'a String>,
|
||||
pub multiple_capture_count: Option<i16>,
|
||||
pub amount_capturable: MinorUnit,
|
||||
pub merchant_connector_id: Option<&'a common_utils::id_type::MerchantConnectorAccountId>,
|
||||
pub merchant_connector_id: Option<&'a id_type::MerchantConnectorAccountId>,
|
||||
pub net_amount: MinorUnit,
|
||||
pub unified_code: Option<&'a String>,
|
||||
pub unified_message: Option<&'a String>,
|
||||
pub mandate_data: Option<&'a MandateDetails>,
|
||||
pub client_source: Option<&'a String>,
|
||||
pub client_version: Option<&'a String>,
|
||||
pub profile_id: &'a id_type::ProfileId,
|
||||
pub organization_id: &'a id_type::OrganizationId,
|
||||
pub card_network: Option<String>,
|
||||
}
|
||||
|
||||
impl<'a> KafkaPaymentAttempt<'a> {
|
||||
@ -100,6 +103,17 @@ impl<'a> KafkaPaymentAttempt<'a> {
|
||||
mandate_data: attempt.mandate_data.as_ref(),
|
||||
client_source: attempt.client_source.as_ref(),
|
||||
client_version: attempt.client_version.as_ref(),
|
||||
profile_id: &attempt.profile_id,
|
||||
organization_id: &attempt.organization_id,
|
||||
card_network: attempt
|
||||
.payment_method_data
|
||||
.as_ref()
|
||||
.and_then(|data| data.as_object())
|
||||
.and_then(|pm| pm.get("card"))
|
||||
.and_then(|data| data.as_object())
|
||||
.and_then(|card| card.get("card_network"))
|
||||
.and_then(|network| network.as_str())
|
||||
.map(|network| network.to_string()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// use diesel_models::enums::MandateDetails;
|
||||
use common_utils::types::MinorUnit;
|
||||
use common_utils::{id_type, types::MinorUnit};
|
||||
use diesel_models::enums as storage_enums;
|
||||
use hyperswitch_domain_models::{
|
||||
mandates::MandateDetails, payments::payment_attempt::PaymentAttempt,
|
||||
@ -10,7 +10,7 @@ use time::OffsetDateTime;
|
||||
#[derive(serde::Serialize, Debug)]
|
||||
pub struct KafkaPaymentAttemptEvent<'a> {
|
||||
pub payment_id: &'a String,
|
||||
pub merchant_id: &'a common_utils::id_type::MerchantId,
|
||||
pub merchant_id: &'a id_type::MerchantId,
|
||||
pub attempt_id: &'a String,
|
||||
pub status: storage_enums::AttemptStatus,
|
||||
pub amount: MinorUnit,
|
||||
@ -48,13 +48,16 @@ pub struct KafkaPaymentAttemptEvent<'a> {
|
||||
pub error_reason: Option<&'a String>,
|
||||
pub multiple_capture_count: Option<i16>,
|
||||
pub amount_capturable: MinorUnit,
|
||||
pub merchant_connector_id: Option<&'a common_utils::id_type::MerchantConnectorAccountId>,
|
||||
pub merchant_connector_id: Option<&'a id_type::MerchantConnectorAccountId>,
|
||||
pub net_amount: MinorUnit,
|
||||
pub unified_code: Option<&'a String>,
|
||||
pub unified_message: Option<&'a String>,
|
||||
pub mandate_data: Option<&'a MandateDetails>,
|
||||
pub client_source: Option<&'a String>,
|
||||
pub client_version: Option<&'a String>,
|
||||
pub profile_id: &'a id_type::ProfileId,
|
||||
pub organization_id: &'a id_type::OrganizationId,
|
||||
pub card_network: Option<String>,
|
||||
}
|
||||
|
||||
impl<'a> KafkaPaymentAttemptEvent<'a> {
|
||||
@ -101,6 +104,17 @@ impl<'a> KafkaPaymentAttemptEvent<'a> {
|
||||
mandate_data: attempt.mandate_data.as_ref(),
|
||||
client_source: attempt.client_source.as_ref(),
|
||||
client_version: attempt.client_version.as_ref(),
|
||||
profile_id: &attempt.profile_id,
|
||||
organization_id: &attempt.organization_id,
|
||||
card_network: attempt
|
||||
.payment_method_data
|
||||
.as_ref()
|
||||
.and_then(|data| data.as_object())
|
||||
.and_then(|pm| pm.get("card"))
|
||||
.and_then(|data| data.as_object())
|
||||
.and_then(|card| card.get("card_network"))
|
||||
.and_then(|network| network.as_str())
|
||||
.map(|network| network.to_string()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,6 +40,7 @@ pub struct KafkaPaymentIntent<'a> {
|
||||
pub customer_email: Option<HashedString<pii::EmailStrategy>>,
|
||||
pub feature_metadata: Option<&'a Value>,
|
||||
pub merchant_order_reference_id: Option<&'a String>,
|
||||
pub organization_id: &'a id_type::OrganizationId,
|
||||
}
|
||||
|
||||
impl<'a> KafkaPaymentIntent<'a> {
|
||||
@ -82,6 +83,7 @@ impl<'a> KafkaPaymentIntent<'a> {
|
||||
.map(|email| HashedString::from(Secret::new(email.to_string()))),
|
||||
feature_metadata: intent.feature_metadata.as_ref(),
|
||||
merchant_order_reference_id: intent.merchant_order_reference_id.as_ref(),
|
||||
organization_id: &intent.organization_id,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,6 +41,7 @@ pub struct KafkaPaymentIntentEvent<'a> {
|
||||
pub customer_email: Option<HashedString<pii::EmailStrategy>>,
|
||||
pub feature_metadata: Option<&'a Value>,
|
||||
pub merchant_order_reference_id: Option<&'a String>,
|
||||
pub organization_id: &'a id_type::OrganizationId,
|
||||
}
|
||||
|
||||
impl<'a> KafkaPaymentIntentEvent<'a> {
|
||||
@ -83,6 +84,7 @@ impl<'a> KafkaPaymentIntentEvent<'a> {
|
||||
.map(|email| HashedString::from(Secret::new(email.to_string()))),
|
||||
feature_metadata: intent.feature_metadata.as_ref(),
|
||||
merchant_order_reference_id: intent.merchant_order_reference_id.as_ref(),
|
||||
organization_id: &intent.organization_id,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
use common_utils::types::MinorUnit;
|
||||
use common_utils::{id_type, types::MinorUnit};
|
||||
use diesel_models::{enums as storage_enums, refund::Refund};
|
||||
use time::OffsetDateTime;
|
||||
|
||||
@ -7,7 +7,7 @@ pub struct KafkaRefund<'a> {
|
||||
pub internal_reference_id: &'a String,
|
||||
pub refund_id: &'a String, //merchant_reference id
|
||||
pub payment_id: &'a String,
|
||||
pub merchant_id: &'a common_utils::id_type::MerchantId,
|
||||
pub merchant_id: &'a id_type::MerchantId,
|
||||
pub connector_transaction_id: &'a String,
|
||||
pub connector: &'a String,
|
||||
pub connector_refund_id: Option<&'a String>,
|
||||
@ -28,6 +28,8 @@ pub struct KafkaRefund<'a> {
|
||||
pub attempt_id: &'a String,
|
||||
pub refund_reason: Option<&'a String>,
|
||||
pub refund_error_code: Option<&'a String>,
|
||||
pub profile_id: Option<&'a id_type::ProfileId>,
|
||||
pub organization_id: &'a id_type::OrganizationId,
|
||||
}
|
||||
|
||||
impl<'a> KafkaRefund<'a> {
|
||||
@ -55,6 +57,8 @@ impl<'a> KafkaRefund<'a> {
|
||||
attempt_id: &refund.attempt_id,
|
||||
refund_reason: refund.refund_reason.as_ref(),
|
||||
refund_error_code: refund.refund_error_code.as_ref(),
|
||||
profile_id: refund.profile_id.as_ref(),
|
||||
organization_id: &refund.organization_id,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
use common_utils::types::MinorUnit;
|
||||
use common_utils::{id_type, types::MinorUnit};
|
||||
use diesel_models::{enums as storage_enums, refund::Refund};
|
||||
use time::OffsetDateTime;
|
||||
|
||||
@ -8,7 +8,7 @@ pub struct KafkaRefundEvent<'a> {
|
||||
pub internal_reference_id: &'a String,
|
||||
pub refund_id: &'a String, //merchant_reference id
|
||||
pub payment_id: &'a String,
|
||||
pub merchant_id: &'a common_utils::id_type::MerchantId,
|
||||
pub merchant_id: &'a id_type::MerchantId,
|
||||
pub connector_transaction_id: &'a String,
|
||||
pub connector: &'a String,
|
||||
pub connector_refund_id: Option<&'a String>,
|
||||
@ -29,6 +29,8 @@ pub struct KafkaRefundEvent<'a> {
|
||||
pub attempt_id: &'a String,
|
||||
pub refund_reason: Option<&'a String>,
|
||||
pub refund_error_code: Option<&'a String>,
|
||||
pub profile_id: Option<&'a id_type::ProfileId>,
|
||||
pub organization_id: &'a id_type::OrganizationId,
|
||||
}
|
||||
|
||||
impl<'a> KafkaRefundEvent<'a> {
|
||||
@ -56,6 +58,8 @@ impl<'a> KafkaRefundEvent<'a> {
|
||||
attempt_id: &refund.attempt_id,
|
||||
refund_reason: refund.refund_reason.as_ref(),
|
||||
refund_error_code: refund.refund_error_code.as_ref(),
|
||||
profile_id: refund.profile_id.as_ref(),
|
||||
organization_id: &refund.organization_id,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,7 +129,60 @@ mod tests {
|
||||
connector: Some(connector),
|
||||
created_at: current_time.into(),
|
||||
modified_at: current_time.into(),
|
||||
..PaymentAttemptNew::default()
|
||||
merchant_id: Default::default(),
|
||||
attempt_id: Default::default(),
|
||||
status: Default::default(),
|
||||
amount: Default::default(),
|
||||
net_amount: Default::default(),
|
||||
currency: Default::default(),
|
||||
save_to_locker: Default::default(),
|
||||
error_message: Default::default(),
|
||||
offer_amount: Default::default(),
|
||||
surcharge_amount: Default::default(),
|
||||
tax_amount: Default::default(),
|
||||
payment_method_id: Default::default(),
|
||||
payment_method: Default::default(),
|
||||
capture_method: Default::default(),
|
||||
capture_on: Default::default(),
|
||||
confirm: Default::default(),
|
||||
authentication_type: Default::default(),
|
||||
last_synced: Default::default(),
|
||||
cancellation_reason: Default::default(),
|
||||
amount_to_capture: Default::default(),
|
||||
mandate_id: Default::default(),
|
||||
browser_info: Default::default(),
|
||||
payment_token: Default::default(),
|
||||
error_code: Default::default(),
|
||||
connector_metadata: Default::default(),
|
||||
payment_experience: Default::default(),
|
||||
payment_method_type: Default::default(),
|
||||
payment_method_data: Default::default(),
|
||||
business_sub_label: Default::default(),
|
||||
straight_through_algorithm: Default::default(),
|
||||
preprocessing_step_id: Default::default(),
|
||||
mandate_details: Default::default(),
|
||||
error_reason: Default::default(),
|
||||
connector_response_reference_id: Default::default(),
|
||||
multiple_capture_count: Default::default(),
|
||||
amount_capturable: Default::default(),
|
||||
updated_by: Default::default(),
|
||||
authentication_data: Default::default(),
|
||||
encoded_data: Default::default(),
|
||||
merchant_connector_id: Default::default(),
|
||||
unified_code: Default::default(),
|
||||
unified_message: Default::default(),
|
||||
external_three_ds_authentication_attempted: Default::default(),
|
||||
authentication_connector: Default::default(),
|
||||
authentication_id: Default::default(),
|
||||
mandate_data: Default::default(),
|
||||
payment_method_billing_address_id: Default::default(),
|
||||
fingerprint_id: Default::default(),
|
||||
charge_id: Default::default(),
|
||||
client_source: Default::default(),
|
||||
client_version: Default::default(),
|
||||
customer_acceptance: Default::default(),
|
||||
profile_id: common_utils::generate_profile_id_of_default_length(),
|
||||
organization_id: Default::default(),
|
||||
};
|
||||
|
||||
let store = state
|
||||
@ -163,7 +216,58 @@ mod tests {
|
||||
created_at: current_time.into(),
|
||||
modified_at: current_time.into(),
|
||||
attempt_id: attempt_id.clone(),
|
||||
..PaymentAttemptNew::default()
|
||||
status: Default::default(),
|
||||
amount: Default::default(),
|
||||
net_amount: Default::default(),
|
||||
currency: Default::default(),
|
||||
save_to_locker: Default::default(),
|
||||
error_message: Default::default(),
|
||||
offer_amount: Default::default(),
|
||||
surcharge_amount: Default::default(),
|
||||
tax_amount: Default::default(),
|
||||
payment_method_id: Default::default(),
|
||||
payment_method: Default::default(),
|
||||
capture_method: Default::default(),
|
||||
capture_on: Default::default(),
|
||||
confirm: Default::default(),
|
||||
authentication_type: Default::default(),
|
||||
last_synced: Default::default(),
|
||||
cancellation_reason: Default::default(),
|
||||
amount_to_capture: Default::default(),
|
||||
mandate_id: Default::default(),
|
||||
browser_info: Default::default(),
|
||||
payment_token: Default::default(),
|
||||
error_code: Default::default(),
|
||||
connector_metadata: Default::default(),
|
||||
payment_experience: Default::default(),
|
||||
payment_method_type: Default::default(),
|
||||
payment_method_data: Default::default(),
|
||||
business_sub_label: Default::default(),
|
||||
straight_through_algorithm: Default::default(),
|
||||
preprocessing_step_id: Default::default(),
|
||||
mandate_details: Default::default(),
|
||||
error_reason: Default::default(),
|
||||
connector_response_reference_id: Default::default(),
|
||||
multiple_capture_count: Default::default(),
|
||||
amount_capturable: Default::default(),
|
||||
updated_by: Default::default(),
|
||||
authentication_data: Default::default(),
|
||||
encoded_data: Default::default(),
|
||||
merchant_connector_id: Default::default(),
|
||||
unified_code: Default::default(),
|
||||
unified_message: Default::default(),
|
||||
external_three_ds_authentication_attempted: Default::default(),
|
||||
authentication_connector: Default::default(),
|
||||
authentication_id: Default::default(),
|
||||
mandate_data: Default::default(),
|
||||
payment_method_billing_address_id: Default::default(),
|
||||
fingerprint_id: Default::default(),
|
||||
charge_id: Default::default(),
|
||||
client_source: Default::default(),
|
||||
client_version: Default::default(),
|
||||
customer_acceptance: Default::default(),
|
||||
profile_id: common_utils::generate_profile_id_of_default_length(),
|
||||
organization_id: Default::default(),
|
||||
};
|
||||
let store = state
|
||||
.stores
|
||||
@ -207,10 +311,59 @@ mod tests {
|
||||
connector: Some(connector),
|
||||
created_at: current_time.into(),
|
||||
modified_at: current_time.into(),
|
||||
// Adding a mandate_id
|
||||
mandate_id: Some("man_121212".to_string()),
|
||||
attempt_id: uuid.clone(),
|
||||
..PaymentAttemptNew::default()
|
||||
status: Default::default(),
|
||||
amount: Default::default(),
|
||||
net_amount: Default::default(),
|
||||
currency: Default::default(),
|
||||
save_to_locker: Default::default(),
|
||||
error_message: Default::default(),
|
||||
offer_amount: Default::default(),
|
||||
surcharge_amount: Default::default(),
|
||||
tax_amount: Default::default(),
|
||||
payment_method_id: Default::default(),
|
||||
payment_method: Default::default(),
|
||||
capture_method: Default::default(),
|
||||
capture_on: Default::default(),
|
||||
confirm: Default::default(),
|
||||
authentication_type: Default::default(),
|
||||
last_synced: Default::default(),
|
||||
cancellation_reason: Default::default(),
|
||||
amount_to_capture: Default::default(),
|
||||
browser_info: Default::default(),
|
||||
payment_token: Default::default(),
|
||||
error_code: Default::default(),
|
||||
connector_metadata: Default::default(),
|
||||
payment_experience: Default::default(),
|
||||
payment_method_type: Default::default(),
|
||||
payment_method_data: Default::default(),
|
||||
business_sub_label: Default::default(),
|
||||
straight_through_algorithm: Default::default(),
|
||||
preprocessing_step_id: Default::default(),
|
||||
mandate_details: Default::default(),
|
||||
error_reason: Default::default(),
|
||||
connector_response_reference_id: Default::default(),
|
||||
multiple_capture_count: Default::default(),
|
||||
amount_capturable: Default::default(),
|
||||
updated_by: Default::default(),
|
||||
authentication_data: Default::default(),
|
||||
encoded_data: Default::default(),
|
||||
merchant_connector_id: Default::default(),
|
||||
unified_code: Default::default(),
|
||||
unified_message: Default::default(),
|
||||
external_three_ds_authentication_attempted: Default::default(),
|
||||
authentication_connector: Default::default(),
|
||||
authentication_id: Default::default(),
|
||||
mandate_data: Default::default(),
|
||||
payment_method_billing_address_id: Default::default(),
|
||||
fingerprint_id: Default::default(),
|
||||
charge_id: Default::default(),
|
||||
client_source: Default::default(),
|
||||
client_version: Default::default(),
|
||||
customer_acceptance: Default::default(),
|
||||
profile_id: common_utils::generate_profile_id_of_default_length(),
|
||||
organization_id: Default::default(),
|
||||
};
|
||||
let store = state
|
||||
.stores
|
||||
|
||||
@ -20,6 +20,7 @@ pub async fn generate_sample_data(
|
||||
state: &SessionState,
|
||||
req: SampleDataRequest,
|
||||
merchant_id: &id_type::MerchantId,
|
||||
org_id: &id_type::OrganizationId,
|
||||
) -> SampleDataResult<Vec<(PaymentIntent, PaymentAttemptBatchNew, Option<RefundNew>)>> {
|
||||
let sample_data_size: usize = req.record.unwrap_or(100);
|
||||
let key_manager_state = &state.into();
|
||||
@ -252,6 +253,7 @@ pub async fn generate_sample_data(
|
||||
merchant_order_reference_id: Default::default(),
|
||||
shipping_details: None,
|
||||
is_payment_processor_token_flow: None,
|
||||
organization_id: org_id.clone(),
|
||||
};
|
||||
let payment_attempt = PaymentAttemptBatchNew {
|
||||
attempt_id: attempt_id.clone(),
|
||||
@ -329,6 +331,8 @@ pub async fn generate_sample_data(
|
||||
client_source: None,
|
||||
client_version: None,
|
||||
customer_acceptance: None,
|
||||
profile_id: profile_id.clone(),
|
||||
organization_id: org_id.clone(),
|
||||
};
|
||||
|
||||
let refund = if refunds_count < number_of_refunds && !is_failed_payment {
|
||||
@ -364,6 +368,7 @@ pub async fn generate_sample_data(
|
||||
updated_by: merchant_from_db.storage_scheme.to_string(),
|
||||
merchant_connector_id: payment_attempt.merchant_connector_id.clone(),
|
||||
charges: None,
|
||||
organization_id: org_id.clone(),
|
||||
})
|
||||
} else {
|
||||
None
|
||||
|
||||
Reference in New Issue
Block a user