mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 19:46:48 +08:00
feat(payments_v2): add payment method list endpoint (#6805)
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:
@ -676,9 +676,11 @@ pub struct MerchantConnectorCreate {
|
||||
/// Type of the Connector for the financial use case. Could range from Payments to Accounting to Banking.
|
||||
#[schema(value_type = ConnectorType, example = "payment_processor")]
|
||||
pub connector_type: api_enums::ConnectorType,
|
||||
|
||||
/// Name of the Connector
|
||||
#[schema(value_type = Connector, example = "stripe")]
|
||||
pub connector_name: api_enums::Connector,
|
||||
|
||||
/// This is an unique label you can generate and pass in order to identify this connector account on your Hyperswitch dashboard and reports, If not passed then if will take `connector_name`_`profile_name`. Eg: if your profile label is `default`, connector label can be `stripe_default`
|
||||
#[schema(example = "stripe_US_travel")]
|
||||
pub connector_label: Option<String>,
|
||||
@ -692,36 +694,8 @@ pub struct MerchantConnectorCreate {
|
||||
pub connector_account_details: Option<pii::SecretSerdeValue>,
|
||||
|
||||
/// An object containing the details about the payment methods that need to be enabled under this merchant connector account
|
||||
#[schema(example = json!([
|
||||
{
|
||||
"payment_method": "wallet",
|
||||
"payment_method_types": [
|
||||
"upi_collect",
|
||||
"upi_intent"
|
||||
],
|
||||
"payment_method_issuers": [
|
||||
"labore magna ipsum",
|
||||
"aute"
|
||||
],
|
||||
"payment_schemes": [
|
||||
"Discover",
|
||||
"Discover"
|
||||
],
|
||||
"accepted_currencies": {
|
||||
"type": "enable_only",
|
||||
"list": ["USD", "EUR"]
|
||||
},
|
||||
"accepted_countries": {
|
||||
"type": "disable_only",
|
||||
"list": ["FR", "DE","IN"]
|
||||
},
|
||||
"minimum_amount": 1,
|
||||
"maximum_amount": 68607706,
|
||||
"recurring_enabled": true,
|
||||
"installment_payment_enabled": true
|
||||
}
|
||||
]))]
|
||||
pub payment_methods_enabled: Option<Vec<PaymentMethodsEnabled>>,
|
||||
#[schema(value_type = PaymentMethodsEnabled)]
|
||||
pub payment_methods_enabled: Option<Vec<common_types::payment_methods::PaymentMethodsEnabled>>,
|
||||
|
||||
/// Webhook details of this merchant connector
|
||||
#[schema(example = json!({
|
||||
@ -1056,36 +1030,8 @@ pub struct MerchantConnectorResponse {
|
||||
pub connector_account_details: pii::SecretSerdeValue,
|
||||
|
||||
/// An object containing the details about the payment methods that need to be enabled under this merchant connector account
|
||||
#[schema(example = json!([
|
||||
{
|
||||
"payment_method": "wallet",
|
||||
"payment_method_types": [
|
||||
"upi_collect",
|
||||
"upi_intent"
|
||||
],
|
||||
"payment_method_issuers": [
|
||||
"labore magna ipsum",
|
||||
"aute"
|
||||
],
|
||||
"payment_schemes": [
|
||||
"Discover",
|
||||
"Discover"
|
||||
],
|
||||
"accepted_currencies": {
|
||||
"type": "enable_only",
|
||||
"list": ["USD", "EUR"]
|
||||
},
|
||||
"accepted_countries": {
|
||||
"type": "disable_only",
|
||||
"list": ["FR", "DE","IN"]
|
||||
},
|
||||
"minimum_amount": 1,
|
||||
"maximum_amount": 68607706,
|
||||
"recurring_enabled": true,
|
||||
"installment_payment_enabled": true
|
||||
}
|
||||
]))]
|
||||
pub payment_methods_enabled: Option<Vec<PaymentMethodsEnabled>>,
|
||||
#[schema(value_type = Vec<PaymentMethodsEnabled>)]
|
||||
pub payment_methods_enabled: Option<Vec<common_types::payment_methods::PaymentMethodsEnabled>>,
|
||||
|
||||
/// Webhook details of this merchant connector
|
||||
#[schema(example = json!({
|
||||
@ -1381,36 +1327,8 @@ pub struct MerchantConnectorListResponse {
|
||||
pub profile_id: id_type::ProfileId,
|
||||
|
||||
/// An object containing the details about the payment methods that need to be enabled under this merchant connector account
|
||||
#[schema(example = json!([
|
||||
{
|
||||
"payment_method": "wallet",
|
||||
"payment_method_types": [
|
||||
"upi_collect",
|
||||
"upi_intent"
|
||||
],
|
||||
"payment_method_issuers": [
|
||||
"labore magna ipsum",
|
||||
"aute"
|
||||
],
|
||||
"payment_schemes": [
|
||||
"Discover",
|
||||
"Discover"
|
||||
],
|
||||
"accepted_currencies": {
|
||||
"type": "enable_only",
|
||||
"list": ["USD", "EUR"]
|
||||
},
|
||||
"accepted_countries": {
|
||||
"type": "disable_only",
|
||||
"list": ["FR", "DE","IN"]
|
||||
},
|
||||
"minimum_amount": 1,
|
||||
"maximum_amount": 68607706,
|
||||
"recurring_enabled": true,
|
||||
"installment_payment_enabled": true
|
||||
}
|
||||
]))]
|
||||
pub payment_methods_enabled: Option<Vec<PaymentMethodsEnabled>>,
|
||||
#[schema(value_type = Vec<PaymentMethodsEnabled>)]
|
||||
pub payment_methods_enabled: Option<Vec<common_types::payment_methods::PaymentMethodsEnabled>>,
|
||||
|
||||
/// A boolean value to indicate if the connector is disabled. By default, its value is false.
|
||||
#[schema(default = false, example = false)]
|
||||
@ -1568,36 +1486,8 @@ pub struct MerchantConnectorUpdate {
|
||||
pub connector_account_details: Option<pii::SecretSerdeValue>,
|
||||
|
||||
/// An object containing the details about the payment methods that need to be enabled under this merchant connector account
|
||||
#[schema(example = json!([
|
||||
{
|
||||
"payment_method": "wallet",
|
||||
"payment_method_types": [
|
||||
"upi_collect",
|
||||
"upi_intent"
|
||||
],
|
||||
"payment_method_issuers": [
|
||||
"labore magna ipsum",
|
||||
"aute"
|
||||
],
|
||||
"payment_schemes": [
|
||||
"Discover",
|
||||
"Discover"
|
||||
],
|
||||
"accepted_currencies": {
|
||||
"type": "enable_only",
|
||||
"list": ["USD", "EUR"]
|
||||
},
|
||||
"accepted_countries": {
|
||||
"type": "disable_only",
|
||||
"list": ["FR", "DE","IN"]
|
||||
},
|
||||
"minimum_amount": 1,
|
||||
"maximum_amount": 68607706,
|
||||
"recurring_enabled": true,
|
||||
"installment_payment_enabled": true
|
||||
}
|
||||
]))]
|
||||
pub payment_methods_enabled: Option<Vec<PaymentMethodsEnabled>>,
|
||||
#[schema(value_type = Option<Vec<PaymentMethodsEnabled>>)]
|
||||
pub payment_methods_enabled: Option<Vec<common_types::payment_methods::PaymentMethodsEnabled>>,
|
||||
|
||||
/// Webhook details of this merchant connector
|
||||
#[schema(example = json!({
|
||||
@ -2085,6 +1975,7 @@ pub struct ProfileCreate {
|
||||
|
||||
/// Indicates if click to pay is enabled or not.
|
||||
#[schema(default = false, example = false)]
|
||||
#[serde(default)]
|
||||
pub is_click_to_pay_enabled: bool,
|
||||
|
||||
/// Product authentication ids
|
||||
|
||||
@ -420,7 +420,15 @@ impl ApiEventMetric for PaymentStartRedirectionRequest {
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
impl ApiEventMetric for events::PaymentsCaptureResponse {
|
||||
impl ApiEventMetric for payments::PaymentMethodListResponseForPayments {
|
||||
// Payment id would be populated by the request
|
||||
fn get_api_event_type(&self) -> Option<ApiEventsType> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
impl ApiEventMetric for payments::PaymentsCaptureResponse {
|
||||
fn get_api_event_type(&self) -> Option<ApiEventsType> {
|
||||
Some(ApiEventsType::Payment {
|
||||
payment_id: self.id.clone(),
|
||||
|
||||
@ -1242,36 +1242,39 @@ pub struct ResponsePaymentMethodTypes {
|
||||
pub pm_auth_connector: Option<String>,
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
|
||||
#[derive(Debug, Clone, serde::Serialize, ToSchema, PartialEq)]
|
||||
#[serde(untagged)] // Untagged used for serialization only
|
||||
pub enum PaymentMethodSubtypeSpecificData {
|
||||
Card {
|
||||
card_networks: Vec<CardNetworkTypes>,
|
||||
},
|
||||
Bank {
|
||||
bank_names: Vec<BankCodeResponse>,
|
||||
},
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
|
||||
#[derive(Debug, Clone, serde::Serialize, ToSchema, PartialEq)]
|
||||
pub struct ResponsePaymentMethodTypes {
|
||||
/// The payment method type enabled
|
||||
#[schema(example = "klarna", value_type = PaymentMethodType)]
|
||||
pub payment_method_subtype: api_enums::PaymentMethodType,
|
||||
pub payment_method_type: common_enums::PaymentMethod,
|
||||
|
||||
/// The list of payment experiences enabled, if applicable for a payment method type
|
||||
pub payment_experience: Option<Vec<PaymentExperienceTypes>>,
|
||||
/// The payment method subtype enabled
|
||||
#[schema(example = "klarna", value_type = PaymentMethodType)]
|
||||
pub payment_method_subtype: common_enums::PaymentMethodType,
|
||||
|
||||
/// The list of card networks enabled, if applicable for a payment method type
|
||||
pub card_networks: Option<Vec<CardNetworkTypes>>,
|
||||
|
||||
/// The list of banks enabled, if applicable for a payment method type
|
||||
pub bank_names: Option<Vec<BankCodeResponse>>,
|
||||
|
||||
/// The Bank debit payment method information, if applicable for a payment method type.
|
||||
pub bank_debits: Option<BankDebitTypes>,
|
||||
|
||||
/// The Bank transfer payment method information, if applicable for a payment method type.
|
||||
pub bank_transfers: Option<BankTransferTypes>,
|
||||
/// payment method subtype specific information
|
||||
#[serde(flatten)]
|
||||
pub extra_information: Option<PaymentMethodSubtypeSpecificData>,
|
||||
|
||||
/// Required fields for the payment_method_type.
|
||||
/// This is the union of all the required fields for the payment method type enabled in all the connectors.
|
||||
pub required_fields: Option<HashMap<String, RequiredFieldInfo>>,
|
||||
|
||||
/// surcharge details for this payment method type if exists
|
||||
pub surcharge_details: Option<SurchargeDetailsResponse>,
|
||||
|
||||
/// auth service connector label for this payment method type, if exists
|
||||
pub pm_auth_connector: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, serde::Serialize, ToSchema)]
|
||||
|
||||
@ -27,6 +27,8 @@ use time::{Date, PrimitiveDateTime};
|
||||
use url::Url;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
use crate::payment_methods;
|
||||
use crate::{
|
||||
admin::{self, MerchantConnectorInfo},
|
||||
disputes, enums as api_enums,
|
||||
@ -6548,6 +6550,23 @@ pub struct SdkInformation {
|
||||
pub sdk_max_timeout: u8,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
#[derive(Debug, serde::Serialize, serde::Deserialize, Clone, ToSchema)]
|
||||
pub struct PaymentMethodsListRequest {}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
#[derive(Debug, serde::Serialize, ToSchema)]
|
||||
pub struct PaymentMethodListResponseForPayments {
|
||||
/// The list of payment methods that are enabled for the business profile
|
||||
#[schema(value_type = Vec<ResponsePaymentMethodTypes>)]
|
||||
pub payment_methods_enabled: Vec<payment_methods::ResponsePaymentMethodTypes>,
|
||||
|
||||
/// The list of payment methods that are saved by the given customer
|
||||
/// This field is only returned if the customer_id is provided in the request
|
||||
#[schema(value_type = Option<Vec<CustomerPaymentMethod>>)]
|
||||
pub customer_payment_methods: Option<Vec<payment_methods::CustomerPaymentMethod>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Serialize, serde::Deserialize, Clone, ToSchema)]
|
||||
pub struct PaymentsExternalAuthenticationResponse {
|
||||
/// Indicates the transaction status
|
||||
|
||||
Reference in New Issue
Block a user