From 3952c19ff518cd6cf05bb948b1ab554a3ced6240 Mon Sep 17 00:00:00 2001 From: Himanshu-370 Date: Sat, 7 Oct 2023 17:25:38 +0530 Subject: [PATCH 1/7] feat(connector): Introduce "connector_request_reference_id" for Nuvei payments Introduces the "connector_request_reference_id" field in the "RouterData" structure to improve consistency in transmitting payment information to the Nuvei payment gateway. This new ID will replace the usage of "payment_id" and "attempt_id", aligning with the Nuvei API requirements for referencing payments. This change ensures that all payment requests to Nuvei use a unified reference ID, reducing potential confusion and streamlining the integration process. Fixes #2309 --- crates/router/src/connector/nuvei/transformers.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/router/src/connector/nuvei/transformers.rs b/crates/router/src/connector/nuvei/transformers.rs index cf7d480e0c18..2fd1a9c272f1 100644 --- a/crates/router/src/connector/nuvei/transformers.rs +++ b/crates/router/src/connector/nuvei/transformers.rs @@ -384,7 +384,7 @@ impl TryFrom<&types::PaymentsAuthorizeSessionTokenRouterData> for NuveiSessionRe let connector_meta: NuveiAuthType = NuveiAuthType::try_from(&item.connector_auth_type)?; let merchant_id = connector_meta.merchant_id; let merchant_site_id = connector_meta.merchant_site_id; - let client_request_id = item.attempt_id.clone(); + let client_request_id = item.connector_request_reference_id.clone(); let time_stamp = date_time::DateTime::::from(date_time::now()); let merchant_secret = connector_meta.merchant_secret; Ok(Self { @@ -737,7 +737,7 @@ impl amount: utils::to_currency_base_unit(item.request.amount, item.request.currency)?, currency: item.request.currency, connector_auth_type: item.connector_auth_type.clone(), - client_request_id: item.attempt_id.clone(), + client_request_id: item.connector_request_reference_id.clone(), session_token: data.1, capture_method: item.request.capture_method, ..Default::default() @@ -914,7 +914,7 @@ impl TryFrom<(&types::PaymentsCompleteAuthorizeRouterData, String)> for NuveiPay amount: utils::to_currency_base_unit(item.request.amount, item.request.currency)?, currency: item.request.currency, connector_auth_type: item.connector_auth_type.clone(), - client_request_id: item.attempt_id.clone(), + client_request_id: item.connector_request_reference_id.clone(), session_token: data.1, capture_method: item.request.capture_method, ..Default::default() @@ -1018,7 +1018,7 @@ impl TryFrom<&types::PaymentsCaptureRouterData> for NuveiPaymentFlowRequest { type Error = error_stack::Report; fn try_from(item: &types::PaymentsCaptureRouterData) -> Result { Self::try_from(NuveiPaymentRequestData { - client_request_id: item.attempt_id.clone(), + client_request_id: item.connector_request_reference_id.clone(), connector_auth_type: item.connector_auth_type.clone(), amount: utils::to_currency_base_unit( item.request.amount_to_capture, @@ -1034,7 +1034,7 @@ impl TryFrom<&types::RefundExecuteRouterData> for NuveiPaymentFlowRequest { type Error = error_stack::Report; fn try_from(item: &types::RefundExecuteRouterData) -> Result { Self::try_from(NuveiPaymentRequestData { - client_request_id: item.attempt_id.clone(), + client_request_id: item.connector_request_reference_id.clone(), connector_auth_type: item.connector_auth_type.clone(), amount: utils::to_currency_base_unit( item.request.refund_amount, @@ -1061,7 +1061,7 @@ impl TryFrom<&types::PaymentsCancelRouterData> for NuveiPaymentFlowRequest { type Error = error_stack::Report; fn try_from(item: &types::PaymentsCancelRouterData) -> Result { Self::try_from(NuveiPaymentRequestData { - client_request_id: item.attempt_id.clone(), + client_request_id: item.connector_request_reference_id.clone(), connector_auth_type: item.connector_auth_type.clone(), amount: utils::to_currency_base_unit( item.request.get_amount()?, From 4ad784e329acb73df8a7b155a75ee72b52261019 Mon Sep 17 00:00:00 2001 From: Himanshu-370 Date: Wed, 11 Oct 2023 18:33:49 +0530 Subject: [PATCH 2/7] refactor(connector): Remove Default Case Handling for Powertranz payments This change ensures that all payment variants are handled explicitly to Powertranz payment gateway. Fixes #2283 --- .../src/connector/powertranz/transformers.rs | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/crates/router/src/connector/powertranz/transformers.rs b/crates/router/src/connector/powertranz/transformers.rs index 4032f8019b09..4e97132b0b6e 100644 --- a/crates/router/src/connector/powertranz/transformers.rs +++ b/crates/router/src/connector/powertranz/transformers.rs @@ -101,9 +101,24 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for PowertranzPaymentsRequest fn try_from(item: &types::PaymentsAuthorizeRouterData) -> Result { let source = match item.request.payment_method_data.clone() { api::PaymentMethodData::Card(card) => Ok(Source::from(&card)), - _ => Err(errors::ConnectorError::NotImplemented( - "Payment method".to_string(), - )), + 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(_) => Err(errors::ConnectorError::NotSupported { + message: utils::SELECTED_PAYMENT_METHOD.to_string(), + connector: "powertranz", + }) + .into_report(), + // _ => Err(errors::ConnectorError::NotImplemented( + // "Payment method".to_string(), + // )), }?; // let billing_address = get_address_details(&item.address.billing, &item.request.email); // let shipping_address = get_address_details(&item.address.shipping, &item.request.email); From 5e920fdcb644b36d7ae1b23d735e72e018fd4f44 Mon Sep 17 00:00:00 2001 From: Himanshu-370 Date: Wed, 11 Oct 2023 21:09:56 +0530 Subject: [PATCH 3/7] refactor(connector): [PowerTranz] refactor powertranz payments to remove default cases Issue #2283 --- crates/router/src/connector/powertranz/transformers.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/router/src/connector/powertranz/transformers.rs b/crates/router/src/connector/powertranz/transformers.rs index 4e97132b0b6e..dba81b395bf7 100644 --- a/crates/router/src/connector/powertranz/transformers.rs +++ b/crates/router/src/connector/powertranz/transformers.rs @@ -1,4 +1,5 @@ use api_models::payments::Card; +use error_stack::IntoReport; use common_utils::pii::Email; use diesel_models::enums::RefundStatus; use masking::Secret; From 48b33dbff451b1b5daa6ff063fd22afff5e75022 Mon Sep 17 00:00:00 2001 From: Himanshu-370 Date: Wed, 11 Oct 2023 21:17:10 +0530 Subject: [PATCH 4/7] refactor(connector): [PowerTranz] refactor powertranz payments to remove default cases Issue #2283 --- crates/router/src/connector/powertranz/transformers.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/router/src/connector/powertranz/transformers.rs b/crates/router/src/connector/powertranz/transformers.rs index dba81b395bf7..60fdbd0b5849 100644 --- a/crates/router/src/connector/powertranz/transformers.rs +++ b/crates/router/src/connector/powertranz/transformers.rs @@ -1,7 +1,7 @@ use api_models::payments::Card; -use error_stack::IntoReport; use common_utils::pii::Email; use diesel_models::enums::RefundStatus; +use error_stack::IntoReport; use masking::Secret; use serde::{Deserialize, Serialize}; use uuid::Uuid; From 3e39035a06489ca4ab710e6d44ac37fdb570a7dc Mon Sep 17 00:00:00 2001 From: Himanshu-370 Date: Fri, 20 Oct 2023 14:01:14 +0530 Subject: [PATCH 5/7] refactor(connector): [PowerTranz] refactor powertranz payments to remove default cases fixes #2283 --- crates/router/src/connector/powertranz/transformers.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/router/src/connector/powertranz/transformers.rs b/crates/router/src/connector/powertranz/transformers.rs index 60fdbd0b5849..5bbfe0943520 100644 --- a/crates/router/src/connector/powertranz/transformers.rs +++ b/crates/router/src/connector/powertranz/transformers.rs @@ -102,7 +102,8 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for PowertranzPaymentsRequest fn try_from(item: &types::PaymentsAuthorizeRouterData) -> Result { let source = match item.request.payment_method_data.clone() { api::PaymentMethodData::Card(card) => Ok(Source::from(&card)), - api::PaymentMethodData::CardRedirect(_) + api::PaymentMethodData::Wallet(_) + | api::PaymentMethodData::CardRedirect(_) | api::PaymentMethodData::PayLater(_) | api::PaymentMethodData::BankRedirect(_) | api::PaymentMethodData::BankDebit(_) @@ -117,9 +118,6 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for PowertranzPaymentsRequest connector: "powertranz", }) .into_report(), - // _ => Err(errors::ConnectorError::NotImplemented( - // "Payment method".to_string(), - // )), }?; // let billing_address = get_address_details(&item.address.billing, &item.request.email); // let shipping_address = get_address_details(&item.address.shipping, &item.request.email); From c1e54a78bdb47fdd0fecf8038432e82af690a37e Mon Sep 17 00:00:00 2001 From: Himanshu-370 Date: Fri, 20 Oct 2023 14:04:06 +0530 Subject: [PATCH 6/7] refactor(connector): [PowerTranz] refactor powertranz payments to remove default cases fixes #2283 --- crates/router/src/connector/powertranz/transformers.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/router/src/connector/powertranz/transformers.rs b/crates/router/src/connector/powertranz/transformers.rs index 5bbfe0943520..13798d9ef41d 100644 --- a/crates/router/src/connector/powertranz/transformers.rs +++ b/crates/router/src/connector/powertranz/transformers.rs @@ -119,6 +119,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for PowertranzPaymentsRequest }) .into_report(), }?; + // billing and shipping are optional fields and requires state in iso codes, hence commenting it // let billing_address = get_address_details(&item.address.billing, &item.request.email); // let shipping_address = get_address_details(&item.address.shipping, &item.request.email); let (three_d_secure, extended_data) = match item.auth_type { From 4700955ae5f46cbe2cd563caa7ceb820cc3fbf1b Mon Sep 17 00:00:00 2001 From: Himanshu-370 Date: Fri, 20 Oct 2023 14:05:03 +0530 Subject: [PATCH 7/7] refactor(connector): [PowerTranz] refactor powertranz payments to remove default cases fixes #2283 --- crates/router/src/connector/powertranz/transformers.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/router/src/connector/powertranz/transformers.rs b/crates/router/src/connector/powertranz/transformers.rs index 13798d9ef41d..5bbfe0943520 100644 --- a/crates/router/src/connector/powertranz/transformers.rs +++ b/crates/router/src/connector/powertranz/transformers.rs @@ -119,7 +119,6 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for PowertranzPaymentsRequest }) .into_report(), }?; - // billing and shipping are optional fields and requires state in iso codes, hence commenting it // let billing_address = get_address_details(&item.address.billing, &item.request.email); // let shipping_address = get_address_details(&item.address.shipping, &item.request.email); let (three_d_secure, extended_data) = match item.auth_type {