Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into frm_oss
Browse files Browse the repository at this point in the history
  • Loading branch information
kashif-m committed Dec 5, 2023
2 parents e82fa94 + 792e642 commit eba33d1
Show file tree
Hide file tree
Showing 46 changed files with 1,678 additions and 70 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions config/config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -481,3 +481,9 @@ ttl = 900

[frm]
enabled = true

[paypal_onboarding]
client_id = "paypal_client_id" # Client ID for PayPal onboarding
client_secret = "paypal_secret_key" # Secret key for PayPal onboarding
partner_id = "paypal_partner_id" # Partner ID for PayPal onboarding
enabled = true # Switch to enable or disable PayPal onboarding
6 changes: 6 additions & 0 deletions config/development.toml
Original file line number Diff line number Diff line change
Expand Up @@ -509,3 +509,9 @@ dbname = "hyperswitch_db"
pool_size = 5
connection_timeout = 10
queue_strategy = "Fifo"

[connector_onboarding.paypal]
client_id = ""
client_secret = ""
partner_id = ""
enabled = true
5 changes: 5 additions & 0 deletions config/docker_compose.toml
Original file line number Diff line number Diff line change
Expand Up @@ -366,3 +366,8 @@ ttl = 900 # 15 * 60 seconds

[frm]
enabled = true

[connector_onboarding.paypal]
client_id = ""
client_secret = ""
partner_id = ""
54 changes: 54 additions & 0 deletions crates/api_models/src/connector_onboarding.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
use super::{admin, enums};

#[derive(serde::Deserialize, serde::Serialize, Debug, Clone)]
pub struct ActionUrlRequest {
pub connector: enums::Connector,
pub connector_id: String,
pub return_url: String,
}

#[derive(serde::Serialize, Debug, Clone)]
#[serde(rename_all = "lowercase")]
pub enum ActionUrlResponse {
PayPal(PayPalActionUrlResponse),
}

#[derive(serde::Deserialize, serde::Serialize, Debug, Clone)]
pub struct OnboardingSyncRequest {
pub profile_id: String,
pub connector_id: String,
pub connector: enums::Connector,
}

#[derive(serde::Serialize, Debug, Clone)]
pub struct PayPalActionUrlResponse {
pub action_url: String,
}

#[derive(serde::Serialize, Debug, Clone)]
#[serde(rename_all = "lowercase")]
pub enum OnboardingStatus {
PayPal(PayPalOnboardingStatus),
}

#[derive(serde::Serialize, Debug, Clone)]
#[serde(rename_all = "snake_case")]
pub enum PayPalOnboardingStatus {
AccountNotFound,
PaymentsNotReceivable,
PpcpCustomDenied,
MorePermissionsNeeded,
EmailNotVerified,
Success(PayPalOnboardingDone),
ConnectorIntegrated(admin::MerchantConnectorResponse),
}

#[derive(serde::Serialize, Debug, Clone)]
pub struct PayPalOnboardingDone {
pub payer_id: String,
}

#[derive(serde::Serialize, Debug, Clone)]
pub struct PayPalIntegrationDone {
pub connector_id: String,
}
1 change: 1 addition & 0 deletions crates/api_models/src/events.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub mod connector_onboarding;
pub mod customer;
pub mod gsm;
mod locker_migration;
Expand Down
12 changes: 12 additions & 0 deletions crates/api_models/src/events/connector_onboarding.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use common_utils::events::{ApiEventMetric, ApiEventsType};

use crate::connector_onboarding::{
ActionUrlRequest, ActionUrlResponse, OnboardingStatus, OnboardingSyncRequest,
};

common_utils::impl_misc_api_event_type!(
ActionUrlRequest,
ActionUrlResponse,
OnboardingSyncRequest,
OnboardingStatus
);
9 changes: 7 additions & 2 deletions crates/api_models/src/events/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ use crate::user::{
GetMetaDataRequest, GetMetaDataResponse, GetMultipleMetaDataPayload, SetMetaDataRequest,
},
AuthorizeResponse, ChangePasswordRequest, ConnectAccountRequest, CreateInternalUserRequest,
DashboardEntryResponse, GetUsersResponse, SignUpRequest, SignUpWithMerchantIdRequest,
DashboardEntryResponse, ForgotPasswordRequest, GetUsersResponse, InviteUserRequest,
InviteUserResponse, ResetPasswordRequest, SignUpRequest, SignUpWithMerchantIdRequest,
SwitchMerchantIdRequest, UserMerchantCreate,
};

