Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(payment_methods): Implemented diesel/domain models in PaymentMethods for v2 #5515

Open
wants to merge 85 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
b88e259
refactor(core): Refactor customer pml for v2
Sarthak1799 Jun 3, 2024
f2d7e05
Merge branch 'main' of github.com:juspay/hyperswitch into refactor-cu…
Sarthak1799 Jun 5, 2024
cd89296
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] Jun 5, 2024
a580b35
fix(payment_methods): Fixed clippy errors
Sarthak1799 Jun 5, 2024
4eae216
fix(payment_methods): Fixed clippy errors
Sarthak1799 Jun 5, 2024
51c7d12
fix(payment_methods): Resolved comments
Sarthak1799 Jun 10, 2024
eb053c5
refactor(payment_methods): Initial commit
Sarthak1799 Jun 11, 2024
7a63e20
refactor(payment_methods): initial dev
Sarthak1799 Jun 14, 2024
c19b60b
refactor(payment_methods): Initital dev
Sarthak1799 Jun 19, 2024
d2f8252
fix(payment_methods): Fixed errors
Sarthak1799 Jun 19, 2024
13f8f72
chore: run formatter
hyperswitch-bot[bot] Jun 19, 2024
c71e21a
Merge branch 'main' of github.com:juspay/hyperswitch into refactor-cu…
Sarthak1799 Jun 20, 2024
bc62440
fix(payment_methods): Fixed errors
Sarthak1799 Jun 20, 2024
ddd9fd6
fix(payment_methods): Resolved comments
Sarthak1799 Jun 26, 2024
45d3980
Merge branch 'main' of github.com:juspay/hyperswitch into refactor-pm…
Sarthak1799 Jun 26, 2024
eb6c837
Merge branch 'main' into refactor-pm-create
Sarthak1799 Jun 26, 2024
944a5d4
fix(payment_methods): Fixed errors
Sarthak1799 Jun 26, 2024
21a23c0
fix(payment_methods): Fixed errors
Sarthak1799 Jun 26, 2024
73113f5
fix(payment_methods): Fixed errors
Sarthak1799 Jun 26, 2024
b2c0274
refactor(payment_methods): refactored for v2 flag
Sarthak1799 Jul 1, 2024
2ac2fa9
chore: run formatter
hyperswitch-bot[bot] Jul 1, 2024
d0e505a
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] Jul 1, 2024
d19ca37
fix(payment_methods): Fixed errors
Sarthak1799 Jul 2, 2024
d98b862
Merge branch 'main' of github.com:juspay/hyperswitch into refactor-cu…
Sarthak1799 Jul 2, 2024
47874b3
fix(payment_methods): Fixed errors
Sarthak1799 Jul 2, 2024
7a918cd
fix(payment_methods): Fixed errors
Sarthak1799 Jul 2, 2024
a921a06
fix(payment_methods): Fixed errors
Sarthak1799 Jul 2, 2024
1b30883
fix(payment_methods): refactored for v2 flag
Sarthak1799 Jul 2, 2024
dbafd56
fix(payment_methods): Fixed errors
Sarthak1799 Jul 2, 2024
ff414c7
refactor(payment_methods): Refactored a bit
Sarthak1799 Jul 3, 2024
f892342
Merge branch 'main' into refactor-customer-pm-list
Sarthak1799 Jul 3, 2024
f991fca
fix(payment_methods): Fixed errors
Sarthak1799 Jul 3, 2024
c4ffddd
fix(payment_methods): Fixed errors
Sarthak1799 Jul 3, 2024
b4cde23
refactor(payment_methods): Refactored a bit
Sarthak1799 Jul 4, 2024
51ece84
Merge branch 'main' of github.com:juspay/hyperswitch into refactor-pm…
Sarthak1799 Jul 4, 2024
2d33c88
fix(payment_methods): Fixed errors
Sarthak1799 Jul 5, 2024
3059b27
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] Jul 5, 2024
e3e03e5
fix(payment_methods): Fixed errors
Sarthak1799 Jul 5, 2024
658a1a2
Merge branch 'main' of github.com:juspay/hyperswitch into refactor-cu…
Sarthak1799 Jul 19, 2024
cf8db57
Merge branch 'main' of github.com:juspay/hyperswitch into refactor-cu…
Sarthak1799 Jul 22, 2024
761dca6
refactor(payment_methods): Refactored
Sarthak1799 Jul 22, 2024
62c91b9
chore: run formatter
hyperswitch-bot[bot] Jul 22, 2024
a681bed
Merge branch 'main' of github.com:juspay/hyperswitch into refactor-cu…
Sarthak1799 Jul 23, 2024
64fc9a4
fix(payment_methods): Fixed errors
Sarthak1799 Jul 23, 2024
8595c68
chore: run formatter
hyperswitch-bot[bot] Jul 23, 2024
4a971ea
fix(payment_methods): Fixed errors
Sarthak1799 Jul 23, 2024
75486a1
chore: run formatter
hyperswitch-bot[bot] Jul 23, 2024
1efda3c
fix(payment_methods): Fixed errors
Sarthak1799 Jul 23, 2024
2049014
fix(payment_methods): Fixed errors
Sarthak1799 Jul 23, 2024
252a4c8
Merge branch 'refactor-customer-pm-list' of github.com:juspay/hypersw…
Sarthak1799 Jul 24, 2024
5135b45
refactor(payment_methods): Refactored
Sarthak1799 Jul 24, 2024
137091b
fix(payment_methods): Resolved comments
Sarthak1799 Jul 25, 2024
9160090
Merge branch 'main' of github.com:juspay/hyperswitch into refactor-cu…
Sarthak1799 Jul 25, 2024
185bc62
chore: run formatter
hyperswitch-bot[bot] Jul 25, 2024
69a2b80
fix(payment_methods): Fixed errors
Sarthak1799 Jul 25, 2024
3b432f9
Merge branch 'refactor-customer-pm-list' of github.com:juspay/hypersw…
Sarthak1799 Jul 25, 2024
e83be21
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] Jul 25, 2024
79456dd
fix(payment_methods): Fixed errors
Sarthak1799 Jul 25, 2024
730b094
Merge branch 'main' into refactor-customer-pm-list
Sarthak1799 Jul 26, 2024
cfde27c
Merge branch 'refactor-customer-pm-list' of github.com:juspay/hypersw…
Sarthak1799 Jul 26, 2024
a8b6abc
fix(payment_methods): Fixed errors
Sarthak1799 Jul 26, 2024
59bd59f
fix(payment_methods): Fixed errors
Sarthak1799 Jul 26, 2024
966a030
chore: run formatter
hyperswitch-bot[bot] Jul 26, 2024
52f68c2
fix(payment_methods): Fixed errors
Sarthak1799 Jul 26, 2024
967492e
Merge branch 'main' into refactor-customer-pm-list
Sarthak1799 Jul 26, 2024
31debdd
Merge branch 'refactor-customer-pm-list' of github.com:juspay/hypersw…
Sarthak1799 Jul 26, 2024
298e69a
Merge branch 'main' into refactor-customer-pm-list
Sarthak1799 Jul 27, 2024
5328c9f
fix(payment_methods): Fixed errors
Sarthak1799 Jul 27, 2024
dddbe8b
Merge branch 'refactor-customer-pm-list' of github.com:juspay/hypersw…
Sarthak1799 Jul 28, 2024
b2ec425
fix(payment_methods): Refactored
Sarthak1799 Jul 28, 2024
0280df9
fix(payment_methods): Fixed errors
Sarthak1799 Jul 29, 2024
b001e1e
fix(payment_methods): Fixed errors
Sarthak1799 Jul 29, 2024
300b09a
Merge branch 'main' of github.com:juspay/hyperswitch into refactor-cu…
Sarthak1799 Jul 30, 2024
c135be7
Merge branch 'refactor-customer-pm-list' of github.com:juspay/hypersw…
Sarthak1799 Jul 30, 2024
4bcca4f
fix(payment_methods): Fixed errors
Sarthak1799 Jul 30, 2024
0cdcc64
fix(payment_methods): Resolved comments
Sarthak1799 Jul 31, 2024
ff378cb
chore: run formatter
hyperswitch-bot[bot] Jul 31, 2024
e838c6e
Merge branch 'main' of github.com:juspay/hyperswitch into refactor-cu…
Sarthak1799 Aug 1, 2024
fcb6c8c
Merge branch 'refactor-customer-pm-list' of github.com:juspay/hypersw…
Sarthak1799 Aug 1, 2024
29945bf
Merge branch 'main' of github.com:juspay/hyperswitch into refactor-cu…
Sarthak1799 Aug 1, 2024
a2da064
Merge branch 'refactor-customer-pm-list' of github.com:juspay/hypersw…
Sarthak1799 Aug 1, 2024
5fb96d2
feat(payment_methods): Implemented diesel and domain models for v2
Sarthak1799 Aug 2, 2024
e383482
chore: run formatter
hyperswitch-bot[bot] Aug 2, 2024
0ec529b
fix(core): Fixed errors
Sarthak1799 Aug 5, 2024
d631153
fix(core): Fixed errors
Sarthak1799 Aug 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions api-reference/openapi_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -14394,6 +14394,28 @@
"$ref": "#/components/schemas/CardDetail"
}
}
},
{
"type": "object",
"required": [
"bank_transfer"
],
"properties": {
"bank_transfer": {
"$ref": "#/components/schemas/Bank"
}
}
},
{
"type": "object",
"required": [
"wallet"
],
"properties": {
"wallet": {
"$ref": "#/components/schemas/Wallet"
}
}
}
]
},
Expand Down
1 change: 1 addition & 0 deletions crates/api_models/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ customer_v2 = []
merchant_account_v2 = []
merchant_connector_account_v2 = []
payment_v2 = []
payment_methods_v2 = []
routing_v2 = []

