Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

feat(payment_methods): add payment-methods/filter endpoint to list countries and currencies for connector payment method in v2 (#8978)

Ayush Anand6016377ad8e4
diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rs
index cf684a680e..1ff441c570 100644
--- a/crates/router/src/routes/app.rs
+++ b/crates/router/src/routes/app.rs
@@ -1348,38 +1348,52 @@ impl Payouts {
}
}
-#[cfg(all(feature = "oltp", feature = "v2"))]
+#[cfg(all(feature = "v2", any(feature = "olap", feature = "oltp")))]
impl PaymentMethods {
pub fn server(state: AppState) -> Scope {
let mut route = web::scope("/v2/payment-methods").app_data(web::Data::new(state));
- route = route
- .service(
- web::resource("").route(web::post().to(payment_methods::create_payment_method_api)),
- )
- .service(
- web::resource("/create-intent")
- .route(web::post().to(payment_methods::create_payment_method_intent_api)),
- );
- route = route.service(
- web::scope("/{id}")
+ #[cfg(feature = "olap")]
+ {
+ route =
+ route.service(web::resource("/filter").route(
+ web::get().to(
+ payment_methods::list_countries_currencies_for_connector_payment_method,
+ ),
+ ));
+ }
+ #[cfg(feature = "oltp")]
+ {
+ route = route
.service(
web::resource("")
- .route(web::get().to(payment_methods::payment_method_retrieve_api))
- .route(web::delete().to(payment_methods::payment_method_delete_api)),
- )
- .service(web::resource("/list-enabled-payment-methods").route(
- web::get().to(payment_methods::payment_method_session_list_payment_methods),
- ))
- .service(
- web::resource("/update-saved-payment-method")
- .route(web::put().to(payment_methods::payment_method_update_api)),
+ .route(web::post().to(payment_methods::create_payment_method_api)),
)
.service(
- web::resource("/get-token")
- .route(web::get().to(payment_methods::get_payment_method_token_data)),
- ),
- );
+ web::resource("/create-intent")
+ .route(web::post().to(payment_methods::create_payment_method_intent_api)),
+ );
+
+ route = route.service(
+ web::scope("/{id}")
+ .service(
+ web::resource("")
+ .route(web::get().to(payment_methods::payment_method_retrieve_api))
+ .route(web::delete().to(payment_methods::payment_method_delete_api)),
+ )
+ .service(web::resource("/list-enabled-payment-methods").route(
+ web::get().to(payment_methods::payment_method_session_list_payment_methods),
+ ))
+ .service(
+ web::resource("/update-saved-payment-method")
+ .route(web::put().to(payment_methods::payment_method_update_api)),
+ )
+ .service(
+ web::resource("/get-token")
+ .route(web::get().to(payment_methods::get_payment_method_token_data)),
+ ),
+ );
+ }
route
}
diff --git a/crates/router/src/routes/payment_methods.rs b/crates/router/src/routes/payment_methods.rs
index 367ece308c..08b84e4097 100644
--- a/crates/router/src/routes/payment_methods.rs
+++ b/crates/router/src/routes/payment_methods.rs
@@ -913,6 +913,47 @@ pub async fn list_countries_currencies_for_connector_payment_method(
.await
}
+#[cfg(feature = "v2")]
+#[instrument(skip_all, fields(flow = ?Flow::ListCountriesCurrencies))]
+pub async fn list_countries_currencies_for_connector_payment_method(
+ state: web::Data<AppState>,
+ req: HttpRequest,
+ query_payload: web::Query<payment_methods::ListCountriesCurrenciesRequest>,
+) -> HttpResponse {
+ let flow = Flow::ListCountriesCurrencies;
+ let payload = query_payload.into_inner();
+ Box::pin(api::server_wrap(
+ flow,
+ state,
+ &req,
+ payload,
+ |state, auth: auth::AuthenticationData, req, _| {
+ cards::list_countries_currencies_for_connector_payment_method(
+ state,
+ req,
+ Some(auth.profile.get_id().clone()),
+ )
+ },
+ #[cfg(not(feature = "release"))]
+ auth::auth_type(
+ &auth::V2ApiKeyAuth {
+ is_connected_allowed: false,
+ is_platform_allowed: false,
+ },
+ &auth::JWTAuth {
+ permission: Permission::ProfileConnectorRead,
+ },
+ req.headers(),
+ ),
+ #[cfg(feature = "release")]
+ &auth::JWTAuth {
+ permission: Permission::ProfileConnectorRead,
+ },
+ api_locking::LockAction::NotApplicable,
+ ))
+ .await
+}
+
#[cfg(feature = "v1")]
#[instrument(skip_all, fields(flow = ?Flow::DefaultPaymentMethodsSet))]
pub async fn default_payment_method_set_api(