Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(FRM): refactor frm configs #4581

Merged
merged 22 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e4a8fc4
refactor frm configs
srujanchikke May 8, 2024
f059940
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] May 8, 2024
11779d3
handle error message only in case of fraud payment
srujanchikke May 9, 2024
79fec1b
Merge branch 'frm_configs' of github.com:juspay/hyperswitch into frm_…
srujanchikke May 9, 2024
c4d7e1b
add check for authentication failure from frm processor
srujanchikke May 10, 2024
b98f209
Merge branch 'main' of github.com:juspay/hyperswitch into frm_configs
srujanchikke May 10, 2024
3c1710f
populate frm_metadata in payments response
srujanchikke May 10, 2024
219170d
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] May 10, 2024
86c45a8
remove frm_metadata from payment_data
srujanchikke May 10, 2024
ba93967
Merge branch 'frm_configs' of github.com:juspay/hyperswitch into frm_…
srujanchikke May 10, 2024
e4d12b6
spell check fix
srujanchikke May 10, 2024
e33c73a
resolve conflicts
srujanchikke May 15, 2024
bc88654
provide backward compatibility
srujanchikke May 16, 2024
b51c5a4
use to_owned instead of clone
srujanchikke May 16, 2024
9c693b9
Merge branch 'main' into frm_configs
srujanchikke May 16, 2024
669e30a
provide comments
srujanchikke May 16, 2024
ab278a4
add openapi_spec
srujanchikke May 16, 2024
036ce1e
add open api spec
srujanchikke May 16, 2024
cb02c1b
add openapi_spec
srujanchikke May 16, 2024
f073443
resolve comments
srujanchikke May 17, 2024
712ec21
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] May 17, 2024
a8d4e76
Merge branch 'main' into frm_configs
srujanchikke May 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions crates/api_models/src/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -729,8 +729,11 @@ pub struct FrmPaymentMethod {
///payment methods(card, wallet, etc) that can be used in the payment
#[schema(value_type = PaymentMethod,example = "card")]
pub payment_method: Option<common_enums::PaymentMethod>,
///payment method types(credit, debit) that can be used in the payment
pub payment_method_types: Vec<FrmPaymentMethodType>,
///payment method types(credit, debit) that can be used in the payment. This field is deprecated. It has not been removed to provide backward compatibility.
pub payment_method_types: Option<Vec<FrmPaymentMethodType>>,
///frm flow type to be used...can be pre/post
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
///frm flow type to be used...can be pre/post
///frm flow type to be used, can be pre/post

#[schema(value_type = FrmPreferredFlowTypes)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#[schema(value_type = FrmPreferredFlowTypes)]
#[schema(value_type = Option<FrmPreferredFlowTypes>)]

pub flow: Option<api_enums::FrmPreferredFlowTypes>,
}

