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

revert: fix(connector): [noon] sync with reference_id (#2556)

SamraatBansal13be4d36eac3
diff --git a/crates/router/src/connector/noon.rs b/crates/router/src/connector/noon.rs
index c2637ba93b..5bd7f24954 100644
--- a/crates/router/src/connector/noon.rs
+++ b/crates/router/src/connector/noon.rs
@@ -9,6 +9,7 @@ use error_stack::{IntoReport, ResultExt};
use masking::PeekInterface;
use transformers as noon;
+use super::utils::PaymentsSyncRequestData;
use crate::{
configs::settings,
connector::utils as connector_utils,
@@ -275,19 +276,10 @@ impl ConnectorIntegration<api::PSync, types::PaymentsSyncData, types::PaymentsRe
req: &types::PaymentsSyncRouterData,
connectors: &settings::Connectors,
) -> CustomResult<String, errors::ConnectorError> {
- //Added as a fix for past payments before the given timestamp we can reconcile using payment_id
- let cutoff_timestamp: i64 = 1697023800;
-
- let reference_id = if req.request.payment_attempt_created_at_as_utc < cutoff_timestamp {
- req.payment_id.clone()
- } else {
- req.attempt_id.clone()
- };
-
+ let connector_transaction_id = req.request.get_connector_transaction_id()?;
Ok(format!(
- "{}payment/v1/order/getbyreference/{}",
- self.base_url(connectors),
- reference_id
+ "{}payment/v1/order/{connector_transaction_id}",
+ self.base_url(connectors)
))
}
@@ -577,9 +569,9 @@ impl ConnectorIntegration<api::RSync, types::RefundsData, types::RefundsResponse
connectors: &settings::Connectors,
) -> CustomResult<String, errors::ConnectorError> {
Ok(format!(
- "{}payment/v1/order/getbyreference/{}",
+ "{}payment/v1/order/{}",
self.base_url(connectors),
- req.attempt_id
+ req.request.connector_transaction_id
))
}
diff --git a/crates/router/src/connector/noon/transformers.rs b/crates/router/src/connector/noon/transformers.rs
index 749c8c8dea..5300525b7c 100644
--- a/crates/router/src/connector/noon/transformers.rs
+++ b/crates/router/src/connector/noon/transformers.rs
@@ -4,7 +4,8 @@ use serde::{Deserialize, Serialize};
use crate::{
connector::utils::{
- self as conn_utils, CardData, PaymentsAuthorizeRequestData, RouterData, WalletData,
+ self as conn_utils, CardData, PaymentsAuthorizeRequestData, RefundsRequestData, RouterData,
+ WalletData,
},
core::errors,
services,
@@ -437,7 +438,6 @@ impl<F, T>
pub struct NoonActionTransaction {
amount: String,
currency: diesel_models::enums::Currency,
- transaction_reference: Option<String>,
}
#[derive(Debug, Serialize)]
@@ -466,7 +466,6 @@ impl TryFrom<&types::PaymentsCaptureRouterData> for NoonPaymentsActionRequest {
item.request.currency,
)?,
currency: item.request.currency,
- transaction_reference: None,
};
Ok(Self {
api_operation: NoonApiOperations::Capture,
@@ -508,7 +507,6 @@ impl<F> TryFrom<&types::RefundsRouterData<F>> for NoonPaymentsActionRequest {
item.request.currency,
)?,
currency: item.request.currency,
- transaction_reference: Some(item.request.refund_id.clone()),
};
Ok(Self {
api_operation: NoonApiOperations::Refund,
@@ -572,11 +570,9 @@ impl TryFrom<types::RefundsResponseRouterData<api::Execute, RefundResponse>>
}
#[derive(Default, Debug, Deserialize)]
-#[serde(rename_all = "camelCase")]
pub struct NoonRefundResponseTransactions {
id: String,
status: RefundStatus,
- transaction_reference: Option<String>,
}
#[derive(Default, Debug, Deserialize)]
@@ -596,19 +592,13 @@ impl TryFrom<types::RefundsResponseRouterData<api::RSync, RefundSyncResponse>>
fn try_from(
item: types::RefundsResponseRouterData<api::RSync, RefundSyncResponse>,
) -> Result<Self, Self::Error> {
+ let connector_refund_id = item.data.request.get_connector_refund_id()?;
let noon_transaction: &NoonRefundResponseTransactions = item
.response
.result
.transactions
.iter()
- .find(|transaction| {
- transaction
- .transaction_reference
- .clone()
- .map_or(false, |transaction_instance| {
- transaction_instance == item.data.request.refund_id
- })
- })
+ .find(|transaction| transaction.id == connector_refund_id)
.ok_or(errors::ConnectorError::ResponseHandlingFailed)?;
Ok(Self {
diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs
index d19460127b..f93b2e9ff4 100644
--- a/crates/router/src/core/payments/transformers.rs
+++ b/crates/router/src/core/payments/transformers.rs
@@ -1051,11 +1051,6 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsSyncData
),
None => types::SyncRequestType::SinglePaymentSync,
},
- payment_attempt_created_at_as_utc: payment_data
- .payment_attempt
- .created_at
- .assume_utc()
- .unix_timestamp(),
})
}
}
diff --git a/crates/router/src/types.rs b/crates/router/src/types.rs
index c3da5564b5..48e3697c6b 100644
--- a/crates/router/src/types.rs
+++ b/crates/router/src/types.rs
@@ -476,9 +476,6 @@ pub struct PaymentsSyncData {
pub connector_meta: Option<serde_json::Value>,
pub sync_type: SyncRequestType,
pub mandate_id: Option<api_models::payments::MandateIds>,
- //This is being added as a temporary fix, will be deprecated before or by v1.65.0
- // #2628
- pub payment_attempt_created_at_as_utc: i64,
}
#[derive(Debug, Default, Clone)]
diff --git a/crates/router/tests/connectors/bambora.rs b/crates/router/tests/connectors/bambora.rs
index 73e75b7136..5638214202 100644
--- a/crates/router/tests/connectors/bambora.rs
+++ b/crates/router/tests/connectors/bambora.rs
@@ -108,7 +108,6 @@ async fn should_sync_authorized_payment() {
capture_method: Some(diesel_models::enums::CaptureMethod::Manual),
sync_type: types::SyncRequestType::SinglePaymentSync,
connector_meta: None,
- payment_attempt_created_at_as_utc: 0,
}),
None,
)
@@ -223,7 +222,6 @@ async fn should_sync_auto_captured_payment() {
capture_method: Some(enums::CaptureMethod::Automatic),
sync_type: types::SyncRequestType::SinglePaymentSync,
connector_meta: None,
- payment_attempt_created_at_as_utc: 0,
}),
None,
)
diff --git a/crates/router/tests/connectors/forte.rs b/crates/router/tests/connectors/forte.rs
index 8cce94dc85..703b8900b6 100644
--- a/crates/router/tests/connectors/forte.rs
+++ b/crates/router/tests/connectors/forte.rs
@@ -153,7 +153,6 @@ async fn should_sync_authorized_payment() {
sync_type: types::SyncRequestType::SinglePaymentSync,
connector_meta: None,
mandate_id: None,
- payment_attempt_created_at_as_utc: 0,
}),
get_default_payment_info(),
)
diff --git a/crates/router/tests/connectors/nexinets.rs b/crates/router/tests/connectors/nexinets.rs
index 5c95b1f41a..f9b8affb06 100644
--- a/crates/router/tests/connectors/nexinets.rs
+++ b/crates/router/tests/connectors/nexinets.rs
@@ -123,7 +123,6 @@ async fn should_sync_authorized_payment() {
sync_type: types::SyncRequestType::SinglePaymentSync,
connector_meta,
mandate_id: None,
- payment_attempt_created_at_as_utc: 0,
}),
None,
)
diff --git a/crates/router/tests/connectors/paypal.rs b/crates/router/tests/connectors/paypal.rs
index 5fe37c374a..e9df655669 100644
--- a/crates/router/tests/connectors/paypal.rs
+++ b/crates/router/tests/connectors/paypal.rs
@@ -140,7 +140,6 @@ async fn should_sync_authorized_payment() {
capture_method: None,
sync_type: types::SyncRequestType::SinglePaymentSync,
connector_meta,
- payment_attempt_created_at_as_utc: 0,
}),
get_default_payment_info(),
)
@@ -337,7 +336,6 @@ async fn should_sync_auto_captured_payment() {
capture_method: Some(enums::CaptureMethod::Automatic),
sync_type: types::SyncRequestType::SinglePaymentSync,
connector_meta,
- payment_attempt_created_at_as_utc: 0,
}),
get_default_payment_info(),
)
diff --git a/crates/router/tests/connectors/utils.rs b/crates/router/tests/connectors/utils.rs
index f88848d379..7d600d98d3 100644
--- a/crates/router/tests/connectors/utils.rs
+++ b/crates/router/tests/connectors/utils.rs
@@ -938,7 +938,6 @@ impl Default for PaymentSyncType {
capture_method: None,
sync_type: types::SyncRequestType::SinglePaymentSync,
connector_meta: None,
- payment_attempt_created_at_as_utc: 0,
};
Self(data)
}
diff --git a/crates/router/tests/connectors/zen.rs b/crates/router/tests/connectors/zen.rs
index a994c290dd..ca71fd0c62 100644
--- a/crates/router/tests/connectors/zen.rs
+++ b/crates/router/tests/connectors/zen.rs
@@ -102,7 +102,6 @@ async fn should_sync_authorized_payment() {
sync_type: types::SyncRequestType::SinglePaymentSync,
connector_meta: None,
mandate_id: None,
- payment_attempt_created_at_as_utc: 0,
}),
None,
)
@@ -217,7 +216,6 @@ async fn should_sync_auto_captured_payment() {
sync_type: types::SyncRequestType::SinglePaymentSync,
connector_meta: None,
mandate_id: None,
- payment_attempt_created_at_as_utc: 0,
}),
None,
)