feat: handle no connector txn id (#39)

This commit is contained in:
Sangamesh Kulkarni
2022-12-01 16:53:30 +05:30
committed by GitHub
parent 473d8f7a1b
commit f47c06a517
13 changed files with 94 additions and 27 deletions

View File

@ -93,6 +93,8 @@ pub enum ApiErrorResponse {
MerchantAccountNotFound,
#[error(error_type = ErrorType::ObjectNotFound, code = "RE_02", message = "Merchant connector account does not exist in our records.")]
MerchantConnectorAccountNotFound,
#[error(error_type = ErrorType::ObjectNotFound, code = "RE_02", message = "Resource ID does not exist in our records.")]
ResourceIdNotFound,
#[error(error_type = ErrorType::DuplicateRequest, code = "RE_01", message = "Duplicate mandate request. Mandate already attempted with the Mandate ID.")]
DuplicateMandate,
#[error(error_type = ErrorType::ObjectNotFound, code = "RE_02", message = "Mandate does not exist in our records.")]
@ -161,6 +163,7 @@ impl actix_web::ResponseError for ApiErrorResponse {
| ApiErrorResponse::MandateNotFound
| ApiErrorResponse::ClientSecretInvalid
| ApiErrorResponse::SuccessfulPaymentNotFound
| ApiErrorResponse::ResourceIdNotFound
| ApiErrorResponse::AddressNotFound => StatusCode::BAD_REQUEST, // 400
ApiErrorResponse::DuplicateMerchantAccount
| ApiErrorResponse::DuplicateMerchantConnectorAccount

View File

@ -123,7 +123,12 @@ async fn payment_response_ut<F: Clone, T>(
storage::PaymentAttemptUpdate::ResponseUpdate {
status: router_data.status,
connector_transaction_id: Some(response.connector_transaction_id),
connector_transaction_id: Some(
response
.resource_id
.get_connector_transaction_id()
.change_context(errors::ApiErrorResponse::ResourceIdNotFound)?,
),
authentication_type: None,
payment_method_id: Some(router_data.payment_method_id),
redirect: Some(response.redirect),
@ -147,7 +152,12 @@ async fn payment_response_ut<F: Clone, T>(
.attach_printable("Could not parse the connector response")?;
let connector_response_update = storage::ConnectorResponseUpdate::ResponseUpdate {
connector_transaction_id: Some(connector_response.connector_transaction_id.clone()),
connector_transaction_id: Some(
connector_response
.resource_id
.get_connector_transaction_id()
.change_context(errors::ApiErrorResponse::ResourceIdNotFound)?,
),
authentication_data,
encoded_data: payment_data.connector_response.encoded_data.clone(),
};

View File

@ -68,7 +68,7 @@ where
.connector_transaction_id
.as_ref()
.map(|id| types::PaymentsResponseData {
connector_transaction_id: id.to_string(),
resource_id: types::ResponseId::ConnectorTransactionId(id.to_string()),
//TODO: Add redirection details here
redirection_data: None,
redirect: false,