[dependencies]
Expand Down
17 changes: 12 additions & 5 deletions crates/api_models/src/events/payment.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
use common_utils::events::{ApiEventMetric, ApiEventsType};

#[cfg(all(
any(feature = "v2", feature = "v1"),
not(feature = "payment_methods_v2")
))]
use crate::payment_methods::CustomerPaymentMethodsListResponse;
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
use crate::payment_methods::CustomerPaymentMethodsListResponse;
use crate::{
payment_methods::{
CustomerDefaultPaymentMethodResponse, CustomerPaymentMethodsListResponse,
DefaultPaymentMethod, ListCountriesCurrenciesRequest, ListCountriesCurrenciesResponse,
PaymentMethodCollectLinkRenderRequest, PaymentMethodCollectLinkRequest,
PaymentMethodCollectLinkResponse, PaymentMethodDeleteResponse, PaymentMethodListRequest,
PaymentMethodListResponse, PaymentMethodResponse, PaymentMethodUpdate,
CustomerDefaultPaymentMethodResponse, DefaultPaymentMethod, ListCountriesCurrenciesRequest,
ListCountriesCurrenciesResponse, PaymentMethodCollectLinkRenderRequest,
PaymentMethodCollectLinkRequest, PaymentMethodCollectLinkResponse,
PaymentMethodDeleteResponse, PaymentMethodListRequest, PaymentMethodListResponse,
PaymentMethodResponse, PaymentMethodUpdate,
},
payments::{
ExtendedCardInfoResponse, PaymentIdType, PaymentListConstraints,
Expand Down
272 changes: 271 additions & 1 deletion crates/api_models/src/payment_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ use crate::{
payments::{self, BankCodeResponse},
};

#[cfg(all(
any(feature = "v1", feature = "v2"),
not(feature = "payment_methods_v2")
))]
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema)]
#[serde(deny_unknown_fields)]
pub struct PaymentMethodCreate {
Expand Down Expand Up @@ -96,6 +100,64 @@ pub struct PaymentMethodCreate {
pub network_transaction_id: Option<String>,
}

#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema)]
#[serde(deny_unknown_fields)]
pub struct PaymentMethodCreate {
/// The type of payment method use for the payment.
#[schema(value_type = PaymentMethod,example = "card")]
pub payment_method: Option<api_enums::PaymentMethod>,

/// This is a sub-category of payment method.
#[schema(value_type = Option<PaymentMethodType>,example = "credit")]
pub payment_method_type: Option<api_enums::PaymentMethodType>,

/// The name of the bank/ provider issuing the payment method to the end user
#[schema(example = "Citibank")]
pub payment_method_issuer: Option<String>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field should be removed.


/// A standard code representing the issuer of payment method
#[schema(value_type = Option<PaymentMethodIssuerCode>,example = "jp_applepay")]
pub payment_method_issuer_code: Option<api_enums::PaymentMethodIssuerCode>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field also should be removed


/// 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<pii::SecretSerdeValue>,

/// The unique identifier of the customer.
#[schema(value_type = Option<String>, max_length = 64, min_length = 1, example = "cus_y3oqhf46pyzuxjbcn2giaqnb44")]
pub customer_id: Option<id_type::CustomerId>,

/// The card network
#[schema(example = "Visa")]
pub card_network: Option<String>,

/// For Client based calls, SDK will use the client_secret
/// in order to call /payment_methods
/// Client secret will be generated whenever a new
/// payment method is created
pub client_secret: Option<String>,

/// Payment method data to be passed
pub payment_method_data: Option<PaymentMethodCreateData>,

/// The billing details of the payment method
#[schema(value_type = Option<Address>)]
pub billing: Option<payments::Address>,

#[serde(skip_deserializing)]
/// The connector mandate details of the payment method, this is added only for cards migration
/// api and is skipped during deserialization of the payment method create request as this
/// it should not be passed in the request
pub connector_mandate_details: Option<PaymentsMandateReference>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field also not added in the documentation, we need to add this?


#[serde(skip_deserializing)]
/// The transaction id of a CIT (customer initiated transaction) associated with the payment method,
/// this is added only for cards migration api and is skipped during deserialization of the
/// payment method create request as it should not be passed in the request
pub network_transaction_id: Option<String>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field also not added in the documentation, we need to add this?

}

#[derive(Debug, serde::Deserialize, serde::Serialize, Clone)]
/// This struct is only used by and internal api to migrate payment method
pub struct PaymentMethodMigrate {
Expand Down Expand Up @@ -159,6 +221,10 @@ pub struct PaymentsMandateReferenceRecord {
pub original_payment_authorized_currency: Option<common_enums::Currency>,
}

#[cfg(all(
any(feature = "v1", feature = "v2"),
not(feature = "payment_methods_v2")
))]
impl PaymentMethodCreate {
pub fn get_payment_method_create_from_payment_method_migrate(
card_number: CardNumber,
Expand Down Expand Up @@ -202,6 +268,29 @@ impl PaymentMethodCreate {
}
}

#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
impl PaymentMethodCreate {
pub fn get_payment_method_create_from_payment_method_migrate(
_card_number: CardNumber,
payment_method_migrate: &PaymentMethodMigrate,
) -> Self {
Self {
customer_id: payment_method_migrate.customer_id.clone(),
payment_method: payment_method_migrate.payment_method,
payment_method_type: payment_method_migrate.payment_method_type,
payment_method_issuer: payment_method_migrate.payment_method_issuer.clone(),
payment_method_issuer_code: payment_method_migrate.payment_method_issuer_code,
metadata: payment_method_migrate.metadata.clone(),
payment_method_data: payment_method_migrate.payment_method_data.clone(),
connector_mandate_details: payment_method_migrate.connector_mandate_details.clone(),
client_secret: None,
billing: payment_method_migrate.billing.clone(),
card_network: payment_method_migrate.card_network.clone(),
network_transaction_id: payment_method_migrate.network_transaction_id.clone(),
}
}
}

#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema)]
#[serde(deny_unknown_fields)]
pub struct PaymentMethodUpdate {
Expand All @@ -225,6 +314,25 @@ pub struct PaymentMethodUpdate {

pub enum PaymentMethodCreateData {
Card(CardDetail),
#[cfg(feature = "payouts")]
#[schema(value_type = Bank)]
BankTransfer(payouts::Bank),
#[cfg(feature = "payouts")]
#[schema(value_type = Wallet)]
Wallet(payouts::Wallet),
}

#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema)]
#[serde(deny_unknown_fields)]
#[serde(rename_all = "snake_case")]
#[serde(rename = "payment_method_data")]

pub enum PaymentMethodResponseData {
Card(CardDetailFromLocker),
#[cfg(feature = "payouts")]
#[schema(value_type = Bank)]
BankTransfer(payouts::Bank),
}

#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema)]
Expand Down Expand Up @@ -349,7 +457,11 @@ impl CardDetailUpdate {
}
}

#[derive(Debug, serde::Deserialize, serde::Serialize, ToSchema)]
#[cfg(all(
any(feature = "v1", feature = "v2"),
not(feature = "payment_methods_v2")
))]
#[derive(Debug, serde::Deserialize, serde::Serialize, ToSchema, Clone)]
pub struct PaymentMethodResponse {
/// Unique identifier for a merchant
#[schema(example = "merchant_1671528864", value_type = String)]
Expand Down Expand Up @@ -410,6 +522,60 @@ pub struct PaymentMethodResponse {
pub client_secret: Option<String>,
}

#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
#[derive(Debug, serde::Deserialize, serde::Serialize, ToSchema, Clone)]
pub struct PaymentMethodResponse {
/// Unique identifier for a merchant
#[schema(example = "merchant_1671528864")]
pub merchant_id: id_type::MerchantId,

/// The unique identifier of the customer.
#[schema(value_type = Option<String>, max_length = 64, min_length = 1, example = "cus_y3oqhf46pyzuxjbcn2giaqnb44")]
pub customer_id: Option<id_type::CustomerId>,

/// The unique identifier of the Payment method
#[schema(example = "card_rGK4Vi5iSW70MY7J2mIg")]
pub payment_method_id: String,

/// The type of payment method use for the payment.
#[schema(value_type = PaymentMethod, example = "card")]
pub payment_method: Option<api_enums::PaymentMethod>,

/// This is a sub-category of payment method.
#[schema(value_type = Option<PaymentMethodType>, example = "credit")]
pub payment_method_type: Option<api_enums::PaymentMethodType>,

/// Indicates whether the payment method is eligible for recurring payments
#[schema(example = true)]
pub recurring_enabled: bool,

/// Indicates whether the payment method is eligible for installment payments
#[schema(example = true)]
pub installment_payment_enabled: bool,

/// Type of payment experience enabled with the connector
#[schema(value_type = Option<Vec<PaymentExperience>>, example = json!(["redirect_to_url"]))]
pub payment_experience: Option<Vec<api_enums::PaymentExperience>>,

/// 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<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")]
#[serde(default, with = "common_utils::custom_serde::iso8601::option")]
pub created: Option<time::PrimitiveDateTime>,

#[schema(value_type = Option<PrimitiveDateTime>, example = "2024-02-24T11:04:09.922Z")]
#[serde(default, with = "common_utils::custom_serde::iso8601::option")]
pub last_used_at: Option<time::PrimitiveDateTime>,

/// For Client based calls
pub client_secret: Option<String>,

pub payment_method_data: Option<PaymentMethodResponseData>,
}

#[derive(Clone, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize)]
pub enum PaymentMethodsData {
Card(CardDetailsPaymentMethod),
Expand Down Expand Up @@ -994,6 +1160,19 @@ impl serde::Serialize for PaymentMethodList {
}
}

#[cfg(all(
any(feature = "v2", feature = "v1"),
not(feature = "payment_methods_v2")
))]
#[derive(Debug, serde::Serialize, ToSchema)]
pub struct CustomerPaymentMethodsListResponse {
/// List of payment methods for customer
pub customer_payment_methods: Vec<CustomerPaymentMethod>,
/// Returns whether a customer id is not tied to a payment intent (only when the request is made against a client secret)
pub is_guest_customer: Option<bool>,
}

