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.
#[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
#[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.
#[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
#[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.
#[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.
#[schema(example = "locker_abc123")]
@ -308,7 +308,7 @@ pub struct MerchantConnector {
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.
#[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.
#[schema(default = false, example = false)]
pub test_mode: Option<bool>,
@ -348,7 +348,7 @@ pub struct MerchantConnector {
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.
#[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

View File

@ -41,12 +41,12 @@ pub struct CustomerRequest {
"first_name": "John",
"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
/// characters long. Metadata is useful for storing additional, structured information on an
/// object.
#[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)]
@ -90,7 +90,7 @@ pub struct CustomerResponse {
/// characters long. Metadata is useful for storing additional, structured information on an
/// object.
#[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)]

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.
#[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.
#[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.
#[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)]
@ -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.
#[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
#[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.
#[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
#[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 utoipa::ToSchema;
use crate::{
enums::{self as api_enums},
refunds,
};
use crate::{enums as api_enums, refunds};
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
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.
#[schema(value_type = Option<Object>)]
pub metadata: Option<serde_json::Value>,
pub metadata: Option<pii::SecretSerdeValue>,
/// description: The customer's email address
#[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
#[schema(value_type = Object, example = r#"{ "city": "NY", "unit": "245" }"#)]
#[serde(flatten)]
pub data: serde_json::Value,
pub data: pii::SecretSerdeValue,
}
#[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 time::PrimitiveDateTime;
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.
#[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)]
@ -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.
#[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)]
@ -81,7 +81,7 @@ pub struct RefundResponse {
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
#[schema(value_type = Option<Object>)]
pub metadata: Option<serde_json::Value>,
pub metadata: Option<pii::SecretSerdeValue>,
/// The error message
pub error_message: Option<String>,
/// The code for the error