refactor: Add secret to metadata (#706)

This commit is contained in:
Kartikeya Hegde
2023-03-08 13:05:07 +05:30
committed by GitHub
parent c451368f7b
commit d36afbed7f
19 changed files with 74 additions and 65 deletions

View File

@ -57,7 +57,7 @@ pub struct MerchantAccountCreate {
/// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object. /// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.
#[schema(value_type = Option<Object>, example = r#"{ "city": "NY", "unit": "245" }"#)] #[schema(value_type = Option<Object>, example = r#"{ "city": "NY", "unit": "245" }"#)]
pub metadata: Option<serde_json::Value>, pub metadata: Option<pii::SecretSerdeValue>,
/// API key that will be used for server side API access /// API key that will be used for server side API access
#[schema(example = "AH3423bkjbkjdsfbkj")] #[schema(example = "AH3423bkjbkjdsfbkj")]
@ -118,7 +118,7 @@ pub struct MerchantAccountUpdate {
/// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object. /// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.
#[schema(value_type = Option<Object>, example = r#"{ "city": "NY", "unit": "245" }"#)] #[schema(value_type = Option<Object>, example = r#"{ "city": "NY", "unit": "245" }"#)]
pub metadata: Option<serde_json::Value>, pub metadata: Option<pii::SecretSerdeValue>,
/// API key that will be used for server side API access /// API key that will be used for server side API access
#[schema(example = "AH3423bkjbkjdsfbkj")] #[schema(example = "AH3423bkjbkjdsfbkj")]
@ -185,7 +185,7 @@ pub struct MerchantAccountResponse {
/// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object. /// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.
#[schema(value_type = Option<Object>, example = r#"{ "city": "NY", "unit": "245" }"#)] #[schema(value_type = Option<Object>, example = r#"{ "city": "NY", "unit": "245" }"#)]
pub metadata: Option<serde_json::Value>, pub metadata: Option<pii::SecretSerdeValue>,
/// An identifier for the vault used to store payment method information. /// An identifier for the vault used to store payment method information.
#[schema(example = "locker_abc123")] #[schema(example = "locker_abc123")]
@ -308,7 +308,7 @@ pub struct MerchantConnector {
pub merchant_connector_id: Option<String>, pub merchant_connector_id: Option<String>,
/// Account details of the Connector. You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Useful for storing additional, structured information on an object. /// Account details of the Connector. You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Useful for storing additional, structured information on an object.
#[schema(value_type = Option<Object>,example = json!({ "auth_type": "HeaderKey","api_key": "Basic MyVerySecretApiKey" }))] #[schema(value_type = Option<Object>,example = json!({ "auth_type": "HeaderKey","api_key": "Basic MyVerySecretApiKey" }))]
pub connector_account_details: Option<Secret<serde_json::Value>>, pub connector_account_details: Option<pii::SecretSerdeValue>,
/// A boolean value to indicate if the connector is in Test mode. By default, its value is false. /// A boolean value to indicate if the connector is in Test mode. By default, its value is false.
#[schema(default = false, example = false)] #[schema(default = false, example = false)]
pub test_mode: Option<bool>, pub test_mode: Option<bool>,
@ -348,7 +348,7 @@ pub struct MerchantConnector {
pub payment_methods_enabled: Option<Vec<PaymentMethodsEnabled>>, pub payment_methods_enabled: Option<Vec<PaymentMethodsEnabled>>,
/// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object. /// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.
#[schema(value_type = Option<Object>,max_length = 255,example = json!({ "city": "NY", "unit": "245" }))] #[schema(value_type = Option<Object>,max_length = 255,example = json!({ "city": "NY", "unit": "245" }))]
pub metadata: Option<serde_json::Value>, pub metadata: Option<pii::SecretSerdeValue>,
} }
/// Details of all the payment methods enabled for the connector for the given merchant account /// Details of all the payment methods enabled for the connector for the given merchant account

View File

@ -41,12 +41,12 @@ pub struct CustomerRequest {
"first_name": "John", "first_name": "John",
"last_name": "Doe" "last_name": "Doe"
}))] }))]
pub address: Option<Secret<serde_json::Value>>, pub address: Option<pii::SecretSerdeValue>,
/// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 /// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500
/// characters long. Metadata is useful for storing additional, structured information on an /// characters long. Metadata is useful for storing additional, structured information on an
/// object. /// object.
#[schema(value_type = Option<Object>,example = json!({ "city": "NY", "unit": "245" }))] #[schema(value_type = Option<Object>,example = json!({ "city": "NY", "unit": "245" }))]
pub metadata: Option<serde_json::Value>, pub metadata: Option<pii::SecretSerdeValue>,
} }
#[derive(Debug, Clone, Serialize, ToSchema)] #[derive(Debug, Clone, Serialize, ToSchema)]
@ -90,7 +90,7 @@ pub struct CustomerResponse {
/// characters long. Metadata is useful for storing additional, structured information on an /// characters long. Metadata is useful for storing additional, structured information on an
/// object. /// object.
#[schema(value_type = Option<Object>,example = json!({ "city": "NY", "unit": "245" }))] #[schema(value_type = Option<Object>,example = json!({ "city": "NY", "unit": "245" }))]
pub metadata: Option<serde_json::Value>, pub metadata: Option<pii::SecretSerdeValue>,
} }
#[derive(Default, Debug, Deserialize, Serialize)] #[derive(Default, Debug, Deserialize, Serialize)]

