mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-31 01:57:45 +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
|
where
|
||||||
FData: MandateBehaviour,
|
FData: MandateBehaviour,
|
||||||
{
|
{
|
||||||
match resp.request.get_mandate_id() {
|
match resp.response {
|
||||||
|
Err(_) => {}
|
||||||
|
Ok(_) => match resp.request.get_mandate_id() {
|
||||||
Some(mandate_id) => {
|
Some(mandate_id) => {
|
||||||
let mandate_id = &mandate_id.mandate_id;
|
let mandate_id = &mandate_id.mandate_id;
|
||||||
let mandate = state
|
let mandate = state
|
||||||
@ -161,7 +163,8 @@ where
|
|||||||
mandate_id,
|
mandate_id,
|
||||||
storage::MandateUpdate::CaptureAmountUpdate {
|
storage::MandateUpdate::CaptureAmountUpdate {
|
||||||
amount_captured: Some(
|
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
|
.store
|
||||||
.insert_mandate(new_mandate_data)
|
.insert_mandate(new_mandate_data)
|
||||||
.await
|
.await
|
||||||
.to_duplicate_response(errors::ApiErrorResponse::DuplicateRefundRequest)?;
|
.to_duplicate_response(
|
||||||
|
errors::ApiErrorResponse::DuplicateRefundRequest,
|
||||||
|
)?;
|
||||||
metrics::MANDATE_COUNT.add(
|
metrics::MANDATE_COUNT.add(
|
||||||
&metrics::CONTEXT,
|
&metrics::CONTEXT,
|
||||||
1,
|
1,
|
||||||
@ -249,8 +254,8 @@ where
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(resp)
|
Ok(resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user