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): [Zen] Use `connector_request_reference_id` as Transaction Id to Retrieve Payments (#2052)

Sakil Mostak5b92c39470e5
diff --git a/crates/router/src/connector/zen.rs b/crates/router/src/connector/zen.rs
index 7e64b00b5d..49bed4921d 100644
--- a/crates/router/src/connector/zen.rs
+++ b/crates/router/src/connector/zen.rs
@@ -9,7 +9,6 @@ use transformers as zen;
use uuid::Uuid;
use self::transformers::{ZenPaymentStatus, ZenWebhookTxnType};
-use super::utils::RefundsRequestData;
use crate::{
configs::settings,
consts,
@@ -128,7 +127,15 @@ impl ConnectorCommon for Zen {
}
}
-impl ConnectorValidation for Zen {}
+impl ConnectorValidation for Zen {
+ fn validate_psync_reference_id(
+ &self,
+ _data: &types::PaymentsSyncRouterData,
+ ) -> CustomResult<(), errors::ConnectorError> {
+ // since we can make psync call with our reference_id, having connector_transaction_id is not an mandatory criteria
+ Ok(())
+ }
+}
impl ConnectorIntegration<api::Session, types::PaymentsSessionData, types::PaymentsResponseData>
for Zen
@@ -279,15 +286,10 @@ impl ConnectorIntegration<api::PSync, types::PaymentsSyncData, types::PaymentsRe
req: &types::PaymentsSyncRouterData,
connectors: &settings::Connectors,
) -> CustomResult<String, errors::ConnectorError> {
- let payment_id = req
- .request
- .connector_transaction_id
- .get_connector_transaction_id()
- .change_context(errors::ConnectorError::MissingConnectorTransactionID)?;
-
Ok(format!(
- "{}v1/transactions/{payment_id}",
+ "{}v1/transactions/merchant/{}",
self.base_url(connectors),
+ req.attempt_id,
))
}
@@ -469,9 +471,9 @@ impl ConnectorIntegration<api::RSync, types::RefundsData, types::RefundsResponse
connectors: &settings::Connectors,
) -> CustomResult<String, errors::ConnectorError> {
Ok(format!(
- "{}v1/transactions/{}",
+ "{}v1/transactions/merchant/{}",
self.base_url(connectors),
- req.request.get_connector_refund_id()?
+ req.request.refund_id
))
}
@@ -606,7 +608,7 @@ impl api::IncomingWebhook for Zen {
),
),
ZenWebhookTxnType::TrtRefund => api_models::webhooks::ObjectReferenceId::RefundId(
- api_models::webhooks::RefundIdType::ConnectorRefundId(webhook_body.transaction_id),
+ api_models::webhooks::RefundIdType::RefundId(webhook_body.merchant_transaction_id),
),
ZenWebhookTxnType::Unknown => Err(errors::ConnectorError::WebhookReferenceIdNotFound)?,
diff --git a/crates/router/src/connector/zen/transformers.rs b/crates/router/src/connector/zen/transformers.rs
index 851fb2754f..5d6f63acf0 100644
--- a/crates/router/src/connector/zen/transformers.rs
+++ b/crates/router/src/connector/zen/transformers.rs
@@ -195,7 +195,7 @@ impl TryFrom<(&types::PaymentsAuthorizeRouterData, &Card)> for ZenPaymentsReques
return_verify_url: item.request.router_return_url.clone(),
}));
Ok(Self::ApiRequest(Box::new(ApiRequest {
- merchant_transaction_id: item.attempt_id.clone(),
+ merchant_transaction_id: item.connector_request_reference_id.clone(),
payment_channel: ZenPaymentChannels::PclCard,
currency: item.request.currency,
payment_specific_data,
@@ -258,7 +258,7 @@ impl
)?,
};
Ok(Self::ApiRequest(Box::new(ApiRequest {
- merchant_transaction_id: item.attempt_id.clone(),
+ merchant_transaction_id: item.connector_request_reference_id.clone(),
payment_channel,
currency: item.request.currency,
payment_specific_data,
@@ -319,7 +319,7 @@ impl
}
};
Ok(Self::ApiRequest(Box::new(ApiRequest {
- merchant_transaction_id: item.attempt_id.clone(),
+ merchant_transaction_id: item.connector_request_reference_id.clone(),
payment_channel,
currency: item.request.currency,
payment_specific_data,
@@ -476,7 +476,7 @@ impl
.clone()
.ok_or(errors::ConnectorError::RequestEncodingFailed)?;
let mut checkout_request = CheckoutRequest {
- merchant_transaction_id: item.attempt_id.clone(),
+ merchant_transaction_id: item.connector_request_reference_id.clone(),
specified_payment_channel,
currency: item.request.currency,
custom_ipn_url: item.request.get_webhook_url()?,