Skip to content

Commit

Permalink
feat(FRM): Revise post FRM core flows (#4394)
Browse files Browse the repository at this point in the history
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
  • Loading branch information
srujanchikke and hyperswitch-bot[bot] committed Apr 29, 2024
1 parent c3a1db1 commit 01ec7c6
Show file tree
Hide file tree
Showing 20 changed files with 337 additions and 125 deletions.
2 changes: 1 addition & 1 deletion crates/common_enums/src/enums.rs
Expand Up @@ -2249,7 +2249,7 @@ pub enum FrmSuggestion {
#[default]
FrmCancelTransaction,
FrmManualReview,
FrmAutoRefund,
FrmAuthorizeTransaction, // When manual capture payment which was marked fraud and held, when approved needs to be authorized.
}

#[derive(
Expand Down
1 change: 1 addition & 0 deletions crates/data_models/src/payments/payment_attempt.rs
Expand Up @@ -303,6 +303,7 @@ pub enum PaymentAttemptUpdate {
currency: storage_enums::Currency,
status: storage_enums::AttemptStatus,
authentication_type: Option<storage_enums::AuthenticationType>,
capture_method: Option<storage_enums::CaptureMethod>,
payment_method: Option<storage_enums::PaymentMethod>,
browser_info: Option<serde_json::Value>,
connector: Option<String>,
Expand Down
3 changes: 3 additions & 0 deletions crates/data_models/src/payments/payment_intent.rs
Expand Up @@ -182,6 +182,7 @@ pub enum PaymentIntentUpdate {
updated_by: String,
},
ApproveUpdate {
status: storage_enums::IntentStatus,
merchant_decision: Option<String>,
updated_by: String,
},
Expand Down Expand Up @@ -382,9 +383,11 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
..Default::default()
},
PaymentIntentUpdate::ApproveUpdate {
status,
merchant_decision,
updated_by,
} => Self {
status: Some(status),
merchant_decision,
updated_by,
..Default::default()
Expand Down
7 changes: 7 additions & 0 deletions crates/diesel_models/src/fraud_check.rs
@@ -1,3 +1,4 @@
use common_enums as storage_enums;
use diesel::{AsChangeset, Identifiable, Insertable, Queryable};
use masking::{Deserialize, Serialize};
use time::PrimitiveDateTime;
Expand Down Expand Up @@ -25,6 +26,7 @@ pub struct FraudCheck {
pub metadata: Option<serde_json::Value>,
pub modified_at: PrimitiveDateTime,
pub last_step: FraudCheckLastStep,
pub payment_capture_method: Option<storage_enums::CaptureMethod>, // In postFrm, we are updating capture method from automatic to manual. To store the merchant actual capture method, we are storing the actual capture method in payment_capture_method. It will be useful while approving the FRM decision.
}

#[derive(router_derive::Setter, Clone, Debug, Insertable, router_derive::DebugAsDisplay)]
Expand All @@ -46,6 +48,7 @@ pub struct FraudCheckNew {
pub metadata: Option<serde_json::Value>,
pub modified_at: PrimitiveDateTime,
pub last_step: FraudCheckLastStep,
pub payment_capture_method: Option<storage_enums::CaptureMethod>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand All @@ -59,6 +62,7 @@ pub enum FraudCheckUpdate {
metadata: Option<serde_json::Value>,
modified_at: PrimitiveDateTime,
last_step: FraudCheckLastStep,
payment_capture_method: Option<storage_enums::CaptureMethod>,
},
ErrorUpdate {
status: FraudCheckStatus,
Expand All @@ -76,6 +80,7 @@ pub struct FraudCheckUpdateInternal {
frm_error: Option<Option<String>>,
metadata: Option<serde_json::Value>,
last_step: FraudCheckLastStep,
payment_capture_method: Option<storage_enums::CaptureMethod>,
}

impl From<FraudCheckUpdate> for FraudCheckUpdateInternal {
Expand All @@ -89,13 +94,15 @@ impl From<FraudCheckUpdate> for FraudCheckUpdateInternal {
metadata,
modified_at: _,
last_step,
payment_capture_method,
} => Self {
frm_status: Some(frm_status),
frm_transaction_id,
frm_reason,
frm_score,
metadata,
last_step,
payment_capture_method,
..Default::default()
},
FraudCheckUpdate::ErrorUpdate {
Expand Down
3 changes: 3 additions & 0 deletions crates/diesel_models/src/payment_attempt.rs
Expand Up @@ -209,6 +209,7 @@ pub enum PaymentAttemptUpdate {
currency: storage_enums::Currency,
status: storage_enums::AttemptStatus,
authentication_type: Option<storage_enums::AuthenticationType>,
capture_method: Option<storage_enums::CaptureMethod>,
payment_method: Option<storage_enums::PaymentMethod>,
browser_info: Option<serde_json::Value>,
connector: Option<String>,
Expand Down Expand Up @@ -559,6 +560,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
amount,
currency,
authentication_type,
capture_method,
status,
payment_method,
browser_info,
Expand Down Expand Up @@ -610,6 +612,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
payment_method_billing_address_id,
fingerprint_id,
payment_method_id,
capture_method,
..Default::default()
},
PaymentAttemptUpdate::VoidUpdate {
Expand Down
3 changes: 3 additions & 0 deletions crates/diesel_models/src/payment_intent.rs
Expand Up @@ -180,6 +180,7 @@ pub enum PaymentIntentUpdate {
updated_by: String,
},
ApproveUpdate {
status: storage_enums::IntentStatus,
merchant_decision: Option<String>,
updated_by: String,
},
Expand Down Expand Up @@ -456,9 +457,11 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
..Default::default()
},
PaymentIntentUpdate::ApproveUpdate {
status,
merchant_decision,
updated_by,
} => Self {
status: Some(status),
merchant_decision,
updated_by,
..Default::default()
Expand Down
1 change: 1 addition & 0 deletions crates/diesel_models/src/schema.rs
Expand Up @@ -450,6 +450,7 @@ diesel::table! {
modified_at -> Timestamp,
#[max_length = 64]
last_step -> Varchar,
payment_capture_method -> Nullable<CaptureMethod>,
}
}

Expand Down

0 comments on commit 01ec7c6

Please sign in to comment.