Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

feat(connector): [AUTHORIZEDOTNET] customer_id length validated and server-too-busy error handled (#8696)

sweta-sharma422724cfe9b3
diff --git a/crates/hyperswitch_connectors/src/connectors/authorizedotnet/transformers.rs b/crates/hyperswitch_connectors/src/connectors/authorizedotnet/transformers.rs
index cfa0c7e298..cf712749b5 100644
--- a/crates/hyperswitch_connectors/src/connectors/authorizedotnet/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/authorizedotnet/transformers.rs
@@ -412,14 +412,23 @@ impl TryFrom<&SetupMandateRouterData> for CreateCustomerProfileRequest {
})
});
+ let merchant_customer_id = match &item.request.customer_id {
+ Some(customer_id)
+ if customer_id.clone().get_string_repr().len() <= MAX_ID_LENGTH =>
+ {
+ Some(customer_id.clone())
+ }
+ _ => None,
+ };
+
Ok(Self {
create_customer_profile_request: AuthorizedotnetZeroMandateRequest {
merchant_authentication,
profile: Profile {
- merchant_customer_id: item.request.customer_id.clone(),
+ merchant_customer_id,
// The payment ID is included in the description because the connector requires unique description when creating a mandate.
description: None,
- email: item.get_optional_shipping_email(),
+ email: item.request.email.clone(),
payment_profiles: PaymentProfiles {
customer_type: CustomerType::Individual,
payment: PaymentDetails::CreditCard(CreditCardDetails {
@@ -458,14 +467,22 @@ impl TryFrom<&SetupMandateRouterData> for CreateCustomerProfileRequest {
}]
})
});
+ let merchant_customer_id = match &item.request.customer_id {
+ Some(customer_id)
+ if customer_id.clone().get_string_repr().len() <= MAX_ID_LENGTH =>
+ {
+ Some(customer_id.clone())
+ }
+ _ => None,
+ };
Ok(Self {
create_customer_profile_request: AuthorizedotnetZeroMandateRequest {
merchant_authentication,
profile: Profile {
- merchant_customer_id: item.request.customer_id.clone(),
+ merchant_customer_id,
// The payment ID is included in the description because the connector requires unique description when creating a mandate.
description: None,
- email: item.get_optional_shipping_email(),
+ email: item.request.email.clone(),
payment_profiles: PaymentProfiles {
customer_type: CustomerType::Individual,
payment: PaymentDetails::OpaqueData(WalletDetails {
@@ -504,14 +521,22 @@ impl TryFrom<&SetupMandateRouterData> for CreateCustomerProfileRequest {
}]
})
});
+ let merchant_customer_id = match &item.request.customer_id {
+ Some(customer_id)
+ if customer_id.clone().get_string_repr().len() <= MAX_ID_LENGTH =>
+ {
+ Some(customer_id.clone())
+ }
+ _ => None,
+ };
Ok(Self {
create_customer_profile_request: AuthorizedotnetZeroMandateRequest {
merchant_authentication,
profile: Profile {
- merchant_customer_id: item.request.customer_id.clone(),
+ merchant_customer_id,
// The payment ID is included in the description because the connector requires unique description when creating a mandate.
description: None,
- email: item.get_optional_shipping_email(),
+ email: item.request.email.clone(),
payment_profiles: PaymentProfiles {
customer_type: CustomerType::Individual,
payment: PaymentDetails::OpaqueData(WalletDetails {
@@ -1881,10 +1906,22 @@ impl<F, Req> TryFrom<ResponseRouterData<F, AuthorizedotnetSyncResponse, Req, Pay
..item.data
})
}
- None => Ok(Self {
- response: Err(get_err_response(item.http_code, item.response.messages)?),
- ..item.data
- }),
+
+ // E00053 indicates "server too busy"
+ // If the server is too busy, we return the already available data
+ None => match item
+ .response
+ .messages
+ .message
+ .iter()
+ .find(|msg| msg.code == "E00053")
+ {
+ Some(_) => Ok(item.data),
+ None => Ok(Self {
+ response: Err(get_err_response(item.http_code, item.response.messages)?),
+ ..item.data
+ }),
+ },
}
}
}