-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add a domain type for
customer_id
(#4705)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
- Loading branch information
1 parent
f192fa3
commit 93d61d1
Showing
106 changed files
with
1,150 additions
and
490 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ use common_utils::{ | |
consts::default_payments_list_limit, | ||
crypto, | ||
ext_traits::{ConfigExt, Encode}, | ||
id_type, | ||
pii::{self, Email}, | ||
types::MinorUnit, | ||
}; | ||
|
@@ -177,10 +178,34 @@ mod client_secret_tests { | |
} | ||
} | ||
|
||
#[derive(Default, Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema, PartialEq)] | ||
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema, PartialEq)] | ||
pub struct CustomerDetails { | ||
/// The identifier for the customer. | ||
pub id: String, | ||
#[schema(value_type = String, max_length = 64, min_length = 1, example = "cus_y3oqhf46pyzuxjbcn2giaqnb44")] | ||
pub id: id_type::CustomerId, | ||
|
||
/// The customer's name | ||
#[schema(max_length = 255, value_type = Option<String>, example = "John Doe")] | ||
pub name: Option<Secret<String>>, | ||
|
||
/// The customer's email address | ||
#[schema(max_length = 255, value_type = Option<String>, example = "[email protected]")] | ||
pub email: Option<Email>, | ||
|
||
/// The customer's phone number | ||
#[schema(value_type = Option<String>, max_length = 10, example = "3141592653")] | ||
pub phone: Option<Secret<String>>, | ||
|
||
/// The country code for the customer's phone number | ||
#[schema(max_length = 2, example = "+1")] | ||
pub phone_country_code: Option<String>, | ||
} | ||
|
||
#[derive(Debug, serde::Serialize, Clone, ToSchema, PartialEq)] | ||
pub struct CustomerDetailsResponse { | ||
/// The identifier for the customer. | ||
#[schema(value_type = String, max_length = 64, min_length = 1, example = "cus_y3oqhf46pyzuxjbcn2giaqnb44")] | ||
pub id: id_type::CustomerId, | ||
|
||
/// The customer's name | ||
#[schema(max_length = 255, value_type = Option<String>, example = "John Doe")] | ||
|
@@ -277,9 +302,9 @@ pub struct PaymentsRequest { | |
/// Passing this object creates a new customer or attaches an existing customer to the payment | ||
pub customer: Option<CustomerDetails>, | ||
|
||
/// The identifier for the customer object. | ||
#[schema(max_length = 255, example = "cus_y3oqhf46pyzuxjbcn2giaqnb44")] | ||
pub customer_id: Option<String>, | ||
/// The identifier for the customer | ||
#[schema(value_type = Option<String>, max_length = 64, min_length = 1, example = "cus_y3oqhf46pyzuxjbcn2giaqnb44")] | ||
pub customer_id: Option<id_type::CustomerId>, | ||
|
||
/// The customer's email address. | ||
/// This field will be deprecated soon, use the customer object instead | ||
|
@@ -762,7 +787,7 @@ pub struct VerifyRequest { | |
// The merchant_id is generated through api key | ||
// and is later passed in the struct | ||
pub merchant_id: Option<String>, | ||
pub customer_id: Option<String>, | ||
pub customer_id: Option<id_type::CustomerId>, | ||
pub email: Option<Email>, | ||
pub name: Option<Secret<String>>, | ||
pub phone: Option<Secret<String>>, | ||
|
@@ -3239,14 +3264,16 @@ pub struct PaymentsResponse { | |
/// The identifier for the customer object. If not provided the customer ID will be autogenerated. | ||
/// This field will be deprecated soon. Please refer to `customer.id` | ||
#[schema( | ||
max_length = 255, | ||
max_length = 64, | ||
min_length = 1, | ||
example = "cus_y3oqhf46pyzuxjbcn2giaqnb44", | ||
deprecated | ||
deprecated, | ||
value_type = Option<String>, | ||
)] | ||
pub customer_id: Option<String>, | ||
pub customer_id: Option<id_type::CustomerId>, | ||
|
||
/// Details of customer attached to this payment | ||
pub customer: Option<CustomerDetails>, | ||
pub customer: Option<CustomerDetailsResponse>, | ||
|
||
/// A description of the payment | ||
#[schema(example = "It's my first payment request")] | ||
|
@@ -3534,8 +3561,13 @@ pub struct ExternalAuthenticationDetailsResponse { | |
#[serde(deny_unknown_fields)] | ||
pub struct PaymentListConstraints { | ||
/// The identifier for customer | ||
#[schema(example = "cus_meowuwunwiuwiwqw")] | ||
pub customer_id: Option<String>, | ||
#[schema( | ||
max_length = 64, | ||
min_length = 1, | ||
example = "cus_y3oqhf46pyzuxjbcn2giaqnb44", | ||
value_type = Option<String>, | ||
)] | ||
pub customer_id: Option<id_type::CustomerId>, | ||
|
||
/// A cursor for use in pagination, fetch the next list after some object | ||
#[schema(example = "pay_fafa124123")] | ||
|
@@ -3632,7 +3664,7 @@ pub struct PaymentListFilterConstraints { | |
/// The identifier for business profile | ||
pub profile_id: Option<String>, | ||
/// The identifier for customer | ||
pub customer_id: Option<String>, | ||
pub customer_id: Option<id_type::CustomerId>, | ||
/// The limit on the number of objects. The default limit is 10 and max limit is 20 | ||
#[serde(default = "default_payments_list_limit")] | ||
pub limit: u32, | ||
|
@@ -3716,7 +3748,7 @@ pub struct VerifyResponse { | |
pub merchant_id: Option<String>, | ||
// pub status: enums::VerifyStatus, | ||
pub client_secret: Option<Secret<String>>, | ||
pub customer_id: Option<String>, | ||
pub customer_id: Option<id_type::CustomerId>, | ||
pub email: crypto::OptionalEncryptableEmail, | ||
pub name: crypto::OptionalEncryptableName, | ||
pub phone: crypto::OptionalEncryptablePhone, | ||
|
@@ -3738,7 +3770,7 @@ pub struct PaymentsRedirectionResponse { | |
pub struct MandateValidationFields { | ||
pub recurring_details: Option<RecurringDetails>, | ||
pub confirm: Option<bool>, | ||
pub customer_id: Option<String>, | ||
pub customer_id: Option<id_type::CustomerId>, | ||
pub mandate_data: Option<MandateData>, | ||
pub setup_future_usage: Option<api_enums::FutureUsage>, | ||
pub off_session: Option<bool>, | ||
|
@@ -3847,7 +3879,7 @@ pub struct PgRedirectResponse { | |
pub payment_id: String, | ||
pub status: api_enums::IntentStatus, | ||
pub gateway_id: String, | ||
pub customer_id: Option<String>, | ||
pub customer_id: Option<id_type::CustomerId>, | ||
pub amount: Option<MinorUnit>, | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.