fix(router): remove attempt_count in payments list response and add it in payments response (#2008)

This commit is contained in:
Sai Harsha Vardhan
2023-08-28 23:47:51 +05:30
committed by GitHub
parent aeebc5b525
commit 23b8d3412c
4 changed files with 13 additions and 18 deletions

View File

@ -1905,6 +1905,9 @@ pub struct PaymentsResponse {
/// The business profile that is associated with this payment
pub profile_id: Option<String>,
/// total number of attempts associated with this payment
pub attempt_count: i16,
}
#[derive(Clone, Debug, serde::Deserialize, ToSchema)]
@ -1970,8 +1973,6 @@ pub struct PaymentListConstraints {
pub struct PaymentListResponse {
/// The number of payments included in the list
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
pub data: Vec<PaymentsResponse>,
}

View File

@ -1262,11 +1262,6 @@ pub async fn list_payments(
.await
.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| {
async {
match db
@ -1314,7 +1309,6 @@ pub async fn list_payments(
Ok(services::ApplicationResponse::Json(
api::PaymentListResponse {
size: data.len(),
attempt_count,
data,
},
))
@ -1341,15 +1335,12 @@ pub async fn apply_filters_on_payments(
.map(|(pi, pa)| (pi, pa.to_storage_model()))
.collect();
let attempt_count = list.iter().map(|item| item.0.attempt_count).sum();
let data: Vec<api::PaymentsResponse> =
list.into_iter().map(ForeignFrom::foreign_from).collect();
Ok(services::ApplicationResponse::Json(
api::PaymentListResponse {
size: data.len(),
attempt_count,
data,
},
))

View File

@ -601,6 +601,7 @@ where
.set_connector_metadata(payment_intent.connector_metadata)
.set_reference_id(payment_attempt.connector_response_reference_id)
.set_profile_id(payment_intent.profile_id)
.set_attempt_count(payment_intent.attempt_count)
.to_owned(),
headers,
))
@ -658,6 +659,7 @@ where
connector_metadata: payment_intent.connector_metadata,
allowed_payment_method_types: payment_intent.allowed_payment_method_types,
reference_id: payment_attempt.connector_response_reference_id,
attempt_count: payment_intent.attempt_count,
..Default::default()
},
headers,
@ -761,6 +763,7 @@ impl ForeignFrom<(storage::PaymentIntent, storage::PaymentAttempt)> for api::Pay
capture_method: pa.capture_method,
authentication_type: pa.authentication_type,
connector_transaction_id: pa.connector_transaction_id,
attempt_count: pi.attempt_count,
..Default::default()
}
}

View File

@ -7708,7 +7708,6 @@
"type": "object",
"required": [
"size",
"attempt_count",
"data"
],
"properties": {
@ -7717,11 +7716,6 @@
"description": "The number of payments included in the list",
"minimum": 0.0
},
"attempt_count": {
"type": "integer",
"format": "int32",
"description": "The total number of payment_attempts for intents included in the list"
},
"data": {
"type": "array",
"items": {
@ -9028,7 +9022,8 @@
"currency",
"payment_method",
"business_country",
"business_label"
"business_label",
"attempt_count"
],
"properties": {
"payment_id": {
@ -9398,6 +9393,11 @@
"type": "string",
"description": "The business profile that is associated with this payment",
"nullable": true
},
"attempt_count": {
"type": "integer",
"format": "int32",
"description": "total number of attempts associated with this payment"
}
}
},