Skip to content

Commit 9eaebe8

Browse files
authored
refactor(router): restricted list payment method Customer to api-key based (#3100)
1 parent 5a5400c commit 9eaebe8

File tree

3 files changed

+2
-30
lines changed

3 files changed

+2
-30
lines changed

crates/api_models/src/payment_methods.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ use utoipa::{schema, ToSchema};
1313
#[cfg(feature = "payouts")]
1414
use crate::payouts;
1515
use crate::{
16-
admin,
17-
customers::CustomerId,
18-
enums as api_enums,
16+
admin, enums as api_enums,
1917
payments::{self, BankCodeResponse},
2018
};
2119

@@ -459,8 +457,6 @@ pub struct RequestPaymentMethodTypes {
459457
#[derive(Debug, Clone, serde::Serialize, Default, ToSchema)]
460458
#[serde(deny_unknown_fields)]
461459
pub struct PaymentMethodListRequest {
462-
#[serde(skip_deserializing)]
463-
pub customer_id: Option<CustomerId>,
464460
/// This is a 15 minute expiry token which shall be used from the client to authenticate and perform sessions from the SDK
465461
#[schema(max_length = 30, min_length = 30, example = "secret_k2uj3he2893ein2d")]
466462
pub client_secret: Option<String>,

crates/router/src/routes/payment_methods.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ pub async fn list_payment_method_api(
108108
get,
109109
path = "/customers/{customer_id}/payment_methods",
110110
params (
111-
("customer_id" = String, Path, description = "The unique identifier for the customer account"),
112111
("accepted_country" = Vec<String>, Query, description = "The two-letter ISO currency code"),
113112
("accepted_currency" = Vec<Currency>, Path, description = "The three-letter ISO currency code"),
114113
("minimum_amount" = i64, Query, description = "The minimum amount accepted for processing by the particular payment method."),
@@ -134,10 +133,6 @@ pub async fn list_customer_payment_method_api(
134133
) -> HttpResponse {
135134
let flow = Flow::CustomerPaymentMethodsList;
136135
let payload = query_payload.into_inner();
137-
let (auth, _) = match auth::check_client_secret_and_get_auth(req.headers(), &payload) {
138-
Ok((auth, _auth_flow)) => (auth, _auth_flow),
139-
Err(e) => return api::log_and_return_error_response(e),
140-
};
141136
let customer_id = customer_id.into_inner().0;
142137
Box::pin(api::server_wrap(
143138
flow,
@@ -153,7 +148,7 @@ pub async fn list_customer_payment_method_api(
153148
Some(&customer_id),
154149
)
155150
},
156-
&*auth,
151+
&auth::ApiKeyAuth,
157152
api_locking::LockAction::NotApplicable,
158153
))
159154
.await
@@ -166,7 +161,6 @@ pub async fn list_customer_payment_method_api(
166161
path = "/customers/payment_methods",
167162
params (
168163
("client-secret" = String, Path, description = "A secret known only to your application and the authorization server"),
169-
("customer_id" = String, Path, description = "The unique identifier for the customer account"),
170164
("accepted_country" = Vec<String>, Query, description = "The two-letter ISO currency code"),
171165
("accepted_currency" = Vec<Currency>, Path, description = "The three-letter ISO currency code"),
172166
("minimum_amount" = i64, Query, description = "The minimum amount accepted for processing by the particular payment method."),

openapi/openapi_spec.json

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -473,15 +473,6 @@
473473
"type": "string"
474474
}
475475
},
476-
{
477-
"name": "customer_id",
478-
"in": "path",
479-
"description": "The unique identifier for the customer account",
480-
"required": true,
481-
"schema": {
482-
"type": "string"
483-
}
484-
},
485476
{
486477
"name": "accepted_country",
487478
"in": "query",
@@ -711,15 +702,6 @@
711702
"description": "List payment methods for a Customer\n\nTo filter and list the applicable payment methods for a particular Customer ID",
712703
"operationId": "List all Payment Methods for a Customer",
713704
"parameters": [
714-
{
715-
"name": "customer_id",
716-
"in": "path",
717-
"description": "The unique identifier for the customer account",
718-
"required": true,
719-
"schema": {
720-
"type": "string"
721-
}
722-
},
723705
{
724706
"name": "accepted_country",
725707
"in": "query",

0 commit comments

Comments
 (0)