View File

@ -36,7 +36,7 @@ pub struct PaymentMethodCreate {
/// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object. /// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.
#[schema(value_type = Option<Object>,example = json!({ "city": "NY", "unit": "245" }))] #[schema(value_type = Option<Object>,example = json!({ "city": "NY", "unit": "245" }))]
pub metadata: Option<serde_json::Value>, pub metadata: Option<pii::SecretSerdeValue>,
/// The unique identifier of the customer. /// The unique identifier of the customer.
#[schema(example = "cus_meowerunwiuwiwqw")] #[schema(example = "cus_meowerunwiuwiwqw")]
@ -64,7 +64,7 @@ pub struct PaymentMethodUpdate {
/// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object. /// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.
#[schema(value_type = Option<Object>,example = json!({ "city": "NY", "unit": "245" }))] #[schema(value_type = Option<Object>,example = json!({ "city": "NY", "unit": "245" }))]
pub metadata: Option<serde_json::Value>, pub metadata: Option<pii::SecretSerdeValue>,
} }
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema)] #[derive(Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema)]
@ -127,7 +127,7 @@ pub struct PaymentMethodResponse {
/// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object. /// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.
#[schema(value_type = Option<Object>,example = json!({ "city": "NY", "unit": "245" }))] #[schema(value_type = Option<Object>,example = json!({ "city": "NY", "unit": "245" }))]
pub metadata: Option<serde_json::Value>, pub metadata: Option<pii::SecretSerdeValue>,
/// A timestamp (ISO 8601 code) that determines when the customer was created /// A timestamp (ISO 8601 code) that determines when the customer was created
#[schema(value_type = Option<PrimitiveDateTime>,example = "2023-01-18T11:04:09.922Z")] #[schema(value_type = Option<PrimitiveDateTime>,example = "2023-01-18T11:04:09.922Z")]
@ -514,7 +514,7 @@ pub struct CustomerPaymentMethod {
/// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object. /// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.
#[schema(value_type = Option<Object>,example = json!({ "city": "NY", "unit": "245" }))] #[schema(value_type = Option<Object>,example = json!({ "city": "NY", "unit": "245" }))]
pub metadata: Option<serde_json::Value>, pub metadata: Option<pii::SecretSerdeValue>,
/// A timestamp (ISO 8601 code) that determines when the customer was created /// A timestamp (ISO 8601 code) that determines when the customer was created
#[schema(value_type = Option<PrimitiveDateTime>,example = "2023-01-18T11:04:09.922Z")] #[schema(value_type = Option<PrimitiveDateTime>,example = "2023-01-18T11:04:09.922Z")]

View File

@ -6,10 +6,7 @@ use router_derive::Setter;
use time::PrimitiveDateTime; use time::PrimitiveDateTime;
use utoipa::ToSchema; use utoipa::ToSchema;
use crate::{ use crate::{enums as api_enums, refunds};
enums::{self as api_enums},
refunds,
};
#[derive(Clone, Copy, Debug, Eq, PartialEq)] #[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum PaymentOp { pub enum PaymentOp {
@ -882,7 +879,7 @@ pub struct PaymentsResponse {
/// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object. /// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.
#[schema(value_type = Option<Object>)] #[schema(value_type = Option<Object>)]
pub metadata: Option<serde_json::Value>, pub metadata: Option<pii::SecretSerdeValue>,
/// description: The customer's email address /// description: The customer's email address
#[schema(max_length = 255, value_type = Option<String>, example = "johntest@test.com")] #[schema(max_length = 255, value_type = Option<String>, example = "johntest@test.com")]
@ -1187,7 +1184,7 @@ pub struct Metadata {
/// Any other metadata that is to be provided /// Any other metadata that is to be provided
#[schema(value_type = Object, example = r#"{ "city": "NY", "unit": "245" }"#)] #[schema(value_type = Object, example = r#"{ "city": "NY", "unit": "245" }"#)]
#[serde(flatten)] #[serde(flatten)]
pub data: serde_json::Value, pub data: pii::SecretSerdeValue,
} }
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema)] #[derive(Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema)]

