feat(connector): [GETNET,HIPAY,KLARNA,MONERIS,OPENNODE] add in feature matrix api (#7873)

Co-authored-by: Anurag Singh <anurag.singh.001@MacBookPro.lan>
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
Co-authored-by: Anurag Singh <anurag.singh.001@Anurag-Singh-WPMHJ5619X.local>
This commit is contained in:
Anurag
2025-04-25 14:53:05 +05:30
committed by GitHub
parent f70824ef5e
commit 69ba651abd
12 changed files with 452 additions and 100 deletions

View File

@ -1,4 +1,6 @@
pub mod transformers;
use std::sync::LazyLock;
use api_models::webhooks::IncomingWebhookEvent;
use base64::{self, Engine};
use common_enums::enums;
@ -23,7 +25,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,
PaymentsSyncRouterData, RefundSyncRouterData, RefundsRouterData,
@ -163,23 +168,6 @@ impl ConnectorCommon for Getnet {
}
impl ConnectorValidation for Getnet {
fn validate_connector_against_payment_request(
&self,
capture_method: Option<enums::CaptureMethod>,
_payment_method: enums::PaymentMethod,
_pmt: Option<enums::PaymentMethodType>,
) -> 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::Scheduled | enums::CaptureMethod::ManualMultiple => Err(
utils::construct_not_implemented_error_report(capture_method, self.id()),
),
}
}
fn validate_psync_reference_id(
&self,
data: &PaymentsSyncData,
@ -829,4 +817,70 @@ impl webhooks::IncomingWebhook for Getnet {
}
}
impl ConnectorSpecifications for Getnet {}
static GETNET_SUPPORTED_PAYMENT_METHODS: LazyLock<SupportedPaymentMethods> = LazyLock::new(|| {
let supported_capture_methods = vec![
enums::CaptureMethod::Automatic,
enums::CaptureMethod::Manual,
enums::CaptureMethod::SequentialAutomatic,
];
let supported_card_network = vec![
common_enums::CardNetwork::Mastercard,
common_enums::CardNetwork::Visa,
common_enums::CardNetwork::Interac,
common_enums::CardNetwork::AmericanExpress,
common_enums::CardNetwork::JCB,
common_enums::CardNetwork::DinersClub,
common_enums::CardNetwork::Discover,
common_enums::CardNetwork::CartesBancaires,
common_enums::CardNetwork::UnionPay,
common_enums::CardNetwork::RuPay,
common_enums::CardNetwork::Maestro,
];
let mut getnet_supported_payment_methods = SupportedPaymentMethods::new();
getnet_supported_payment_methods.add(
enums::PaymentMethod::Card,
enums::PaymentMethodType::Credit,
PaymentMethodDetails {
mandates: enums::FeatureStatus::NotSupported,
refunds: enums::FeatureStatus::Supported,
supported_capture_methods,
specific_features: Some(
api_models::feature_matrix::PaymentMethodSpecificFeatures::Card({
api_models::feature_matrix::CardSpecificFeatures {
three_ds: common_enums::FeatureStatus::NotSupported,
no_three_ds: common_enums::FeatureStatus::Supported,
supported_card_networks: supported_card_network,
}
}),
),
},
);
getnet_supported_payment_methods
});
static GETNET_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo {
display_name: "Getnet",
description: "Getnet is a high-tech global payment platform that helps businesses accept payments securely while providing the best frictionless experience for customers everywhere.",
connector_type: enums::PaymentConnectorCategory::PaymentGateway,
};
static GETNET_SUPPORTED_WEBHOOK_FLOWS: [enums::EventClass; 2] =
[enums::EventClass::Payments, enums::EventClass::Refunds];
impl ConnectorSpecifications for Getnet {
fn get_connector_about(&self) -> Option<&'static ConnectorInfo> {
Some(&GETNET_CONNECTOR_INFO)
}
fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> {
Some(&*GETNET_SUPPORTED_PAYMENT_METHODS)
}
fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> {
Some(&GETNET_SUPPORTED_WEBHOOK_FLOWS)
}
}

View File

