feat(core): Add authorized_amount in payment_attempt to support partial authorization for manual_multiple capture (#9594)

Co-authored-by: Vani Gupta <vani.gupta@juspay.in>
This commit is contained in:
Vani Gupta
2025-10-01 14:28:18 +05:30
committed by GitHub
parent daad946eb5
commit 8e62824b03
37 changed files with 156 additions and 2 deletions

View File

@ -210,6 +210,7 @@ pub fn construct_router_data<F: Clone, Req, Res>(
is_payment_id_from_merchant: None,
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
})
}

View File

@ -162,6 +162,7 @@ impl ConstructFlowSpecificData<frm_api::Checkout, FraudCheckCheckoutData, FraudC
is_payment_id_from_merchant: None,
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
};
Ok(router_data)

View File

@ -136,6 +136,7 @@ pub async fn construct_fulfillment_router_data<'a>(
is_payment_id_from_merchant: None,
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
};
Ok(router_data)
}

View File

@ -133,6 +133,7 @@ impl ConstructFlowSpecificData<RecordReturn, FraudCheckRecordReturnData, FraudCh
is_payment_id_from_merchant: None,
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
};
Ok(router_data)

View File

@ -141,6 +141,7 @@ impl ConstructFlowSpecificData<frm_api::Sale, FraudCheckSaleData, FraudCheckResp
is_payment_id_from_merchant: None,
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
};
Ok(router_data)

View File

@ -150,6 +150,7 @@ impl
is_payment_id_from_merchant: None,
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
};
Ok(router_data)

View File

@ -89,6 +89,7 @@ pub async fn construct_mandate_revoke_router_data(
is_payment_id_from_merchant: None,
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
};
Ok(router_data)

View File

@ -3831,6 +3831,7 @@ async fn create_single_use_tokenization_flow(
is_payment_id_from_merchant: None,
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
};
let payment_method_token_response = Box::pin(tokenization::add_token_for_payment_method(

View File

@ -4545,6 +4545,7 @@ pub fn router_data_type_conversion<F1, F2, Req1, Req2, Res1, Res2>(
is_payment_id_from_merchant: router_data.is_payment_id_from_merchant,
l2_l3_data: router_data.l2_l3_data,
minor_amount_capturable: router_data.minor_amount_capturable,
authorized_amount: router_data.authorized_amount,
}
}
@ -4805,6 +4806,7 @@ impl AttemptType {
network_transaction_id: None,
network_details: None,
is_stored_credential: old_payment_attempt.is_stored_credential,
authorized_amount: old_payment_attempt.authorized_amount,
}
}

View File

@ -1415,7 +1415,8 @@ impl PaymentCreate {
connector_request_reference_id: None,
network_transaction_id:None,
network_details:None,
is_stored_credential
is_stored_credential,
authorized_amount: None,
},
additional_pm_data,

View File

@ -1939,6 +1939,7 @@ async fn payment_response_update_tracker<F: Clone, T: types::Capturable>(
debit_routing_savings,
network_transaction_id: resp_network_transaction_id,
is_overcapture_enabled,
authorized_amount: router_data.authorized_amount,
}),
),
};
@ -2031,7 +2032,10 @@ async fn payment_response_update_tracker<F: Clone, T: types::Capturable>(
multiple_capture_data.update_capture(updated_capture);
}
let authorized_amount = payment_data.payment_attempt.get_total_amount();
let authorized_amount = payment_data
.payment_attempt
.authorized_amount
.unwrap_or_else(|| payment_data.payment_attempt.get_total_amount());
payment_attempt_update = Some(storage::PaymentAttemptUpdate::AmountToCaptureUpdate {
status: multiple_capture_data.get_attempt_status(authorized_amount),

View File

@ -547,6 +547,7 @@ where
.network_transaction_id
.clone(),
is_overcapture_enabled: None,
authorized_amount: router_data.authorized_amount,
};
#[cfg(feature = "v1")]
@ -749,6 +750,7 @@ pub fn make_new_payment_attempt(
network_transaction_id: old_payment_attempt.network_transaction_id,
network_details: Default::default(),
is_stored_credential: old_payment_attempt.is_stored_credential,
authorized_amount: old_payment_attempt.authorized_amount,
}
}

View File

@ -187,6 +187,7 @@ where
is_payment_id_from_merchant: payment_data.payment_intent.is_payment_id_from_merchant,
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
};
Ok(router_data)
}
@ -521,6 +522,7 @@ pub async fn construct_payment_router_data_for_authorize<'a>(
is_payment_id_from_merchant: payment_data.payment_intent.is_payment_id_from_merchant,
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
};
Ok(router_data)
@ -865,6 +867,7 @@ pub async fn construct_payment_router_data_for_capture<'a>(
is_payment_id_from_merchant: None,
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
};
Ok(router_data)
@ -996,6 +999,7 @@ pub async fn construct_router_data_for_psync<'a>(
is_payment_id_from_merchant: None,
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
};
Ok(router_data)
@ -1348,6 +1352,7 @@ pub async fn construct_payment_router_data_for_sdk_session<'a>(
is_payment_id_from_merchant: None,
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
};
Ok(router_data)
@ -1574,6 +1579,7 @@ pub async fn construct_payment_router_data_for_setup_mandate<'a>(
is_payment_id_from_merchant: None,
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
};
Ok(router_data)
@ -1846,6 +1852,7 @@ where
is_payment_id_from_merchant: payment_data.payment_intent.is_payment_id_from_merchant,
l2_l3_data,
minor_amount_capturable: None,
authorized_amount: None,
};
Ok(router_data)
@ -2042,6 +2049,7 @@ pub async fn construct_payment_router_data_for_update_metadata<'a>(
is_payment_id_from_merchant: payment_data.payment_intent.is_payment_id_from_merchant,
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
};
Ok(router_data)