View File

@ -1,4 +1,4 @@
use common_utils::custom_serde; use common_utils::{custom_serde, pii};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use time::PrimitiveDateTime; use time::PrimitiveDateTime;
use utoipa::ToSchema; use utoipa::ToSchema;
@ -42,7 +42,7 @@ pub struct RefundRequest {
/// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object. /// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.
#[schema(value_type = Option<Object>, example = r#"{ "city": "NY", "unit": "245" }"#)] #[schema(value_type = Option<Object>, example = r#"{ "city": "NY", "unit": "245" }"#)]
pub metadata: Option<serde_json::Value>, pub metadata: Option<pii::SecretSerdeValue>,
} }
#[derive(Default, Debug, ToSchema, Clone, Deserialize)] #[derive(Default, Debug, ToSchema, Clone, Deserialize)]
@ -54,7 +54,7 @@ pub struct RefundUpdateRequest {
/// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object. /// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.
#[schema(value_type = Option<Object>, example = r#"{ "city": "NY", "unit": "245" }"#)] #[schema(value_type = Option<Object>, example = r#"{ "city": "NY", "unit": "245" }"#)]
pub metadata: Option<serde_json::Value>, pub metadata: Option<pii::SecretSerdeValue>,
} }
#[derive(Default, Debug, Clone, ToSchema, Deserialize)] #[derive(Default, Debug, Clone, ToSchema, Deserialize)]
@ -81,7 +81,7 @@ pub struct RefundResponse {
pub status: RefundStatus, pub status: RefundStatus,
/// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object /// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object
#[schema(value_type = Option<Object>)] #[schema(value_type = Option<Object>)]
pub metadata: Option<serde_json::Value>, pub metadata: Option<pii::SecretSerdeValue>,
/// The error message /// The error message
pub error_message: Option<String>, pub error_message: Option<String>,
/// The code for the error /// The code for the error

View File

@ -6,6 +6,9 @@ use masking::{Strategy, WithType};
use crate::validation::validate_email; use crate::validation::validate_email;
/// Type alias for serde_json value which has Secret Information
pub type SecretSerdeValue = masking::Secret<serde_json::Value>;
/// Card number /// Card number
#[derive(Debug)] #[derive(Debug)]
pub struct CardNumber; pub struct CardNumber;

View File

@ -1,10 +1,10 @@
use std::{convert::From, default::Default}; use std::{convert::From, default::Default};
use api_models::payment_methods as api_types; use api_models::payment_methods as api_types;
use common_utils::date_time; use common_utils::{date_time, pii};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::{logger, pii, types::api}; use crate::{logger, types::api};
#[derive(Clone, Default, Serialize, Deserialize, PartialEq, Eq)] #[derive(Clone, Default, Serialize, Deserialize, PartialEq, Eq)]
pub struct CreateCustomerRequest { pub struct CreateCustomerRequest {
@ -13,7 +13,7 @@ pub struct CreateCustomerRequest {
pub name: Option<String>, pub name: Option<String>,
pub phone: Option<masking::Secret<String>>, pub phone: Option<masking::Secret<String>>,
pub address: Option<masking::Secret<serde_json::Value>>, pub address: Option<masking::Secret<serde_json::Value>>,
pub metadata: Option<serde_json::Value>, pub metadata: Option<pii::SecretSerdeValue>,
pub description: Option<String>, pub description: Option<String>,
} }
@ -24,7 +24,7 @@ pub struct CustomerUpdateRequest {
pub phone: Option<masking::Secret<String, masking::WithType>>, pub phone: Option<masking::Secret<String, masking::WithType>>,
pub name: Option<String>, pub name: Option<String>,
pub address: Option<masking::Secret<serde_json::Value>>, pub address: Option<masking::Secret<serde_json::Value>>,
pub metadata: Option<serde_json::Value>, pub metadata: Option<pii::SecretSerdeValue>,
} }
#[derive(Default, Serialize, PartialEq, Eq)] #[derive(Default, Serialize, PartialEq, Eq)]
@ -34,7 +34,7 @@ pub struct CreateCustomerResponse {
pub created: u64, pub created: u64,
pub description: Option<String>, pub description: Option<String>,
pub email: Option<masking::Secret<String, pii::Email>>, pub email: Option<masking::Secret<String, pii::Email>>,
pub metadata: Option<serde_json::Value>, pub metadata: Option<pii::SecretSerdeValue>,
pub name: Option<String>, pub name: Option<String>,
pub phone: Option<masking::Secret<String, masking::WithType>>, pub phone: Option<masking::Secret<String, masking::WithType>>,
} }

