Skip to content

Commit

Permalink
feat(connector): [Zen] Use connector_request_reference_id as Transa…
Browse files Browse the repository at this point in the history
…ction Id to Retrieve Payments (#2052)
  • Loading branch information
Sakilmostak authored Aug 31, 2023
1 parent c804464 commit 5b92c39
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
26 changes: 14 additions & 12 deletions crates/router/src/connector/zen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
))
}

Expand Down Expand Up @@ -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
))
}

Expand Down Expand Up @@ -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)?,
Expand Down
8 changes: 4 additions & 4 deletions crates/router/src/connector/zen/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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()?,
Expand Down

0 comments on commit 5b92c39

Please sign in to comment.