Skip to content

Commit

Permalink
feat(router): add connector_transaction_id in error_response from c…
Browse files Browse the repository at this point in the history
…onnector flows (#2972)
  • Loading branch information
sai-harsha-vardhan authored Nov 24, 2023
1 parent 5cc829a commit 3322103
Show file tree
Hide file tree
Showing 77 changed files with 153 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/data_models/src/payments/payment_attempt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ pub enum PaymentAttemptUpdate {
updated_by: String,
unified_code: Option<Option<String>>,
unified_message: Option<Option<String>>,
connector_transaction_id: Option<String>,
},
CaptureUpdate {
amount_to_capture: Option<i64>,
Expand Down
3 changes: 3 additions & 0 deletions crates/diesel_models/src/payment_attempt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ pub enum PaymentAttemptUpdate {
updated_by: String,
unified_code: Option<Option<String>>,
unified_message: Option<Option<String>>,
connector_transaction_id: Option<String>,
},
CaptureUpdate {
amount_to_capture: Option<i64>,
Expand Down Expand Up @@ -543,6 +544,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
updated_by,
unified_code,
unified_message,
connector_transaction_id,
} => Self {
connector,
status: Some(status),
Expand All @@ -556,6 +558,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
tax_amount,
unified_code,
unified_message,
connector_transaction_id,
..Default::default()
},
PaymentAttemptUpdate::StatusUpdate { status, updated_by } => Self {
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/connector/aci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ impl ConnectorCommon for Aci {
.join("; ")
}),
attempt_status: None,
connector_transaction_id: None,
})
}
}
Expand Down
7 changes: 7 additions & 0 deletions crates/router/src/connector/adyen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ impl ConnectorCommon for Adyen {
message: response.message,
reason: None,
attempt_status: None,
connector_transaction_id: None,
})
}
}
Expand Down Expand Up @@ -256,6 +257,7 @@ impl
message: response.message,
reason: None,
attempt_status: None,
connector_transaction_id: None,
})
}
}
Expand Down Expand Up @@ -375,6 +377,7 @@ impl
message: response.message,
reason: None,
attempt_status: None,
connector_transaction_id: None,
})
}
}
Expand Down Expand Up @@ -546,6 +549,7 @@ impl
message: response.message,
reason: None,
attempt_status: None,
connector_transaction_id: None,
})
}

Expand Down Expand Up @@ -716,6 +720,7 @@ impl
message: response.message,
reason: None,
attempt_status: None,
connector_transaction_id: None,
})
}
}
Expand Down Expand Up @@ -920,6 +925,7 @@ impl
message: response.message,
reason: None,
attempt_status: None,
connector_transaction_id: None,
})
}
}
Expand Down Expand Up @@ -1439,6 +1445,7 @@ impl services::ConnectorIntegration<api::Execute, types::RefundsData, types::Ref
message: response.message,
reason: None,
attempt_status: None,
connector_transaction_id: None,
})
}
}
Expand Down
5 changes: 5 additions & 0 deletions crates/router/src/connector/adyen/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2907,6 +2907,7 @@ pub fn get_adyen_response(
reason: response.refusal_reason,
status_code,
attempt_status: None,
connector_transaction_id: None,
})
} else {
None
Expand Down Expand Up @@ -2999,6 +3000,7 @@ pub fn get_redirection_response(
reason: None,
status_code,
attempt_status: None,
connector_transaction_id: None,
})
} else {
None
Expand Down Expand Up @@ -3061,6 +3063,7 @@ pub fn get_present_to_shopper_response(
reason: None,
status_code,
attempt_status: None,
connector_transaction_id: None,
})
} else {
None
Expand Down Expand Up @@ -3111,6 +3114,7 @@ pub fn get_qr_code_response(
reason: None,
status_code,
attempt_status: None,
connector_transaction_id: None,
})
} else {
None
Expand Down Expand Up @@ -3149,6 +3153,7 @@ pub fn get_redirection_error_response(
reason: Some(response.refusal_reason),
status_code,
attempt_status: None,
connector_transaction_id: None,
});
// We don't get connector transaction id for redirections in Adyen.
let payments_response_data = types::PaymentsResponseData::TransactionResponse {
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/connector/airwallex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ impl ConnectorCommon for Airwallex {
message: response.message,
reason: response.source,
attempt_status: None,
connector_transaction_id: None,
})
}
}
Expand Down
3 changes: 3 additions & 0 deletions crates/router/src/connector/authorizedotnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,7 @@ fn get_error_response(
reason: Some(error.error_text),
status_code,
attempt_status: None,
connector_transaction_id: None,
})
})
.unwrap_or_else(|| types::ErrorResponse {
Expand All @@ -919,6 +920,7 @@ fn get_error_response(
reason: None,
status_code,
attempt_status: None,
connector_transaction_id: None,
})),
Some(authorizedotnet::TransactionResponse::AuthorizedotnetTransactionResponseError(_))
| None => {
Expand All @@ -929,6 +931,7 @@ fn get_error_response(
reason: Some(message.to_string()),
status_code,
attempt_status: None,
connector_transaction_id: None,
})
}
}
Expand Down
4 changes: 4 additions & 0 deletions crates/router/src/connector/authorizedotnet/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@ impl<F, T>
reason: None,
status_code: item.http_code,
attempt_status: None,
connector_transaction_id: None,
})
});
let metadata = transaction_response
Expand Down Expand Up @@ -649,6 +650,7 @@ impl<F, T>
reason: None,
status_code: item.http_code,
attempt_status: None,
connector_transaction_id: None,
})
});
let metadata = transaction_response
Expand Down Expand Up @@ -792,6 +794,7 @@ impl<F> TryFrom<types::RefundsResponseRouterData<F, AuthorizedotnetRefundRespons
reason: None,
status_code: item.http_code,
attempt_status: None,
connector_transaction_id: None,
})
});