@ -1,6 +1,8 @@
pub mod transformers;
use std::sync::LazyLock;
use base64::Engine;
use common_enums::{CaptureMethod, PaymentMethod, PaymentMethodType};
use common_enums::{enums, CaptureMethod, PaymentMethod, PaymentMethodType};
use common_utils::{
consts::BASE64_ENGINE,
errors::{self as common_errors, CustomResult},
@ -21,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,
PaymentsSyncRouterData, RefundSyncRouterData, RefundsRouterData, TokenizationRouterData,
@ -251,28 +256,7 @@ impl ConnectorCommon for Hipay {
}
}
impl ConnectorValidation for Hipay {
fn validate_connector_against_payment_request(
&self,
capture_method: Option<CaptureMethod>,
_payment_method: PaymentMethod,
_pmt: Option<PaymentMethodType>,
) -> CustomResult<(), errors::ConnectorError> {
let capture_method = capture_method.unwrap_or_default();
match capture_method {
CaptureMethod::Automatic
| CaptureMethod::Manual
| CaptureMethod::SequentialAutomatic => Ok(()),
CaptureMethod::ManualMultiple | CaptureMethod::Scheduled => {
Err(errors::ConnectorError::NotSupported {
message: capture_method.to_string(),
connector: self.id(),
}
.into())
}
}
}
}
impl ConnectorValidation for Hipay {}
impl ConnectorIntegration<Session, PaymentsSessionData, PaymentsResponseData> for Hipay {}
@ -768,4 +752,86 @@ impl webhooks::IncomingWebhook for Hipay {
}
}
impl ConnectorSpecifications for Hipay {}
static HIPAY_SUPPORTED_PAYMENT_METHODS: LazyLock<SupportedPaymentMethods> = LazyLock::new(|| {
let supported_capture_methods = vec![
CaptureMethod::Automatic,
CaptureMethod::Manual,
CaptureMethod::SequentialAutomatic,
];
let supported_card_network = vec![
common_enums::CardNetwork::Mastercard,
common_enums::CardNetwork::Visa,
common_enums::CardNetwork::Interac,
common_enums::CardNetwork::AmericanExpress,
common_enums::CardNetwork::JCB,
common_enums::CardNetwork::DinersClub,
common_enums::CardNetwork::Discover,
common_enums::CardNetwork::CartesBancaires,
common_enums::CardNetwork::UnionPay,
];
let mut hipay_supported_payment_methods = SupportedPaymentMethods::new();
hipay_supported_payment_methods.add(
PaymentMethod::Card,
PaymentMethodType::Credit,
PaymentMethodDetails {
mandates: enums::FeatureStatus::NotSupported,
refunds: enums::FeatureStatus::Supported,
supported_capture_methods: supported_capture_methods.clone(),
specific_features: Some(
api_models::feature_matrix::PaymentMethodSpecificFeatures::Card({
api_models::feature_matrix::CardSpecificFeatures {
three_ds: common_enums::FeatureStatus::Supported,
no_three_ds: common_enums::FeatureStatus::Supported,
supported_card_networks: supported_card_network.clone(),
}
}),
),
},
);
hipay_supported_payment_methods.add(
PaymentMethod::Card,
PaymentMethodType::Debit,
PaymentMethodDetails {
mandates: enums::FeatureStatus::NotSupported,
refunds: enums::FeatureStatus::Supported,
supported_capture_methods: supported_capture_methods.clone(),
specific_features: Some(
api_models::feature_matrix::PaymentMethodSpecificFeatures::Card({
api_models::feature_matrix::CardSpecificFeatures {
three_ds: common_enums::FeatureStatus::Supported,
no_three_ds: common_enums::FeatureStatus::Supported,
supported_card_networks: supported_card_network.clone(),
}
}),
),
},
);
hipay_supported_payment_methods
});
static HIPAY_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo {
display_name: "Hipay",
description: "HiPay is an independent global payment service provider that is based in France.",
connector_type: enums::PaymentConnectorCategory::PaymentGateway,
};
static HIPAY_SUPPORTED_WEBHOOK_FLOWS: [enums::EventClass; 0] = [];
impl ConnectorSpecifications for Hipay {
fn get_connector_about(&self) -> Option<&'static ConnectorInfo> {
Some(&HIPAY_CONNECTOR_INFO)
}
fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> {
Some(&*HIPAY_SUPPORTED_PAYMENT_METHODS)
}
fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> {
Some(&HIPAY_SUPPORTED_WEBHOOK_FLOWS)
}
}

View File

