diff --git a/config/config.example.toml b/config/config.example.toml index 5783a70c37..2559a157b3 100644 --- a/config/config.example.toml +++ b/config/config.example.toml @@ -240,6 +240,7 @@ gpayments.base_url = "https://{{merchant_endpoint_prefix}}-test.api.as1.gpayment helcim.base_url = "https://api.helcim.com/" hipay.base_url = "https://stage-secure-gateway.hipay-tpp.com/rest/" hyperswitch_vault.base_url = "http://localhost:8080" +hyperwallet.base_url = "https://uat-api.paylution.com" hipay.secondary_base_url = "https://stage-secure2-vault.hipay-tpp.com/rest/" hipay.third_base_url = "https://stage-api-gateway.hipay.com/" iatapay.base_url = "https://sandbox.iata-pay.iata.org/api/v1" diff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.toml index a387cd0c16..d4fa61acb4 100644 --- a/config/deployments/integration_test.toml +++ b/config/deployments/integration_test.toml @@ -80,6 +80,7 @@ helcim.base_url = "https://api.helcim.com/" hipay.base_url = "https://stage-secure-gateway.hipay-tpp.com/rest/" hipay.secondary_base_url = "https://stage-secure2-vault.hipay-tpp.com/rest/" hipay.third_base_url = "https://stage-api-gateway.hipay.com/" +hyperwallet.base_url = "https://uat-api.paylution.com" 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/" diff --git a/config/deployments/production.toml b/config/deployments/production.toml index a95d88dc63..fedfd2d142 100644 --- a/config/deployments/production.toml +++ b/config/deployments/production.toml @@ -84,6 +84,7 @@ helcim.base_url = "https://api.helcim.com/" hipay.base_url = "https://secure-gateway.hipay-tpp.com/rest/" hipay.secondary_base_url = "https://secure2-vault.hipay-tpp.com/rest/" hipay.third_base_url = "https://api-gateway.hipay.com/" +hyperwallet.base_url = "https://uat-api.paylution.com" 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/" diff --git a/config/deployments/sandbox.toml b/config/deployments/sandbox.toml index 296888abcd..cc688456bc 100644 --- a/config/deployments/sandbox.toml +++ b/config/deployments/sandbox.toml @@ -84,6 +84,7 @@ helcim.base_url = "https://api.helcim.com/" hipay.base_url = "https://stage-secure-gateway.hipay-tpp.com/rest/" hipay.secondary_base_url = "https://stage-secure2-vault.hipay-tpp.com/rest/" hipay.third_base_url = "https://stage-api-gateway.hipay.com/" +hyperwallet.base_url = "https://uat-api.paylution.com" 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/" diff --git a/config/development.toml b/config/development.toml index 95b2f28962..c20d7487db 100644 --- a/config/development.toml +++ b/config/development.toml @@ -279,6 +279,7 @@ gpayments.base_url = "https://{{merchant_endpoint_prefix}}-test.api.as1.gpayment helcim.base_url = "https://api.helcim.com/" hipay.base_url = "https://stage-secure-gateway.hipay-tpp.com/rest/" hyperswitch_vault.base_url = "http://localhost:8080" +hyperwallet.base_url = "https://uat-api.paylution.com" hipay.secondary_base_url = "https://stage-secure2-vault.hipay-tpp.com/rest/" hipay.third_base_url = "https://stage-api-gateway.hipay.com/" iatapay.base_url = "https://sandbox.iata-pay.iata.org/api/v1" diff --git a/config/docker_compose.toml b/config/docker_compose.toml index a2c52bd776..a96d9b88be 100644 --- a/config/docker_compose.toml +++ b/config/docker_compose.toml @@ -166,6 +166,7 @@ gpayments.base_url = "https://{{merchant_endpoint_prefix}}-test.api.as1.gpayment helcim.base_url = "https://api.helcim.com/" hipay.base_url = "https://stage-secure-gateway.hipay-tpp.com/rest/" hyperswitch_vault.base_url = "http://localhost:8080" +hyperwallet.base_url = "https://uat-api.paylution.com" hipay.secondary_base_url = "https://stage-secure2-vault.hipay-tpp.com/rest/" hipay.third_base_url = "https://stage-api-gateway.hipay.com/" iatapay.base_url = "https://sandbox.iata-pay.iata.org/api/v1" diff --git a/crates/common_enums/src/connector_enums.rs b/crates/common_enums/src/connector_enums.rs index 9e00ff366a..d750189692 100644 --- a/crates/common_enums/src/connector_enums.rs +++ b/crates/common_enums/src/connector_enums.rs @@ -276,6 +276,7 @@ pub enum Connector { Hipay, Helcim, HyperswitchVault, + // Hyperwallet, added as template code for future usage Inespay, Iatapay, Itaubank, diff --git a/crates/connector_configs/src/connector.rs b/crates/connector_configs/src/connector.rs index 9a5c7edb2c..6605e78107 100644 --- a/crates/connector_configs/src/connector.rs +++ b/crates/connector_configs/src/connector.rs @@ -246,6 +246,7 @@ pub struct ConnectorConfig { pub hipay: Option, pub helcim: Option, pub hyperswitch_vault: Option, + pub hyperwallet: Option, pub inespay: Option, pub jpmorgan: Option, pub klarna: Option, diff --git a/crates/connector_configs/toml/development.toml b/crates/connector_configs/toml/development.toml index 42a1f3328e..b186700322 100644 --- a/crates/connector_configs/toml/development.toml +++ b/crates/connector_configs/toml/development.toml @@ -6679,3 +6679,8 @@ key1 = "Client secret" [[flexiti.pay_later]] payment_method_type = "flexiti" payment_experience = "redirect_to_url" + +[hyperwallet] +[hyperwallet.connector_auth.BodyKey] +api_key = "Password" +key1 = "Username" diff --git a/crates/connector_configs/toml/production.toml b/crates/connector_configs/toml/production.toml index df773d3c18..82ad0848c9 100644 --- a/crates/connector_configs/toml/production.toml +++ b/crates/connector_configs/toml/production.toml @@ -5297,3 +5297,8 @@ api_key = "API Key" [sift] [sift.connector_auth.HeaderKey] api_key = "API Key" + +[hyperwallet] +[hyperwallet.connector_auth.BodyKey] +api_key = "Password" +key1 = "Username" diff --git a/crates/connector_configs/toml/sandbox.toml b/crates/connector_configs/toml/sandbox.toml index e62a3b441b..ff0dd91305 100644 --- a/crates/connector_configs/toml/sandbox.toml +++ b/crates/connector_configs/toml/sandbox.toml @@ -6661,3 +6661,8 @@ key1 = "Client secret" [[flexiti.pay_later]] payment_method_type = "flexiti" payment_experience = "redirect_to_url" + +[hyperwallet] +[hyperwallet.connector_auth.BodyKey] +api_key = "Password" +key1 = "Username" \ No newline at end of file diff --git a/crates/hyperswitch_connectors/src/connectors.rs b/crates/hyperswitch_connectors/src/connectors.rs index b0b440b5b5..e6494a5971 100644 --- a/crates/hyperswitch_connectors/src/connectors.rs +++ b/crates/hyperswitch_connectors/src/connectors.rs @@ -53,6 +53,7 @@ pub mod gpayments; pub mod helcim; pub mod hipay; pub mod hyperswitch_vault; +pub mod hyperwallet; pub mod iatapay; pub mod inespay; pub mod itaubank; @@ -140,19 +141,20 @@ pub use self::{ ebanx::Ebanx, elavon::Elavon, facilitapay::Facilitapay, fiserv::Fiserv, fiservemea::Fiservemea, fiuu::Fiuu, flexiti::Flexiti, forte::Forte, getnet::Getnet, globalpay::Globalpay, globepay::Globepay, gocardless::Gocardless, gpayments::Gpayments, helcim::Helcim, hipay::Hipay, - hyperswitch_vault::HyperswitchVault, iatapay::Iatapay, inespay::Inespay, itaubank::Itaubank, - jpmorgan::Jpmorgan, juspaythreedsserver::Juspaythreedsserver, katapult::Katapult, - klarna::Klarna, mifinity::Mifinity, mollie::Mollie, moneris::Moneris, mpgs::Mpgs, - multisafepay::Multisafepay, netcetera::Netcetera, nexinets::Nexinets, nexixpay::Nexixpay, - nmi::Nmi, nomupay::Nomupay, noon::Noon, nordea::Nordea, novalnet::Novalnet, nuvei::Nuvei, - opayo::Opayo, opennode::Opennode, paybox::Paybox, payeezy::Payeezy, payload::Payload, - payme::Payme, payone::Payone, paypal::Paypal, paystack::Paystack, paytm::Paytm, payu::Payu, - phonepe::Phonepe, placetopay::Placetopay, plaid::Plaid, powertranz::Powertranz, - prophetpay::Prophetpay, rapyd::Rapyd, razorpay::Razorpay, recurly::Recurly, redsys::Redsys, - riskified::Riskified, santander::Santander, shift4::Shift4, sift::Sift, signifyd::Signifyd, - silverflow::Silverflow, square::Square, stax::Stax, stripe::Stripe, - stripebilling::Stripebilling, taxjar::Taxjar, threedsecureio::Threedsecureio, thunes::Thunes, - tokenio::Tokenio, trustpay::Trustpay, trustpayments::Trustpayments, tsys::Tsys, + hyperswitch_vault::HyperswitchVault, hyperwallet::Hyperwallet, iatapay::Iatapay, + inespay::Inespay, itaubank::Itaubank, jpmorgan::Jpmorgan, + juspaythreedsserver::Juspaythreedsserver, katapult::Katapult, klarna::Klarna, + mifinity::Mifinity, mollie::Mollie, moneris::Moneris, mpgs::Mpgs, multisafepay::Multisafepay, + netcetera::Netcetera, nexinets::Nexinets, nexixpay::Nexixpay, nmi::Nmi, nomupay::Nomupay, + noon::Noon, nordea::Nordea, novalnet::Novalnet, nuvei::Nuvei, opayo::Opayo, opennode::Opennode, + paybox::Paybox, payeezy::Payeezy, payload::Payload, payme::Payme, payone::Payone, + paypal::Paypal, paystack::Paystack, paytm::Paytm, payu::Payu, phonepe::Phonepe, + placetopay::Placetopay, plaid::Plaid, powertranz::Powertranz, prophetpay::Prophetpay, + rapyd::Rapyd, razorpay::Razorpay, recurly::Recurly, redsys::Redsys, riskified::Riskified, + santander::Santander, shift4::Shift4, sift::Sift, signifyd::Signifyd, silverflow::Silverflow, + square::Square, stax::Stax, stripe::Stripe, stripebilling::Stripebilling, taxjar::Taxjar, + threedsecureio::Threedsecureio, thunes::Thunes, tokenio::Tokenio, trustpay::Trustpay, + trustpayments::Trustpayments, tsys::Tsys, unified_authentication_service::UnifiedAuthenticationService, vgs::Vgs, volt::Volt, wellsfargo::Wellsfargo, wellsfargopayout::Wellsfargopayout, wise::Wise, worldline::Worldline, worldpay::Worldpay, worldpayvantiv::Worldpayvantiv, worldpayxml::Worldpayxml, xendit::Xendit, diff --git a/crates/hyperswitch_connectors/src/connectors/hyperwallet.rs b/crates/hyperswitch_connectors/src/connectors/hyperwallet.rs new file mode 100644 index 0000000000..88ff435324 --- /dev/null +++ b/crates/hyperswitch_connectors/src/connectors/hyperwallet.rs @@ -0,0 +1,624 @@ +pub mod transformers; + +use std::sync::LazyLock; + +use common_enums::enums; +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::{ + payment_method_data::PaymentMethodData, + router_data::{AccessToken, ConnectorAuthType, ErrorResponse, RouterData}, + router_flow_types::{ + access_token_auth::AccessTokenAuth, + payments::{Authorize, Capture, PSync, PaymentMethodToken, Session, SetupMandate, Void}, + refunds::{Execute, RSync}, + }, + router_request_types::{ + AccessTokenRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData, + PaymentsCancelData, PaymentsCaptureData, PaymentsSessionData, PaymentsSyncData, + RefundsData, SetupMandateRequestData, + }, + router_response_types::{ + ConnectorInfo, PaymentsResponseData, RefundsResponseData, SupportedPaymentMethods, + }, + 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 hyperwallet; + +use crate::{constants::headers, types::ResponseRouterData, utils}; + +#[derive(Clone)] +pub struct Hyperwallet { + amount_converter: &'static (dyn AmountConvertor + Sync), +} + +impl Hyperwallet { + pub fn new() -> &'static Self { + &Self { + amount_converter: &StringMinorUnitForConnector, + } + } +} + +impl api::Payment for Hyperwallet {} +impl api::PaymentSession for Hyperwallet {} +impl api::ConnectorAccessToken for Hyperwallet {} +impl api::MandateSetup for Hyperwallet {} +impl api::PaymentAuthorize for Hyperwallet {} +impl api::PaymentSync for Hyperwallet {} +impl api::PaymentCapture for Hyperwallet {} +impl api::PaymentVoid for Hyperwallet {} +impl api::Refund for Hyperwallet {} +impl api::RefundExecute for Hyperwallet {} +impl api::RefundSync for Hyperwallet {} +impl api::PaymentToken for Hyperwallet {} + +impl ConnectorIntegration + for Hyperwallet +{ + // Not Implemented (R) +} + +impl ConnectorCommonExt for Hyperwallet +where + Self: ConnectorIntegration, +{ + fn build_headers( + &self, + req: &RouterData, + _connectors: &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 Hyperwallet { + fn id(&self) -> &'static str { + "hyperwallet" + } + + fn get_currency_unit(&self) -> api::CurrencyUnit { + api::CurrencyUnit::Base + } + + fn common_get_content_type(&self) -> &'static str { + "application/json" + } + + fn base_url<'a>(&self, connectors: &'a Connectors) -> &'a str { + connectors.hyperwallet.base_url.as_ref() + } + + fn get_auth_header( + &self, + auth_type: &ConnectorAuthType, + ) -> CustomResult)>, errors::ConnectorError> { + let auth = hyperwallet::HyperwalletAuthType::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 { + let response: hyperwallet::HyperwalletErrorResponse = res + .response + .parse_struct("HyperwalletErrorResponse") + .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, + network_advice_code: None, + network_decline_code: None, + network_error_message: None, + }) + } +} + +impl ConnectorValidation for Hyperwallet { + fn validate_mandate_payment( + &self, + _pm_type: Option, + pm_data: PaymentMethodData, + ) -> CustomResult<(), errors::ConnectorError> { + match pm_data { + PaymentMethodData::Card(_) => Err(errors::ConnectorError::NotImplemented( + "validate_mandate_payment does not support cards".to_string(), + ) + .into()), + _ => Ok(()), + } + } + + fn validate_psync_reference_id( + &self, + _data: &PaymentsSyncData, + _is_three_ds: bool, + _status: enums::AttemptStatus, + _connector_meta_data: Option, + ) -> CustomResult<(), errors::ConnectorError> { + Ok(()) + } +} + +impl ConnectorIntegration for Hyperwallet { + //TODO: implement sessions flow +} + +impl ConnectorIntegration for Hyperwallet {} + +impl ConnectorIntegration + for Hyperwallet +{ +} + +impl ConnectorIntegration for Hyperwallet { + fn get_headers( + &self, + req: &PaymentsAuthorizeRouterData, + connectors: &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: &PaymentsAuthorizeRouterData, + _connectors: &Connectors, + ) -> CustomResult { + Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into()) + } + + fn get_request_body( + &self, + req: &PaymentsAuthorizeRouterData, + _connectors: &Connectors, + ) -> CustomResult { + let amount = utils::convert_amount( + self.amount_converter, + req.request.minor_amount, + req.request.currency, + )?; + + let connector_router_data = hyperwallet::HyperwalletRouterData::from((amount, req)); + let connector_req = + hyperwallet::HyperwalletPaymentsRequest::try_from(&connector_router_data)?; + Ok(RequestContent::Json(Box::new(connector_req))) + } + + fn build_request( + &self, + req: &PaymentsAuthorizeRouterData, + connectors: &Connectors, + ) -> CustomResult, 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 { + let response: hyperwallet::HyperwalletPaymentsResponse = res + .response + .parse_struct("Hyperwallet 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 { + self.build_error_response(res, event_builder) + } +} + +impl ConnectorIntegration for Hyperwallet { + fn get_headers( + &self, + req: &PaymentsSyncRouterData, + connectors: &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: &PaymentsSyncRouterData, + _connectors: &Connectors, + ) -> CustomResult { + Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into()) + } + + fn build_request( + &self, + req: &PaymentsSyncRouterData, + connectors: &Connectors, + ) -> CustomResult, 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 { + let response: hyperwallet::HyperwalletPaymentsResponse = res + .response + .parse_struct("hyperwallet 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 { + self.build_error_response(res, event_builder) + } +} + +impl ConnectorIntegration for Hyperwallet { + fn get_headers( + &self, + req: &PaymentsCaptureRouterData, + connectors: &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: &PaymentsCaptureRouterData, + _connectors: &Connectors, + ) -> CustomResult { + Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into()) + } + + fn get_request_body( + &self, + _req: &PaymentsCaptureRouterData, + _connectors: &Connectors, + ) -> CustomResult { + Err(errors::ConnectorError::NotImplemented("get_request_body method".to_string()).into()) + } + + fn build_request( + &self, + req: &PaymentsCaptureRouterData, + connectors: &Connectors, + ) -> CustomResult, 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 { + let response: hyperwallet::HyperwalletPaymentsResponse = res + .response + .parse_struct("Hyperwallet 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 { + self.build_error_response(res, event_builder) + } +} + +impl ConnectorIntegration for Hyperwallet {} + +impl ConnectorIntegration for Hyperwallet { + fn get_headers( + &self, + req: &RefundsRouterData, + connectors: &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: &RefundsRouterData, + _connectors: &Connectors, + ) -> CustomResult { + Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into()) + } + + fn get_request_body( + &self, + req: &RefundsRouterData, + _connectors: &Connectors, + ) -> CustomResult { + let refund_amount = utils::convert_amount( + self.amount_converter, + req.request.minor_refund_amount, + req.request.currency, + )?; + + let connector_router_data = hyperwallet::HyperwalletRouterData::from((refund_amount, req)); + let connector_req = + hyperwallet::HyperwalletRefundRequest::try_from(&connector_router_data)?; + Ok(RequestContent::Json(Box::new(connector_req))) + } + + fn build_request( + &self, + req: &RefundsRouterData, + connectors: &Connectors, + ) -> CustomResult, 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, + event_builder: Option<&mut ConnectorEvent>, + res: Response, + ) -> CustomResult, errors::ConnectorError> { + let response: hyperwallet::RefundResponse = res + .response + .parse_struct("hyperwallet 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 { + self.build_error_response(res, event_builder) + } +} + +impl ConnectorIntegration for Hyperwallet { + fn get_headers( + &self, + req: &RefundSyncRouterData, + connectors: &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: &RefundSyncRouterData, + _connectors: &Connectors, + ) -> CustomResult { + Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into()) + } + + fn build_request( + &self, + req: &RefundSyncRouterData, + connectors: &Connectors, + ) -> CustomResult, 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 { + let response: hyperwallet::RefundResponse = res + .response + .parse_struct("hyperwallet 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 { + self.build_error_response(res, event_builder) + } +} + +#[async_trait::async_trait] +impl webhooks::IncomingWebhook for Hyperwallet { + fn get_webhook_object_reference_id( + &self, + _request: &webhooks::IncomingWebhookRequestDetails<'_>, + ) -> CustomResult { + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) + } + + fn get_webhook_event_type( + &self, + _request: &webhooks::IncomingWebhookRequestDetails<'_>, + ) -> CustomResult { + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) + } + + fn get_webhook_resource_object( + &self, + _request: &webhooks::IncomingWebhookRequestDetails<'_>, + ) -> CustomResult, errors::ConnectorError> { + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) + } +} + +static HYPERWALLET_SUPPORTED_PAYMENT_METHODS: LazyLock = + LazyLock::new(SupportedPaymentMethods::new); + +static HYPERWALLET_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo { + display_name: "Hyperwallet", + description: "Hyperwallet connector", + connector_type: enums::PaymentConnectorCategory::PaymentGateway, +}; + +static HYPERWALLET_SUPPORTED_WEBHOOK_FLOWS: [enums::EventClass; 0] = []; + +impl ConnectorSpecifications for Hyperwallet { + fn get_connector_about(&self) -> Option<&'static ConnectorInfo> { + Some(&HYPERWALLET_CONNECTOR_INFO) + } + + fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> { + Some(&*HYPERWALLET_SUPPORTED_PAYMENT_METHODS) + } + + fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> { + Some(&HYPERWALLET_SUPPORTED_WEBHOOK_FLOWS) + } +} diff --git a/crates/hyperswitch_connectors/src/connectors/hyperwallet/transformers.rs b/crates/hyperswitch_connectors/src/connectors/hyperwallet/transformers.rs new file mode 100644 index 0000000000..1436ec6335 --- /dev/null +++ b/crates/hyperswitch_connectors/src/connectors/hyperwallet/transformers.rs @@ -0,0 +1,219 @@ +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}; + +//TODO: Fill the struct with respective fields +pub struct HyperwalletRouterData { + pub amount: StringMinorUnit, // The type of amount that a connector accepts, for example, String, i64, f64, etc. + pub router_data: T, +} + +impl From<(StringMinorUnit, T)> for HyperwalletRouterData { + 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 HyperwalletPaymentsRequest { + amount: StringMinorUnit, + card: HyperwalletCard, +} + +#[derive(Default, Debug, Serialize, Eq, PartialEq)] +pub struct HyperwalletCard { + number: cards::CardNumber, + expiry_month: Secret, + expiry_year: Secret, + cvc: Secret, + complete: bool, +} + +impl TryFrom<&HyperwalletRouterData<&PaymentsAuthorizeRouterData>> for HyperwalletPaymentsRequest { + type Error = error_stack::Report; + fn try_from( + item: &HyperwalletRouterData<&PaymentsAuthorizeRouterData>, + ) -> Result { + match item.router_data.request.payment_method_data.clone() { + PaymentMethodData::Card(_) => Err(errors::ConnectorError::NotImplemented( + "Card payment method not implemented".to_string(), + ) + .into()), + _ => Err(errors::ConnectorError::NotImplemented("Payment method".to_string()).into()), + } + } +} + +//TODO: Fill the struct with respective fields +// Auth Struct +pub struct HyperwalletAuthType { + pub(super) api_key: Secret, +} + +impl TryFrom<&ConnectorAuthType> for HyperwalletAuthType { + type Error = error_stack::Report; + fn try_from(auth_type: &ConnectorAuthType) -> Result { + 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, Copy, Default, Serialize, Deserialize, PartialEq)] +#[serde(rename_all = "lowercase")] +pub enum HyperwalletPaymentStatus { + Succeeded, + Failed, + #[default] + Processing, +} + +impl From for common_enums::AttemptStatus { + fn from(item: HyperwalletPaymentStatus) -> Self { + match item { + HyperwalletPaymentStatus::Succeeded => Self::Charged, + HyperwalletPaymentStatus::Failed => Self::Failure, + HyperwalletPaymentStatus::Processing => Self::Authorizing, + } + } +} + +//TODO: Fill the struct with respective fields +#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)] +pub struct HyperwalletPaymentsResponse { + status: HyperwalletPaymentStatus, + id: String, +} + +impl TryFrom> + for RouterData +{ + type Error = error_stack::Report; + fn try_from( + item: ResponseRouterData, + ) -> Result { + 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 HyperwalletRefundRequest { + pub amount: StringMinorUnit, +} + +impl TryFrom<&HyperwalletRouterData<&RefundsRouterData>> for HyperwalletRefundRequest { + type Error = error_stack::Report; + fn try_from(item: &HyperwalletRouterData<&RefundsRouterData>) -> Result { + Ok(Self { + amount: item.amount.to_owned(), + }) + } +} + +// Type definition for Refund Response + +#[allow(dead_code)] +#[derive(Debug, Copy, 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, + //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> for RefundsRouterData { + type Error = error_stack::Report; + fn try_from( + item: RefundsResponseRouterData, + ) -> Result { + 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> for RefundsRouterData { + type Error = error_stack::Report; + fn try_from( + item: RefundsResponseRouterData, + ) -> Result { + 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 HyperwalletErrorResponse { + pub status_code: u16, + pub code: String, + pub message: String, + pub reason: Option, + pub network_advice_code: Option, + pub network_decline_code: Option, + pub network_error_message: Option, +} diff --git a/crates/hyperswitch_connectors/src/default_implementations.rs b/crates/hyperswitch_connectors/src/default_implementations.rs index 96834d99cc..27abb8bf5c 100644 --- a/crates/hyperswitch_connectors/src/default_implementations.rs +++ b/crates/hyperswitch_connectors/src/default_implementations.rs @@ -203,6 +203,7 @@ default_imp_for_authorize_session_token!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -342,6 +343,7 @@ default_imp_for_calculate_tax!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -474,6 +476,7 @@ default_imp_for_session_update!( connectors::Getnet, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -614,6 +617,7 @@ default_imp_for_post_session_tokens!( connectors::Getnet, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -753,6 +757,7 @@ default_imp_for_create_order!( connectors::Getnet, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -893,6 +898,7 @@ default_imp_for_update_metadata!( connectors::Getnet, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -1033,6 +1039,7 @@ default_imp_for_cancel_post_capture!( connectors::Getnet, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -1174,6 +1181,7 @@ default_imp_for_complete_authorize!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -1301,6 +1309,7 @@ default_imp_for_incremental_authorization!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -1436,6 +1445,7 @@ default_imp_for_create_customer!( connectors::Gpayments, connectors::Hipay, connectors::Helcim, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -1570,6 +1580,7 @@ default_imp_for_connector_redirect_response!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -1695,6 +1706,7 @@ default_imp_for_pre_processing_steps!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -1825,6 +1837,7 @@ default_imp_for_post_processing_steps!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -1966,6 +1979,7 @@ default_imp_for_approve!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -2108,6 +2122,7 @@ default_imp_for_reject!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -2250,6 +2265,7 @@ default_imp_for_webhook_source_verification!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -2390,6 +2406,7 @@ default_imp_for_accept_dispute!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -2529,6 +2546,7 @@ default_imp_for_submit_evidence!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -2666,6 +2684,7 @@ default_imp_for_defend_dispute!( connectors::Gpayments, connectors::Hipay, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -2808,6 +2827,7 @@ default_imp_for_fetch_disputes!( connectors::Gpayments, connectors::Hipay, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -2949,6 +2969,7 @@ default_imp_for_dispute_sync!( connectors::Gpayments, connectors::Hipay, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -3098,6 +3119,7 @@ default_imp_for_file_upload!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -3227,6 +3249,7 @@ default_imp_for_payouts!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -3363,6 +3386,7 @@ default_imp_for_payouts_create!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -3503,6 +3527,7 @@ default_imp_for_payouts_retrieve!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -3642,6 +3667,7 @@ default_imp_for_payouts_eligibility!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -3780,6 +3806,7 @@ default_imp_for_payouts_fulfill!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -3917,6 +3944,7 @@ default_imp_for_payouts_cancel!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -4057,6 +4085,7 @@ default_imp_for_payouts_quote!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -4198,6 +4227,7 @@ default_imp_for_payouts_recipient!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -4339,6 +4369,7 @@ default_imp_for_payouts_recipient_account!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -4481,6 +4512,7 @@ default_imp_for_frm_sale!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -4623,6 +4655,7 @@ default_imp_for_frm_checkout!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -4765,6 +4798,7 @@ default_imp_for_frm_transaction!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -4907,6 +4941,7 @@ default_imp_for_frm_fulfillment!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -5049,6 +5084,7 @@ default_imp_for_frm_record_return!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -5186,6 +5222,7 @@ default_imp_for_revoking_mandates!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -5326,6 +5363,7 @@ default_imp_for_uas_pre_authentication!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -5465,6 +5503,7 @@ default_imp_for_uas_post_authentication!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -5605,6 +5644,7 @@ default_imp_for_uas_authentication_confirmation!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -5736,6 +5776,7 @@ default_imp_for_connector_request_id!( connectors::Gpayments, connectors::Hipay, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -5871,6 +5912,7 @@ default_imp_for_fraud_check!( connectors::Helcim, connectors::Hipay, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -6034,6 +6076,7 @@ default_imp_for_connector_authentication!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -6172,6 +6215,7 @@ default_imp_for_uas_authentication!( connectors::Helcim, connectors::Hipay, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -6304,6 +6348,7 @@ default_imp_for_revenue_recovery!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -6447,6 +6492,7 @@ default_imp_for_billing_connector_payment_sync!( connectors::Helcim, connectors::Hipay, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -6588,6 +6634,7 @@ default_imp_for_revenue_recovery_record_back!( connectors::Helcim, connectors::Hipay, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -6729,6 +6776,7 @@ default_imp_for_billing_connector_invoice_sync!( connectors::Helcim, connectors::Hipay, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -6864,6 +6912,7 @@ default_imp_for_external_vault!( connectors::Helcim, connectors::Hipay, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -7005,6 +7054,7 @@ default_imp_for_external_vault_insert!( connectors::Helcim, connectors::Hipay, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -7146,6 +7196,7 @@ default_imp_for_external_vault_retrieve!( connectors::Helcim, connectors::Hipay, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -7287,6 +7338,7 @@ default_imp_for_external_vault_delete!( connectors::Helcim, connectors::Hipay, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -7375,6 +7427,7 @@ macro_rules! default_imp_for_external_vault_create { } default_imp_for_external_vault_create!( + connectors::Hyperwallet, connectors::Aci, connectors::Adyen, connectors::Adyenplatform, @@ -7568,6 +7621,7 @@ default_imp_for_connector_authentication_token!( connectors::Helcim, connectors::Hipay, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, diff --git a/crates/hyperswitch_connectors/src/default_implementations_v2.rs b/crates/hyperswitch_connectors/src/default_implementations_v2.rs index 046aba87b0..ba6f4e9d27 100644 --- a/crates/hyperswitch_connectors/src/default_implementations_v2.rs +++ b/crates/hyperswitch_connectors/src/default_implementations_v2.rs @@ -312,6 +312,7 @@ default_imp_for_new_connector_integration_payment!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -401,6 +402,7 @@ macro_rules! default_imp_for_new_connector_integration_refund { } default_imp_for_new_connector_integration_refund!( + connectors::Hyperwallet, connectors::Vgs, connectors::Aci, connectors::Adyen, @@ -589,6 +591,7 @@ default_imp_for_new_connector_integration_connector_authentication_token!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -721,6 +724,7 @@ default_imp_for_new_connector_integration_connector_access_token!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -863,6 +867,7 @@ default_imp_for_new_connector_integration_accept_dispute!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -1005,6 +1010,7 @@ default_imp_for_new_connector_integration_fetch_disputes!( connectors::Helcim, connectors::Hipay, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -1148,6 +1154,7 @@ default_imp_for_new_connector_integration_dispute_sync!( connectors::Helcim, connectors::Hipay, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -1291,6 +1298,7 @@ default_imp_for_new_connector_integration_defend_dispute!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -1432,6 +1440,7 @@ default_imp_for_new_connector_integration_submit_evidence!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -1584,6 +1593,7 @@ default_imp_for_new_connector_integration_file_upload!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -1728,6 +1738,7 @@ default_imp_for_new_connector_integration_payouts_create!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -1872,6 +1883,7 @@ default_imp_for_new_connector_integration_payouts_eligibility!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -2016,6 +2028,7 @@ default_imp_for_new_connector_integration_payouts_fulfill!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -2160,6 +2173,7 @@ default_imp_for_new_connector_integration_payouts_cancel!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -2304,6 +2318,7 @@ default_imp_for_new_connector_integration_payouts_quote!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -2448,6 +2463,7 @@ default_imp_for_new_connector_integration_payouts_recipient!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -2592,6 +2608,7 @@ default_imp_for_new_connector_integration_payouts_sync!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -2736,6 +2753,7 @@ default_imp_for_new_connector_integration_payouts_recipient_account!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -2878,6 +2896,7 @@ default_imp_for_new_connector_integration_webhook_source_verification!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -3022,6 +3041,7 @@ default_imp_for_new_connector_integration_frm_sale!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -3166,6 +3186,7 @@ default_imp_for_new_connector_integration_frm_checkout!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -3310,6 +3331,7 @@ default_imp_for_new_connector_integration_frm_transaction!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -3454,6 +3476,7 @@ default_imp_for_new_connector_integration_frm_fulfillment!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -3598,6 +3621,7 @@ default_imp_for_new_connector_integration_frm_record_return!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -3739,6 +3763,7 @@ default_imp_for_new_connector_integration_revoking_mandates!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, @@ -3864,6 +3889,7 @@ default_imp_for_new_connector_integration_frm!( connectors::Gpayments, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Inespay, connectors::Jpmorgan, connectors::Juspaythreedsserver, @@ -4005,6 +4031,7 @@ default_imp_for_new_connector_integration_connector_authentication!( connectors::Helcim, connectors::Hipay, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Inespay, connectors::Jpmorgan, connectors::Juspaythreedsserver, @@ -4135,6 +4162,7 @@ default_imp_for_new_connector_integration_revenue_recovery!( connectors::Helcim, connectors::Hipay, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Inespay, connectors::Jpmorgan, connectors::Juspaythreedsserver, @@ -4285,6 +4313,7 @@ default_imp_for_new_connector_integration_external_vault!( connectors::Hipay, connectors::Helcim, connectors::HyperswitchVault, + connectors::Hyperwallet, connectors::Iatapay, connectors::Inespay, connectors::Itaubank, diff --git a/crates/hyperswitch_domain_models/src/connector_endpoints.rs b/crates/hyperswitch_domain_models/src/connector_endpoints.rs index ab6b031ee5..53b17691fe 100644 --- a/crates/hyperswitch_domain_models/src/connector_endpoints.rs +++ b/crates/hyperswitch_domain_models/src/connector_endpoints.rs @@ -68,6 +68,7 @@ pub struct Connectors { pub helcim: ConnectorParams, pub hipay: ConnectorParamsWithThreeUrls, pub hyperswitch_vault: ConnectorParams, + pub hyperwallet: ConnectorParams, pub iatapay: ConnectorParams, pub inespay: ConnectorParams, pub itaubank: ConnectorParams, diff --git a/crates/router/src/connector.rs b/crates/router/src/connector.rs index def4e3cff0..5e375593ea 100644 --- a/crates/router/src/connector.rs +++ b/crates/router/src/connector.rs @@ -22,19 +22,19 @@ pub use hyperswitch_connectors::connectors::{ fiuu::Fiuu, flexiti, flexiti::Flexiti, forte, forte::Forte, getnet, getnet::Getnet, globalpay, globalpay::Globalpay, globepay, globepay::Globepay, gocardless, gocardless::Gocardless, gpayments, gpayments::Gpayments, helcim, helcim::Helcim, hipay, hipay::Hipay, - hyperswitch_vault, hyperswitch_vault::HyperswitchVault, iatapay, iatapay::Iatapay, inespay, - inespay::Inespay, itaubank, itaubank::Itaubank, jpmorgan, jpmorgan::Jpmorgan, - juspaythreedsserver, juspaythreedsserver::Juspaythreedsserver, katapult, katapult::Katapult, - klarna, klarna::Klarna, mifinity, mifinity::Mifinity, mollie, mollie::Mollie, moneris, - moneris::Moneris, mpgs, mpgs::Mpgs, multisafepay, multisafepay::Multisafepay, netcetera, - netcetera::Netcetera, nexinets, nexinets::Nexinets, nexixpay, nexixpay::Nexixpay, nmi, - nmi::Nmi, nomupay, nomupay::Nomupay, noon, noon::Noon, nordea, nordea::Nordea, novalnet, - novalnet::Novalnet, nuvei, nuvei::Nuvei, opayo, opayo::Opayo, opennode, opennode::Opennode, - paybox, paybox::Paybox, payeezy, payeezy::Payeezy, payload, payload::Payload, payme, - payme::Payme, payone, payone::Payone, paypal, paypal::Paypal, paystack, paystack::Paystack, - paytm, paytm::Paytm, payu, payu::Payu, phonepe, phonepe::Phonepe, placetopay, - placetopay::Placetopay, plaid, plaid::Plaid, powertranz, powertranz::Powertranz, prophetpay, - prophetpay::Prophetpay, rapyd, rapyd::Rapyd, razorpay, razorpay::Razorpay, recurly, + hyperswitch_vault, hyperswitch_vault::HyperswitchVault, hyperwallet, hyperwallet::Hyperwallet, + iatapay, iatapay::Iatapay, inespay, inespay::Inespay, itaubank, itaubank::Itaubank, jpmorgan, + jpmorgan::Jpmorgan, juspaythreedsserver, juspaythreedsserver::Juspaythreedsserver, katapult, + katapult::Katapult, klarna, klarna::Klarna, mifinity, mifinity::Mifinity, mollie, + mollie::Mollie, moneris, moneris::Moneris, mpgs, mpgs::Mpgs, multisafepay, + multisafepay::Multisafepay, netcetera, netcetera::Netcetera, nexinets, nexinets::Nexinets, + nexixpay, nexixpay::Nexixpay, nmi, nmi::Nmi, nomupay, nomupay::Nomupay, noon, noon::Noon, + nordea, nordea::Nordea, novalnet, novalnet::Novalnet, nuvei, nuvei::Nuvei, opayo, opayo::Opayo, + opennode, opennode::Opennode, paybox, paybox::Paybox, payeezy, payeezy::Payeezy, payload, + payload::Payload, payme, payme::Payme, payone, payone::Payone, paypal, paypal::Paypal, + paystack, paystack::Paystack, paytm, paytm::Paytm, payu, payu::Payu, phonepe, phonepe::Phonepe, + placetopay, placetopay::Placetopay, plaid, plaid::Plaid, powertranz, powertranz::Powertranz, + prophetpay, prophetpay::Prophetpay, rapyd, rapyd::Rapyd, razorpay, razorpay::Razorpay, recurly, recurly::Recurly, redsys, redsys::Redsys, riskified, riskified::Riskified, santander, santander::Santander, shift4, shift4::Shift4, sift, sift::Sift, signifyd, signifyd::Signifyd, silverflow, silverflow::Silverflow, square, square::Square, stax, stax::Stax, stripe, diff --git a/crates/router/tests/connectors/hyperwallet.rs b/crates/router/tests/connectors/hyperwallet.rs new file mode 100644 index 0000000000..cfd1bcb79e --- /dev/null +++ b/crates/router/tests/connectors/hyperwallet.rs @@ -0,0 +1,421 @@ +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 HyperwalletTest; +impl ConnectorActions for HyperwalletTest {} +impl utils::Connector for HyperwalletTest { + fn get_data(&self) -> api::ConnectorData { + use router::connector::Hyperwallet; + utils::construct_connector_data_old( + Box::new(Hyperwallet::new()), + types::Connector::Plaid, + api::GetToken::Connector, + None, + ) + } + + fn get_auth_token(&self) -> types::ConnectorAuthType { + utils::to_connector_auth_type( + connector_auth::ConnectorAuthentication::new() + .hyperwallet + .expect("Missing connector authentication configuration") + .into(), + ) + } + + fn get_name(&self) -> String { + "hyperwallet".to_string() + } +} + +static CONNECTOR: HyperwalletTest = HyperwalletTest {}; + +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: 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 tests diff --git a/crates/router/tests/connectors/main.rs b/crates/router/tests/connectors/main.rs index 7f3c170104..ca96206e0a 100644 --- a/crates/router/tests/connectors/main.rs +++ b/crates/router/tests/connectors/main.rs @@ -56,6 +56,7 @@ mod gpayments; mod helcim; mod hipay; mod hyperswitch_vault; +mod hyperwallet; mod iatapay; mod inespay; mod itaubank; diff --git a/crates/test_utils/src/connector_auth.rs b/crates/test_utils/src/connector_auth.rs index 22a44919f8..49cb0717c7 100644 --- a/crates/test_utils/src/connector_auth.rs +++ b/crates/test_utils/src/connector_auth.rs @@ -65,6 +65,7 @@ pub struct ConnectorAuthentication { pub helcim: Option, pub hipay: Option, pub hyperswitch_vault: Option, + pub hyperwallet: Option, pub iatapay: Option, pub inespay: Option, pub itaubank: Option, diff --git a/loadtest/config/development.toml b/loadtest/config/development.toml index 41954a9f8b..e3fe4e7722 100644 --- a/loadtest/config/development.toml +++ b/loadtest/config/development.toml @@ -133,6 +133,7 @@ gpayments.base_url = "https://{{merchant_endpoint_prefix}}-test.api.as1.gpayment helcim.base_url = "https://api.helcim.com/" hipay.base_url = "https://stage-secure-gateway.hipay-tpp.com/rest/" hyperswitch_vault.base_url = "http://localhost:8080" +hyperwallet.base_url = "https://uat-api.paylution.com" hipay.secondary_base_url = "https://stage-secure2-vault.hipay-tpp.com/rest/" hipay.third_base_url = "https://stage-api-gateway.hipay.com/" iatapay.base_url = "https://sandbox.iata-pay.iata.org/api/v1" diff --git a/scripts/add_connector.sh b/scripts/add_connector.sh index e909c144d1..b826b23850 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 adyenplatform affirm airwallex amazonpay applepay archipel authipay authorizedotnet bambora bamboraapac bankofamerica barclaycard billwerk bitpay blackhawknetwork bluecode bluesnap boku braintree breadpay cashtocode celero chargebee checkbook checkout coinbase cryptopay ctp_visa custombilling cybersource datatrans deutschebank digitalvirgo dlocal dummyconnector dwolla ebanx elavon facilitapay fiserv fiservemea fiuu flexiti forte getnet globalpay globepay gocardless gpayments helcim hipay hyperswitch_vault iatapay inespay itaubank jpmorgan juspaythreedsserver katapult klarna mifinity mollie moneris mpgs multisafepay netcetera nexinets nexixpay nomupay noon nordea novalnet nuvei opayo opennode paybox payeezy payload payme payone paypal paystack paytm payu phonepe placetopay plaid powertranz prophetpay rapyd razorpay recurly redsys santander shift4 sift silverflow square stax stripe stripebilling taxjar threedsecureio thunes tokenio trustpay trustpayments tsys unified_authentication_service vgs volt wellsfargo wellsfargopayout wise worldline worldpay worldpayvantiv worldpayxml xendit zsl "$1") + connectors=(aci adyen adyenplatform affirm airwallex amazonpay applepay archipel authipay authorizedotnet bambora bamboraapac bankofamerica barclaycard billwerk bitpay blackhawknetwork bluecode bluesnap boku braintree breadpay cashtocode celero chargebee checkbook checkout coinbase cryptopay ctp_visa custombilling cybersource datatrans deutschebank digitalvirgo dlocal dummyconnector dwolla ebanx elavon facilitapay fiserv fiservemea fiuu flexiti forte getnet globalpay globepay gocardless gpayments helcim hipay hyperswitch_vault hyperwallet hyperwallet iatapay inespay itaubank jpmorgan juspaythreedsserver katapult klarna mifinity mollie moneris mpgs multisafepay netcetera nexinets nexixpay nomupay noon nordea novalnet nuvei opayo opennode paybox payeezy payload payme payone paypal paystack paytm payu phonepe placetopay plaid powertranz prophetpay rapyd razorpay recurly redsys santander shift4 sift silverflow square stax stripe stripebilling taxjar threedsecureio thunes tokenio trustpay trustpayments tsys unified_authentication_service vgs volt wellsfargo wellsfargopayout wise worldline worldpay worldpayvantiv worldpayxml xendit zsl "$1") IFS=$'\n' sorted=($(sort <<<"${connectors[*]}")); unset IFS