Skip to content

Commit

Permalink
feat(business_profile): add profile id in affected tables and modify …
Browse files Browse the repository at this point in the history
…api contract (#1971)
  • Loading branch information
Narayanbhat166 authored Aug 23, 2023
1 parent bca9d50 commit fe8d4c2
Show file tree
Hide file tree
Showing 29 changed files with 346 additions and 76 deletions.
19 changes: 18 additions & 1 deletion crates/api_models/src/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ pub struct MerchantAccountUpdate {
///Will be used to expire client secret after certain amount of time to be supplied in seconds
///(900) for 15 mins
pub intent_fulfillment_time: Option<u32>,

/// The default business profile that must be used for creating merchant accounts and payments
/// To unset this field, pass an empty string
#[schema(max_length = 64)]
pub default_profile: Option<String>,
}

#[derive(Clone, Debug, ToSchema, Serialize)]
Expand Down Expand Up @@ -263,6 +268,10 @@ pub struct MerchantAccountResponse {

/// A boolean value to indicate if the merchant has recon service is enabled or not, by default value is false
pub is_recon_enabled: bool,

/// The default business profile that must be used for creating merchant accounts and payments
#[schema(max_length = 64)]
pub default_profile: Option<String>,
}

#[derive(Clone, Debug, Deserialize, ToSchema, Serialize)]
Expand Down Expand Up @@ -617,6 +626,9 @@ pub struct MerchantConnectorCreate {
}
}))]
pub connector_webhook_details: Option<MerchantConnectorWebhookDetails>,

/// Identifier for the business profile, if not provided default will be chosen from merchant account
pub profile_id: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
Expand Down Expand Up @@ -711,6 +723,11 @@ pub struct MerchantConnectorResponse {
}
}))]
pub connector_webhook_details: Option<MerchantConnectorWebhookDetails>,

/// The business profile this connector must be created in
/// default value from merchant account is taken if not passed
#[schema(max_length = 64)]
pub profile_id: Option<String>,
}

/// Create a new Merchant Connector for the merchant account. The connector could be a payment processor / facilitator / acquirer or specialized services like Fraud / Accounting etc."
Expand Down Expand Up @@ -936,7 +953,7 @@ pub enum PayoutStraightThroughAlgorithm {
Single(api_enums::PayoutConnectors),
}

