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

feat(core): implemented platform merchant account #6882

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 14 additions & 0 deletions crates/diesel_models/src/merchant_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pub struct MerchantAccount {
pub payment_link_config: Option<serde_json::Value>,
pub pm_collect_link_config: Option<serde_json::Value>,
pub version: common_enums::ApiVersion,
pub is_platform_account: bool,
}

#[cfg(feature = "v1")]
Expand Down Expand Up @@ -83,6 +84,7 @@ pub struct MerchantAccountSetter {
pub payment_link_config: Option<serde_json::Value>,
pub pm_collect_link_config: Option<serde_json::Value>,
pub version: common_enums::ApiVersion,
pub is_platform_account: bool,
}

#[cfg(feature = "v1")]
Expand Down Expand Up @@ -117,6 +119,7 @@ impl From<MerchantAccountSetter> for MerchantAccount {
payment_link_config: item.payment_link_config,
pm_collect_link_config: item.pm_collect_link_config,
version: item.version,
is_platform_account: item.is_platform_account,
}
}
}
Expand Down Expand Up @@ -148,6 +151,7 @@ pub struct MerchantAccount {
pub recon_status: storage_enums::ReconStatus,
pub version: common_enums::ApiVersion,
pub id: common_utils::id_type::MerchantId,
pub is_platform_account: bool,
}

#[cfg(feature = "v2")]
Expand All @@ -165,6 +169,7 @@ impl From<MerchantAccountSetter> for MerchantAccount {
organization_id: item.organization_id,
recon_status: item.recon_status,
version: item.version,
is_platform_account: item.is_platform_account,
}
}
}
Expand All @@ -182,6 +187,7 @@ pub struct MerchantAccountSetter {
pub organization_id: common_utils::id_type::OrganizationId,
pub recon_status: storage_enums::ReconStatus,
pub version: common_enums::ApiVersion,
pub is_platform_account: bool,
}

impl MerchantAccount {
Expand Down Expand Up @@ -228,6 +234,7 @@ pub struct MerchantAccountNew {
pub payment_link_config: Option<serde_json::Value>,
pub pm_collect_link_config: Option<serde_json::Value>,
pub version: common_enums::ApiVersion,
pub is_platform_account: bool,
}

#[cfg(feature = "v2")]
Expand All @@ -244,6 +251,7 @@ pub struct MerchantAccountNew {
pub recon_status: storage_enums::ReconStatus,
pub id: common_utils::id_type::MerchantId,
pub version: common_enums::ApiVersion,
pub is_platform_account: bool,
}

#[cfg(feature = "v2")]
Expand All @@ -258,6 +266,7 @@ pub struct MerchantAccountUpdateInternal {
pub modified_at: time::PrimitiveDateTime,
pub organization_id: Option<common_utils::id_type::OrganizationId>,
pub recon_status: Option<storage_enums::ReconStatus>,
pub is_platform_account: Option<bool>,
}

#[cfg(feature = "v2")]
Expand All @@ -272,6 +281,7 @@ impl MerchantAccountUpdateInternal {
modified_at,
organization_id,
recon_status,
is_platform_account,
} = self;

MerchantAccount {
Expand All @@ -286,6 +296,7 @@ impl MerchantAccountUpdateInternal {
recon_status: recon_status.unwrap_or(source.recon_status),
version: source.version,
id: source.id,
is_platform_account: is_platform_account.unwrap_or(source.is_platform_account),
}
}
}
Expand Down Expand Up @@ -319,6 +330,7 @@ pub struct MerchantAccountUpdateInternal {
pub recon_status: Option<storage_enums::ReconStatus>,
pub payment_link_config: Option<serde_json::Value>,
pub pm_collect_link_config: Option<serde_json::Value>,
pub is_platform_account: Option<bool>,
}

#[cfg(feature = "v1")]
Expand Down Expand Up @@ -350,6 +362,7 @@ impl MerchantAccountUpdateInternal {
recon_status,
payment_link_config,
pm_collect_link_config,
is_platform_account,
} = self;