///Details of FrmPaymentMethodType are mentioned here... it should be passed in payment connector create api call, and stored in merchant_connector_table
Expand Down
7 changes: 6 additions & 1 deletion crates/api_models/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,8 @@ pub struct PaymentsRequest {
pub session_expiry: Option<u32>,

/// additional data related to some frm connectors
pub frm_metadata: Option<serde_json::Value>,
#[schema(value_type = Option<Object>, example = r#"{ "coverage_request" : "fraud", "fulfillment_method" : "delivery" }"#)]
pub frm_metadata: Option<pii::SecretSerdeValue>,

/// Whether to perform external authentication (if applicable)
#[schema(example = true)]
Expand Down Expand Up @@ -3397,6 +3398,10 @@ pub struct PaymentsResponse {
#[schema(example = "2022-09-10T10:11:12Z")]
#[serde(default, with = "common_utils::custom_serde::iso8601::option")]
pub updated: Option<PrimitiveDateTime>,

/// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. FRM Metadata is useful for storing additional, structured information on an object related to FRM.
#[schema(value_type = Option<Object>, example = r#"{ "fulfillment_method" : "deliver", "coverage_request" : "fraud" }"#)]
pub frm_metadata: Option<pii::SecretSerdeValue>,
}

#[derive(Setter, Clone, Default, Debug, PartialEq, serde::Serialize, ToSchema)]
Expand Down
12 changes: 11 additions & 1 deletion crates/diesel_models/src/payment_intent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pub struct PaymentIntent {
pub session_expiry: Option<PrimitiveDateTime>,
pub fingerprint_id: Option<String>,
pub request_external_three_ds_authentication: Option<bool>,
pub frm_metadata: Option<pii::SecretSerdeValue>,
}

#[derive(
Expand Down Expand Up @@ -111,6 +112,7 @@ pub struct PaymentIntentNew {
pub session_expiry: Option<PrimitiveDateTime>,
pub fingerprint_id: Option<String>,
pub request_external_three_ds_authentication: Option<bool>,
pub frm_metadata: Option<pii::SecretSerdeValue>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand Down Expand Up @@ -167,6 +169,7 @@ pub enum PaymentIntentUpdate {
session_expiry: Option<PrimitiveDateTime>,
fingerprint_id: Option<String>,
request_external_three_ds_authentication: Option<bool>,
frm_metadata: Option<pii::SecretSerdeValue>,
},
PaymentAttemptAndAttemptCountUpdate {
active_attempt_id: String,
Expand Down Expand Up @@ -236,6 +239,7 @@ pub struct PaymentIntentUpdateInternal {
pub session_expiry: Option<PrimitiveDateTime>,
pub fingerprint_id: Option<String>,
pub request_external_three_ds_authentication: Option<bool>,
pub frm_metadata: Option<pii::SecretSerdeValue>,
}

impl PaymentIntentUpdate {
Expand Down Expand Up @@ -271,6 +275,7 @@ impl PaymentIntentUpdate {
session_expiry,
fingerprint_id,
request_external_three_ds_authentication,
frm_metadata,
} = self.into();
PaymentIntent {
amount: amount.unwrap_or(source.amount),
Expand Down Expand Up @@ -308,6 +313,8 @@ impl PaymentIntentUpdate {
session_expiry: session_expiry.or(source.session_expiry),
request_external_three_ds_authentication: request_external_three_ds_authentication
.or(source.request_external_three_ds_authentication),

frm_metadata: frm_metadata.or(source.frm_metadata),
..source
}
}
Expand Down Expand Up @@ -337,6 +344,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
session_expiry,
fingerprint_id,
request_external_three_ds_authentication,
frm_metadata,
} => Self {
amount: Some(amount),
currency: Some(currency),
Expand All @@ -359,6 +367,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
session_expiry,
fingerprint_id,
request_external_three_ds_authentication,
frm_metadata,
..Default::default()
},
PaymentIntentUpdate::MetadataUpdate {
Expand Down Expand Up @@ -542,7 +551,8 @@ mod tests {
"incremental_authorization_allowed": null,
"authorization_count": null,
"session_expiry": null,
"fingerprint_id": null
"fingerprint_id": null,
"frm_metadata": null
}"#;
let deserialized_payment_intent =
serde_json::from_str::<super::PaymentIntent>(serialized_payment_intent);
Expand Down
1 change: 1 addition & 0 deletions crates/diesel_models/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,7 @@ diesel::table! {
#[max_length = 64]
fingerprint_id -> Nullable<Varchar>,
request_external_three_ds_authentication -> Nullable<Bool>,
frm_metadata -> Nullable<Jsonb>,
}
}

Expand Down
1 change: 1 addition & 0 deletions crates/hyperswitch_domain_models/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@ pub struct PaymentIntent {
#[serde(with = "common_utils::custom_serde::iso8601::option")]
pub session_expiry: Option<PrimitiveDateTime>,
pub request_external_three_ds_authentication: Option<bool>,
pub frm_metadata: Option<pii::SecretSerdeValue>,
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ pub struct PaymentIntentNew {
pub description: Option<String>,
pub return_url: Option<String>,
pub metadata: Option<pii::SecretSerdeValue>,
pub frm_metadata: Option<pii::SecretSerdeValue>,
pub connector_id: Option<String>,
pub shipping_address_id: Option<String>,
pub billing_address_id: Option<String>,
Expand Down Expand Up @@ -164,6 +165,7 @@ pub enum PaymentIntentUpdate {
statement_descriptor_suffix: Option<String>,
order_details: Option<Vec<pii::SecretSerdeValue>>,
metadata: Option<pii::SecretSerdeValue>,
frm_metadata: Option<pii::SecretSerdeValue>,
payment_confirm_source: Option<storage_enums::PaymentSource>,
updated_by: String,
fingerprint_id: Option<String>,
Expand Down Expand Up @@ -237,6 +239,7 @@ pub struct PaymentIntentUpdateInternal {
pub fingerprint_id: Option<String>,
pub session_expiry: Option<PrimitiveDateTime>,
pub request_external_three_ds_authentication: Option<bool>,
pub frm_metadata: Option<pii::SecretSerdeValue>,
}

impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
Expand All @@ -263,6 +266,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
fingerprint_id,
session_expiry,
request_external_three_ds_authentication,
frm_metadata,
} => Self {
amount: Some(amount),
currency: Some(currency),
Expand All @@ -285,6 +289,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
fingerprint_id,
session_expiry,
request_external_three_ds_authentication,
frm_metadata,
..Default::default()
},
PaymentIntentUpdate::MetadataUpdate {
Expand Down
2 changes: 1 addition & 1 deletion crates/hyperswitch_domain_models/src/router_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub struct RouterData<Flow, Request, Response> {
/// Contains apple pay flow type simplified or manual
pub apple_pay_flow: Option<common_enums::enums::ApplePayFlow>,

pub frm_metadata: Option<serde_json::Value>,
pub frm_metadata: Option<common_utils::pii::SecretSerdeValue>,

pub dispute_id: Option<String>,
pub refund_id: Option<String>,
Expand Down
4 changes: 3 additions & 1 deletion crates/router/src/connector/signifyd/transformers/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ impl TryFrom<&frm_types::FrmSaleRouterData> for SignifydPaymentsSaleRequest {
field_name: "frm_metadata",
})?
.parse_value("Signifyd Frm Metadata")
.change_context(errors::ConnectorError::RequestEncodingFailed)?;
.change_context(errors::ConnectorError::InvalidDataFormat {
field_name: "frm_metadata",
})?;
let ship_address = item.get_shipping_address()?;
let billing_address = item.get_billing()?;
let street_addr = ship_address.get_line1()?;
Expand Down
Loading
Loading