Skip to content

Commit a801fed

Browse files
chore: add extra information enum and make customer_payment_methods as optional
1 parent 7618c9d commit a801fed

File tree

5 files changed

+57
-24
lines changed

5 files changed

+57
-24
lines changed

api-reference-v2/openapi_spec.json

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13947,6 +13947,38 @@
1394713947
"awaiting_data"
1394813948
]
1394913949
},
13950+
"PaymentMethodSubtypeSpecificData": {
13951+
"oneOf": [
13952+
{
13953+
"type": "object",
13954+
"required": [
13955+
"card_networks"
13956+
],
13957+
"properties": {
13958+
"card_networks": {
13959+
"type": "array",
13960+
"items": {
13961+
"$ref": "#/components/schemas/CardNetworkTypes"
13962+
}
13963+
}
13964+
}
13965+
},
13966+
{
13967+
"type": "object",
13968+
"required": [
13969+
"bank_names"
13970+
],
13971+
"properties": {
13972+
"bank_names": {
13973+
"type": "array",
13974+
"items": {
13975+
"$ref": "#/components/schemas/BankCodeResponse"
13976+
}
13977+
}
13978+
}
13979+
}
13980+
]
13981+
},
1395013982
"PaymentMethodType": {
1395113983
"type": "string",
1395213984
"description": "Indicates the sub type of payment method. Eg: 'google_pay' & 'apple_pay' for wallets.",
@@ -18858,20 +18890,12 @@
1885818890
"payment_method_subtype": {
1885918891
"$ref": "#/components/schemas/PaymentMethodType"
1886018892
},
18861-
"card_networks": {
18862-
"type": "array",
18863-
"items": {
18864-
"$ref": "#/components/schemas/CardNetworkTypes"
18865-
},
18866-
"description": "The list of card networks enabled, if applicable for a payment method type",
18867-
"nullable": true
18868-
},
18869-
"bank_names": {
18870-
"type": "array",
18871-
"items": {
18872-
"$ref": "#/components/schemas/BankCodeResponse"
18873-
},
18874-
"description": "The list of banks enabled, if applicable for a payment method type",
18893+
"extra_information": {
18894+
"allOf": [
18895+
{
18896+
"$ref": "#/components/schemas/PaymentMethodSubtypeSpecificData"
18897+
}
18898+
],
1887518899
"nullable": true
1887618900
},
1887718901
"required_fields": {

crates/api_models/src/payment_methods.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,6 +1252,18 @@ pub struct ResponsePaymentMethodTypes {
12521252
pub pm_auth_connector: Option<String>,
12531253
}
12541254

1255+
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
1256+
#[derive(Debug, Clone, serde::Serialize, ToSchema, PartialEq)]
1257+
#[serde(untagged)] // Untagged used for serialization only
1258+
pub enum PaymentMethodSubtypeSpecificData {
1259+
Card {
1260+
card_networks: Vec<CardNetworkTypes>,
1261+
},
1262+
Bank {
1263+
bank_names: Vec<BankCodeResponse>,
1264+
},
1265+
}
1266+
12551267
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
12561268
#[derive(Debug, Clone, serde::Serialize, ToSchema, PartialEq)]
12571269
pub struct ResponsePaymentMethodTypes {
@@ -1263,11 +1275,8 @@ pub struct ResponsePaymentMethodTypes {
12631275
#[schema(example = "klarna", value_type = PaymentMethodType)]
12641276
pub payment_method_subtype: common_enums::PaymentMethodType,
12651277

1266-
/// The list of card networks enabled, if applicable for a payment method type
1267-
pub card_networks: Option<Vec<CardNetworkTypes>>,
1268-
1269-
/// The list of banks enabled, if applicable for a payment method type
1270-
pub bank_names: Option<Vec<BankCodeResponse>>,
1278+
/// payment method subtype specific information
1279+
pub extra_information: Option<PaymentMethodSubtypeSpecificData>,
12711280

12721281
/// Required fields for the payment_method_type.
12731282
/// This is the union of all the required fields for the payment method type enabled in all the connectors.

crates/api_models/src/payments.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6472,8 +6472,8 @@ pub struct PaymentMethodListResponseForPayments {
64726472

64736473
/// The list of payment methods that are saved by the given customer
64746474
/// This field is only returned if the customer_id is provided in the request
6475-
#[schema(value_type = Vec<CustomerPaymentMethod>)]
6476-
pub customer_payment_methods: Vec<payment_methods::CustomerPaymentMethod>,
6475+
#[schema(value_type = Option<Vec<CustomerPaymentMethod>>)]
6476+
pub customer_payment_methods: Option<Vec<payment_methods::CustomerPaymentMethod>>,
64776477
}
64786478

64796479
#[derive(Debug, serde::Serialize, serde::Deserialize, Clone, ToSchema)]

crates/openapi/src/openapi_v2.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ Never share your secret api keys. Keep them guarded and secure.
198198
api_models::payment_methods::PaymentMethodListRequest,
199199
api_models::payment_methods::PaymentMethodListResponse,
200200
api_models::payment_methods::ResponsePaymentMethodsEnabled,
201+
api_models::payment_methods::PaymentMethodSubtypeSpecificData,
201202
api_models::payment_methods::ResponsePaymentMethodTypes,
202203
api_models::payment_methods::PaymentExperienceTypes,
203204
api_models::payment_methods::CardNetworkTypes,

crates/router/src/core/payments/payment_methods.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,14 @@ impl RequiredFieldsAndSurchargeForEnabledPaymentMethodTypes {
142142
payment_method_subtype: payment_methods_enabled.payment_method_subtype,
143143
required_fields: payment_methods_enabled.required_field,
144144
surcharge_details: payment_methods_enabled.surcharge,
145-
card_networks: None,
146-
bank_names: None,
145+
extra_information: None,
147146
}
148147
})
149148
.collect();
150149

151150
api_models::payments::PaymentMethodListResponseForPayments {
152151
payment_methods_enabled: response_payment_methods,
153-
customer_payment_methods: Vec::new(),
152+
customer_payment_methods: None,
154153
}
155154
}
156155
}

0 commit comments

Comments
 (0)