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] Audit Connector (#4035)

DEEPANSHU BANSAL7840bdb95f90
diff --git a/config/deployments/production.toml b/config/deployments/production.toml
index 892f11e941..6bfcad3ad5 100644
--- a/config/deployments/production.toml
+++ b/config/deployments/production.toml
@@ -21,7 +21,7 @@ adyen.base_url = "https://{{merchant_endpoint_prefix}}-checkout-live.adyenpaymen
adyen.secondary_base_url = "https://{{merchant_endpoint_prefix}}-pal-live.adyenpayments.com/"
airwallex.base_url = "https://api-demo.airwallex.com/"
applepay.base_url = "https://apple-pay-gateway.apple.com/"
-authorizedotnet.base_url = "https://apitest.authorize.net/xml/v1/request.api"
+authorizedotnet.base_url = "https://api.authorize.net/xml/v1/request.api"
bambora.base_url = "https://api.na.bambora.com"
bankofamerica.base_url = "https://api.merchant-services.bankofamerica.com/"
bitpay.base_url = "https://bitpay.com"
diff --git a/crates/router/src/connector/authorizedotnet.rs b/crates/router/src/connector/authorizedotnet.rs
index 0aba48fa5e..be02b4524f 100644
--- a/crates/router/src/connector/authorizedotnet.rs
+++ b/crates/router/src/connector/authorizedotnet.rs
@@ -685,8 +685,8 @@ impl ConnectorIntegration<api::RSync, types::RefundsData, types::RefundsResponse
let intermediate_response =
bytes::Bytes::copy_from_slice(intermediate_response.0.as_bytes());
- let response: authorizedotnet::AuthorizedotnetSyncResponse = intermediate_response
- .parse_struct("AuthorizedotnetSyncResponse")
+ let response: authorizedotnet::AuthorizedotnetRSyncResponse = intermediate_response
+ .parse_struct("AuthorizedotnetRSyncResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
@@ -872,11 +872,17 @@ impl api::IncomingWebhook for Authorizedotnet {
),
))
}
- _ => Ok(api_models::webhooks::ObjectReferenceId::PaymentId(
- api_models::payments::PaymentIdType::ConnectorTransactionId(
- authorizedotnet::get_trans_id(&details)?,
- ),
- )),
+ authorizedotnet::AuthorizedotnetWebhookEvent::AuthorizationCreated
+ | authorizedotnet::AuthorizedotnetWebhookEvent::PriorAuthCapture
+ | authorizedotnet::AuthorizedotnetWebhookEvent::AuthCapCreated
+ | authorizedotnet::AuthorizedotnetWebhookEvent::CaptureCreated
+ | authorizedotnet::AuthorizedotnetWebhookEvent::VoidCreated => {
+ Ok(api_models::webhooks::ObjectReferenceId::PaymentId(
+ api_models::payments::PaymentIdType::ConnectorTransactionId(
+ authorizedotnet::get_trans_id(&details)?,
+ ),
+ ))
+ }
}
}
diff --git a/crates/router/src/connector/authorizedotnet/transformers.rs b/crates/router/src/connector/authorizedotnet/transformers.rs
index 5d3a7d0054..4a79b179b8 100644
--- a/crates/router/src/connector/authorizedotnet/transformers.rs
+++ b/crates/router/src/connector/authorizedotnet/transformers.rs
@@ -190,44 +190,48 @@ fn get_pm_and_subsequent_auth_detail(
}
}
}
- _ => match item.router_data.request.payment_method_data {
- api::PaymentMethodData::Card(ref ccard) => {
- Ok((
- PaymentDetails::CreditCard(CreditCardDetails {
- card_number: (*ccard.card_number).clone(),
- // expiration_date: format!("{expiry_year}-{expiry_month}").into(),
- expiration_date: ccard.get_expiry_date_as_yyyymm("-"),
- card_code: Some(ccard.card_cvc.clone()),
- }),
- Some(ProcessingOptions {
- is_subsequent_auth: true,
- }),
+ Some(api_models::payments::MandateReferenceId::ConnectorMandateId(_)) | None => {
+ match item.router_data.request.payment_method_data {
+ api::PaymentMethodData::Card(ref ccard) => {
+ Ok((
+ PaymentDetails::CreditCard(CreditCardDetails {
+ card_number: (*ccard.card_number).clone(),
+ // expiration_date: format!("{expiry_year}-{expiry_month}").into(),
+ expiration_date: ccard.get_expiry_date_as_yyyymm("-"),
+ card_code: Some(ccard.card_cvc.clone()),
+ }),
+ Some(ProcessingOptions {
+ is_subsequent_auth: true,
+ }),
+ None,
+ ))
+ }
+ api::PaymentMethodData::Wallet(ref wallet_data) => Ok((
+ get_wallet_data(
+ wallet_data,
+ &item.router_data.request.complete_authorize_url,
+ )?,
+ None,
None,
- ))
+ )),
+ api::PaymentMethodData::CardRedirect(_)
+ | api::PaymentMethodData::PayLater(_)
+ | api::PaymentMethodData::BankRedirect(_)
+ | api::PaymentMethodData::BankDebit(_)
+ | api::PaymentMethodData::BankTransfer(_)
+ | api::PaymentMethodData::Crypto(_)
+ | api::PaymentMethodData::MandatePayment
+ | api::PaymentMethodData::Reward
+ | api::PaymentMethodData::Upi(_)
+ | api::PaymentMethodData::Voucher(_)
+ | api::PaymentMethodData::GiftCard(_)
+ | api::PaymentMethodData::CardToken(_) => {
+ Err(errors::ConnectorError::NotImplemented(
+ utils::get_unimplemented_payment_method_error_message("authorizedotnet"),
+ ))?
+ }
}
- api::PaymentMethodData::Wallet(ref wallet_data) => Ok((
- get_wallet_data(
- wallet_data,
- &item.router_data.request.complete_authorize_url,
- )?,
- None,
- None,
- )),
- api::PaymentMethodData::CardRedirect(_)
- | api::PaymentMethodData::PayLater(_)
- | api::PaymentMethodData::BankRedirect(_)
- | api::PaymentMethodData::BankDebit(_)
- | api::PaymentMethodData::BankTransfer(_)
- | api::PaymentMethodData::Crypto(_)
- | api::PaymentMethodData::MandatePayment
- | api::PaymentMethodData::Reward
- | api::PaymentMethodData::Upi(_)
- | api::PaymentMethodData::Voucher(_)
- | api::PaymentMethodData::GiftCard(_)
- | api::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented(
- utils::get_unimplemented_payment_method_error_message("authorizedotnet"),
- ))?,
- },
+ }
}
}
@@ -382,7 +386,7 @@ impl TryFrom<&AuthorizedotnetRouterData<&types::PaymentsAuthorizeRouterData>>
country: address.country,
});
let transaction_request = TransactionRequest {
- transaction_type: TransactionType::from(item.router_data.request.capture_method),
+ transaction_type: TransactionType::try_from(item.router_data.request.capture_method)?,
amount: item.amount,
currency_code: item.router_data.request.currency.to_string(),
payment: payment_details,
@@ -662,7 +666,7 @@ impl<F, T>
reason: None,
status_code: item.http_code,
attempt_status: None,
- connector_transaction_id: None,
+ connector_transaction_id: Some(transaction_response.transaction_id.clone()),
})
});
let metadata = transaction_response
@@ -740,7 +744,7 @@ impl<F, T>
reason: None,
status_code: item.http_code,
attempt_status: None,
- connector_transaction_id: None,
+ connector_transaction_id: Some(transaction_response.transaction_id.clone()),
})
});
let metadata = transaction_response
@@ -886,7 +890,7 @@ impl<F> TryFrom<types::RefundsResponseRouterData<F, AuthorizedotnetRefundRespons
reason: None,
status_code: item.http_code,
attempt_status: None,
- connector_transaction_id: None,
+ connector_transaction_id: Some(transaction_response.transaction_id.clone()),
})
});
@@ -976,6 +980,15 @@ pub enum SyncStatus {
FDSPendingReview,
}
+#[derive(Debug, Deserialize, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub enum RSyncStatus {
+ RefundSettledSuccessfully,
+ RefundPendingSettlement,
+ Declined,
+ GeneralError,
+}
+
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SyncTransactionResponse {
@@ -990,14 +1003,18 @@ pub struct AuthorizedotnetSyncResponse {
messages: ResponseMessages,
}
-impl From<SyncStatus> for enums::RefundStatus {
- fn from(transaction_status: SyncStatus) -> Self {
- match transaction_status {
- SyncStatus::RefundSettledSuccessfully => Self::Success,
- SyncStatus::RefundPendingSettlement => Self::Pending,
- _ => Self::Failure,
- }
- }
+#[derive(Debug, Deserialize, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct RSyncTransactionResponse {
+ #[serde(rename = "transId")]
+ transaction_id: String,
+ transaction_status: RSyncStatus,
+}
+
+#[derive(Debug, Deserialize, Serialize)]
+pub struct AuthorizedotnetRSyncResponse {
+ transaction: Option<RSyncTransactionResponse>,
+ messages: ResponseMessages,
}
impl From<SyncStatus> for enums::AttemptStatus {
@@ -1017,13 +1034,23 @@ impl From<SyncStatus> for enums::AttemptStatus {
}
}
-impl TryFrom<types::RefundsResponseRouterData<api::RSync, AuthorizedotnetSyncResponse>>
+impl From<RSyncStatus> for enums::RefundStatus {
+ fn from(transaction_status: RSyncStatus) -> Self {
+ match transaction_status {
+ RSyncStatus::RefundSettledSuccessfully => Self::Success,
+ RSyncStatus::RefundPendingSettlement => Self::Pending,
+ RSyncStatus::Declined | RSyncStatus::GeneralError => Self::Failure,
+ }
+ }
+}
+
+impl TryFrom<types::RefundsResponseRouterData<api::RSync, AuthorizedotnetRSyncResponse>>
for types::RefundsRouterData<api::RSync>
{
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
- item: types::RefundsResponseRouterData<api::RSync, AuthorizedotnetSyncResponse>,
+ item: types::RefundsResponseRouterData<api::RSync, AuthorizedotnetRSyncResponse>,
) -> Result<Self, Self::Error> {
match item.response.transaction {
Some(transaction) => {
@@ -1108,11 +1135,24 @@ fn construct_refund_payment_details(masked_number: String) -> PaymentDetails {
})
}
-impl From<Option<enums::CaptureMethod>> for TransactionType {
- fn from(capture_method: Option<enums::CaptureMethod>) -> Self {
+impl TryFrom<Option<enums::CaptureMethod>> for TransactionType {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(capture_method: Option<enums::CaptureMethod>) -> Result<Self, Self::Error> {
match capture_method {
- Some(enums::CaptureMethod::Manual) => Self::Authorization,
- _ => Self::Payment,
+ Some(enums::CaptureMethod::Manual) => Ok(Self::Authorization),
+ Some(enums::CaptureMethod::Automatic) | None => Ok(Self::Payment),
+ Some(enums::CaptureMethod::ManualMultiple) => {
+ Err(utils::construct_not_supported_error_report(
+ enums::CaptureMethod::ManualMultiple,
+ "authorizedotnet",
+ ))?
+ }
+ Some(enums::CaptureMethod::Scheduled) => {
+ Err(utils::construct_not_supported_error_report(
+ enums::CaptureMethod::Scheduled,
+ "authorizedotnet",
+ ))?
+ }
}
}
}
@@ -1359,9 +1399,19 @@ impl TryFrom<&AuthorizedotnetRouterData<&types::PaymentsCompleteAuthorizeRouterD
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?
.payer_id;
let transaction_type = match item.router_data.request.capture_method {
- Some(enums::CaptureMethod::Manual) => TransactionType::ContinueAuthorization,
- _ => TransactionType::ContinueCapture,
- };
+ Some(enums::CaptureMethod::Manual) => Ok(TransactionType::ContinueAuthorization),
+ Some(enums::CaptureMethod::Automatic) | None => Ok(TransactionType::ContinueCapture),
+ Some(enums::CaptureMethod::ManualMultiple) => {
+ Err(errors::ConnectorError::NotSupported {
+ message: enums::CaptureMethod::ManualMultiple.to_string(),
+ connector: "authorizedotnet",
+ })
+ }
+ Some(enums::CaptureMethod::Scheduled) => Err(errors::ConnectorError::NotSupported {
+ message: enums::CaptureMethod::Scheduled.to_string(),
+ connector: "authorizedotnet",
+ }),
+ }?;
let transaction_request = TransactionConfirmRequest {
transaction_type,
payment: PaypalPaymentConfirm {