docs: Update naming conventions and added examples (#709)

Co-authored-by: Narayan Bhat <narayan.bhat@juspay.in>
This commit is contained in:
Kartikeya Hegde
2023-03-06 16:53:32 +05:30
committed by GitHub
parent 45484752a2
commit 9841519324
22 changed files with 879 additions and 628 deletions

View File

@ -369,19 +369,28 @@ pub struct Card {
/// The card number
#[schema(value_type = String, example = "4242424242424242")]
pub card_number: Secret<String, pii::CardNumber>,
/// The card's expiry month
#[schema(value_type = String, example = "24")]
pub card_exp_month: Secret<String>,
/// The card's expiry year
#[schema(value_type = String, example = "24")]
pub card_exp_year: Secret<String>,
/// The card holder's name
#[schema(value_type = String, example = "John Test")]
pub card_holder_name: Secret<String>,
/// The CVC number for the card
#[schema(value_type = String, example = "242")]
pub card_cvc: Secret<String>,
/// The name of the issuer of card
#[schema(example = "chase")]
pub card_issuer: Option<String>,
/// The card network for the card
#[schema(value_type = Option<CardNetwork>, example = "Visa")]
pub card_network: Option<api_enums::CardNetwork>,
}
@ -469,7 +478,9 @@ pub enum BankRedirectData {
Eps {
/// The billing details for bank redirection
billing_details: BankRedirectBilling,
#[schema(value_type = BankNames)]
/// The hyperswitch bank code for eps
#[schema(value_type = BankNames, example = "triodos_bank")]
bank_name: api_enums::BankNames,
},
Giropay {
@ -479,13 +490,18 @@ pub enum BankRedirectData {
Ideal {
/// The billing details for bank redirection
billing_details: BankRedirectBilling,
#[schema(value_type = BankNames)]
/// The hyperswitch bank code for ideal
#[schema(value_type = BankNames, example = "abn_amro")]
bank_name: api_enums::BankNames,
},
Sofort {
/// The country for bank payment
#[schema(example = "US")]
country: String,
/// The preferred language
#[schema(example = "en")]
preferred_language: String,
},
}
@ -493,16 +509,14 @@ pub enum BankRedirectData {
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)]
pub struct SofortBilling {
/// The country associated with the billing
#[schema(example = "US")]
pub billing_country: String,
}
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)]
pub struct BankRedirectionRequest {}
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)]
pub struct BankRedirectBilling {
/// The name for which billing is issued
#[schema(value_type = String)]
#[schema(value_type = String, example = "John Doe")]
pub billing_name: Secret<String>,
}
@ -510,7 +524,7 @@ pub struct BankRedirectBilling {
#[serde(rename_all = "snake_case")]
pub enum WalletData {
/// The wallet data for Google pay
GooglePay(GpayWalletData),
GooglePay(GooglePayWalletData),
/// The wallet data for Apple pay
ApplePay(ApplePayWalletData),
/// The wallet data for Paypal
@ -520,14 +534,14 @@ pub enum WalletData {
}
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
pub struct GpayWalletData {
pub struct GooglePayWalletData {
/// The type of payment method
#[serde(rename = "type")]
pub pm_type: String,
/// User-facing message to describe the payment method that funds this transaction.
pub description: String,
/// The information of the payment method
pub info: GpayPaymentMethodInfo,
pub info: GooglePayPaymentMethodInfo,
/// The tokenization data of Google pay
pub tokenization_data: GpayTokenizationData,
}
@ -536,7 +550,7 @@ pub struct GpayWalletData {
pub struct PaypalRedirection {}
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
pub struct GpayPaymentMethodInfo {
pub struct GooglePayPaymentMethodInfo {
/// The name of the card network
pub card_network: String,
/// The details of the card
@ -770,115 +784,152 @@ pub struct PaymentsResponse {
example = "pay_mbabizu24mvu3mela5njyhpit4"
)]
pub payment_id: Option<String>,
/// This is an identifier for the merchant account. This is inferred from the API key
/// provided during the request
#[schema(max_length = 255, example = "merchant_1668273825")]
pub merchant_id: Option<String>,
/// The status of the current payment that was made
#[schema(value_type = IntentStatus, example = "failed", default = "requires_confirmation")]
pub status: api_enums::IntentStatus,
/// The payment amount. Amount for the payment in lowest denomination of the currency. (i.e) in cents for USD denomination, in paisa for INR denomination etc.,
#[schema(example = 100)]
pub amount: i64,
/// The maximum amount that could be captured from the payment
#[schema(minimum = 100, example = 6540)]
pub amount_capturable: Option<i64>,
/// The amount which is already captured from the payment
#[schema(minimum = 100, example = 6540)]
pub amount_received: Option<i64>,
/// The connector used for the payment
#[schema(example = "stripe")]
pub connector: Option<String>,
/// It's a token used for client side verification.
#[schema(value_type = Option<String>, example = "pay_U42c409qyHwOkWo3vK60_secret_el9ksDkiB8hi6j9N78yo")]
pub client_secret: Option<Secret<String>>,
/// Time when the payment was created
#[schema(example = "2022-09-10T10:11:12Z")]
#[serde(with = "common_utils::custom_serde::iso8601::option")]
pub created: Option<PrimitiveDateTime>,
/// The currency of the amount of the payment
#[schema(value_type = Currency, example = "USD")]
pub currency: String,
/// The identifier for the customer object. If not provided the customer ID will be autogenerated.
#[schema(max_length = 255, example = "cus_y3oqhf46pyzuxjbcn2giaqnb44")]
pub customer_id: Option<String>,
/// A description of the payment
#[schema(example = "It's my first payment request")]
pub description: Option<String>,
/// List of refund that happened on this intent
#[schema(value_type = Option<Vec<RefundResponse>>)]
pub refunds: Option<Vec<refunds::RefundResponse>>,
/// A unique identifier to link the payment to a mandate, can be use instead of payment_method_data
#[schema(max_length = 255, example = "mandate_iwer89rnjef349dni3")]
pub mandate_id: Option<String>,
/// Provided mandate information for creating a mandate
pub mandate_data: Option<MandateData>,
/// Indicates that you intend to make future payments with this Payments payment method. Providing this parameter will attach the payment method to the Customer, if present, after the Payment is confirmed and any required actions from the user are complete.
#[schema(value_type = Option<FutureUsage>, example = "off_session")]
pub setup_future_usage: Option<api_enums::FutureUsage>,
/// Set to true to indicate that the customer is not in your checkout flow during this payment, and therefore is unable to authenticate. This parameter is intended for scenarios where you collect card details and charge them later. This parameter can only be used with confirm=true.
#[schema(example = true)]
pub off_session: Option<bool>,
/// A timestamp (ISO 8601 code) that determines when the payment should be captured.
/// Providing this field will automatically set `capture` to true
#[schema(example = "2022-09-10T10:11:12Z")]
#[serde(with = "common_utils::custom_serde::iso8601::option")]
pub capture_on: Option<PrimitiveDateTime>,
/// This is the instruction for capture/ debit the money from the users' card. On the other hand authorization refers to blocking the amount on the users' payment method.
#[schema(value_type = Option<CaptureMethod>, example = "PaymentProcessor")]
pub capture_method: Option<api_enums::CaptureMethod>,
/// The payment method that is to be used
#[schema(value_type = PaymentMethodType, example = "bank_transfer")]
#[auth_based]
pub payment_method: Option<api_enums::PaymentMethod>,
/// The payment method information provided for making a payment
#[schema(value_type = Option<PaymentMethod>, example = "bank_transfer")]
#[auth_based]
pub payment_method_data: Option<PaymentMethodDataResponse>,
/// Provide a reference to a stored payment method
#[schema(example = "187282ab-40ef-47a9-9206-5099ba31e432")]
pub payment_token: Option<String>,
/// The shipping address for the payment
pub shipping: Option<Address>,
/// The billing address for the payment
pub billing: Option<Address>,
/// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.
#[schema(value_type = Option<Object>)]
pub metadata: Option<serde_json::Value>,
/// description: The customer's email address
#[schema(max_length = 255, value_type = Option<String>, example = "johntest@test.com")]
pub email: Option<Secret<String, pii::Email>>,
/// description: The customer's name
#[schema(value_type = Option<String>, max_length = 255, example = "John Test")]
pub name: Option<Secret<String>>,
/// The customer's phone number
#[schema(value_type = Option<String>, max_length = 255, example = "3141592653")]
pub phone: Option<Secret<String>>,
/// The URL to redirect after the completion of the operation
#[schema(example = "https://hyperswitch.io")]
pub return_url: Option<String>,
/// The transaction authentication can be set to undergo payer authentication. By default, the authentication will be marked as NO_THREE_DS
#[schema(value_type = Option<AuthenticationType>, example = "no_three_ds", default = "three_ds")]
pub authentication_type: Option<api_enums::AuthenticationType>,
/// For non-card charges, you can use this value as the complete description that appears on your customers statements. Must contain at least one letter, maximum 22 characters.
#[schema(max_length = 255, example = "Hyperswitch Router")]
pub statement_descriptor_name: Option<String>,
/// Provides information about a card payment that customers see on their statements. Concatenated with the prefix (shortened descriptor) or statement descriptor thats set on the account to form the complete statement descriptor. Maximum 255 characters for the concatenated descriptor.
#[schema(max_length = 255, example = "Payment for shoes purchase")]
pub statement_descriptor_suffix: Option<String>,
/// Additional information required for redirection
pub next_action: Option<NextAction>,
/// If the payment was cancelled the reason provided here
pub cancellation_reason: Option<String>,
/// If there was an error while calling the connectors the code is received here
#[schema(example = "E0001")]
pub error_code: Option<String>,
/// If there was an error while calling the connector the error message is received here
#[schema(example = "Failed while verifying the card")]
pub error_message: Option<String>,
/// Payment Experience for the current payment
#[schema(value_type = Option<PaymentExperience>, example = "redirect_to_url")]
pub payment_experience: Option<api_enums::PaymentExperience>,
/// Payment Method Type
#[schema(value_type = Option<PaymentMethodType>, example = "gpay")]
pub payment_method_type: Option<api_enums::PaymentMethodType>,
@ -888,30 +939,56 @@ pub struct PaymentsResponse {
#[serde(deny_unknown_fields)]
pub struct PaymentListConstraints {
/// The identifier for customer
#[schema(example = "cus_meowuwunwiuwiwqw")]
pub customer_id: Option<String>,
/// A cursor for use in pagination, fetch the next list after some object
#[schema(example = "pay_fafa124123")]
pub starting_after: Option<String>,
/// A cursor for use in pagination, fetch the previous list before some object
#[schema(example = "pay_fafa124123")]
pub ending_before: Option<String>,
/// limit on the number of objects to return
#[schema(default = 10)]
#[serde(default = "default_limit")]
pub limit: i64,
/// The time at which payment is created
#[schema(example = "2022-09-10T10:11:12Z")]
#[serde(default, with = "common_utils::custom_serde::iso8601::option")]
pub created: Option<PrimitiveDateTime>,
/// Time less than the payment created time
#[serde(default, with = "common_utils::custom_serde::iso8601::option")]
#[serde(rename = "created.lt")]
#[schema(example = "2022-09-10T10:11:12Z")]
#[serde(
default,
with = "common_utils::custom_serde::iso8601::option",
rename = "created.lt"
)]
pub created_lt: Option<PrimitiveDateTime>,
/// Time greater than the payment created time
#[serde(default, with = "common_utils::custom_serde::iso8601::option")]
#[serde(rename = "created.gt")]
#[schema(example = "2022-09-10T10:11:12Z")]
#[serde(
default,
with = "common_utils::custom_serde::iso8601::option",
rename = "created.gt"
)]
pub created_gt: Option<PrimitiveDateTime>,
/// Time less than or equals to the payment created time
#[serde(default, with = "common_utils::custom_serde::iso8601::option")]
#[serde(rename = "created.lte")]
#[schema(example = "2022-09-10T10:11:12Z")]
#[serde(
default,
with = "common_utils::custom_serde::iso8601::option",
rename = "created.lte"
)]
pub created_lte: Option<PrimitiveDateTime>,
/// Time greater than or equals to the payment created time
#[schema(example = "2022-09-10T10:11:12Z")]
#[serde(default, with = "common_utils::custom_serde::iso8601::option")]
#[serde(rename = "created.gte")]
pub created_gte: Option<PrimitiveDateTime>,