View File

@ -1,8 +1,7 @@
use api_models::{payments, refunds}; use api_models::{payments, refunds};
use common_utils::ext_traits::StringExt; use common_utils::{ext_traits::StringExt, pii as secret};
use error_stack::ResultExt; use error_stack::ResultExt;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_json::Value;
use crate::{ use crate::{
core::errors, core::errors,
@ -63,7 +62,7 @@ pub struct StripePaymentMethodData {
pub billing_details: Option<StripeBillingDetails>, pub billing_details: Option<StripeBillingDetails>,
#[serde(flatten)] #[serde(flatten)]
pub payment_method_details: Option<StripePaymentMethodDetails>, // enum pub payment_method_details: Option<StripePaymentMethodDetails>, // enum
pub metadata: Option<Value>, pub metadata: Option<secret::SecretSerdeValue>,
} }
#[derive(PartialEq, Eq, Deserialize, Clone)] #[derive(PartialEq, Eq, Deserialize, Clone)]
@ -277,7 +276,7 @@ pub struct StripePaymentIntentResponse {
pub customer: Option<String>, pub customer: Option<String>,
pub refunds: Option<Vec<refunds::RefundResponse>>, pub refunds: Option<Vec<refunds::RefundResponse>>,
pub mandate_id: Option<String>, pub mandate_id: Option<String>,
pub metadata: Option<Value>, pub metadata: Option<secret::SecretSerdeValue>,
pub charges: Charges, pub charges: Charges,
pub connector: Option<String>, pub connector: Option<String>,
pub description: Option<String>, pub description: Option<String>,

View File

@ -1,5 +1,6 @@
use std::{convert::From, default::Default}; use std::{convert::From, default::Default};
use common_utils::pii;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::types::api::refunds; use crate::types::api::refunds;
@ -13,7 +14,7 @@ pub struct StripeCreateRefundRequest {
#[derive(Clone, Default, Serialize, Deserialize, PartialEq, Eq)] #[derive(Clone, Default, Serialize, Deserialize, PartialEq, Eq)]
pub struct StripeUpdateRefundRequest { pub struct StripeUpdateRefundRequest {
pub metadata: Option<serde_json::Value>, pub metadata: Option<pii::SecretSerdeValue>,
} }
#[derive(Clone, Serialize, PartialEq, Eq)] #[derive(Clone, Serialize, PartialEq, Eq)]
@ -24,7 +25,7 @@ pub struct StripeCreateRefundResponse {
pub payment_intent: String, pub payment_intent: String,
pub status: StripeRefundStatus, pub status: StripeRefundStatus,
pub created: Option<i64>, pub created: Option<i64>,
pub metadata: serde_json::Value, pub metadata: pii::SecretSerdeValue,
} }
#[derive(Clone, Serialize, Deserialize, Eq, PartialEq)] #[derive(Clone, Serialize, Deserialize, Eq, PartialEq)]
@ -77,7 +78,9 @@ impl From<refunds::RefundResponse> for StripeCreateRefundResponse {
payment_intent: res.payment_id, payment_intent: res.payment_id,
status: res.status.into(), status: res.status.into(),
created: res.created_at.map(|t| t.assume_utc().unix_timestamp()), created: res.created_at.map(|t| t.assume_utc().unix_timestamp()),
metadata: res.metadata.unwrap_or_else(|| serde_json::json!({})), metadata: res
.metadata
.unwrap_or_else(|| masking::Secret::new(serde_json::json!({}))),
} }
} }
} }

View File

