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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
fix(connector): [Tsys] Update endpoint and unit tests (#1730)
SamraatBansal8223f8b29a3b
diff --git a/crates/router/src/connector/tsys.rs b/crates/router/src/connector/tsys.rsindex 02a19395ee..222e20926d 100644--- a/crates/router/src/connector/tsys.rs+++ b/crates/router/src/connector/tsys.rs@@ -197,7 +197,7 @@ impl ConnectorIntegration<api::PSync, types::PaymentsSyncData, types::PaymentsReconnectors: &settings::Connectors,) -> CustomResult<String, errors::ConnectorError> {Ok(format!(- "{}servlets/Transnox_API_server",+ "{}servlets/transnox_api_server",self.base_url(connectors)))}@@ -276,7 +276,7 @@ impl ConnectorIntegration<api::Capture, types::PaymentsCaptureData, types::Paymeconnectors: &settings::Connectors,) -> CustomResult<String, errors::ConnectorError> {Ok(format!(- "{}servlets/Transnox_API_server",+ "{}servlets/transnox_api_server",self.base_url(connectors)))}@@ -357,7 +357,7 @@ impl ConnectorIntegration<api::Void, types::PaymentsCancelData, types::PaymentsRconnectors: &settings::Connectors,) -> CustomResult<String, errors::ConnectorError> {Ok(format!(- "{}servlets/Transnox_API_server",+ "{}servlets/transnox_api_server",self.base_url(connectors),))}@@ -431,7 +431,7 @@ impl ConnectorIntegration<api::Execute, types::RefundsData, types::RefundsResponconnectors: &settings::Connectors,) -> CustomResult<String, errors::ConnectorError> {Ok(format!(- "{}servlets/Transnox_API_server",+ "{}servlets/transnox_api_server",self.base_url(connectors)))}@@ -509,7 +509,7 @@ impl ConnectorIntegration<api::RSync, types::RefundsData, types::RefundsResponseconnectors: &settings::Connectors,) -> CustomResult<String, errors::ConnectorError> {Ok(format!(- "{}servlets/Transnox_API_server",+ "{}servlets/transnox_api_server",self.base_url(connectors),))}diff --git a/crates/router/src/connector/tsys/transformers.rs b/crates/router/src/connector/tsys/transformers.rsindex fd555e6768..536f6d02ef 100644--- a/crates/router/src/connector/tsys/transformers.rs+++ b/crates/router/src/connector/tsys/transformers.rs@@ -464,6 +464,7 @@ impl From<TsysTransactionDetails> for enums::RefundStatus {fn from(item: TsysTransactionDetails) -> Self {match item.transaction_status {TsysTransactionStatus::Approved => Self::Pending,+ //Connector calls refunds as VoidTsysTransactionStatus::Void => Self::Success,TsysTransactionStatus::Declined => Self::Failure,}diff --git a/crates/router/tests/connectors/tsys.rs b/crates/router/tests/connectors/tsys.rsindex d744fedd05..51112b4724 100644--- a/crates/router/tests/connectors/tsys.rs+++ b/crates/router/tests/connectors/tsys.rs@@ -1,4 +1,4 @@-use std::str::FromStr;+use std::{str::FromStr, time::Duration};use cards::CardNumber;use masking::Secret;@@ -41,8 +41,9 @@ fn get_default_payment_info() -> Option<utils::PaymentInfo> {None}-fn payment_method_details() -> Option<types::PaymentsAuthorizeData> {+fn payment_method_details(amount: i64) -> Option<types::PaymentsAuthorizeData> {Some(types::PaymentsAuthorizeData {+ amount,payment_method_data: types::api::PaymentMethodData::Card(api::Card {card_number: CardNumber::from_str("4111111111111111").unwrap(),..utils::CCardType::default().0@@ -56,7 +57,7 @@ fn payment_method_details() -> Option<types::PaymentsAuthorizeData> {#[actix_web::test]async fn should_only_authorize_payment() {let response = CONNECTOR- .authorize_payment(payment_method_details(), get_default_payment_info())+ .authorize_payment(payment_method_details(101), get_default_payment_info()).await.expect("Authorize payment response");assert_eq!(response.status, enums::AttemptStatus::Authorized);@@ -66,7 +67,11 @@ async fn should_only_authorize_payment() {#[actix_web::test]async fn should_capture_authorized_payment() {let response = CONNECTOR- .authorize_and_capture_payment(payment_method_details(), None, get_default_payment_info())+ .authorize_and_capture_payment(+ payment_method_details(100),+ None,+ get_default_payment_info(),+ ).await.expect("Capture payment response");assert_eq!(response.status, enums::AttemptStatus::Charged);@@ -77,7 +82,7 @@ async fn should_capture_authorized_payment() {async fn should_partially_capture_authorized_payment() {let response = CONNECTOR.authorize_and_capture_payment(- payment_method_details(),+ payment_method_details(130),Some(types::PaymentsCaptureData {amount_to_capture: 50,..utils::PaymentCaptureType::default().0@@ -93,7 +98,7 @@ async fn should_partially_capture_authorized_payment() {#[actix_web::test]async fn should_sync_authorized_payment() {let authorize_response = CONNECTOR- .authorize_payment(payment_method_details(), get_default_payment_info())+ .authorize_payment(payment_method_details(140), get_default_payment_info()).await.expect("Authorize payment response");let txn_id = utils::get_connector_transaction_id(authorize_response.response);@@ -118,7 +123,7 @@ async fn should_sync_authorized_payment() {async fn should_void_authorized_payment() {let response = CONNECTOR.authorize_and_void_payment(- payment_method_details(),+ payment_method_details(150),Some(types::PaymentsCancelData {connector_transaction_id: String::from(""),cancellation_reason: Some("requested_by_customer".to_string()),@@ -136,9 +141,15 @@ async fn should_void_authorized_payment() {async fn should_refund_manually_captured_payment() {let response = CONNECTOR.capture_payment_and_refund(- payment_method_details(),- None,- None,+ payment_method_details(160),+ Some(types::PaymentsCaptureData {+ amount_to_capture: 160,+ ..utils::PaymentCaptureType::default().0+ }),+ Some(types::RefundsData {+ refund_amount: 160,+ ..utils::PaymentRefundType::default().0+ }),get_default_payment_info(),).await@@ -154,8 +165,11 @@ async fn should_refund_manually_captured_payment() {async fn should_partially_refund_manually_captured_payment() {let response = CONNECTOR.capture_payment_and_refund(- payment_method_details(),- None,+ payment_method_details(170),+ Some(types::PaymentsCaptureData {+ amount_to_capture: 170,+ ..utils::PaymentCaptureType::default().0+ }),Some(types::RefundsData {refund_amount: 50,..utils::PaymentRefundType::default().0@@ -175,13 +189,20 @@ async fn should_partially_refund_manually_captured_payment() {async fn should_sync_manually_captured_refund() {let refund_response = CONNECTOR.capture_payment_and_refund(- payment_method_details(),- None,- None,+ payment_method_details(180),+ Some(types::PaymentsCaptureData {+ amount_to_capture: 180,+ ..utils::PaymentCaptureType::default().0+ }),+ Some(types::RefundsData {+ refund_amount: 180,+ ..utils::PaymentRefundType::default().0+ }),get_default_payment_info(),).await.unwrap();+ tokio::time::sleep(Duration::from_secs(10)).await;let response = CONNECTOR.rsync_retry_till_status_matches(enums::RefundStatus::Success,@@ -201,7 +222,7 @@ async fn should_sync_manually_captured_refund() {#[actix_web::test]async fn should_make_payment() {let authorize_response = CONNECTOR- .make_payment(payment_method_details(), get_default_payment_info())+ .make_payment(payment_method_details(200), get_default_payment_info()).await.unwrap();assert_eq!(authorize_response.status, enums::AttemptStatus::Charged);@@ -211,7 +232,7 @@ async fn should_make_payment() {#[actix_web::test]async fn should_sync_auto_captured_payment() {let authorize_response = CONNECTOR- .make_payment(payment_method_details(), get_default_payment_info())+ .make_payment(payment_method_details(210), get_default_payment_info()).await.unwrap();assert_eq!(authorize_response.status, enums::AttemptStatus::Charged);@@ -238,7 +259,14 @@ async fn should_sync_auto_captured_payment() {#[actix_web::test]async fn should_refund_auto_captured_payment() {let response = CONNECTOR- .make_payment_and_refund(payment_method_details(), None, get_default_payment_info())+ .make_payment_and_refund(+ payment_method_details(220),+ Some(types::RefundsData {+ refund_amount: 220,+ ..utils::PaymentRefundType::default().0+ }),+ get_default_payment_info(),+ ).await.unwrap();assert_eq!(@@ -252,7 +280,7 @@ async fn should_refund_auto_captured_payment() {async fn should_partially_refund_succeeded_payment() {let refund_response = CONNECTOR.make_payment_and_refund(- payment_method_details(),+ payment_method_details(230),Some(types::RefundsData {refund_amount: 50,..utils::PaymentRefundType::default().0@@ -272,7 +300,7 @@ async fn should_partially_refund_succeeded_payment() {async fn should_refund_succeeded_payment_multiple_times() {CONNECTOR.make_payment_and_multiple_refund(- payment_method_details(),+ payment_method_details(250),Some(types::RefundsData {refund_amount: 50,..utils::PaymentRefundType::default().0@@ -286,9 +314,14 @@ async fn should_refund_succeeded_payment_multiple_times() {#[actix_web::test]async fn should_sync_refund() {let refund_response = CONNECTOR- .make_payment_and_refund(payment_method_details(), None, get_default_payment_info())+ .make_payment_and_refund(+ payment_method_details(100),+ None,+ get_default_payment_info(),+ ).await.unwrap();+ tokio::time::sleep(Duration::from_secs(10)).await;let response = CONNECTOR.rsync_retry_till_status_matches(enums::RefundStatus::Success,@@ -376,7 +409,7 @@ async fn should_fail_payment_for_incorrect_expiry_year() {#[ignore = "Connector Refunds the payment on Void call for Auto Captured Payment"]async fn should_fail_void_payment_for_auto_capture() {let authorize_response = CONNECTOR- .make_payment(payment_method_details(), get_default_payment_info())+ .make_payment(payment_method_details(500), get_default_payment_info()).await.unwrap();assert_eq!(authorize_response.status, enums::AttemptStatus::Charged);@@ -410,7 +443,7 @@ async fn should_fail_capture_for_invalid_payment() {async fn should_fail_for_refund_amount_higher_than_payment_amount() {let response = CONNECTOR.make_payment_and_refund(- payment_method_details(),+ payment_method_details(100),Some(types::RefundsData {refund_amount: 150,..utils::PaymentRefundType::default().0