From a423ff53d3523508ba6c584134e32f3f1bb4f0c0 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger <131388445+AkshayaFoiger@users.noreply.github.com> Date: Tue, 24 Dec 2024 14:37:19 +0530 Subject: [PATCH] feat(router): add endpoint for listing connector features (#6612) Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Co-authored-by: Pa1NarK <69745008+pixincreate@users.noreply.github.com> --- Cargo.lock | 1 + api-reference-v2/openapi_spec.json | 132 +++++++++++++++ api-reference/openapi_spec.json | 132 +++++++++++++++ config/config.example.toml | 4 + config/deployments/integration_test.toml | 4 + config/deployments/production.toml | 4 + config/deployments/sandbox.toml | 4 + config/development.toml | 4 + config/docker_compose.toml | 3 + connector-template/mod.rs | 5 +- crates/api_models/src/feature_matrix.rs | 46 ++++++ crates/api_models/src/lib.rs | 1 + crates/common_enums/src/enums.rs | 39 +++++ crates/hyperswitch_connectors/Cargo.toml | 1 + .../src/connectors/airwallex.rs | 7 +- .../src/connectors/amazonpay.rs | 7 +- .../src/connectors/bambora.rs | 79 ++++++--- .../src/connectors/bamboraapac.rs | 10 +- .../src/connectors/billwerk.rs | 10 +- .../src/connectors/bitpay.rs | 7 +- .../src/connectors/bluesnap.rs | 7 +- .../src/connectors/boku.rs | 10 +- .../src/connectors/cashtocode.rs | 10 +- .../src/connectors/coinbase.rs | 10 +- .../src/connectors/cryptopay.rs | 7 +- .../src/connectors/ctp_mastercard.rs | 7 +- .../src/connectors/datatrans.rs | 12 +- .../src/connectors/deutschebank.rs | 74 ++++++--- .../src/connectors/digitalvirgo.rs | 7 +- .../src/connectors/dlocal.rs | 10 +- .../src/connectors/elavon.rs | 12 +- .../src/connectors/fiserv.rs | 10 +- .../src/connectors/fiservemea.rs | 10 +- .../src/connectors/fiuu.rs | 12 +- .../src/connectors/forte.rs | 10 +- .../src/connectors/globepay.rs | 7 +- .../src/connectors/gocardless.rs | 10 +- .../src/connectors/helcim.rs | 10 +- .../src/connectors/inespay.rs | 7 +- .../src/connectors/jpmorgan.rs | 10 +- .../src/connectors/mollie.rs | 4 +- .../src/connectors/multisafepay.rs | 10 +- .../src/connectors/nexinets.rs | 10 +- .../src/connectors/nexixpay.rs | 10 +- .../src/connectors/nomupay.rs | 7 +- .../src/connectors/novalnet.rs | 7 +- .../src/connectors/paybox.rs | 7 +- .../src/connectors/payeezy.rs | 12 +- .../src/connectors/payu.rs | 10 +- .../src/connectors/placetopay.rs | 10 +- .../src/connectors/powertranz.rs | 10 +- .../src/connectors/prophetpay.rs | 7 +- .../src/connectors/rapyd.rs | 9 +- .../src/connectors/razorpay.rs | 7 +- .../src/connectors/redsys.rs | 7 +- .../src/connectors/shift4.rs | 10 +- .../src/connectors/square.rs | 10 +- .../src/connectors/stax.rs | 10 +- .../src/connectors/taxjar.rs | 7 +- .../src/connectors/thunes.rs | 7 +- .../src/connectors/tsys.rs | 10 +- .../unified_authentication_service.rs | 7 +- .../src/connectors/volt.rs | 7 +- .../src/connectors/worldline.rs | 9 +- .../src/connectors/worldpay.rs | 7 +- .../src/connectors/xendit.rs | 7 +- .../src/connectors/zen.rs | 4 +- .../src/connectors/zsl.rs | 72 ++++++--- .../src/router_response_types.rs | 53 +++++++ crates/hyperswitch_interfaces/src/api.rs | 103 ++++++++++-- .../src/api/payments.rs | 1 + .../src/api/payments_v2.rs | 5 +- crates/hyperswitch_interfaces/src/types.rs | 1 + crates/openapi/src/openapi.rs | 8 +- crates/openapi/src/openapi_v2.rs | 6 + crates/router/src/connector/aci.rs | 3 + crates/router/src/connector/adyen.rs | 7 +- crates/router/src/connector/adyenplatform.rs | 4 +- .../router/src/connector/authorizedotnet.rs | 7 +- crates/router/src/connector/bankofamerica.rs | 7 +- crates/router/src/connector/braintree.rs | 7 +- crates/router/src/connector/checkout.rs | 7 +- crates/router/src/connector/cybersource.rs | 7 +- crates/router/src/connector/dummyconnector.rs | 7 +- crates/router/src/connector/ebanx.rs | 4 +- crates/router/src/connector/globalpay.rs | 7 +- crates/router/src/connector/gpayments.rs | 4 +- crates/router/src/connector/iatapay.rs | 4 +- crates/router/src/connector/itaubank.rs | 4 +- crates/router/src/connector/klarna.rs | 7 +- crates/router/src/connector/mifinity.rs | 4 +- crates/router/src/connector/netcetera.rs | 4 +- crates/router/src/connector/nmi.rs | 7 +- crates/router/src/connector/noon.rs | 7 +- crates/router/src/connector/nuvei.rs | 7 +- crates/router/src/connector/opayo.rs | 7 +- crates/router/src/connector/opennode.rs | 4 +- crates/router/src/connector/payme.rs | 7 +- crates/router/src/connector/payone.rs | 4 +- crates/router/src/connector/paypal.rs | 7 +- crates/router/src/connector/plaid.rs | 4 +- crates/router/src/connector/riskified.rs | 4 +- crates/router/src/connector/signifyd.rs | 4 +- crates/router/src/connector/stripe.rs | 7 +- crates/router/src/connector/threedsecureio.rs | 4 +- crates/router/src/connector/trustpay.rs | 4 +- crates/router/src/connector/wellsfargo.rs | 7 +- .../router/src/connector/wellsfargopayout.rs | 4 +- crates/router/src/connector/wise.rs | 4 +- .../src/core/payments/flows/authorize_flow.rs | 3 +- crates/router/src/lib.rs | 3 +- crates/router/src/routes.rs | 7 +- crates/router/src/routes/app.rs | 14 ++ crates/router/src/routes/feature_matrix.rs | 150 ++++++++++++++++++ crates/router/src/routes/lock_utils.rs | 3 + crates/router/src/services/api.rs | 3 +- .../connector_integration_interface.rs | 48 +++++- crates/router/src/types/api.rs | 9 +- crates/router/src/types/api/payments.rs | 42 ++--- .../src/utils/connector_onboarding/paypal.rs | 6 +- crates/router_env/src/logger/types.rs | 2 + .../e2e/PaymentTest/00000-CoreFlows.cy.js | 16 ++ cypress-tests/cypress/support/commands.js | 23 +++ loadtest/config/development.toml | 4 + 124 files changed, 1490 insertions(+), 252 deletions(-) create mode 100644 crates/api_models/src/feature_matrix.rs create mode 100644 crates/router/src/routes/feature_matrix.rs diff --git a/Cargo.lock b/Cargo.lock index 9c020d9d4d9c..e34c80bd9278 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4003,6 +4003,7 @@ dependencies = [ "hyperswitch_domain_models", "hyperswitch_interfaces", "image", + "lazy_static", "masking", "mime", "once_cell", diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.json index 3f9167ab7578..636723d808a4 100644 --- a/api-reference-v2/openapi_spec.json +++ b/api-reference-v2/openapi_spec.json @@ -6700,6 +6700,43 @@ "zsl" ] }, + "ConnectorFeatureMatrixResponse": { + "type": "object", + "required": [ + "name", + "supported_payment_methods" + ], + "properties": { + "name": { + "type": "string" + }, + "description": { + "type": "string", + "nullable": true + }, + "category": { + "allOf": [ + { + "$ref": "#/components/schemas/PaymentConnectorCategory" + } + ], + "nullable": true + }, + "supported_payment_methods": { + "type": "array", + "items": { + "$ref": "#/components/schemas/SupportedPaymentMethod" + } + }, + "supported_webhook_flows": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EventClass" + }, + "nullable": true + } + } + }, "ConnectorMetadata": { "type": "object", "description": "Some connectors like Apple Pay, Airwallex and Noon might require some additional information, find specific details in the child attributes below.", @@ -8672,6 +8709,38 @@ } } }, + "FeatureMatrixListResponse": { + "type": "object", + "required": [ + "connector_count", + "connectors" + ], + "properties": { + "connector_count": { + "type": "integer", + "description": "The number of connectors included in the response", + "minimum": 0 + }, + "connectors": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ConnectorFeatureMatrixResponse" + } + } + } + }, + "FeatureMatrixRequest": { + "type": "object", + "properties": { + "connectors": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Connector" + }, + "nullable": true + } + } + }, "FeatureMetadata": { "type": "object", "description": "additional data that might be required by hyperswitch", @@ -8702,6 +8771,14 @@ } } }, + "FeatureStatus": { + "type": "string", + "description": "The status of the feature", + "enum": [ + "not_supported", + "supported" + ] + }, "FieldType": { "oneOf": [ { @@ -12746,6 +12823,15 @@ } ] }, + "PaymentConnectorCategory": { + "type": "string", + "description": "Connector Access Method", + "enum": [ + "payment_gateway", + "alternative_payment_method", + "bank_acquirer" + ] + }, "PaymentCreatePaymentLinkConfig": { "allOf": [ { @@ -20591,6 +20677,52 @@ }, "additionalProperties": false }, + "SupportedPaymentMethod": { + "type": "object", + "required": [ + "payment_method", + "payment_method_type", + "mandates", + "refunds", + "supported_capture_methods" + ], + "properties": { + "payment_method": { + "$ref": "#/components/schemas/PaymentMethod" + }, + "payment_method_type": { + "$ref": "#/components/schemas/PaymentMethodType" + }, + "mandates": { + "$ref": "#/components/schemas/FeatureStatus" + }, + "refunds": { + "$ref": "#/components/schemas/FeatureStatus" + }, + "supported_capture_methods": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CaptureMethod" + } + }, + "supported_countries": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CountryAlpha2" + }, + "uniqueItems": true, + "nullable": true + }, + "supported_currencies": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Currency" + }, + "uniqueItems": true, + "nullable": true + } + } + }, "SurchargeCalculationOverride": { "type": "string", "enum": [ diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.json index 2aa19e4e223c..3c80fd8c4634 100644 --- a/api-reference/openapi_spec.json +++ b/api-reference/openapi_spec.json @@ -9319,6 +9319,43 @@ "zsl" ] }, + "ConnectorFeatureMatrixResponse": { + "type": "object", + "required": [ + "name", + "supported_payment_methods" + ], + "properties": { + "name": { + "type": "string" + }, + "description": { + "type": "string", + "nullable": true + }, + "category": { + "allOf": [ + { + "$ref": "#/components/schemas/PaymentConnectorCategory" + } + ], + "nullable": true + }, + "supported_payment_methods": { + "type": "array", + "items": { + "$ref": "#/components/schemas/SupportedPaymentMethod" + } + }, + "supported_webhook_flows": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EventClass" + }, + "nullable": true + } + } + }, "ConnectorMetadata": { "type": "object", "description": "Some connectors like Apple Pay, Airwallex and Noon might require some additional information, find specific details in the child attributes below.", @@ -11269,6 +11306,38 @@ } } }, + "FeatureMatrixListResponse": { + "type": "object", + "required": [ + "connector_count", + "connectors" + ], + "properties": { + "connector_count": { + "type": "integer", + "description": "The number of connectors included in the response", + "minimum": 0 + }, + "connectors": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ConnectorFeatureMatrixResponse" + } + } + } + }, + "FeatureMatrixRequest": { + "type": "object", + "properties": { + "connectors": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Connector" + }, + "nullable": true + } + } + }, "FeatureMetadata": { "type": "object", "description": "additional data that might be required by hyperswitch", @@ -11299,6 +11368,14 @@ } } }, + "FeatureStatus": { + "type": "string", + "description": "The status of the feature", + "enum": [ + "not_supported", + "supported" + ] + }, "FieldType": { "oneOf": [ { @@ -15782,6 +15859,15 @@ } ] }, + "PaymentConnectorCategory": { + "type": "string", + "description": "Connector Access Method", + "enum": [ + "payment_gateway", + "alternative_payment_method", + "bank_acquirer" + ] + }, "PaymentCreatePaymentLinkConfig": { "allOf": [ { @@ -25077,6 +25163,52 @@ } } }, + "SupportedPaymentMethod": { + "type": "object", + "required": [ + "payment_method", + "payment_method_type", + "mandates", + "refunds", + "supported_capture_methods" + ], + "properties": { + "payment_method": { + "$ref": "#/components/schemas/PaymentMethod" + }, + "payment_method_type": { + "$ref": "#/components/schemas/PaymentMethodType" + }, + "mandates": { + "$ref": "#/components/schemas/FeatureStatus" + }, + "refunds": { + "$ref": "#/components/schemas/FeatureStatus" + }, + "supported_capture_methods": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CaptureMethod" + } + }, + "supported_countries": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CountryAlpha2" + }, + "uniqueItems": true, + "nullable": true + }, + "supported_currencies": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Currency" + }, + "uniqueItems": true, + "nullable": true + } + } + }, "SurchargeDetailsResponse": { "type": "object", "required": [ diff --git a/config/config.example.toml b/config/config.example.toml index 11e8bed7dacd..999266321144 100644 --- a/config/config.example.toml +++ b/config/config.example.toml @@ -516,6 +516,10 @@ seicomart = { country = "JP", currency = "JPY" } pay_easy = { country = "JP", currency = "JPY" } boleto = { country = "BR", currency = "BRL" } +[pm_filters.bambora] +credit = { country = "US,CA", currency = "USD" } +debit = { country = "US,CA", currency = "USD" } + [pm_filters.volt] open_banking_uk = { country = "DE,GB,AT,BE,CY,EE,ES,FI,FR,GR,HR,IE,IT,LT,LU,LV,MT,NL,PT,SI,SK,BG,CZ,DK,HU,NO,PL,RO,SE,AU,BR", currency = "EUR,GBP,DKK,NOK,PLN,SEK,AUD,BRL" } diff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.toml index 65ce1fdbc0a6..dd4938d8d6f8 100644 --- a/config/deployments/integration_test.toml +++ b/config/deployments/integration_test.toml @@ -278,6 +278,10 @@ we_chat_pay = { country = "AU,NZ,CN,JP,HK,SG,ES,GB,SE,NO,AT,NL,DE,CY,CH,BE,FR,DK google_pay.currency = "CHF,DKK,EUR,GBP,NOK,PLN,SEK,USD,AUD,NZD,CAD" paypal.currency = "CHF,DKK,EUR,GBP,NOK,PLN,SEK,USD,AUD,NZD,CAD" +[pm_filters.bambora] +credit = { country = "US,CA", currency = "USD" } +debit = { country = "US,CA", currency = "USD" } + [pm_filters.bankofamerica] credit = { currency = "USD" } debit = { currency = "USD" } diff --git a/config/deployments/production.toml b/config/deployments/production.toml index 8900b0ac3856..9ad4f90b71f1 100644 --- a/config/deployments/production.toml +++ b/config/deployments/production.toml @@ -292,6 +292,10 @@ we_chat_pay = { country = "AU,NZ,CN,JP,HK,SG,ES,GB,SE,NO,AT,NL,DE,CY,CH,BE,FR,DK google_pay.currency = "CHF,DKK,EUR,GBP,NOK,PLN,SEK,USD,AUD,NZD,CAD" paypal.currency = "CHF,DKK,EUR,GBP,NOK,PLN,SEK,USD,AUD,NZD,CAD" +[pm_filters.bambora] +credit = { country = "US,CA", currency = "USD" } +debit = { country = "US,CA", currency = "USD" } + [pm_filters.bankofamerica] credit = { currency = "USD" } debit = { currency = "USD" } diff --git a/config/deployments/sandbox.toml b/config/deployments/sandbox.toml index ae4afb2ec3ff..d2132cd1e400 100644 --- a/config/deployments/sandbox.toml +++ b/config/deployments/sandbox.toml @@ -294,6 +294,10 @@ pix = { country = "BR", currency = "BRL" } google_pay.currency = "CHF,DKK,EUR,GBP,NOK,PLN,SEK,USD,AUD,NZD,CAD" paypal.currency = "CHF,DKK,EUR,GBP,NOK,PLN,SEK,USD,AUD,NZD,CAD" +[pm_filters.bambora] +credit = { country = "US,CA", currency = "USD" } +debit = { country = "US,CA", currency = "USD" } + [pm_filters.bankofamerica] credit = { currency = "USD" } debit = { currency = "USD" } diff --git a/config/development.toml b/config/development.toml index 7e3c3c8ba070..d157894ac766 100644 --- a/config/development.toml +++ b/config/development.toml @@ -459,6 +459,10 @@ pay_easy = { country = "JP", currency = "JPY" } pix = { country = "BR", currency = "BRL" } boleto = { country = "BR", currency = "BRL" } +[pm_filters.bambora] +credit = { country = "US,CA", currency = "USD" } +debit = { country = "US,CA", currency = "USD" } + [pm_filters.bankofamerica] credit = { currency = "USD" } debit = { currency = "USD" } diff --git a/config/docker_compose.toml b/config/docker_compose.toml index 09b27d6bd7f4..3bbb11063505 100644 --- a/config/docker_compose.toml +++ b/config/docker_compose.toml @@ -430,6 +430,9 @@ vipps = { country = "NO", currency = "NOK" } walley = { country = "SE,NO,DK,FI", currency = "DKK,EUR,NOK,SEK" } we_chat_pay = { country = "AU,NZ,CN,JP,HK,SG,ES,GB,SE,NO,AT,NL,DE,CY,CH,BE,FR,DK,LI,MT,SI,GR,PT,IT,CA,US", currency = "AUD,CAD,CNY,EUR,GBP,HKD,JPY,NZD,SGD,USD,CNY" } +[pm_filters.bambora] +credit = { country = "US,CA", currency = "USD" } +debit = { country = "US,CA", currency = "USD" } [pm_filters.volt] open_banking_uk = { country = "DE,GB,AT,BE,CY,EE,ES,FI,FR,GR,HR,IE,IT,LT,LU,LV,MT,NL,PT,SI,SK,BG,CZ,DK,HU,NO,PL,RO,SE,AU,BR", currency = "EUR,GBP,DKK,NOK,PLN,SEK,AUD,BRL" } diff --git a/connector-template/mod.rs b/connector-template/mod.rs index ae450aecf20b..ee5f4872d6eb 100644 --- a/connector-template/mod.rs +++ b/connector-template/mod.rs @@ -32,7 +32,7 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation, ConnectorSpecifications}, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -551,3 +551,6 @@ impl webhooks::IncomingWebhook for {{project-name | downcase | pascal_case}} { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for {{project-name | downcase | pascal_case}} {} + diff --git a/crates/api_models/src/feature_matrix.rs b/crates/api_models/src/feature_matrix.rs new file mode 100644 index 000000000000..2eaade1b61e8 --- /dev/null +++ b/crates/api_models/src/feature_matrix.rs @@ -0,0 +1,46 @@ +use std::collections::HashSet; + +use serde::{Deserialize, Serialize}; +use utoipa::ToSchema; + +use crate::enums::{ + CaptureMethod, Connector, CountryAlpha2, Currency, EventClass, FeatureStatus, + PaymentConnectorCategory, PaymentMethod, PaymentMethodType, +}; + +#[derive(Default, Debug, Deserialize, Serialize, Clone, ToSchema)] +pub struct FeatureMatrixRequest { + // List of connectors for which the feature matrix is requested + pub connectors: Option>, +} + +#[derive(Debug, ToSchema, Serialize)] +pub struct SupportedPaymentMethod { + pub payment_method: PaymentMethod, + pub payment_method_type: PaymentMethodType, + pub mandates: FeatureStatus, + pub refunds: FeatureStatus, + pub supported_capture_methods: Vec, + pub supported_countries: Option>, + pub supported_currencies: Option>, +} + +#[derive(Debug, ToSchema, Serialize)] +pub struct ConnectorFeatureMatrixResponse { + pub name: String, + pub description: Option, + pub category: Option, + pub supported_payment_methods: Vec, + pub supported_webhook_flows: Option>, +} + +#[derive(Debug, Serialize, ToSchema)] +pub struct FeatureMatrixListResponse { + /// The number of connectors included in the response + pub connector_count: usize, + // The list of payments response objects + pub connectors: Vec, +} + +impl common_utils::events::ApiEventMetric for FeatureMatrixListResponse {} +impl common_utils::events::ApiEventMetric for FeatureMatrixRequest {} diff --git a/crates/api_models/src/lib.rs b/crates/api_models/src/lib.rs index 2d1e87ebf01e..60d1d11f27db 100644 --- a/crates/api_models/src/lib.rs +++ b/crates/api_models/src/lib.rs @@ -16,6 +16,7 @@ pub mod ephemeral_key; #[cfg(feature = "errors")] pub mod errors; pub mod events; +pub mod feature_matrix; pub mod files; pub mod gsm; pub mod health_check; diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs index 193998c3fd1c..0833ab37e3f8 100644 --- a/crates/common_enums/src/enums.rs +++ b/crates/common_enums/src/enums.rs @@ -3574,3 +3574,42 @@ pub enum StripeChargeType { Direct, Destination, } + +/// Connector Access Method +#[derive( + Clone, + Copy, + Debug, + Eq, + PartialEq, + serde::Deserialize, + serde::Serialize, + strum::Display, + ToSchema, +)] +#[strum(serialize_all = "snake_case")] +#[serde(rename_all = "snake_case")] +pub enum PaymentConnectorCategory { + PaymentGateway, + AlternativePaymentMethod, + BankAcquirer, +} + +/// The status of the feature +#[derive( + Clone, + Copy, + Debug, + Eq, + PartialEq, + serde::Deserialize, + serde::Serialize, + strum::Display, + ToSchema, +)] +#[strum(serialize_all = "snake_case")] +#[serde(rename_all = "snake_case")] +pub enum FeatureStatus { + NotSupported, + Supported, +} diff --git a/crates/hyperswitch_connectors/Cargo.toml b/crates/hyperswitch_connectors/Cargo.toml index 6405ac8ae84f..ca9e77283cda 100644 --- a/crates/hyperswitch_connectors/Cargo.toml +++ b/crates/hyperswitch_connectors/Cargo.toml @@ -40,6 +40,7 @@ time = "0.3.35" url = "2.5.0" urlencoding = "2.1.3" uuid = { version = "1.8.0", features = ["v4"] } +lazy_static = "1.4.0" # First party crates api_models = { version = "0.1.0", path = "../api_models", features = ["errors"], default-features = false } diff --git a/crates/hyperswitch_connectors/src/connectors/airwallex.rs b/crates/hyperswitch_connectors/src/connectors/airwallex.rs index 2b7b301ab943..f37bef830269 100644 --- a/crates/hyperswitch_connectors/src/connectors/airwallex.rs +++ b/crates/hyperswitch_connectors/src/connectors/airwallex.rs @@ -34,7 +34,7 @@ use hyperswitch_domain_models::{ use hyperswitch_interfaces::{ api::{ self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorRedirectResponse, - ConnectorValidation, + ConnectorSpecifications, ConnectorValidation, }, configs::Connectors, disputes::DisputePayload, @@ -127,9 +127,10 @@ impl ConnectorCommon for Airwallex { } impl ConnectorValidation for Airwallex { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -1105,3 +1106,5 @@ impl ConnectorRedirectResponse for Airwallex { } } } + +impl ConnectorSpecifications for Airwallex {} diff --git a/crates/hyperswitch_connectors/src/connectors/amazonpay.rs b/crates/hyperswitch_connectors/src/connectors/amazonpay.rs index da4d3d79bbcf..f89595415748 100644 --- a/crates/hyperswitch_connectors/src/connectors/amazonpay.rs +++ b/crates/hyperswitch_connectors/src/connectors/amazonpay.rs @@ -26,7 +26,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -565,3 +568,5 @@ impl webhooks::IncomingWebhook for Amazonpay { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Amazonpay {} diff --git a/crates/hyperswitch_connectors/src/connectors/bambora.rs b/crates/hyperswitch_connectors/src/connectors/bambora.rs index 4e69a39fed66..193a16df0b19 100644 --- a/crates/hyperswitch_connectors/src/connectors/bambora.rs +++ b/crates/hyperswitch_connectors/src/connectors/bambora.rs @@ -22,7 +22,10 @@ use hyperswitch_domain_models::{ PaymentsAuthorizeData, PaymentsCancelData, PaymentsCaptureData, PaymentsSessionData, PaymentsSyncData, RefundsData, SetupMandateRequestData, }, - router_response_types::{PaymentsResponseData, RefundsResponseData}, + router_response_types::{ + ConnectorInfo, PaymentMethodDetails, PaymentsResponseData, RefundsResponseData, + SupportedPaymentMethods, SupportedPaymentMethodsExt, + }, types::{ PaymentsAuthorizeRouterData, PaymentsCancelRouterData, PaymentsCaptureRouterData, PaymentsCompleteAuthorizeRouterData, PaymentsSyncRouterData, RefundSyncRouterData, @@ -32,7 +35,7 @@ use hyperswitch_domain_models::{ use hyperswitch_interfaces::{ api::{ self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorRedirectResponse, - ConnectorValidation, + ConnectorSpecifications, ConnectorValidation, }, configs::Connectors, errors, @@ -43,6 +46,7 @@ use hyperswitch_interfaces::{ }, webhooks, }; +use lazy_static::lazy_static; use masking::Mask; use transformers as bambora; @@ -144,23 +148,7 @@ impl ConnectorCommon for Bambora { } } -impl ConnectorValidation for Bambora { - fn validate_capture_method( - &self, - capture_method: Option, - _pmt: Option, - ) -> CustomResult<(), errors::ConnectorError> { - let capture_method = capture_method.unwrap_or_default(); - match capture_method { - enums::CaptureMethod::Automatic - | enums::CaptureMethod::Manual - | enums::CaptureMethod::SequentialAutomatic => Ok(()), - enums::CaptureMethod::ManualMultiple | enums::CaptureMethod::Scheduled => Err( - utils::construct_not_implemented_error_report(capture_method, self.id()), - ), - } - } -} +impl ConnectorValidation for Bambora {} impl ConnectorIntegration for Bambora @@ -828,3 +816,56 @@ impl webhooks::IncomingWebhook for Bambora { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +lazy_static! { + static ref BAMBORA_SUPPORTED_PAYMENT_METHODS: SupportedPaymentMethods = { + let default_capture_methods = vec![ + enums::CaptureMethod::Automatic, + enums::CaptureMethod::Manual, + enums::CaptureMethod::SequentialAutomatic, + ]; + + let mut bambora_supported_payment_methods = SupportedPaymentMethods::new(); + + bambora_supported_payment_methods.add( + enums::PaymentMethod::Card, + enums::PaymentMethodType::Credit, + PaymentMethodDetails { + mandates: common_enums::FeatureStatus::NotSupported, + refunds: common_enums::FeatureStatus::Supported, + supported_capture_methods: default_capture_methods.clone(), + }, + ); + bambora_supported_payment_methods.add( + enums::PaymentMethod::Card, + enums::PaymentMethodType::Debit, + PaymentMethodDetails { + mandates: common_enums::FeatureStatus::NotSupported, + refunds: common_enums::FeatureStatus::Supported, + supported_capture_methods: default_capture_methods.clone(), + }, + ); + + bambora_supported_payment_methods + }; + static ref BAMBORA_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo { + description: "Bambora is a leading online payment provider in Canada and United States." + .to_string(), + connector_type: enums::PaymentConnectorCategory::PaymentGateway, + }; + static ref BAMBORA_SUPPORTED_WEBHOOK_FLOWS: Vec = Vec::new(); +} + +impl ConnectorSpecifications for Bambora { + fn get_connector_about(&self) -> Option<&'static ConnectorInfo> { + Some(&*BAMBORA_CONNECTOR_INFO) + } + + fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> { + Some(&*BAMBORA_SUPPORTED_PAYMENT_METHODS) + } + + fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> { + Some(&*BAMBORA_SUPPORTED_WEBHOOK_FLOWS) + } +} diff --git a/crates/hyperswitch_connectors/src/connectors/bamboraapac.rs b/crates/hyperswitch_connectors/src/connectors/bamboraapac.rs index 9954c568071c..cdfacbf3ecb1 100644 --- a/crates/hyperswitch_connectors/src/connectors/bamboraapac.rs +++ b/crates/hyperswitch_connectors/src/connectors/bamboraapac.rs @@ -29,7 +29,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, consts::{NO_ERROR_CODE, NO_ERROR_MESSAGE}, errors, @@ -95,9 +98,10 @@ where } impl ConnectorValidation for Bamboraapac { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -742,3 +746,5 @@ impl IncomingWebhook for Bamboraapac { fn html_to_xml_string_conversion(res: String) -> String { res.replace("<", "<").replace(">", ">") } + +impl ConnectorSpecifications for Bamboraapac {} diff --git a/crates/hyperswitch_connectors/src/connectors/billwerk.rs b/crates/hyperswitch_connectors/src/connectors/billwerk.rs index 7a6fefa820b2..3987039de974 100644 --- a/crates/hyperswitch_connectors/src/connectors/billwerk.rs +++ b/crates/hyperswitch_connectors/src/connectors/billwerk.rs @@ -29,7 +29,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, consts::{NO_ERROR_CODE, NO_ERROR_MESSAGE}, errors, @@ -151,9 +154,10 @@ impl ConnectorCommon for Billwerk { } impl ConnectorValidation for Billwerk { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: common_enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -813,3 +817,5 @@ impl IncomingWebhook for Billwerk { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Billwerk {} diff --git a/crates/hyperswitch_connectors/src/connectors/bitpay.rs b/crates/hyperswitch_connectors/src/connectors/bitpay.rs index 032b8cf051fa..c2a2c7b76a17 100644 --- a/crates/hyperswitch_connectors/src/connectors/bitpay.rs +++ b/crates/hyperswitch_connectors/src/connectors/bitpay.rs @@ -27,7 +27,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, consts, errors, events::connector_api_logs::ConnectorEvent, @@ -412,3 +415,5 @@ impl webhooks::IncomingWebhook for Bitpay { Ok(Box::new(notif)) } } + +impl ConnectorSpecifications for Bitpay {} diff --git a/crates/hyperswitch_connectors/src/connectors/bluesnap.rs b/crates/hyperswitch_connectors/src/connectors/bluesnap.rs index 3267637b09a7..8fac36424e23 100644 --- a/crates/hyperswitch_connectors/src/connectors/bluesnap.rs +++ b/crates/hyperswitch_connectors/src/connectors/bluesnap.rs @@ -35,7 +35,7 @@ use hyperswitch_domain_models::{ use hyperswitch_interfaces::{ api::{ self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorRedirectResponse, - ConnectorValidation, + ConnectorSpecifications, ConnectorValidation, }, configs::Connectors, consts::{NO_ERROR_CODE, NO_ERROR_MESSAGE}, @@ -204,9 +204,10 @@ impl ConnectorCommon for Bluesnap { } impl ConnectorValidation for Bluesnap { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -1369,3 +1370,5 @@ fn get_rsync_url_with_connector_refund_id( req.request.get_connector_refund_id()? )) } + +impl ConnectorSpecifications for Bluesnap {} diff --git a/crates/hyperswitch_connectors/src/connectors/boku.rs b/crates/hyperswitch_connectors/src/connectors/boku.rs index 73b17ca802ec..68195979874b 100644 --- a/crates/hyperswitch_connectors/src/connectors/boku.rs +++ b/crates/hyperswitch_connectors/src/connectors/boku.rs @@ -28,7 +28,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, consts::NO_ERROR_CODE, errors, @@ -168,9 +171,10 @@ impl ConnectorCommon for Boku { } impl ConnectorValidation for Boku { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -705,3 +709,5 @@ fn get_xml_deserialized( } } } + +impl ConnectorSpecifications for Boku {} diff --git a/crates/hyperswitch_connectors/src/connectors/cashtocode.rs b/crates/hyperswitch_connectors/src/connectors/cashtocode.rs index b4e066ebd992..cc7ac3812374 100644 --- a/crates/hyperswitch_connectors/src/connectors/cashtocode.rs +++ b/crates/hyperswitch_connectors/src/connectors/cashtocode.rs @@ -25,7 +25,10 @@ use hyperswitch_domain_models::{ types::{PaymentsAuthorizeRouterData, PaymentsSyncRouterData}, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -148,9 +151,10 @@ impl ConnectorCommon for Cashtocode { } impl ConnectorValidation for Cashtocode { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -452,3 +456,5 @@ impl ConnectorIntegration for Cashtoc impl ConnectorIntegration for Cashtocode { // default implementation of build_request method will be executed } + +impl ConnectorSpecifications for Cashtocode {} diff --git a/crates/hyperswitch_connectors/src/connectors/coinbase.rs b/crates/hyperswitch_connectors/src/connectors/coinbase.rs index 168cb2132d70..f58437ff0793 100644 --- a/crates/hyperswitch_connectors/src/connectors/coinbase.rs +++ b/crates/hyperswitch_connectors/src/connectors/coinbase.rs @@ -29,7 +29,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -133,9 +136,10 @@ impl ConnectorCommon for Coinbase { } impl ConnectorValidation for Coinbase { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -440,3 +444,5 @@ impl webhooks::IncomingWebhook for Coinbase { Ok(Box::new(notif.event)) } } + +impl ConnectorSpecifications for Coinbase {} diff --git a/crates/hyperswitch_connectors/src/connectors/cryptopay.rs b/crates/hyperswitch_connectors/src/connectors/cryptopay.rs index dcd629f4336b..2650d8f1e91b 100644 --- a/crates/hyperswitch_connectors/src/connectors/cryptopay.rs +++ b/crates/hyperswitch_connectors/src/connectors/cryptopay.rs @@ -27,7 +27,10 @@ use hyperswitch_domain_models::{ types::{PaymentsAuthorizeRouterData, PaymentsSyncRouterData}, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -496,3 +499,5 @@ impl webhooks::IncomingWebhook for Cryptopay { Ok(Box::new(notif)) } } + +impl ConnectorSpecifications for Cryptopay {} diff --git a/crates/hyperswitch_connectors/src/connectors/ctp_mastercard.rs b/crates/hyperswitch_connectors/src/connectors/ctp_mastercard.rs index 1d82b98af8af..6a1c7e08815a 100644 --- a/crates/hyperswitch_connectors/src/connectors/ctp_mastercard.rs +++ b/crates/hyperswitch_connectors/src/connectors/ctp_mastercard.rs @@ -15,7 +15,10 @@ use hyperswitch_domain_models::{ router_response_types::{PaymentsResponseData, RefundsResponseData}, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, webhooks, }; @@ -122,3 +125,5 @@ impl webhooks::IncomingWebhook for CtpMastercard { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for CtpMastercard {} diff --git a/crates/hyperswitch_connectors/src/connectors/datatrans.rs b/crates/hyperswitch_connectors/src/connectors/datatrans.rs index 081fedc6a36f..2a19a99c0fad 100644 --- a/crates/hyperswitch_connectors/src/connectors/datatrans.rs +++ b/crates/hyperswitch_connectors/src/connectors/datatrans.rs @@ -2,7 +2,7 @@ pub mod transformers; use api_models::webhooks::{IncomingWebhookEvent, ObjectReferenceId}; use base64::Engine; -use common_enums::{CaptureMethod, PaymentMethodType}; +use common_enums::{CaptureMethod, PaymentMethod, PaymentMethodType}; use common_utils::{ consts::BASE64_ENGINE, errors::CustomResult, @@ -30,7 +30,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -153,9 +156,10 @@ impl ConnectorCommon for Datatrans { impl ConnectorValidation for Datatrans { //TODO: implement functions when support enabled - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -682,3 +686,5 @@ impl IncomingWebhook for Datatrans { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Datatrans {} diff --git a/crates/hyperswitch_connectors/src/connectors/deutschebank.rs b/crates/hyperswitch_connectors/src/connectors/deutschebank.rs index 28bcd8afca6d..3098d27e7ecb 100644 --- a/crates/hyperswitch_connectors/src/connectors/deutschebank.rs +++ b/crates/hyperswitch_connectors/src/connectors/deutschebank.rs @@ -27,7 +27,10 @@ use hyperswitch_domain_models::{ PaymentsAuthorizeData, PaymentsCancelData, PaymentsCaptureData, PaymentsSessionData, PaymentsSyncData, RefundsData, SetupMandateRequestData, }, - router_response_types::{PaymentsResponseData, RefundsResponseData}, + router_response_types::{ + ConnectorInfo, PaymentMethodDetails, PaymentsResponseData, RefundsResponseData, + SupportedPaymentMethods, SupportedPaymentMethodsExt, + }, types::{ PaymentsAuthorizeRouterData, PaymentsCancelRouterData, PaymentsCaptureRouterData, PaymentsCompleteAuthorizeRouterData, PaymentsSyncRouterData, RefreshTokenRouterData, @@ -35,13 +38,17 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, types::{self, Response}, webhooks, }; +use lazy_static::lazy_static; use masking::{ExposeInterface, Mask, Secret}; use rand::distributions::{Alphanumeric, DistString}; use ring::hmac; @@ -172,22 +179,6 @@ impl ConnectorCommon for Deutschebank { } impl ConnectorValidation for Deutschebank { - fn validate_capture_method( - &self, - capture_method: Option, - _pmt: Option, - ) -> CustomResult<(), errors::ConnectorError> { - let capture_method = capture_method.unwrap_or_default(); - match capture_method { - enums::CaptureMethod::Automatic - | enums::CaptureMethod::Manual - | enums::CaptureMethod::SequentialAutomatic => Ok(()), - enums::CaptureMethod::ManualMultiple | enums::CaptureMethod::Scheduled => Err( - utils::construct_not_implemented_error_report(capture_method, self.id()), - ), - } - } - fn validate_mandate_payment( &self, pm_type: Option, @@ -948,3 +939,50 @@ impl webhooks::IncomingWebhook for Deutschebank { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +lazy_static! { + static ref DEUTSCHEBANK_SUPPORTED_PAYMENT_METHODS: SupportedPaymentMethods = { + let supported_capture_methods = vec![ + enums::CaptureMethod::Automatic, + enums::CaptureMethod::Manual, + enums::CaptureMethod::SequentialAutomatic, + ]; + let mut deutschebank_supported_payment_methods = SupportedPaymentMethods::new(); + + deutschebank_supported_payment_methods.add( + enums::PaymentMethod::BankDebit, + enums::PaymentMethodType::Sepa, + PaymentMethodDetails{ + mandates: enums::FeatureStatus::NotSupported, + refunds: enums::FeatureStatus::NotSupported, + supported_capture_methods, + } + ); + + deutschebank_supported_payment_methods + }; + + static ref DEUTSCHEBANK_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo { + description: + "Deutsche Bank is a German multinational investment bank and financial services company " + .to_string(), + connector_type: enums::PaymentConnectorCategory::BankAcquirer, + }; + + static ref DEUTSCHEBANK_SUPPORTED_WEBHOOK_FLOWS: Vec = Vec::new(); + +} + +impl ConnectorSpecifications for Deutschebank { + fn get_connector_about(&self) -> Option<&'static ConnectorInfo> { + Some(&*DEUTSCHEBANK_CONNECTOR_INFO) + } + + fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> { + Some(&*DEUTSCHEBANK_SUPPORTED_PAYMENT_METHODS) + } + + fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> { + Some(&*DEUTSCHEBANK_SUPPORTED_WEBHOOK_FLOWS) + } +} diff --git a/crates/hyperswitch_connectors/src/connectors/digitalvirgo.rs b/crates/hyperswitch_connectors/src/connectors/digitalvirgo.rs index 0f84bfa61931..74d76c4754ff 100644 --- a/crates/hyperswitch_connectors/src/connectors/digitalvirgo.rs +++ b/crates/hyperswitch_connectors/src/connectors/digitalvirgo.rs @@ -35,7 +35,7 @@ use hyperswitch_domain_models::{ use hyperswitch_interfaces::{ api::{ self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorRedirectResponse, - ConnectorValidation, + ConnectorSpecifications, ConnectorValidation, }, configs::Connectors, errors, @@ -163,9 +163,10 @@ impl ConnectorCommon for Digitalvirgo { } impl ConnectorValidation for Digitalvirgo { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -538,3 +539,5 @@ impl webhooks::IncomingWebhook for Digitalvirgo { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Digitalvirgo {} diff --git a/crates/hyperswitch_connectors/src/connectors/dlocal.rs b/crates/hyperswitch_connectors/src/connectors/dlocal.rs index a61110435e7f..0aefd65e4a0f 100644 --- a/crates/hyperswitch_connectors/src/connectors/dlocal.rs +++ b/crates/hyperswitch_connectors/src/connectors/dlocal.rs @@ -32,7 +32,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -154,9 +157,10 @@ impl ConnectorCommon for Dlocal { } impl ConnectorValidation for Dlocal { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -688,3 +692,5 @@ impl webhooks::IncomingWebhook for Dlocal { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Dlocal {} diff --git a/crates/hyperswitch_connectors/src/connectors/elavon.rs b/crates/hyperswitch_connectors/src/connectors/elavon.rs index 4fcc75296f57..28ffecff7315 100644 --- a/crates/hyperswitch_connectors/src/connectors/elavon.rs +++ b/crates/hyperswitch_connectors/src/connectors/elavon.rs @@ -1,7 +1,7 @@ pub mod transformers; use std::{collections::HashMap, str}; -use common_enums::{CaptureMethod, PaymentMethodType}; +use common_enums::{CaptureMethod, PaymentMethod, PaymentMethodType}; use common_utils::{ errors::CustomResult, request::{Method, Request, RequestBuilder, RequestContent}, @@ -28,7 +28,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -579,9 +582,10 @@ impl webhooks::IncomingWebhook for Elavon { } impl ConnectorValidation for Elavon { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -603,3 +607,5 @@ impl ConnectorValidation for Elavon { utils::is_mandate_supported(pm_data, pm_type, mandate_supported_pmd, self.id()) } } + +impl ConnectorSpecifications for Elavon {} diff --git a/crates/hyperswitch_connectors/src/connectors/fiserv.rs b/crates/hyperswitch_connectors/src/connectors/fiserv.rs index e241990f8eb3..e80c57454a09 100644 --- a/crates/hyperswitch_connectors/src/connectors/fiserv.rs +++ b/crates/hyperswitch_connectors/src/connectors/fiserv.rs @@ -29,7 +29,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, consts, errors, events::connector_api_logs::ConnectorEvent, @@ -179,9 +182,10 @@ impl ConnectorCommon for Fiserv { } impl ConnectorValidation for Fiserv { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -784,3 +788,5 @@ impl webhooks::IncomingWebhook for Fiserv { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Fiserv {} diff --git a/crates/hyperswitch_connectors/src/connectors/fiservemea.rs b/crates/hyperswitch_connectors/src/connectors/fiservemea.rs index 86a626908b64..13ec1870e04c 100644 --- a/crates/hyperswitch_connectors/src/connectors/fiservemea.rs +++ b/crates/hyperswitch_connectors/src/connectors/fiservemea.rs @@ -28,7 +28,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, consts, errors, events::connector_api_logs::ConnectorEvent, @@ -247,9 +250,10 @@ impl ConnectorCommon for Fiservemea { } impl ConnectorValidation for Fiservemea { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -786,3 +790,5 @@ impl webhooks::IncomingWebhook for Fiservemea { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Fiservemea {} diff --git a/crates/hyperswitch_connectors/src/connectors/fiuu.rs b/crates/hyperswitch_connectors/src/connectors/fiuu.rs index df2d0f5006fe..7805281c4be0 100644 --- a/crates/hyperswitch_connectors/src/connectors/fiuu.rs +++ b/crates/hyperswitch_connectors/src/connectors/fiuu.rs @@ -2,7 +2,7 @@ pub mod transformers; use std::collections::{HashMap, HashSet}; -use common_enums::{CaptureMethod, PaymentMethodType}; +use common_enums::{CaptureMethod, PaymentMethod, PaymentMethodType}; use common_utils::{ crypto::{self, GenerateDigest}, errors::{self as common_errors, CustomResult}, @@ -31,7 +31,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -202,9 +205,10 @@ pub fn build_form_from_struct(data: T) -> Result, + _payment_method: PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -925,3 +929,5 @@ impl webhooks::IncomingWebhook for Fiuu { Ok(mandate_reference) } } + +impl ConnectorSpecifications for Fiuu {} diff --git a/crates/hyperswitch_connectors/src/connectors/forte.rs b/crates/hyperswitch_connectors/src/connectors/forte.rs index b35efc7c5fd4..1068922faa7a 100644 --- a/crates/hyperswitch_connectors/src/connectors/forte.rs +++ b/crates/hyperswitch_connectors/src/connectors/forte.rs @@ -30,7 +30,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, consts::NO_ERROR_CODE, errors, @@ -167,9 +170,10 @@ impl ConnectorCommon for Forte { } impl ConnectorValidation for Forte { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -727,3 +731,5 @@ impl IncomingWebhook for Forte { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Forte {} diff --git a/crates/hyperswitch_connectors/src/connectors/globepay.rs b/crates/hyperswitch_connectors/src/connectors/globepay.rs index c9e316707c1e..f11b7b5977f2 100644 --- a/crates/hyperswitch_connectors/src/connectors/globepay.rs +++ b/crates/hyperswitch_connectors/src/connectors/globepay.rs @@ -28,7 +28,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, consts, errors, events::connector_api_logs::ConnectorEvent, @@ -553,3 +556,5 @@ impl webhooks::IncomingWebhook for Globepay { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Globepay {} diff --git a/crates/hyperswitch_connectors/src/connectors/gocardless.rs b/crates/hyperswitch_connectors/src/connectors/gocardless.rs index 4e866d6f1330..0ecf8bac4a21 100644 --- a/crates/hyperswitch_connectors/src/connectors/gocardless.rs +++ b/crates/hyperswitch_connectors/src/connectors/gocardless.rs @@ -32,7 +32,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -333,9 +336,10 @@ impl ConnectorIntegration, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -868,3 +872,5 @@ impl IncomingWebhook for Gocardless { } } } + +impl ConnectorSpecifications for Gocardless {} diff --git a/crates/hyperswitch_connectors/src/connectors/helcim.rs b/crates/hyperswitch_connectors/src/connectors/helcim.rs index a9344beac135..5f0e49d84e15 100644 --- a/crates/hyperswitch_connectors/src/connectors/helcim.rs +++ b/crates/hyperswitch_connectors/src/connectors/helcim.rs @@ -29,7 +29,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, consts::NO_ERROR_CODE, errors, @@ -170,9 +173,10 @@ impl ConnectorCommon for Helcim { } impl ConnectorValidation for Helcim { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -810,3 +814,5 @@ impl IncomingWebhook for Helcim { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Helcim {} diff --git a/crates/hyperswitch_connectors/src/connectors/inespay.rs b/crates/hyperswitch_connectors/src/connectors/inespay.rs index 89bf50c60ca9..3d3ea346b78a 100644 --- a/crates/hyperswitch_connectors/src/connectors/inespay.rs +++ b/crates/hyperswitch_connectors/src/connectors/inespay.rs @@ -26,7 +26,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -561,3 +564,5 @@ impl webhooks::IncomingWebhook for Inespay { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Inespay {} diff --git a/crates/hyperswitch_connectors/src/connectors/jpmorgan.rs b/crates/hyperswitch_connectors/src/connectors/jpmorgan.rs index 9e5a24faab5f..2689e1a62d0f 100644 --- a/crates/hyperswitch_connectors/src/connectors/jpmorgan.rs +++ b/crates/hyperswitch_connectors/src/connectors/jpmorgan.rs @@ -27,7 +27,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, consts, errors, events::connector_api_logs::ConnectorEvent, @@ -165,9 +168,10 @@ impl ConnectorCommon for Jpmorgan { } impl ConnectorValidation for Jpmorgan { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -820,3 +824,5 @@ impl webhooks::IncomingWebhook for Jpmorgan { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Jpmorgan {} diff --git a/crates/hyperswitch_connectors/src/connectors/mollie.rs b/crates/hyperswitch_connectors/src/connectors/mollie.rs index 010ae90c56f1..8cdf4f03a703 100644 --- a/crates/hyperswitch_connectors/src/connectors/mollie.rs +++ b/crates/hyperswitch_connectors/src/connectors/mollie.rs @@ -30,7 +30,7 @@ use hyperswitch_domain_models::{ use hyperswitch_interfaces::{ api::{ self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorRedirectResponse, - ConnectorValidation, + ConnectorSpecifications, ConnectorValidation, }, configs::Connectors, consts, errors, @@ -634,3 +634,5 @@ impl ConnectorRedirectResponse for Mollie { } } } + +impl ConnectorSpecifications for Mollie {} diff --git a/crates/hyperswitch_connectors/src/connectors/multisafepay.rs b/crates/hyperswitch_connectors/src/connectors/multisafepay.rs index 562f84cbe8d4..3403f2213d26 100644 --- a/crates/hyperswitch_connectors/src/connectors/multisafepay.rs +++ b/crates/hyperswitch_connectors/src/connectors/multisafepay.rs @@ -29,7 +29,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -127,9 +130,10 @@ impl ConnectorCommon for Multisafepay { } impl ConnectorValidation for Multisafepay { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -565,3 +569,5 @@ impl IncomingWebhook for Multisafepay { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Multisafepay {} diff --git a/crates/hyperswitch_connectors/src/connectors/nexinets.rs b/crates/hyperswitch_connectors/src/connectors/nexinets.rs index 35899737c2aa..f93eef657245 100644 --- a/crates/hyperswitch_connectors/src/connectors/nexinets.rs +++ b/crates/hyperswitch_connectors/src/connectors/nexinets.rs @@ -28,7 +28,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -164,9 +167,10 @@ impl ConnectorCommon for Nexinets { } impl ConnectorValidation for Nexinets { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -738,3 +742,5 @@ impl ConnectorIntegration, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -994,3 +998,5 @@ impl webhooks::IncomingWebhook for Nexixpay { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Nexixpay {} diff --git a/crates/hyperswitch_connectors/src/connectors/nomupay.rs b/crates/hyperswitch_connectors/src/connectors/nomupay.rs index a08bbddc527a..9ed1e501cf58 100644 --- a/crates/hyperswitch_connectors/src/connectors/nomupay.rs +++ b/crates/hyperswitch_connectors/src/connectors/nomupay.rs @@ -26,7 +26,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -561,3 +564,5 @@ impl webhooks::IncomingWebhook for Nomupay { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Nomupay {} diff --git a/crates/hyperswitch_connectors/src/connectors/novalnet.rs b/crates/hyperswitch_connectors/src/connectors/novalnet.rs index 0f53158187b5..99da9c5caced 100644 --- a/crates/hyperswitch_connectors/src/connectors/novalnet.rs +++ b/crates/hyperswitch_connectors/src/connectors/novalnet.rs @@ -34,7 +34,7 @@ use hyperswitch_domain_models::{ use hyperswitch_interfaces::{ api::{ self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorRedirectResponse, - ConnectorValidation, + ConnectorSpecifications, ConnectorValidation, }, configs::Connectors, disputes, errors, @@ -158,9 +158,10 @@ impl ConnectorCommon for Novalnet { } impl ConnectorValidation for Novalnet { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -920,3 +921,5 @@ impl webhooks::IncomingWebhook for Novalnet { }) } } + +impl ConnectorSpecifications for Novalnet {} diff --git a/crates/hyperswitch_connectors/src/connectors/paybox.rs b/crates/hyperswitch_connectors/src/connectors/paybox.rs index 4f85f31c698e..89453364d875 100644 --- a/crates/hyperswitch_connectors/src/connectors/paybox.rs +++ b/crates/hyperswitch_connectors/src/connectors/paybox.rs @@ -33,7 +33,7 @@ use hyperswitch_domain_models::{ use hyperswitch_interfaces::{ api::{ self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorRedirectResponse, - ConnectorValidation, + ConnectorSpecifications, ConnectorValidation, }, configs::Connectors, errors, @@ -158,9 +158,10 @@ impl ConnectorCommon for Paybox { } impl ConnectorValidation for Paybox { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -701,3 +702,5 @@ impl ConnectorRedirectResponse for Paybox { } } } + +impl ConnectorSpecifications for Paybox {} diff --git a/crates/hyperswitch_connectors/src/connectors/payeezy.rs b/crates/hyperswitch_connectors/src/connectors/payeezy.rs index d2e21a927d38..5621b9d1230e 100644 --- a/crates/hyperswitch_connectors/src/connectors/payeezy.rs +++ b/crates/hyperswitch_connectors/src/connectors/payeezy.rs @@ -2,7 +2,7 @@ pub mod transformers; use api_models::webhooks::IncomingWebhookEvent; use base64::Engine; -use common_enums::{CaptureMethod, PaymentMethodType}; +use common_enums::{CaptureMethod, PaymentMethod, PaymentMethodType}; use common_utils::{ errors::CustomResult, ext_traits::ByteSliceExt, @@ -28,7 +28,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -151,9 +154,10 @@ impl ConnectorCommon for Payeezy { } impl ConnectorValidation for Payeezy { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -590,3 +594,5 @@ impl IncomingWebhook for Payeezy { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Payeezy {} diff --git a/crates/hyperswitch_connectors/src/connectors/payu.rs b/crates/hyperswitch_connectors/src/connectors/payu.rs index 6007b542e9cd..5ceb759df8cc 100644 --- a/crates/hyperswitch_connectors/src/connectors/payu.rs +++ b/crates/hyperswitch_connectors/src/connectors/payu.rs @@ -28,7 +28,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -139,9 +142,10 @@ impl ConnectorCommon for Payu { } impl ConnectorValidation for Payu { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -796,3 +800,5 @@ impl IncomingWebhook for Payu { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Payu {} diff --git a/crates/hyperswitch_connectors/src/connectors/placetopay.rs b/crates/hyperswitch_connectors/src/connectors/placetopay.rs index 5f8426e75bad..6e593c53e16d 100644 --- a/crates/hyperswitch_connectors/src/connectors/placetopay.rs +++ b/crates/hyperswitch_connectors/src/connectors/placetopay.rs @@ -28,7 +28,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -136,9 +139,10 @@ impl ConnectorCommon for Placetopay { } impl ConnectorValidation for Placetopay { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -677,3 +681,5 @@ impl IncomingWebhook for Placetopay { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Placetopay {} diff --git a/crates/hyperswitch_connectors/src/connectors/powertranz.rs b/crates/hyperswitch_connectors/src/connectors/powertranz.rs index 7da88269c703..80a35590520c 100644 --- a/crates/hyperswitch_connectors/src/connectors/powertranz.rs +++ b/crates/hyperswitch_connectors/src/connectors/powertranz.rs @@ -30,7 +30,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, consts, errors, events::connector_api_logs::ConnectorEvent, @@ -145,9 +148,10 @@ impl ConnectorCommon for Powertranz { } impl ConnectorValidation for Powertranz { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -613,3 +617,5 @@ impl webhooks::IncomingWebhook for Powertranz { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Powertranz {} diff --git a/crates/hyperswitch_connectors/src/connectors/prophetpay.rs b/crates/hyperswitch_connectors/src/connectors/prophetpay.rs index b6e16fc23579..245eaf73e751 100644 --- a/crates/hyperswitch_connectors/src/connectors/prophetpay.rs +++ b/crates/hyperswitch_connectors/src/connectors/prophetpay.rs @@ -31,7 +31,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, consts::{NO_ERROR_CODE, NO_ERROR_MESSAGE}, errors, @@ -710,3 +713,5 @@ impl IncomingWebhook for Prophetpay { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Prophetpay {} diff --git a/crates/hyperswitch_connectors/src/connectors/rapyd.rs b/crates/hyperswitch_connectors/src/connectors/rapyd.rs index f909de4dccdb..63659c6aadbe 100644 --- a/crates/hyperswitch_connectors/src/connectors/rapyd.rs +++ b/crates/hyperswitch_connectors/src/connectors/rapyd.rs @@ -31,7 +31,9 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, + }, configs::Connectors, disputes::DisputePayload, errors, @@ -146,9 +148,10 @@ impl ConnectorCommon for Rapyd { } impl ConnectorValidation for Rapyd { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -946,3 +949,5 @@ impl IncomingWebhook for Rapyd { }) } } + +impl ConnectorSpecifications for Rapyd {} diff --git a/crates/hyperswitch_connectors/src/connectors/razorpay.rs b/crates/hyperswitch_connectors/src/connectors/razorpay.rs index e05be5b107ff..f5f3aa85e897 100644 --- a/crates/hyperswitch_connectors/src/connectors/razorpay.rs +++ b/crates/hyperswitch_connectors/src/connectors/razorpay.rs @@ -27,7 +27,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, consts::NO_ERROR_CODE, errors, @@ -672,3 +675,5 @@ fn get_webhook_object_from_body( Ok(details.payload) } + +impl ConnectorSpecifications for Razorpay {} diff --git a/crates/hyperswitch_connectors/src/connectors/redsys.rs b/crates/hyperswitch_connectors/src/connectors/redsys.rs index 760ce148b40a..501182dec07a 100644 --- a/crates/hyperswitch_connectors/src/connectors/redsys.rs +++ b/crates/hyperswitch_connectors/src/connectors/redsys.rs @@ -26,7 +26,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -561,3 +564,5 @@ impl webhooks::IncomingWebhook for Redsys { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Redsys {} diff --git a/crates/hyperswitch_connectors/src/connectors/shift4.rs b/crates/hyperswitch_connectors/src/connectors/shift4.rs index 89f81cb3dd26..019f681ec5f5 100644 --- a/crates/hyperswitch_connectors/src/connectors/shift4.rs +++ b/crates/hyperswitch_connectors/src/connectors/shift4.rs @@ -31,7 +31,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, consts::NO_ERROR_CODE, errors, @@ -138,9 +141,10 @@ impl ConnectorCommon for Shift4 { } impl ConnectorValidation for Shift4 { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -851,3 +855,5 @@ impl IncomingWebhook for Shift4 { Ok(Box::new(details.data)) } } + +impl ConnectorSpecifications for Shift4 {} diff --git a/crates/hyperswitch_connectors/src/connectors/square.rs b/crates/hyperswitch_connectors/src/connectors/square.rs index d3bfd5201e1a..e07d85800ffd 100644 --- a/crates/hyperswitch_connectors/src/connectors/square.rs +++ b/crates/hyperswitch_connectors/src/connectors/square.rs @@ -34,7 +34,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, consts, errors, events::connector_api_logs::ConnectorEvent, @@ -156,9 +159,10 @@ impl ConnectorCommon for Square { } impl ConnectorValidation for Square { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -922,3 +926,5 @@ impl IncomingWebhook for Square { }) } } + +impl ConnectorSpecifications for Square {} diff --git a/crates/hyperswitch_connectors/src/connectors/stax.rs b/crates/hyperswitch_connectors/src/connectors/stax.rs index 63716a20e822..27be4d309dc5 100644 --- a/crates/hyperswitch_connectors/src/connectors/stax.rs +++ b/crates/hyperswitch_connectors/src/connectors/stax.rs @@ -33,7 +33,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, consts, errors, events::connector_api_logs::ConnectorEvent, @@ -137,9 +140,10 @@ impl ConnectorCommon for Stax { } impl ConnectorValidation for Stax { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -918,3 +922,5 @@ impl webhooks::IncomingWebhook for Stax { Ok(Box::new(reference_object)) } } + +impl ConnectorSpecifications for Stax {} diff --git a/crates/hyperswitch_connectors/src/connectors/taxjar.rs b/crates/hyperswitch_connectors/src/connectors/taxjar.rs index c2466799cdf9..30b92d9ceb84 100644 --- a/crates/hyperswitch_connectors/src/connectors/taxjar.rs +++ b/crates/hyperswitch_connectors/src/connectors/taxjar.rs @@ -28,7 +28,10 @@ use hyperswitch_domain_models::{ types::PaymentsTaxCalculationRouterData, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -292,3 +295,5 @@ impl webhooks::IncomingWebhook for Taxjar { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Taxjar {} diff --git a/crates/hyperswitch_connectors/src/connectors/thunes.rs b/crates/hyperswitch_connectors/src/connectors/thunes.rs index 972ba0d7dd30..b26c0e67fec3 100644 --- a/crates/hyperswitch_connectors/src/connectors/thunes.rs +++ b/crates/hyperswitch_connectors/src/connectors/thunes.rs @@ -26,7 +26,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -561,3 +564,5 @@ impl webhooks::IncomingWebhook for Thunes { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Thunes {} diff --git a/crates/hyperswitch_connectors/src/connectors/tsys.rs b/crates/hyperswitch_connectors/src/connectors/tsys.rs index 2575006b0d7c..39c8f9186993 100644 --- a/crates/hyperswitch_connectors/src/connectors/tsys.rs +++ b/crates/hyperswitch_connectors/src/connectors/tsys.rs @@ -27,7 +27,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -102,9 +105,10 @@ impl ConnectorCommon for Tsys { } impl ConnectorValidation for Tsys { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -653,3 +657,5 @@ impl webhooks::IncomingWebhook for Tsys { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Tsys {} diff --git a/crates/hyperswitch_connectors/src/connectors/unified_authentication_service.rs b/crates/hyperswitch_connectors/src/connectors/unified_authentication_service.rs index 00d2d31cd1a5..ece7130bb1dd 100644 --- a/crates/hyperswitch_connectors/src/connectors/unified_authentication_service.rs +++ b/crates/hyperswitch_connectors/src/connectors/unified_authentication_service.rs @@ -28,7 +28,10 @@ use hyperswitch_domain_models::{ types::{UasPostAuthenticationRouterData, UasPreAuthenticationRouterData}, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, consts::NO_ERROR_MESSAGE, errors, @@ -411,3 +414,5 @@ impl webhooks::IncomingWebhook for UnifiedAuthenticationService { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for UnifiedAuthenticationService {} diff --git a/crates/hyperswitch_connectors/src/connectors/volt.rs b/crates/hyperswitch_connectors/src/connectors/volt.rs index e90248970141..630218814436 100644 --- a/crates/hyperswitch_connectors/src/connectors/volt.rs +++ b/crates/hyperswitch_connectors/src/connectors/volt.rs @@ -28,7 +28,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -727,3 +730,5 @@ impl webhooks::IncomingWebhook for Volt { Ok(Box::new(details)) } } + +impl ConnectorSpecifications for Volt {} diff --git a/crates/hyperswitch_connectors/src/connectors/worldline.rs b/crates/hyperswitch_connectors/src/connectors/worldline.rs index b68a1e7a6526..1bfef7b752aa 100644 --- a/crates/hyperswitch_connectors/src/connectors/worldline.rs +++ b/crates/hyperswitch_connectors/src/connectors/worldline.rs @@ -31,8 +31,8 @@ use hyperswitch_domain_models::{ }; use hyperswitch_interfaces::{ api::{ - self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation, - PaymentCapture, PaymentSync, + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, PaymentCapture, PaymentSync, }, configs::Connectors, errors, @@ -170,9 +170,10 @@ impl ConnectorCommon for Worldline { } impl ConnectorValidation for Worldline { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -837,3 +838,5 @@ impl webhooks::IncomingWebhook for Worldline { Ok(response) } } + +impl ConnectorSpecifications for Worldline {} diff --git a/crates/hyperswitch_connectors/src/connectors/worldpay.rs b/crates/hyperswitch_connectors/src/connectors/worldpay.rs index d43739f19719..07e4c178f9b8 100644 --- a/crates/hyperswitch_connectors/src/connectors/worldpay.rs +++ b/crates/hyperswitch_connectors/src/connectors/worldpay.rs @@ -36,7 +36,7 @@ use hyperswitch_domain_models::{ use hyperswitch_interfaces::{ api::{ self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorRedirectResponse, - ConnectorValidation, + ConnectorSpecifications, ConnectorValidation, }, configs::Connectors, errors, @@ -161,9 +161,10 @@ impl ConnectorCommon for Worldpay { } impl ConnectorValidation for Worldpay { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -1215,3 +1216,5 @@ impl ConnectorRedirectResponse for Worldpay { } } } + +impl ConnectorSpecifications for Worldpay {} diff --git a/crates/hyperswitch_connectors/src/connectors/xendit.rs b/crates/hyperswitch_connectors/src/connectors/xendit.rs index c3f75a7673e1..571bd87e83c3 100644 --- a/crates/hyperswitch_connectors/src/connectors/xendit.rs +++ b/crates/hyperswitch_connectors/src/connectors/xendit.rs @@ -26,7 +26,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -561,3 +564,5 @@ impl webhooks::IncomingWebhook for Xendit { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Xendit {} diff --git a/crates/hyperswitch_connectors/src/connectors/zen.rs b/crates/hyperswitch_connectors/src/connectors/zen.rs index 5dc9e4d3176d..70703b316432 100644 --- a/crates/hyperswitch_connectors/src/connectors/zen.rs +++ b/crates/hyperswitch_connectors/src/connectors/zen.rs @@ -34,7 +34,7 @@ use hyperswitch_domain_models::{ use hyperswitch_interfaces::{ api::{ self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorRedirectResponse, - ConnectorValidation, + ConnectorSpecifications, ConnectorValidation, }, configs::Connectors, consts::{NO_ERROR_CODE, NO_ERROR_MESSAGE}, @@ -695,3 +695,5 @@ impl ConnectorRedirectResponse for Zen { } } } + +impl ConnectorSpecifications for Zen {} diff --git a/crates/hyperswitch_connectors/src/connectors/zsl.rs b/crates/hyperswitch_connectors/src/connectors/zsl.rs index 1eeeeafbb2e9..434cfbc3435a 100644 --- a/crates/hyperswitch_connectors/src/connectors/zsl.rs +++ b/crates/hyperswitch_connectors/src/connectors/zsl.rs @@ -23,7 +23,10 @@ use hyperswitch_domain_models::{ PaymentsCancelData, PaymentsCaptureData, PaymentsSessionData, PaymentsSyncData, RefundsData, SetupMandateRequestData, }, - router_response_types::{PaymentsResponseData, RefundsResponseData}, + router_response_types::{ + ConnectorInfo, PaymentMethodDetails, PaymentsResponseData, RefundsResponseData, + SupportedPaymentMethods, SupportedPaymentMethodsExt, + }, types::{ PaymentsAuthorizeRouterData, PaymentsCancelRouterData, PaymentsCaptureRouterData, PaymentsSessionRouterData, PaymentsSyncRouterData, RefundSyncRouterData, RefundsRouterData, @@ -31,20 +34,23 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, types::{self, Response}, webhooks::{IncomingWebhook, IncomingWebhookFlowError, IncomingWebhookRequestDetails}, }; +use lazy_static::lazy_static; use masking::{ExposeInterface, Secret}; use transformers::{self as zsl, get_status}; use crate::{ constants::headers, types::{RefreshTokenRouterData, ResponseRouterData}, - utils::construct_not_supported_error_report, }; #[derive(Debug, Clone)] @@ -122,23 +128,6 @@ impl ConnectorCommon for Zsl { } impl ConnectorValidation for Zsl { - fn validate_capture_method( - &self, - capture_method: Option, - _pmt: Option, - ) -> CustomResult<(), errors::ConnectorError> { - let capture_method = capture_method.unwrap_or_default(); - match capture_method { - enums::CaptureMethod::Automatic | enums::CaptureMethod::SequentialAutomatic => Ok(()), - enums::CaptureMethod::Manual - | enums::CaptureMethod::ManualMultiple - | enums::CaptureMethod::Scheduled => Err(construct_not_supported_error_report( - capture_method, - self.id(), - )), - } - } - fn is_webhook_source_verification_mandatory(&self) -> bool { true } @@ -456,3 +445,46 @@ fn get_webhook_object_from_body( .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; Ok(response) } + +lazy_static! { + static ref ZSL_SUPPORTED_PAYMENT_METHODS: SupportedPaymentMethods = { + let supported_capture_methods = vec![enums::CaptureMethod::Automatic]; + + let mut zsl_supported_payment_methods = SupportedPaymentMethods::new(); + zsl_supported_payment_methods.add( + enums::PaymentMethod::BankTransfer, + enums::PaymentMethodType::LocalBankTransfer, + PaymentMethodDetails{ + mandates: common_enums::FeatureStatus::NotSupported, + refunds: common_enums::FeatureStatus::NotSupported, + supported_capture_methods, + }, + ); + + zsl_supported_payment_methods + }; + + static ref ZSL_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo { + description: + "Zsl is a payment gateway operating in China, specializing in facilitating local bank transfers" + .to_string(), + connector_type: enums::PaymentConnectorCategory::PaymentGateway, + }; + + static ref ZSL_SUPPORTED_WEBHOOK_FLOWS: Vec = Vec::new(); + +} + +impl ConnectorSpecifications for Zsl { + fn get_connector_about(&self) -> Option<&'static ConnectorInfo> { + Some(&*ZSL_CONNECTOR_INFO) + } + + fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> { + Some(&*ZSL_SUPPORTED_PAYMENT_METHODS) + } + + fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> { + Some(&*ZSL_SUPPORTED_WEBHOOK_FLOWS) + } +} diff --git a/crates/hyperswitch_domain_models/src/router_response_types.rs b/crates/hyperswitch_domain_models/src/router_response_types.rs index 89eb7f9b3cdb..61453f36b84e 100644 --- a/crates/hyperswitch_domain_models/src/router_response_types.rs +++ b/crates/hyperswitch_domain_models/src/router_response_types.rs @@ -511,3 +511,56 @@ pub struct CompleteAuthorizeRedirectResponse { pub params: Option>, pub payload: Option, } + +/// Represents details of a payment method. +#[derive(Debug, Clone)] +pub struct PaymentMethodDetails { + /// Indicates whether mandates are supported by this payment method. + pub mandates: common_enums::FeatureStatus, + /// Indicates whether refund is supported by this payment method. + pub refunds: common_enums::FeatureStatus, + /// List of supported capture methods + pub supported_capture_methods: Vec, +} + +/// list of payment method types and metadata related to them +pub type PaymentMethodTypeMetadata = HashMap; + +/// list of payment methods, payment method types and metadata related to them +pub type SupportedPaymentMethods = HashMap; + +#[derive(Debug, Clone)] +pub struct ConnectorInfo { + /// Description of the connector. + pub description: String, + + /// Connector Type + pub connector_type: common_enums::PaymentConnectorCategory, +} + +pub trait SupportedPaymentMethodsExt { + fn add( + &mut self, + payment_method: common_enums::PaymentMethod, + payment_method_type: common_enums::PaymentMethodType, + payment_method_details: PaymentMethodDetails, + ); +} + +impl SupportedPaymentMethodsExt for SupportedPaymentMethods { + fn add( + &mut self, + payment_method: common_enums::PaymentMethod, + payment_method_type: common_enums::PaymentMethodType, + payment_method_details: PaymentMethodDetails, + ) { + if let Some(payment_method_data) = self.get_mut(&payment_method) { + payment_method_data.insert(payment_method_type, payment_method_details); + } else { + let mut payment_method_type_metadata = PaymentMethodTypeMetadata::new(); + payment_method_type_metadata.insert(payment_method_type, payment_method_details); + + self.insert(payment_method, payment_method_type_metadata); + } + } +} diff --git a/crates/hyperswitch_interfaces/src/api.rs b/crates/hyperswitch_interfaces/src/api.rs index bb6b2a4e4f5b..ca2d806762ad 100644 --- a/crates/hyperswitch_interfaces/src/api.rs +++ b/crates/hyperswitch_interfaces/src/api.rs @@ -16,7 +16,11 @@ pub mod payouts; pub mod payouts_v2; pub mod refunds; pub mod refunds_v2; -use common_enums::enums::{CallConnectorAction, CaptureMethod, PaymentAction, PaymentMethodType}; + +use common_enums::{ + enums::{CallConnectorAction, CaptureMethod, EventClass, PaymentAction, PaymentMethodType}, + PaymentMethod, +}; use common_utils::{ errors::CustomResult, request::{Method, Request, RequestContent}, @@ -40,7 +44,10 @@ use hyperswitch_domain_models::{ }, AccessTokenRequestData, MandateRevokeRequestData, VerifyWebhookSourceRequestData, }, - router_response_types::{MandateRevokeResponseData, VerifyWebhookSourceResponseData}, + router_response_types::{ + ConnectorInfo, MandateRevokeResponseData, PaymentMethodDetails, SupportedPaymentMethods, + VerifyWebhookSourceResponseData, + }, }; use masking::Maskable; use serde_json::json; @@ -280,6 +287,24 @@ pub trait ConnectorCommon { } } +/// The trait that provides specifications about the connector +pub trait ConnectorSpecifications { + /// Details related to payment method supported by the connector + fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> { + None + } + + /// Supported webhooks flows + fn get_supported_webhook_flows(&self) -> Option<&'static [EventClass]> { + None + } + + /// About the connector + fn get_connector_about(&self) -> Option<&'static ConnectorInfo> { + None + } +} + /// Extended trait for connector common to allow functions with generic type pub trait ConnectorCommonExt: ConnectorCommon + ConnectorIntegration @@ -399,23 +424,46 @@ pub trait UasPostAuthenticationV2: } /// trait ConnectorValidation -pub trait ConnectorValidation: ConnectorCommon { - /// fn validate_capture_method - fn validate_capture_method( +pub trait ConnectorValidation: ConnectorCommon + ConnectorSpecifications { + /// Validate, the payment request against the connector supported features + fn validate_connector_against_payment_request( &self, capture_method: Option, - _pmt: Option, + payment_method: PaymentMethod, + pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); - match capture_method { - CaptureMethod::Automatic | CaptureMethod::SequentialAutomatic => Ok(()), - CaptureMethod::Manual | CaptureMethod::ManualMultiple | CaptureMethod::Scheduled => { - Err(errors::ConnectorError::NotSupported { - message: capture_method.to_string(), - connector: self.id(), - } - .into()) + let is_default_capture_method = + [CaptureMethod::Automatic, CaptureMethod::SequentialAutomatic] + .contains(&capture_method); + let is_feature_supported = match self.get_supported_payment_methods() { + Some(supported_payment_methods) => { + let connector_payment_method_type_info = get_connector_payment_method_type_info( + supported_payment_methods, + payment_method, + pmt, + self.id(), + )?; + + connector_payment_method_type_info + .map(|payment_method_type_info| { + payment_method_type_info + .supported_capture_methods + .contains(&capture_method) + }) + .unwrap_or_else(|| is_default_capture_method) } + None => is_default_capture_method, + }; + + if is_feature_supported { + Ok(()) + } else { + Err(errors::ConnectorError::NotSupported { + message: capture_method.to_string(), + connector: self.id(), + } + .into()) } } @@ -476,3 +524,30 @@ pub trait ConnectorRedirectResponse { /// Empty trait for when payouts feature is disabled #[cfg(not(feature = "payouts"))] pub trait Payouts {} + +fn get_connector_payment_method_type_info( + supported_payment_method: &SupportedPaymentMethods, + payment_method: PaymentMethod, + payment_method_type: Option, + connector: &'static str, +) -> CustomResult, errors::ConnectorError> { + let payment_method_details = + supported_payment_method + .get(&payment_method) + .ok_or_else(|| errors::ConnectorError::NotSupported { + message: payment_method.to_string(), + connector, + })?; + + payment_method_type + .map(|pmt| { + payment_method_details.get(&pmt).cloned().ok_or_else(|| { + errors::ConnectorError::NotSupported { + message: format!("{} {}", payment_method, pmt), + connector, + } + .into() + }) + }) + .transpose() +} diff --git a/crates/hyperswitch_interfaces/src/api/payments.rs b/crates/hyperswitch_interfaces/src/api/payments.rs index b3ac7e0fa906..ab327d0629a6 100644 --- a/crates/hyperswitch_interfaces/src/api/payments.rs +++ b/crates/hyperswitch_interfaces/src/api/payments.rs @@ -23,6 +23,7 @@ use crate::api; /// trait Payment pub trait Payment: api::ConnectorCommon + + api::ConnectorSpecifications + api::ConnectorValidation + PaymentAuthorize + PaymentAuthorizeSessionToken diff --git a/crates/hyperswitch_interfaces/src/api/payments_v2.rs b/crates/hyperswitch_interfaces/src/api/payments_v2.rs index e2ddf49e0cd0..366024f7da6e 100644 --- a/crates/hyperswitch_interfaces/src/api/payments_v2.rs +++ b/crates/hyperswitch_interfaces/src/api/payments_v2.rs @@ -19,7 +19,9 @@ use hyperswitch_domain_models::{ router_response_types::{PaymentsResponseData, TaxCalculationResponseData}, }; -use crate::api::{ConnectorCommon, ConnectorIntegrationV2, ConnectorValidation}; +use crate::api::{ + ConnectorCommon, ConnectorIntegrationV2, ConnectorSpecifications, ConnectorValidation, +}; /// trait PaymentAuthorizeV2 pub trait PaymentAuthorizeV2: @@ -182,6 +184,7 @@ pub trait PaymentsPostProcessingV2: /// trait PaymentV2 pub trait PaymentV2: ConnectorCommon + + ConnectorSpecifications + ConnectorValidation + PaymentAuthorizeV2 + PaymentAuthorizeSessionTokenV2 diff --git a/crates/hyperswitch_interfaces/src/types.rs b/crates/hyperswitch_interfaces/src/types.rs index dd344edf9da2..eb31fd221d64 100644 --- a/crates/hyperswitch_interfaces/src/types.rs +++ b/crates/hyperswitch_interfaces/src/types.rs @@ -1,4 +1,5 @@ //! Types interface + use hyperswitch_domain_models::{ router_data::AccessToken, router_flow_types::{ diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rs index daf43fded07e..2f068b5609b8 100644 --- a/crates/openapi/src/openapi.rs +++ b/crates/openapi/src/openapi.rs @@ -306,6 +306,8 @@ Never share your secret api keys. Keep them guarded and secure. api_models::enums::PaymentLinkDetailsLayout, api_models::enums::PaymentMethodStatus, api_models::enums::UIWidgetFormLayout, + api_models::enums::PaymentConnectorCategory, + api_models::enums::FeatureStatus, api_models::admin::MerchantConnectorCreate, api_models::admin::AdditionalMerchantData, api_models::admin::ConnectorWalletDetails, @@ -688,7 +690,11 @@ Never share your secret api keys. Keep them guarded and secure. api_models::payments::DisplayAmountOnSdk, api_models::payments::PaymentsPostSessionTokensRequest, api_models::payments::PaymentsPostSessionTokensResponse, - api_models::payments::CtpServiceDetails + api_models::payments::CtpServiceDetails, + api_models::feature_matrix::FeatureMatrixListResponse, + api_models::feature_matrix::FeatureMatrixRequest, + api_models::feature_matrix::ConnectorFeatureMatrixResponse, + api_models::feature_matrix::SupportedPaymentMethod, )), modifiers(&SecurityAddon) )] diff --git a/crates/openapi/src/openapi_v2.rs b/crates/openapi/src/openapi_v2.rs index 6ea55ba6b79b..12b0fd003559 100644 --- a/crates/openapi/src/openapi_v2.rs +++ b/crates/openapi/src/openapi_v2.rs @@ -261,6 +261,8 @@ Never share your secret api keys. Keep them guarded and secure. api_models::enums::SizeVariants, api_models::enums::PaymentLinkDetailsLayout, api_models::enums::PaymentMethodStatus, + api_models::enums::PaymentConnectorCategory, + api_models::enums::FeatureStatus, api_models::enums::OrderFulfillmentTimeOrigin, api_models::enums::UIWidgetFormLayout, api_models::admin::MerchantConnectorCreate, @@ -639,6 +641,10 @@ Never share your secret api keys. Keep them guarded and secure. api_models::payments::DisplayAmountOnSdk, api_models::payments::ErrorDetails, api_models::payments::CtpServiceDetails, + api_models::feature_matrix::FeatureMatrixListResponse, + api_models::feature_matrix::FeatureMatrixRequest, + api_models::feature_matrix::ConnectorFeatureMatrixResponse, + api_models::feature_matrix::SupportedPaymentMethod, common_utils::types::BrowserInformation, api_models::payments::PaymentAmountDetailsResponse, routes::payments::ForceSync, diff --git a/crates/router/src/connector/aci.rs b/crates/router/src/connector/aci.rs index 6f800194a476..c59c0ce07556 100644 --- a/crates/router/src/connector/aci.rs +++ b/crates/router/src/connector/aci.rs @@ -6,6 +6,7 @@ use common_utils::{ types::{AmountConvertor, StringMajorUnit, StringMajorUnitForConnector}, }; use error_stack::{report, ResultExt}; +use hyperswitch_interfaces::api::ConnectorSpecifications; use masking::PeekInterface; use transformers as aci; @@ -616,3 +617,5 @@ impl api::IncomingWebhook for Aci { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Aci {} diff --git a/crates/router/src/connector/adyen.rs b/crates/router/src/connector/adyen.rs index 112842efc6d0..b9ab7ea87e0f 100644 --- a/crates/router/src/connector/adyen.rs +++ b/crates/router/src/connector/adyen.rs @@ -27,7 +27,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorValidation, + ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -98,9 +98,10 @@ impl ConnectorCommon for Adyen { } impl ConnectorValidation for Adyen { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -2291,3 +2292,5 @@ impl api::FileUpload for Adyen { Ok(()) } } + +impl ConnectorSpecifications for Adyen {} diff --git a/crates/router/src/connector/adyenplatform.rs b/crates/router/src/connector/adyenplatform.rs index 2ee80699a5a0..f95e9cd4d649 100644 --- a/crates/router/src/connector/adyenplatform.rs +++ b/crates/router/src/connector/adyenplatform.rs @@ -29,7 +29,7 @@ use crate::{ configs::settings, core::errors::{self, CustomResult}, headers, - services::{self, request::Mask, ConnectorValidation}, + services::{self, request::Mask, ConnectorSpecifications, ConnectorValidation}, types::{ self, api::{self, ConnectorCommon}, @@ -461,3 +461,5 @@ impl api::IncomingWebhook for Adyenplatform { } } } + +impl ConnectorSpecifications for Adyenplatform {} diff --git a/crates/router/src/connector/authorizedotnet.rs b/crates/router/src/connector/authorizedotnet.rs index fecfa315ab14..afc8f063e4eb 100644 --- a/crates/router/src/connector/authorizedotnet.rs +++ b/crates/router/src/connector/authorizedotnet.rs @@ -19,7 +19,7 @@ use crate::{ }, events::connector_api_logs::ConnectorEvent, headers, - services::{self, request, ConnectorIntegration, ConnectorValidation}, + services::{self, request, ConnectorIntegration, ConnectorSpecifications, ConnectorValidation}, types::{ self, api::{self, ConnectorCommon, ConnectorCommonExt, PaymentsCompleteAuthorize}, @@ -66,9 +66,10 @@ impl ConnectorCommon for Authorizedotnet { } impl ConnectorValidation for Authorizedotnet { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -1057,3 +1058,5 @@ impl services::ConnectorRedirectResponse for Authorizedotnet { } } } + +impl ConnectorSpecifications for Authorizedotnet {} diff --git a/crates/router/src/connector/bankofamerica.rs b/crates/router/src/connector/bankofamerica.rs index fc6594442c94..95ceee555895 100644 --- a/crates/router/src/connector/bankofamerica.rs +++ b/crates/router/src/connector/bankofamerica.rs @@ -25,7 +25,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -278,9 +278,10 @@ impl ConnectorCommon for Bankofamerica { } impl ConnectorValidation for Bankofamerica { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -1065,3 +1066,5 @@ impl api::IncomingWebhook for Bankofamerica { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Bankofamerica {} diff --git a/crates/router/src/connector/braintree.rs b/crates/router/src/connector/braintree.rs index a462010eebf1..7a88180c64d2 100644 --- a/crates/router/src/connector/braintree.rs +++ b/crates/router/src/connector/braintree.rs @@ -30,7 +30,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -173,9 +173,10 @@ impl ConnectorCommon for Braintree { } impl ConnectorValidation for Braintree { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -1209,3 +1210,5 @@ impl self.build_error_response(res, event_builder) } } + +impl ConnectorSpecifications for Braintree {} diff --git a/crates/router/src/connector/checkout.rs b/crates/router/src/connector/checkout.rs index f73d5cb14eb9..96b30dc80f93 100644 --- a/crates/router/src/connector/checkout.rs +++ b/crates/router/src/connector/checkout.rs @@ -27,7 +27,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -154,9 +154,10 @@ impl ConnectorCommon for Checkout { } impl ConnectorValidation for Checkout { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -1489,3 +1490,5 @@ impl ConnectorErrorTypeMapping for Checkout { } } } + +impl ConnectorSpecifications for Checkout {} diff --git a/crates/router/src/connector/cybersource.rs b/crates/router/src/connector/cybersource.rs index f676d6ca25b1..078f66335f5c 100644 --- a/crates/router/src/connector/cybersource.rs +++ b/crates/router/src/connector/cybersource.rs @@ -27,7 +27,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -246,9 +246,10 @@ impl ConnectorCommon for Cybersource { } impl ConnectorValidation for Cybersource { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -1718,3 +1719,5 @@ impl api::IncomingWebhook for Cybersource { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Cybersource {} diff --git a/crates/router/src/connector/dummyconnector.rs b/crates/router/src/connector/dummyconnector.rs index b87b495a9379..15a2ff690366 100644 --- a/crates/router/src/connector/dummyconnector.rs +++ b/crates/router/src/connector/dummyconnector.rs @@ -16,7 +16,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -124,9 +124,10 @@ impl ConnectorCommon for DummyConnector { } impl ConnectorValidation for DummyConnector { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -613,3 +614,5 @@ impl api::IncomingWebhook for DummyConnector { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for DummyConnector {} diff --git a/crates/router/src/connector/ebanx.rs b/crates/router/src/connector/ebanx.rs index e5e7f2e259aa..01db54c1f67e 100644 --- a/crates/router/src/connector/ebanx.rs +++ b/crates/router/src/connector/ebanx.rs @@ -15,7 +15,7 @@ use crate::{ configs::settings, core::errors::{self, CustomResult}, events::connector_api_logs::ConnectorEvent, - services::{ConnectorIntegration, ConnectorValidation}, + services::{ConnectorIntegration, ConnectorSpecifications, ConnectorValidation}, types::{ self, api::{self, ConnectorCommon, ConnectorCommonExt}, @@ -466,3 +466,5 @@ impl api::IncomingWebhook for Ebanx { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Ebanx {} diff --git a/crates/router/src/connector/globalpay.rs b/crates/router/src/connector/globalpay.rs index 2c8bfb548ec7..2e971f8034a1 100644 --- a/crates/router/src/connector/globalpay.rs +++ b/crates/router/src/connector/globalpay.rs @@ -28,7 +28,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -127,9 +127,10 @@ impl ConnectorCommon for Globalpay { } impl ConnectorValidation for Globalpay { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -1043,3 +1044,5 @@ impl services::ConnectorRedirectResponse for Globalpay { } } } + +impl ConnectorSpecifications for Globalpay {} diff --git a/crates/router/src/connector/gpayments.rs b/crates/router/src/connector/gpayments.rs index 9f88e215138f..1febbfa7885d 100644 --- a/crates/router/src/connector/gpayments.rs +++ b/crates/router/src/connector/gpayments.rs @@ -14,7 +14,7 @@ use crate::{ core::errors::{self, CustomResult}, events::connector_api_logs::ConnectorEvent, headers, services, - services::{request, ConnectorIntegration, ConnectorValidation}, + services::{request, ConnectorIntegration, ConnectorSpecifications, ConnectorValidation}, types::{ self, api::{self, ConnectorCommon, ConnectorCommonExt}, @@ -613,3 +613,5 @@ impl self.build_error_response(res, event_builder) } } + +impl ConnectorSpecifications for Gpayments {} diff --git a/crates/router/src/connector/iatapay.rs b/crates/router/src/connector/iatapay.rs index cf4a1d6e16bc..e694968ee04b 100644 --- a/crates/router/src/connector/iatapay.rs +++ b/crates/router/src/connector/iatapay.rs @@ -22,7 +22,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -757,3 +757,5 @@ impl api::IncomingWebhook for Iatapay { } } } + +impl ConnectorSpecifications for Iatapay {} diff --git a/crates/router/src/connector/itaubank.rs b/crates/router/src/connector/itaubank.rs index 0c99a95e0e51..2087c72ba859 100644 --- a/crates/router/src/connector/itaubank.rs +++ b/crates/router/src/connector/itaubank.rs @@ -14,7 +14,7 @@ use crate::{ core::errors::{self, CustomResult}, events::connector_api_logs::ConnectorEvent, headers, - services::{self, request, ConnectorIntegration, ConnectorValidation}, + services::{self, request, ConnectorIntegration, ConnectorSpecifications, ConnectorValidation}, types::{ self, api::{self, ConnectorCommon, ConnectorCommonExt}, @@ -785,3 +785,5 @@ impl api::IncomingWebhook for Itaubank { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Itaubank {} diff --git a/crates/router/src/connector/klarna.rs b/crates/router/src/connector/klarna.rs index 77e2a027d835..4e54311a89a7 100644 --- a/crates/router/src/connector/klarna.rs +++ b/crates/router/src/connector/klarna.rs @@ -21,7 +21,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorValidation, + ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -110,9 +110,10 @@ impl ConnectorCommon for Klarna { } impl ConnectorValidation for Klarna { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -1158,3 +1159,5 @@ impl api::IncomingWebhook for Klarna { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Klarna {} diff --git a/crates/router/src/connector/mifinity.rs b/crates/router/src/connector/mifinity.rs index d8ac2d101297..dcf95a576e3f 100644 --- a/crates/router/src/connector/mifinity.rs +++ b/crates/router/src/connector/mifinity.rs @@ -16,7 +16,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -501,3 +501,5 @@ impl api::IncomingWebhook for Mifinity { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Mifinity {} diff --git a/crates/router/src/connector/netcetera.rs b/crates/router/src/connector/netcetera.rs index edf56365f4ef..459ac93e0680 100644 --- a/crates/router/src/connector/netcetera.rs +++ b/crates/router/src/connector/netcetera.rs @@ -13,7 +13,7 @@ use crate::{ core::errors::{self, CustomResult}, events::connector_api_logs::ConnectorEvent, headers, - services::{self, request, ConnectorIntegration, ConnectorValidation}, + services::{self, request, ConnectorIntegration, ConnectorSpecifications, ConnectorValidation}, types::{ self, api::{self, ConnectorCommon, ConnectorCommonExt}, @@ -462,3 +462,5 @@ impl > for Netcetera { } + +impl ConnectorSpecifications for Netcetera {} diff --git a/crates/router/src/connector/nmi.rs b/crates/router/src/connector/nmi.rs index 42a04e7e7e37..73aaec55e574 100644 --- a/crates/router/src/connector/nmi.rs +++ b/crates/router/src/connector/nmi.rs @@ -19,7 +19,7 @@ use crate::{ payments, }, events::connector_api_logs::ConnectorEvent, - services::{self, request, ConnectorIntegration, ConnectorValidation}, + services::{self, request, ConnectorIntegration, ConnectorSpecifications, ConnectorValidation}, types::{ self, api::{self, ConnectorCommon, ConnectorCommonExt}, @@ -108,9 +108,10 @@ impl ConnectorCommon for Nmi { } impl ConnectorValidation for Nmi { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -1033,3 +1034,5 @@ impl services::ConnectorRedirectResponse for Nmi { } } } + +impl ConnectorSpecifications for Nmi {} diff --git a/crates/router/src/connector/noon.rs b/crates/router/src/connector/noon.rs index 76526ca2eb5f..c8780af3ce50 100644 --- a/crates/router/src/connector/noon.rs +++ b/crates/router/src/connector/noon.rs @@ -27,7 +27,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -176,9 +176,10 @@ impl ConnectorCommon for Noon { } impl ConnectorValidation for Noon { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -945,3 +946,5 @@ impl api::IncomingWebhook for Noon { Ok(Box::new(noon::NoonPaymentsResponse::from(resource))) } } + +impl ConnectorSpecifications for Noon {} diff --git a/crates/router/src/connector/nuvei.rs b/crates/router/src/connector/nuvei.rs index 7c50f87fc454..c72bee24fa28 100644 --- a/crates/router/src/connector/nuvei.rs +++ b/crates/router/src/connector/nuvei.rs @@ -21,7 +21,7 @@ use crate::{ }, events::connector_api_logs::ConnectorEvent, headers, - services::{self, request, ConnectorIntegration, ConnectorValidation}, + services::{self, request, ConnectorIntegration, ConnectorSpecifications, ConnectorValidation}, types::{ self, api::{self, ConnectorCommon, ConnectorCommonExt}, @@ -73,9 +73,10 @@ impl ConnectorCommon for Nuvei { } impl ConnectorValidation for Nuvei { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -980,3 +981,5 @@ impl services::ConnectorRedirectResponse for Nuvei { } } } + +impl ConnectorSpecifications for Nuvei {} diff --git a/crates/router/src/connector/opayo.rs b/crates/router/src/connector/opayo.rs index 4a093c019a54..a9fc439e54ce 100644 --- a/crates/router/src/connector/opayo.rs +++ b/crates/router/src/connector/opayo.rs @@ -18,7 +18,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -131,9 +131,10 @@ impl ConnectorCommon for Opayo { } impl ConnectorValidation for Opayo { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -601,3 +602,5 @@ impl api::IncomingWebhook for Opayo { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Opayo {} diff --git a/crates/router/src/connector/opennode.rs b/crates/router/src/connector/opennode.rs index 0a1de1fdde2a..1c11da057122 100644 --- a/crates/router/src/connector/opennode.rs +++ b/crates/router/src/connector/opennode.rs @@ -16,7 +16,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -449,3 +449,5 @@ impl api::IncomingWebhook for Opennode { Ok(Box::new(notif.status)) } } + +impl ConnectorSpecifications for Opennode {} diff --git a/crates/router/src/connector/payme.rs b/crates/router/src/connector/payme.rs index c00ab061a32c..10a0fe675621 100644 --- a/crates/router/src/connector/payme.rs +++ b/crates/router/src/connector/payme.rs @@ -23,7 +23,7 @@ use crate::{ }, events::connector_api_logs::ConnectorEvent, headers, - services::{self, request, ConnectorIntegration, ConnectorValidation}, + services::{self, request, ConnectorIntegration, ConnectorSpecifications, ConnectorValidation}, types::{ self, api::{self, ConnectorCommon, ConnectorCommonExt}, @@ -138,9 +138,10 @@ impl ConnectorCommon for Payme { } impl ConnectorValidation for Payme { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -1294,3 +1295,5 @@ impl api::IncomingWebhook for Payme { }) } } + +impl ConnectorSpecifications for Payme {} diff --git a/crates/router/src/connector/payone.rs b/crates/router/src/connector/payone.rs index 6bc04ed79c5f..58b179e57992 100644 --- a/crates/router/src/connector/payone.rs +++ b/crates/router/src/connector/payone.rs @@ -30,7 +30,7 @@ use crate::{ headers, services::{ request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -429,3 +429,5 @@ impl ConnectorErrorTypeMapping for Payone { } } } + +impl ConnectorSpecifications for Payone {} diff --git a/crates/router/src/connector/paypal.rs b/crates/router/src/connector/paypal.rs index 375853e27a02..fb635708c23e 100644 --- a/crates/router/src/connector/paypal.rs +++ b/crates/router/src/connector/paypal.rs @@ -36,7 +36,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, PaymentAction, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, PaymentAction, }, types::{ self, @@ -320,9 +320,10 @@ impl ConnectorCommon for Paypal { } impl ConnectorValidation for Paypal { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -2206,3 +2207,5 @@ impl ConnectorErrorTypeMapping for Paypal { } } } + +impl ConnectorSpecifications for Paypal {} diff --git a/crates/router/src/connector/plaid.rs b/crates/router/src/connector/plaid.rs index 5bfd42994262..f24d7bd8d6d5 100644 --- a/crates/router/src/connector/plaid.rs +++ b/crates/router/src/connector/plaid.rs @@ -13,7 +13,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -456,3 +456,5 @@ impl api::IncomingWebhook for Plaid { Err((errors::ConnectorError::WebhooksNotImplemented).into()) } } + +impl ConnectorSpecifications for Plaid {} diff --git a/crates/router/src/connector/riskified.rs b/crates/router/src/connector/riskified.rs index 7d9feec717a5..1268e041603d 100644 --- a/crates/router/src/connector/riskified.rs +++ b/crates/router/src/connector/riskified.rs @@ -22,7 +22,7 @@ use super::utils::{self as connector_utils, FrmTransactionRouterDataRequest}; use crate::{ configs::settings, core::errors::{self, CustomResult}, - services::{self, ConnectorIntegration, ConnectorValidation}, + services::{self, ConnectorIntegration, ConnectorSpecifications, ConnectorValidation}, types::{ self, api::{self, ConnectorCommon, ConnectorCommonExt}, @@ -677,3 +677,5 @@ impl api::IncomingWebhook for Riskified { Ok(Box::new(resource)) } } + +impl ConnectorSpecifications for Riskified {} diff --git a/crates/router/src/connector/signifyd.rs b/crates/router/src/connector/signifyd.rs index 4ee36d8966ba..21452819c39a 100644 --- a/crates/router/src/connector/signifyd.rs +++ b/crates/router/src/connector/signifyd.rs @@ -20,7 +20,7 @@ use crate::{ configs::settings, core::errors::{self, CustomResult}, headers, - services::{self, request, ConnectorIntegration, ConnectorValidation}, + services::{self, request, ConnectorIntegration, ConnectorSpecifications, ConnectorValidation}, types::{ self, api::{self, ConnectorCommon, ConnectorCommonExt}, @@ -754,3 +754,5 @@ impl api::IncomingWebhook for Signifyd { Ok(Box::new(resource)) } } + +impl ConnectorSpecifications for Signifyd {} diff --git a/crates/router/src/connector/stripe.rs b/crates/router/src/connector/stripe.rs index 31cc0a713af0..6d377171121c 100644 --- a/crates/router/src/connector/stripe.rs +++ b/crates/router/src/connector/stripe.rs @@ -30,7 +30,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorValidation, + ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -134,9 +134,10 @@ impl ConnectorCommon for Stripe { } impl ConnectorValidation for Stripe { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -2932,3 +2933,5 @@ impl self.build_error_response(res, event_builder) } } + +impl ConnectorSpecifications for Stripe {} diff --git a/crates/router/src/connector/threedsecureio.rs b/crates/router/src/connector/threedsecureio.rs index a051cf471f19..aec8f7804512 100644 --- a/crates/router/src/connector/threedsecureio.rs +++ b/crates/router/src/connector/threedsecureio.rs @@ -15,7 +15,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -530,3 +530,5 @@ impl > for Threedsecureio { } + +impl ConnectorSpecifications for Threedsecureio {} diff --git a/crates/router/src/connector/trustpay.rs b/crates/router/src/connector/trustpay.rs index 6562ba319760..10c71a5d3754 100644 --- a/crates/router/src/connector/trustpay.rs +++ b/crates/router/src/connector/trustpay.rs @@ -29,7 +29,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -1077,3 +1077,5 @@ impl ConnectorErrorTypeMapping for Trustpay { } } } + +impl ConnectorSpecifications for Trustpay {} diff --git a/crates/router/src/connector/wellsfargo.rs b/crates/router/src/connector/wellsfargo.rs index df0de2c0c5ed..b47b3662253e 100644 --- a/crates/router/src/connector/wellsfargo.rs +++ b/crates/router/src/connector/wellsfargo.rs @@ -27,7 +27,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -245,9 +245,10 @@ impl ConnectorCommon for Wellsfargo { } impl ConnectorValidation for Wellsfargo { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -1316,3 +1317,5 @@ impl api::IncomingWebhook for Wellsfargo { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Wellsfargo {} diff --git a/crates/router/src/connector/wellsfargopayout.rs b/crates/router/src/connector/wellsfargopayout.rs index fe8f5dda25fe..33111ee7be05 100644 --- a/crates/router/src/connector/wellsfargopayout.rs +++ b/crates/router/src/connector/wellsfargopayout.rs @@ -14,7 +14,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -581,3 +581,5 @@ impl api::IncomingWebhook for Wellsfargopayout { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Wellsfargopayout {} diff --git a/crates/router/src/connector/wise.rs b/crates/router/src/connector/wise.rs index 9f41651b2f92..e4493f5016f8 100644 --- a/crates/router/src/connector/wise.rs +++ b/crates/router/src/connector/wise.rs @@ -19,7 +19,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorValidation, + ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -748,3 +748,5 @@ impl api::IncomingWebhook for Wise { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Wise {} diff --git a/crates/router/src/core/payments/flows/authorize_flow.rs b/crates/router/src/core/payments/flows/authorize_flow.rs index 75eda0ed9138..7efa9a5e1809 100644 --- a/crates/router/src/core/payments/flows/authorize_flow.rs +++ b/crates/router/src/core/payments/flows/authorize_flow.rs @@ -337,8 +337,9 @@ impl Feature for types::PaymentsAu payments::CallConnectorAction::Trigger => { connector .connector - .validate_capture_method( + .validate_connector_against_payment_request( self.request.capture_method, + self.payment_method, self.request.payment_method_type, ) .to_payment_failed_response()?; diff --git a/crates/router/src/lib.rs b/crates/router/src/lib.rs index 9ed724c36ef0..4fe9318f64bb 100644 --- a/crates/router/src/lib.rs +++ b/crates/router/src/lib.rs @@ -192,7 +192,8 @@ pub fn mk_app( .service(routes::ConnectorOnboarding::server(state.clone())) .service(routes::Verify::server(state.clone())) .service(routes::Analytics::server(state.clone())) - .service(routes::WebhookEvents::server(state.clone())); + .service(routes::WebhookEvents::server(state.clone())) + .service(routes::FeatureMatrix::server(state.clone())); } } diff --git a/crates/router/src/routes.rs b/crates/router/src/routes.rs index 53e5d5aac71d..462861d331f4 100644 --- a/crates/router/src/routes.rs +++ b/crates/router/src/routes.rs @@ -17,6 +17,7 @@ pub mod disputes; #[cfg(feature = "dummy_connector")] pub mod dummy_connector; pub mod ephemeral_key; +pub mod feature_matrix; pub mod files; #[cfg(feature = "frm")] pub mod fraud_check; @@ -66,9 +67,9 @@ pub use self::app::DummyConnector; pub use self::app::Recon; pub use self::app::{ ApiKeys, AppState, ApplePayCertificatesMigration, Cache, Cards, Configs, ConnectorOnboarding, - Customers, Disputes, EphemeralKey, Files, Forex, Gsm, Health, Mandates, MerchantAccount, - MerchantConnectorAccount, PaymentLink, PaymentMethods, Payments, Poll, Profile, ProfileNew, - Refunds, Relay, SessionState, User, Webhooks, + Customers, Disputes, EphemeralKey, FeatureMatrix, Files, Forex, Gsm, Health, Mandates, + MerchantAccount, MerchantConnectorAccount, PaymentLink, PaymentMethods, Payments, Poll, + Profile, ProfileNew, Refunds, Relay, SessionState, User, Webhooks, }; #[cfg(feature = "olap")] pub use self::app::{Blocklist, Organization, Routing, Verify, WebhookEvents}; diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rs index 28a994fdf3fb..f9dbec774528 100644 --- a/crates/router/src/routes/app.rs +++ b/crates/router/src/routes/app.rs @@ -70,6 +70,8 @@ use crate::analytics::AnalyticsProvider; use crate::errors::RouterResult; #[cfg(feature = "v1")] use crate::routes::cards_info::card_iin_info; +#[cfg(all(feature = "olap", feature = "v1"))] +use crate::routes::feature_matrix; #[cfg(all(feature = "frm", feature = "oltp"))] use crate::routes::fraud_check as frm_routes; #[cfg(all(feature = "recon", feature = "olap"))] @@ -2254,3 +2256,15 @@ impl WebhookEvents { ) } } + +#[cfg(feature = "olap")] +pub struct FeatureMatrix; + +#[cfg(all(feature = "olap", feature = "v1"))] +impl FeatureMatrix { + pub fn server(state: AppState) -> Scope { + web::scope("/feature_matrix") + .app_data(web::Data::new(state)) + .service(web::resource("").route(web::get().to(feature_matrix::fetch_feature_matrix))) + } +} diff --git a/crates/router/src/routes/feature_matrix.rs b/crates/router/src/routes/feature_matrix.rs new file mode 100644 index 000000000000..08dd7d0d7b2b --- /dev/null +++ b/crates/router/src/routes/feature_matrix.rs @@ -0,0 +1,150 @@ +use actix_web::{web, HttpRequest, Responder}; +use api_models::{connector_enums::Connector, feature_matrix}; +use common_enums::enums; +use hyperswitch_domain_models::{ + api::ApplicationResponse, router_response_types::PaymentMethodTypeMetadata, +}; +use hyperswitch_interfaces::api::ConnectorSpecifications; +use router_env::{instrument, tracing, Flow}; +use strum::IntoEnumIterator; + +use crate::{ + self as app, + core::{api_locking::LockAction, errors::RouterResponse}, + services::{api, authentication as auth, connector_integration_interface::ConnectorEnum}, + settings, + types::api::{self as api_types, payments as payment_types}, +}; + +#[instrument(skip_all)] +pub async fn fetch_feature_matrix( + state: web::Data, + req: HttpRequest, + json_payload: Option>, +) -> impl Responder { + let flow: Flow = Flow::FeatureMatrix; + let payload = json_payload + .map(|json_request| json_request.into_inner()) + .unwrap_or_else(|| payment_types::FeatureMatrixRequest { connectors: None }); + + Box::pin(api::server_wrap( + flow, + state, + &req, + payload, + |state, (), req, _| generate_feature_matrix(state, req), + &auth::NoAuth, + LockAction::NotApplicable, + )) + .await +} + +pub async fn generate_feature_matrix( + state: app::SessionState, + req: payment_types::FeatureMatrixRequest, +) -> RouterResponse { + let connector_list = req + .connectors + .unwrap_or_else(|| Connector::iter().collect()); + + let feature_matrix_response: Vec = + connector_list + .into_iter() + .filter_map(|connector_name| { + api_types::ConnectorData::convert_connector(&connector_name.to_string()) + .inspect_err(|_| { + router_env::logger::warn!("Failed to fetch {:?} details", connector_name) + }) + .ok() + .and_then(|connector| { + build_connector_feature_details( + &state, + connector, + connector_name.to_string(), + ) + }) + }) + .collect(); + + Ok(ApplicationResponse::Json( + payment_types::FeatureMatrixListResponse { + connector_count: feature_matrix_response.len(), + connectors: feature_matrix_response, + }, + )) +} + +fn build_connector_feature_details( + state: &app::SessionState, + connector: ConnectorEnum, + connector_name: String, +) -> Option { + let connector_integration_features = connector.get_supported_payment_methods(); + connector_integration_features.map(|connector_integration_feature_data| { + let supported_payment_methods = connector_integration_feature_data + .iter() + .flat_map(|(payment_method, supported_payment_method_types)| { + build_payment_method_wise_feature_details( + state, + &connector_name, + *payment_method, + supported_payment_method_types, + ) + }) + .collect::>(); + + let connector_about = connector.get_connector_about(); + let supported_webhook_flows = connector + .get_supported_webhook_flows() + .map(|webhook_flows| webhook_flows.to_vec()); + feature_matrix::ConnectorFeatureMatrixResponse { + name: connector_name, + description: connector_about.map(|about| about.description.clone()), + category: connector_about.map(|about| about.connector_type), + supported_webhook_flows, + supported_payment_methods, + } + }) +} + +fn build_payment_method_wise_feature_details( + state: &app::SessionState, + connector_name: &str, + payment_method: enums::PaymentMethod, + supported_payment_method_types: &PaymentMethodTypeMetadata, +) -> Vec { + supported_payment_method_types + .iter() + .map(|(payment_method_type, feature_metadata)| { + let payment_method_type_config = + state + .conf + .pm_filters + .0 + .get(connector_name) + .and_then(|selected_connector| { + selected_connector.0.get( + &settings::PaymentMethodFilterKey::PaymentMethodType( + *payment_method_type, + ), + ) + }); + + let supported_countries = + payment_method_type_config.and_then(|config| config.country.clone()); + + let supported_currencies = + payment_method_type_config.and_then(|config| config.currency.clone()); + + feature_matrix::SupportedPaymentMethod { + payment_method, + payment_method_type: *payment_method_type, + mandates: feature_metadata.mandates, + refunds: feature_metadata.refunds, + supported_capture_methods: feature_metadata.supported_capture_methods.clone(), + supported_countries, + supported_currencies, + } + }) + .collect() +} diff --git a/crates/router/src/routes/lock_utils.rs b/crates/router/src/routes/lock_utils.rs index 1bc31451fad3..9d7ae1874c10 100644 --- a/crates/router/src/routes/lock_utils.rs +++ b/crates/router/src/routes/lock_utils.rs @@ -38,6 +38,7 @@ pub enum ApiIdentifier { Poll, ApplePayCertificatesMigration, Relay, + Documentation, } impl From for ApiIdentifier { @@ -303,6 +304,8 @@ impl From for ApiIdentifier { | Flow::ReconVerifyToken => Self::Recon, Flow::RetrievePollStatus => Self::Poll, + + Flow::FeatureMatrix => Self::Documentation, } } } diff --git a/crates/router/src/services/api.rs b/crates/router/src/services/api.rs index f746aa28fd5f..cac856b2c48b 100644 --- a/crates/router/src/services/api.rs +++ b/crates/router/src/services/api.rs @@ -39,7 +39,8 @@ pub use hyperswitch_domain_models::{ pub use hyperswitch_interfaces::{ api::{ BoxedConnectorIntegration, CaptureSyncMethod, ConnectorIntegration, - ConnectorIntegrationAny, ConnectorRedirectResponse, ConnectorValidation, + ConnectorIntegrationAny, ConnectorRedirectResponse, ConnectorSpecifications, + ConnectorValidation, }, connector_integration_v2::{ BoxedConnectorIntegrationV2, ConnectorIntegrationAnyV2, ConnectorIntegrationV2, diff --git a/crates/router/src/services/connector_integration_interface.rs b/crates/router/src/services/connector_integration_interface.rs index 934b2d8086c7..5903c8e9cc0d 100644 --- a/crates/router/src/services/connector_integration_interface.rs +++ b/crates/router/src/services/connector_integration_interface.rs @@ -1,11 +1,15 @@ use common_utils::{crypto, errors::CustomResult, request::Request}; -use hyperswitch_domain_models::{router_data::RouterData, router_data_v2::RouterDataV2}; +use hyperswitch_domain_models::{ + router_data::RouterData, + router_data_v2::RouterDataV2, + router_response_types::{ConnectorInfo, SupportedPaymentMethods}, +}; use hyperswitch_interfaces::{ authentication::ExternalAuthenticationPayload, connector_integration_v2::ConnectorIntegrationV2, webhooks::IncomingWebhookFlowError, }; -use super::{BoxedConnectorIntegrationV2, ConnectorValidation}; +use super::{BoxedConnectorIntegrationV2, ConnectorSpecifications, ConnectorValidation}; use crate::{ core::payments, errors, @@ -363,14 +367,23 @@ impl ConnectorRedirectResponse for ConnectorEnum { } impl ConnectorValidation for ConnectorEnum { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, + payment_method: common_enums::PaymentMethod, pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { match self { - Self::Old(connector) => connector.validate_capture_method(capture_method, pmt), - Self::New(connector) => connector.validate_capture_method(capture_method, pmt), + Self::Old(connector) => connector.validate_connector_against_payment_request( + capture_method, + payment_method, + pmt, + ), + Self::New(connector) => connector.validate_connector_against_payment_request( + capture_method, + payment_method, + pmt, + ), } } @@ -416,6 +429,31 @@ impl ConnectorValidation for ConnectorEnum { } } +impl ConnectorSpecifications for ConnectorEnum { + fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> { + match self { + Self::Old(connector) => connector.get_supported_payment_methods(), + Self::New(connector) => connector.get_supported_payment_methods(), + } + } + + /// Supported webhooks flows + fn get_supported_webhook_flows(&self) -> Option<&'static [common_enums::EventClass]> { + match self { + Self::Old(connector) => connector.get_supported_webhook_flows(), + Self::New(connector) => connector.get_supported_webhook_flows(), + } + } + + /// Details related to connector + fn get_connector_about(&self) -> Option<&'static ConnectorInfo> { + match self { + Self::Old(connector) => connector.get_connector_about(), + Self::New(connector) => connector.get_connector_about(), + } + } +} + impl api::ConnectorCommon for ConnectorEnum { fn id(&self) -> &'static str { match self { diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rs index df5d497ea8fa..b0c3d2d21df8 100644 --- a/crates/router/src/types/api.rs +++ b/crates/router/src/types/api.rs @@ -278,12 +278,12 @@ pub enum ConnectorChoice { impl ConnectorData { pub fn get_connector_by_name( - connectors: &Connectors, + _connectors: &Connectors, name: &str, connector_type: GetToken, connector_id: Option, ) -> CustomResult { - let connector = Self::convert_connector(connectors, name)?; + let connector = Self::convert_connector(name)?; let connector_name = api_enums::Connector::from_str(name) .change_context(errors::ConnectorError::InvalidConnectorName) .change_context(errors::ApiErrorResponse::InternalServerError) @@ -298,12 +298,12 @@ impl ConnectorData { #[cfg(feature = "payouts")] pub fn get_payout_connector_by_name( - connectors: &Connectors, + _connectors: &Connectors, name: &str, connector_type: GetToken, connector_id: Option, ) -> CustomResult { - let connector = Self::convert_connector(connectors, name)?; + let connector = Self::convert_connector(name)?; let payout_connector_name = api_enums::PayoutConnectors::from_str(name) .change_context(errors::ConnectorError::InvalidConnectorName) .change_context(errors::ApiErrorResponse::InternalServerError) @@ -318,7 +318,6 @@ impl ConnectorData { } pub fn convert_connector( - _connectors: &Connectors, connector_name: &str, ) -> CustomResult { match enums::Connector::from_str(connector_name) { diff --git a/crates/router/src/types/api/payments.rs b/crates/router/src/types/api/payments.rs index 8be423c037be..6ec0fe701e9c 100644 --- a/crates/router/src/types/api/payments.rs +++ b/crates/router/src/types/api/payments.rs @@ -1,27 +1,33 @@ #[cfg(feature = "v1")] pub use api_models::payments::PaymentsRequest; -pub use api_models::payments::{ - AcceptanceType, Address, AddressDetails, Amount, AuthenticationForStartResponse, Card, - CryptoData, CustomerAcceptance, CustomerDetailsResponse, MandateAmountData, MandateData, - MandateTransactionType, MandateType, MandateValidationFields, NextActionType, OnlineMandate, - OpenBankingSessionToken, PayLaterData, PaymentIdType, PaymentListConstraints, - PaymentListFilterConstraints, PaymentListFilters, PaymentListFiltersV2, PaymentListResponse, - PaymentListResponseV2, PaymentMethodData, PaymentMethodDataRequest, PaymentMethodDataResponse, - PaymentOp, PaymentRetrieveBody, PaymentRetrieveBodyWithCredentials, PaymentsAggregateResponse, - PaymentsApproveRequest, PaymentsCancelRequest, PaymentsCaptureRequest, - PaymentsCompleteAuthorizeRequest, PaymentsDynamicTaxCalculationRequest, - PaymentsDynamicTaxCalculationResponse, PaymentsExternalAuthenticationRequest, - PaymentsIncrementalAuthorizationRequest, PaymentsManualUpdateRequest, - PaymentsPostSessionTokensRequest, PaymentsPostSessionTokensResponse, PaymentsRedirectRequest, - PaymentsRedirectionResponse, PaymentsRejectRequest, PaymentsResponse, PaymentsResponseForm, - PaymentsRetrieveRequest, PaymentsSessionRequest, PaymentsSessionResponse, PaymentsStartRequest, - PgRedirectResponse, PhoneDetails, RedirectionResponse, SessionToken, UrlDetails, VerifyRequest, - VerifyResponse, WalletData, -}; #[cfg(feature = "v2")] pub use api_models::payments::{ PaymentsCreateIntentRequest, PaymentsIntentResponse, PaymentsUpdateIntentRequest, }; +pub use api_models::{ + feature_matrix::{ + ConnectorFeatureMatrixResponse, FeatureMatrixListResponse, FeatureMatrixRequest, + }, + payments::{ + AcceptanceType, Address, AddressDetails, Amount, AuthenticationForStartResponse, Card, + CryptoData, CustomerAcceptance, CustomerDetailsResponse, MandateAmountData, MandateData, + MandateTransactionType, MandateType, MandateValidationFields, NextActionType, + OnlineMandate, OpenBankingSessionToken, PayLaterData, PaymentIdType, + PaymentListConstraints, PaymentListFilterConstraints, PaymentListFilters, + PaymentListFiltersV2, PaymentListResponse, PaymentListResponseV2, PaymentMethodData, + PaymentMethodDataRequest, PaymentMethodDataResponse, PaymentOp, PaymentRetrieveBody, + PaymentRetrieveBodyWithCredentials, PaymentsAggregateResponse, PaymentsApproveRequest, + PaymentsCancelRequest, PaymentsCaptureRequest, PaymentsCompleteAuthorizeRequest, + PaymentsDynamicTaxCalculationRequest, PaymentsDynamicTaxCalculationResponse, + PaymentsExternalAuthenticationRequest, PaymentsIncrementalAuthorizationRequest, + PaymentsManualUpdateRequest, PaymentsPostSessionTokensRequest, + PaymentsPostSessionTokensResponse, PaymentsRedirectRequest, PaymentsRedirectionResponse, + PaymentsRejectRequest, PaymentsResponse, PaymentsResponseForm, PaymentsRetrieveRequest, + PaymentsSessionRequest, PaymentsSessionResponse, PaymentsStartRequest, PgRedirectResponse, + PhoneDetails, RedirectionResponse, SessionToken, UrlDetails, VerifyRequest, VerifyResponse, + WalletData, + }, +}; use error_stack::ResultExt; pub use hyperswitch_domain_models::router_flow_types::payments::{ Approve, Authorize, AuthorizeSessionToken, Balance, CalculateTax, Capture, CompleteAuthorize, diff --git a/crates/router/src/utils/connector_onboarding/paypal.rs b/crates/router/src/utils/connector_onboarding/paypal.rs index ebd40fb11dd2..33b85587b430 100644 --- a/crates/router/src/utils/connector_onboarding/paypal.rs +++ b/crates/router/src/utils/connector_onboarding/paypal.rs @@ -16,10 +16,8 @@ use crate::{ pub async fn generate_access_token(state: SessionState) -> RouterResult { let connector = enums::Connector::Paypal; - let boxed_connector = types::api::ConnectorData::convert_connector( - &state.conf.connectors, - connector.to_string().as_str(), - )?; + let boxed_connector = + types::api::ConnectorData::convert_connector(connector.to_string().as_str())?; let connector_auth = super::get_connector_auth(connector, state.conf.connector_onboarding.get_inner())?; diff --git a/crates/router_env/src/logger/types.rs b/crates/router_env/src/logger/types.rs index 8bcd9e44199a..10183f75d5bc 100644 --- a/crates/router_env/src/logger/types.rs +++ b/crates/router_env/src/logger/types.rs @@ -353,6 +353,8 @@ pub enum Flow { DecisionManagerRetrieveConfig, /// Manual payment fulfillment acknowledgement FrmFulfillment, + /// Get connectors feature matrix + FeatureMatrix, /// Change password flow ChangePassword, /// Signout flow diff --git a/cypress-tests/cypress/e2e/PaymentTest/00000-CoreFlows.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00000-CoreFlows.cy.js index c785c1e68273..a0e2ad643e89 100644 --- a/cypress-tests/cypress/e2e/PaymentTest/00000-CoreFlows.cy.js +++ b/cypress-tests/cypress/e2e/PaymentTest/00000-CoreFlows.cy.js @@ -184,4 +184,20 @@ describe("Core flows", () => { cy.merchantDeleteCall(globalState); }); }); + + context("List Connector Feature Matrix", () => { + before("seed global state", () => { + cy.task("getGlobalState").then((state) => { + globalState = new State(state); + }); + }); + + after("flush global state", () => { + cy.task("setGlobalState", globalState.data); + }); + + it("List connector feature matrix call", () => { + cy.ListConnectorsFeatureMatrixCall(globalState); + }); + }); }); diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js index 891c65914922..28590abd8b6c 100644 --- a/cypress-tests/cypress/support/commands.js +++ b/cypress-tests/cypress/support/commands.js @@ -118,6 +118,29 @@ Cypress.Commands.add("merchantDeleteCall", (globalState) => { }); }); +Cypress.Commands.add("ListConnectorsFeatureMatrixCall", (globalState) => { + const baseUrl = globalState.get("baseUrl"); + const url = `${baseUrl}/feature_matrix`; + + cy.request({ + method: "GET", + url: url, + headers: { + Accept: "application/json", + }, + }).then((response) => { + logRequestId(response.headers["x-request-id"]); + + expect(response.body).to.have.property("connectors").and.not.empty; + expect(response.body.connectors).to.be.an("array").and.not.empty; + response.body.connectors.forEach((item) => { + expect(item).to.have.property("description").and.not.empty; + expect(item).to.have.property("category").and.not.empty; + expect(item).to.have.property("supported_payment_methods").and.not.empty; + }); + }); +}); + Cypress.Commands.add("merchantListCall", (globalState) => { const organization_id = globalState.get("organizationId"); diff --git a/loadtest/config/development.toml b/loadtest/config/development.toml index 3320a5516d07..64d0526d1476 100644 --- a/loadtest/config/development.toml +++ b/loadtest/config/development.toml @@ -279,6 +279,10 @@ paypal = { country = "AU,NZ,CN,JP,HK,MY,TH,KR,PH,ID,AE,KW,BR,ES,GB,SE,NO,SK,AT,N klarna = { country = "AU,AT,BE,CA,CZ,DK,FI,FR,DE,GR,IE,IT,NO,PL,PT,RO,ES,SE,CH,NL,GB,US", currency = "AUD,EUR,CAD,CZK,DKK,NOK,PLN,RON,SEK,CHF,GBP,USD"} ideal = { country = "NL", currency = "EUR" } +[pm_filters.bambora] +credit = { country = "US,CA", currency = "USD" } +debit = { country = "US,CA", currency = "USD" } + [pm_filters.zen] credit = { not_available_flows = { capture_method = "manual" } } debit = { not_available_flows = { capture_method = "manual" } }