mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 17:19:15 +08:00
fix(router): remove attempt_count in payments list response and add it in payments response (#2008)
This commit is contained in:
committed by
GitHub
parent
aeebc5b525
commit
23b8d3412c
@ -1905,6 +1905,9 @@ pub struct PaymentsResponse {
|
|||||||
|
|
||||||
/// The business profile that is associated with this payment
|
/// The business profile that is associated with this payment
|
||||||
pub profile_id: Option<String>,
|
pub profile_id: Option<String>,
|
||||||
|
|
||||||
|
/// total number of attempts associated with this payment
|
||||||
|
pub attempt_count: i16,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, serde::Deserialize, ToSchema)]
|
#[derive(Clone, Debug, serde::Deserialize, ToSchema)]
|
||||||
@ -1970,8 +1973,6 @@ pub struct PaymentListConstraints {
|
|||||||
pub struct PaymentListResponse {
|
pub struct PaymentListResponse {
|
||||||
/// The number of payments included in the list
|
/// The number of payments included in the list
|
||||||
pub size: usize,
|
pub size: usize,
|
||||||
/// The total number of payment_attempts for intents included in the list
|
|
||||||
pub attempt_count: i16,
|
|
||||||
// The list of payments response objects
|
// The list of payments response objects
|
||||||
pub data: Vec<PaymentsResponse>,
|
pub data: Vec<PaymentsResponse>,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1262,11 +1262,6 @@ pub async fn list_payments(
|
|||||||
.await
|
.await
|
||||||
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;
|
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;
|
||||||
|
|
||||||
let attempt_count = payment_intents
|
|
||||||
.iter()
|
|
||||||
.map(|intent| intent.attempt_count)
|
|
||||||
.sum();
|
|
||||||
|
|
||||||
let collected_futures = payment_intents.into_iter().map(|pi| {
|
let collected_futures = payment_intents.into_iter().map(|pi| {
|
||||||
async {
|
async {
|
||||||
match db
|
match db
|
||||||
@ -1314,7 +1309,6 @@ pub async fn list_payments(
|
|||||||
Ok(services::ApplicationResponse::Json(
|
Ok(services::ApplicationResponse::Json(
|
||||||
api::PaymentListResponse {
|
api::PaymentListResponse {
|
||||||
size: data.len(),
|
size: data.len(),
|
||||||
attempt_count,
|
|
||||||
data,
|
data,
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
@ -1341,15 +1335,12 @@ pub async fn apply_filters_on_payments(
|
|||||||
.map(|(pi, pa)| (pi, pa.to_storage_model()))
|
.map(|(pi, pa)| (pi, pa.to_storage_model()))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let attempt_count = list.iter().map(|item| item.0.attempt_count).sum();
|
|
||||||
|
|
||||||
let data: Vec<api::PaymentsResponse> =
|
let data: Vec<api::PaymentsResponse> =
|
||||||
list.into_iter().map(ForeignFrom::foreign_from).collect();
|
list.into_iter().map(ForeignFrom::foreign_from).collect();
|
||||||
|
|
||||||
Ok(services::ApplicationResponse::Json(
|
Ok(services::ApplicationResponse::Json(
|
||||||
api::PaymentListResponse {
|
api::PaymentListResponse {
|
||||||
size: data.len(),
|
size: data.len(),
|
||||||
attempt_count,
|
|
||||||
data,
|
data,
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
|
|||||||
@ -601,6 +601,7 @@ where
|
|||||||
.set_connector_metadata(payment_intent.connector_metadata)
|
.set_connector_metadata(payment_intent.connector_metadata)
|
||||||
.set_reference_id(payment_attempt.connector_response_reference_id)
|
.set_reference_id(payment_attempt.connector_response_reference_id)
|
||||||
.set_profile_id(payment_intent.profile_id)
|
.set_profile_id(payment_intent.profile_id)
|
||||||
|
.set_attempt_count(payment_intent.attempt_count)
|
||||||
.to_owned(),
|
.to_owned(),
|
||||||
headers,
|
headers,
|
||||||
))
|
))
|
||||||
@ -658,6 +659,7 @@ where
|
|||||||
connector_metadata: payment_intent.connector_metadata,
|
connector_metadata: payment_intent.connector_metadata,
|
||||||
allowed_payment_method_types: payment_intent.allowed_payment_method_types,
|
allowed_payment_method_types: payment_intent.allowed_payment_method_types,
|
||||||
reference_id: payment_attempt.connector_response_reference_id,
|
reference_id: payment_attempt.connector_response_reference_id,
|
||||||
|
attempt_count: payment_intent.attempt_count,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
headers,
|
headers,
|
||||||
@ -761,6 +763,7 @@ impl ForeignFrom<(storage::PaymentIntent, storage::PaymentAttempt)> for api::Pay
|
|||||||
capture_method: pa.capture_method,
|
capture_method: pa.capture_method,
|
||||||
authentication_type: pa.authentication_type,
|
authentication_type: pa.authentication_type,
|
||||||
connector_transaction_id: pa.connector_transaction_id,
|
connector_transaction_id: pa.connector_transaction_id,
|
||||||
|
attempt_count: pi.attempt_count,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7708,7 +7708,6 @@
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
"size",
|
"size",
|
||||||
"attempt_count",
|
|
||||||
"data"
|
"data"
|
||||||
],
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -7717,11 +7716,6 @@
|
|||||||
"description": "The number of payments included in the list",
|
"description": "The number of payments included in the list",
|
||||||
"minimum": 0.0
|
"minimum": 0.0
|
||||||
},
|
},
|
||||||
"attempt_count": {
|
|
||||||
"type": "integer",
|
|
||||||
"format": "int32",
|
|
||||||
"description": "The total number of payment_attempts for intents included in the list"
|
|
||||||
},
|
|
||||||
"data": {
|
"data": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
@ -9028,7 +9022,8 @@
|
|||||||
"currency",
|
"currency",
|
||||||
"payment_method",
|
"payment_method",
|
||||||
"business_country",
|
"business_country",
|
||||||
"business_label"
|
"business_label",
|
||||||
|
"attempt_count"
|
||||||
],
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"payment_id": {
|
"payment_id": {
|
||||||
@ -9398,6 +9393,11 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "The business profile that is associated with this payment",
|
"description": "The business profile that is associated with this payment",
|
||||||
"nullable": true
|
"nullable": true
|
||||||
|
},
|
||||||
|
"attempt_count": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int32",
|
||||||
|
"description": "total number of attempts associated with this payment"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user