MerchantAccount {
Expand Down Expand Up @@ -385,6 +398,7 @@ impl MerchantAccountUpdateInternal {
payment_link_config: payment_link_config.or(source.payment_link_config),
pm_collect_link_config: pm_collect_link_config.or(source.pm_collect_link_config),
version: source.version,
is_platform_account: is_platform_account.unwrap_or(source.is_platform_account),
}
}
}
4 changes: 4 additions & 0 deletions crates/diesel_models/src/payment_intent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ pub struct PaymentIntent {
pub payment_link_config: Option<PaymentLinkConfigRequestForPayments>,
pub id: common_utils::id_type::GlobalPaymentId,
pub psd2_sca_exemption_type: Option<storage_enums::ScaExemptionType>,
pub platform_merchant_id: Option<common_utils::id_type::MerchantId>,
pub split_payments: Option<common_types::payments::SplitPaymentsRequest>,
}

Expand Down Expand Up @@ -139,6 +140,7 @@ pub struct PaymentIntent {
pub tax_details: Option<TaxDetails>,
pub skip_external_tax_calculation: Option<bool>,
pub psd2_sca_exemption_type: Option<storage_enums::ScaExemptionType>,
pub platform_merchant_id: Option<common_utils::id_type::MerchantId>,
pub split_payments: Option<common_types::payments::SplitPaymentsRequest>,
}

Expand Down Expand Up @@ -298,6 +300,7 @@ pub struct PaymentIntentNew {
pub enable_payment_link: Option<bool>,
pub apply_mit_exemption: Option<bool>,
pub id: common_utils::id_type::GlobalPaymentId,
pub platform_merchant_id: Option<common_utils::id_type::MerchantId>,
}

#[cfg(feature = "v1")]
Expand Down Expand Up @@ -364,6 +367,7 @@ pub struct PaymentIntentNew {
pub tax_details: Option<TaxDetails>,
pub skip_external_tax_calculation: Option<bool>,
pub psd2_sca_exemption_type: Option<storage_enums::ScaExemptionType>,
pub platform_merchant_id: Option<common_utils::id_type::MerchantId>,
pub split_payments: Option<common_types::payments::SplitPaymentsRequest>,
}

Expand Down
3 changes: 3 additions & 0 deletions crates/diesel_models/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,7 @@ diesel::table! {
payment_link_config -> Nullable<Jsonb>,
pm_collect_link_config -> Nullable<Jsonb>,
version -> ApiVersion,
is_platform_account -> Bool,
}
}

Expand Down Expand Up @@ -967,6 +968,8 @@ diesel::table! {
tax_details -> Nullable<Jsonb>,
skip_external_tax_calculation -> Nullable<Bool>,
psd2_sca_exemption_type -> Nullable<ScaExemptionType>,
#[max_length = 64]
platform_merchant_id -> Nullable<Varchar>,
split_payments -> Nullable<Jsonb>,
}
}
Expand Down
3 changes: 3 additions & 0 deletions crates/diesel_models/src/schema_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,7 @@ diesel::table! {
version -> ApiVersion,
#[max_length = 64]
id -> Varchar,
is_platform_account -> Bool,
}
}

Expand Down Expand Up @@ -930,6 +931,8 @@ diesel::table! {
#[max_length = 64]
id -> Varchar,
psd2_sca_exemption_type -> Nullable<ScaExemptionType>,
#[max_length = 64]
platform_merchant_id -> Nullable<Varchar>,
split_payments -> Nullable<Jsonb>,
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,10 @@ pub enum ApiErrorResponse {
field_names: String,
connector_transaction_id: Option<String>,
},
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_42", message = "API does not support platform account operation")]
PlatformAccountAuthNotSupported,
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_43", message = "Invalid platform account operation")]
InvalidPlatformOperation,
}

#[derive(Clone)]
Expand Down Expand Up @@ -667,6 +671,12 @@ impl ErrorSwitch<api_models::errors::types::ApiErrorResponse> for ApiErrorRespon
..Default::default()
})
)),
Self::PlatformAccountAuthNotSupported => {
AER::BadRequest(ApiError::new("IR", 42, "API does not support platform operation", None))
}
Self::InvalidPlatformOperation => {
AER::Unauthorized(ApiError::new("IR", 43, "Invalid platform account operation", None))
}
}
}
}
Expand Down
Loading
Loading