mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 00:49:42 +08:00
docs: Update naming conventions and added examples (#709)
Co-authored-by: Narayan Bhat <narayan.bhat@juspay.in>
This commit is contained in:
@ -9,7 +9,7 @@ use crate::{
|
||||
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct CreatePaymentMethod {
|
||||
pub struct PaymentMethodCreate {
|
||||
/// The type of payment method use for the payment.
|
||||
#[schema(value_type = PaymentMethodType,example = "card")]
|
||||
pub payment_method: api_enums::PaymentMethod,
|
||||
@ -49,7 +49,7 @@ pub struct CreatePaymentMethod {
|
||||
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct UpdatePaymentMethod {
|
||||
pub struct PaymentMethodUpdate {
|
||||
/// Card Details
|
||||
#[schema(example = json!({
|
||||
"card_number": "4111111145551142",
|
||||
@ -162,27 +162,49 @@ pub struct CardDetailFromLocker {
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema, PartialEq, Eq)]
|
||||
pub struct PaymentExperienceTypes {
|
||||
/// The payment experience enabled
|
||||
#[schema(value_type = Option<PaymentExperience>, example = "redirect_to_url")]
|
||||
pub payment_experience_type: api_enums::PaymentExperience,
|
||||
|
||||
/// The list of eligible connectors for a given payment experience
|
||||
#[schema(example = json!(["stripe", "adyen"]))]
|
||||
pub eligible_connectors: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema, PartialEq, Eq)]
|
||||
pub struct CardNetworkTypes {
|
||||
/// The card network enabled
|
||||
#[schema(value_type = Option<CardNetwork>, example = "Visa")]
|
||||
pub card_network: api_enums::CardNetwork,
|
||||
|
||||
/// The list of eligible connectors for a given card network
|
||||
#[schema(example = json!(["stripe", "adyen"]))]
|
||||
pub eligible_connectors: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema, PartialEq, Eq)]
|
||||
pub struct ResponsePaymentMethodTypes {
|
||||
/// The payment method type enabled
|
||||
#[schema(example = "klarna")]
|
||||
pub payment_method_type: api_enums::PaymentMethodType,
|
||||
|
||||
/// The list of payment experiences enabled, if applicable for a payment method type
|
||||
pub payment_experience: Option<Vec<PaymentExperienceTypes>>,
|
||||
|
||||
/// 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>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)]
|
||||
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize, ToSchema)]
|
||||
pub struct ResponsePaymentMethodsEnabled {
|
||||
/// The payment method enabled
|
||||
#[schema(value_type = PaymentMethod)]
|
||||
pub payment_method: api_enums::PaymentMethod,
|
||||
|
||||
/// The list of payment method types enabled for a connector account
|
||||
pub payment_method_types: Vec<ResponsePaymentMethodTypes>,
|
||||
}
|
||||
|
||||
@ -257,7 +279,7 @@ pub struct RequestPaymentMethodTypes {
|
||||
//List Payment Method
|
||||
#[derive(Debug, serde::Serialize, Default, ToSchema)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct ListPaymentMethodRequest {
|
||||
pub struct PaymentMethodListRequest {
|
||||
/// This is a 15 minute expiry token which shall be used from the client to authenticate and perform sessions from the SDK
|
||||
#[schema(max_length = 30, min_length = 30, example = "secret_k2uj3he2893ein2d")]
|
||||
pub client_secret: Option<String>,
|
||||
@ -287,7 +309,7 @@ pub struct ListPaymentMethodRequest {
|
||||
pub card_networks: Option<Vec<api_enums::CardNetwork>>,
|
||||
}
|
||||
|
||||
impl<'de> serde::Deserialize<'de> for ListPaymentMethodRequest {
|
||||
impl<'de> serde::Deserialize<'de> for PaymentMethodListRequest {
|
||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
@ -295,7 +317,7 @@ impl<'de> serde::Deserialize<'de> for ListPaymentMethodRequest {
|
||||
struct FieldVisitor;
|
||||
|
||||
impl<'de> de::Visitor<'de> for FieldVisitor {
|
||||
type Value = ListPaymentMethodRequest;
|
||||
type Value = PaymentMethodListRequest;
|
||||
|
||||
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
formatter.write_str("Failed while deserializing as map")
|
||||
@ -305,7 +327,7 @@ impl<'de> serde::Deserialize<'de> for ListPaymentMethodRequest {
|
||||
where
|
||||
A: de::MapAccess<'de>,
|
||||
{
|
||||
let mut output = ListPaymentMethodRequest::default();
|
||||
let mut output = PaymentMethodListRequest::default();
|
||||
|
||||
while let Some(key) = map.next_key()? {
|
||||
match key {
|
||||
@ -381,13 +403,13 @@ fn set_or_reject_duplicate<T, E: de::Error>(
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Serialize, ToSchema)]
|
||||
pub struct ListPaymentMethodResponse {
|
||||
pub struct PaymentMethodListResponse {
|
||||
/// Redirect URL of the merchant
|
||||
#[schema(example = "https://www.google.com")]
|
||||
pub redirect_url: Option<String>,
|
||||
|
||||
/// Information about the payment method
|
||||
#[schema(value_type = Vec<ListPaymentMethod>,example = json!(
|
||||
#[schema(value_type = Vec<PaymentMethodList>,example = json!(
|
||||
[
|
||||
{
|
||||
"payment_method": "wallet",
|
||||
@ -402,24 +424,8 @@ pub struct ListPaymentMethodResponse {
|
||||
pub payment_methods: Vec<ResponsePaymentMethodsEnabled>,
|
||||
}
|
||||
|
||||
// impl ResponsePaymentMethodTypes {
|
||||
// pub fn new(
|
||||
// pm_type: RequestPaymentMethodTypes,
|
||||
// connector: String,
|
||||
// payment_method: api_enums::PaymentMethod,
|
||||
// ) -> Self {
|
||||
// Self {
|
||||
// payment_method_type: pm_type.payment_method_type,
|
||||
// payment_experience: pm_type.payment_experience,
|
||||
// connector,
|
||||
// card_networks: pm_type.card_networks,
|
||||
// payment_method,
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
#[derive(Eq, PartialEq, Hash, Debug, serde::Deserialize, ToSchema)]
|
||||
pub struct ListPaymentMethod {
|
||||
pub struct PaymentMethodList {
|
||||
/// The type of payment method use for the payment.
|
||||
#[schema(value_type = PaymentMethod,example = "card")]
|
||||
pub payment_method: api_enums::PaymentMethod,
|
||||
@ -432,13 +438,13 @@ pub struct ListPaymentMethod {
|
||||
/// Currently if the payment method is Wallet or Paylater the relevant fields are `payment_method`
|
||||
/// and `payment_method_issuers`. Otherwise only consider
|
||||
/// `payment_method`,`payment_method_issuers`,`payment_method_types`,`payment_schemes` fields.
|
||||
impl serde::Serialize for ListPaymentMethod {
|
||||
impl serde::Serialize for PaymentMethodList {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: serde::Serializer,
|
||||
{
|
||||
use serde::ser::SerializeStruct;
|
||||
let mut state = serializer.serialize_struct("ListPaymentMethod", 4)?;
|
||||
let mut state = serializer.serialize_struct("PaymentMethodList", 4)?;
|
||||
state.serialize_field("payment_method", &self.payment_method)?;
|
||||
|
||||
state.serialize_field("payment_method_types", &self.payment_method_types)?;
|
||||
@ -448,13 +454,13 @@ impl serde::Serialize for ListPaymentMethod {
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Serialize, ToSchema)]
|
||||
pub struct ListCustomerPaymentMethodsResponse {
|
||||
pub struct CustomerPaymentMethodsListResponse {
|
||||
/// List of payment methods for customer
|
||||
pub customer_payment_methods: Vec<CustomerPaymentMethod>,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Serialize, ToSchema)]
|
||||
pub struct DeletePaymentMethodResponse {
|
||||
pub struct PaymentMethodDeleteResponse {
|
||||
/// The unique identifier of the Payment method
|
||||
#[schema(example = "card_rGK4Vi5iSW70MY7J2mIy")]
|
||||
pub payment_method_id: String,
|
||||
|
||||
Reference in New Issue
Block a user