Expand Down Expand Up @@ -1025,6 +1028,7 @@ fn get_err_response(status_code: u16, message: ResponseMessages) -> types::Error
reason: None,
status_code,
attempt_status: None,
connector_transaction_id: None,
}
}

Expand Down
1 change: 1 addition & 0 deletions crates/router/src/connector/bambora.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ impl ConnectorCommon for Bambora {
message: response.message,
reason: Some(serde_json::to_string(&response.details).unwrap_or_default()),
attempt_status: None,
connector_transaction_id: None,
})
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/connector/bankofamerica.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ impl ConnectorCommon for Bankofamerica {
message,
reason: Some(connector_reason),
attempt_status: None,
connector_transaction_id: None,
})
}
}
Expand Down
3 changes: 3 additions & 0 deletions crates/router/src/connector/bankofamerica/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ impl<F>
reason: error_response.error_information.reason,
status_code: item.http_code,
attempt_status: None,
connector_transaction_id: None,
}),
..item.data
}),
Expand Down Expand Up @@ -596,6 +597,7 @@ impl<F>
reason: error_response.error_information.reason,
status_code: item.http_code,
attempt_status: None,
connector_transaction_id: None,
}),
..item.data
}),
Expand Down Expand Up @@ -652,6 +654,7 @@ impl<F>
reason: error_response.error_information.reason,
status_code: item.http_code,
attempt_status: None,
connector_transaction_id: None,
}),
..item.data
}),
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/connector/bitpay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ impl ConnectorCommon for Bitpay {
message: response.error,
reason: response.message,
attempt_status: None,
connector_transaction_id: None,
})
}
}
Expand Down
3 changes: 3 additions & 0 deletions crates/router/src/connector/bluesnap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ impl ConnectorCommon for Bluesnap {
.unwrap_or(consts::NO_ERROR_MESSAGE.to_string()),
reason: Some(reason),
attempt_status: None,
connector_transaction_id: None,
}
}
bluesnap::BluesnapErrors::Auth(error_res) => ErrorResponse {
Expand All @@ -135,6 +136,7 @@ impl ConnectorCommon for Bluesnap {
message: error_res.error_name.clone().unwrap_or(error_res.error_code),
reason: Some(error_res.error_description),
attempt_status: None,
connector_transaction_id: None,
},
bluesnap::BluesnapErrors::General(error_response) => {
let (error_res, attempt_status) = if res.status_code == 403
Expand All @@ -156,6 +158,7 @@ impl ConnectorCommon for Bluesnap {
message: error_response,
reason: Some(error_res),
attempt_status,
connector_transaction_id: None,
}
}
};
Expand Down
2 changes: 2 additions & 0 deletions crates/router/src/connector/boku.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ impl ConnectorCommon for Boku {
message: response.message,
reason: response.reason,
attempt_status: None,
connector_transaction_id: None,
}),
Err(_) => get_xml_deserialized(res),
}
Expand Down Expand Up @@ -668,6 +669,7 @@ fn get_xml_deserialized(res: Response) -> CustomResult<ErrorResponse, errors::Co
message: consts::UNSUPPORTED_ERROR_MESSAGE.to_string(),
reason: Some(response_data),
attempt_status: None,
connector_transaction_id: None,
})
}
}
Expand Down
2 changes: 2 additions & 0 deletions crates/router/src/connector/braintree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ impl ConnectorCommon for Braintree {
message,
reason: Some(response.api_error_response.message),
attempt_status: None,
connector_transaction_id: None,
})
}
Ok(braintree::ErrorResponse::BraintreeErrorResponse(response)) => Ok(ErrorResponse {
Expand All @@ -141,6 +142,7 @@ impl ConnectorCommon for Braintree {
message: consts::NO_ERROR_MESSAGE.to_string(),
reason: Some(response.errors),
attempt_status: None,
connector_transaction_id: None,
}),
Err(error_msg) => {
logger::error!(deserialization_error =? error_msg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ fn get_error_response<T>(
reason: error_reason,
status_code: http_code,
attempt_status: None,
connector_transaction_id: None,
})
}

Expand Down
1 change: 1 addition & 0 deletions crates/router/src/connector/cashtocode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ impl ConnectorCommon for Cashtocode {
message: response.error_description,
reason: None,
attempt_status: None,
connector_transaction_id: None,
})
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/connector/cashtocode/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ impl<F, T>
message: error_data.error_description,
reason: None,
attempt_status: None,
connector_transaction_id: None,
}),
),
CashtocodePaymentsResponse::CashtoCodeData(response_data) => {
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/connector/checkout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ impl ConnectorCommon for Checkout {
.map(|errors| errors.join(" & "))
.or(response.error_type),
attempt_status: None,
connector_transaction_id: None,
})
}
}
Expand Down
2 changes: 2 additions & 0 deletions crates/router/src/connector/checkout/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ impl TryFrom<types::PaymentsResponseRouterData<PaymentsResponse>>
.unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()),
reason: item.response.response_summary,
attempt_status: None,
connector_transaction_id: None,
})
} else {
None
Expand Down Expand Up @@ -625,6 +626,7 @@ impl TryFrom<types::PaymentsSyncResponseRouterData<PaymentsResponse>>
.unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()),
reason: item.response.response_summary,
attempt_status: None,
connector_transaction_id: None,
})
} else {
None
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/connector/coinbase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ impl ConnectorCommon for Coinbase {
message: response.error.message,
reason: response.error.code,
attempt_status: None,
connector_transaction_id: None,
})
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/connector/cryptopay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ impl ConnectorCommon for Cryptopay {
message: response.error.message,
reason: response.error.reason,
attempt_status: None,
connector_transaction_id: None,
})
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/connector/cybersource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ impl ConnectorCommon for Cybersource {
message,
reason: Some(connector_reason),
attempt_status: None,
connector_transaction_id: None,
})
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/connector/cybersource/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ impl<F, T>
reason: Some(error.reason),
status_code: item.http_code,
attempt_status: None,
connector_transaction_id: None,
}),
_ => Ok(types::PaymentsResponseData::TransactionResponse {
resource_id: types::ResponseId::ConnectorTransactionId(
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/connector/dlocal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ impl ConnectorCommon for Dlocal {
message: response.message,
reason: response.param,
attempt_status: None,
connector_transaction_id: None,
})
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/connector/dummyconnector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ impl<const T: u8> ConnectorCommon for DummyConnector<T> {
message: response.error.message,
reason: response.error.reason,
attempt_status: None,
connector_transaction_id: None,
})
}
}
Expand Down
Loading

0 comments on commit 3322103

Please sign in to comment.