#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
#[derive(Debug, serde::Serialize, ToSchema)]
pub struct CustomerPaymentMethodsListResponse {
/// List of payment methods for customer
Expand Down Expand Up @@ -1028,6 +1207,97 @@ pub struct CustomerDefaultPaymentMethodResponse {
pub payment_method_type: Option<api_enums::PaymentMethodType>,
}

#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
#[derive(Debug, Clone, serde::Serialize, ToSchema)]
pub struct CustomerPaymentMethod {
/// Token for payment method in temporary card locker which gets refreshed often
#[schema(example = "7ebf443f-a050-4067-84e5-e6f6d4800aef")]
pub payment_token: Option<String>,
/// The unique identifier of the customer.
#[schema(example = "pm_iouuy468iyuowqs")]
pub payment_method_id: String,

/// The unique identifier of the customer.
#[schema(value_type = String, max_length = 64, min_length = 1, example = "cus_y3oqhf46pyzuxjbcn2giaqnb44")]
pub customer_id: id_type::CustomerId,

/// The type of payment method use for the payment.
#[schema(value_type = PaymentMethod,example = "card")]
pub payment_method: api_enums::PaymentMethod,

/// This is a sub-category of payment method.
#[schema(value_type = Option<PaymentMethodType>,example = "credit_card")]
pub payment_method_type: Option<api_enums::PaymentMethodType>,

/// The name of the bank/ provider issuing the payment method to the end user
#[schema(example = "Citibank")]
pub payment_method_issuer: Option<String>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this field


/// A standard code representing the issuer of payment method
#[schema(value_type = Option<PaymentMethodIssuerCode>,example = "jp_applepay")]
pub payment_method_issuer_code: Option<api_enums::PaymentMethodIssuerCode>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this field


/// Indicates whether the payment method is eligible for recurring payments
#[schema(example = true)]
pub recurring_enabled: bool,

/// Indicates whether the payment method is eligible for installment payments
#[schema(example = true)]
pub installment_payment_enabled: bool,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this field


/// Type of payment experience enabled with the connector
#[schema(value_type = Option<Vec<PaymentExperience>>,example = json!(["redirect_to_url"]))]
pub payment_experience: Option<Vec<api_enums::PaymentExperience>>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this field


/// PaymentMethod Data from locker
pub payment_method_data: Option<PaymentMethodListData>,

/// Masked bank details from PM auth services
#[schema(example = json!({"mask": "0000"}))]
pub bank: Option<MaskedBankDetails>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be moved payment_method_data


/// 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<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")]
#[serde(default, with = "common_utils::custom_serde::iso8601::option")]
pub created: Option<time::PrimitiveDateTime>,

/// Surcharge details for this saved card
pub surcharge_details: Option<SurchargeDetailsResponse>,

/// Whether this payment method requires CVV to be collected
#[schema(example = true)]
pub requires_cvv: bool,

/// A timestamp (ISO 8601 code) that determines when the payment method was last used
#[schema(value_type = Option<PrimitiveDateTime>,example = "2024-02-24T11:04:09.922Z")]
#[serde(default, with = "common_utils::custom_serde::iso8601::option")]
pub last_used_at: Option<time::PrimitiveDateTime>,
/// Indicates if the payment method has been set to default or not
#[schema(example = true)]
pub default_payment_method_set: bool,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to is_default


/// The billing details of the payment method
#[schema(value_type = Option<Address>)]
pub billing: Option<payments::Address>,
}

#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
#[derive(Debug, Clone, serde::Serialize, ToSchema)]
#[serde(rename_all = "snake_case")]
pub enum PaymentMethodListData {
Card(CardDetailFromLocker),
#[cfg(feature = "payouts")]
Bank(payouts::Bank),
}

#[cfg(all(
any(feature = "v2", feature = "v1"),
not(feature = "payment_methods_v2")
))]
#[derive(Debug, Clone, serde::Serialize, ToSchema)]
pub struct CustomerPaymentMethod {
/// Token for payment method in temporary card locker which gets refreshed often
Expand Down
Loading
Loading