Skip to content

Commit

Permalink
Merge branch 'main' into sample-data-for-user
Browse files Browse the repository at this point in the history
  • Loading branch information
racnan committed Nov 30, 2023
2 parents 7dd1f3d + 1ca2ba4 commit d51d098
Show file tree
Hide file tree
Showing 142 changed files with 2,764 additions and 93 deletions.
1 change: 1 addition & 0 deletions connector-template/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ impl<F,T> TryFrom<types::ResponseRouterData<F, {{project-name | downcase | pasca
connector_metadata: None,
network_txn_id: None,
connector_response_reference_id: None,
incremental_authorization_allowed: None,
}),
..item.data
})
Expand Down
32 changes: 32 additions & 0 deletions crates/api_models/src/admin.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::collections::HashMap;

use common_utils::{
crypto::{Encryptable, OptionalEncryptableName},
pii,
Expand Down Expand Up @@ -614,6 +616,36 @@ pub struct MerchantConnectorCreate {
pub status: Option<api_enums::ConnectorStatus>,
}

// Different patterns of authentication.
#[derive(Default, Debug, Clone, serde::Deserialize, serde::Serialize)]
#[serde(tag = "auth_type")]
pub enum ConnectorAuthType {
TemporaryAuth,
HeaderKey {
api_key: Secret<String>,
},
BodyKey {
api_key: Secret<String>,
key1: Secret<String>,
},
SignatureKey {
api_key: Secret<String>,
key1: Secret<String>,
api_secret: Secret<String>,
},
MultiAuthKey {
api_key: Secret<String>,
key1: Secret<String>,
api_secret: Secret<String>,
key2: Secret<String>,
},
CurrencyAuthKey {
auth_key_map: HashMap<common_enums::Currency, pii::SecretSerdeValue>,
},
#[default]
NoKey,
}

#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
#[serde(deny_unknown_fields)]
pub struct MerchantConnectorWebhookDetails {
Expand Down
15 changes: 13 additions & 2 deletions crates/api_models/src/events/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ use common_utils::events::{ApiEventMetric, ApiEventsType};

#[cfg(feature = "dummy_connector")]
use crate::user::sample_data::SampleDataRequest;
use crate::user::{ChangePasswordRequest, ConnectAccountRequest, ConnectAccountResponse};
use crate::user::{
dashboard_metadata::{
GetMetaDataRequest, GetMetaDataResponse, GetMultipleMetaDataPayload, SetMetaDataRequest,
},
ChangePasswordRequest, ConnectAccountRequest, ConnectAccountResponse,
};

impl ApiEventMetric for ConnectAccountResponse {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Expand All @@ -15,7 +20,13 @@ impl ApiEventMetric for ConnectAccountResponse {

impl ApiEventMetric for ConnectAccountRequest {}

common_utils::impl_misc_api_event_type!(ChangePasswordRequest);
common_utils::impl_misc_api_event_type!(
ChangePasswordRequest,
GetMultipleMetaDataPayload,
GetMetaDataResponse,
GetMetaDataRequest,
SetMetaDataRequest
);

#[cfg(feature = "dummy_connector")]
common_utils::impl_misc_api_event_type!(SampleDataRequest);
1 change: 1 addition & 0 deletions crates/api_models/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ pub mod routing;
pub mod surcharge_decision_configs;
pub mod user;
pub mod verifications;
pub mod verify_connector;
pub mod webhooks;
10 changes: 8 additions & 2 deletions crates/api_models/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,9 @@ pub struct PaymentsRequest {
/// The type of the payment that differentiates between normal and various types of mandate payments
#[schema(value_type = Option<PaymentType>)]
pub payment_type: Option<api_enums::PaymentType>,

///Request for an incremental authorization
pub request_incremental_authorization: Option<bool>,
}

impl PaymentsRequest {
Expand Down Expand Up @@ -1204,10 +1207,10 @@ pub enum BankRedirectData {
OpenBankingUk {
// Issuer banks
#[schema(value_type = BankNames)]
issuer: api_enums::BankNames,
issuer: Option<api_enums::BankNames>,
/// The country for bank payment
#[schema(value_type = CountryAlpha2, example = "US")]
country: api_enums::CountryAlpha2,
country: Option<api_enums::CountryAlpha2>,
},
Przelewy24 {
//Issuer banks
Expand Down Expand Up @@ -2210,6 +2213,9 @@ pub struct PaymentsResponse {

/// Identifier of the connector ( merchant connector account ) which was chosen to make the payment
pub merchant_connector_id: Option<String>,

/// If true incremental authorization can be performed on this payment
pub incremental_authorization_allowed: Option<bool>,
}

#[derive(Clone, Debug, serde::Deserialize, ToSchema, serde::Serialize)]
Expand Down
1 change: 1 addition & 0 deletions crates/api_models/src/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use common_utils::pii;
use masking::Secret;
#[cfg(feature = "dummy_connector")]
pub mod sample_data;
pub mod dashboard_metadata;

#[derive(serde::Deserialize, Debug, Clone, serde::Serialize)]
pub struct ConnectAccountRequest {
Expand Down
110 changes: 110 additions & 0 deletions crates/api_models/src/user/dashboard_metadata.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
use masking::Secret;
use strum::EnumString;

#[derive(Debug, serde::Deserialize, serde::Serialize)]
pub enum SetMetaDataRequest {
ProductionAgreement(ProductionAgreementRequest),
SetupProcessor(SetupProcessor),
ConfigureEndpoint,
SetupComplete,
FirstProcessorConnected(ProcessorConnected),
SecondProcessorConnected(ProcessorConnected),
ConfiguredRouting(ConfiguredRouting),
TestPayment(TestPayment),
IntegrationMethod(IntegrationMethod),
IntegrationCompleted,
SPRoutingConfigured(ConfiguredRouting),
SPTestPayment,
DownloadWoocom,
ConfigureWoocom,
SetupWoocomWebhook,
IsMultipleConfiguration,
}

#[derive(Debug, serde::Deserialize, serde::Serialize)]
pub struct ProductionAgreementRequest {
pub version: String,
#[serde(skip_deserializing)]
pub ip_address: Option<Secret<String, common_utils::pii::IpAddress>>,
}

#[derive(Debug, serde::Deserialize, serde::Serialize)]
pub struct SetupProcessor {
pub connector_id: String,
}

#[derive(Debug, serde::Deserialize, serde::Serialize)]
pub struct ProcessorConnected {
pub processor_id: String,
pub processor_name: String,
}

#[derive(Debug, serde::Deserialize, serde::Serialize)]
pub struct ConfiguredRouting {
pub routing_id: String,
}

#[derive(Debug, serde::Deserialize, serde::Serialize)]
pub struct TestPayment {
pub payment_id: String,
}

#[derive(Debug, serde::Deserialize, serde::Serialize)]
pub struct IntegrationMethod {
pub integration_type: String,
}

#[derive(Debug, serde::Deserialize, EnumString, serde::Serialize)]
pub enum GetMetaDataRequest {
ProductionAgreement,
SetupProcessor,
ConfigureEndpoint,
SetupComplete,
FirstProcessorConnected,
SecondProcessorConnected,
ConfiguredRouting,
TestPayment,
IntegrationMethod,
IntegrationCompleted,
StripeConnected,
PaypalConnected,
SPRoutingConfigured,
SPTestPayment,
DownloadWoocom,
ConfigureWoocom,
SetupWoocomWebhook,
IsMultipleConfiguration,
}

#[derive(Debug, serde::Deserialize, serde::Serialize)]
#[serde(transparent)]
pub struct GetMultipleMetaDataPayload {
pub results: Vec<GetMetaDataRequest>,
}

#[derive(Debug, serde::Deserialize, serde::Serialize)]
pub struct GetMultipleMetaDataRequest {
pub keys: String,
}

#[derive(Debug, serde::Serialize)]
pub enum GetMetaDataResponse {
ProductionAgreement(bool),
SetupProcessor(Option<SetupProcessor>),
ConfigureEndpoint(bool),
SetupComplete(bool),
FirstProcessorConnected(Option<ProcessorConnected>),
SecondProcessorConnected(Option<ProcessorConnected>),
ConfiguredRouting(Option<ConfiguredRouting>),
TestPayment(Option<TestPayment>),
IntegrationMethod(Option<IntegrationMethod>),
IntegrationCompleted(bool),
StripeConnected(Option<ProcessorConnected>),
PaypalConnected(Option<ProcessorConnected>),
SPRoutingConfigured(Option<ConfiguredRouting>),
SPTestPayment(bool),
DownloadWoocom(bool),
ConfigureWoocom(bool),
SetupWoocomWebhook(bool),
IsMultipleConfiguration(bool),
}
11 changes: 11 additions & 0 deletions crates/api_models/src/verify_connector.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use common_utils::events::{ApiEventMetric, ApiEventsType};

use crate::{admin, enums};

#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
pub struct VerifyConnectorRequest {
pub connector_name: enums::Connector,
pub connector_account_details: admin::ConnectorAuthType,
}

common_utils::impl_misc_api_event_type!(VerifyConnectorRequest);
24 changes: 24 additions & 0 deletions crates/common_enums/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub mod diesel_exports {
DbFutureUsage as FutureUsage, DbIntentStatus as IntentStatus,
DbMandateStatus as MandateStatus, DbPaymentMethodIssuerCode as PaymentMethodIssuerCode,
DbPaymentType as PaymentType, DbRefundStatus as RefundStatus,
DbRequestIncrementalAuthorization as RequestIncrementalAuthorization,
};
}

Expand Down Expand Up @@ -1387,6 +1388,29 @@ pub enum CountryAlpha2 {
US
}

#[derive(
Clone,
Debug,
Copy,
Default,
Eq,
Hash,
PartialEq,
serde::Deserialize,
serde::Serialize,
strum::Display,
strum::EnumString,
)]
#[router_derive::diesel_enum(storage_type = "db_enum")]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum RequestIncrementalAuthorization {
True,
False,
#[default]
Default,
}

#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
#[rustfmt::skip]
pub enum CountryAlpha3 {
Expand Down
2 changes: 2 additions & 0 deletions crates/data_models/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,6 @@ pub struct PaymentIntent {

pub updated_by: String,
pub surcharge_applicable: Option<bool>,
pub request_incremental_authorization: storage_enums::RequestIncrementalAuthorization,
pub incremental_authorization_allowed: Option<bool>,
}
14 changes: 13 additions & 1 deletion crates/data_models/src/payments/payment_intent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ pub struct PaymentIntentNew {

pub updated_by: String,
pub surcharge_applicable: Option<bool>,
pub request_incremental_authorization: storage_enums::RequestIncrementalAuthorization,
pub incremental_authorization_allowed: Option<bool>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand All @@ -116,6 +118,7 @@ pub enum PaymentIntentUpdate {
amount_captured: Option<i64>,
return_url: Option<String>,
updated_by: String,
incremental_authorization_allowed: Option<bool>,
},
MetadataUpdate {
metadata: pii::SecretSerdeValue,
Expand All @@ -137,6 +140,7 @@ pub enum PaymentIntentUpdate {
},
PGStatusUpdate {
status: storage_enums::IntentStatus,
incremental_authorization_allowed: Option<bool>,
updated_by: String,
},
Update {
Expand Down Expand Up @@ -213,6 +217,7 @@ pub struct PaymentIntentUpdateInternal {

pub updated_by: String,
pub surcharge_applicable: Option<bool>,
pub incremental_authorization_allowed: Option<bool>,
}

impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
Expand Down Expand Up @@ -283,10 +288,15 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
updated_by,
..Default::default()
},
PaymentIntentUpdate::PGStatusUpdate { status, updated_by } => Self {
PaymentIntentUpdate::PGStatusUpdate {
status,
updated_by,
incremental_authorization_allowed,
} => Self {
status: Some(status),
modified_at: Some(common_utils::date_time::now()),
updated_by,
incremental_authorization_allowed,
..Default::default()
},
PaymentIntentUpdate::MerchantStatusUpdate {
Expand All @@ -310,6 +320,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
// customer_id,
return_url,
updated_by,
incremental_authorization_allowed,
} => Self {
// amount,
// currency: Some(currency),
Expand All @@ -319,6 +330,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
return_url,
modified_at: Some(common_utils::date_time::now()),
updated_by,
incremental_authorization_allowed,
..Default::default()
},
PaymentIntentUpdate::PaymentAttemptAndAttemptCountUpdate {
Expand Down
Loading

0 comments on commit d51d098

Please sign in to comment.