From a7b688aac72e15f782046b9d108aca12f43a9994 Mon Sep 17 00:00:00 2001 From: chikke srujan <121822803+srujanchikke@users.noreply.github.com> Date: Tue, 12 Dec 2023 15:03:21 +0530 Subject: [PATCH] feat(connector): [Placetopay] Add Connector Template Code (#3084) Signed-off-by: chikke srujan <121822803+srujanchikke@users.noreply.github.com> Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> --- config/config.example.toml | 1 + config/development.toml | 2 + config/docker_compose.toml | 2 + connector-template/transformers.rs | 2 - crates/api_models/src/enums.rs | 1 + crates/common_enums/src/enums.rs | 1 + crates/router/src/configs/settings.rs | 1 + crates/router/src/connector.rs | 9 +- crates/router/src/connector/placetopay.rs | 545 ++++++++++++++++++ .../src/connector/placetopay/transformers.rs | 236 ++++++++ crates/router/src/core/admin.rs | 4 + crates/router/src/core/payments/flows.rs | 26 + crates/router/src/types/api.rs | 1 + crates/router/src/types/transformers.rs | 1 + crates/router/tests/connectors/main.rs | 1 + crates/router/tests/connectors/placetopay.rs | 420 ++++++++++++++ .../router/tests/connectors/sample_auth.toml | 4 + crates/test_utils/src/connector_auth.rs | 1 + loadtest/config/development.toml | 2 + openapi/openapi_spec.json | 1 + scripts/add_connector.sh | 2 +- 21 files changed, 1256 insertions(+), 7 deletions(-) create mode 100644 crates/router/src/connector/placetopay.rs create mode 100644 crates/router/src/connector/placetopay/transformers.rs create mode 100644 crates/router/tests/connectors/placetopay.rs diff --git a/config/config.example.toml b/config/config.example.toml index 335433077b..1b720eaeb4 100644 --- a/config/config.example.toml +++ b/config/config.example.toml @@ -216,6 +216,7 @@ payeezy.base_url = "https://api-cert.payeezy.com/" payme.base_url = "https://sandbox.payme.io/" paypal.base_url = "https://api-m.sandbox.paypal.com/" payu.base_url = "https://secure.snd.payu.com/" +placetopay.base_url = "https://api-co-dev.placetopay.ws/gateway" powertranz.base_url = "https://staging.ptranz.com/api/" prophetpay.base_url = "https://ccm-thirdparty.cps.golf/" rapyd.base_url = "https://sandboxapi.rapyd.net" diff --git a/config/development.toml b/config/development.toml index 090751b2ea..1ce26053fc 100644 --- a/config/development.toml +++ b/config/development.toml @@ -130,6 +130,7 @@ cards = [ "payme", "paypal", "payu", + "placetopay", "powertranz", "prophetpay", "shift4", @@ -202,6 +203,7 @@ payeezy.base_url = "https://api-cert.payeezy.com/" payme.base_url = "https://sandbox.payme.io/" paypal.base_url = "https://api-m.sandbox.paypal.com/" payu.base_url = "https://secure.snd.payu.com/" +placetopay.base_url = "https://api-co-dev.placetopay.ws/gateway" powertranz.base_url = "https://staging.ptranz.com/api/" prophetpay.base_url = "https://ccm-thirdparty.cps.golf/" rapyd.base_url = "https://sandboxapi.rapyd.net" diff --git a/config/docker_compose.toml b/config/docker_compose.toml index dc42a5b44c..00840daf55 100644 --- a/config/docker_compose.toml +++ b/config/docker_compose.toml @@ -138,6 +138,7 @@ payeezy.base_url = "https://api-cert.payeezy.com/" payme.base_url = "https://sandbox.payme.io/" paypal.base_url = "https://api-m.sandbox.paypal.com/" payu.base_url = "https://secure.snd.payu.com/" +placetopay.base_url = "https://api-co-dev.placetopay.ws/gateway" powertranz.base_url = "https://staging.ptranz.com/api/" prophetpay.base_url = "https://ccm-thirdparty.cps.golf/" rapyd.base_url = "https://sandboxapi.rapyd.net" @@ -201,6 +202,7 @@ cards = [ "payme", "paypal", "payu", + "placetopay", "powertranz", "prophetpay", "shift4", diff --git a/connector-template/transformers.rs b/connector-template/transformers.rs index bdbfb2e456..60b1369305 100644 --- a/connector-template/transformers.rs +++ b/connector-template/transformers.rs @@ -42,7 +42,6 @@ pub struct {{project-name | downcase | pascal_case}}PaymentsRequest { #[derive(Default, Debug, Serialize, Eq, PartialEq)] pub struct {{project-name | downcase | pascal_case}}Card { - name: Secret, number: cards::CardNumber, expiry_month: Secret, expiry_year: Secret, @@ -56,7 +55,6 @@ impl TryFrom<&{{project-name | downcase | pascal_case}}RouterData<&types::Paymen match item.router_data.request.payment_method_data.clone() { api::PaymentMethodData::Card(req_card) => { let card = {{project-name | downcase | pascal_case}}Card { - name: req_card.card_holder_name, number: req_card.card_number, expiry_month: req_card.card_exp_month, expiry_year: req_card.card_exp_year, diff --git a/crates/api_models/src/enums.rs b/crates/api_models/src/enums.rs index 2158605405..f1b4447c33 100644 --- a/crates/api_models/src/enums.rs +++ b/crates/api_models/src/enums.rs @@ -109,6 +109,7 @@ pub enum Connector { Payme, Paypal, Payu, + Placetopay, Powertranz, Prophetpay, Rapyd, diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs index 980f98db15..a749744e06 100644 --- a/crates/common_enums/src/enums.rs +++ b/crates/common_enums/src/enums.rs @@ -142,6 +142,7 @@ pub enum RoutableConnectors { Payme, Paypal, Payu, + Placetopay, Powertranz, Prophetpay, Rapyd, diff --git a/crates/router/src/configs/settings.rs b/crates/router/src/configs/settings.rs index 1c885e90cc..5b34d56c93 100644 --- a/crates/router/src/configs/settings.rs +++ b/crates/router/src/configs/settings.rs @@ -614,6 +614,7 @@ pub struct Connectors { pub payme: ConnectorParams, pub paypal: ConnectorParams, pub payu: ConnectorParams, + pub placetopay: ConnectorParams, pub powertranz: ConnectorParams, pub prophetpay: ConnectorParams, pub rapyd: ConnectorParams, diff --git a/crates/router/src/connector.rs b/crates/router/src/connector.rs index 55c6144259..e336d8e351 100644 --- a/crates/router/src/connector.rs +++ b/crates/router/src/connector.rs @@ -36,6 +36,7 @@ pub mod payeezy; pub mod payme; pub mod paypal; pub mod payu; +pub mod placetopay; pub mod powertranz; pub mod prophetpay; pub mod rapyd; @@ -63,8 +64,8 @@ pub use self::{ globalpay::Globalpay, globepay::Globepay, gocardless::Gocardless, helcim::Helcim, iatapay::Iatapay, klarna::Klarna, mollie::Mollie, multisafepay::Multisafepay, nexinets::Nexinets, nmi::Nmi, noon::Noon, nuvei::Nuvei, opayo::Opayo, opennode::Opennode, - payeezy::Payeezy, payme::Payme, paypal::Paypal, payu::Payu, powertranz::Powertranz, - prophetpay::Prophetpay, rapyd::Rapyd, shift4::Shift4, signifyd::Signifyd, square::Square, - stax::Stax, stripe::Stripe, trustpay::Trustpay, tsys::Tsys, volt::Volt, wise::Wise, - worldline::Worldline, worldpay::Worldpay, zen::Zen, + payeezy::Payeezy, payme::Payme, paypal::Paypal, payu::Payu, placetopay::Placetopay, + powertranz::Powertranz, prophetpay::Prophetpay, rapyd::Rapyd, shift4::Shift4, + signifyd::Signifyd, square::Square, stax::Stax, stripe::Stripe, trustpay::Trustpay, tsys::Tsys, + volt::Volt, wise::Wise, worldline::Worldline, worldpay::Worldpay, zen::Zen, }; diff --git a/crates/router/src/connector/placetopay.rs b/crates/router/src/connector/placetopay.rs new file mode 100644 index 0000000000..71f07d79fb --- /dev/null +++ b/crates/router/src/connector/placetopay.rs @@ -0,0 +1,545 @@ +pub mod transformers; + +use std::fmt::Debug; + +use error_stack::{IntoReport, ResultExt}; +use masking::ExposeInterface; +use transformers as placetopay; + +use crate::{ + configs::settings, + core::errors::{self, CustomResult}, + headers, + services::{ + self, + request::{self, Mask}, + ConnectorIntegration, ConnectorValidation, + }, + types::{ + self, + api::{self, ConnectorCommon, ConnectorCommonExt}, + ErrorResponse, Response, + }, + utils::{self, BytesExt}, +}; + +#[derive(Debug, Clone)] +pub struct Placetopay; + +impl api::Payment for Placetopay {} +impl api::PaymentSession for Placetopay {} +impl api::ConnectorAccessToken for Placetopay {} +impl api::MandateSetup for Placetopay {} +impl api::PaymentAuthorize for Placetopay {} +impl api::PaymentSync for Placetopay {} +impl api::PaymentCapture for Placetopay {} +impl api::PaymentVoid for Placetopay {} +impl api::Refund for Placetopay {} +impl api::RefundExecute for Placetopay {} +impl api::RefundSync for Placetopay {} +impl api::PaymentToken for Placetopay {} + +impl + ConnectorIntegration< + api::PaymentMethodToken, + types::PaymentMethodTokenizationData, + types::PaymentsResponseData, + > for Placetopay +{ + // Not Implemented (R) +} + +impl ConnectorCommonExt for Placetopay +where + Self: ConnectorIntegration, +{ + fn build_headers( + &self, + req: &types::RouterData, + _connectors: &settings::Connectors, + ) -> CustomResult)>, errors::ConnectorError> { + let mut header = vec![( + headers::CONTENT_TYPE.to_string(), + self.get_content_type().to_string().into(), + )]; + let mut api_key = self.get_auth_header(&req.connector_auth_type)?; + header.append(&mut api_key); + Ok(header) + } +} + +impl ConnectorCommon for Placetopay { + fn id(&self) -> &'static str { + "placetopay" + } + + fn get_currency_unit(&self) -> api::CurrencyUnit { + api::CurrencyUnit::Minor + } + + fn common_get_content_type(&self) -> &'static str { + "application/json" + } + + fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str { + connectors.placetopay.base_url.as_ref() + } + + fn get_auth_header( + &self, + auth_type: &types::ConnectorAuthType, + ) -> CustomResult)>, errors::ConnectorError> { + let auth = placetopay::PlacetopayAuthType::try_from(auth_type) + .change_context(errors::ConnectorError::FailedToObtainAuthType)?; + Ok(vec![( + headers::AUTHORIZATION.to_string(), + auth.api_key.expose().into_masked(), + )]) + } + + fn build_error_response( + &self, + res: Response, + ) -> CustomResult { + let response: placetopay::PlacetopayErrorResponse = res + .response + .parse_struct("PlacetopayErrorResponse") + .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; + + Ok(ErrorResponse { + status_code: res.status_code, + code: response.code, + message: response.message, + reason: response.reason, + attempt_status: None, + connector_transaction_id: None, + }) + } +} + +impl ConnectorValidation for Placetopay {} + +impl ConnectorIntegration + for Placetopay +{ +} + +impl ConnectorIntegration + for Placetopay +{ +} + +impl + ConnectorIntegration< + api::SetupMandate, + types::SetupMandateRequestData, + types::PaymentsResponseData, + > for Placetopay +{ +} + +impl ConnectorIntegration + for Placetopay +{ + fn get_headers( + &self, + req: &types::PaymentsAuthorizeRouterData, + connectors: &settings::Connectors, + ) -> CustomResult)>, errors::ConnectorError> { + self.build_headers(req, connectors) + } + + fn get_content_type(&self) -> &'static str { + self.common_get_content_type() + } + + fn get_url( + &self, + _req: &types::PaymentsAuthorizeRouterData, + _connectors: &settings::Connectors, + ) -> CustomResult { + Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into()) + } + + fn get_request_body( + &self, + req: &types::PaymentsAuthorizeRouterData, + _connectors: &settings::Connectors, + ) -> CustomResult, errors::ConnectorError> { + let connector_router_data = placetopay::PlacetopayRouterData::try_from(( + &self.get_currency_unit(), + req.request.currency, + req.request.amount, + req, + ))?; + let req_obj = placetopay::PlacetopayPaymentsRequest::try_from(&connector_router_data)?; + let placetopay_req = types::RequestBody::log_and_get_request_body( + &req_obj, + utils::Encode::::encode_to_string_of_json, + ) + .change_context(errors::ConnectorError::RequestEncodingFailed)?; + Ok(Some(placetopay_req)) + } + + fn build_request( + &self, + req: &types::PaymentsAuthorizeRouterData, + connectors: &settings::Connectors, + ) -> CustomResult, errors::ConnectorError> { + Ok(Some( + services::RequestBuilder::new() + .method(services::Method::Post) + .url(&types::PaymentsAuthorizeType::get_url( + self, req, connectors, + )?) + .attach_default_headers() + .headers(types::PaymentsAuthorizeType::get_headers( + self, req, connectors, + )?) + .body(types::PaymentsAuthorizeType::get_request_body( + self, req, connectors, + )?) + .build(), + )) + } + + fn handle_response( + &self, + data: &types::PaymentsAuthorizeRouterData, + res: Response, + ) -> CustomResult { + let response: placetopay::PlacetopayPaymentsResponse = res + .response + .parse_struct("Placetopay PaymentsAuthorizeResponse") + .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; + types::RouterData::try_from(types::ResponseRouterData { + response, + data: data.clone(), + http_code: res.status_code, + }) + } + + fn get_error_response( + &self, + res: Response, + ) -> CustomResult { + self.build_error_response(res) + } +} + +impl ConnectorIntegration + for Placetopay +{ + fn get_headers( + &self, + req: &types::PaymentsSyncRouterData, + connectors: &settings::Connectors, + ) -> CustomResult)>, errors::ConnectorError> { + self.build_headers(req, connectors) + } + + fn get_content_type(&self) -> &'static str { + self.common_get_content_type() + } + + fn get_url( + &self, + _req: &types::PaymentsSyncRouterData, + _connectors: &settings::Connectors, + ) -> CustomResult { + Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into()) + } + + fn build_request( + &self, + req: &types::PaymentsSyncRouterData, + connectors: &settings::Connectors, + ) -> CustomResult, errors::ConnectorError> { + Ok(Some( + services::RequestBuilder::new() + .method(services::Method::Get) + .url(&types::PaymentsSyncType::get_url(self, req, connectors)?) + .attach_default_headers() + .headers(types::PaymentsSyncType::get_headers(self, req, connectors)?) + .build(), + )) + } + + fn handle_response( + &self, + data: &types::PaymentsSyncRouterData, + res: Response, + ) -> CustomResult { + let response: placetopay::PlacetopayPaymentsResponse = res + .response + .parse_struct("placetopay PaymentsSyncResponse") + .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; + types::RouterData::try_from(types::ResponseRouterData { + response, + data: data.clone(), + http_code: res.status_code, + }) + } + + fn get_error_response( + &self, + res: Response, + ) -> CustomResult { + self.build_error_response(res) + } +} + +impl ConnectorIntegration + for Placetopay +{ + fn get_headers( + &self, + req: &types::PaymentsCaptureRouterData, + connectors: &settings::Connectors, + ) -> CustomResult)>, errors::ConnectorError> { + self.build_headers(req, connectors) + } + + fn get_content_type(&self) -> &'static str { + self.common_get_content_type() + } + + fn get_url( + &self, + _req: &types::PaymentsCaptureRouterData, + _connectors: &settings::Connectors, + ) -> CustomResult { + Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into()) + } + + fn get_request_body( + &self, + _req: &types::PaymentsCaptureRouterData, + _connectors: &settings::Connectors, + ) -> CustomResult, errors::ConnectorError> { + Err(errors::ConnectorError::NotImplemented("get_request_body method".to_string()).into()) + } + + fn build_request( + &self, + req: &types::PaymentsCaptureRouterData, + connectors: &settings::Connectors, + ) -> CustomResult, errors::ConnectorError> { + Ok(Some( + services::RequestBuilder::new() + .method(services::Method::Post) + .url(&types::PaymentsCaptureType::get_url(self, req, connectors)?) + .attach_default_headers() + .headers(types::PaymentsCaptureType::get_headers( + self, req, connectors, + )?) + .body(types::PaymentsCaptureType::get_request_body( + self, req, connectors, + )?) + .build(), + )) + } + + fn handle_response( + &self, + data: &types::PaymentsCaptureRouterData, + res: Response, + ) -> CustomResult { + let response: placetopay::PlacetopayPaymentsResponse = res + .response + .parse_struct("Placetopay PaymentsCaptureResponse") + .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; + types::RouterData::try_from(types::ResponseRouterData { + response, + data: data.clone(), + http_code: res.status_code, + }) + } + + fn get_error_response( + &self, + res: Response, + ) -> CustomResult { + self.build_error_response(res) + } +} + +impl ConnectorIntegration + for Placetopay +{ +} + +impl ConnectorIntegration + for Placetopay +{ + fn get_headers( + &self, + req: &types::RefundsRouterData, + connectors: &settings::Connectors, + ) -> CustomResult)>, errors::ConnectorError> { + self.build_headers(req, connectors) + } + + fn get_content_type(&self) -> &'static str { + self.common_get_content_type() + } + + fn get_url( + &self, + _req: &types::RefundsRouterData, + _connectors: &settings::Connectors, + ) -> CustomResult { + Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into()) + } + + fn get_request_body( + &self, + req: &types::RefundsRouterData, + _connectors: &settings::Connectors, + ) -> CustomResult, errors::ConnectorError> { + let connector_router_data = placetopay::PlacetopayRouterData::try_from(( + &self.get_currency_unit(), + req.request.currency, + req.request.refund_amount, + req, + ))?; + let req_obj = placetopay::PlacetopayRefundRequest::try_from(&connector_router_data)?; + let placetopay_req = types::RequestBody::log_and_get_request_body( + &req_obj, + utils::Encode::::encode_to_string_of_json, + ) + .change_context(errors::ConnectorError::RequestEncodingFailed)?; + Ok(Some(placetopay_req)) + } + + fn build_request( + &self, + req: &types::RefundsRouterData, + connectors: &settings::Connectors, + ) -> CustomResult, errors::ConnectorError> { + let request = services::RequestBuilder::new() + .method(services::Method::Post) + .url(&types::RefundExecuteType::get_url(self, req, connectors)?) + .attach_default_headers() + .headers(types::RefundExecuteType::get_headers( + self, req, connectors, + )?) + .body(types::RefundExecuteType::get_request_body( + self, req, connectors, + )?) + .build(); + Ok(Some(request)) + } + + fn handle_response( + &self, + data: &types::RefundsRouterData, + res: Response, + ) -> CustomResult, errors::ConnectorError> { + let response: placetopay::RefundResponse = res + .response + .parse_struct("placetopay RefundResponse") + .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; + types::RouterData::try_from(types::ResponseRouterData { + response, + data: data.clone(), + http_code: res.status_code, + }) + } + + fn get_error_response( + &self, + res: Response, + ) -> CustomResult { + self.build_error_response(res) + } +} + +impl ConnectorIntegration + for Placetopay +{ + fn get_headers( + &self, + req: &types::RefundSyncRouterData, + connectors: &settings::Connectors, + ) -> CustomResult)>, errors::ConnectorError> { + self.build_headers(req, connectors) + } + + fn get_content_type(&self) -> &'static str { + self.common_get_content_type() + } + + fn get_url( + &self, + _req: &types::RefundSyncRouterData, + _connectors: &settings::Connectors, + ) -> CustomResult { + Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into()) + } + + fn build_request( + &self, + req: &types::RefundSyncRouterData, + connectors: &settings::Connectors, + ) -> CustomResult, errors::ConnectorError> { + Ok(Some( + services::RequestBuilder::new() + .method(services::Method::Get) + .url(&types::RefundSyncType::get_url(self, req, connectors)?) + .attach_default_headers() + .headers(types::RefundSyncType::get_headers(self, req, connectors)?) + .body(types::RefundSyncType::get_request_body( + self, req, connectors, + )?) + .build(), + )) + } + + fn handle_response( + &self, + data: &types::RefundSyncRouterData, + res: Response, + ) -> CustomResult { + let response: placetopay::RefundResponse = res + .response + .parse_struct("placetopay RefundSyncResponse") + .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; + types::RouterData::try_from(types::ResponseRouterData { + response, + data: data.clone(), + http_code: res.status_code, + }) + } + + fn get_error_response( + &self, + res: Response, + ) -> CustomResult { + self.build_error_response(res) + } +} + +#[async_trait::async_trait] +impl api::IncomingWebhook for Placetopay { + fn get_webhook_object_reference_id( + &self, + _request: &api::IncomingWebhookRequestDetails<'_>, + ) -> CustomResult { + Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + } + + fn get_webhook_event_type( + &self, + _request: &api::IncomingWebhookRequestDetails<'_>, + ) -> CustomResult { + Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + } + + fn get_webhook_resource_object( + &self, + _request: &api::IncomingWebhookRequestDetails<'_>, + ) -> CustomResult, errors::ConnectorError> { + Err(errors::ConnectorError::WebhooksNotImplemented).into_report() + } +} diff --git a/crates/router/src/connector/placetopay/transformers.rs b/crates/router/src/connector/placetopay/transformers.rs new file mode 100644 index 0000000000..e947c6830c --- /dev/null +++ b/crates/router/src/connector/placetopay/transformers.rs @@ -0,0 +1,236 @@ +use masking::Secret; +use serde::{Deserialize, Serialize}; + +use crate::{ + connector::utils::PaymentsAuthorizeRequestData, + core::errors, + types::{self, api, storage::enums}, +}; + +pub struct PlacetopayRouterData { + pub amount: i64, // The type of amount that a connector accepts, for example, String, i64, f64, etc. + pub router_data: T, +} + +impl + TryFrom<( + &types::api::CurrencyUnit, + types::storage::enums::Currency, + i64, + T, + )> for PlacetopayRouterData +{ + type Error = error_stack::Report; + fn try_from( + (_currency_unit, _currency, amount, item): ( + &types::api::CurrencyUnit, + types::storage::enums::Currency, + i64, + T, + ), + ) -> Result { + Ok(Self { + amount, + router_data: item, + }) + } +} + +#[derive(Default, Debug, Serialize, Eq, PartialEq)] +pub struct PlacetopayPaymentsRequest { + amount: i64, + card: PlacetopayCard, +} + +#[derive(Default, Debug, Serialize, Eq, PartialEq)] +pub struct PlacetopayCard { + number: cards::CardNumber, + expiry_month: Secret, + expiry_year: Secret, + cvc: Secret, + complete: bool, +} + +impl TryFrom<&PlacetopayRouterData<&types::PaymentsAuthorizeRouterData>> + for PlacetopayPaymentsRequest +{ + type Error = error_stack::Report; + fn try_from( + item: &PlacetopayRouterData<&types::PaymentsAuthorizeRouterData>, + ) -> Result { + match item.router_data.request.payment_method_data.clone() { + api::PaymentMethodData::Card(req_card) => { + let card = PlacetopayCard { + number: req_card.card_number, + expiry_month: req_card.card_exp_month, + expiry_year: req_card.card_exp_year, + cvc: req_card.card_cvc, + complete: item.router_data.request.is_auto_capture()?, + }; + Ok(Self { + amount: item.amount.to_owned(), + card, + }) + } + _ => Err(errors::ConnectorError::NotImplemented("Payment methods".to_string()).into()), + } + } +} + +// Auth Struct +pub struct PlacetopayAuthType { + pub(super) api_key: Secret, +} + +impl TryFrom<&types::ConnectorAuthType> for PlacetopayAuthType { + type Error = error_stack::Report; + fn try_from(auth_type: &types::ConnectorAuthType) -> Result { + match auth_type { + types::ConnectorAuthType::HeaderKey { api_key } => Ok(Self { + api_key: api_key.to_owned(), + }), + _ => Err(errors::ConnectorError::FailedToObtainAuthType.into()), + } + } +} +// PaymentsResponse +#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq)] +#[serde(rename_all = "lowercase")] +pub enum PlacetopayPaymentStatus { + Succeeded, + Failed, + #[default] + Processing, +} + +impl From for enums::AttemptStatus { + fn from(item: PlacetopayPaymentStatus) -> Self { + match item { + PlacetopayPaymentStatus::Succeeded => Self::Charged, + PlacetopayPaymentStatus::Failed => Self::Failure, + PlacetopayPaymentStatus::Processing => Self::Authorizing, + } + } +} + +#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)] +pub struct PlacetopayPaymentsResponse { + status: PlacetopayPaymentStatus, + id: String, +} + +impl + TryFrom< + types::ResponseRouterData, + > for types::RouterData +{ + type Error = error_stack::Report; + fn try_from( + item: types::ResponseRouterData< + F, + PlacetopayPaymentsResponse, + T, + types::PaymentsResponseData, + >, + ) -> Result { + Ok(Self { + status: enums::AttemptStatus::from(item.response.status), + response: Ok(types::PaymentsResponseData::TransactionResponse { + resource_id: types::ResponseId::ConnectorTransactionId(item.response.id), + redirection_data: None, + mandate_reference: None, + connector_metadata: None, + network_txn_id: None, + connector_response_reference_id: None, + incremental_authorization_allowed: None, + }), + ..item.data + }) + } +} +// REFUND : +// Type definition for RefundRequest +#[derive(Default, Debug, Serialize)] +pub struct PlacetopayRefundRequest { + pub amount: i64, +} + +impl TryFrom<&PlacetopayRouterData<&types::RefundsRouterData>> for PlacetopayRefundRequest { + type Error = error_stack::Report; + fn try_from( + item: &PlacetopayRouterData<&types::RefundsRouterData>, + ) -> Result { + Ok(Self { + amount: item.amount.to_owned(), + }) + } +} + +// Type definition for Refund Response + +#[allow(dead_code)] +#[derive(Debug, Serialize, Default, Deserialize, Clone)] +pub enum RefundStatus { + Succeeded, + Failed, + #[default] + Processing, +} + +impl From for enums::RefundStatus { + fn from(item: RefundStatus) -> Self { + match item { + RefundStatus::Succeeded => Self::Success, + RefundStatus::Failed => Self::Failure, + RefundStatus::Processing => Self::Pending, + } + } +} + +#[derive(Default, Debug, Clone, Serialize, Deserialize)] +pub struct RefundResponse { + id: String, + status: RefundStatus, +} + +impl TryFrom> + for types::RefundsRouterData +{ + type Error = error_stack::Report; + fn try_from( + item: types::RefundsResponseRouterData, + ) -> Result { + Ok(Self { + response: Ok(types::RefundsResponseData { + connector_refund_id: item.response.id.to_string(), + refund_status: enums::RefundStatus::from(item.response.status), + }), + ..item.data + }) + } +} + +impl TryFrom> + for types::RefundsRouterData +{ + type Error = error_stack::Report; + fn try_from( + item: types::RefundsResponseRouterData, + ) -> Result { + Ok(Self { + response: Ok(types::RefundsResponseData { + connector_refund_id: item.response.id.to_string(), + refund_status: enums::RefundStatus::from(item.response.status), + }), + ..item.data + }) + } +} + +#[derive(Default, Debug, Serialize, Deserialize, PartialEq)] +pub struct PlacetopayErrorResponse { + pub status_code: u16, + pub code: String, + pub message: String, + pub reason: Option, +} diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rs index 113bc7d677..f5bb357af0 100644 --- a/crates/router/src/core/admin.rs +++ b/crates/router/src/core/admin.rs @@ -1795,6 +1795,10 @@ pub(crate) fn validate_auth_and_metadata_type( payu::transformers::PayuAuthType::try_from(val)?; Ok(()) } + api_enums::Connector::Placetopay => { + placetopay::transformers::PlacetopayAuthType::try_from(val)?; + Ok(()) + } api_enums::Connector::Powertranz => { powertranz::transformers::PowertranzAuthType::try_from(val)?; Ok(()) diff --git a/crates/router/src/core/payments/flows.rs b/crates/router/src/core/payments/flows.rs index 81ba48e983..0cb91de059 100644 --- a/crates/router/src/core/payments/flows.rs +++ b/crates/router/src/core/payments/flows.rs @@ -171,6 +171,7 @@ default_imp_for_complete_authorize!( connector::Opennode, connector::Payeezy, connector::Payu, + connector::Placetopay, connector::Rapyd, connector::Signifyd, connector::Square, @@ -246,6 +247,7 @@ default_imp_for_webhook_source_verification!( connector::Payeezy, connector::Payme, connector::Payu, + connector::Placetopay, connector::Powertranz, connector::Prophetpay, connector::Rapyd, @@ -326,6 +328,7 @@ default_imp_for_create_customer!( connector::Paypal, connector::Payme, connector::Payu, + connector::Placetopay, connector::Powertranz, connector::Prophetpay, connector::Rapyd, @@ -395,6 +398,7 @@ default_imp_for_connector_redirect_response!( connector::Opennode, connector::Payeezy, connector::Payu, + connector::Placetopay, connector::Powertranz, connector::Prophetpay, connector::Rapyd, @@ -455,6 +459,7 @@ default_imp_for_connector_request_id!( connector::Payme, connector::Paypal, connector::Payu, + connector::Placetopay, connector::Powertranz, connector::Prophetpay, connector::Rapyd, @@ -538,6 +543,7 @@ default_imp_for_accept_dispute!( connector::Paypal, connector::Payme, connector::Payu, + connector::Placetopay, connector::Powertranz, connector::Prophetpay, connector::Rapyd, @@ -639,6 +645,7 @@ default_imp_for_file_upload!( connector::Paypal, connector::Payme, connector::Payu, + connector::Placetopay, connector::Powertranz, connector::Prophetpay, connector::Rapyd, @@ -718,6 +725,7 @@ default_imp_for_submit_evidence!( connector::Paypal, connector::Payme, connector::Payu, + connector::Placetopay, connector::Powertranz, connector::Prophetpay, connector::Rapyd, @@ -797,6 +805,7 @@ default_imp_for_defend_dispute!( connector::Paypal, connector::Payme, connector::Payu, + connector::Placetopay, connector::Powertranz, connector::Prophetpay, connector::Rapyd, @@ -875,6 +884,7 @@ default_imp_for_pre_processing_steps!( connector::Opennode, connector::Payeezy, connector::Payu, + connector::Placetopay, connector::Powertranz, connector::Prophetpay, connector::Rapyd, @@ -937,6 +947,7 @@ default_imp_for_payouts!( connector::Payme, connector::Paypal, connector::Payu, + connector::Placetopay, connector::Powertranz, connector::Prophetpay, connector::Rapyd, @@ -1017,6 +1028,7 @@ default_imp_for_payouts_create!( connector::Payme, connector::Paypal, connector::Payu, + connector::Placetopay, connector::Powertranz, connector::Prophetpay, connector::Rapyd, @@ -1100,6 +1112,7 @@ default_imp_for_payouts_eligibility!( connector::Payme, connector::Paypal, connector::Payu, + connector::Placetopay, connector::Powertranz, connector::Prophetpay, connector::Rapyd, @@ -1180,6 +1193,7 @@ default_imp_for_payouts_fulfill!( connector::Payme, connector::Paypal, connector::Payu, + connector::Placetopay, connector::Powertranz, connector::Prophetpay, connector::Rapyd, @@ -1260,6 +1274,7 @@ default_imp_for_payouts_cancel!( connector::Payme, connector::Paypal, connector::Payu, + connector::Placetopay, connector::Powertranz, connector::Prophetpay, connector::Rapyd, @@ -1341,6 +1356,7 @@ default_imp_for_payouts_quote!( connector::Payme, connector::Paypal, connector::Payu, + connector::Placetopay, connector::Powertranz, connector::Prophetpay, connector::Rapyd, @@ -1422,6 +1438,7 @@ default_imp_for_payouts_recipient!( connector::Payme, connector::Paypal, connector::Payu, + connector::Placetopay, connector::Powertranz, connector::Prophetpay, connector::Rapyd, @@ -1502,6 +1519,7 @@ default_imp_for_approve!( connector::Payme, connector::Paypal, connector::Payu, + connector::Placetopay, connector::Powertranz, connector::Prophetpay, connector::Rapyd, @@ -1583,6 +1601,7 @@ default_imp_for_reject!( connector::Payme, connector::Paypal, connector::Payu, + connector::Placetopay, connector::Powertranz, connector::Prophetpay, connector::Rapyd, @@ -1648,6 +1667,7 @@ default_imp_for_fraud_check!( connector::Payme, connector::Paypal, connector::Payu, + connector::Placetopay, connector::Powertranz, connector::Prophetpay, connector::Rapyd, @@ -1730,6 +1750,7 @@ default_imp_for_frm_sale!( connector::Payme, connector::Paypal, connector::Payu, + connector::Placetopay, connector::Powertranz, connector::Prophetpay, connector::Rapyd, @@ -1812,6 +1833,7 @@ default_imp_for_frm_checkout!( connector::Payme, connector::Paypal, connector::Payu, + connector::Placetopay, connector::Powertranz, connector::Prophetpay, connector::Rapyd, @@ -1894,6 +1916,7 @@ default_imp_for_frm_transaction!( connector::Payme, connector::Paypal, connector::Payu, + connector::Placetopay, connector::Powertranz, connector::Prophetpay, connector::Rapyd, @@ -1976,6 +1999,7 @@ default_imp_for_frm_fulfillment!( connector::Payme, connector::Paypal, connector::Payu, + connector::Placetopay, connector::Powertranz, connector::Prophetpay, connector::Rapyd, @@ -2058,6 +2082,7 @@ default_imp_for_frm_record_return!( connector::Payme, connector::Paypal, connector::Payu, + connector::Placetopay, connector::Powertranz, connector::Prophetpay, connector::Rapyd, @@ -2137,6 +2162,7 @@ default_imp_for_incremental_authorization!( connector::Payme, connector::Paypal, connector::Payu, + connector::Placetopay, connector::Powertranz, connector::Prophetpay, connector::Rapyd, diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rs index 978ce078fa..71751adf6b 100644 --- a/crates/router/src/types/api.rs +++ b/crates/router/src/types/api.rs @@ -388,6 +388,7 @@ impl ConnectorData { // "payeezy" => Ok(Box::new(&connector::Payeezy)), As psync and rsync are not supported by this connector, it is added as template code for future usage enums::Connector::Payme => Ok(Box::new(&connector::Payme)), enums::Connector::Payu => Ok(Box::new(&connector::Payu)), + enums::Connector::Placetopay => Ok(Box::new(&connector::Placetopay)), enums::Connector::Powertranz => Ok(Box::new(&connector::Powertranz)), enums::Connector::Prophetpay => Ok(Box::new(&connector::Prophetpay)), enums::Connector::Rapyd => Ok(Box::new(&connector::Rapyd)), diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rs index 34ae3dceb5..9f5d46aba4 100644 --- a/crates/router/src/types/transformers.rs +++ b/crates/router/src/types/transformers.rs @@ -212,6 +212,7 @@ impl ForeignTryFrom for common_enums::RoutableConnectors { api_enums::Connector::Payme => Self::Payme, api_enums::Connector::Paypal => Self::Paypal, api_enums::Connector::Payu => Self::Payu, + api_models::enums::Connector::Placetopay => Self::Placetopay, api_enums::Connector::Plaid => { Err(common_utils::errors::ValidationError::InvalidValue { message: "plaid is not a routable connector".to_string(), diff --git a/crates/router/tests/connectors/main.rs b/crates/router/tests/connectors/main.rs index fc474818b5..8db743d609 100644 --- a/crates/router/tests/connectors/main.rs +++ b/crates/router/tests/connectors/main.rs @@ -45,6 +45,7 @@ mod payeezy; mod payme; mod paypal; mod payu; +mod placetopay; mod powertranz; #[cfg(feature = "dummy_connector")] mod prophetpay; diff --git a/crates/router/tests/connectors/placetopay.rs b/crates/router/tests/connectors/placetopay.rs new file mode 100644 index 0000000000..b7c70c789d --- /dev/null +++ b/crates/router/tests/connectors/placetopay.rs @@ -0,0 +1,420 @@ +use masking::Secret; +use router::types::{self, api, storage::enums}; +use test_utils::connector_auth; + +use crate::utils::{self, ConnectorActions}; + +#[derive(Clone, Copy)] +struct PlacetopayTest; +impl ConnectorActions for PlacetopayTest {} +impl utils::Connector for PlacetopayTest { + fn get_data(&self) -> types::api::ConnectorData { + use router::connector::Placetopay; + types::api::ConnectorData { + connector: Box::new(&Placetopay), + connector_name: types::Connector::Placetopay, + get_token: types::api::GetToken::Connector, + merchant_connector_id: None, + } + } + + fn get_auth_token(&self) -> types::ConnectorAuthType { + utils::to_connector_auth_type( + connector_auth::ConnectorAuthentication::new() + .placetopay + .expect("Missing connector authentication configuration") + .into(), + ) + } + + fn get_name(&self) -> String { + "placetopay".to_string() + } +} + +static CONNECTOR: PlacetopayTest = PlacetopayTest {}; + +fn get_default_payment_info() -> Option { + None +} + +fn payment_method_details() -> Option { + None +} + +// Cards Positive Tests +// Creates a payment using the manual capture flow (Non 3DS). +#[actix_web::test] +async fn should_only_authorize_payment() { + let response = CONNECTOR + .authorize_payment(payment_method_details(), get_default_payment_info()) + .await + .expect("Authorize payment response"); + assert_eq!(response.status, enums::AttemptStatus::Authorized); +} + +// Captures a payment using the manual capture flow (Non 3DS). +#[actix_web::test] +async fn should_capture_authorized_payment() { + let response = CONNECTOR + .authorize_and_capture_payment(payment_method_details(), None, get_default_payment_info()) + .await + .expect("Capture payment response"); + assert_eq!(response.status, enums::AttemptStatus::Charged); +} + +// Partially captures a payment using the manual capture flow (Non 3DS). +#[actix_web::test] +async fn should_partially_capture_authorized_payment() { + let response = CONNECTOR + .authorize_and_capture_payment( + payment_method_details(), + Some(types::PaymentsCaptureData { + amount_to_capture: 50, + ..utils::PaymentCaptureType::default().0 + }), + get_default_payment_info(), + ) + .await + .expect("Capture payment response"); + assert_eq!(response.status, enums::AttemptStatus::Charged); +} + +// Synchronizes a payment using the manual capture flow (Non 3DS). +#[actix_web::test] +async fn should_sync_authorized_payment() { + let authorize_response = CONNECTOR + .authorize_payment(payment_method_details(), get_default_payment_info()) + .await + .expect("Authorize payment response"); + let txn_id = utils::get_connector_transaction_id(authorize_response.response); + let response = CONNECTOR + .psync_retry_till_status_matches( + enums::AttemptStatus::Authorized, + Some(types::PaymentsSyncData { + connector_transaction_id: router::types::ResponseId::ConnectorTransactionId( + txn_id.unwrap(), + ), + ..Default::default() + }), + get_default_payment_info(), + ) + .await + .expect("PSync response"); + assert_eq!(response.status, enums::AttemptStatus::Authorized,); +} + +// Voids a payment using the manual capture flow (Non 3DS). +#[actix_web::test] +async fn should_void_authorized_payment() { + let response = CONNECTOR + .authorize_and_void_payment( + payment_method_details(), + Some(types::PaymentsCancelData { + connector_transaction_id: String::from(""), + cancellation_reason: Some("requested_by_customer".to_string()), + ..Default::default() + }), + get_default_payment_info(), + ) + .await + .expect("Void payment response"); + assert_eq!(response.status, enums::AttemptStatus::Voided); +} + +// Refunds a payment using the manual capture flow (Non 3DS). +#[actix_web::test] +async fn should_refund_manually_captured_payment() { + let response = CONNECTOR + .capture_payment_and_refund( + payment_method_details(), + None, + None, + get_default_payment_info(), + ) + .await + .unwrap(); + assert_eq!( + response.response.unwrap().refund_status, + enums::RefundStatus::Success, + ); +} + +// Partially refunds a payment using the manual capture flow (Non 3DS). +#[actix_web::test] +async fn should_partially_refund_manually_captured_payment() { + let response = CONNECTOR + .capture_payment_and_refund( + payment_method_details(), + None, + Some(types::RefundsData { + refund_amount: 50, + ..utils::PaymentRefundType::default().0 + }), + get_default_payment_info(), + ) + .await + .unwrap(); + assert_eq!( + response.response.unwrap().refund_status, + enums::RefundStatus::Success, + ); +} + +// Synchronizes a refund using the manual capture flow (Non 3DS). +#[actix_web::test] +async fn should_sync_manually_captured_refund() { + let refund_response = CONNECTOR + .capture_payment_and_refund( + payment_method_details(), + None, + None, + get_default_payment_info(), + ) + .await + .unwrap(); + let response = CONNECTOR + .rsync_retry_till_status_matches( + enums::RefundStatus::Success, + refund_response.response.unwrap().connector_refund_id, + None, + get_default_payment_info(), + ) + .await + .unwrap(); + assert_eq!( + response.response.unwrap().refund_status, + enums::RefundStatus::Success, + ); +} + +// Creates a payment using the automatic capture flow (Non 3DS). +#[actix_web::test] +async fn should_make_payment() { + let authorize_response = CONNECTOR + .make_payment(payment_method_details(), get_default_payment_info()) + .await + .unwrap(); + assert_eq!(authorize_response.status, enums::AttemptStatus::Charged); +} + +// Synchronizes a payment using the automatic capture flow (Non 3DS). +#[actix_web::test] +async fn should_sync_auto_captured_payment() { + let authorize_response = CONNECTOR + .make_payment(payment_method_details(), get_default_payment_info()) + .await + .unwrap(); + assert_eq!(authorize_response.status, enums::AttemptStatus::Charged); + let txn_id = utils::get_connector_transaction_id(authorize_response.response); + assert_ne!(txn_id, None, "Empty connector transaction id"); + let response = CONNECTOR + .psync_retry_till_status_matches( + enums::AttemptStatus::Charged, + Some(types::PaymentsSyncData { + connector_transaction_id: router::types::ResponseId::ConnectorTransactionId( + txn_id.unwrap(), + ), + capture_method: Some(enums::CaptureMethod::Automatic), + ..Default::default() + }), + get_default_payment_info(), + ) + .await + .unwrap(); + assert_eq!(response.status, enums::AttemptStatus::Charged,); +} + +// Refunds a payment using the automatic capture flow (Non 3DS). +#[actix_web::test] +async fn should_refund_auto_captured_payment() { + let response = CONNECTOR + .make_payment_and_refund(payment_method_details(), None, get_default_payment_info()) + .await + .unwrap(); + assert_eq!( + response.response.unwrap().refund_status, + enums::RefundStatus::Success, + ); +} + +// Partially refunds a payment using the automatic capture flow (Non 3DS). +#[actix_web::test] +async fn should_partially_refund_succeeded_payment() { + let refund_response = CONNECTOR + .make_payment_and_refund( + payment_method_details(), + Some(types::RefundsData { + refund_amount: 50, + ..utils::PaymentRefundType::default().0 + }), + get_default_payment_info(), + ) + .await + .unwrap(); + assert_eq!( + refund_response.response.unwrap().refund_status, + enums::RefundStatus::Success, + ); +} + +// Creates multiple refunds against a payment using the automatic capture flow (Non 3DS). +#[actix_web::test] +async fn should_refund_succeeded_payment_multiple_times() { + CONNECTOR + .make_payment_and_multiple_refund( + payment_method_details(), + Some(types::RefundsData { + refund_amount: 50, + ..utils::PaymentRefundType::default().0 + }), + get_default_payment_info(), + ) + .await; +} + +// Synchronizes a refund using the automatic capture flow (Non 3DS). +#[actix_web::test] +async fn should_sync_refund() { + let refund_response = CONNECTOR + .make_payment_and_refund(payment_method_details(), None, get_default_payment_info()) + .await + .unwrap(); + let response = CONNECTOR + .rsync_retry_till_status_matches( + enums::RefundStatus::Success, + refund_response.response.unwrap().connector_refund_id, + None, + get_default_payment_info(), + ) + .await + .unwrap(); + assert_eq!( + response.response.unwrap().refund_status, + enums::RefundStatus::Success, + ); +} + +// Cards Negative scenerios +// Creates a payment with incorrect CVC. +#[actix_web::test] +async fn should_fail_payment_for_incorrect_cvc() { + let response = CONNECTOR + .make_payment( + Some(types::PaymentsAuthorizeData { + payment_method_data: types::api::PaymentMethodData::Card(api::Card { + card_cvc: Secret::new("12345".to_string()), + ..utils::CCardType::default().0 + }), + ..utils::PaymentAuthorizeType::default().0 + }), + get_default_payment_info(), + ) + .await + .unwrap(); + assert_eq!( + response.response.unwrap_err().message, + "Your card's security code is invalid.".to_string(), + ); +} + +// Creates a payment with incorrect expiry month. +#[actix_web::test] +async fn should_fail_payment_for_invalid_exp_month() { + let response = CONNECTOR + .make_payment( + Some(types::PaymentsAuthorizeData { + payment_method_data: types::api::PaymentMethodData::Card(api::Card { + card_exp_month: Secret::new("20".to_string()), + ..utils::CCardType::default().0 + }), + ..utils::PaymentAuthorizeType::default().0 + }), + get_default_payment_info(), + ) + .await + .unwrap(); + assert_eq!( + response.response.unwrap_err().message, + "Your card's expiration month is invalid.".to_string(), + ); +} + +// Creates a payment with incorrect expiry year. +#[actix_web::test] +async fn should_fail_payment_for_incorrect_expiry_year() { + let response = CONNECTOR + .make_payment( + Some(types::PaymentsAuthorizeData { + payment_method_data: types::api::PaymentMethodData::Card(api::Card { + card_exp_year: Secret::new("2000".to_string()), + ..utils::CCardType::default().0 + }), + ..utils::PaymentAuthorizeType::default().0 + }), + get_default_payment_info(), + ) + .await + .unwrap(); + assert_eq!( + response.response.unwrap_err().message, + "Your card's expiration year is invalid.".to_string(), + ); +} + +// Voids a payment using automatic capture flow (Non 3DS). +#[actix_web::test] +async fn should_fail_void_payment_for_auto_capture() { + let authorize_response = CONNECTOR + .make_payment(payment_method_details(), get_default_payment_info()) + .await + .unwrap(); + assert_eq!(authorize_response.status, enums::AttemptStatus::Charged); + let txn_id = utils::get_connector_transaction_id(authorize_response.response); + assert_ne!(txn_id, None, "Empty connector transaction id"); + let void_response = CONNECTOR + .void_payment(txn_id.unwrap(), None, get_default_payment_info()) + .await + .unwrap(); + assert_eq!( + void_response.response.unwrap_err().message, + "You cannot cancel this PaymentIntent because it has a status of succeeded." + ); +} + +// Captures a payment using invalid connector payment id. +#[actix_web::test] +async fn should_fail_capture_for_invalid_payment() { + let capture_response = CONNECTOR + .capture_payment("123456789".to_string(), None, get_default_payment_info()) + .await + .unwrap(); + assert_eq!( + capture_response.response.unwrap_err().message, + String::from("No such payment_intent: '123456789'") + ); +} + +// Refunds a payment with refund amount higher than payment amount. +#[actix_web::test] +async fn should_fail_for_refund_amount_higher_than_payment_amount() { + let response = CONNECTOR + .make_payment_and_refund( + payment_method_details(), + Some(types::RefundsData { + refund_amount: 150, + ..utils::PaymentRefundType::default().0 + }), + get_default_payment_info(), + ) + .await + .unwrap(); + assert_eq!( + response.response.unwrap_err().message, + "Refund amount (₹1.50) is greater than charge amount (₹1.00)", + ); +} + +// Connector dependent test cases goes here + +// [#478]: add unit tests for non 3DS, wallets & webhooks in connector tests diff --git a/crates/router/tests/connectors/sample_auth.toml b/crates/router/tests/connectors/sample_auth.toml index f8f6039d6d..ff179f7450 100644 --- a/crates/router/tests/connectors/sample_auth.toml +++ b/crates/router/tests/connectors/sample_auth.toml @@ -189,3 +189,7 @@ api_key="API Key" api_key = "MyApiKey" key1 = "Merchant id" api_secret = "Secret key" + +[placetopay] +api_key= "Login" +key1= "Trankey" diff --git a/crates/test_utils/src/connector_auth.rs b/crates/test_utils/src/connector_auth.rs index 9562972c12..d95d6ed94f 100644 --- a/crates/test_utils/src/connector_auth.rs +++ b/crates/test_utils/src/connector_auth.rs @@ -48,6 +48,7 @@ pub struct ConnectorAuthentication { pub payme: Option, pub paypal: Option, pub payu: Option, + pub placetopay: Option, pub powertranz: Option, pub prophetpay: Option, pub rapyd: Option, diff --git a/loadtest/config/development.toml b/loadtest/config/development.toml index f4070beb94..c8c6b19211 100644 --- a/loadtest/config/development.toml +++ b/loadtest/config/development.toml @@ -111,6 +111,7 @@ payeezy.base_url = "https://api-cert.payeezy.com/" payme.base_url = "https://sandbox.payme.io/" paypal.base_url = "https://api-m.sandbox.paypal.com/" payu.base_url = "https://secure.snd.payu.com/" +placetopay.base_url = "https://api-co-dev.placetopay.ws/gateway" powertranz.base_url = "https://staging.ptranz.com/api/" prophetpay.base_url = "https://ccm-thirdparty.cps.golf/" rapyd.base_url = "https://sandboxapi.rapyd.net" @@ -173,6 +174,7 @@ cards = [ "payme", "paypal", "payu", + "placetopay", "powertranz", "prophetpay", "shift4", diff --git a/openapi/openapi_spec.json b/openapi/openapi_spec.json index f77638a43d..3c0206a158 100644 --- a/openapi/openapi_spec.json +++ b/openapi/openapi_spec.json @@ -4380,6 +4380,7 @@ "payme", "paypal", "payu", + "placetopay", "powertranz", "prophetpay", "rapyd", diff --git a/scripts/add_connector.sh b/scripts/add_connector.sh index 1246c51d8e..c1f59cb363 100755 --- a/scripts/add_connector.sh +++ b/scripts/add_connector.sh @@ -6,7 +6,7 @@ function find_prev_connector() { git checkout $self cp $self $self.tmp # Add new connector to existing list and sort it - connectors=(aci adyen airwallex applepay authorizedotnet bambora bankofamerica bitpay bluesnap boku braintree cashtocode checkout coinbase cryptopay cybersource dlocal dummyconnector fiserv forte globalpay globepay gocardless helcim iatapay klarna mollie multisafepay nexinets noon nuvei opayo opennode payeezy payme paypal payu powertranz prophetpay rapyd shift4 square stax stripe trustpay tsys volt wise worldline worldpay "$1") + connectors=(aci adyen airwallex applepay authorizedotnet bambora bankofamerica bitpay bluesnap boku braintree cashtocode checkout coinbase cryptopay cybersource dlocal dummyconnector fiserv forte globalpay globepay gocardless helcim iatapay klarna mollie multisafepay nexinets noon nuvei opayo opennode payeezy payme paypal payu placetopay powertranz prophetpay rapyd shift4 square stax stripe trustpay tsys volt wise worldline worldpay "$1") IFS=$'\n' sorted=($(sort <<<"${connectors[*]}")); unset IFS res=`echo ${sorted[@]}` sed -i'' -e "s/^ connectors=.*/ connectors=($res \"\$1\")/" $self.tmp