mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 17:47:54 +08:00
fix(mandate): only trigger mandate procedure on successful connector call (#1122)
This commit is contained in:
@ -134,7 +134,9 @@ pub async fn mandate_procedure<F, FData>(
|
||||
where
|
||||
FData: MandateBehaviour,
|
||||
{
|
||||
match resp.request.get_mandate_id() {
|
||||
match resp.response {
|
||||
Err(_) => {}
|
||||
Ok(_) => match resp.request.get_mandate_id() {
|
||||
Some(mandate_id) => {
|
||||
let mandate_id = &mandate_id.mandate_id;
|
||||
let mandate = state
|
||||
@ -161,7 +163,8 @@ where
|
||||
mandate_id,
|
||||
storage::MandateUpdate::CaptureAmountUpdate {
|
||||
amount_captured: Some(
|
||||
mandate.amount_captured.unwrap_or(0) + resp.request.get_amount(),
|
||||
mandate.amount_captured.unwrap_or(0)
|
||||
+ resp.request.get_amount(),
|
||||
),
|
||||
},
|
||||
)
|
||||
@ -240,7 +243,9 @@ where
|
||||
.store
|
||||
.insert_mandate(new_mandate_data)
|
||||
.await
|
||||
.to_duplicate_response(errors::ApiErrorResponse::DuplicateRefundRequest)?;
|
||||
.to_duplicate_response(
|
||||
errors::ApiErrorResponse::DuplicateRefundRequest,
|
||||
)?;
|
||||
metrics::MANDATE_COUNT.add(
|
||||
&metrics::CONTEXT,
|
||||
1,
|
||||
@ -249,8 +254,8 @@ where
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
Ok(resp)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user