Skip to content

Commit 76d275e

Browse files
fix(connector): [AUTHORIZEDOTNET] error for customer already exists refactored (#8866)
1 parent 1b2a98c commit 76d275e

File tree

1 file changed

+14
-7
lines changed
  • crates/hyperswitch_connectors/src/connectors/authorizedotnet

1 file changed

+14
-7
lines changed

crates/hyperswitch_connectors/src/connectors/authorizedotnet/transformers.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ pub struct AuthorizedotnetSetupMandateResponse {
592592
#[derive(Debug, Clone, Deserialize, Serialize)]
593593
#[serde(rename_all = "camelCase")]
594594
pub struct AuthorizedotnetCustomerResponse {
595-
customer_profile_id: String,
595+
customer_profile_id: Option<String>,
596596
#[serde(default, skip_serializing_if = "Vec::is_empty")]
597597
customer_payment_profile_id_list: Vec<String>,
598598
#[serde(default, skip_serializing_if = "Vec::is_empty")]
@@ -607,14 +607,21 @@ impl<F, T> TryFrom<ResponseRouterData<F, AuthorizedotnetCustomerResponse, T, Pay
607607
fn try_from(
608608
item: ResponseRouterData<F, AuthorizedotnetCustomerResponse, T, PaymentsResponseData>,
609609
) -> Result<Self, Self::Error> {
610-
let connector_customer_id = item.response.customer_profile_id.clone();
611610
match item.response.messages.result_code {
612-
ResultCode::Ok => Ok(Self {
613-
response: Ok(PaymentsResponseData::ConnectorCustomerResponse {
614-
connector_customer_id,
611+
ResultCode::Ok => match item.response.customer_profile_id.clone() {
612+
Some(connector_customer_id) => Ok(Self {
613+
response: Ok(PaymentsResponseData::ConnectorCustomerResponse {
614+
connector_customer_id,
615+
}),
616+
..item.data
615617
}),
616-
..item.data
617-
}),
618+
None => Err(
619+
errors::ConnectorError::UnexpectedResponseError(bytes::Bytes::from(
620+
"Missing customer profile id from Authorizedotnet".to_string(),
621+
))
622+
.into(),
623+
),
624+
},
618625
ResultCode::Error => {
619626
let error_message = item.response.messages.message.first();
620627
let error_code = error_message.map(|error| error.code.clone());

0 commit comments

Comments
 (0)