@ -1,5 +1,7 @@
pub mod transformers;
use std::sync::LazyLock;
use api_models::webhooks::IncomingWebhookEvent;
use base64::Engine;
use common_enums::enums;
@ -24,7 +26,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,
@ -50,8 +55,8 @@ use crate::{
constants::headers,
types::ResponseRouterData,
utils::{
construct_not_supported_error_report, convert_amount, get_http_header,
get_unimplemented_payment_method_error_message, missing_field_err, RefundsRequestData,
convert_amount, get_http_header, get_unimplemented_payment_method_error_message,
missing_field_err, RefundsRequestData,
},
};
@ -133,24 +138,7 @@ impl ConnectorCommon for Klarna {
}
}
impl ConnectorValidation for Klarna {
fn validate_connector_against_payment_request(
&self,
capture_method: Option<enums::CaptureMethod>,
_payment_method: enums::PaymentMethod,
_pmt: Option<enums::PaymentMethodType>,
) -> 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(
construct_not_supported_error_report(capture_method, self.id()),
),
}
}
}
impl ConnectorValidation for Klarna {}
impl api::Payment for Klarna {}
@ -1369,4 +1357,47 @@ impl IncomingWebhook for Klarna {
}
}
impl ConnectorSpecifications for Klarna {}
static KLARNA_SUPPORTED_PAYMENT_METHODS: LazyLock<SupportedPaymentMethods> = LazyLock::new(|| {
let supported_capture_methods = vec![
enums::CaptureMethod::Automatic,
enums::CaptureMethod::Manual,
enums::CaptureMethod::SequentialAutomatic,
];
let mut klarna_supported_payment_methods = SupportedPaymentMethods::new();
klarna_supported_payment_methods.add(
enums::PaymentMethod::PayLater,
enums::PaymentMethodType::Klarna,
PaymentMethodDetails {
mandates: enums::FeatureStatus::NotSupported,
refunds: enums::FeatureStatus::Supported,
supported_capture_methods,
specific_features: None,
},
);
klarna_supported_payment_methods
});
static KLARNA_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo {
display_name: "Klarna",
description: "Klarna provides payment processing services for the e-commerce industry, managing store claims and customer payments.",
connector_type: enums::PaymentConnectorCategory::PaymentGateway,
};
static KLARNA_SUPPORTED_WEBHOOK_FLOWS: [enums::EventClass; 0] = [];
impl ConnectorSpecifications for Klarna {
fn get_connector_about(&self) -> Option<&'static ConnectorInfo> {
Some(&KLARNA_CONNECTOR_INFO)
}
fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> {
Some(&*KLARNA_SUPPORTED_PAYMENT_METHODS)
}
fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> {
Some(&KLARNA_SUPPORTED_WEBHOOK_FLOWS)
}
}

View File

