mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 09:07:09 +08:00
feat(router): add payments incremental authorization api (#3038)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
9274cefbdd
commit
a0cfdd3fb1
@ -8,8 +8,9 @@ use crate::{
|
||||
payments::{
|
||||
PaymentIdType, PaymentListConstraints, PaymentListFilterConstraints, PaymentListFilters,
|
||||
PaymentListResponse, PaymentListResponseV2, PaymentsApproveRequest, PaymentsCancelRequest,
|
||||
PaymentsCaptureRequest, PaymentsRejectRequest, PaymentsRequest, PaymentsResponse,
|
||||
PaymentsRetrieveRequest, PaymentsStartRequest, RedirectionResponse,
|
||||
PaymentsCaptureRequest, PaymentsIncrementalAuthorizationRequest, PaymentsRejectRequest,
|
||||
PaymentsRequest, PaymentsResponse, PaymentsRetrieveRequest, PaymentsStartRequest,
|
||||
RedirectionResponse,
|
||||
},
|
||||
};
|
||||
impl ApiEventMetric for PaymentsRetrieveRequest {
|
||||
@ -149,3 +150,11 @@ impl ApiEventMetric for PaymentListResponseV2 {
|
||||
}
|
||||
|
||||
impl ApiEventMetric for RedirectionResponse {}
|
||||
|
||||
impl ApiEventMetric for PaymentsIncrementalAuthorizationRequest {
|
||||
fn get_api_event_type(&self) -> Option<ApiEventsType> {
|
||||
Some(ApiEventsType::Payment {
|
||||
payment_id: self.payment_id.clone(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -2209,6 +2209,12 @@ pub struct PaymentsResponse {
|
||||
|
||||
/// If true incremental authorization can be performed on this payment
|
||||
pub incremental_authorization_allowed: Option<bool>,
|
||||
|
||||
/// Total number of authorizations happened in an incremental_authorization payment
|
||||
pub authorization_count: Option<i32>,
|
||||
|
||||
/// List of incremental authorizations happened to the payment
|
||||
pub incremental_authorizations: Option<Vec<IncrementalAuthorizationResponse>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, serde::Deserialize, ToSchema, serde::Serialize)]
|
||||
@ -2277,6 +2283,24 @@ pub struct PaymentListResponse {
|
||||
// The list of payments response objects
|
||||
pub data: Vec<PaymentsResponse>,
|
||||
}
|
||||
|
||||
#[derive(Setter, Clone, Default, Debug, PartialEq, serde::Serialize, ToSchema)]
|
||||
pub struct IncrementalAuthorizationResponse {
|
||||
/// The unique identifier of authorization
|
||||
pub authorization_id: String,
|
||||
/// Amount the authorization has been made for
|
||||
pub amount: i64,
|
||||
#[schema(value_type= AuthorizationStatus)]
|
||||
/// The status of the authorization
|
||||
pub status: common_enums::AuthorizationStatus,
|
||||
/// Error code sent by the connector for authorization
|
||||
pub error_code: Option<String>,
|
||||
/// Error message sent by the connector for authorization
|
||||
pub error_message: Option<String>,
|
||||
/// Previously authorized amount for the payment
|
||||
pub previously_authorized_amount: i64,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, serde::Serialize)]
|
||||
pub struct PaymentListResponseV2 {
|
||||
/// The number of payments included in the list for given constraints
|
||||
@ -2985,6 +3009,18 @@ pub struct PaymentsCancelRequest {
|
||||
pub merchant_connector_details: Option<admin::MerchantConnectorDetailsWrap>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, serde::Serialize, serde::Deserialize, Clone, ToSchema)]
|
||||
pub struct PaymentsIncrementalAuthorizationRequest {
|
||||
/// The identifier for the payment
|
||||
#[serde(skip)]
|
||||
pub payment_id: String,
|
||||
/// The total amount including previously authorized amount and additional amount
|
||||
#[schema(value_type = i64, example = 6540)]
|
||||
pub amount: i64,
|
||||
/// Reason for incremental authorization
|
||||
pub reason: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema)]
|
||||
pub struct PaymentsApproveRequest {
|
||||
/// The identifier for the payment
|
||||
|
||||
Reference in New Issue
Block a user