Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
feat(connector): Added ThreeDs server integration template pr (#7424)
Sahkal Poddar7e5da488b349
diff --git a/config/config.example.toml b/config/config.example.tomlindex aedcabcade..7d6f19c4d6 100644--- a/config/config.example.toml+++ b/config/config.example.toml@@ -223,6 +223,7 @@ iatapay.base_url = "https://sandbox.iata-pay.iata.org/api/v1"inespay.base_url = "https://apiflow.inespay.com/san/v21"itaubank.base_url = "https://sandbox.devportal.itau.com.br/"jpmorgan.base_url = "https://api-mock.payments.jpmorgan.com/api/v2"+juspaythreedsserver.base_url = "http://localhost:8000"jpmorgan.secondary_base_url= "https://id.payments.jpmorgan.com"klarna.base_url = "https://api{{klarna_region}}.playground.klarna.com/"mifinity.base_url = "https://demo.mifinity.com/"diff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.tomlindex a6a7a09e16..77afe3dc60 100644--- a/config/deployments/integration_test.toml+++ b/config/deployments/integration_test.toml@@ -69,6 +69,7 @@ iatapay.base_url = "https://sandbox.iata-pay.iata.org/api/v1"inespay.base_url = "https://apiflow.inespay.com/san/v21"itaubank.base_url = "https://sandbox.devportal.itau.com.br/"jpmorgan.base_url = "https://api-mock.payments.jpmorgan.com/api/v2"+juspaythreedsserver.base_url = "http://localhost:8000"jpmorgan.secondary_base_url="https://id.payments.jpmorgan.com"klarna.base_url = "https://api{{klarna_region}}.playground.klarna.com/"mifinity.base_url = "https://demo.mifinity.com/"diff --git a/config/deployments/production.toml b/config/deployments/production.tomlindex e8f2c30c69..e7ad09e4fc 100644--- a/config/deployments/production.toml+++ b/config/deployments/production.toml@@ -73,6 +73,7 @@ iatapay.base_url = "https://iata-pay.iata.org/api/v1"inespay.base_url = "https://apiflow.inespay.com/san/v21"itaubank.base_url = "https://secure.api.itau/"jpmorgan.base_url = "https://api-ms.payments.jpmorgan.com/api/v2"+juspaythreedsserver.base_url = "http://localhost:8000"jpmorgan.secondary_base_url="https://id.payments.jpmorgan.com"klarna.base_url = "https://api{{klarna_region}}.klarna.com/"mifinity.base_url = "https://secure.mifinity.com/"diff --git a/config/deployments/sandbox.toml b/config/deployments/sandbox.tomlindex 302ff6f3a0..07412b6ef8 100644--- a/config/deployments/sandbox.toml+++ b/config/deployments/sandbox.toml@@ -73,6 +73,7 @@ iatapay.base_url = "https://sandbox.iata-pay.iata.org/api/v1"inespay.base_url = "https://apiflow.inespay.com/san/v21"itaubank.base_url = "https://sandbox.devportal.itau.com.br/"jpmorgan.base_url = "https://api-mock.payments.jpmorgan.com/api/v2"+juspaythreedsserver.base_url = "http://localhost:8000"jpmorgan.secondary_base_url="https://id.payments.jpmorgan.com"klarna.base_url = "https://api{{klarna_region}}.playground.klarna.com/"mifinity.base_url = "https://demo.mifinity.com/"diff --git a/config/development.toml b/config/development.tomlindex 7031d79149..2acfea968d 100644--- a/config/development.toml+++ b/config/development.toml@@ -180,6 +180,7 @@ cards = ["inespay","itaubank","jpmorgan",+ "juspaythreedsserver","mollie","moneris","multisafepay",@@ -295,6 +296,7 @@ iatapay.base_url = "https://sandbox.iata-pay.iata.org/api/v1"inespay.base_url = "https://apiflow.inespay.com/san/v21"itaubank.base_url = "https://sandbox.devportal.itau.com.br/"jpmorgan.base_url = "https://api-mock.payments.jpmorgan.com/api/v2"+juspaythreedsserver.base_url = "http://localhost:8000"jpmorgan.secondary_base_url = "https://id.payments.jpmorgan.com"klarna.base_url = "https://api{{klarna_region}}.playground.klarna.com/"mifinity.base_url = "https://demo.mifinity.com/"diff --git a/config/docker_compose.toml b/config/docker_compose.tomlindex 259fe51ab8..6da16f1edf 100644--- a/config/docker_compose.toml+++ b/config/docker_compose.toml@@ -155,6 +155,7 @@ iatapay.base_url = "https://sandbox.iata-pay.iata.org/api/v1"inespay.base_url = "https://apiflow.inespay.com/san/v21"itaubank.base_url = "https://sandbox.devportal.itau.com.br/"jpmorgan.base_url = "https://api-mock.payments.jpmorgan.com/api/v2"+juspaythreedsserver.base_url = "http://localhost:8000"jpmorgan.secondary_base_url="https://id.payments.jpmorgan.com"klarna.base_url = "https://api{{klarna_region}}.playground.klarna.com/"mifinity.base_url = "https://demo.mifinity.com/"@@ -264,6 +265,7 @@ cards = ["inespay","itaubank","jpmorgan",+ "juspaythreedsserver","mollie","moneris","multisafepay",diff --git a/crates/common_enums/src/connector_enums.rs b/crates/common_enums/src/connector_enums.rsindex 65fa444175..f5d0d0eb40 100644--- a/crates/common_enums/src/connector_enums.rs+++ b/crates/common_enums/src/connector_enums.rs@@ -233,6 +233,7 @@ pub enum Connector {Iatapay,Itaubank,Jpmorgan,+ Juspaythreedsserver,Klarna,Mifinity,Mollie,@@ -389,6 +390,7 @@ impl Connector {| Self::Inespay| Self::Itaubank| Self::Jpmorgan+ | Self::Juspaythreedsserver| Self::Klarna| Self::Mifinity| Self::Molliediff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rsindex 208fb7dedb..dbbee9764f 100644--- a/crates/common_enums/src/enums.rs+++ b/crates/common_enums/src/enums.rs@@ -6502,6 +6502,7 @@ pub enum AuthenticationConnectors {Gpayments,CtpMastercard,UnifiedAuthenticationService,+ Juspaythreedsserver,}impl AuthenticationConnectors {@@ -6510,7 +6511,8 @@ impl AuthenticationConnectors {Self::Threedsecureio| Self::Netcetera| Self::CtpMastercard- | Self::UnifiedAuthenticationService => false,+ | Self::UnifiedAuthenticationService+ | Self::Juspaythreedsserver => false,Self::Gpayments => true,}}diff --git a/crates/connector_configs/src/connector.rs b/crates/connector_configs/src/connector.rsindex 8920e39b5b..5f281ec924 100644--- a/crates/connector_configs/src/connector.rs+++ b/crates/connector_configs/src/connector.rs@@ -156,6 +156,7 @@ pub struct ConnectorTomlConfig {#[serde_with::skip_serializing_none]#[derive(Debug, Deserialize, serde::Serialize, Clone)]pub struct ConnectorConfig {+ pub juspaythreedsserver: Option<ConnectorTomlConfig>,pub aci: Option<ConnectorTomlConfig>,pub adyen: Option<ConnectorTomlConfig>,#[cfg(feature = "payouts")]@@ -304,6 +305,7 @@ impl ConnectorConfig {AuthenticationConnectors::UnifiedAuthenticationService => {Ok(connector_data.unified_authentication_service)}+ AuthenticationConnectors::Juspaythreedsserver => Ok(connector_data.juspaythreedsserver),}}@@ -371,6 +373,7 @@ impl ConnectorConfig {Connector::Helcim => Ok(connector_data.helcim),Connector::Inespay => Ok(connector_data.inespay),Connector::Jpmorgan => Ok(connector_data.jpmorgan),+ Connector::Juspaythreedsserver => Ok(connector_data.juspaythreedsserver),Connector::Klarna => Ok(connector_data.klarna),Connector::Mifinity => Ok(connector_data.mifinity),Connector::Mollie => Ok(connector_data.mollie),diff --git a/crates/connector_configs/toml/development.toml b/crates/connector_configs/toml/development.tomlindex 8f544db131..7404fcf18f 100644--- a/crates/connector_configs/toml/development.toml+++ b/crates/connector_configs/toml/development.toml@@ -4617,4 +4617,55 @@ merchant_secret="Webhook Verification Token"api_key="API Key"key1="API Token"[inespay.connector_webhook_details]-merchant_secret="API Key"\ No newline at end of file+merchant_secret="API Key"++[juspaythreedsserver]+[juspaythreedsserver.metadata.mcc]+name="mcc"+label="MCC"+placeholder="Enter MCC"+required=false+type="Text"++[juspaythreedsserver.metadata.merchant_country_code]+name="merchant_country_code"+label="3 digit numeric country code"+placeholder="Enter 3 digit numeric country code"+required=false+type="Text"+[juspaythreedsserver.metadata.merchant_name]+name="merchant_name"+label="Name of the merchant"+placeholder="Enter Name of the merchant"+required=false+type="Text"+[juspaythreedsserver.metadata.three_ds_requestor_name]+name="three_ds_requestor_name"+label="ThreeDS requestor name"+placeholder="Enter ThreeDS requestor name"+required=false+type="Text"+[juspaythreedsserver.metadata.three_ds_requestor_id]+name="three_ds_requestor_id"+label="ThreeDS request id"+placeholder="Enter ThreeDS request id"+required=false+type="Text"+[juspaythreedsserver.metadata.acquirer_bin]+name="acquirer_bin"+label="Acquirer Bin"+placeholder="Enter Acquirer Bin"+required=true+type="Text"+[juspaythreedsserver.metadata.acquirer_country_code]+name="acquirer_country_code"+label="Acquirer Country Code"+placeholder="Enter Acquirer Country Code"+required=true+type="Text"+[juspaythreedsserver.metadata.acquirer_merchant_id]+name="acquirer_merchant_id"+label="Acquirer Merchant Id"+placeholder="Enter Acquirer Merchant Id"+required=true+type="Text"\ No newline at end of filediff --git a/crates/connector_configs/toml/sandbox.toml b/crates/connector_configs/toml/sandbox.tomlindex f7a1b114cc..a816ed4277 100644--- a/crates/connector_configs/toml/sandbox.toml+++ b/crates/connector_configs/toml/sandbox.toml@@ -4558,4 +4558,55 @@ merchant_secret="Webhook Verification Token"api_key="API Key"key1="API Token"[inespay.connector_webhook_details]-merchant_secret="API Key"\ No newline at end of file+merchant_secret="API Key"++[juspaythreedsserver]+[juspaythreedsserver.metadata.mcc]+name="mcc"+label="MCC"+placeholder="Enter MCC"+required=false+type="Text"++[juspaythreedsserver.metadata.merchant_country_code]+name="merchant_country_code"+label="3 digit numeric country code"+placeholder="Enter 3 digit numeric country code"+required=false+type="Text"+[juspaythreedsserver.metadata.merchant_name]+name="merchant_name"+label="Name of the merchant"+placeholder="Enter Name of the merchant"+required=false+type="Text"+[juspaythreedsserver.metadata.three_ds_requestor_name]+name="three_ds_requestor_name"+label="ThreeDS requestor name"+placeholder="Enter ThreeDS requestor name"+required=false+type="Text"+[juspaythreedsserver.metadata.three_ds_requestor_id]+name="three_ds_requestor_id"+label="ThreeDS request id"+placeholder="Enter ThreeDS request id"+required=false+type="Text"+[juspaythreedsserver.metadata.acquirer_bin]+name="acquirer_bin"+label="Acquirer Bin"+placeholder="Enter Acquirer Bin"+required=true+type="Text"+[juspaythreedsserver.metadata.acquirer_country_code]+name="acquirer_country_code"+label="Acquirer Country Code"+placeholder="Enter Acquirer Country Code"+required=true+type="Text"+[juspaythreedsserver.metadata.acquirer_merchant_id]+name="acquirer_merchant_id"+label="Acquirer Merchant Id"+placeholder="Enter Acquirer Merchant Id"+required=true+type="Text"diff --git a/crates/hyperswitch_connectors/src/connectors.rs b/crates/hyperswitch_connectors/src/connectors.rsindex 495228de0c..f987c01dbd 100644--- a/crates/hyperswitch_connectors/src/connectors.rs+++ b/crates/hyperswitch_connectors/src/connectors.rs@@ -36,6 +36,7 @@ pub mod iatapay;pub mod inespay;pub mod itaubank;pub mod jpmorgan;+pub mod juspaythreedsserver;pub mod klarna;pub mod mifinity;pub mod mollie;@@ -88,14 +89,14 @@ pub use self::{elavon::Elavon, fiserv::Fiserv, fiservemea::Fiservemea, fiuu::Fiuu, forte::Forte,getnet::Getnet, globalpay::Globalpay, globepay::Globepay, gocardless::Gocardless,helcim::Helcim, iatapay::Iatapay, inespay::Inespay, itaubank::Itaubank, jpmorgan::Jpmorgan,- klarna::Klarna, mifinity::Mifinity, mollie::Mollie, moneris::Moneris,- multisafepay::Multisafepay, nexinets::Nexinets, nexixpay::Nexixpay, nomupay::Nomupay,- noon::Noon, novalnet::Novalnet, nuvei::Nuvei, opayo::Opayo, opennode::Opennode, paybox::Paybox,- payeezy::Payeezy, payme::Payme, paystack::Paystack, payu::Payu, placetopay::Placetopay,- powertranz::Powertranz, prophetpay::Prophetpay, rapyd::Rapyd, razorpay::Razorpay,- recurly::Recurly, redsys::Redsys, shift4::Shift4, square::Square, stax::Stax,- stripebilling::Stripebilling, taxjar::Taxjar, thunes::Thunes, trustpay::Trustpay, tsys::Tsys,- unified_authentication_service::UnifiedAuthenticationService, volt::Volt,- wellsfargo::Wellsfargo, worldline::Worldline, worldpay::Worldpay, xendit::Xendit, zen::Zen,- zsl::Zsl,+ juspaythreedsserver::Juspaythreedsserver, klarna::Klarna, mifinity::Mifinity, mollie::Mollie,+ moneris::Moneris, multisafepay::Multisafepay, nexinets::Nexinets, nexixpay::Nexixpay,+ nomupay::Nomupay, noon::Noon, novalnet::Novalnet, nuvei::Nuvei, opayo::Opayo,+ opennode::Opennode, paybox::Paybox, payeezy::Payeezy, payme::Payme, paystack::Paystack,+ payu::Payu, placetopay::Placetopay, powertranz::Powertranz, prophetpay::Prophetpay,+ rapyd::Rapyd, razorpay::Razorpay, recurly::Recurly, redsys::Redsys, shift4::Shift4,+ square::Square, stax::Stax, stripebilling::Stripebilling, taxjar::Taxjar, thunes::Thunes,+ trustpay::Trustpay, tsys::Tsys, unified_authentication_service::UnifiedAuthenticationService,+ volt::Volt, wellsfargo::Wellsfargo, worldline::Worldline, worldpay::Worldpay, xendit::Xendit,+ zen::Zen, zsl::Zsl,};diff --git a/crates/hyperswitch_connectors/src/connectors/juspaythreedsserver.rs b/crates/hyperswitch_connectors/src/connectors/juspaythreedsserver.rsnew file mode 100644index 0000000000..cbe7881c53--- /dev/null+++ b/crates/hyperswitch_connectors/src/connectors/juspaythreedsserver.rs@@ -0,0 +1,629 @@+pub mod transformers;++use common_utils::{+ errors::CustomResult,+ ext_traits::BytesExt,+ request::{Method, Request, RequestBuilder, RequestContent},+ types::{AmountConvertor, StringMinorUnit, StringMinorUnitForConnector},+};+use error_stack::{report, ResultExt};+use hyperswitch_domain_models::{+ router_data::{AccessToken, ConnectorAuthType, ErrorResponse, RouterData},+ router_flow_types::{+ access_token_auth::AccessTokenAuth,+ payments::{Authorize, Capture, PSync, PaymentMethodToken, Session, SetupMandate, Void},+ refunds::{Execute, RSync},+ Authenticate, AuthenticationConfirmation, PostAuthenticate, PreAuthenticate,+ },+ router_request_types::{+ unified_authentication_service::{+ UasAuthenticationRequestData, UasAuthenticationResponseData,+ UasConfirmationRequestData, UasPostAuthenticationRequestData,+ UasPreAuthenticationRequestData,+ },+ AccessTokenRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,+ PaymentsCancelData, PaymentsCaptureData, PaymentsSessionData, PaymentsSyncData,+ RefundsData, SetupMandateRequestData,+ },+ router_response_types::{PaymentsResponseData, RefundsResponseData},+ types::{+ PaymentsAuthorizeRouterData, PaymentsCaptureRouterData, PaymentsSyncRouterData,+ RefundSyncRouterData, RefundsRouterData,+ },+};+use hyperswitch_interfaces::{+ api::{+ self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications,+ ConnectorValidation,+ },+ configs::Connectors,+ errors,+ events::connector_api_logs::ConnectorEvent,+ types::{self, Response},+ webhooks,+};+use masking::{ExposeInterface, Mask};+use transformers as juspaythreedsserver;++use crate::{constants::headers, types::ResponseRouterData, utils};++#[derive(Clone)]+pub struct Juspaythreedsserver {+ amount_converter: &'static (dyn AmountConvertor<Output = StringMinorUnit> + Sync),+}++impl Juspaythreedsserver {+ pub fn new() -> &'static Self {+ &Self {+ amount_converter: &StringMinorUnitForConnector,+ }+ }+}++impl api::Payment for Juspaythreedsserver {}+impl api::PaymentSession for Juspaythreedsserver {}+impl api::ConnectorAccessToken for Juspaythreedsserver {}+impl api::MandateSetup for Juspaythreedsserver {}+impl api::PaymentAuthorize for Juspaythreedsserver {}+impl api::PaymentSync for Juspaythreedsserver {}+impl api::PaymentCapture for Juspaythreedsserver {}+impl api::PaymentVoid for Juspaythreedsserver {}+impl api::Refund for Juspaythreedsserver {}+impl api::RefundExecute for Juspaythreedsserver {}+impl api::RefundSync for Juspaythreedsserver {}+impl api::PaymentToken for Juspaythreedsserver {}+impl api::UnifiedAuthenticationService for Juspaythreedsserver {}+impl api::UasPreAuthentication for Juspaythreedsserver {}+impl api::UasPostAuthentication for Juspaythreedsserver {}+impl api::UasAuthenticationConfirmation for Juspaythreedsserver {}+impl api::UasAuthentication for Juspaythreedsserver {}++impl+ ConnectorIntegration<+ PreAuthenticate,+ UasPreAuthenticationRequestData,+ UasAuthenticationResponseData,+ > for Juspaythreedsserver+{+}++impl+ ConnectorIntegration<+ PostAuthenticate,+ UasPostAuthenticationRequestData,+ UasAuthenticationResponseData,+ > for Juspaythreedsserver+{+}++impl+ ConnectorIntegration<+ AuthenticationConfirmation,+ UasConfirmationRequestData,+ UasAuthenticationResponseData,+ > for Juspaythreedsserver+{+}++impl ConnectorIntegration<Authenticate, UasAuthenticationRequestData, UasAuthenticationResponseData>+ for Juspaythreedsserver+{+}++impl ConnectorIntegration<PaymentMethodToken, PaymentMethodTokenizationData, PaymentsResponseData>+ for Juspaythreedsserver+{+ // Not Implemented (R)+}++impl<Flow, Request, Response> ConnectorCommonExt<Flow, Request, Response> for Juspaythreedsserver+where+ Self: ConnectorIntegration<Flow, Request, Response>,+{+ fn build_headers(+ &self,+ req: &RouterData<Flow, Request, Response>,+ _connectors: &Connectors,+ ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, 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 Juspaythreedsserver {+ fn id(&self) -> &'static str {+ "juspaythreedsserver"+ }++ fn get_currency_unit(&self) -> api::CurrencyUnit {+ api::CurrencyUnit::Base+ // TODO! Check connector documentation, on which unit they are processing the currency.+ // If the connector accepts amount in lower unit ( i.e cents for USD) then return api::CurrencyUnit::Minor,+ // if connector accepts amount in base unit (i.e dollars for USD) then return api::CurrencyUnit::Base+ }++ fn common_get_content_type(&self) -> &'static str {+ "application/json"+ }++ fn base_url<'a>(&self, connectors: &'a Connectors) -> &'a str {+ connectors.juspaythreedsserver.base_url.as_ref()+ }++ fn get_auth_header(+ &self,+ auth_type: &ConnectorAuthType,+ ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {+ let auth = juspaythreedsserver::JuspaythreedsserverAuthType::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,+ event_builder: Option<&mut ConnectorEvent>,+ ) -> CustomResult<ErrorResponse, errors::ConnectorError> {+ let response: juspaythreedsserver::JuspaythreedsserverErrorResponse = res+ .response+ .parse_struct("JuspaythreedsserverErrorResponse")+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;++ event_builder.map(|i| i.set_response_body(&response));+ router_env::logger::info!(connector_response=?response);++ 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 Juspaythreedsserver {+ //TODO: implement functions when support enabled+}++impl ConnectorIntegration<Session, PaymentsSessionData, PaymentsResponseData>+ for Juspaythreedsserver+{+ //TODO: implement sessions flow+}++impl ConnectorIntegration<AccessTokenAuth, AccessTokenRequestData, AccessToken>+ for Juspaythreedsserver+{+}++impl ConnectorIntegration<SetupMandate, SetupMandateRequestData, PaymentsResponseData>+ for Juspaythreedsserver+{+}++impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData>+ for Juspaythreedsserver+{+ fn get_headers(+ &self,+ req: &PaymentsAuthorizeRouterData,+ connectors: &Connectors,+ ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {+ self.build_headers(req, connectors)+ }++ fn get_content_type(&self) -> &'static str {+ self.common_get_content_type()+ }++ fn get_url(+ &self,+ _req: &PaymentsAuthorizeRouterData,+ _connectors: &Connectors,+ ) -> CustomResult<String, errors::ConnectorError> {+ Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())+ }++ fn get_request_body(+ &self,+ req: &PaymentsAuthorizeRouterData,+ _connectors: &Connectors,+ ) -> CustomResult<RequestContent, errors::ConnectorError> {+ let amount = utils::convert_amount(+ self.amount_converter,+ req.request.minor_amount,+ req.request.currency,+ )?;++ let connector_router_data =+ juspaythreedsserver::JuspaythreedsserverRouterData::from((amount, req));+ let connector_req = juspaythreedsserver::JuspaythreedsserverPaymentsRequest::try_from(+ &connector_router_data,+ )?;+ Ok(RequestContent::Json(Box::new(connector_req)))+ }++ fn build_request(+ &self,+ req: &PaymentsAuthorizeRouterData,+ connectors: &Connectors,+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {+ Ok(Some(+ RequestBuilder::new()+ .method(Method::Post)+ .url(&types::PaymentsAuthorizeType::get_url(+ self, req, connectors,+ )?)+ .attach_default_headers()+ .headers(types::PaymentsAuthorizeType::get_headers(+ self, req, connectors,+ )?)+ .set_body(types::PaymentsAuthorizeType::get_request_body(+ self, req, connectors,+ )?)+ .build(),+ ))+ }++ fn handle_response(+ &self,+ data: &PaymentsAuthorizeRouterData,+ event_builder: Option<&mut ConnectorEvent>,+ res: Response,+ ) -> CustomResult<PaymentsAuthorizeRouterData, errors::ConnectorError> {+ let response: juspaythreedsserver::JuspaythreedsserverPaymentsResponse = res+ .response+ .parse_struct("Juspaythreedsserver PaymentsAuthorizeResponse")+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;+ event_builder.map(|i| i.set_response_body(&response));+ router_env::logger::info!(connector_response=?response);+ RouterData::try_from(ResponseRouterData {+ response,+ data: data.clone(),+ http_code: res.status_code,+ })+ }++ fn get_error_response(+ &self,+ res: Response,+ event_builder: Option<&mut ConnectorEvent>,+ ) -> CustomResult<ErrorResponse, errors::ConnectorError> {+ self.build_error_response(res, event_builder)+ }+}++impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for Juspaythreedsserver {+ fn get_headers(+ &self,+ req: &PaymentsSyncRouterData,+ connectors: &Connectors,+ ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {+ self.build_headers(req, connectors)+ }++ fn get_content_type(&self) -> &'static str {+ self.common_get_content_type()+ }++ fn get_url(+ &self,+ _req: &PaymentsSyncRouterData,+ _connectors: &Connectors,+ ) -> CustomResult<String, errors::ConnectorError> {+ Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())+ }++ fn build_request(+ &self,+ req: &PaymentsSyncRouterData,+ connectors: &Connectors,+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {+ Ok(Some(+ RequestBuilder::new()+ .method(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: &PaymentsSyncRouterData,+ event_builder: Option<&mut ConnectorEvent>,+ res: Response,+ ) -> CustomResult<PaymentsSyncRouterData, errors::ConnectorError> {+ let response: juspaythreedsserver::JuspaythreedsserverPaymentsResponse = res+ .response+ .parse_struct("juspaythreedsserver PaymentsSyncResponse")+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;+ event_builder.map(|i| i.set_response_body(&response));+ router_env::logger::info!(connector_response=?response);+ RouterData::try_from(ResponseRouterData {+ response,+ data: data.clone(),+ http_code: res.status_code,+ })+ }++ fn get_error_response(+ &self,+ res: Response,+ event_builder: Option<&mut ConnectorEvent>,+ ) -> CustomResult<ErrorResponse, errors::ConnectorError> {+ self.build_error_response(res, event_builder)+ }+}++impl ConnectorIntegration<Capture, PaymentsCaptureData, PaymentsResponseData>+ for Juspaythreedsserver+{+ fn get_headers(+ &self,+ req: &PaymentsCaptureRouterData,+ connectors: &Connectors,+ ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {+ self.build_headers(req, connectors)+ }++ fn get_content_type(&self) -> &'static str {+ self.common_get_content_type()+ }++ fn get_url(+ &self,+ _req: &PaymentsCaptureRouterData,+ _connectors: &Connectors,+ ) -> CustomResult<String, errors::ConnectorError> {+ Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())+ }++ fn get_request_body(+ &self,+ _req: &PaymentsCaptureRouterData,+ _connectors: &Connectors,+ ) -> CustomResult<RequestContent, errors::ConnectorError> {+ Err(errors::ConnectorError::NotImplemented("get_request_body method".to_string()).into())+ }++ fn build_request(+ &self,+ req: &PaymentsCaptureRouterData,+ connectors: &Connectors,+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {+ Ok(Some(+ RequestBuilder::new()+ .method(Method::Post)+ .url(&types::PaymentsCaptureType::get_url(self, req, connectors)?)+ .attach_default_headers()+ .headers(types::PaymentsCaptureType::get_headers(+ self, req, connectors,+ )?)+ .set_body(types::PaymentsCaptureType::get_request_body(+ self, req, connectors,+ )?)+ .build(),+ ))+ }++ fn handle_response(+ &self,+ data: &PaymentsCaptureRouterData,+ event_builder: Option<&mut ConnectorEvent>,+ res: Response,+ ) -> CustomResult<PaymentsCaptureRouterData, errors::ConnectorError> {+ let response: juspaythreedsserver::JuspaythreedsserverPaymentsResponse = res+ .response+ .parse_struct("Juspaythreedsserver PaymentsCaptureResponse")+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;+ event_builder.map(|i| i.set_response_body(&response));+ router_env::logger::info!(connector_response=?response);+ RouterData::try_from(ResponseRouterData {+ response,+ data: data.clone(),+ http_code: res.status_code,+ })+ }++ fn get_error_response(+ &self,+ res: Response,+ event_builder: Option<&mut ConnectorEvent>,+ ) -> CustomResult<ErrorResponse, errors::ConnectorError> {+ self.build_error_response(res, event_builder)+ }+}++impl ConnectorIntegration<Void, PaymentsCancelData, PaymentsResponseData> for Juspaythreedsserver {}++impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Juspaythreedsserver {+ fn get_headers(+ &self,+ req: &RefundsRouterData<Execute>,+ connectors: &Connectors,+ ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {+ self.build_headers(req, connectors)+ }++ fn get_content_type(&self) -> &'static str {+ self.common_get_content_type()+ }++ fn get_url(+ &self,+ _req: &RefundsRouterData<Execute>,+ _connectors: &Connectors,+ ) -> CustomResult<String, errors::ConnectorError> {+ Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())+ }++ fn get_request_body(+ &self,+ req: &RefundsRouterData<Execute>,+ _connectors: &Connectors,+ ) -> CustomResult<RequestContent, errors::ConnectorError> {+ let refund_amount = utils::convert_amount(+ self.amount_converter,+ req.request.minor_refund_amount,+ req.request.currency,+ )?;++ let connector_router_data =+ juspaythreedsserver::JuspaythreedsserverRouterData::from((refund_amount, req));+ let connector_req = juspaythreedsserver::JuspaythreedsserverRefundRequest::try_from(+ &connector_router_data,+ )?;+ Ok(RequestContent::Json(Box::new(connector_req)))+ }++ fn build_request(+ &self,+ req: &RefundsRouterData<Execute>,+ connectors: &Connectors,+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {+ let request = RequestBuilder::new()+ .method(Method::Post)+ .url(&types::RefundExecuteType::get_url(self, req, connectors)?)+ .attach_default_headers()+ .headers(types::RefundExecuteType::get_headers(+ self, req, connectors,+ )?)+ .set_body(types::RefundExecuteType::get_request_body(+ self, req, connectors,+ )?)+ .build();+ Ok(Some(request))+ }++ fn handle_response(+ &self,+ data: &RefundsRouterData<Execute>,+ event_builder: Option<&mut ConnectorEvent>,+ res: Response,+ ) -> CustomResult<RefundsRouterData<Execute>, errors::ConnectorError> {+ let response: juspaythreedsserver::RefundResponse = res+ .response+ .parse_struct("juspaythreedsserver RefundResponse")+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;+ event_builder.map(|i| i.set_response_body(&response));+ router_env::logger::info!(connector_response=?response);+ RouterData::try_from(ResponseRouterData {+ response,+ data: data.clone(),+ http_code: res.status_code,+ })+ }++ fn get_error_response(+ &self,+ res: Response,+ event_builder: Option<&mut ConnectorEvent>,+ ) -> CustomResult<ErrorResponse, errors::ConnectorError> {+ self.build_error_response(res, event_builder)+ }+}++impl ConnectorIntegration<RSync, RefundsData, RefundsResponseData> for Juspaythreedsserver {+ fn get_headers(+ &self,+ req: &RefundSyncRouterData,+ connectors: &Connectors,+ ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {+ self.build_headers(req, connectors)+ }++ fn get_content_type(&self) -> &'static str {+ self.common_get_content_type()+ }++ fn get_url(+ &self,+ _req: &RefundSyncRouterData,+ _connectors: &Connectors,+ ) -> CustomResult<String, errors::ConnectorError> {+ Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())+ }++ fn build_request(+ &self,+ req: &RefundSyncRouterData,+ connectors: &Connectors,+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {+ Ok(Some(+ RequestBuilder::new()+ .method(Method::Get)+ .url(&types::RefundSyncType::get_url(self, req, connectors)?)+ .attach_default_headers()+ .headers(types::RefundSyncType::get_headers(self, req, connectors)?)+ .set_body(types::RefundSyncType::get_request_body(+ self, req, connectors,+ )?)+ .build(),+ ))+ }++ fn handle_response(+ &self,+ data: &RefundSyncRouterData,+ event_builder: Option<&mut ConnectorEvent>,+ res: Response,+ ) -> CustomResult<RefundSyncRouterData, errors::ConnectorError> {+ let response: juspaythreedsserver::RefundResponse = res+ .response+ .parse_struct("juspaythreedsserver RefundSyncResponse")+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;+ event_builder.map(|i| i.set_response_body(&response));+ router_env::logger::info!(connector_response=?response);+ RouterData::try_from(ResponseRouterData {+ response,+ data: data.clone(),+ http_code: res.status_code,+ })+ }++ fn get_error_response(+ &self,+ res: Response,+ event_builder: Option<&mut ConnectorEvent>,+ ) -> CustomResult<ErrorResponse, errors::ConnectorError> {+ self.build_error_response(res, event_builder)+ }+}++#[async_trait::async_trait]+impl webhooks::IncomingWebhook for Juspaythreedsserver {+ fn get_webhook_object_reference_id(+ &self,+ _request: &webhooks::IncomingWebhookRequestDetails<'_>,+ ) -> CustomResult<api_models::webhooks::ObjectReferenceId, errors::ConnectorError> {+ Err(report!(errors::ConnectorError::WebhooksNotImplemented))+ }++ fn get_webhook_event_type(+ &self,+ _request: &webhooks::IncomingWebhookRequestDetails<'_>,+ ) -> CustomResult<api_models::webhooks::IncomingWebhookEvent, errors::ConnectorError> {+ Err(report!(errors::ConnectorError::WebhooksNotImplemented))+ }++ fn get_webhook_resource_object(+ &self,+ _request: &webhooks::IncomingWebhookRequestDetails<'_>,+ ) -> CustomResult<Box<dyn masking::ErasedMaskSerialize>, errors::ConnectorError> {+ Err(report!(errors::ConnectorError::WebhooksNotImplemented))+ }+}++impl ConnectorSpecifications for Juspaythreedsserver {}diff --git a/crates/hyperswitch_connectors/src/connectors/juspaythreedsserver/transformers.rs b/crates/hyperswitch_connectors/src/connectors/juspaythreedsserver/transformers.rsnew file mode 100644index 0000000000..32156b7f30--- /dev/null+++ b/crates/hyperswitch_connectors/src/connectors/juspaythreedsserver/transformers.rs@@ -0,0 +1,235 @@+use common_enums::enums;+use common_utils::types::StringMinorUnit;+use hyperswitch_domain_models::{+ payment_method_data::PaymentMethodData,+ router_data::{ConnectorAuthType, RouterData},+ router_flow_types::refunds::{Execute, RSync},+ router_request_types::ResponseId,+ router_response_types::{PaymentsResponseData, RefundsResponseData},+ types::{PaymentsAuthorizeRouterData, RefundsRouterData},+};+use hyperswitch_interfaces::errors;+use masking::Secret;+use serde::{Deserialize, Serialize};++use crate::{+ types::{RefundsResponseRouterData, ResponseRouterData},+ utils::PaymentsAuthorizeRequestData,+};++//TODO: Fill the struct with respective fields+pub struct JuspaythreedsserverRouterData<T> {+ pub amount: StringMinorUnit, // The type of amount that a connector accepts, for example, String, i64, f64, etc.+ pub router_data: T,+}++impl<T> From<(StringMinorUnit, T)> for JuspaythreedsserverRouterData<T> {+ fn from((amount, item): (StringMinorUnit, T)) -> Self {+ //Todo : use utils to convert the amount to the type of amount that a connector accepts+ Self {+ amount,+ router_data: item,+ }+ }+}++//TODO: Fill the struct with respective fields+#[derive(Default, Debug, Serialize, PartialEq)]+pub struct JuspaythreedsserverPaymentsRequest {+ amount: StringMinorUnit,+ card: JuspaythreedsserverCard,+}++#[derive(Default, Debug, Serialize, Eq, PartialEq)]+pub struct JuspaythreedsserverCard {+ number: cards::CardNumber,+ expiry_month: Secret<String>,+ expiry_year: Secret<String>,+ cvc: Secret<String>,+ complete: bool,+}++impl TryFrom<&JuspaythreedsserverRouterData<&PaymentsAuthorizeRouterData>>+ for JuspaythreedsserverPaymentsRequest+{+ type Error = error_stack::Report<errors::ConnectorError>;+ fn try_from(+ item: &JuspaythreedsserverRouterData<&PaymentsAuthorizeRouterData>,+ ) -> Result<Self, Self::Error> {+ match item.router_data.request.payment_method_data.clone() {+ PaymentMethodData::Card(req_card) => {+ let card = JuspaythreedsserverCard {+ 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.clone(),+ card,+ })+ }+ _ => Err(errors::ConnectorError::NotImplemented("Payment method".to_string()).into()),+ }+ }+}++//TODO: Fill the struct with respective fields+// Auth Struct+pub struct JuspaythreedsserverAuthType {+ pub(super) api_key: Secret<String>,+}++impl TryFrom<&ConnectorAuthType> for JuspaythreedsserverAuthType {+ type Error = error_stack::Report<errors::ConnectorError>;+ fn try_from(auth_type: &ConnectorAuthType) -> Result<Self, Self::Error> {+ match auth_type {+ ConnectorAuthType::HeaderKey { api_key } => Ok(Self {+ api_key: api_key.to_owned(),+ }),+ _ => Err(errors::ConnectorError::FailedToObtainAuthType.into()),+ }+ }+}+// PaymentsResponse+//TODO: Append the remaining status flags+#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq)]+#[serde(rename_all = "lowercase")]+pub enum JuspaythreedsserverPaymentStatus {+ Succeeded,+ Failed,+ #[default]+ Processing,+}++impl From<JuspaythreedsserverPaymentStatus> for common_enums::AttemptStatus {+ fn from(item: JuspaythreedsserverPaymentStatus) -> Self {+ match item {+ JuspaythreedsserverPaymentStatus::Succeeded => Self::Charged,+ JuspaythreedsserverPaymentStatus::Failed => Self::Failure,+ JuspaythreedsserverPaymentStatus::Processing => Self::Authorizing,+ }+ }+}++//TODO: Fill the struct with respective fields+#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)]+pub struct JuspaythreedsserverPaymentsResponse {+ status: JuspaythreedsserverPaymentStatus,+ id: String,+}++impl<F, T>+ TryFrom<ResponseRouterData<F, JuspaythreedsserverPaymentsResponse, T, PaymentsResponseData>>+ for RouterData<F, T, PaymentsResponseData>+{+ type Error = error_stack::Report<errors::ConnectorError>;+ fn try_from(+ item: ResponseRouterData<F, JuspaythreedsserverPaymentsResponse, T, PaymentsResponseData>,+ ) -> Result<Self, Self::Error> {+ Ok(Self {+ status: common_enums::AttemptStatus::from(item.response.status),+ response: Ok(PaymentsResponseData::TransactionResponse {+ resource_id: ResponseId::ConnectorTransactionId(item.response.id),+ redirection_data: Box::new(None),+ mandate_reference: Box::new(None),+ connector_metadata: None,+ network_txn_id: None,+ connector_response_reference_id: None,+ incremental_authorization_allowed: None,+ charges: None,+ }),+ ..item.data+ })+ }+}++//TODO: Fill the struct with respective fields+// REFUND :+// Type definition for RefundRequest+#[derive(Default, Debug, Serialize)]+pub struct JuspaythreedsserverRefundRequest {+ pub amount: StringMinorUnit,+}++impl<F> TryFrom<&JuspaythreedsserverRouterData<&RefundsRouterData<F>>>+ for JuspaythreedsserverRefundRequest+{+ type Error = error_stack::Report<errors::ConnectorError>;+ fn try_from(+ item: &JuspaythreedsserverRouterData<&RefundsRouterData<F>>,+ ) -> Result<Self, Self::Error> {+ 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<RefundStatus> for enums::RefundStatus {+ fn from(item: RefundStatus) -> Self {+ match item {+ RefundStatus::Succeeded => Self::Success,+ RefundStatus::Failed => Self::Failure,+ RefundStatus::Processing => Self::Pending,+ //TODO: Review mapping+ }+ }+}++//TODO: Fill the struct with respective fields+#[derive(Default, Debug, Clone, Serialize, Deserialize)]+pub struct RefundResponse {+ id: String,+ status: RefundStatus,+}++impl TryFrom<RefundsResponseRouterData<Execute, RefundResponse>> for RefundsRouterData<Execute> {+ type Error = error_stack::Report<errors::ConnectorError>;+ fn try_from(+ item: RefundsResponseRouterData<Execute, RefundResponse>,+ ) -> Result<Self, Self::Error> {+ Ok(Self {+ response: Ok(RefundsResponseData {+ connector_refund_id: item.response.id.to_string(),+ refund_status: enums::RefundStatus::from(item.response.status),+ }),+ ..item.data+ })+ }+}++impl TryFrom<RefundsResponseRouterData<RSync, RefundResponse>> for RefundsRouterData<RSync> {+ type Error = error_stack::Report<errors::ConnectorError>;+ fn try_from(+ item: RefundsResponseRouterData<RSync, RefundResponse>,+ ) -> Result<Self, Self::Error> {+ Ok(Self {+ response: Ok(RefundsResponseData {+ connector_refund_id: item.response.id.to_string(),+ refund_status: enums::RefundStatus::from(item.response.status),+ }),+ ..item.data+ })+ }+}++//TODO: Fill the struct with respective fields+#[derive(Default, Debug, Serialize, Deserialize, PartialEq)]+pub struct JuspaythreedsserverErrorResponse {+ pub status_code: u16,+ pub code: String,+ pub message: String,+ pub reason: Option<String>,+}diff --git a/crates/hyperswitch_connectors/src/default_implementations.rs b/crates/hyperswitch_connectors/src/default_implementations.rsindex 69b75dabf3..fc0723a54f 100644--- a/crates/hyperswitch_connectors/src/default_implementations.rs+++ b/crates/hyperswitch_connectors/src/default_implementations.rs@@ -138,6 +138,7 @@ default_imp_for_authorize_session_token!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Nomupay,connectors::Noon,@@ -232,6 +233,7 @@ default_imp_for_calculate_tax!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Mifinity,connectors::Mollie,@@ -322,6 +324,7 @@ default_imp_for_session_update!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Rapyd,connectors::Razorpay,@@ -419,6 +422,7 @@ default_imp_for_post_session_tokens!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Rapyd,connectors::Razorpay,@@ -512,6 +516,7 @@ default_imp_for_complete_authorize!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Mifinity,connectors::Moneris,@@ -599,6 +604,7 @@ default_imp_for_incremental_authorization!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Nomupay,connectors::Noon,@@ -694,6 +700,7 @@ default_imp_for_create_customer!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Mifinity,connectors::Mollie,@@ -784,6 +791,7 @@ default_imp_for_connector_redirect_response!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Mifinity,connectors::Moneris,@@ -867,6 +875,7 @@ default_imp_for_pre_processing_steps!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Nomupay,connectors::Noon,@@ -958,6 +967,7 @@ default_imp_for_post_processing_steps!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Nomupay,connectors::Noon,@@ -1055,6 +1065,7 @@ default_imp_for_approve!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Nomupay,connectors::Noon,@@ -1152,6 +1163,7 @@ default_imp_for_reject!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Nomupay,connectors::Noon,@@ -1249,6 +1261,7 @@ default_imp_for_webhook_source_verification!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Nomupay,connectors::Noon,@@ -1346,6 +1359,7 @@ default_imp_for_accept_dispute!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Nomupay,connectors::Noon,@@ -1442,6 +1456,7 @@ default_imp_for_submit_evidence!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Nomupay,connectors::Noon,@@ -1537,6 +1552,7 @@ default_imp_for_defend_dispute!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Helcim,connectors::Nomupay,@@ -1643,6 +1659,7 @@ default_imp_for_file_upload!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Nomupay,connectors::Noon,@@ -1732,6 +1749,7 @@ default_imp_for_payouts!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Mifinity,connectors::Mollie,@@ -1829,6 +1847,7 @@ default_imp_for_payouts_create!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Noon,connectors::Novalnet,@@ -1927,6 +1946,7 @@ default_imp_for_payouts_retrieve!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Noon,connectors::Novalnet,@@ -2025,6 +2045,7 @@ default_imp_for_payouts_eligibility!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Noon,connectors::Novalnet,@@ -2122,6 +2143,7 @@ default_imp_for_payouts_fulfill!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Noon,connectors::Novalnet,@@ -2220,6 +2242,7 @@ default_imp_for_payouts_cancel!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Noon,connectors::Novalnet,@@ -2318,6 +2341,7 @@ default_imp_for_payouts_quote!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Noon,connectors::Novalnet,@@ -2416,6 +2440,7 @@ default_imp_for_payouts_recipient!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Noon,connectors::Novalnet,@@ -2514,6 +2539,7 @@ default_imp_for_payouts_recipient_account!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Noon,connectors::Novalnet,@@ -2612,6 +2638,7 @@ default_imp_for_frm_sale!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Nomupay,connectors::Noon,@@ -2711,6 +2738,7 @@ default_imp_for_frm_checkout!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Nomupay,connectors::Noon,@@ -2810,6 +2838,7 @@ default_imp_for_frm_transaction!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Nomupay,connectors::Noon,@@ -2909,6 +2938,7 @@ default_imp_for_frm_fulfillment!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Nomupay,connectors::Noon,@@ -3008,6 +3038,7 @@ default_imp_for_frm_record_return!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Nomupay,connectors::Noon,@@ -3103,6 +3134,7 @@ default_imp_for_revoking_mandates!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Nomupay,connectors::Novalnet,@@ -3581,6 +3613,7 @@ default_imp_for_additional_revenue_recovery_call!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Nomupay,connectors::Noon,diff --git a/crates/hyperswitch_connectors/src/default_implementations_v2.rs b/crates/hyperswitch_connectors/src/default_implementations_v2.rsindex 972a26adf3..09711ff54d 100644--- a/crates/hyperswitch_connectors/src/default_implementations_v2.rs+++ b/crates/hyperswitch_connectors/src/default_implementations_v2.rs@@ -242,6 +242,7 @@ default_imp_for_new_connector_integration_payment!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Nomupay,connectors::Noon,@@ -340,6 +341,7 @@ default_imp_for_new_connector_integration_refund!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Nomupay,connectors::Noon,@@ -433,6 +435,7 @@ default_imp_for_new_connector_integration_connector_access_token!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Nomupay,connectors::Noon,@@ -531,6 +534,7 @@ default_imp_for_new_connector_integration_accept_dispute!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Nomupay,connectors::Noon,@@ -628,6 +632,7 @@ default_imp_for_new_connector_integration_submit_evidence!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Nomupay,connectors::Noon,@@ -726,6 +731,7 @@ default_imp_for_new_connector_integration_defend_dispute!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Nomupay,connectors::Noon,@@ -834,6 +840,7 @@ default_imp_for_new_connector_integration_file_upload!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Nomupay,connectors::Noon,@@ -934,6 +941,7 @@ default_imp_for_new_connector_integration_payouts_create!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Nomupay,connectors::Noon,@@ -1034,6 +1042,7 @@ default_imp_for_new_connector_integration_payouts_eligibility!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Nomupay,connectors::Noon,@@ -1134,6 +1143,7 @@ default_imp_for_new_connector_integration_payouts_fulfill!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Nomupay,connectors::Noon,@@ -1234,6 +1244,7 @@ default_imp_for_new_connector_integration_payouts_cancel!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Nomupay,connectors::Noon,@@ -1334,6 +1345,7 @@ default_imp_for_new_connector_integration_payouts_quote!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Nomupay,connectors::Noon,@@ -1434,6 +1446,7 @@ default_imp_for_new_connector_integration_payouts_recipient!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Nomupay,connectors::Noon,@@ -1534,6 +1547,7 @@ default_imp_for_new_connector_integration_payouts_sync!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Nomupay,connectors::Noon,@@ -1634,6 +1648,7 @@ default_imp_for_new_connector_integration_payouts_recipient_account!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Nomupay,connectors::Noon,@@ -1732,6 +1747,7 @@ default_imp_for_new_connector_integration_webhook_source_verification!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Nomupay,connectors::Noon,@@ -1832,6 +1848,7 @@ default_imp_for_new_connector_integration_frm_sale!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Nomupay,connectors::Noon,@@ -1932,6 +1949,7 @@ default_imp_for_new_connector_integration_frm_checkout!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Nomupay,connectors::Noon,@@ -2032,6 +2050,7 @@ default_imp_for_new_connector_integration_frm_transaction!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Nomupay,connectors::Noon,@@ -2132,6 +2151,7 @@ default_imp_for_new_connector_integration_frm_fulfillment!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Nomupay,connectors::Noon,@@ -2232,6 +2252,7 @@ default_imp_for_new_connector_integration_frm_record_return!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Nomupay,connectors::Noon,@@ -2329,6 +2350,7 @@ default_imp_for_new_connector_integration_revoking_mandates!(connectors::Inespay,connectors::Itaubank,connectors::Jpmorgan,+ connectors::Juspaythreedsserver,connectors::Klarna,connectors::Nomupay,connectors::Noon,diff --git a/crates/hyperswitch_interfaces/src/configs.rs b/crates/hyperswitch_interfaces/src/configs.rsindex e317785692..71f30a88ab 100644--- a/crates/hyperswitch_interfaces/src/configs.rs+++ b/crates/hyperswitch_interfaces/src/configs.rs@@ -53,6 +53,7 @@ pub struct Connectors {pub inespay: ConnectorParams,pub itaubank: ConnectorParams,pub jpmorgan: ConnectorParams,+ pub juspaythreedsserver: ConnectorParams,pub klarna: ConnectorParams,pub mifinity: ConnectorParams,pub mollie: ConnectorParams,diff --git a/crates/router/src/connector.rs b/crates/router/src/connector.rsindex a89ae69451..682ae21fdb 100644--- a/crates/router/src/connector.rs+++ b/crates/router/src/connector.rs@@ -31,12 +31,13 @@ pub use hyperswitch_connectors::connectors::{fiuu::Fiuu, forte, forte::Forte, getnet, getnet::Getnet, globalpay, globalpay::Globalpay,globepay, globepay::Globepay, gocardless, gocardless::Gocardless, helcim, helcim::Helcim,iatapay, iatapay::Iatapay, inespay, inespay::Inespay, itaubank, itaubank::Itaubank, jpmorgan,- jpmorgan::Jpmorgan, klarna, klarna::Klarna, mifinity, mifinity::Mifinity, mollie,- mollie::Mollie, moneris, moneris::Moneris, multisafepay, multisafepay::Multisafepay, nexinets,- nexinets::Nexinets, nexixpay, nexixpay::Nexixpay, nomupay, nomupay::Nomupay, noon, noon::Noon,- novalnet, novalnet::Novalnet, nuvei, nuvei::Nuvei, opayo, opayo::Opayo, opennode,- opennode::Opennode, paybox, paybox::Paybox, payeezy, payeezy::Payeezy, payme, payme::Payme,- paystack, paystack::Paystack, payu, payu::Payu, placetopay, placetopay::Placetopay, powertranz,+ jpmorgan::Jpmorgan, juspaythreedsserver, juspaythreedsserver::Juspaythreedsserver, klarna,+ klarna::Klarna, mifinity, mifinity::Mifinity, mollie, mollie::Mollie, moneris,+ moneris::Moneris, multisafepay, multisafepay::Multisafepay, nexinets, nexinets::Nexinets,+ nexixpay, nexixpay::Nexixpay, nomupay, nomupay::Nomupay, noon, noon::Noon, novalnet,+ novalnet::Novalnet, nuvei, nuvei::Nuvei, opayo, opayo::Opayo, opennode, opennode::Opennode,+ paybox, paybox::Paybox, payeezy, payeezy::Payeezy, payme, payme::Payme, paystack,+ paystack::Paystack, payu, payu::Payu, placetopay, placetopay::Placetopay, powertranz,powertranz::Powertranz, prophetpay, prophetpay::Prophetpay, rapyd, rapyd::Rapyd, razorpay,razorpay::Razorpay, recurly::Recurly, redsys, redsys::Redsys, shift4, shift4::Shift4, square,square::Square, stax, stax::Stax, stripebilling, stripebilling::Stripebilling, taxjar,diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rsindex ee99c7b8ab..d71985a596 100644--- a/crates/router/src/core/admin.rs+++ b/crates/router/src/core/admin.rs@@ -1422,6 +1422,7 @@ impl ConnectorAuthTypeAndMetadataValidation<'_> {jpmorgan::transformers::JpmorganAuthType::try_from(self.auth_type)?;Ok(())}+ api_enums::Connector::Juspaythreedsserver => Ok(()),api_enums::Connector::Klarna => {klarna::transformers::KlarnaAuthType::try_from(self.auth_type)?;klarna::transformers::KlarnaConnectorMetadataObject::try_from(diff --git a/crates/router/src/core/payments/connector_integration_v2_impls.rs b/crates/router/src/core/payments/connector_integration_v2_impls.rsindex 8d38b84a00..115bf863c9 100644--- a/crates/router/src/core/payments/connector_integration_v2_impls.rs+++ b/crates/router/src/core/payments/connector_integration_v2_impls.rs@@ -962,6 +962,7 @@ default_imp_for_new_connector_integration_payouts!(connector::Inespay,connector::Itaubank,connector::Jpmorgan,+ connector::Juspaythreedsserver,connector::Klarna,connector::Mifinity,connector::Mollie,@@ -1367,6 +1368,7 @@ default_imp_for_new_connector_integration_frm!(connector::Inespay,connector::Itaubank,connector::Jpmorgan,+ connector::Juspaythreedsserver,connector::Klarna,connector::Mifinity,connector::Mollie,@@ -1704,6 +1706,7 @@ default_imp_for_new_connector_integration_connector_authentication!(connector::Inespay,connector::Itaubank,connector::Jpmorgan,+ connector::Juspaythreedsserver,connector::Klarna,connector::Mifinity,connector::Mollie,diff --git a/crates/router/src/core/payments/flows.rs b/crates/router/src/core/payments/flows.rsindex 937de63f5f..dbab90ecb4 100644--- a/crates/router/src/core/payments/flows.rs+++ b/crates/router/src/core/payments/flows.rs@@ -413,6 +413,7 @@ default_imp_for_connector_request_id!(connector::Inespay,connector::Itaubank,connector::Jpmorgan,+ connector::Juspaythreedsserver,connector::Klarna,connector::Mifinity,connector::Mollie,@@ -1263,6 +1264,7 @@ default_imp_for_fraud_check!(connector::Inespay,connector::Itaubank,connector::Jpmorgan,+ connector::Juspaythreedsserver,connector::Klarna,connector::Mifinity,connector::Mollie,@@ -1754,6 +1756,7 @@ default_imp_for_connector_authentication!(connector::Inespay,connector::Itaubank,connector::Jpmorgan,+ connector::Juspaythreedsserver,connector::Klarna,connector::Mifinity,connector::Mollie,diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rsindex a1185d377c..0c42acf587 100644--- a/crates/router/src/types/api.rs+++ b/crates/router/src/types/api.rs@@ -465,6 +465,9 @@ impl ConnectorData {enums::Connector::Jpmorgan => {Ok(ConnectorEnum::Old(Box::new(connector::Jpmorgan::new())))}+ enums::Connector::Juspaythreedsserver => Ok(ConnectorEnum::Old(Box::new(+ connector::Juspaythreedsserver::new(),+ ))),enums::Connector::Klarna => {Ok(ConnectorEnum::Old(Box::new(connector::Klarna::new())))}diff --git a/crates/router/src/types/api/authentication.rs b/crates/router/src/types/api/authentication.rsindex e82ee11670..e5f835a100 100644--- a/crates/router/src/types/api/authentication.rs+++ b/crates/router/src/types/api/authentication.rs@@ -156,6 +156,9 @@ impl AuthenticationConnectorData {enums::AuthenticationConnectors::UnifiedAuthenticationService => Ok(ConnectorEnum::Old(Box::new(connector::UnifiedAuthenticationService::new())),),+ enums::AuthenticationConnectors::Juspaythreedsserver => Ok(ConnectorEnum::Old(+ Box::new(connector::Juspaythreedsserver::new()),+ )),}}}diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rsindex c93cfb40dc..a44684a3de 100644--- a/crates/router/src/types/transformers.rs+++ b/crates/router/src/types/transformers.rs@@ -260,6 +260,11 @@ impl ForeignTryFrom<api_enums::Connector> for common_enums::RoutableConnectors {api_enums::Connector::Inespay => Self::Inespay,api_enums::Connector::Itaubank => Self::Itaubank,api_enums::Connector::Jpmorgan => Self::Jpmorgan,+ api_enums::Connector::Juspaythreedsserver => {+ Err(common_utils::errors::ValidationError::InvalidValue {+ message: "juspaythreedsserver is not a routable connector".to_string(),+ })?+ }api_enums::Connector::Klarna => Self::Klarna,api_enums::Connector::Mifinity => Self::Mifinity,api_enums::Connector::Mollie => Self::Mollie,diff --git a/crates/router/tests/connectors/juspaythreedsserver.rs b/crates/router/tests/connectors/juspaythreedsserver.rsnew file mode 100644index 0000000000..108ac2d1e0--- /dev/null+++ b/crates/router/tests/connectors/juspaythreedsserver.rs@@ -0,0 +1,427 @@+use hyperswitch_domain_models::payment_method_data::{Card, PaymentMethodData};+use masking::Secret;+use router::types::{self, api, storage::enums};+use test_utils::connector_auth;++use crate::utils::{self, ConnectorActions};++#[derive(Clone, Copy)]+struct JuspaythreedsserverTest;+impl JuspaythreedsserverTest {+ #[allow(dead_code)]+ fn new() -> Self {+ Self+ }+}+impl ConnectorActions for JuspaythreedsserverTest {}+impl utils::Connector for JuspaythreedsserverTest {+ fn get_data(&self) -> api::ConnectorData {+ use router::connector::Juspaythreedsserver;+ utils::construct_connector_data_old(+ Box::new(Juspaythreedsserver::new()),+ types::Connector::Plaid,+ api::GetToken::Connector,+ None,+ )+ }++ fn get_auth_token(&self) -> types::ConnectorAuthType {+ utils::to_connector_auth_type(+ connector_auth::ConnectorAuthentication::new()+ .juspaythreedsserver+ .expect("Missing connector authentication configuration")+ .into(),+ )+ }++ fn get_name(&self) -> String {+ "juspaythreedsserver".to_string()+ }+}++static CONNECTOR: JuspaythreedsserverTest = JuspaythreedsserverTest {};++fn get_default_payment_info() -> Option<utils::PaymentInfo> {+ None+}++fn payment_method_details() -> Option<types::PaymentsAuthorizeData> {+ 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: 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: 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 scenarios+// 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: PaymentMethodData::Card(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: PaymentMethodData::Card(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: PaymentMethodData::Card(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 testsdiff --git a/crates/router/tests/connectors/main.rs b/crates/router/tests/connectors/main.rsindex 040b2dd631..447eeef23a 100644--- a/crates/router/tests/connectors/main.rs+++ b/crates/router/tests/connectors/main.rs@@ -48,6 +48,7 @@ mod iatapay;mod inespay;mod itaubank;mod jpmorgan;+mod juspaythreedsserver;mod mifinity;mod mollie;mod moneris;@@ -89,6 +90,7 @@ mod taxjar;mod trustpay;mod tsys;mod unified_authentication_service;+mod utils;mod volt;mod wellsfargo;diff --git a/crates/test_utils/src/connector_auth.rs b/crates/test_utils/src/connector_auth.rsindex f19d5d22e8..38b8b99dc7 100644--- a/crates/test_utils/src/connector_auth.rs+++ b/crates/test_utils/src/connector_auth.rs@@ -55,6 +55,7 @@ pub struct ConnectorAuthentication {pub inespay: Option<HeaderKey>,pub itaubank: Option<MultiAuthKey>,pub jpmorgan: Option<BodyKey>,+ pub juspaythreedsserver: Option<HeaderKey>,pub mifinity: Option<HeaderKey>,pub mollie: Option<BodyKey>,pub moneris: Option<SignatureKey>,diff --git a/loadtest/config/development.toml b/loadtest/config/development.tomlindex 6b1afeab21..15375c6f2b 100644--- a/loadtest/config/development.toml+++ b/loadtest/config/development.toml@@ -121,6 +121,7 @@ iatapay.base_url = "https://sandbox.iata-pay.iata.org/api/v1"inespay.base_url = "https://apiflow.inespay.com/san/v21"itaubank.base_url = "https://sandbox.devportal.itau.com.br/"jpmorgan.base_url = "https://api-mock.payments.jpmorgan.com/api/v2"+juspaythreedsserver.base_url = "http://localhost:8000"jpmorgan.secondary_base_url = "https://id.payments.jpmorgan.com"klarna.base_url = "https://api{{klarna_region}}.playground.klarna.com/"mifinity.base_url = "https://demo.mifinity.com/"@@ -229,6 +230,7 @@ cards = ["inespay","itaubank","jpmorgan",+ "juspaythreedsserver","mollie","moneris","multisafepay",diff --git a/scripts/add_connector.sh b/scripts/add_connector.shindex 022e54a943..f65dceab95 100755--- a/scripts/add_connector.sh+++ b/scripts/add_connector.sh@@ -6,7 +6,7 @@ function find_prev_connector() {git checkout $selfcp $self $self.tmp# Add new connector to existing list and sort it- connectors=(aci adyen adyenplatform airwallex amazonpay applepay authorizedotnet bambora bamboraapac bankofamerica billwerk bitpay bluesnap boku braintree cashtocode chargebee checkout coinbase cryptopay cybersource datatrans deutschebank digitalvirgo dlocal dummyconnector ebanx elavon fiserv fiservemea fiuu forte getnet globalpay globepay gocardless gpayments helcim iatapay inespay itaubank jpmorgan klarna mifinity mollie moneris multisafepay netcetera nexinets nexixpay nomupay noon novalnet nuvei opayo opennode paybox payeezy payme payone paypal paystack payu placetopay plaid powertranz prophetpay rapyd razorpay recurly redsys shift4 square stax stripe stripebilling taxjar threedsecureio thunes trustpay tsys unified_authentication_service volt wellsfargo wellsfargopayout wise worldline worldpay xendit zsl "$1")+ connectors=(aci adyen adyenplatform airwallex amazonpay applepay authorizedotnet bambora bamboraapac bankofamerica billwerk bitpay bluesnap boku braintree cashtocode chargebee checkout coinbase cryptopay cybersource datatrans deutschebank digitalvirgo dlocal dummyconnector ebanx elavon fiserv fiservemea fiuu forte getnet globalpay globepay gocardless gpayments helcim iatapay inespay itaubank jpmorgan juspaythreedsserver klarna mifinity mollie moneris multisafepay netcetera nexinets nexixpay nomupay noon novalnet nuvei opayo opennode paybox payeezy payme payone paypal paystack payu placetopay plaid powertranz prophetpay rapyd razorpay recurly redsys shift4 square stax stripe stripebilling taxjar threedsecureio thunes trustpay tsys unified_authentication_service volt wellsfargo wellsfargopayout wise worldline worldpay xendit zsl "$1")IFS=$'\n' sorted=($(sort <<<"${connectors[*]}")); unset IFSres="$(echo ${sorted[@]})"sed -i'' -e "s/^ connectors=.*/ connectors=($res \"\$1\")/" $self.tmp