feat(payment_methods_v2): add payment methods list endpoint (#6938)

Co-authored-by: Sanchith Hegde <sanchith.hegde@juspay.in>
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Narayan Bhat
2025-01-13 15:07:19 +05:30
committed by GitHub
parent 1d993055d2
commit 6a1f5a8875
47 changed files with 1228 additions and 864 deletions

View File

@ -1,4 +1,3 @@
use common_enums::{PaymentMethod, PaymentMethodType};
use serde::Serialize;
use crate::{id_type, types::TimeRange};
@ -33,10 +32,17 @@ pub enum ApiEventsType {
payment_id: id_type::GlobalPaymentId,
refund_id: id_type::GlobalRefundId,
},
#[cfg(feature = "v1")]
PaymentMethod {
payment_method_id: String,
payment_method: Option<PaymentMethod>,
payment_method_type: Option<PaymentMethodType>,
payment_method: Option<common_enums::PaymentMethod>,
payment_method_type: Option<common_enums::PaymentMethodType>,
},
#[cfg(feature = "v2")]
PaymentMethod {
payment_method_id: id_type::GlobalPaymentMethodId,
payment_method_type: Option<common_enums::PaymentMethod>,
payment_method_subtype: Option<common_enums::PaymentMethodType>,
},
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
PaymentMethodCreate,
@ -60,6 +66,10 @@ pub enum ApiEventsType {
PaymentMethodList {
payment_id: Option<String>,
},
#[cfg(feature = "v2")]
PaymentMethodListForPaymentMethods {
payment_method_id: id_type::GlobalPaymentMethodId,
},
#[cfg(feature = "v1")]
Webhooks {
connector: String,

View File

@ -1,9 +1,8 @@
use error_stack::ResultExt;
use crate::{
errors,
errors::CustomResult,
id_type::global_id::{CellId, GlobalEntity, GlobalId, GlobalIdError},
id_type::global_id::{CellId, GlobalEntity, GlobalId},
};
/// A global id that can be used to identify a payment method
@ -26,6 +25,16 @@ pub enum GlobalPaymentMethodIdError {
ConstructionError,
}
impl crate::events::ApiEventMetric for GlobalPaymentMethodId {
fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> {
Some(
crate::events::ApiEventsType::PaymentMethodListForPaymentMethods {
payment_method_id: self.clone(),
},
)
}
}
impl GlobalPaymentMethodId {
/// Create a new GlobalPaymentMethodId from cell id information
pub fn generate(cell_id: &CellId) -> error_stack::Result<Self, GlobalPaymentMethodIdError> {