@ -1,6 +1,6 @@
use std::collections::HashMap; use std::collections::HashMap;
use common_utils::pii; use common_utils::{ext_traits::ValueExt, pii};
use error_stack::{report, IntoReport, ResultExt}; use error_stack::{report, IntoReport, ResultExt};
use masking::Secret; use masking::Secret;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
@ -45,7 +45,7 @@ pub trait RouterData {
fn get_billing_phone(&self) -> Result<&api::PhoneDetails, Error>; fn get_billing_phone(&self) -> Result<&api::PhoneDetails, Error>;
fn get_description(&self) -> Result<String, Error>; fn get_description(&self) -> Result<String, Error>;
fn get_billing_address(&self) -> Result<&api::AddressDetails, Error>; fn get_billing_address(&self) -> Result<&api::AddressDetails, Error>;
fn get_connector_meta(&self) -> Result<serde_json::Value, Error>; fn get_connector_meta(&self) -> Result<pii::SecretSerdeValue, Error>;
fn get_session_token(&self) -> Result<String, Error>; fn get_session_token(&self) -> Result<String, Error>;
fn to_connector_meta<T>(&self) -> Result<T, Error> fn to_connector_meta<T>(&self) -> Result<T, Error>
where where
@ -89,7 +89,7 @@ impl<Flow, Request, Response> RouterData for types::RouterData<Flow, Request, Re
.and_then(|a| a.address.as_ref()) .and_then(|a| a.address.as_ref())
.ok_or_else(missing_field_err("billing.address")) .ok_or_else(missing_field_err("billing.address"))
} }
fn get_connector_meta(&self) -> Result<serde_json::Value, Error> { fn get_connector_meta(&self) -> Result<pii::SecretSerdeValue, Error> {
self.connector_meta_data self.connector_meta_data
.clone() .clone()
.ok_or_else(missing_field_err("connector_meta_data")) .ok_or_else(missing_field_err("connector_meta_data"))
@ -105,8 +105,8 @@ impl<Flow, Request, Response> RouterData for types::RouterData<Flow, Request, Re
where where
T: serde::de::DeserializeOwned, T: serde::de::DeserializeOwned,
{ {
serde_json::from_value::<T>(self.get_connector_meta()?) self.get_connector_meta()?
.into_report() .parse_value(std::any::type_name::<T>())
.change_context(errors::ConnectorError::NoConnectorMetaData) .change_context(errors::ConnectorError::NoConnectorMetaData)
} }

View File

@ -502,7 +502,7 @@ impl PaymentCreate {
billing_address_id, billing_address_id,
statement_descriptor_name: request.statement_descriptor_name.clone(), statement_descriptor_name: request.statement_descriptor_name.clone(),
statement_descriptor_suffix: request.statement_descriptor_suffix.clone(), statement_descriptor_suffix: request.statement_descriptor_suffix.clone(),
metadata, metadata: metadata.map(masking::Secret::new),
..storage::PaymentIntentNew::default() ..storage::PaymentIntentNew::default()
}) })
} }

View File