@ -1,5 +1,7 @@
pub mod transformers;
use std::sync::LazyLock;
use common_enums::enums;
use common_utils::{
errors::CustomResult,
@ -20,7 +22,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,
PaymentsSyncRouterData, RefreshTokenRouterData, RefundSyncRouterData, RefundsRouterData,
@ -182,23 +187,6 @@ impl ConnectorCommon for Moneris {
}
impl ConnectorValidation for Moneris {
fn validate_connector_against_payment_request(
&self,
capture_method: Option<enums::CaptureMethod>,
_payment_method: enums::PaymentMethod,
_pmt: Option<enums::PaymentMethodType>,
) -> CustomResult<(), errors::ConnectorError> {
let capture_method = capture_method.unwrap_or_default();
match capture_method {
enums::CaptureMethod::Automatic | enums::CaptureMethod::Manual => Ok(()),
enums::CaptureMethod::ManualMultiple
| enums::CaptureMethod::Scheduled
| enums::CaptureMethod::SequentialAutomatic => Err(
utils::construct_not_implemented_error_report(capture_method, self.id()),
),
}
}
fn validate_mandate_payment(
&self,
pm_type: Option<enums::PaymentMethodType>,
@ -819,4 +807,85 @@ impl webhooks::IncomingWebhook for Moneris {
}
}
impl ConnectorSpecifications for Moneris {}
static MONERIS_SUPPORTED_PAYMENT_METHODS: LazyLock<SupportedPaymentMethods> = LazyLock::new(|| {
let supported_capture_methods = vec![
enums::CaptureMethod::Automatic,
enums::CaptureMethod::Manual,
];
let supported_card_network = vec![
common_enums::CardNetwork::Mastercard,
common_enums::CardNetwork::Visa,
common_enums::CardNetwork::Interac,
common_enums::CardNetwork::AmericanExpress,
common_enums::CardNetwork::JCB,
common_enums::CardNetwork::DinersClub,
common_enums::CardNetwork::Discover,
common_enums::CardNetwork::CartesBancaires,
common_enums::CardNetwork::UnionPay,
];
let mut moneris_supported_payment_methods = SupportedPaymentMethods::new();
moneris_supported_payment_methods.add(
enums::PaymentMethod::Card,
enums::PaymentMethodType::Credit,
PaymentMethodDetails {
mandates: enums::FeatureStatus::Supported,
refunds: enums::FeatureStatus::Supported,
supported_capture_methods: supported_capture_methods.clone(),
specific_features: Some(
api_models::feature_matrix::PaymentMethodSpecificFeatures::Card({
api_models::feature_matrix::CardSpecificFeatures {
three_ds: common_enums::FeatureStatus::NotSupported,
no_three_ds: common_enums::FeatureStatus::Supported,
supported_card_networks: supported_card_network.clone(),
}
}),
),
},
);
moneris_supported_payment_methods.add(
enums::PaymentMethod::Card,
enums::PaymentMethodType::Debit,
PaymentMethodDetails {
mandates: enums::FeatureStatus::Supported,
refunds: enums::FeatureStatus::Supported,
supported_capture_methods: supported_capture_methods.clone(),
specific_features: Some(
api_models::feature_matrix::PaymentMethodSpecificFeatures::Card({
api_models::feature_matrix::CardSpecificFeatures {
three_ds: common_enums::FeatureStatus::NotSupported,
no_three_ds: common_enums::FeatureStatus::Supported,
supported_card_networks: supported_card_network.clone(),
}
}),
),
},
);
moneris_supported_payment_methods
});
static MONERIS_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo {
display_name: "Moneris",
description: "Moneris is Canada's top payment solutions provider, empowering businesses with innovative mobile, online & in-store solutions.",
connector_type: enums::PaymentConnectorCategory::PaymentGateway,
};
static MONERIS_SUPPORTED_WEBHOOK_FLOWS: [enums::EventClass; 0] = [];
impl ConnectorSpecifications for Moneris {
fn get_connector_about(&self) -> Option<&'static ConnectorInfo> {
Some(&MONERIS_CONNECTOR_INFO)
}
fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> {
Some(&*MONERIS_SUPPORTED_PAYMENT_METHODS)
}
fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> {
Some(&MONERIS_SUPPORTED_WEBHOOK_FLOWS)
}
}

View File

@ -1,7 +1,8 @@
pub mod transformers;
use std::fmt::Debug;
use std::{fmt::Debug, sync::LazyLock};
use common_enums::enums;
use common_utils::{
crypto,
errors::CustomResult,
@ -21,7 +22,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, PaymentsCaptureRouterData, PaymentsSyncRouterData,
RefundsRouterData,
@ -439,4 +443,45 @@ impl IncomingWebhook for Opennode {
}
}
impl ConnectorSpecifications for Opennode {}
static OPENNODE_SUPPORTED_PAYMENT_METHODS: LazyLock<SupportedPaymentMethods> =
LazyLock::new(|| {
let supported_capture_methods = vec![enums::CaptureMethod::Automatic];
let mut opennode_supported_payment_methods = SupportedPaymentMethods::new();
opennode_supported_payment_methods.add(
enums::PaymentMethod::Crypto,
enums::PaymentMethodType::CryptoCurrency,
PaymentMethodDetails {
mandates: enums::FeatureStatus::NotSupported,
refunds: enums::FeatureStatus::NotSupported,
supported_capture_methods,
specific_features: None,
},
);
opennode_supported_payment_methods
});
static OPENNODE_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo {
display_name: "Opennode",
description:
"OpenNode offers accessible way for e-commerce businesses to process bitcoin payments.",
connector_type: enums::PaymentConnectorCategory::PaymentGateway,
};
static OPENNODE_SUPPORTED_WEBHOOK_FLOWS: [enums::EventClass; 1] = [enums::EventClass::Payments];
impl ConnectorSpecifications for Opennode {
fn get_connector_about(&self) -> Option<&'static ConnectorInfo> {
Some(&OPENNODE_CONNECTOR_INFO)
}
fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> {
Some(&*OPENNODE_SUPPORTED_PAYMENT_METHODS)
}
fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> {
Some(&OPENNODE_SUPPORTED_WEBHOOK_FLOWS)
}
}