Expand All @@ -33,7 +34,11 @@ common_utils::impl_misc_api_event_type!(
UserMerchantCreate,
GetUsersResponse,
AuthorizeResponse,
ConnectAccountRequest
ConnectAccountRequest,
ForgotPasswordRequest,
ResetPasswordRequest,
InviteUserRequest,
InviteUserResponse
);

#[cfg(feature = "dummy_connector")]
Expand Down
1 change: 1 addition & 0 deletions crates/api_models/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pub mod api_keys;
pub mod bank_accounts;
pub mod cards_info;
pub mod conditional_configs;
pub mod connector_onboarding;
pub mod currency;
pub mod customers;
pub mod disputes;
Expand Down
2 changes: 1 addition & 1 deletion crates/api_models/src/refunds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ pub struct RefundListMetaData {
pub currency: Vec<enums::Currency>,
/// The list of available refund status filters
#[schema(value_type = Vec<RefundStatus>)]
pub status: Vec<enums::RefundStatus>,
pub refund_status: Vec<enums::RefundStatus>,
}

/// The status for refunds
Expand Down
23 changes: 23 additions & 0 deletions crates/api_models/src/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,29 @@ pub struct ChangePasswordRequest {
pub old_password: Secret<String>,
}

#[derive(serde::Deserialize, Debug, serde::Serialize)]
pub struct ForgotPasswordRequest {
pub email: pii::Email,
}

#[derive(serde::Deserialize, Debug, serde::Serialize)]
pub struct ResetPasswordRequest {
pub token: Secret<String>,
pub password: Secret<String>,
}

#[derive(Debug, serde::Deserialize, serde::Serialize, Clone)]
pub struct InviteUserRequest {
pub email: pii::Email,
pub name: Secret<String>,
pub role_id: String,
}

#[derive(Debug, serde::Serialize)]
pub struct InviteUserResponse {
pub is_email_sent: bool,
}

#[derive(Debug, serde::Deserialize, serde::Serialize)]
pub struct SwitchMerchantIdRequest {
pub merchant_id: String,
Expand Down
41 changes: 40 additions & 1 deletion crates/api_models/src/user/dashboard_metadata.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use common_enums::CountryAlpha2;
use common_utils::pii;
use masking::Secret;
use strum::EnumString;

Expand All @@ -12,8 +14,11 @@ pub enum SetMetaDataRequest {
ConfiguredRouting(ConfiguredRouting),
TestPayment(TestPayment),
IntegrationMethod(IntegrationMethod),
ConfigurationType(ConfigurationType),
IntegrationCompleted,
SPRoutingConfigured(ConfiguredRouting),
Feedback(Feedback),
ProdIntent(ProdIntent),
SPTestPayment,
DownloadWoocom,
ConfigureWoocom,
Expand Down Expand Up @@ -49,10 +54,38 @@ pub struct TestPayment {
pub payment_id: String,
}

#[derive(Debug, serde::Deserialize, serde::Serialize)]
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone)]
pub struct IntegrationMethod {
pub integration_type: String,
}
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone)]
pub enum ConfigurationType {
Single,
Multiple,
}

#[derive(Debug, serde::Deserialize, serde::Serialize, Clone)]
pub struct Feedback {
pub email: pii::Email,
pub description: Option<String>,
pub rating: Option<i32>,
pub category: Option<String>,
}
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone)]
pub struct ProdIntent {
pub legal_business_name: Option<String>,
pub business_label: Option<String>,
pub business_location: Option<CountryAlpha2>,
pub display_name: Option<String>,
pub poc_email: Option<String>,
pub business_type: Option<String>,
pub business_identifier: Option<String>,
pub business_website: Option<String>,
pub poc_name: Option<String>,
pub poc_contact: Option<String>,
pub comments: Option<String>,
pub is_completed: bool,
}