View File

@ -147,6 +147,7 @@ pub async fn construct_relay_refund_router_data<F>(
is_payment_id_from_merchant: None,
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
};
Ok(router_data)

View File

@ -130,6 +130,7 @@ pub fn construct_uas_router_data<F: Clone, Req, Res>(
is_payment_id_from_merchant: None,
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
})
}

View File

@ -231,6 +231,7 @@ pub async fn construct_payout_router_data<'a, F>(
is_payment_id_from_merchant: None,
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
};
Ok(router_data)
@ -405,6 +406,7 @@ pub async fn construct_refund_router_data<'a, F>(
is_payment_id_from_merchant: None,
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
};
Ok(router_data)
@ -611,6 +613,7 @@ pub async fn construct_refund_router_data<'a, F>(
is_payment_id_from_merchant: None,
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
};
Ok(router_data)
@ -1054,6 +1057,7 @@ pub async fn construct_accept_dispute_router_data<'a>(
is_payment_id_from_merchant: None,
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
};
Ok(router_data)
}
@ -1157,6 +1161,7 @@ pub async fn construct_submit_evidence_router_data<'a>(
is_payment_id_from_merchant: None,
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
};
Ok(router_data)
}
@ -1269,6 +1274,7 @@ pub async fn construct_upload_file_router_data<'a>(
is_payment_id_from_merchant: None,
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
};
Ok(router_data)
}
@ -1342,6 +1348,7 @@ pub async fn construct_dispute_list_router_data<'a>(
is_payment_id_from_merchant: None,
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
})
}
@ -1447,6 +1454,7 @@ pub async fn construct_dispute_sync_router_data<'a>(
is_payment_id_from_merchant: None,
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
};
Ok(router_data)
}
@ -1575,6 +1583,7 @@ pub async fn construct_payments_dynamic_tax_calculation_router_data<F: Clone>(
is_payment_id_from_merchant: None,
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
};
Ok(router_data)
}
@ -1681,6 +1690,7 @@ pub async fn construct_defend_dispute_router_data<'a>(
is_payment_id_from_merchant: None,
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
};
Ok(router_data)
}
@ -1781,6 +1791,7 @@ pub async fn construct_retrieve_file_router_data<'a>(
is_payment_id_from_merchant: None,
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
};
Ok(router_data)
}

View File

@ -143,6 +143,7 @@ pub async fn construct_webhook_router_data(
is_payment_id_from_merchant: None,
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
};
Ok(router_data)
}

View File

@ -281,6 +281,7 @@ impl<'a> KafkaPaymentAttempt<'a> {
created_by,
connector_request_reference_id,
network_transaction_id: _,
authorized_amount: _,
} = attempt;
let (connector_payment_id, connector_payment_data) = connector_payment_id

View File

@ -283,6 +283,7 @@ impl<'a> KafkaPaymentAttemptEvent<'a> {
created_by,
connector_request_reference_id,
network_transaction_id: _,
authorized_amount: _,
} = attempt;
let (connector_payment_id, connector_payment_data) = connector_payment_id

View File

@ -1308,6 +1308,7 @@ impl<F1, F2, T1, T2> ForeignFrom<(&RouterData<F1, T1, PaymentsResponseData>, T2)
is_payment_id_from_merchant: data.is_payment_id_from_merchant,
l2_l3_data: data.l2_l3_data.clone(),
minor_amount_capturable: data.minor_amount_capturable,
authorized_amount: data.authorized_amount,
}
}
}
@ -1379,6 +1380,7 @@ impl<F1, F2>
is_payment_id_from_merchant: data.is_payment_id_from_merchant,
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
}
}
}

View File

@ -136,6 +136,7 @@ impl VerifyConnectorData {
is_payment_id_from_merchant: None,
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
}
}
}

View File

@ -230,6 +230,7 @@ mod tests {
network_transaction_id: Default::default(),
network_details: Default::default(),
is_stored_credential: None,
authorized_amount: Default::default(),
};
let store = state
@ -325,6 +326,7 @@ mod tests {
network_transaction_id: Default::default(),
network_details: Default::default(),
is_stored_credential: Default::default(),
authorized_amount: Default::default(),
};
let store = state
.stores
@ -433,6 +435,7 @@ mod tests {
network_transaction_id: Default::default(),
network_details: Default::default(),
is_stored_credential: Default::default(),
authorized_amount: Default::default(),
};
let store = state
.stores

View File

@ -395,6 +395,7 @@ pub async fn generate_sample_data(
network_transaction_id: None,
network_details: None,
is_stored_credential: None,
authorized_amount: None,
};
let refund = if refunds_count < number_of_refunds && !is_failed_payment {