#[derive(Clone, Debug, Deserialize, ToSchema)]
#[derive(Clone, Debug, Deserialize, ToSchema, Default)]
#[serde(deny_unknown_fields)]
pub struct BusinessProfileCreate {
/// A short name to identify the business profile
Expand Down
7 changes: 7 additions & 0 deletions crates/api_models/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,10 @@ pub struct PaymentsRequest {

/// additional data that might be required by hyperswitch
pub feature_metadata: Option<FeatureMetadata>,

/// The business profile to use for this payment, if not passed the default business profile
/// associated with the merchant account will be used.
pub profile_id: Option<String>,
}

#[derive(
Expand Down Expand Up @@ -1898,6 +1902,9 @@ pub struct PaymentsResponse {
/// reference to the payment at connector side
#[schema(value_type = Option<String>, example = "993672945374576J")]
pub reference_id: Option<String>,

/// The business profile that is associated with this payment
pub profile_id: Option<String>,
}

#[derive(Clone, Debug, serde::Deserialize, ToSchema)]
Expand Down
2 changes: 2 additions & 0 deletions crates/data_models/src/payments/payment_intent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ pub struct PaymentIntent {
pub connector_metadata: Option<serde_json::Value>,
pub feature_metadata: Option<serde_json::Value>,
pub attempt_count: i16,
pub profile_id: Option<String>,
}

#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
Expand Down Expand Up @@ -126,6 +127,7 @@ pub struct PaymentIntentNew {
pub connector_metadata: Option<serde_json::Value>,
pub feature_metadata: Option<serde_json::Value>,
pub attempt_count: i16,
pub profile_id: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand Down
2 changes: 2 additions & 0 deletions crates/diesel_models/src/dispute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub struct DisputeNew {
pub connector_updated_at: Option<PrimitiveDateTime>,
pub connector: String,
pub evidence: Option<Secret<serde_json::Value>>,
pub profile_id: Option<String>,
}

#[derive(Clone, Debug, PartialEq, Serialize, Identifiable, Queryable)]
Expand Down Expand Up @@ -55,6 +56,7 @@ pub struct Dispute {
pub modified_at: PrimitiveDateTime,
pub connector: String,
pub evidence: Secret<serde_json::Value>,
pub profile_id: Option<String>,
}

#[derive(Debug)]
Expand Down
3 changes: 3 additions & 0 deletions crates/diesel_models/src/merchant_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub struct MerchantAccount {
pub payout_routing_algorithm: Option<serde_json::Value>,
pub organization_id: Option<String>,
pub is_recon_enabled: bool,
pub default_profile: Option<String>,
}

#[derive(Clone, Debug, Insertable, router_derive::DebugAsDisplay)]
Expand Down Expand Up @@ -65,6 +66,7 @@ pub struct MerchantAccountNew {
pub payout_routing_algorithm: Option<serde_json::Value>,
pub organization_id: Option<String>,
pub is_recon_enabled: bool,
pub default_profile: Option<String>,
}

#[derive(Clone, Debug, Default, AsChangeset, router_derive::DebugAsDisplay)]
Expand All @@ -91,4 +93,5 @@ pub struct MerchantAccountUpdateInternal {
pub payout_routing_algorithm: Option<serde_json::Value>,
pub organization_id: Option<String>,
pub is_recon_enabled: bool,
pub default_profile: Option<Option<String>>,
}
2 changes: 2 additions & 0 deletions crates/diesel_models/src/merchant_connector_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub struct MerchantConnectorAccount {
pub connector_webhook_details: Option<pii::SecretSerdeValue>,
#[diesel(deserialize_as = super::OptionalDieselArray<pii::SecretSerdeValue>)]
pub frm_config: Option<Vec<Secret<serde_json::Value>>>,
pub profile_id: Option<String>,
}

#[derive(Clone, Debug, Insertable, router_derive::DebugAsDisplay)]
Expand All @@ -62,6 +63,7 @@ pub struct MerchantConnectorAccountNew {
pub connector_webhook_details: Option<pii::SecretSerdeValue>,
#[diesel(deserialize_as = super::OptionalDieselArray<pii::SecretSerdeValue>)]
pub frm_config: Option<Vec<Secret<serde_json::Value>>>,
pub profile_id: Option<String>,
}

#[derive(Clone, Debug, AsChangeset, router_derive::DebugAsDisplay)]
Expand Down
2 changes: 2 additions & 0 deletions crates/diesel_models/src/payment_intent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub struct PaymentIntent {
pub connector_metadata: Option<serde_json::Value>,
pub feature_metadata: Option<serde_json::Value>,
pub attempt_count: i16,
pub profile_id: Option<String>,
}

#[derive(
Expand Down Expand Up @@ -90,6 +91,7 @@ pub struct PaymentIntentNew {
pub connector_metadata: Option<serde_json::Value>,
pub feature_metadata: Option<serde_json::Value>,
pub attempt_count: i16,
pub profile_id: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand Down
3 changes: 3 additions & 0 deletions crates/diesel_models/src/payout_attempt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub struct PayoutAttempt {
pub created_at: PrimitiveDateTime,
#[serde(with = "common_utils::custom_serde::iso8601")]
pub last_modified_at: PrimitiveDateTime,
pub profile_id: Option<String>,
}

impl Default for PayoutAttempt {
Expand All @@ -49,6 +50,7 @@ impl Default for PayoutAttempt {
business_label: None,
created_at: now,
last_modified_at: now,
profile_id: None,
}
}
}
Expand Down Expand Up @@ -85,6 +87,7 @@ pub struct PayoutAttemptNew {
pub created_at: Option<PrimitiveDateTime>,
#[serde(default, with = "common_utils::custom_serde::iso8601::option")]
pub last_modified_at: Option<PrimitiveDateTime>,
pub profile_id: Option<String>,
}

#[derive(Debug)]
Expand Down
2 changes: 2 additions & 0 deletions crates/diesel_models/src/refund.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub struct Refund {
pub attempt_id: String,
pub refund_reason: Option<String>,
pub refund_error_code: Option<String>,
pub profile_id: Option<String>,
}

#[derive(
Expand Down Expand Up @@ -75,6 +76,7 @@ pub struct RefundNew {
pub description: Option<String>,
pub attempt_id: String,
pub refund_reason: Option<String>,
pub profile_id: Option<String>,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
Expand Down
12 changes: 12 additions & 0 deletions crates/diesel_models/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ diesel::table! {
#[max_length = 255]
connector -> Varchar,
evidence -> Jsonb,
#[max_length = 64]
profile_id -> Nullable<Varchar>,
}
}

Expand Down Expand Up @@ -428,6 +430,8 @@ diesel::table! {
#[max_length = 32]
organization_id -> Nullable<Varchar>,
is_recon_enabled -> Bool,
#[max_length = 64]
default_profile -> Nullable<Varchar>,
}
}

Expand Down Expand Up @@ -461,6 +465,8 @@ diesel::table! {
modified_at -> Timestamp,
connector_webhook_details -> Nullable<Jsonb>,
frm_config -> Nullable<Array<Nullable<Jsonb>>>,
#[max_length = 64]
profile_id -> Nullable<Varchar>,
}
}

Expand Down Expand Up @@ -586,6 +592,8 @@ diesel::table! {
connector_metadata -> Nullable<Json>,
feature_metadata -> Nullable<Json>,
attempt_count -> Int2,
#[max_length = 64]
profile_id -> Nullable<Varchar>,
}
}

Expand Down Expand Up @@ -661,6 +669,8 @@ diesel::table! {
business_label -> Nullable<Varchar>,
created_at -> Timestamp,
last_modified_at -> Timestamp,
#[max_length = 64]
profile_id -> Nullable<Varchar>,
}
}

Expand Down Expand Up @@ -764,6 +774,8 @@ diesel::table! {
#[max_length = 255]
refund_reason -> Nullable<Varchar>,
refund_error_code -> Nullable<Text>,
#[max_length = 64]
profile_id -> Nullable<Varchar>,
}
}

Expand Down
Loading

0 comments on commit fe8d4c2

Please sign in to comment.