#[derive(Debug, serde::Deserialize, EnumString, serde::Serialize)]
pub enum GetMetaDataRequest {
Expand All @@ -65,10 +98,13 @@ pub enum GetMetaDataRequest {
ConfiguredRouting,
TestPayment,
IntegrationMethod,
ConfigurationType,
IntegrationCompleted,
StripeConnected,
PaypalConnected,
SPRoutingConfigured,
Feedback,
ProdIntent,
SPTestPayment,
DownloadWoocom,
ConfigureWoocom,
Expand Down Expand Up @@ -98,10 +134,13 @@ pub enum GetMetaDataResponse {
ConfiguredRouting(Option<ConfiguredRouting>),
TestPayment(Option<TestPayment>),
IntegrationMethod(Option<IntegrationMethod>),
ConfigurationType(Option<ConfigurationType>),
IntegrationCompleted(bool),
StripeConnected(Option<ProcessorConnected>),
PaypalConnected(Option<ProcessorConnected>),
SPRoutingConfigured(Option<ConfiguredRouting>),
Feedback(Option<Feedback>),
ProdIntent(Option<ProdIntent>),
SPTestPayment(bool),
DownloadWoocom(bool),
ConfigureWoocom(bool),
Expand Down
1 change: 0 additions & 1 deletion crates/common_utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ strum = { version = "0.24.1", features = ["derive"] }
thiserror = "1.0.40"
time = { version = "0.3.21", features = ["serde", "serde-well-known", "std"] }
tokio = { version = "1.28.2", features = ["macros", "rt-multi-thread"], optional = true }
utoipa = { version = "3.3.0", features = ["preserve_order"] }

# First party crates
common_enums = { version = "0.1.0", path = "../common_enums" }
Expand Down
3 changes: 3 additions & 0 deletions crates/diesel_models/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,10 +452,13 @@ pub enum DashboardMetadata {
ConfiguredRouting,
TestPayment,
IntegrationMethod,
ConfigurationType,
IntegrationCompleted,
StripeConnected,
PaypalConnected,
SpRoutingConfigured,
Feedback,
ProdIntent,
SpTestPayment,
DownloadWoocom,
ConfigureWoocom,
Expand Down
45 changes: 30 additions & 15 deletions crates/diesel_models/src/query/dashboard_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,36 @@ impl DashboardMetadata {
data_key: enums::DashboardMetadata,
dashboard_metadata_update: DashboardMetadataUpdate,
) -> StorageResult<Self> {
generics::generic_update_with_unique_predicate_get_result::<
<Self as HasTable>::Table,
_,
_,
_,
>(
conn,
dsl::user_id
.eq(user_id.to_owned())
.and(dsl::merchant_id.eq(merchant_id.to_owned()))
.and(dsl::org_id.eq(org_id.to_owned()))
.and(dsl::data_key.eq(data_key.to_owned())),
DashboardMetadataUpdateInternal::from(dashboard_metadata_update),
)
.await
let predicate = dsl::merchant_id
.eq(merchant_id.to_owned())
.and(dsl::org_id.eq(org_id.to_owned()))
.and(dsl::data_key.eq(data_key.to_owned()));

if let Some(uid) = user_id {
generics::generic_update_with_unique_predicate_get_result::<
<Self as HasTable>::Table,
_,
_,
_,
>(
conn,
predicate.and(dsl::user_id.eq(uid)),
DashboardMetadataUpdateInternal::from(dashboard_metadata_update),
)
.await
} else {
generics::generic_update_with_unique_predicate_get_result::<
<Self as HasTable>::Table,
_,
_,
_,
>(
conn,
predicate.and(dsl::user_id.is_null()),
DashboardMetadataUpdateInternal::from(dashboard_metadata_update),
)
.await
}
}

pub async fn find_user_scoped_dashboard_metadata(
Expand Down
Loading

0 comments on commit eba33d1

Please sign in to comment.