mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-28 12:15:40 +08:00
feat(payments_v2): implement payments capture v2 (#6722)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -11,7 +11,7 @@ use super::{
|
||||
))]
|
||||
use crate::payment_methods::CustomerPaymentMethodsListResponse;
|
||||
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
|
||||
use crate::payment_methods::CustomerPaymentMethodsListResponse;
|
||||
use crate::{events, payment_methods::CustomerPaymentMethodsListResponse};
|
||||
use crate::{
|
||||
payment_methods::{
|
||||
CustomerDefaultPaymentMethodResponse, DefaultPaymentMethod, ListCountriesCurrenciesRequest,
|
||||
@ -418,3 +418,12 @@ impl ApiEventMetric for PaymentStartRedirectionRequest {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
impl ApiEventMetric for events::PaymentsCaptureResponse {
|
||||
fn get_api_event_type(&self) -> Option<ApiEventsType> {
|
||||
Some(ApiEventsType::Payment {
|
||||
payment_id: self.id.clone(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -621,7 +621,7 @@ pub struct AmountDetailsResponse {
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
#[derive(Clone, Debug, PartialEq, serde::Serialize, ToSchema)]
|
||||
pub struct ConfirmIntentAmountDetailsResponse {
|
||||
pub struct PaymentAmountDetailsResponse {
|
||||
/// 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 1 for 1¥ since ¥ is a zero-decimal currency. Read more about [the Decimal and Non-Decimal Currencies](https://github.com/juspay/hyperswitch/wiki/Decimal-and-Non%E2%80%90Decimal-Currencies)
|
||||
#[schema(value_type = u64, example = 6540)]
|
||||
#[serde(default, deserialize_with = "amount::deserialize")]
|
||||
@ -4077,6 +4077,7 @@ pub struct PhoneDetails {
|
||||
pub country_code: Option<String>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v1")]
|
||||
#[derive(Debug, Clone, Default, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)]
|
||||
pub struct PaymentsCaptureRequest {
|
||||
/// The unique identifier for the payment
|
||||
@ -4085,7 +4086,7 @@ pub struct PaymentsCaptureRequest {
|
||||
/// The unique identifier for the merchant
|
||||
#[schema(value_type = Option<String>)]
|
||||
pub merchant_id: Option<id_type::MerchantId>,
|
||||
/// The Amount to be captured/ debited from the user's payment method.
|
||||
/// The Amount to be captured/ debited from the user's payment method. If not passed the full amount will be captured.
|
||||
#[schema(value_type = i64, example = 6540)]
|
||||
pub amount_to_capture: Option<MinorUnit>,
|
||||
/// Decider to refund the uncaptured amount
|
||||
@ -4099,6 +4100,28 @@ pub struct PaymentsCaptureRequest {
|
||||
pub merchant_connector_details: Option<admin::MerchantConnectorDetailsWrap>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
#[derive(Debug, Clone, Default, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)]
|
||||
pub struct PaymentsCaptureRequest {
|
||||
/// The Amount to be captured/ debited from the user's payment method. If not passed the full amount will be captured.
|
||||
#[schema(value_type = Option<i64>, example = 6540)]
|
||||
pub amount_to_capture: Option<MinorUnit>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
#[derive(Debug, Clone, serde::Serialize, ToSchema)]
|
||||
pub struct PaymentsCaptureResponse {
|
||||
/// The unique identifier for the payment
|
||||
pub id: id_type::GlobalPaymentId,
|
||||
|
||||
/// Status of the payment
|
||||
#[schema(value_type = IntentStatus, example = "succeeded")]
|
||||
pub status: common_enums::IntentStatus,
|
||||
|
||||
/// Amount details related to the payment
|
||||
pub amount: PaymentAmountDetailsResponse,
|
||||
}
|
||||
|
||||
#[derive(Default, Clone, Debug, Eq, PartialEq, serde::Serialize)]
|
||||
pub struct UrlDetails {
|
||||
pub url: String,
|
||||
@ -4801,7 +4824,7 @@ pub struct PaymentsConfirmIntentResponse {
|
||||
pub status: api_enums::IntentStatus,
|
||||
|
||||
/// Amount related information for this payment and attempt
|
||||
pub amount: ConfirmIntentAmountDetailsResponse,
|
||||
pub amount: PaymentAmountDetailsResponse,
|
||||
|
||||
/// The identifier for the customer
|
||||
#[schema(
|
||||
@ -4879,7 +4902,7 @@ pub struct PaymentsRetrieveResponse {
|
||||
pub status: api_enums::IntentStatus,
|
||||
|
||||
/// Amount related information for this payment and attempt
|
||||
pub amount: ConfirmIntentAmountDetailsResponse,
|
||||
pub amount: PaymentAmountDetailsResponse,
|
||||
|
||||
/// The identifier for the customer
|
||||
#[schema(
|
||||
|
||||
Reference in New Issue
Block a user