Skip to content

Commit

Permalink
chore: add extra data
Browse files Browse the repository at this point in the history
  • Loading branch information
Narayanbhat166 committed Dec 18, 2023
1 parent 7f42c46 commit 45b6d4d
Show file tree
Hide file tree
Showing 5 changed files with 393 additions and 47 deletions.
1 change: 1 addition & 0 deletions crates/api_models/src/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,7 @@ pub enum AcceptedCurrencies {
content = "list",
rename_all = "snake_case"
)]
/// Object to filter the customer countries for which the payment method is displayed
pub enum AcceptedCountries {
#[schema(value_type = Vec<CountryAlpha2>)]
EnableOnly(Vec<api_enums::CountryAlpha2>),
Expand Down
11 changes: 9 additions & 2 deletions crates/api_models/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub struct CustomerDetails {
ToSchema,
router_derive::PolymorphicSchema,
)]
#[generate_schemas(PaymentsCreateRequest, PaymentsUpdateRequest)]
#[generate_schemas(PaymentsCreateRequest, PaymentsUpdateRequest, PaymentsConfirmRequest)]
#[serde(deny_unknown_fields)]
pub struct PaymentsRequest {
/// The payment amount. Amount for the payment in the lowest denomination of the currency. (i.e) in cents for USD denomination, in yen for JPY denomination etc. E.g., Pass 100 to charge $1.00 and ¥100 since ¥ is a zero-decimal currency
Expand Down Expand Up @@ -237,6 +237,7 @@ pub struct PaymentsRequest {

/// A unique identifier to link the payment to a mandate. To do Recurring payments after a mandate has been created, pass the mandate_id instead of payment_method_data
#[schema(max_length = 255, example = "mandate_iwer89rnjef349dni3")]
#[remove_in(PaymentsUpdateRequest)]
pub mandate_id: Option<String>,

/// Additional details required by 3DS 2.0
Expand Down Expand Up @@ -264,11 +265,13 @@ pub struct PaymentsRequest {
/// Business country of the merchant for this payment.
/// To be deprecated soon. Pass the profile_id instead
#[schema(value_type = Option<CountryAlpha2>, example = "US")]
#[remove_in(PaymentsUpdateRequest, PaymentsConfirmRequest)]
pub business_country: Option<api_enums::CountryAlpha2>,

/// Business label of the merchant for this payment.
/// To be deprecated soon. Pass the profile_id instead
#[schema(example = "food")]
#[remove_in(PaymentsUpdateRequest, PaymentsConfirmRequest)]
pub business_label: Option<String>,

/// Merchant connector details used to make payments.
Expand All @@ -280,6 +283,7 @@ pub struct PaymentsRequest {
pub allowed_payment_method_types: Option<Vec<api_enums::PaymentMethodType>>,

/// Business sub label for the payment
#[remove_in(PaymentsUpdateRequest, PaymentsConfirmRequest, PaymentsCreateRequest)]
pub business_sub_label: Option<String>,

/// Denotes the retry action
Expand All @@ -300,9 +304,11 @@ pub struct PaymentsRequest {

/// The business profile to use for this payment, if not passed the default business profile
/// associated with the merchant account will be used.
#[remove_in(PaymentsUpdateRequest, PaymentsConfirmRequest)]
pub profile_id: Option<String>,

/// surcharge_details for this payment
#[remove_in(PaymentsConfirmRequest)]
#[schema(value_type = Option<RequestSurchargeDetails>)]
pub surcharge_details: Option<RequestSurchargeDetails>,

Expand Down Expand Up @@ -688,6 +694,7 @@ pub struct CustomerAcceptance {

#[derive(Default, Debug, serde::Deserialize, serde::Serialize, PartialEq, Eq, Clone, ToSchema)]
#[serde(rename_all = "lowercase")]
/// This is used to indicate if the mandate was accepted online or offline
pub enum AcceptanceType {
Online,
#[default]
Expand Down Expand Up @@ -3118,7 +3125,7 @@ pub struct PaymentsCancelRequest {
/// The reason for the payment cancel
pub cancellation_reason: Option<String>,
/// Merchant connector details used to make payments.
#[schema(value_type = MerchantConnectorDetailsWrap)]
#[schema(value_type = Option<MerchantConnectorDetailsWrap>)]
pub merchant_connector_details: Option<admin::MerchantConnectorDetailsWrap>,
}

Expand Down
1 change: 1 addition & 0 deletions crates/openapi/src/openapi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::payments::PaymentsRequest,
api_models::payments::PaymentsCreateRequest,
api_models::payments::PaymentsUpdateRequest,
api_models::payments::PaymentsConfirmRequest,
api_models::payments::PaymentsResponse,
api_models::payments::PaymentsStartRequest,
api_models::payments::PaymentRetrieveBody,
Expand Down
20 changes: 17 additions & 3 deletions crates/openapi/src/routes/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ pub fn payments_update() {}
("payment_id" = String, Path, description = "The identifier for payment")
),
request_body(
content = PaymentsRequest,
content = PaymentsConfirmRequest,
examples(
(
"Confirm a payment with payment method data" = (
Expand Down Expand Up @@ -320,7 +320,21 @@ pub fn payments_confirm() {}
params(
("payment_id" = String, Path, description = "The identifier for payment")
),
request_body=PaymentsCaptureRequest,
request_body (
content = PaymentsCaptureRequest,
examples(
(
"Capture the full amount" = (
value = json!({})
)
),
(
"Capture partial amount" = (
value = json!({"amount_to_capture": 654})
)
),
)
),
responses(
(status = 200, description = "Payment captured", body = PaymentsResponse),
(status = 400, description = "Missing mandatory fields")
Expand All @@ -333,7 +347,7 @@ pub fn payments_capture() {}

/// Payments - Session token
///
/// To create the session object or to get *session token* for wallets
/// Creates a session object or a session token for wallets like Apple Pay, Google Pay, etc. These tokens are used by Hyperswitch's SDK to initiate these wallets' SDK.
#[utoipa::path(
post,
path = "/payments/session_tokens",
Expand Down
Loading

0 comments on commit 45b6d4d

Please sign in to comment.