From 1911011046855151bc5de610eed59b46a25d73e8 Mon Sep 17 00:00:00 2001 From: Suraj Date: Tue, 3 Oct 2023 20:41:31 +0530 Subject: [PATCH 01/11] Add currency conversion in Worldpay.rs --- crates/router/src/connector/worldpay.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/router/src/connector/worldpay.rs b/crates/router/src/connector/worldpay.rs index 20185cf81abe..121e1a9aa62b 100644 --- a/crates/router/src/connector/worldpay.rs +++ b/crates/router/src/connector/worldpay.rs @@ -56,6 +56,10 @@ impl ConnectorCommon for Worldpay { "worldpay" } + fn get_currency_unit(&self) -> api::CurrencyUnit { + api::CurrencyUnit::Minor + } + fn common_get_content_type(&self) -> &'static str { "application/vnd.worldpay.payments-v6+json" } @@ -424,7 +428,14 @@ impl ConnectorIntegration CustomResult, errors::ConnectorError> { - let connector_request = WorldpayPaymentsRequest::try_from(req)?; + let connector_router_data = worldpay::WorldpayRouterData::try_from(( + &self.get_currency_unit(), + req.request.currency, + req.request.amount, + req, + ))?; + // let connector_request = WorldpayPaymentsRequest::try_from(req)?; + let connector_request = WorldpayPaymentsRequest::try_from(&connector_router_data)?; let worldpay_payment_request = types::RequestBody::log_and_get_request_body( &connector_request, ext_traits::Encode::::encode_to_string_of_json, From e448bf9b2a2793a4bc953fbf9804c29631dd487a Mon Sep 17 00:00:00 2001 From: Suraj Date: Tue, 3 Oct 2023 20:59:09 +0530 Subject: [PATCH 02/11] Update Worldpay/transformers.rs file --- .../src/connector/worldpay/transformers.rs | 39 ++++++++++++++++++- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/crates/router/src/connector/worldpay/transformers.rs b/crates/router/src/connector/worldpay/transformers.rs index 3d467f4198f7..55590ba8fe86 100644 --- a/crates/router/src/connector/worldpay/transformers.rs +++ b/crates/router/src/connector/worldpay/transformers.rs @@ -12,6 +12,34 @@ use crate::{ types::{self, api}, }; +#[derive(Debug,Serialize)] +pub struct WorldpayRouterData{ + amount: i64, + router_data: T, +} +impl + TryFrom<( + &types::api::CurrencyUnit, + types::storage::enums::Currency, + i64, + T, + )> for WorldpayRouterData +{ + type Error = error_stack::Report; + fn try_from( + (_currency_unit, _currency, amount, router_data): ( + &types::api::CurrencyUnit, + types::storage::enums::Currency, + i64, + T, + ), + ) -> Result { + Ok(Self { + amount, + router_data, + }) + } +} fn fetch_payment_instrument( payment_method: api::PaymentMethodData, ) -> CustomResult { @@ -100,9 +128,15 @@ fn fetch_payment_instrument( } } -impl TryFrom<&types::PaymentsAuthorizeRouterData> for WorldpayPaymentsRequest { +impl TryFrom<&WorldpayRouterData<&types::PaymentsAuthorizeRouterData>> for WorldpayPaymentsRequest { type Error = error_stack::Report; - fn try_from(item: &types::PaymentsAuthorizeRouterData) -> Result { + + fn try_from(item: &WorldpayRouterData<&types::PaymentsAuthorizeRouterData>,) -> Result { + let request = &item.router_data.request; + match + request.order_details.clone(){ + Some(order_details)=> + Ok(Self { instruction: Instruction { value: PaymentValue { @@ -128,6 +162,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for WorldpayPaymentsRequest { }) } } +} pub struct WorldpayAuthType { pub(super) api_key: Secret, From 850cfcf5530b9a746e36f6b49d4e34ffe6014ff5 Mon Sep 17 00:00:00 2001 From: Suraj Date: Wed, 4 Oct 2023 00:35:08 +0530 Subject: [PATCH 03/11] Solve amount issue --- crates/router/src/connector/worldpay.rs | 2 +- .../src/connector/worldpay/transformers.rs | 58 ++++++++++--------- package-lock.json | 36 ++++++++++++ package.json | 4 ++ 4 files changed, 71 insertions(+), 29 deletions(-) diff --git a/crates/router/src/connector/worldpay.rs b/crates/router/src/connector/worldpay.rs index 121e1a9aa62b..4d22a5c56f41 100644 --- a/crates/router/src/connector/worldpay.rs +++ b/crates/router/src/connector/worldpay.rs @@ -58,7 +58,7 @@ impl ConnectorCommon for Worldpay { fn get_currency_unit(&self) -> api::CurrencyUnit { api::CurrencyUnit::Minor - } + } fn common_get_content_type(&self) -> &'static str { "application/vnd.worldpay.payments-v6+json" diff --git a/crates/router/src/connector/worldpay/transformers.rs b/crates/router/src/connector/worldpay/transformers.rs index 55590ba8fe86..496f24c85475 100644 --- a/crates/router/src/connector/worldpay/transformers.rs +++ b/crates/router/src/connector/worldpay/transformers.rs @@ -12,8 +12,8 @@ use crate::{ types::{self, api}, }; -#[derive(Debug,Serialize)] -pub struct WorldpayRouterData{ +#[derive(Debug, Serialize)] +pub struct WorldpayRouterData { amount: i64, router_data: T, } @@ -131,38 +131,40 @@ fn fetch_payment_instrument( impl TryFrom<&WorldpayRouterData<&types::PaymentsAuthorizeRouterData>> for WorldpayPaymentsRequest { type Error = error_stack::Report; - fn try_from(item: &WorldpayRouterData<&types::PaymentsAuthorizeRouterData>,) -> Result { + fn try_from( + item: &WorldpayRouterData<&types::PaymentsAuthorizeRouterData>, + ) -> Result { let request = &item.router_data.request; - match - request.order_details.clone(){ - Some(order_details)=> - - Ok(Self { - instruction: Instruction { - value: PaymentValue { - amount: item.request.amount, - currency: item.request.currency.to_string(), + match request.order_details.clone() { + Some(order_details) => Ok(Self { + instruction: Instruction { + value: PaymentValue { + amount: item.request.amount, + currency: item.request.currency.to_string(), + }, + narrative: InstructionNarrative { + line1: item.merchant_id.clone().replace('_', "-"), + ..Default::default() + }, + payment_instrument: fetch_payment_instrument( + item.request.payment_method_data.clone(), + )?, + debt_repayment: None, }, - narrative: InstructionNarrative { - line1: item.merchant_id.clone().replace('_', "-"), + merchant: Merchant { + entity: item.attempt_id.clone().replace('_', "-"), ..Default::default() }, - payment_instrument: fetch_payment_instrument( - item.request.payment_method_data.clone(), - )?, - debt_repayment: None, - }, - merchant: Merchant { - entity: item.attempt_id.clone().replace('_', "-"), - ..Default::default() - }, - transaction_reference: item.attempt_id.clone(), - channel: None, - customer: None, - }) + transaction_reference: item.attempt_id.clone(), + channel: None, + customer: None, + }), + None => Err(error_stack::Report::new( + errors::ConnectorError::CustomError("order_details is None"), + )), + } } } -} pub struct WorldpayAuthType { pub(super) api_key: Secret, diff --git a/package-lock.json b/package-lock.json index 9efb15d87eaa..2a77531a0da3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,6 +7,10 @@ "": { "name": "hyperswitch", "version": "0.0.0", + "dependencies": { + "cargo": "^0.8.0", + "rust": "^0.1.6" + }, "devDependencies": { "newman": "git+ssh://git@github.com:knutties/newman.git#37708c1fbf6b36240ac796a42dc5a7b435990764" } @@ -172,6 +176,11 @@ "base64-js": "^1.1.2" } }, + "node_modules/cargo": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/cargo/-/cargo-0.8.0.tgz", + "integrity": "sha512-Fl49HZ8CAs4++TjtwcoZgwyq2ZQUiFVGQ3byyKKUilNk65iuBRDjpCGH/AUORvAODaVVbGbKyFCa67tlDG3p4g==" + }, "node_modules/caseless": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", @@ -691,6 +700,11 @@ "verror": "1.10.0" } }, + "node_modules/keypress": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/keypress/-/keypress-0.1.0.tgz", + "integrity": "sha512-x0yf9PL/nx9Nw9oLL8ZVErFAk85/lslwEP7Vz7s5SI1ODXZIgit3C5qyWjw4DxOuO/3Hb4866SQh28a1V1d+WA==" + }, "node_modules/liquid-json": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/liquid-json/-/liquid-json-0.3.1.tgz", @@ -1071,6 +1085,28 @@ "node": ">=6" } }, + "node_modules/rust": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/rust/-/rust-0.1.6.tgz", + "integrity": "sha512-nE0vjFJPvvQkqA/4npktgKHvKWwr3u5a3fe70vAf0kBooQR2qGrn0LCdoPY44mxfYdmWJS5c4VqNvKhtLFKtzg==", + "dependencies": { + "commander": "~1.1.1" + }, + "bin": { + "rust": "rust" + } + }, + "node_modules/rust/node_modules/commander": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-1.1.1.tgz", + "integrity": "sha512-71Rod2AhcH3JhkBikVpNd0pA+fWsmAaVoti6OR38T76chA7vE3pSerS0Jor4wDw+tOueD2zLVvFOw5H0Rcj7rA==", + "dependencies": { + "keypress": "0.1.x" + }, + "engines": { + "node": ">= 0.6.x" + } + }, "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", diff --git a/package.json b/package.json index c13e70dafee5..602368612cce 100644 --- a/package.json +++ b/package.json @@ -5,5 +5,9 @@ "description": "This is just to run automated newman tests for this service", "devDependencies": { "newman": "git+ssh://git@github.com:knutties/newman.git#37708c1fbf6b36240ac796a42dc5a7b435990764" + }, + "dependencies": { + "cargo": "^0.8.0", + "rust": "^0.1.6" } } From 9180f7474b29d5b9f3e1f61ad552ed3e55c4c0d5 Mon Sep 17 00:00:00 2001 From: Suraj Date: Fri, 6 Oct 2023 01:07:47 +0530 Subject: [PATCH 04/11] remove commented line --- crates/router/src/connector/worldpay.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/router/src/connector/worldpay.rs b/crates/router/src/connector/worldpay.rs index 4d22a5c56f41..32fde5f78ddc 100644 --- a/crates/router/src/connector/worldpay.rs +++ b/crates/router/src/connector/worldpay.rs @@ -434,7 +434,6 @@ impl ConnectorIntegration Date: Fri, 6 Oct 2023 01:08:29 +0530 Subject: [PATCH 05/11] modify transformers file --- .../src/connector/worldpay/transformers.rs | 60 +++++++++---------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/crates/router/src/connector/worldpay/transformers.rs b/crates/router/src/connector/worldpay/transformers.rs index 496f24c85475..11011c2c5eae 100644 --- a/crates/router/src/connector/worldpay/transformers.rs +++ b/crates/router/src/connector/worldpay/transformers.rs @@ -27,7 +27,7 @@ impl { type Error = error_stack::Report; fn try_from( - (_currency_unit, _currency, amount, router_data): ( + (_currency_unit, _currency, amount, item): ( &types::api::CurrencyUnit, types::storage::enums::Currency, i64, @@ -36,7 +36,7 @@ impl ) -> Result { Ok(Self { amount, - router_data, + router_data: item, }) } } @@ -131,38 +131,36 @@ fn fetch_payment_instrument( impl TryFrom<&WorldpayRouterData<&types::PaymentsAuthorizeRouterData>> for WorldpayPaymentsRequest { type Error = error_stack::Report; - fn try_from( - item: &WorldpayRouterData<&types::PaymentsAuthorizeRouterData>, - ) -> Result { - let request = &item.router_data.request; - match request.order_details.clone() { - Some(order_details) => Ok(Self { - instruction: Instruction { - value: PaymentValue { - amount: item.request.amount, - currency: item.request.currency.to_string(), - }, - narrative: InstructionNarrative { - line1: item.merchant_id.clone().replace('_', "-"), - ..Default::default() - }, - payment_instrument: fetch_payment_instrument( - item.request.payment_method_data.clone(), - )?, - debt_repayment: None, + fn try_from(item: &types::PaymentsAuthorizeRouterData) -> Result { + let connector_common_instance = utils::get_connector_common_instance()?; + + // Use the get_currency_unit method to obtain the currency unit. + let currency_unit = connector_common_instance.get_currency_unit(); + + // Create the WorldpayPaymentsRequest instance. + Ok(Self { + instruction: Instruction { + value: PaymentValue { + amount: item.request.amount, + currency: currency_unit, // Use the currency unit obtained from ConnectorCommon }, - merchant: Merchant { - entity: item.attempt_id.clone().replace('_', "-"), + narrative: InstructionNarrative { + line1: item.merchant_id.clone().replace('_', "-"), ..Default::default() }, - transaction_reference: item.attempt_id.clone(), - channel: None, - customer: None, - }), - None => Err(error_stack::Report::new( - errors::ConnectorError::CustomError("order_details is None"), - )), - } + payment_instrument: fetch_payment_instrument( + item.request.payment_method_data.clone(), + )?, + debt_repayment: None, + }, + merchant: Merchant { + entity: item.attempt_id.clone().replace('_', "-"), + ..Default::default() + }, + transaction_reference: item.attempt_id.clone(), + channel: None, + customer: None, + }) } } From 4be7bade089e25570af5b2dc382542e67efa64c6 Mon Sep 17 00:00:00 2001 From: Suraj Date: Fri, 6 Oct 2023 01:16:48 +0530 Subject: [PATCH 06/11] remove comments --- crates/router/src/connector/worldpay/transformers.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/crates/router/src/connector/worldpay/transformers.rs b/crates/router/src/connector/worldpay/transformers.rs index 11011c2c5eae..4f9f503fb9f0 100644 --- a/crates/router/src/connector/worldpay/transformers.rs +++ b/crates/router/src/connector/worldpay/transformers.rs @@ -134,15 +134,13 @@ impl TryFrom<&WorldpayRouterData<&types::PaymentsAuthorizeRouterData>> for World fn try_from(item: &types::PaymentsAuthorizeRouterData) -> Result { let connector_common_instance = utils::get_connector_common_instance()?; - // Use the get_currency_unit method to obtain the currency unit. let currency_unit = connector_common_instance.get_currency_unit(); - // Create the WorldpayPaymentsRequest instance. Ok(Self { instruction: Instruction { value: PaymentValue { amount: item.request.amount, - currency: currency_unit, // Use the currency unit obtained from ConnectorCommon + currency: currency_unit, }, narrative: InstructionNarrative { line1: item.merchant_id.clone().replace('_', "-"), From ee1be16c369b34d492e40fbdc10005448d45881e Mon Sep 17 00:00:00 2001 From: Suraj Date: Fri, 6 Oct 2023 19:44:15 +0530 Subject: [PATCH 07/11] remove extra dependencies --- Cargo.lock | 165 ++++++++++++++++------------------------------ package-lock.json | 36 ---------- package.json | 6 +- 3 files changed, 57 insertions(+), 150 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cca3b6f58d98..9e026101d1a1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -393,6 +393,7 @@ dependencies = [ "serde", "serde_json", "strum 0.24.1", + "thiserror", "time 0.3.22", "url", "utoipa", @@ -471,18 +472,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "async-bb8-diesel" -version = "0.1.0" -source = "git+https://github.com/juspay/async-bb8-diesel?rev=9a71d142726dbc33f41c1fd935ddaa79841c7be5#9a71d142726dbc33f41c1fd935ddaa79841c7be5" -dependencies = [ - "async-trait", - "bb8", - "diesel", - "thiserror", - "tokio", -] - [[package]] name = "async-bb8-diesel" version = "0.1.0" @@ -735,39 +724,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "aws-sdk-s3" -version = "0.25.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "392b9811ca489747ac84349790e49deaa1f16631949e7dd4156000251c260eae" -dependencies = [ - "aws-credential-types", - "aws-endpoint", - "aws-http", - "aws-sig-auth", - "aws-sigv4", - "aws-smithy-async", - "aws-smithy-checksums", - "aws-smithy-client", - "aws-smithy-eventstream", - "aws-smithy-http", - "aws-smithy-http-tower", - "aws-smithy-json", - "aws-smithy-types", - "aws-smithy-xml", - "aws-types", - "bytes", - "http", - "http-body", - "once_cell", - "percent-encoding", - "regex", - "tokio-stream", - "tower", - "tracing", - "url", -] - [[package]] name = "aws-sdk-s3" version = "0.28.0" @@ -1204,7 +1160,16 @@ dependencies = [ "cc", "cfg-if", "constant_time_eq", - "digest", + "digest 0.10.7", +] + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", ] [[package]] @@ -1853,9 +1818,9 @@ dependencies = [ name = "diesel_models" version = "0.1.0" dependencies = [ - "async-bb8-diesel 0.1.0 (git+https://github.com/oxidecomputer/async-bb8-diesel?rev=be3d9bce50051d8c0e0c06078e8066cc27db3001)", + "async-bb8-diesel", "aws-config", - "aws-sdk-s3 0.28.0", + "aws-sdk-s3", "common_enums", "common_utils", "diesel", @@ -1882,13 +1847,22 @@ dependencies = [ "syn 2.0.29", ] +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + [[package]] name = "digest" version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ - "block-buffer", + "block-buffer 0.10.4", "crypto-common", "subtle", ] @@ -1940,7 +1914,7 @@ checksum = "0688c2a7f92e427f44895cd63841bff7b29f8d7a1648b9e7e07a4a365b2e1257" name = "drainer" version = "0.1.0" dependencies = [ - "async-bb8-diesel 0.1.0 (git+https://github.com/oxidecomputer/async-bb8-diesel?rev=be3d9bce50051d8c0e0c06078e8066cc27db3001)", + "async-bb8-diesel", "bb8", "clap", "common_utils", @@ -1988,20 +1962,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" dependencies = [ "atty", - "humantime 1.3.0", - "log", - "regex", - "termcolor", -] - -[[package]] -name = "env_logger" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" -dependencies = [ - "humantime 2.1.0", - "is-terminal", + "humantime", "log", "regex", "termcolor", @@ -2192,7 +2153,7 @@ dependencies = [ "rand 0.8.5", "redis-protocol", "semver", - "sha-1", + "sha-1 0.10.1", "tokio", "tokio-stream", "tokio-util", @@ -2522,7 +2483,7 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" dependencies = [ - "digest", + "digest 0.10.7", ] [[package]] @@ -2589,12 +2550,6 @@ dependencies = [ "quick-error", ] -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - [[package]] name = "hyper" version = "0.14.27" @@ -2779,18 +2734,6 @@ version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12b6ee2129af8d4fb011108c73d99a1b83a85977f23b82460c0ae2e25bb4b57f" -[[package]] -name = "is-terminal" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" -dependencies = [ - "hermit-abi 0.3.1", - "io-lifetimes", - "rustix", - "windows-sys 0.48.0", -] - [[package]] name = "itertools" version = "0.10.5" @@ -3070,7 +3013,7 @@ version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6365506850d44bff6e2fbcb5176cf63650e48bd45ef2fe2665ae1570e0f4b9ca" dependencies = [ - "digest", + "digest 0.10.7", ] [[package]] @@ -3321,6 +3264,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44d11de466f4a3006fe8a5e7ec84e93b79c70cb992ae0aa0eb631ad2df8abfe2" +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + [[package]] name = "openssl" version = "0.10.55" @@ -3680,7 +3629,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "926d36b9553851b8b0005f1275891b392ee4d2d833852c417ed025477350fb9d" dependencies = [ - "env_logger 0.7.1", + "env_logger", "log", ] @@ -4134,11 +4083,11 @@ dependencies = [ "actix-rt", "actix-web", "api_models", - "async-bb8-diesel 0.1.0 (git+https://github.com/oxidecomputer/async-bb8-diesel?rev=be3d9bce50051d8c0e0c06078e8066cc27db3001)", + "async-bb8-diesel", "async-trait", "awc", "aws-config", - "aws-sdk-s3 0.28.0", + "aws-sdk-s3", "base64 0.21.2", "bb8", "blake3", @@ -4151,6 +4100,7 @@ dependencies = [ "derive_deref", "diesel", "diesel_models", + "digest 0.9.0", "dyn-clone", "encoding_rs", "error-stack", @@ -4189,6 +4139,7 @@ dependencies = [ "serde_urlencoded", "serde_with", "serial_test", + "sha-1 0.9.8", "signal-hook", "signal-hook-tokio", "storage_impl", @@ -4428,36 +4379,19 @@ dependencies = [ name = "scheduler" version = "0.1.0" dependencies = [ - "actix-multipart", - "actix-rt", - "actix-web", - "api_models", - "async-bb8-diesel 0.1.0 (git+https://github.com/juspay/async-bb8-diesel?rev=9a71d142726dbc33f41c1fd935ddaa79841c7be5)", "async-trait", - "aws-config", - "aws-sdk-s3 0.25.1", - "cards", - "clap", "common_utils", - "diesel", "diesel_models", - "dyn-clone", - "env_logger 0.10.0", "error-stack", "external_services", - "frunk", - "frunk_core", "futures", - "infer 0.13.0", "masking", "once_cell", "rand 0.8.5", "redis_interface", - "router_derive", "router_env", "serde", "serde_json", - "signal-hook", "signal-hook-tokio", "storage_impl", "strum 0.24.1", @@ -4678,6 +4612,19 @@ dependencies = [ "syn 2.0.29", ] +[[package]] +name = "sha-1" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if", + "cpufeatures", + "digest 0.9.0", + "opaque-debug", +] + [[package]] name = "sha-1" version = "0.10.1" @@ -4686,7 +4633,7 @@ checksum = "f5058ada175748e33390e40e872bd0fe59a19f265d0158daa551c5a88a76009c" dependencies = [ "cfg-if", "cpufeatures", - "digest", + "digest 0.10.7", ] [[package]] @@ -4697,7 +4644,7 @@ checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" dependencies = [ "cfg-if", "cpufeatures", - "digest", + "digest 0.10.7", ] [[package]] @@ -4708,7 +4655,7 @@ checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" dependencies = [ "cfg-if", "cpufeatures", - "digest", + "digest 0.10.7", ] [[package]] @@ -4824,7 +4771,7 @@ version = "0.1.0" dependencies = [ "actix-web", "api_models", - "async-bb8-diesel 0.1.0 (git+https://github.com/oxidecomputer/async-bb8-diesel?rev=be3d9bce50051d8c0e0c06078e8066cc27db3001)", + "async-bb8-diesel", "async-trait", "bb8", "bytes", diff --git a/package-lock.json b/package-lock.json index 2a77531a0da3..9efb15d87eaa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,10 +7,6 @@ "": { "name": "hyperswitch", "version": "0.0.0", - "dependencies": { - "cargo": "^0.8.0", - "rust": "^0.1.6" - }, "devDependencies": { "newman": "git+ssh://git@github.com:knutties/newman.git#37708c1fbf6b36240ac796a42dc5a7b435990764" } @@ -176,11 +172,6 @@ "base64-js": "^1.1.2" } }, - "node_modules/cargo": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/cargo/-/cargo-0.8.0.tgz", - "integrity": "sha512-Fl49HZ8CAs4++TjtwcoZgwyq2ZQUiFVGQ3byyKKUilNk65iuBRDjpCGH/AUORvAODaVVbGbKyFCa67tlDG3p4g==" - }, "node_modules/caseless": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", @@ -700,11 +691,6 @@ "verror": "1.10.0" } }, - "node_modules/keypress": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/keypress/-/keypress-0.1.0.tgz", - "integrity": "sha512-x0yf9PL/nx9Nw9oLL8ZVErFAk85/lslwEP7Vz7s5SI1ODXZIgit3C5qyWjw4DxOuO/3Hb4866SQh28a1V1d+WA==" - }, "node_modules/liquid-json": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/liquid-json/-/liquid-json-0.3.1.tgz", @@ -1085,28 +1071,6 @@ "node": ">=6" } }, - "node_modules/rust": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/rust/-/rust-0.1.6.tgz", - "integrity": "sha512-nE0vjFJPvvQkqA/4npktgKHvKWwr3u5a3fe70vAf0kBooQR2qGrn0LCdoPY44mxfYdmWJS5c4VqNvKhtLFKtzg==", - "dependencies": { - "commander": "~1.1.1" - }, - "bin": { - "rust": "rust" - } - }, - "node_modules/rust/node_modules/commander": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-1.1.1.tgz", - "integrity": "sha512-71Rod2AhcH3JhkBikVpNd0pA+fWsmAaVoti6OR38T76chA7vE3pSerS0Jor4wDw+tOueD2zLVvFOw5H0Rcj7rA==", - "dependencies": { - "keypress": "0.1.x" - }, - "engines": { - "node": ">= 0.6.x" - } - }, "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", diff --git a/package.json b/package.json index 602368612cce..61b3e950c6ca 100644 --- a/package.json +++ b/package.json @@ -5,9 +5,5 @@ "description": "This is just to run automated newman tests for this service", "devDependencies": { "newman": "git+ssh://git@github.com:knutties/newman.git#37708c1fbf6b36240ac796a42dc5a7b435990764" - }, - "dependencies": { - "cargo": "^0.8.0", - "rust": "^0.1.6" } -} +} \ No newline at end of file From 9f1bd38adf3b6653551e81c8f29b3e6ca234ca7d Mon Sep 17 00:00:00 2001 From: Suraj Date: Sun, 8 Oct 2023 01:03:21 +0530 Subject: [PATCH 08/11] import serde --- .../src/connector/worldpay/transformers.rs | 35 ++++++++++++++----- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/crates/router/src/connector/worldpay/transformers.rs b/crates/router/src/connector/worldpay/transformers.rs index 4f9f503fb9f0..9c04f64ccbab 100644 --- a/crates/router/src/connector/worldpay/transformers.rs +++ b/crates/router/src/connector/worldpay/transformers.rs @@ -3,6 +3,7 @@ use common_utils::errors::CustomResult; use diesel_models::enums; use error_stack::{IntoReport, ResultExt}; use masking::{PeekInterface, Secret}; +use serde::{Deserialize, Serialize}; use super::{requests::*, response::*}; use crate::{ @@ -128,10 +129,28 @@ fn fetch_payment_instrument( } } -impl TryFrom<&WorldpayRouterData<&types::PaymentsAuthorizeRouterData>> for WorldpayPaymentsRequest { +impl + TryFrom< + &WorldpayRouterData< + &types::RouterData< + types::api::payments::Authorize, + PaymentsAuthorizeData, + PaymentsResponseData, + >, + >, + > for WorldpayPaymentsRequest +{ type Error = error_stack::Report; - fn try_from(item: &types::PaymentsAuthorizeRouterData) -> Result { + fn try_from( + item: &WorldpayRouterData< + &types::RouterData< + types::api::payments::Authorize, + PaymentsAuthorizeData, + PaymentsResponseData, + >, + >, + ) -> Result { let connector_common_instance = utils::get_connector_common_instance()?; let currency_unit = connector_common_instance.get_currency_unit(); @@ -139,23 +158,23 @@ impl TryFrom<&WorldpayRouterData<&types::PaymentsAuthorizeRouterData>> for World Ok(Self { instruction: Instruction { value: PaymentValue { - amount: item.request.amount, - currency: currency_unit, + amount: item.amount, + currency: currency_unit.clone(), }, narrative: InstructionNarrative { - line1: item.merchant_id.clone().replace('_', "-"), + line1: item.router_data.merchant_id.clone().replace('_', "-"), ..Default::default() }, payment_instrument: fetch_payment_instrument( - item.request.payment_method_data.clone(), + item.router_data.request.payment_method_data.clone(), )?, debt_repayment: None, }, merchant: Merchant { - entity: item.attempt_id.clone().replace('_', "-"), + entity: item.router_data.attempt_id.clone().replace('_', "-"), ..Default::default() }, - transaction_reference: item.attempt_id.clone(), + transaction_reference: item.router_data.attempt_id.clone(), channel: None, customer: None, }) From 13b9a386b8f393379ca17b0af5a86f96cb6ff7c0 Mon Sep 17 00:00:00 2001 From: Suraj Date: Wed, 11 Oct 2023 00:57:40 +0530 Subject: [PATCH 09/11] solve intergration connection errors --- .../src/connector/worldpay/transformers.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/crates/router/src/connector/worldpay/transformers.rs b/crates/router/src/connector/worldpay/transformers.rs index 9c04f64ccbab..675177736326 100644 --- a/crates/router/src/connector/worldpay/transformers.rs +++ b/crates/router/src/connector/worldpay/transformers.rs @@ -3,14 +3,17 @@ use common_utils::errors::CustomResult; use diesel_models::enums; use error_stack::{IntoReport, ResultExt}; use masking::{PeekInterface, Secret}; -use serde::{Deserialize, Serialize}; +use serde::Serialize; -use super::{requests::*, response::*}; +use super::{requests::*, response::*, Worldpay}; use crate::{ - connector::utils, + connector::{ + utils, + worldpay::{ConnectorCommon, Worldpay}, + }, consts, core::errors, - types::{self, api}, + types::{self, api, PaymentsAuthorizeData, PaymentsResponseData}, }; #[derive(Debug, Serialize)] @@ -151,15 +154,14 @@ impl >, >, ) -> Result { - let connector_common_instance = utils::get_connector_common_instance()?; - - let currency_unit = connector_common_instance.get_currency_unit(); + let worldpay_instance = Worldpay; + let currency_unit = worldpay_instance.get_currency_unit(); Ok(Self { instruction: Instruction { value: PaymentValue { amount: item.amount, - currency: currency_unit.clone(), + currency: item.router_data.request.currency, }, narrative: InstructionNarrative { line1: item.router_data.merchant_id.clone().replace('_', "-"), From 0cc0c831444f6f3d1c8d6420fc3fdefcc0dac4b5 Mon Sep 17 00:00:00 2001 From: Suraj <105744567+Suraj3240@users.noreply.github.com> Date: Wed, 11 Oct 2023 09:20:51 +0530 Subject: [PATCH 10/11] Update transformers.rs --- crates/router/src/connector/worldpay/transformers.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/crates/router/src/connector/worldpay/transformers.rs b/crates/router/src/connector/worldpay/transformers.rs index 675177736326..0c6edd27f5b0 100644 --- a/crates/router/src/connector/worldpay/transformers.rs +++ b/crates/router/src/connector/worldpay/transformers.rs @@ -5,12 +5,9 @@ use error_stack::{IntoReport, ResultExt}; use masking::{PeekInterface, Secret}; use serde::Serialize; -use super::{requests::*, response::*, Worldpay}; +use super::{requests::*, response::*}; use crate::{ - connector::{ - utils, - worldpay::{ConnectorCommon, Worldpay}, - }, + connector::utils, consts, core::errors, types::{self, api, PaymentsAuthorizeData, PaymentsResponseData}, @@ -154,14 +151,12 @@ impl >, >, ) -> Result { - let worldpay_instance = Worldpay; - let currency_unit = worldpay_instance.get_currency_unit(); Ok(Self { instruction: Instruction { value: PaymentValue { amount: item.amount, - currency: item.router_data.request.currency, + currency: item.router_data.request.currency.to_string(), }, narrative: InstructionNarrative { line1: item.router_data.merchant_id.clone().replace('_', "-"), From be6489f0fd7c4b0308d71a9da63fe9b7387a97bd Mon Sep 17 00:00:00 2001 From: Suraj <105744567+Suraj3240@users.noreply.github.com> Date: Wed, 11 Oct 2023 13:58:51 +0000 Subject: [PATCH 11/11] format transformers.rs file --- crates/router/src/connector/worldpay/transformers.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/router/src/connector/worldpay/transformers.rs b/crates/router/src/connector/worldpay/transformers.rs index 0c6edd27f5b0..aabe27fc4eb1 100644 --- a/crates/router/src/connector/worldpay/transformers.rs +++ b/crates/router/src/connector/worldpay/transformers.rs @@ -151,7 +151,6 @@ impl >, >, ) -> Result { - Ok(Self { instruction: Instruction { value: PaymentValue {