mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-01 19:42:27 +08:00
fix(connector): [Trustpay] add reason to all the error responses (#1482)
This commit is contained in:
committed by
GitHub
parent
8198559966
commit
1d216db5ce
@ -113,7 +113,7 @@ impl ConnectorCommon for Trustpay {
|
|||||||
status_code: res.status_code,
|
status_code: res.status_code,
|
||||||
code: response.status.to_string(),
|
code: response.status.to_string(),
|
||||||
message: format!("{:?}", response.errors.first().unwrap_or(&default_error)),
|
message: format!("{:?}", response.errors.first().unwrap_or(&default_error)),
|
||||||
reason: None,
|
reason: Some(format!("{:?}", response.errors)),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -242,8 +242,12 @@ impl ConnectorIntegration<api::AccessTokenAuth, types::AccessTokenRequestData, t
|
|||||||
Ok(ErrorResponse {
|
Ok(ErrorResponse {
|
||||||
status_code: res.status_code,
|
status_code: res.status_code,
|
||||||
code: response.result_info.result_code.to_string(),
|
code: response.result_info.result_code.to_string(),
|
||||||
message: response.result_info.additional_info.unwrap_or_default(),
|
message: response
|
||||||
reason: None,
|
.result_info
|
||||||
|
.additional_info
|
||||||
|
.clone()
|
||||||
|
.unwrap_or_default(),
|
||||||
|
reason: response.result_info.additional_info,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -314,8 +318,8 @@ impl ConnectorIntegration<api::PSync, types::PaymentsSyncData, types::PaymentsRe
|
|||||||
Ok(ErrorResponse {
|
Ok(ErrorResponse {
|
||||||
status_code: res.status_code,
|
status_code: res.status_code,
|
||||||
code: response.status.to_string(),
|
code: response.status.to_string(),
|
||||||
message: response.payment_description,
|
message: response.payment_description.clone(),
|
||||||
reason: None,
|
reason: Some(response.payment_description),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -577,8 +577,10 @@ fn handle_cards_response(
|
|||||||
code: response
|
code: response
|
||||||
.payment_status
|
.payment_status
|
||||||
.unwrap_or_else(|| consts::NO_ERROR_CODE.to_string()),
|
.unwrap_or_else(|| consts::NO_ERROR_CODE.to_string()),
|
||||||
message: msg.unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()),
|
message: msg
|
||||||
reason: None,
|
.clone()
|
||||||
|
.unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()),
|
||||||
|
reason: msg,
|
||||||
status_code,
|
status_code,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@ -638,8 +640,9 @@ fn handle_bank_redirects_error_response(
|
|||||||
message: response
|
message: response
|
||||||
.payment_result_info
|
.payment_result_info
|
||||||
.additional_info
|
.additional_info
|
||||||
|
.clone()
|
||||||
.unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()),
|
.unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()),
|
||||||
reason: None,
|
reason: response.payment_result_info.additional_info,
|
||||||
status_code,
|
status_code,
|
||||||
});
|
});
|
||||||
let payment_response_data = types::PaymentsResponseData::TransactionResponse {
|
let payment_response_data = types::PaymentsResponseData::TransactionResponse {
|
||||||
@ -674,8 +677,9 @@ fn handle_bank_redirects_sync_response(
|
|||||||
message: reason_info
|
message: reason_info
|
||||||
.reason
|
.reason
|
||||||
.reject_reason
|
.reject_reason
|
||||||
|
.clone()
|
||||||
.unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()),
|
.unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()),
|
||||||
reason: None,
|
reason: reason_info.reason.reject_reason,
|
||||||
status_code,
|
status_code,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@ -801,8 +805,9 @@ impl<F, T> TryFrom<types::ResponseRouterData<F, TrustpayAuthUpdateResponse, T, t
|
|||||||
.response
|
.response
|
||||||
.result_info
|
.result_info
|
||||||
.additional_info
|
.additional_info
|
||||||
|
.clone()
|
||||||
.unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()),
|
.unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()),
|
||||||
reason: None,
|
reason: item.response.result_info.additional_info,
|
||||||
status_code: item.http_code,
|
status_code: item.http_code,
|
||||||
}),
|
}),
|
||||||
..item.data
|
..item.data
|
||||||
@ -1069,8 +1074,10 @@ fn handle_cards_refund_response(
|
|||||||
let error = if msg.is_some() {
|
let error = if msg.is_some() {
|
||||||
Some(types::ErrorResponse {
|
Some(types::ErrorResponse {
|
||||||
code: response.payment_status,
|
code: response.payment_status,
|
||||||
message: msg.unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()),
|
message: msg
|
||||||
reason: None,
|
.clone()
|
||||||
|
.unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()),
|
||||||
|
reason: msg,
|
||||||
status_code,
|
status_code,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@ -1107,7 +1114,7 @@ fn handle_bank_redirects_refund_response(
|
|||||||
Some(types::ErrorResponse {
|
Some(types::ErrorResponse {
|
||||||
code: response.result_info.result_code.to_string(),
|
code: response.result_info.result_code.to_string(),
|
||||||
message: msg.unwrap_or(consts::NO_ERROR_MESSAGE).to_owned(),
|
message: msg.unwrap_or(consts::NO_ERROR_MESSAGE).to_owned(),
|
||||||
reason: None,
|
reason: msg.map(|message| message.to_string()),
|
||||||
status_code,
|
status_code,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@ -1135,8 +1142,9 @@ fn handle_bank_redirects_refund_sync_response(
|
|||||||
message: reason_info
|
message: reason_info
|
||||||
.reason
|
.reason
|
||||||
.reject_reason
|
.reject_reason
|
||||||
|
.clone()
|
||||||
.unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()),
|
.unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()),
|
||||||
reason: None,
|
reason: reason_info.reason.reject_reason,
|
||||||
status_code,
|
status_code,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@ -1158,8 +1166,9 @@ fn handle_bank_redirects_refund_sync_error_response(
|
|||||||
message: response
|
message: response
|
||||||
.payment_result_info
|
.payment_result_info
|
||||||
.additional_info
|
.additional_info
|
||||||
|
.clone()
|
||||||
.unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_owned()),
|
.unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_owned()),
|
||||||
reason: None,
|
reason: response.payment_result_info.additional_info,
|
||||||
status_code,
|
status_code,
|
||||||
});
|
});
|
||||||
//unreachable case as we are sending error as Some()
|
//unreachable case as we are sending error as Some()
|
||||||
|
|||||||
Reference in New Issue
Block a user