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] create connector customer flow added (#8774)

sweta-sharma8818a9b36ff5
diff --git a/config/config.example.toml b/config/config.example.toml
index 6ca1ccffef..e2cdf7fd3f 100644
--- a/config/config.example.toml
+++ b/config/config.example.toml
@@ -887,7 +887,7 @@ pix = { country = "BR", currency = "BRL" }
bluecode = { country = "AT,BE,BG,HR,CY,CZ,DK,EE,FI,FR,DE,GR,HU,IE,IT,LV,LT,LU,MT,NL,PL,PT,RO,SK,SI,ES,SE,IS,LI,NO", currency = "EUR" }
[connector_customer]
-connector_list = "adyen,facilitapay,gocardless,hyperswitch_vault,stax,stripe"
+connector_list = "adyen,authorizedotnet,facilitapay,gocardless,hyperswitch_vault,stax,stripe"
payout_connector_list = "nomupay,stripe,wise"
[bank_config.online_banking_fpx]
diff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.toml
index 50d1ffd2ee..9e64b7928e 100644
--- a/config/deployments/integration_test.toml
+++ b/config/deployments/integration_test.toml
@@ -191,7 +191,7 @@ force_cookies = true
enabled = true
[connector_customer]
-connector_list = "adyen,facilitapay,gocardless,hyperswitch_vault,stax,stripe"
+connector_list = "adyen,authorizedotnet,facilitapay,gocardless,hyperswitch_vault,stax,stripe"
payout_connector_list = "nomupay,stripe,wise"
[delayed_session_response]
diff --git a/config/deployments/production.toml b/config/deployments/production.toml
index 6489e0ef96..fe7041d553 100644
--- a/config/deployments/production.toml
+++ b/config/deployments/production.toml
@@ -15,7 +15,7 @@ open_banking_uk.adyen.banks = "aib,bank_of_scotland,danske_bank,first_direct,fir
przelewy24.stripe.banks = "alior_bank,bank_millennium,bank_nowy_bfg_sa,bank_pekao_sa,banki_spbdzielcze,blik,bnp_paribas,boz,citi,credit_agricole,e_transfer_pocztowy24,getin_bank,idea_bank,inteligo,mbank_mtransfer,nest_przelew,noble_pay,pbac_z_ipko,plus_bank,santander_przelew24,toyota_bank,volkswagen_bank"
[connector_customer]
-connector_list = "adyen,facilitapay,gocardless,hyperswitch_vault,stax,stripe"
+connector_list = "adyen,authorizedotnet,facilitapay,gocardless,hyperswitch_vault,stax,stripe"
payout_connector_list = "nomupay,stripe,wise"
# Connector configuration, provided attributes will be used to fulfill API requests.
diff --git a/config/deployments/sandbox.toml b/config/deployments/sandbox.toml
index beb4a80eb3..e9f5b09c75 100644
--- a/config/deployments/sandbox.toml
+++ b/config/deployments/sandbox.toml
@@ -15,7 +15,7 @@ open_banking_uk.adyen.banks = "aib,bank_of_scotland,danske_bank,first_direct,fir
przelewy24.stripe.banks = "alior_bank,bank_millennium,bank_nowy_bfg_sa,bank_pekao_sa,banki_spbdzielcze,blik,bnp_paribas,boz,citi,credit_agricole,e_transfer_pocztowy24,getin_bank,idea_bank,inteligo,mbank_mtransfer,nest_przelew,noble_pay,pbac_z_ipko,plus_bank,santander_przelew24,toyota_bank,volkswagen_bank"
[connector_customer]
-connector_list = "adyen,facilitapay,gocardless,hyperswitch_vault,stax,stripe"
+connector_list = "adyen,authorizedotnet,facilitapay,gocardless,hyperswitch_vault,stax,stripe"
payout_connector_list = "nomupay,stripe,wise"
# Connector configuration, provided attributes will be used to fulfill API requests.
diff --git a/config/development.toml b/config/development.toml
index e73b35609e..c06d9798cd 100644
--- a/config/development.toml
+++ b/config/development.toml
@@ -942,7 +942,7 @@ nexixpay = { payment_method = "card" }
redsys = { payment_method = "card" }
[connector_customer]
-connector_list = "adyen,facilitapay,gocardless,hyperswitch_vault,stax,stripe"
+connector_list = "adyen,authorizedotnet,facilitapay,gocardless,hyperswitch_vault,stax,stripe"
payout_connector_list = "nomupay,stripe,wise"
[dummy_connector]
diff --git a/config/docker_compose.toml b/config/docker_compose.toml
index b6ef24fcd2..8893834e23 100644
--- a/config/docker_compose.toml
+++ b/config/docker_compose.toml
@@ -946,7 +946,7 @@ card.debit = { connector_list = "cybersource" }
connector_list = "adyen,archipel,cybersource,novalnet,stripe,worldpay,worldpayvantiv"
[connector_customer]
-connector_list = "adyen,facilitapay,gocardless,hyperswitch_vault,stax,stripe"
+connector_list = "adyen,authorizedotnet,facilitapay,gocardless,hyperswitch_vault,stax,stripe"
payout_connector_list = "nomupay,stripe,wise"
diff --git a/crates/hyperswitch_connectors/src/connectors/authorizedotnet.rs b/crates/hyperswitch_connectors/src/connectors/authorizedotnet.rs
index 7164d0585e..3f9c771fb4 100644
--- a/crates/hyperswitch_connectors/src/connectors/authorizedotnet.rs
+++ b/crates/hyperswitch_connectors/src/connectors/authorizedotnet.rs
@@ -16,21 +16,22 @@ use hyperswitch_domain_models::{
access_token_auth::AccessTokenAuth,
payments::{Authorize, Capture, PSync, PaymentMethodToken, Session, SetupMandate, Void},
refunds::{Execute, RSync},
- CompleteAuthorize,
+ CompleteAuthorize, CreateConnectorCustomer,
},
router_request_types::{
- AccessTokenRequestData, CompleteAuthorizeData, PaymentMethodTokenizationData,
- PaymentsAuthorizeData, PaymentsCancelData, PaymentsCaptureData, PaymentsSessionData,
- PaymentsSyncData, RefundsData, SetupMandateRequestData,
+ AccessTokenRequestData, CompleteAuthorizeData, ConnectorCustomerData,
+ PaymentMethodTokenizationData, PaymentsAuthorizeData, PaymentsCancelData,
+ PaymentsCaptureData, PaymentsSessionData, PaymentsSyncData, RefundsData,
+ SetupMandateRequestData,
},
router_response_types::{
ConnectorInfo, PaymentMethodDetails, PaymentsResponseData, RefundsResponseData,
SupportedPaymentMethods, SupportedPaymentMethodsExt,
},
types::{
- PaymentsAuthorizeRouterData, PaymentsCancelRouterData, PaymentsCaptureRouterData,
- PaymentsCompleteAuthorizeRouterData, PaymentsSyncRouterData, RefundsRouterData,
- SetupMandateRouterData,
+ ConnectorCustomerRouterData, PaymentsAuthorizeRouterData, PaymentsCancelRouterData,
+ PaymentsCaptureRouterData, PaymentsCompleteAuthorizeRouterData, PaymentsSyncRouterData,
+ RefundsRouterData, SetupMandateRouterData,
},
};
use hyperswitch_interfaces::{
@@ -42,9 +43,9 @@ use hyperswitch_interfaces::{
consts, errors,
events::connector_api_logs::ConnectorEvent,
types::{
- PaymentsAuthorizeType, PaymentsCaptureType, PaymentsCompleteAuthorizeType,
- PaymentsSyncType, PaymentsVoidType, RefundExecuteType, RefundSyncType, Response,
- SetupMandateType,
+ ConnectorCustomerType, PaymentsAuthorizeType, PaymentsCaptureType,
+ PaymentsCompleteAuthorizeType, PaymentsSyncType, PaymentsVoidType, RefundExecuteType,
+ RefundSyncType, Response, SetupMandateType,
},
webhooks,
};
@@ -137,6 +138,128 @@ impl ConnectorIntegration<AccessTokenAuth, AccessTokenRequestData, AccessToken>
// Not Implemented (R)
}
+impl api::ConnectorCustomer for Authorizedotnet {}
+
+impl ConnectorIntegration<CreateConnectorCustomer, ConnectorCustomerData, PaymentsResponseData>
+ for Authorizedotnet
+{
+ fn get_headers(
+ &self,
+ req: &ConnectorCustomerRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Vec<(String, Maskable<String>)>, errors::ConnectorError> {
+ self.build_headers(req, connectors)
+ }
+
+ fn get_content_type(&self) -> &'static str {
+ self.common_get_content_type()
+ }
+
+ fn get_url(
+ &self,
+ _req: &ConnectorCustomerRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<String, errors::ConnectorError> {
+ Ok(self.base_url(connectors).to_string())
+ }
+
+ fn get_request_body(
+ &self,
+ req: &ConnectorCustomerRouterData,
+ _connectors: &Connectors,
+ ) -> CustomResult<RequestContent, errors::ConnectorError> {
+ let connector_req = authorizedotnet::CustomerRequest::try_from(req)?;
+ Ok(RequestContent::Json(Box::new(connector_req)))
+ }
+
+ fn build_request(
+ &self,
+ req: &ConnectorCustomerRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {
+ Ok(Some(
+ RequestBuilder::new()
+ .method(Method::Post)
+ .url(&ConnectorCustomerType::get_url(self, req, connectors)?)
+ .attach_default_headers()
+ .headers(ConnectorCustomerType::get_headers(self, req, connectors)?)
+ .set_body(ConnectorCustomerType::get_request_body(
+ self, req, connectors,
+ )?)
+ .build(),
+ ))
+ }
+
+ fn handle_response(
+ &self,
+ data: &ConnectorCustomerRouterData,
+ event_builder: Option<&mut ConnectorEvent>,
+ res: Response,
+ ) -> CustomResult<ConnectorCustomerRouterData, errors::ConnectorError>
+ where
+ PaymentsResponseData: Clone,
+ {
+ use bytes::Buf;
+ // Handle the case where response bytes contains U+FEFF (BOM) character sent by connector
+ let encoding = encoding_rs::UTF_8;
+ let intermediate_response = encoding.decode_with_bom_removal(res.response.chunk());
+ let intermediate_response =
+ bytes::Bytes::copy_from_slice(intermediate_response.0.as_bytes());
+ let response: authorizedotnet::AuthorizedotnetCustomerResponse = intermediate_response
+ .parse_struct("AuthorizedotnetCustomerResponse")
+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+
+ event_builder.map(|i| i.set_response_body(&response));
+ router_env::logger::info!(connector_response=?response);
+
+ RouterData::try_from(ResponseRouterData {
+ response,
+ data: data.clone(),
+ http_code: res.status_code,
+ })
+ .change_context(errors::ConnectorError::ResponseHandlingFailed)
+ }
+
+ fn get_error_response(
+ &self,
+ res: Response,
+ event_builder: Option<&mut ConnectorEvent>,
+ ) -> CustomResult<ErrorResponse, errors::ConnectorError> {
+ use bytes::Buf;
+ // Handle the case where response bytes contains U+FEFF (BOM) character sent by connector
+ let encoding = encoding_rs::UTF_8;
+ let intermediate_response = encoding.decode_with_bom_removal(res.response.chunk());
+ let intermediate_response =
+ bytes::Bytes::copy_from_slice(intermediate_response.0.as_bytes());
+ let response: authorizedotnet::AuthorizedotnetErrorResponse = intermediate_response
+ .parse_struct("AuthorizedotnetErrorResponse")
+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+
+ event_builder.map(|i| i.set_error_response_body(&response));
+ router_env::logger::info!(connector_response=?response);
+
+ Ok(ErrorResponse {
+ status_code: res.status_code,
+ code: response
+ .error
+ .code
+ .clone()
+ .unwrap_or_else(|| consts::NO_ERROR_CODE.to_string()),
+ message: response
+ .error
+ .message
+ .clone()
+ .unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()),
+ reason: response.error.message,
+ attempt_status: None,
+ connector_transaction_id: None,
+ network_advice_code: None,
+ network_decline_code: None,
+ network_error_message: None,
+ })
+ }
+}
+
impl MandateSetup for Authorizedotnet {}
impl ConnectorIntegration<SetupMandate, SetupMandateRequestData, PaymentsResponseData>
@@ -165,7 +288,7 @@ impl ConnectorIntegration<SetupMandate, SetupMandateRequestData, PaymentsRespons
req: &SetupMandateRouterData,
_connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
- let connector_req = authorizedotnet::CreateCustomerProfileRequest::try_from(req)?;
+ let connector_req = authorizedotnet::CreateCustomerPaymentProfileRequest::try_from(req)?;
Ok(RequestContent::Json(Box::new(connector_req)))
}
@@ -192,7 +315,6 @@ impl ConnectorIntegration<SetupMandate, SetupMandateRequestData, PaymentsRespons
res: Response,
) -> CustomResult<SetupMandateRouterData, errors::ConnectorError> {
use bytes::Buf;
-
// Handle the case where response bytes contains U+FEFF (BOM) character sent by connector
let encoding = encoding_rs::UTF_8;
let intermediate_response = encoding.decode_with_bom_removal(res.response.chunk());
diff --git a/crates/hyperswitch_connectors/src/connectors/authorizedotnet/transformers.rs b/crates/hyperswitch_connectors/src/connectors/authorizedotnet/transformers.rs
index ff2b01cdff..c032b78f45 100644
--- a/crates/hyperswitch_connectors/src/connectors/authorizedotnet/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/authorizedotnet/transformers.rs
@@ -22,9 +22,9 @@ use hyperswitch_domain_models::{
MandateReference, PaymentsResponseData, RedirectForm, RefundsResponseData,
},
types::{
- PaymentsAuthorizeRouterData, PaymentsCancelRouterData, PaymentsCaptureRouterData,
- PaymentsCompleteAuthorizeRouterData, PaymentsSyncRouterData, RefundsRouterData,
- SetupMandateRouterData,
+ ConnectorCustomerRouterData, PaymentsAuthorizeRouterData, PaymentsCancelRouterData,
+ PaymentsCaptureRouterData, PaymentsCompleteAuthorizeRouterData, PaymentsSyncRouterData,
+ RefundsRouterData, SetupMandateRouterData,
},
};
use hyperswitch_interfaces::{api, errors};
@@ -298,15 +298,29 @@ pub struct AuthorizedotnetPaymentCancelOrCaptureRequest {
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
// The connector enforces field ordering, it expects fields to be in the same order as in their API documentation
-pub struct CreateCustomerProfileRequest {
- create_customer_profile_request: AuthorizedotnetZeroMandateRequest,
+pub struct CustomerRequest {
+ create_customer_profile_request: CreateCustomerRequest,
}
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
-pub struct AuthorizedotnetZeroMandateRequest {
+pub struct CreateCustomerRequest {
merchant_authentication: AuthorizedotnetAuthType,
profile: Profile,
+}
+
+#[derive(Debug, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct CreateCustomerPaymentProfileRequest {
+ create_customer_payment_profile_request: AuthorizedotnetPaymentProfileRequest,
+}
+
+#[derive(Debug, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct AuthorizedotnetPaymentProfileRequest {
+ merchant_authentication: AuthorizedotnetAuthType,
+ customer_profile_id: Secret<String>,
+ payment_profile: PaymentProfile,
validation_mode: ValidationMode,
}
@@ -334,10 +348,14 @@ pub struct ShipToList {
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
struct Profile {
+ #[serde(skip_serializing_if = "Option::is_none")]
merchant_customer_id: Option<CustomerId>,
+ #[serde(skip_serializing_if = "Option::is_none")]
description: Option<String>,
+ #[serde(skip_serializing_if = "Option::is_none")]
email: Option<Email>,
- payment_profiles: PaymentProfiles,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ payment_profiles: Option<PaymentProfiles>,
#[serde(skip_serializing_if = "Option::is_none")]
ship_to_list: Option<Vec<ShipToList>>,
}
@@ -346,6 +364,16 @@ struct Profile {
#[serde(rename_all = "camelCase")]
struct PaymentProfiles {
customer_type: CustomerType,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ bill_to: Option<BillTo>,
+ payment: PaymentDetails,
+}
+
+#[derive(Debug, Serialize)]
+#[serde(rename_all = "camelCase")]
+struct PaymentProfile {
+ #[serde(skip_serializing_if = "Option::is_none")]
+ bill_to: Option<BillTo>,
payment: PaymentDetails,
}
@@ -384,178 +412,104 @@ impl ForeignTryFrom<Value> for Vec<UserField> {
}
}
-impl TryFrom<&SetupMandateRouterData> for CreateCustomerProfileRequest {
+impl TryFrom<&ConnectorCustomerRouterData> for CustomerRequest {
type Error = error_stack::Report<errors::ConnectorError>;
- fn try_from(item: &SetupMandateRouterData) -> Result<Self, Self::Error> {
- match item.request.payment_method_data.clone() {
- PaymentMethodData::Card(ccard) => {
- let merchant_authentication =
- AuthorizedotnetAuthType::try_from(&item.connector_auth_type)?;
- let validation_mode = match item.test_mode {
- Some(true) | None => ValidationMode::TestMode,
- Some(false) => ValidationMode::LiveMode,
- };
- let ship_to_list = item.get_optional_shipping().and_then(|shipping| {
- shipping.address.as_ref().map(|address| {
- vec![ShipToList {
- first_name: address.first_name.clone(),
- last_name: address.last_name.clone(),
- address: address.line1.clone(),
- city: address.city.clone(),
- state: address.state.clone(),
- zip: address.zip.clone(),
- country: address.country,
- phone_number: shipping.phone.as_ref().and_then(|phone| {
- phone.number.as_ref().map(|number| number.to_owned())
- }),
- }]
- })
- });
+ fn try_from(item: &ConnectorCustomerRouterData) -> Result<Self, Self::Error> {
+ let merchant_authentication = AuthorizedotnetAuthType::try_from(&item.connector_auth_type)?;
+ let ship_to_list = item.get_optional_shipping().and_then(|shipping| {
+ shipping.address.as_ref().map(|address| {
+ vec![ShipToList {
+ first_name: address.first_name.clone(),
+ last_name: address.last_name.clone(),
+ address: address.line1.clone(),
+ city: address.city.clone(),
+ state: address.state.clone(),
+ zip: address.zip.clone(),
+ country: address.country,
+ phone_number: shipping
+ .phone
+ .as_ref()
+ .and_then(|phone| phone.number.as_ref().map(|number| number.to_owned())),
+ }]
+ })
+ });
- 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,
- };
+ let merchant_customer_id = match item.customer_id.as_ref() {
+ Some(cid) if cid.get_string_repr().len() <= MAX_ID_LENGTH => Some(cid.clone()),
+ _ => None,
+ };
- Ok(Self {
- create_customer_profile_request: AuthorizedotnetZeroMandateRequest {
- merchant_authentication,
- profile: Profile {
- 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.request.email.clone(),
- payment_profiles: PaymentProfiles {
- customer_type: CustomerType::Individual,
- payment: PaymentDetails::CreditCard(CreditCardDetails {
- card_number: (*ccard.card_number).clone(),
- expiration_date: ccard.get_expiry_date_as_yyyymm("-"),
- card_code: Some(ccard.card_cvc.clone()),
- }),
- },
- ship_to_list,
- },
- validation_mode,
- },
- })
- }
+ Ok(Self {
+ create_customer_profile_request: CreateCustomerRequest {
+ merchant_authentication,
+ profile: Profile {
+ merchant_customer_id,
+ description: None,
+ email: item.request.email.clone(),
+ payment_profiles: None,
+ ship_to_list,
+ },
+ },
+ })
+ }
+}
+
+impl TryFrom<&SetupMandateRouterData> for CreateCustomerPaymentProfileRequest {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(item: &SetupMandateRouterData) -> Result<Self, Self::Error> {
+ let merchant_authentication = AuthorizedotnetAuthType::try_from(&item.connector_auth_type)?;
+ let validation_mode = match item.test_mode {
+ Some(true) | None => ValidationMode::TestMode,
+ Some(false) => ValidationMode::LiveMode,
+ };
+ let customer_profile_id = item.get_connector_customer_id()?.into();
+
+ let bill_to = item
+ .get_optional_billing()
+ .and_then(|billing_address| billing_address.address.as_ref())
+ .map(|address| BillTo {
+ first_name: address.first_name.clone(),
+ last_name: address.last_name.clone(),
+ address: address.line1.clone(),
+ city: address.city.clone(),
+ state: address.state.clone(),
+ zip: address.zip.clone(),
+ country: address.country,
+ });
+ let payment_profile = match item.request.payment_method_data.clone() {
+ PaymentMethodData::Card(ccard) => Ok(PaymentProfile {
+ bill_to,
+ payment: PaymentDetails::CreditCard(CreditCardDetails {
+ card_number: (*ccard.card_number).clone(),
+ expiration_date: ccard.get_expiry_date_as_yyyymm("-"),
+ card_code: Some(ccard.card_cvc.clone()),
+ }),
+ }),
PaymentMethodData::Wallet(wallet_data) => match wallet_data {
- WalletData::GooglePay(_) => {
- let merchant_authentication =
- AuthorizedotnetAuthType::try_from(&item.connector_auth_type)?;
- let validation_mode = match item.test_mode {
- Some(true) | None => ValidationMode::TestMode,
- Some(false) => ValidationMode::LiveMode,
- };
- let ship_to_list = item.get_optional_shipping().and_then(|shipping| {
- shipping.address.as_ref().map(|address| {
- vec![ShipToList {
- first_name: address.first_name.clone(),
- last_name: address.last_name.clone(),
- address: address.line1.clone(),
- city: address.city.clone(),
- state: address.state.clone(),
- zip: address.zip.clone(),
- country: address.country,
- phone_number: shipping.phone.as_ref().and_then(|phone| {
- phone.number.as_ref().map(|number| number.to_owned())
- }),
- }]
- })
- });
- 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,
- // The payment ID is included in the description because the connector requires unique description when creating a mandate.
- description: None,
- email: item.request.email.clone(),
- payment_profiles: PaymentProfiles {
- customer_type: CustomerType::Individual,
- payment: PaymentDetails::OpaqueData(WalletDetails {
- data_descriptor: WalletMethod::Googlepay,
- data_value: Secret::new(
- wallet_data.get_encoded_wallet_token()?,
- ),
- }),
- },
- ship_to_list,
- },
- validation_mode,
- },
- })
- }
+ WalletData::GooglePay(_) => Ok(PaymentProfile {
+ bill_to,
+ payment: PaymentDetails::OpaqueData(WalletDetails {
+ data_descriptor: WalletMethod::Googlepay,
+ data_value: Secret::new(wallet_data.get_encoded_wallet_token()?),
+ }),
+ }),
WalletData::ApplePay(applepay_token) => {
- let merchant_authentication =
- AuthorizedotnetAuthType::try_from(&item.connector_auth_type)?;
- let validation_mode = match item.test_mode {
- Some(true) | None => ValidationMode::TestMode,
- Some(false) => ValidationMode::LiveMode,
- };
- let ship_to_list = item.get_optional_shipping().and_then(|shipping| {
- shipping.address.as_ref().map(|address| {
- vec![ShipToList {
- first_name: address.first_name.clone(),
- last_name: address.last_name.clone(),
- address: address.line1.clone(),
- city: address.city.clone(),
- state: address.state.clone(),
- zip: address.zip.clone(),
- country: address.country,
- phone_number: shipping.phone.as_ref().and_then(|phone| {
- phone.number.as_ref().map(|number| number.to_owned())
- }),
- }]
- })
- });
- 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,
- };
let apple_pay_encrypted_data = applepay_token
.payment_data
.get_encrypted_apple_pay_payment_data_mandatory()
.change_context(errors::ConnectorError::MissingRequiredField {
field_name: "Apple pay encrypted data",
})?;
- Ok(Self {
- create_customer_profile_request: AuthorizedotnetZeroMandateRequest {
- merchant_authentication,
- profile: Profile {
- 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.request.email.clone(),
- payment_profiles: PaymentProfiles {
- customer_type: CustomerType::Individual,
- payment: PaymentDetails::OpaqueData(WalletDetails {
- data_descriptor: WalletMethod::Applepay,
- data_value: Secret::new(apple_pay_encrypted_data.clone()),
- }),
- },
- ship_to_list,
- },
- validation_mode,
- },
+
+ Ok(PaymentProfile {
+ bill_to,
+ payment: PaymentDetails::OpaqueData(WalletDetails {
+ data_descriptor: WalletMethod::Applepay,
+ data_value: Secret::new(apple_pay_encrypted_data.clone()),
+ }),
})
}
+
WalletData::AliPayQr(_)
| WalletData::AliPayRedirect(_)
| WalletData::AliPayHkRedirect(_)
@@ -588,7 +542,7 @@ impl TryFrom<&SetupMandateRouterData> for CreateCustomerProfileRequest {
| WalletData::Mifinity(_)
| WalletData::RevolutPay(_) => Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("authorizedotnet"),
- ))?,
+ )),
},
PaymentMethodData::CardRedirect(_)
| PaymentMethodData::PayLater(_)
@@ -609,21 +563,92 @@ impl TryFrom<&SetupMandateRouterData> for CreateCustomerProfileRequest {
| PaymentMethodData::CardDetailsForNetworkTransactionId(_) => {
Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("authorizedotnet"),
- ))?
+ ))
}
- }
+ }?;
+ Ok(Self {
+ create_customer_payment_profile_request: AuthorizedotnetPaymentProfileRequest {
+ merchant_authentication,
+ customer_profile_id,
+ payment_profile,
+ validation_mode,
+ },
+ })
}
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct AuthorizedotnetSetupMandateResponse {
- customer_profile_id: Option<String>,
+ #[serde(default, skip_serializing_if = "Vec::is_empty")]
customer_payment_profile_id_list: Vec<String>,
+ customer_profile_id: Option<String>,
+ #[serde(rename = "customerPaymentProfileId")]
+ customer_payment_profile_id: Option<String>,
validation_direct_response_list: Option<Vec<Secret<String>>>,
pub messages: ResponseMessages,
}
+#[derive(Debug, Clone, Deserialize, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct AuthorizedotnetCustomerResponse {
+ customer_profile_id: String,
+ #[serde(default, skip_serializing_if = "Vec::is_empty")]
+ customer_payment_profile_id_list: Vec<String>,
+ #[serde(default, skip_serializing_if = "Vec::is_empty")]
+ customer_shipping_address_id_list: Vec<String>,
+ pub messages: ResponseMessages,
+}
+
+impl<F, T> TryFrom<ResponseRouterData<F, AuthorizedotnetCustomerResponse, T, PaymentsResponseData>>
+ for RouterData<F, T, PaymentsResponseData>
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: ResponseRouterData<F, AuthorizedotnetCustomerResponse, T, PaymentsResponseData>,
+ ) -> Result<Self, Self::Error> {
+ let connector_customer_id = item.response.customer_profile_id.clone();
+ match item.response.messages.result_code {
+ ResultCode::Ok => Ok(Self {
+ response: Ok(PaymentsResponseData::ConnectorCustomerResponse {
+ connector_customer_id,
+ }),
+ ..item.data
+ }),
+ ResultCode::Error => {
+ let error_message = item.response.messages.message.first();
+ let error_code = error_message.map(|error| error.code.clone());
+ let error_code = error_code
+ .unwrap_or_else(|| hyperswitch_interfaces::consts::NO_ERROR_CODE.to_string());
+ let error_reason = item
+ .response
+ .messages
+ .message
+ .iter()
+ .map(|error: &ResponseMessage| error.text.clone())
+ .collect::<Vec<String>>()
+ .join(" ");
+ let response = Err(ErrorResponse {
+ code: error_code,
+ message: item.response.messages.result_code.to_string(),
+ reason: Some(error_reason),
+ status_code: item.http_code,
+ attempt_status: None,
+ connector_transaction_id: None,
+ network_advice_code: None,
+ network_decline_code: None,
+ network_error_message: None,
+ });
+ Ok(Self {
+ response,
+ status: enums::AttemptStatus::Failure,
+ ..item.data
+ })
+ }
+ }
+ }
+}
+
// zero dollar response
impl<F, T>
TryFrom<ResponseRouterData<F, AuthorizedotnetSetupMandateResponse, T, PaymentsResponseData>>
@@ -633,25 +658,26 @@ impl<F, T>
fn try_from(
item: ResponseRouterData<F, AuthorizedotnetSetupMandateResponse, T, PaymentsResponseData>,
) -> Result<Self, Self::Error> {
+ let connector_customer_id = item.data.get_connector_customer_id()?;
match item.response.messages.result_code {
ResultCode::Ok => Ok(Self {
status: enums::AttemptStatus::Charged,
response: Ok(PaymentsResponseData::TransactionResponse {
resource_id: ResponseId::NoResponseId,
redirection_data: Box::new(None),
- mandate_reference: Box::new(item.response.customer_profile_id.map(
- |customer_profile_id| MandateReference {
- connector_mandate_id:
- item.response.customer_payment_profile_id_list.first().map(
- |payment_profile_id| {
- format!("{customer_profile_id}-{payment_profile_id}")
- },
- ),
- payment_method_id: None,
- mandate_metadata: None,
- connector_mandate_request_reference_id: None,
- },
- )),
+ mandate_reference: Box::new(Some(MandateReference {
+ connector_mandate_id: item
+ .response
+ .customer_payment_profile_id_list
+ .first()
+ .or(item.response.customer_payment_profile_id.as_ref())
+ .map(|payment_profile_id| {
+ format!("{connector_customer_id}-{payment_profile_id}")
+ }),
+ payment_method_id: None,
+ mandate_metadata: None,
+ connector_mandate_request_reference_id: None,
+ })),
connector_metadata: None,
network_txn_id: None,
connector_response_reference_id: None,
@@ -661,10 +687,10 @@ impl<F, T>
..item.data
}),
ResultCode::Error => {
- let error_code = match item.response.messages.message.first() {
- Some(first_error_message) => first_error_message.code.clone(),
- None => hyperswitch_interfaces::consts::NO_ERROR_CODE.to_string(),
- };
+ let error_message = item.response.messages.message.first();
+ let error_code = error_message.map(|error| error.code.clone());
+ let error_code = error_code
+ .unwrap_or_else(|| hyperswitch_interfaces::consts::NO_ERROR_CODE.to_string());
let error_reason = item
.response
.messages
@@ -1931,7 +1957,7 @@ impl<F, Req> TryFrom<ResponseRouterData<F, AuthorizedotnetSyncResponse, Req, Pay
}
}
-#[derive(Debug, Default, Deserialize)]
+#[derive(Debug, Default, Deserialize, Serialize)]
pub struct ErrorDetails {
pub code: Option<String>,
#[serde(rename = "type")]
@@ -1940,7 +1966,7 @@ pub struct ErrorDetails {
pub param: Option<String>,
}
-#[derive(Default, Debug, Deserialize)]
+#[derive(Default, Debug, Deserialize, Serialize)]
pub struct AuthorizedotnetErrorResponse {
pub error: ErrorDetails,
}
diff --git a/crates/hyperswitch_connectors/src/default_implementations.rs b/crates/hyperswitch_connectors/src/default_implementations.rs
index 67821e66d7..1ea8dbd33c 100644
--- a/crates/hyperswitch_connectors/src/default_implementations.rs
+++ b/crates/hyperswitch_connectors/src/default_implementations.rs
@@ -1241,7 +1241,6 @@ default_imp_for_create_customer!(
connectors::Amazonpay,
connectors::Archipel,
connectors::Authipay,
- connectors::Authorizedotnet,
connectors::Bambora,
connectors::Bamboraapac,
connectors::Bankofamerica,
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Authorizedotnet.js b/cypress-tests/cypress/e2e/configs/Payment/Authorizedotnet.js
index b468d1de64..d4ff9bf1cb 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Authorizedotnet.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Authorizedotnet.js
@@ -3,6 +3,7 @@ import {
multiUseMandateData,
singleUseMandateData,
} from "./Commons";
+import { generateRandomEmail } from "../../../utils/RequestBodyUtils";
const successfulNo3DSCardDetails = {
card_number: "4111111111111111",
@@ -56,6 +57,7 @@ export const connectorDetails = {
currency: "USD",
customer_acceptance: null,
setup_future_usage: "on_session",
+ email: generateRandomEmail(),
},
Response: {
status: 200,
@@ -71,6 +73,7 @@ export const connectorDetails = {
currency: "USD",
customer_acceptance: null,
setup_future_usage: "off_session",
+ email: generateRandomEmail(),
},
Response: {
status: 200,
@@ -83,6 +86,7 @@ export const connectorDetails = {
Request: {
currency: "USD",
shipping_cost: 50,
+ email: generateRandomEmail(),
},
Response: {
status: 200,
@@ -101,6 +105,7 @@ export const connectorDetails = {
},
customer_acceptance: null,
setup_future_usage: "on_session",
+ email: generateRandomEmail(),
},
Response: {
status: 200,
@@ -122,6 +127,7 @@ export const connectorDetails = {
currency: "USD",
customer_acceptance: null,
setup_future_usage: "on_session",
+ email: generateRandomEmail(),
},
Response: {
status: 200,
@@ -140,6 +146,7 @@ export const connectorDetails = {
currency: "USD",
customer_acceptance: null,
setup_future_usage: "on_session",
+ email: generateRandomEmail(),
},
Response: {
status: 200,
@@ -158,6 +165,7 @@ export const connectorDetails = {
currency: "USD",
customer_acceptance: null,
setup_future_usage: "on_session",
+ email: generateRandomEmail(),
},
Response: {
status: 200,
@@ -176,6 +184,7 @@ export const connectorDetails = {
currency: "USD",
customer_acceptance: null,
setup_future_usage: "on_session",
+ email: generateRandomEmail(),
},
Response: {
status: 200,
@@ -193,6 +202,7 @@ export const connectorDetails = {
},
customer_acceptance: null,
setup_future_usage: "on_session",
+ email: generateRandomEmail(),
},
Response: {
status: 200,
@@ -310,6 +320,7 @@ export const connectorDetails = {
},
currency: "USD",
mandate_data: singleUseMandateData,
+ email: generateRandomEmail(),
},
Response: {
status: 200,
@@ -327,6 +338,7 @@ export const connectorDetails = {
},
currency: "USD",
mandate_data: singleUseMandateData,
+ email: generateRandomEmail(),
},
Response: {
status: 200,
@@ -344,6 +356,7 @@ export const connectorDetails = {
},
currency: "USD",
mandate_data: singleUseMandateData,
+ email: generateRandomEmail(),
},
Response: {
status: 200,
@@ -361,6 +374,7 @@ export const connectorDetails = {
},
currency: "USD",
mandate_data: singleUseMandateData,
+ email: generateRandomEmail(),
},
Response: {
status: 200,
@@ -377,6 +391,7 @@ export const connectorDetails = {
},
currency: "USD",
mandate_data: multiUseMandateData,
+ email: generateRandomEmail(),
},
Response: {
status: 200,
@@ -394,6 +409,7 @@ export const connectorDetails = {
},
currency: "USD",
mandate_data: multiUseMandateData,
+ email: generateRandomEmail(),
},
Response: {
status: 200,
@@ -411,6 +427,7 @@ export const connectorDetails = {
},
currency: "USD",
mandate_data: multiUseMandateData,
+ email: generateRandomEmail(),
},
Response: {
status: 200,
@@ -428,6 +445,7 @@ export const connectorDetails = {
},
currency: "USD",
mandate_data: multiUseMandateData,
+ email: generateRandomEmail(),
},
Response: {
status: 200,
@@ -463,6 +481,7 @@ export const connectorDetails = {
},
currency: "USD",
mandate_data: singleUseMandateData,
+ email: generateRandomEmail(),
},
Response: {
status: 200,
@@ -493,6 +512,7 @@ export const connectorDetails = {
payment_method_data: {
card: successfulNo3DSCardDetails,
},
+ email: generateRandomEmail(),
},
Response: {
status: 200,
@@ -511,6 +531,7 @@ export const connectorDetails = {
currency: "USD",
setup_future_usage: "on_session",
customer_acceptance: customerAcceptance,
+ email: generateRandomEmail(),
},
Response: {
status: 200,
@@ -528,6 +549,7 @@ export const connectorDetails = {
},
setup_future_usage: "off_session",
customer_acceptance: customerAcceptance,
+ email: generateRandomEmail(),
},
Response: {
status: 200,
@@ -545,6 +567,7 @@ export const connectorDetails = {
},
setup_future_usage: "off_session",
customer_acceptance: customerAcceptance,
+ email: generateRandomEmail(),
},
Response: {
status: 200,
@@ -561,6 +584,7 @@ export const connectorDetails = {
},
setup_future_usage: "off_session",
customer_acceptance: customerAcceptance,
+ email: generateRandomEmail(),
},
Response: {
status: 200,
@@ -572,6 +596,7 @@ export const connectorDetails = {
SaveCardConfirmAutoCaptureOffSession: {
Request: {
setup_future_usage: "off_session",
+ email: generateRandomEmail(),
},
Response: {
status: 200,
@@ -583,6 +608,7 @@ export const connectorDetails = {
SaveCardConfirmManualCaptureOffSession: {
Request: {
setup_future_usage: "off_session",
+ email: generateRandomEmail(),
},
Response: {
status: 200,
@@ -600,6 +626,7 @@ export const connectorDetails = {
currency: "USD",
setup_future_usage: "on_session",
customer_acceptance: customerAcceptance,
+ email: generateRandomEmail(),
},
Response: {
status: 200,
@@ -617,6 +644,7 @@ export const connectorDetails = {
currency: "USD",
mandate_data: null,
customer_acceptance: customerAcceptance,
+ email: generateRandomEmail(),
},
Response: {
status: 200,
@@ -634,6 +662,7 @@ export const connectorDetails = {
currency: "USD",
mandate_data: null,
customer_acceptance: customerAcceptance,
+ email: generateRandomEmail(),
},
Response: {
status: 200,
@@ -652,6 +681,7 @@ export const connectorDetails = {
mandate_data: null,
authentication_type: "three_ds",
customer_acceptance: customerAcceptance,
+ email: generateRandomEmail(),
},
Response: {
status: 200,
@@ -669,6 +699,7 @@ export const connectorDetails = {
mandate_data: null,
authentication_type: "three_ds",
customer_acceptance: customerAcceptance,
+ email: generateRandomEmail(),
},
Response: {
status: 200,
diff --git a/cypress-tests/cypress/utils/RequestBodyUtils.js b/cypress-tests/cypress/utils/RequestBodyUtils.js
index 58099a27da..724463a0ef 100644
--- a/cypress-tests/cypress/utils/RequestBodyUtils.js
+++ b/cypress-tests/cypress/utils/RequestBodyUtils.js
@@ -75,6 +75,90 @@ export function validateEnv(baseUrl, keyIdType) {
return prefix;
}
+/**
+ * Generates a random email address for testing purposes.
+ * @returns {string} A randomly generated email address (e.g., "[email protected]").
+ */
+export function generateRandomEmail() {
+ const firstNames = [
+ "alex",
+ "jamie",
+ "taylor",
+ "morgan",
+ "casey",
+ "jordan",
+ "pat",
+ "sam",
+ "chris",
+ "dana",
+ "olivia",
+ "liam",
+ "emma",
+ "noah",
+ "ava",
+ "william",
+ "sophia",
+ "james",
+ "isabella",
+ "oliver",
+ "charlotte",
+ "benjamin",
+ "amelia",
+ "elijah",
+ "mia",
+ "lucas",
+ "harper",
+ "mason",
+ "evelyn",
+ "logan",
+ "abigail",
+ ];
+
+ const lastNames = [
+ "smith",
+ "jones",
+ "williams",
+ "brown",
+ "davis",
+ "miller",
+ "wilson",
+ "moore",
+ "taylor",
+ "lee",
+ "anderson",
+ "thomas",
+ "jackson",
+ "white",
+ "harris",
+ "martin",
+ "garcia",
+ "martinez",
+ "robinson",
+ "clark",
+ "rodriguez",
+ ];
+
+ const domains = [
+ "example.com",
+ "test.com",
+ "demo.org",
+ "sample.net",
+ "testing.io",
+ "cypress.test",
+ "automation.dev",
+ "qa.example",
+ ];
+
+ const randomFirstName =
+ firstNames[Math.floor(Math.random() * firstNames.length)];
+ const randomLastName =
+ lastNames[Math.floor(Math.random() * lastNames.length)];
+ const randomDomain = domains[Math.floor(Math.random() * domains.length)];
+ const randomNumber = Math.floor(Math.random() * 1000);
+
+ return `${randomFirstName}.${randomLastName}${randomNumber}@${randomDomain}`;
+}
+
/**
* Generates a random-ish card holder name from predefined lists.
* @returns {string} A randomly generated full name (e.g., "Jane Smith").
diff --git a/loadtest/config/development.toml b/loadtest/config/development.toml
index bd5c963501..5118bbe1ec 100644
--- a/loadtest/config/development.toml
+++ b/loadtest/config/development.toml
@@ -627,7 +627,7 @@ billwerk = { long_lived_token = false, payment_method = "card" }
globalpay = { long_lived_token = false, payment_method = "card", flow = "mandates" }
[connector_customer]
-connector_list = "adyen,facilitapay,gocardless,hyperswitch_vault,stax,stripe"
+connector_list = "adyen,authorizedotnet,facilitapay,gocardless,hyperswitch_vault,stax,stripe"
payout_connector_list = "nomupay,wise"
[dummy_connector]