mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 09:38:33 +08:00
feat(router): Add customer_list_saved_payment_methods endpoint to OLAP (#7241)
This commit is contained in:
@ -1264,6 +1264,23 @@ pub async fn list_payment_methods_for_session(
|
||||
))
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "v2", feature = "olap"))]
|
||||
#[instrument(skip_all)]
|
||||
pub async fn list_saved_payment_methods_for_customer(
|
||||
state: SessionState,
|
||||
merchant_account: domain::MerchantAccount,
|
||||
key_store: domain::MerchantKeyStore,
|
||||
customer_id: id_type::GlobalCustomerId,
|
||||
) -> RouterResponse<api::CustomerPaymentMethodsListResponse> {
|
||||
let customer_payment_methods =
|
||||
list_customer_payment_method_core(&state, &merchant_account, &key_store, &customer_id)
|
||||
.await?;
|
||||
|
||||
Ok(hyperswitch_domain_models::api::ApplicationResponse::Json(
|
||||
customer_payment_methods,
|
||||
))
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
/// Container for the inputs required for the required fields
|
||||
struct RequiredFieldsInput {
|
||||
@ -1641,11 +1658,7 @@ fn get_pm_list_context(
|
||||
Ok(payment_method_retrieval_context)
|
||||
}
|
||||
|
||||
#[cfg(all(
|
||||
feature = "v2",
|
||||
feature = "payment_methods_v2",
|
||||
feature = "customer_v2"
|
||||
))]
|
||||
#[cfg(all(feature = "v2", feature = "olap"))]
|
||||
pub async fn list_customer_payment_method_core(
|
||||
state: &SessionState,
|
||||
merchant_account: &domain::MerchantAccount,
|
||||
|
||||
@ -1038,6 +1038,10 @@ impl Customers {
|
||||
.route(web::get().to(customers::customers_retrieve))
|
||||
.route(web::delete().to(customers::customers_delete)),
|
||||
)
|
||||
.service(
|
||||
web::resource("/{id}/saved-payment-methods")
|
||||
.route(web::get().to(payment_methods::list_customer_payment_method_api)),
|
||||
)
|
||||
}
|
||||
route
|
||||
}
|
||||
|
||||
@ -581,6 +581,43 @@ pub async fn initiate_pm_collect_link_flow(
|
||||
.await
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "v2", feature = "olap"))]
|
||||
#[instrument(skip_all, fields(flow = ?Flow::CustomerPaymentMethodsList))]
|
||||
pub async fn list_customer_payment_method_api(
|
||||
state: web::Data<AppState>,
|
||||
customer_id: web::Path<id_type::GlobalCustomerId>,
|
||||
req: HttpRequest,
|
||||
query_payload: web::Query<api_models::payment_methods::PaymentMethodListRequest>,
|
||||
) -> HttpResponse {
|
||||
let flow = Flow::CustomerPaymentMethodsList;
|
||||
let payload = query_payload.into_inner();
|
||||
let customer_id = customer_id.into_inner();
|
||||
|
||||
Box::pin(api::server_wrap(
|
||||
flow,
|
||||
state,
|
||||
&req,
|
||||
payload,
|
||||
|state, auth: auth::AuthenticationData, _, _| {
|
||||
payment_methods_routes::list_saved_payment_methods_for_customer(
|
||||
state,
|
||||
auth.merchant_account,
|
||||
auth.key_store,
|
||||
customer_id.clone(),
|
||||
)
|
||||
},
|
||||
auth::auth_type(
|
||||
&auth::HeaderAuth(auth::ApiKeyAuth),
|
||||
&auth::JWTAuth {
|
||||
permission: Permission::MerchantCustomerRead,
|
||||
},
|
||||
req.headers(),
|
||||
),
|
||||
api_locking::LockAction::NotApplicable,
|
||||
))
|
||||
.await
|
||||
}
|
||||
|
||||
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
|
||||
/// Generate a form link for collecting payment methods for a customer
|
||||
#[instrument(skip_all, fields(flow = ?Flow::PaymentMethodCollectLink))]
|
||||
|
||||
Reference in New Issue
Block a user