@ -13,7 +13,7 @@ pub mod transformers;
use std::marker::PhantomData; use std::marker::PhantomData;
pub use api_models::enums::Connector; pub use api_models::enums::Connector;
use common_utils::pii::Email; use common_utils::{pii, pii::Email};
use error_stack::{IntoReport, ResultExt}; use error_stack::{IntoReport, ResultExt};
use self::{api::payments, storage::enums as storage_enums}; use self::{api::payments, storage::enums as storage_enums};
@ -92,7 +92,7 @@ pub struct RouterData<Flow, Request, Response> {
pub router_return_url: Option<String>, pub router_return_url: Option<String>,
pub address: PaymentAddress, pub address: PaymentAddress,
pub auth_type: storage_enums::AuthenticationType, pub auth_type: storage_enums::AuthenticationType,
pub connector_meta_data: Option<serde_json::Value>, pub connector_meta_data: Option<pii::SecretSerdeValue>,
pub amount_captured: Option<i64>, pub amount_captured: Option<i64>,
pub access_token: Option<AccessToken>, pub access_token: Option<AccessToken>,
pub session_token: Option<String>, pub session_token: Option<String>,

View File

@ -379,7 +379,9 @@ pub trait ConnectorActions: Connector {
.and_then(|a| a.address) .and_then(|a| a.address)
.or_else(|| Some(PaymentAddress::default())) .or_else(|| Some(PaymentAddress::default()))
.unwrap(), .unwrap(),
connector_meta_data: info.clone().and_then(|a| a.connector_meta_data), connector_meta_data: info
.clone()
.and_then(|a| a.connector_meta_data.map(masking::Secret::new)),
amount_captured: None, amount_captured: None,
access_token: info.and_then(|a| a.access_token), access_token: info.and_then(|a| a.access_token),
session_token: None, session_token: None,

View File

@ -15,7 +15,7 @@ pub struct CustomerNew {
pub phone: Option<Secret<String>>, pub phone: Option<Secret<String>>,
pub description: Option<String>, pub description: Option<String>,
pub phone_country_code: Option<String>, pub phone_country_code: Option<String>,
pub metadata: Option<serde_json::Value>, pub metadata: Option<pii::SecretSerdeValue>,
} }
#[derive(Clone, Debug, Identifiable, Queryable)] #[derive(Clone, Debug, Identifiable, Queryable)]
@ -30,7 +30,7 @@ pub struct Customer {
pub phone_country_code: Option<String>, pub phone_country_code: Option<String>,
pub description: Option<String>, pub description: Option<String>,
pub created_at: PrimitiveDateTime, pub created_at: PrimitiveDateTime,
pub metadata: Option<serde_json::Value>, pub metadata: Option<pii::SecretSerdeValue>,
} }
#[derive(Debug)] #[derive(Debug)]
@ -41,7 +41,7 @@ pub enum CustomerUpdate {
phone: Option<Secret<String>>, phone: Option<Secret<String>>,
description: Option<String>, description: Option<String>,
phone_country_code: Option<String>, phone_country_code: Option<String>,
metadata: Option<serde_json::Value>, metadata: Option<pii::SecretSerdeValue>,
}, },
} }
@ -53,7 +53,7 @@ pub struct CustomerUpdateInternal {
phone: Option<Secret<String>>, phone: Option<Secret<String>>,
description: Option<String>, description: Option<String>,
phone_country_code: Option<String>, phone_country_code: Option<String>,
metadata: Option<serde_json::Value>, metadata: Option<pii::SecretSerdeValue>,
} }
impl From<CustomerUpdate> for CustomerUpdateInternal { impl From<CustomerUpdate> for CustomerUpdateInternal {

View File

@ -1,3 +1,4 @@
use common_utils::pii;
use diesel::{AsChangeset, Identifiable, Insertable, Queryable}; use diesel::{AsChangeset, Identifiable, Insertable, Queryable};
use masking::StrongSecret; use masking::StrongSecret;
@ -31,7 +32,7 @@ pub struct MerchantAccount {
pub publishable_key: Option<String>, pub publishable_key: Option<String>,
pub storage_scheme: storage_enums::MerchantStorageScheme, pub storage_scheme: storage_enums::MerchantStorageScheme,
pub locker_id: Option<String>, pub locker_id: Option<String>,
pub metadata: Option<serde_json::Value>, pub metadata: Option<pii::SecretSerdeValue>,
pub routing_algorithm: Option<serde_json::Value>, pub routing_algorithm: Option<serde_json::Value>,
} }
@ -51,7 +52,7 @@ pub struct MerchantAccountNew {
pub redirect_to_merchant_with_http_post: Option<bool>, pub redirect_to_merchant_with_http_post: Option<bool>,
pub publishable_key: Option<String>, pub publishable_key: Option<String>,
pub locker_id: Option<String>, pub locker_id: Option<String>,
pub metadata: Option<serde_json::Value>, pub metadata: Option<pii::SecretSerdeValue>,
pub routing_algorithm: Option<serde_json::Value>, pub routing_algorithm: Option<serde_json::Value>,
} }
@ -70,7 +71,7 @@ pub enum MerchantAccountUpdate {
redirect_to_merchant_with_http_post: Option<bool>, redirect_to_merchant_with_http_post: Option<bool>,
publishable_key: Option<String>, publishable_key: Option<String>,
locker_id: Option<String>, locker_id: Option<String>,
metadata: Option<serde_json::Value>, metadata: Option<pii::SecretSerdeValue>,
routing_algorithm: Option<serde_json::Value>, routing_algorithm: Option<serde_json::Value>,
}, },
StorageSchemeUpdate { StorageSchemeUpdate {
@ -94,7 +95,7 @@ pub struct MerchantAccountUpdateInternal {
publishable_key: Option<String>, publishable_key: Option<String>,
storage_scheme: Option<storage_enums::MerchantStorageScheme>, storage_scheme: Option<storage_enums::MerchantStorageScheme>,
locker_id: Option<String>, locker_id: Option<String>,
metadata: Option<serde_json::Value>, metadata: Option<pii::SecretSerdeValue>,
routing_algorithm: Option<serde_json::Value>, routing_algorithm: Option<serde_json::Value>,
} }

View File

@ -1,3 +1,4 @@
use common_utils::pii;
use diesel::{AsChangeset, Identifiable, Insertable, Queryable}; use diesel::{AsChangeset, Identifiable, Insertable, Queryable};
use masking::Secret; use masking::Secret;
@ -26,7 +27,7 @@ pub struct MerchantConnectorAccount {
#[diesel(deserialize_as = super::OptionalDieselArray<serde_json::Value>)] #[diesel(deserialize_as = super::OptionalDieselArray<serde_json::Value>)]
pub payment_methods_enabled: Option<Vec<serde_json::Value>>, pub payment_methods_enabled: Option<Vec<serde_json::Value>>,
pub connector_type: storage_enums::ConnectorType, pub connector_type: storage_enums::ConnectorType,
pub metadata: Option<serde_json::Value>, pub metadata: Option<pii::SecretSerdeValue>,
} }
#[derive(Clone, Debug, Default, Insertable, router_derive::DebugAsDisplay)] #[derive(Clone, Debug, Default, Insertable, router_derive::DebugAsDisplay)]
@ -40,7 +41,7 @@ pub struct MerchantConnectorAccountNew {
pub disabled: Option<bool>, pub disabled: Option<bool>,
pub merchant_connector_id: String, pub merchant_connector_id: String,
pub payment_methods_enabled: Option<Vec<serde_json::Value>>, pub payment_methods_enabled: Option<Vec<serde_json::Value>>,
pub metadata: Option<serde_json::Value>, pub metadata: Option<pii::SecretSerdeValue>,
} }
#[derive(Debug)] #[derive(Debug)]
@ -54,7 +55,7 @@ pub enum MerchantConnectorAccountUpdate {
disabled: Option<bool>, disabled: Option<bool>,
merchant_connector_id: Option<String>, merchant_connector_id: Option<String>,
payment_methods_enabled: Option<Vec<serde_json::Value>>, payment_methods_enabled: Option<Vec<serde_json::Value>>,
metadata: Option<serde_json::Value>, metadata: Option<pii::SecretSerdeValue>,
}, },
} }
#[derive(Clone, Debug, Default, AsChangeset, router_derive::DebugAsDisplay)] #[derive(Clone, Debug, Default, AsChangeset, router_derive::DebugAsDisplay)]
@ -68,7 +69,7 @@ pub struct MerchantConnectorAccountUpdateInternal {
disabled: Option<bool>, disabled: Option<bool>,
merchant_connector_id: Option<String>, merchant_connector_id: Option<String>,
payment_methods_enabled: Option<Vec<serde_json::Value>>, payment_methods_enabled: Option<Vec<serde_json::Value>>,
metadata: Option<serde_json::Value>, metadata: Option<pii::SecretSerdeValue>,
} }
impl From<MerchantConnectorAccountUpdate> for MerchantConnectorAccountUpdateInternal { impl From<MerchantConnectorAccountUpdate> for MerchantConnectorAccountUpdateInternal {

View File

@ -1,3 +1,4 @@
use common_utils::pii;
use diesel::{AsChangeset, Identifiable, Insertable, Queryable}; use diesel::{AsChangeset, Identifiable, Insertable, Queryable};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use time::PrimitiveDateTime; use time::PrimitiveDateTime;
@ -17,7 +18,7 @@ pub struct PaymentIntent {
pub customer_id: Option<String>, pub customer_id: Option<String>,
pub description: Option<String>, pub description: Option<String>,
pub return_url: Option<String>, pub return_url: Option<String>,
pub metadata: Option<serde_json::Value>, pub metadata: Option<pii::SecretSerdeValue>,
pub connector_id: Option<String>, pub connector_id: Option<String>,
pub shipping_address_id: Option<String>, pub shipping_address_id: Option<String>,
pub billing_address_id: Option<String>, pub billing_address_id: Option<String>,
@ -53,7 +54,7 @@ pub struct PaymentIntentNew {
pub customer_id: Option<String>, pub customer_id: Option<String>,
pub description: Option<String>, pub description: Option<String>,
pub return_url: Option<String>, pub return_url: Option<String>,
pub metadata: Option<serde_json::Value>, pub metadata: Option<pii::SecretSerdeValue>,
pub connector_id: Option<String>, pub connector_id: Option<String>,
pub shipping_address_id: Option<String>, pub shipping_address_id: Option<String>,
pub billing_address_id: Option<String>, pub billing_address_id: Option<String>,
@ -75,7 +76,7 @@ pub enum PaymentIntentUpdate {
return_url: Option<String>, return_url: Option<String>,
}, },
MetadataUpdate { MetadataUpdate {
metadata: serde_json::Value, metadata: pii::SecretSerdeValue,
}, },
ReturnUrlUpdate { ReturnUrlUpdate {
return_url: Option<String>, return_url: Option<String>,
@ -116,7 +117,7 @@ pub struct PaymentIntentUpdateInternal {
pub return_url: Option<String>, pub return_url: Option<String>,
pub setup_future_usage: Option<storage_enums::FutureUsage>, pub setup_future_usage: Option<storage_enums::FutureUsage>,
pub off_session: Option<bool>, pub off_session: Option<bool>,
pub metadata: Option<serde_json::Value>, pub metadata: Option<pii::SecretSerdeValue>,
pub client_secret: Option<Option<String>>, pub client_secret: Option<Option<String>>,
pub billing_address_id: Option<String>, pub billing_address_id: Option<String>,
pub shipping_address_id: Option<String>, pub shipping_address_id: Option<String>,

View File

@ -1,3 +1,4 @@
use common_utils::pii;
use diesel::{Identifiable, Insertable, Queryable}; use diesel::{Identifiable, Insertable, Queryable};
use masking::Secret; use masking::Secret;
use time::PrimitiveDateTime; use time::PrimitiveDateTime;
@ -29,7 +30,7 @@ pub struct PaymentMethod {
pub payment_method_type: Option<storage_enums::PaymentMethodType>, pub payment_method_type: Option<storage_enums::PaymentMethodType>,
pub payment_method_issuer: Option<String>, pub payment_method_issuer: Option<String>,
pub payment_method_issuer_code: Option<storage_enums::PaymentMethodIssuerCode>, pub payment_method_issuer_code: Option<storage_enums::PaymentMethodIssuerCode>,
pub metadata: Option<serde_json::Value>, pub metadata: Option<pii::SecretSerdeValue>,
} }
#[derive(Clone, Debug, Eq, PartialEq, Insertable, Queryable, router_derive::DebugAsDisplay)] #[derive(Clone, Debug, Eq, PartialEq, Insertable, Queryable, router_derive::DebugAsDisplay)]
@ -54,7 +55,7 @@ pub struct PaymentMethodNew {
pub direct_debit_token: Option<String>, pub direct_debit_token: Option<String>,
pub created_at: PrimitiveDateTime, pub created_at: PrimitiveDateTime,
pub last_modified: PrimitiveDateTime, pub last_modified: PrimitiveDateTime,
pub metadata: Option<serde_json::Value>, pub metadata: Option<pii::SecretSerdeValue>,
} }
impl Default for PaymentMethodNew { impl Default for PaymentMethodNew {

View File

@ -1,3 +1,4 @@
use common_utils::pii;
use diesel::{AsChangeset, Identifiable, Insertable, Queryable}; use diesel::{AsChangeset, Identifiable, Insertable, Queryable};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use time::PrimitiveDateTime; use time::PrimitiveDateTime;
@ -25,7 +26,7 @@ pub struct Refund {
pub refund_status: storage_enums::RefundStatus, pub refund_status: storage_enums::RefundStatus,
pub sent_to_gateway: bool, pub sent_to_gateway: bool,
pub refund_error_message: Option<String>, pub refund_error_message: Option<String>,
pub metadata: Option<serde_json::Value>, pub metadata: Option<pii::SecretSerdeValue>,
pub refund_arn: Option<String>, pub refund_arn: Option<String>,
pub created_at: PrimitiveDateTime, pub created_at: PrimitiveDateTime,
pub updated_at: PrimitiveDateTime, pub updated_at: PrimitiveDateTime,
@ -63,7 +64,7 @@ pub struct RefundNew {
pub refund_amount: i64, pub refund_amount: i64,
pub refund_status: storage_enums::RefundStatus, pub refund_status: storage_enums::RefundStatus,
pub sent_to_gateway: bool, pub sent_to_gateway: bool,
pub metadata: Option<serde_json::Value>, pub metadata: Option<pii::SecretSerdeValue>,
pub refund_arn: Option<String>, pub refund_arn: Option<String>,
pub created_at: Option<PrimitiveDateTime>, pub created_at: Option<PrimitiveDateTime>,
pub modified_at: Option<PrimitiveDateTime>, pub modified_at: Option<PrimitiveDateTime>,
@ -82,7 +83,7 @@ pub enum RefundUpdate {
refund_arn: String, refund_arn: String,
}, },
MetadataAndReasonUpdate { MetadataAndReasonUpdate {
metadata: Option<serde_json::Value>, metadata: Option<pii::SecretSerdeValue>,
reason: Option<String>, reason: Option<String>,
}, },
StatusUpdate { StatusUpdate {
@ -105,7 +106,7 @@ pub struct RefundUpdateInternal {
sent_to_gateway: Option<bool>, sent_to_gateway: Option<bool>,
refund_error_message: Option<String>, refund_error_message: Option<String>,
refund_arn: Option<String>, refund_arn: Option<String>,
metadata: Option<serde_json::Value>, metadata: Option<pii::SecretSerdeValue>,
refund_reason: Option<String>, refund_reason: Option<String>,
refund_error_code: Option<String>, refund_error_code: Option<String>,
} }