mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-03 13:30:39 +08:00
feat(payment_methods_v2): Payment methods v2 API models (#5564)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -1,5 +1,9 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[cfg(all(
|
||||
any(feature = "v1", feature = "v2"),
|
||||
not(feature = "payment_methods_v2")
|
||||
))]
|
||||
use api_models::payment_methods::PaymentMethodsData;
|
||||
use common_enums::PaymentMethod;
|
||||
use common_utils::{
|
||||
@ -54,6 +58,10 @@ impl<F, Req: Clone> From<&types::RouterData<F, Req, types::PaymentsResponseData>
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(
|
||||
any(feature = "v1", feature = "v2"),
|
||||
not(feature = "payment_methods_v2")
|
||||
))]
|
||||
#[instrument(skip_all)]
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub async fn save_payment_method<FData>(
|
||||
@ -180,14 +188,15 @@ where
|
||||
.attach_printable("Unable to serialize customer acceptance to value")?;
|
||||
|
||||
let pm_id = if customer_acceptance.is_some() {
|
||||
let payment_method_create_request = helpers::get_payment_method_create_request(
|
||||
Some(&save_payment_method_data.request.get_payment_method_data()),
|
||||
Some(save_payment_method_data.payment_method),
|
||||
payment_method_type,
|
||||
&customer_id.clone(),
|
||||
billing_name,
|
||||
)
|
||||
.await?;
|
||||
let payment_method_create_request =
|
||||
payment_methods::get_payment_method_create_request(
|
||||
Some(&save_payment_method_data.request.get_payment_method_data()),
|
||||
Some(save_payment_method_data.payment_method),
|
||||
payment_method_type,
|
||||
&customer_id.clone(),
|
||||
billing_name,
|
||||
)
|
||||
.await?;
|
||||
let customer_id = customer_id.to_owned().get_required_value("customer_id")?;
|
||||
let merchant_id = merchant_account.get_id();
|
||||
let (mut resp, duplication_check) = if !state.conf.locker.locker_enabled {
|
||||
@ -641,6 +650,35 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
// check in review
|
||||
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
|
||||
#[instrument(skip_all)]
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub async fn save_payment_method<FData>(
|
||||
_state: &SessionState,
|
||||
_connector_name: String,
|
||||
_merchant_connector_id: Option<String>,
|
||||
_save_payment_method_data: SavePaymentMethodData<FData>,
|
||||
_customer_id: Option<id_type::CustomerId>,
|
||||
_merchant_account: &domain::MerchantAccount,
|
||||
_payment_method_type: Option<storage_enums::PaymentMethodType>,
|
||||
_key_store: &domain::MerchantKeyStore,
|
||||
_amount: Option<i64>,
|
||||
_currency: Option<storage_enums::Currency>,
|
||||
_billing_name: Option<Secret<String>>,
|
||||
_payment_method_billing_address: Option<&api::Address>,
|
||||
_business_profile: &domain::BusinessProfile,
|
||||
) -> RouterResult<(Option<String>, Option<common_enums::PaymentMethodStatus>)>
|
||||
where
|
||||
FData: mandate::MandateBehaviour + Clone,
|
||||
{
|
||||
todo!()
|
||||
}
|
||||
|
||||
#[cfg(all(
|
||||
any(feature = "v1", feature = "v2"),
|
||||
not(feature = "payment_methods_v2")
|
||||
))]
|
||||
async fn skip_saving_card_in_locker(
|
||||
merchant_account: &domain::MerchantAccount,
|
||||
payment_method_request: api::PaymentMethodCreate,
|
||||
@ -729,6 +767,21 @@ async fn skip_saving_card_in_locker(
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
|
||||
async fn skip_saving_card_in_locker(
|
||||
merchant_account: &domain::MerchantAccount,
|
||||
payment_method_request: api::PaymentMethodCreate,
|
||||
) -> RouterResult<(
|
||||
api_models::payment_methods::PaymentMethodResponse,
|
||||
Option<payment_methods::transformers::DataDuplicationCheck>,
|
||||
)> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
#[cfg(all(
|
||||
any(feature = "v1", feature = "v2"),
|
||||
not(feature = "payment_methods_v2")
|
||||
))]
|
||||
pub async fn save_in_locker(
|
||||
state: &SessionState,
|
||||
merchant_account: &domain::MerchantAccount,
|
||||
@ -779,6 +832,18 @@ pub async fn save_in_locker(
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
|
||||
pub async fn save_in_locker(
|
||||
_state: &SessionState,
|
||||
_merchant_account: &domain::MerchantAccount,
|
||||
_payment_method_request: api::PaymentMethodCreate,
|
||||
) -> RouterResult<(
|
||||
api_models::payment_methods::PaymentMethodResponse,
|
||||
Option<payment_methods::transformers::DataDuplicationCheck>,
|
||||
)> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub fn create_payment_method_metadata(
|
||||
metadata: Option<&pii::SecretSerdeValue>,
|
||||
connector_token: Option<(String, String)>,
|
||||
|
||||
Reference in New Issue
Block a user