text
stringlengths 65
57.3k
| file_path
stringlengths 22
92
| module
stringclasses 38
values | type
stringclasses 7
values | struct_name
stringlengths 3
60
⌀ | impl_count
int64 0
60
⌀ | traits
listlengths 0
59
⌀ | tokens
int64 16
8.19k
| function_name
stringlengths 3
85
⌀ | type_name
stringlengths 1
67
⌀ | trait_name
stringclasses 573
values | method_count
int64 0
31
⌀ | public_method_count
int64 0
19
⌀ | submodule_count
int64 0
56
⌀ | export_count
int64 0
9
⌀ |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
// File: crates/connector_configs/src/connector.rs
// Module: connector_configs
// Public functions: 5
// Public structs: 13
use std::collections::HashMap;
#[cfg(feature = "payouts")]
use api_models::enums::PayoutConnectors;
use api_models::{
enums::{AuthenticationConnectors, Connector, PmAuthConnectors, TaxConnectors},
payments,
};
use serde::{Deserialize, Serialize};
use toml;
use crate::common_config::{CardProvider, InputData, Provider, ZenApplePay};
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
pub struct PayloadCurrencyAuthKeyType {
pub api_key: String,
pub processing_account_id: String,
}
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
pub struct Classic {
pub password_classic: String,
pub username_classic: String,
pub merchant_id_classic: String,
}
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
pub struct Evoucher {
pub password_evoucher: String,
pub username_evoucher: String,
pub merchant_id_evoucher: String,
}
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
pub struct CashtoCodeCurrencyAuthKeyType {
pub classic: Classic,
pub evoucher: Evoucher,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CurrencyAuthValue {
CashtoCode(CashtoCodeCurrencyAuthKeyType),
Payload(PayloadCurrencyAuthKeyType),
}
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
pub enum ConnectorAuthType {
HeaderKey {
api_key: String,
},
BodyKey {
api_key: String,
key1: String,
},
SignatureKey {
api_key: String,
key1: String,
api_secret: String,
},
MultiAuthKey {
api_key: String,
key1: String,
api_secret: String,
key2: String,
},
CurrencyAuthKey {
auth_key_map: HashMap<String, CurrencyAuthValue>,
},
CertificateAuth {
certificate: String,
private_key: String,
},
#[default]
NoKey,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Deserialize, Serialize, Clone)]
#[serde(untagged)]
pub enum ApplePayTomlConfig {
Standard(Box<payments::ApplePayMetadata>),
Zen(ZenApplePay),
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum KlarnaEndpoint {
Europe,
NorthAmerica,
Oceania,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct ConfigMerchantAdditionalDetails {
pub open_banking_recipient_data: Option<InputData>,
pub account_data: Option<InputData>,
pub iban: Option<Vec<InputData>>,
pub bacs: Option<Vec<InputData>>,
pub connector_recipient_id: Option<InputData>,
pub wallet_id: Option<InputData>,
pub faster_payments: Option<Vec<InputData>>,
pub sepa: Option<Vec<InputData>>,
pub sepa_instant: Option<Vec<InputData>>,
pub elixir: Option<Vec<InputData>>,
pub bankgiro: Option<Vec<InputData>>,
pub plusgiro: Option<Vec<InputData>>,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct AccountIdConfigForCard {
pub three_ds: Option<Vec<InputData>>,
pub no_three_ds: Option<Vec<InputData>>,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct AccountIdConfigForRedirect {
pub three_ds: Option<Vec<InputData>>,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct AccountIdConfigForApplePay {
pub encrypt: Option<Vec<InputData>>,
pub decrypt: Option<Vec<InputData>>,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct AccountIDSupportedMethods {
apple_pay: HashMap<String, AccountIdConfigForApplePay>,
card: HashMap<String, AccountIdConfigForCard>,
interac: HashMap<String, AccountIdConfigForRedirect>,
pay_safe_card: HashMap<String, AccountIdConfigForRedirect>,
skrill: HashMap<String, AccountIdConfigForRedirect>,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct ConfigMetadata {
pub merchant_config_currency: Option<InputData>,
pub merchant_account_id: Option<InputData>,
pub account_name: Option<InputData>,
pub account_type: Option<InputData>,
pub terminal_id: Option<InputData>,
pub google_pay: Option<Vec<InputData>>,
pub apple_pay: Option<Vec<InputData>>,
pub merchant_id: Option<InputData>,
pub endpoint_prefix: Option<InputData>,
pub mcc: Option<InputData>,
pub merchant_country_code: Option<InputData>,
pub merchant_name: Option<InputData>,
pub acquirer_bin: Option<InputData>,
pub acquirer_merchant_id: Option<InputData>,
pub acquirer_country_code: Option<InputData>,
pub three_ds_requestor_name: Option<InputData>,
pub three_ds_requestor_id: Option<InputData>,
pub pull_mechanism_for_external_3ds_enabled: Option<InputData>,
pub klarna_region: Option<InputData>,
pub pricing_type: Option<InputData>,
pub source_balance_account: Option<InputData>,
pub brand_id: Option<InputData>,
pub destination_account_number: Option<InputData>,
pub dpa_id: Option<InputData>,
pub dpa_name: Option<InputData>,
pub locale: Option<InputData>,
pub card_brands: Option<InputData>,
pub merchant_category_code: Option<InputData>,
pub merchant_configuration_id: Option<InputData>,
pub currency_id: Option<InputData>,
pub platform_id: Option<InputData>,
pub ledger_account_id: Option<InputData>,
pub tenant_id: Option<InputData>,
pub platform_url: Option<InputData>,
pub report_group: Option<InputData>,
pub proxy_url: Option<InputData>,
pub shop_name: Option<InputData>,
pub merchant_funding_source: Option<InputData>,
pub account_id: Option<AccountIDSupportedMethods>,
pub name: Option<InputData>,
pub client_merchant_reference_id: Option<InputData>,
pub route: Option<InputData>,
pub mid: Option<InputData>,
pub tid: Option<InputData>,
pub site: Option<InputData>,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct ConnectorWalletDetailsConfig {
pub samsung_pay: Option<Vec<InputData>>,
pub paze: Option<Vec<InputData>>,
pub google_pay: Option<Vec<InputData>>,
pub amazon_pay: Option<Vec<InputData>>,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct ConnectorTomlConfig {
pub connector_auth: Option<ConnectorAuthType>,
pub connector_webhook_details: Option<api_models::admin::MerchantConnectorWebhookDetails>,
pub metadata: Option<Box<ConfigMetadata>>,
pub connector_wallets_details: Option<Box<ConnectorWalletDetailsConfig>>,
pub additional_merchant_data: Option<Box<ConfigMerchantAdditionalDetails>>,
pub credit: Option<Vec<CardProvider>>,
pub debit: Option<Vec<CardProvider>>,
pub bank_transfer: Option<Vec<Provider>>,
pub bank_redirect: Option<Vec<Provider>>,
pub bank_debit: Option<Vec<Provider>>,
pub open_banking: Option<Vec<Provider>>,
pub pay_later: Option<Vec<Provider>>,
pub wallet: Option<Vec<Provider>>,
pub crypto: Option<Vec<Provider>>,
pub reward: Option<Vec<Provider>>,
pub upi: Option<Vec<Provider>>,
pub voucher: Option<Vec<Provider>>,
pub gift_card: Option<Vec<Provider>>,
pub card_redirect: Option<Vec<Provider>>,
pub is_verifiable: Option<bool>,
pub real_time_payment: Option<Vec<Provider>>,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct ConnectorConfig {
pub authipay: Option<ConnectorTomlConfig>,
pub juspaythreedsserver: Option<ConnectorTomlConfig>,
pub katapult: Option<ConnectorTomlConfig>,
pub aci: Option<ConnectorTomlConfig>,
pub adyen: Option<ConnectorTomlConfig>,
pub affirm: Option<ConnectorTomlConfig>,
#[cfg(feature = "payouts")]
pub adyen_payout: Option<ConnectorTomlConfig>,
#[cfg(feature = "payouts")]
pub adyenplatform_payout: Option<ConnectorTomlConfig>,
pub airwallex: Option<ConnectorTomlConfig>,
pub amazonpay: Option<ConnectorTomlConfig>,
pub archipel: Option<ConnectorTomlConfig>,
pub authorizedotnet: Option<ConnectorTomlConfig>,
pub bamboraapac: Option<ConnectorTomlConfig>,
pub bankofamerica: Option<ConnectorTomlConfig>,
pub barclaycard: Option<ConnectorTomlConfig>,
pub billwerk: Option<ConnectorTomlConfig>,
pub bitpay: Option<ConnectorTomlConfig>,
pub blackhawknetwork: Option<ConnectorTomlConfig>,
pub bluecode: Option<ConnectorTomlConfig>,
pub bluesnap: Option<ConnectorTomlConfig>,
pub boku: Option<ConnectorTomlConfig>,
pub braintree: Option<ConnectorTomlConfig>,
pub breadpay: Option<ConnectorTomlConfig>,
pub cardinal: Option<ConnectorTomlConfig>,
pub cashtocode: Option<ConnectorTomlConfig>,
pub celero: Option<ConnectorTomlConfig>,
pub chargebee: Option<ConnectorTomlConfig>,
pub custombilling: Option<ConnectorTomlConfig>,
pub checkbook: Option<ConnectorTomlConfig>,
pub checkout: Option<ConnectorTomlConfig>,
pub coinbase: Option<ConnectorTomlConfig>,
pub coingate: Option<ConnectorTomlConfig>,
pub cryptopay: Option<ConnectorTomlConfig>,
pub ctp_visa: Option<ConnectorTomlConfig>,
pub cybersource: Option<ConnectorTomlConfig>,
#[cfg(feature = "payouts")]
pub cybersource_payout: Option<ConnectorTomlConfig>,
pub iatapay: Option<ConnectorTomlConfig>,
pub itaubank: Option<ConnectorTomlConfig>,
pub opennode: Option<ConnectorTomlConfig>,
pub bambora: Option<ConnectorTomlConfig>,
pub datatrans: Option<ConnectorTomlConfig>,
pub deutschebank: Option<ConnectorTomlConfig>,
pub digitalvirgo: Option<ConnectorTomlConfig>,
pub dlocal: Option<ConnectorTomlConfig>,
pub dwolla: Option<ConnectorTomlConfig>,
pub ebanx_payout: Option<ConnectorTomlConfig>,
pub elavon: Option<ConnectorTomlConfig>,
pub facilitapay: Option<ConnectorTomlConfig>,
pub finix: Option<ConnectorTomlConfig>,
pub fiserv: Option<ConnectorTomlConfig>,
pub fiservemea: Option<ConnectorTomlConfig>,
pub fiuu: Option<ConnectorTomlConfig>,
pub flexiti: Option<ConnectorTomlConfig>,
pub forte: Option<ConnectorTomlConfig>,
pub getnet: Option<ConnectorTomlConfig>,
pub gigadat: Option<ConnectorTomlConfig>,
pub globalpay: Option<ConnectorTomlConfig>,
pub globepay: Option<ConnectorTomlConfig>,
pub gocardless: Option<ConnectorTomlConfig>,
pub gpayments: Option<ConnectorTomlConfig>,
pub hipay: Option<ConnectorTomlConfig>,
pub helcim: Option<ConnectorTomlConfig>,
pub hyperswitch_vault: Option<ConnectorTomlConfig>,
pub hyperwallet: Option<ConnectorTomlConfig>,
pub inespay: Option<ConnectorTomlConfig>,
pub jpmorgan: Option<ConnectorTomlConfig>,
pub klarna: Option<ConnectorTomlConfig>,
pub loonio: Option<ConnectorTomlConfig>,
pub mifinity: Option<ConnectorTomlConfig>,
pub mollie: Option<ConnectorTomlConfig>,
pub moneris: Option<ConnectorTomlConfig>,
pub mpgs: Option<ConnectorTomlConfig>,
pub multisafepay: Option<ConnectorTomlConfig>,
pub nexinets: Option<ConnectorTomlConfig>,
pub nexixpay: Option<ConnectorTomlConfig>,
pub nmi: Option<ConnectorTomlConfig>,
pub nomupay_payout: Option<ConnectorTomlConfig>,
pub noon: Option<ConnectorTomlConfig>,
pub nordea: Option<ConnectorTomlConfig>,
pub novalnet: Option<ConnectorTomlConfig>,
pub nuvei_payout: Option<ConnectorTomlConfig>,
pub nuvei: Option<ConnectorTomlConfig>,
pub paybox: Option<ConnectorTomlConfig>,
pub payload: Option<ConnectorTomlConfig>,
pub payme: Option<ConnectorTomlConfig>,
#[cfg(feature = "payouts")]
pub payone_payout: Option<ConnectorTomlConfig>,
pub paypal: Option<ConnectorTomlConfig>,
pub paysafe: Option<ConnectorTomlConfig>,
#[cfg(feature = "payouts")]
pub paypal_payout: Option<ConnectorTomlConfig>,
pub paystack: Option<ConnectorTomlConfig>,
pub paytm: Option<ConnectorTomlConfig>,
pub payu: Option<ConnectorTomlConfig>,
pub peachpayments: Option<ConnectorTomlConfig>,
pub phonepe: Option<ConnectorTomlConfig>,
pub placetopay: Option<ConnectorTomlConfig>,
pub plaid: Option<ConnectorTomlConfig>,
pub powertranz: Option<ConnectorTomlConfig>,
pub prophetpay: Option<ConnectorTomlConfig>,
pub razorpay: Option<ConnectorTomlConfig>,
pub recurly: Option<ConnectorTomlConfig>,
pub riskified: Option<ConnectorTomlConfig>,
pub rapyd: Option<ConnectorTomlConfig>,
pub redsys: Option<ConnectorTomlConfig>,
pub santander: Option<ConnectorTomlConfig>,
pub shift4: Option<ConnectorTomlConfig>,
pub sift: Option<ConnectorTomlConfig>,
pub silverflow: Option<ConnectorTomlConfig>,
pub stripe: Option<ConnectorTomlConfig>,
#[cfg(feature = "payouts")]
pub stripe_payout: Option<ConnectorTomlConfig>,
pub stripebilling: Option<ConnectorTomlConfig>,
pub signifyd: Option<ConnectorTomlConfig>,
pub tokenex: Option<ConnectorTomlConfig>,
pub tokenio: Option<ConnectorTomlConfig>,
pub trustpay: Option<ConnectorTomlConfig>,
pub trustpayments: Option<ConnectorTomlConfig>,
pub threedsecureio: Option<ConnectorTomlConfig>,
pub netcetera: Option<ConnectorTomlConfig>,
pub tsys: Option<ConnectorTomlConfig>,
pub vgs: Option<ConnectorTomlConfig>,
pub volt: Option<ConnectorTomlConfig>,
pub wellsfargo: Option<ConnectorTomlConfig>,
#[cfg(feature = "payouts")]
pub wise_payout: Option<ConnectorTomlConfig>,
pub worldline: Option<ConnectorTomlConfig>,
pub worldpay: Option<ConnectorTomlConfig>,
pub worldpayvantiv: Option<ConnectorTomlConfig>,
pub worldpayxml: Option<ConnectorTomlConfig>,
pub xendit: Option<ConnectorTomlConfig>,
pub square: Option<ConnectorTomlConfig>,
pub stax: Option<ConnectorTomlConfig>,
pub dummy_connector: Option<ConnectorTomlConfig>,
pub stripe_test: Option<ConnectorTomlConfig>,
pub paypal_test: Option<ConnectorTomlConfig>,
pub zen: Option<ConnectorTomlConfig>,
pub zsl: Option<ConnectorTomlConfig>,
pub taxjar: Option<ConnectorTomlConfig>,
pub tesouro: Option<ConnectorTomlConfig>,
pub ctp_mastercard: Option<ConnectorTomlConfig>,
pub unified_authentication_service: Option<ConnectorTomlConfig>,
}
impl ConnectorConfig {
fn new() -> Result<Self, String> {
let config_str = if cfg!(feature = "production") {
include_str!("../toml/production.toml")
} else if cfg!(feature = "sandbox") {
include_str!("../toml/sandbox.toml")
} else {
include_str!("../toml/development.toml")
};
let config = toml::from_str::<Self>(config_str);
match config {
Ok(data) => Ok(data),
Err(err) => Err(err.to_string()),
}
}
#[cfg(feature = "payouts")]
pub fn get_payout_connector_config(
connector: PayoutConnectors,
) -> Result<Option<ConnectorTomlConfig>, String> {
let connector_data = Self::new()?;
match connector {
PayoutConnectors::Adyen => Ok(connector_data.adyen_payout),
PayoutConnectors::Adyenplatform => Ok(connector_data.adyenplatform_payout),
PayoutConnectors::Cybersource => Ok(connector_data.cybersource_payout),
PayoutConnectors::Ebanx => Ok(connector_data.ebanx_payout),
PayoutConnectors::Nomupay => Ok(connector_data.nomupay_payout),
PayoutConnectors::Nuvei => Ok(connector_data.nuvei_payout),
PayoutConnectors::Payone => Ok(connector_data.payone_payout),
PayoutConnectors::Paypal => Ok(connector_data.paypal_payout),
PayoutConnectors::Stripe => Ok(connector_data.stripe_payout),
PayoutConnectors::Wise => Ok(connector_data.wise_payout),
}
}
pub fn get_authentication_connector_config(
connector: AuthenticationConnectors,
) -> Result<Option<ConnectorTomlConfig>, String> {
let connector_data = Self::new()?;
match connector {
AuthenticationConnectors::Threedsecureio => Ok(connector_data.threedsecureio),
AuthenticationConnectors::Netcetera => Ok(connector_data.netcetera),
AuthenticationConnectors::Gpayments => Ok(connector_data.gpayments),
AuthenticationConnectors::CtpMastercard => Ok(connector_data.ctp_mastercard),
AuthenticationConnectors::CtpVisa => Ok(connector_data.ctp_visa),
AuthenticationConnectors::UnifiedAuthenticationService => {
Ok(connector_data.unified_authentication_service)
}
AuthenticationConnectors::Juspaythreedsserver => Ok(connector_data.juspaythreedsserver),
AuthenticationConnectors::Cardinal => Ok(connector_data.cardinal),
}
}
pub fn get_tax_processor_config(
connector: TaxConnectors,
) -> Result<Option<ConnectorTomlConfig>, String> {
let connector_data = Self::new()?;
match connector {
TaxConnectors::Taxjar => Ok(connector_data.taxjar),
}
}
pub fn get_pm_authentication_processor_config(
connector: PmAuthConnectors,
) -> Result<Option<ConnectorTomlConfig>, String> {
let connector_data = Self::new()?;
match connector {
PmAuthConnectors::Plaid => Ok(connector_data.plaid),
}
}
pub fn get_connector_config(
connector: Connector,
) -> Result<Option<ConnectorTomlConfig>, String> {
let connector_data = Self::new()?;
match connector {
Connector::Aci => Ok(connector_data.aci),
Connector::Authipay => Ok(connector_data.authipay),
Connector::Adyen => Ok(connector_data.adyen),
Connector::Affirm => Ok(connector_data.affirm),
Connector::Adyenplatform => Err("Use get_payout_connector_config".to_string()),
Connector::Airwallex => Ok(connector_data.airwallex),
Connector::Amazonpay => Ok(connector_data.amazonpay),
Connector::Archipel => Ok(connector_data.archipel),
Connector::Authorizedotnet => Ok(connector_data.authorizedotnet),
Connector::Bamboraapac => Ok(connector_data.bamboraapac),
Connector::Bankofamerica => Ok(connector_data.bankofamerica),
Connector::Barclaycard => Ok(connector_data.barclaycard),
Connector::Billwerk => Ok(connector_data.billwerk),
Connector::Bitpay => Ok(connector_data.bitpay),
Connector::Bluesnap => Ok(connector_data.bluesnap),
Connector::Bluecode => Ok(connector_data.bluecode),
Connector::Blackhawknetwork => Ok(connector_data.blackhawknetwork),
Connector::Boku => Ok(connector_data.boku),
Connector::Braintree => Ok(connector_data.braintree),
Connector::Breadpay => Ok(connector_data.breadpay),
Connector::Cashtocode => Ok(connector_data.cashtocode),
Connector::Cardinal => Ok(connector_data.cardinal),
Connector::Celero => Ok(connector_data.celero),
Connector::Chargebee => Ok(connector_data.chargebee),
Connector::Checkbook => Ok(connector_data.checkbook),
Connector::Checkout => Ok(connector_data.checkout),
Connector::Coinbase => Ok(connector_data.coinbase),
Connector::Coingate => Ok(connector_data.coingate),
Connector::Cryptopay => Ok(connector_data.cryptopay),
Connector::CtpVisa => Ok(connector_data.ctp_visa),
Connector::Custombilling => Ok(connector_data.custombilling),
Connector::Cybersource => Ok(connector_data.cybersource),
#[cfg(feature = "dummy_connector")]
Connector::DummyBillingConnector => Ok(connector_data.dummy_connector),
Connector::Iatapay => Ok(connector_data.iatapay),
Connector::Itaubank => Ok(connector_data.itaubank),
Connector::Opennode => Ok(connector_data.opennode),
Connector::Bambora => Ok(connector_data.bambora),
Connector::Datatrans => Ok(connector_data.datatrans),
Connector::Deutschebank => Ok(connector_data.deutschebank),
Connector::Digitalvirgo => Ok(connector_data.digitalvirgo),
Connector::Dlocal => Ok(connector_data.dlocal),
Connector::Dwolla => Ok(connector_data.dwolla),
Connector::Ebanx => Ok(connector_data.ebanx_payout),
Connector::Elavon => Ok(connector_data.elavon),
Connector::Facilitapay => Ok(connector_data.facilitapay),
Connector::Fiserv => Ok(connector_data.fiserv),
Connector::Fiservemea => Ok(connector_data.fiservemea),
Connector::Fiuu => Ok(connector_data.fiuu),
Connector::Flexiti => Ok(connector_data.flexiti),
Connector::Forte => Ok(connector_data.forte),
Connector::Getnet => Ok(connector_data.getnet),
Connector::Gigadat => Ok(connector_data.gigadat),
Connector::Globalpay => Ok(connector_data.globalpay),
Connector::Globepay => Ok(connector_data.globepay),
Connector::Gocardless => Ok(connector_data.gocardless),
Connector::Gpayments => Ok(connector_data.gpayments),
Connector::Hipay => Ok(connector_data.hipay),
Connector::HyperswitchVault => Ok(connector_data.hyperswitch_vault),
Connector::Helcim => Ok(connector_data.helcim),
Connector::Inespay => Ok(connector_data.inespay),
Connector::Jpmorgan => Ok(connector_data.jpmorgan),
Connector::Juspaythreedsserver => Ok(connector_data.juspaythreedsserver),
Connector::Klarna => Ok(connector_data.klarna),
Connector::Loonio => Ok(connector_data.loonio),
Connector::Mifinity => Ok(connector_data.mifinity),
Connector::Mollie => Ok(connector_data.mollie),
Connector::Moneris => Ok(connector_data.moneris),
Connector::Multisafepay => Ok(connector_data.multisafepay),
Connector::Nexinets => Ok(connector_data.nexinets),
Connector::Nexixpay => Ok(connector_data.nexixpay),
Connector::Prophetpay => Ok(connector_data.prophetpay),
Connector::Nmi => Ok(connector_data.nmi),
Connector::Nordea => Ok(connector_data.nordea),
Connector::Nomupay => Err("Use get_payout_connector_config".to_string()),
Connector::Novalnet => Ok(connector_data.novalnet),
Connector::Noon => Ok(connector_data.noon),
Connector::Nuvei => Ok(connector_data.nuvei),
Connector::Paybox => Ok(connector_data.paybox),
Connector::Payload => Ok(connector_data.payload),
Connector::Payme => Ok(connector_data.payme),
Connector::Payone => Err("Use get_payout_connector_config".to_string()),
Connector::Paypal => Ok(connector_data.paypal),
Connector::Paysafe => Ok(connector_data.paysafe),
Connector::Paystack => Ok(connector_data.paystack),
Connector::Payu => Ok(connector_data.payu),
Connector::Peachpayments => Ok(connector_data.peachpayments),
Connector::Placetopay => Ok(connector_data.placetopay),
Connector::Plaid => Ok(connector_data.plaid),
Connector::Powertranz => Ok(connector_data.powertranz),
Connector::Razorpay => Ok(connector_data.razorpay),
Connector::Rapyd => Ok(connector_data.rapyd),
Connector::Recurly => Ok(connector_data.recurly),
Connector::Redsys => Ok(connector_data.redsys),
Connector::Riskified => Ok(connector_data.riskified),
Connector::Santander => Ok(connector_data.santander),
Connector::Shift4 => Ok(connector_data.shift4),
Connector::Signifyd => Ok(connector_data.signifyd),
Connector::Silverflow => Ok(connector_data.silverflow),
Connector::Square => Ok(connector_data.square),
Connector::Stax => Ok(connector_data.stax),
Connector::Stripe => Ok(connector_data.stripe),
Connector::Stripebilling => Ok(connector_data.stripebilling),
Connector::Tokenex => Ok(connector_data.tokenex),
Connector::Tokenio => Ok(connector_data.tokenio),
Connector::Trustpay => Ok(connector_data.trustpay),
Connector::Trustpayments => Ok(connector_data.trustpayments),
Connector::Threedsecureio => Ok(connector_data.threedsecureio),
Connector::Taxjar => Ok(connector_data.taxjar),
Connector::Tsys => Ok(connector_data.tsys),
Connector::Vgs => Ok(connector_data.vgs),
Connector::Volt => Ok(connector_data.volt),
Connector::Wellsfargo => Ok(connector_data.wellsfargo),
Connector::Wise => Err("Use get_payout_connector_config".to_string()),
Connector::Worldline => Ok(connector_data.worldline),
Connector::Worldpay => Ok(connector_data.worldpay),
Connector::Worldpayvantiv => Ok(connector_data.worldpayvantiv),
Connector::Worldpayxml => Ok(connector_data.worldpayxml),
Connector::Zen => Ok(connector_data.zen),
Connector::Zsl => Ok(connector_data.zsl),
#[cfg(feature = "dummy_connector")]
Connector::DummyConnector1 => Ok(connector_data.dummy_connector),
#[cfg(feature = "dummy_connector")]
Connector::DummyConnector2 => Ok(connector_data.dummy_connector),
#[cfg(feature = "dummy_connector")]
Connector::DummyConnector3 => Ok(connector_data.dummy_connector),
#[cfg(feature = "dummy_connector")]
Connector::DummyConnector4 => Ok(connector_data.stripe_test),
#[cfg(feature = "dummy_connector")]
Connector::DummyConnector5 => Ok(connector_data.dummy_connector),
#[cfg(feature = "dummy_connector")]
Connector::DummyConnector6 => Ok(connector_data.dummy_connector),
#[cfg(feature = "dummy_connector")]
Connector::DummyConnector7 => Ok(connector_data.paypal_test),
Connector::Netcetera => Ok(connector_data.netcetera),
Connector::CtpMastercard => Ok(connector_data.ctp_mastercard),
Connector::Xendit => Ok(connector_data.xendit),
Connector::Paytm => Ok(connector_data.paytm),
Connector::Phonepe => Ok(connector_data.phonepe),
}
}
}
|
crates/connector_configs/src/connector.rs
|
connector_configs
|
full_file
| null | null | null | 6,288
| null | null | null | null | null | null | null |
// File: crates/router/src/types/domain/user_key_store.rs
// Module: router
// Public structs: 1
use common_utils::{
crypto::Encryptable,
date_time, type_name,
types::keymanager::{Identifier, KeyManagerState},
};
use error_stack::ResultExt;
use hyperswitch_domain_models::type_encryption::{crypto_operation, CryptoOperation};
use masking::{PeekInterface, Secret};
use time::PrimitiveDateTime;
use crate::errors::{CustomResult, ValidationError};
#[derive(Clone, Debug, serde::Serialize)]
pub struct UserKeyStore {
pub user_id: String,
pub key: Encryptable<Secret<Vec<u8>>>,
pub created_at: PrimitiveDateTime,
}
#[async_trait::async_trait]
impl super::behaviour::Conversion for UserKeyStore {
type DstType = diesel_models::user_key_store::UserKeyStore;
type NewDstType = diesel_models::user_key_store::UserKeyStoreNew;
async fn convert(self) -> CustomResult<Self::DstType, ValidationError> {
Ok(diesel_models::user_key_store::UserKeyStore {
key: self.key.into(),
user_id: self.user_id,
created_at: self.created_at,
})
}
async fn convert_back(
state: &KeyManagerState,
item: Self::DstType,
key: &Secret<Vec<u8>>,
_key_manager_identifier: Identifier,
) -> CustomResult<Self, ValidationError>
where
Self: Sized,
{
let identifier = Identifier::User(item.user_id.clone());
Ok(Self {
key: crypto_operation(
state,
type_name!(Self::DstType),
CryptoOperation::Decrypt(item.key),
identifier,
key.peek(),
)
.await
.and_then(|val| val.try_into_operation())
.change_context(ValidationError::InvalidValue {
message: "Failed while decrypting customer data".to_string(),
})?,
user_id: item.user_id,
created_at: item.created_at,
})
}
async fn construct_new(self) -> CustomResult<Self::NewDstType, ValidationError> {
Ok(diesel_models::user_key_store::UserKeyStoreNew {
user_id: self.user_id,
key: self.key.into(),
created_at: date_time::now(),
})
}
}
|
crates/router/src/types/domain/user_key_store.rs
|
router
|
full_file
| null | null | null | 495
| null | null | null | null | null | null | null |
// Struct: WellsfargoNotAvailableErrorObject
// File: crates/hyperswitch_connectors/src/connectors/wellsfargo/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct WellsfargoNotAvailableErrorObject
|
crates/hyperswitch_connectors/src/connectors/wellsfargo/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
WellsfargoNotAvailableErrorObject
| 0
|
[] | 57
| null | null | null | null | null | null | null |
// Function: payouts_list_available_filters_for_profile
// File: crates/router/src/routes/payouts.rs
// Module: router
pub fn payouts_list_available_filters_for_profile(
state: web::Data<AppState>,
req: HttpRequest,
json_payload: web::Json<common_utils::types::TimeRange>,
) -> HttpResponse
|
crates/router/src/routes/payouts.rs
|
router
|
function_signature
| null | null | null | 69
|
payouts_list_available_filters_for_profile
| null | null | null | null | null | null |
// Struct: Association
// File: crates/hyperswitch_connectors/src/connectors/fiserv/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct Association
|
crates/hyperswitch_connectors/src/connectors/fiserv/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
Association
| 0
|
[] | 44
| null | null | null | null | null | null | null |
// Struct: PartnerReferralIntegrationPreference
// File: crates/router/src/types/api/connector_onboarding/paypal.rs
// Module: router
// Implementations: 0
pub struct PartnerReferralIntegrationPreference
|
crates/router/src/types/api/connector_onboarding/paypal.rs
|
router
|
struct_definition
|
PartnerReferralIntegrationPreference
| 0
|
[] | 44
| null | null | null | null | null | null | null |
// Struct: ErrorMessagesResult
// File: crates/api_models/src/analytics/refunds.rs
// Module: api_models
// Implementations: 0
pub struct ErrorMessagesResult
|
crates/api_models/src/analytics/refunds.rs
|
api_models
|
struct_definition
|
ErrorMessagesResult
| 0
|
[] | 38
| null | null | null | null | null | null | null |
// Struct: HipayAuthType
// File: crates/hyperswitch_connectors/src/connectors/hipay/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct HipayAuthType
|
crates/hyperswitch_connectors/src/connectors/hipay/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
HipayAuthType
| 0
|
[] | 50
| null | null | null | null | null | null | null |
// Struct: CardHolderAccountInformation
// File: crates/hyperswitch_connectors/src/connectors/netcetera/netcetera_types.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct CardHolderAccountInformation
|
crates/hyperswitch_connectors/src/connectors/netcetera/netcetera_types.rs
|
hyperswitch_connectors
|
struct_definition
|
CardHolderAccountInformation
| 0
|
[] | 53
| null | null | null | null | null | null | null |
// Function: insert_locales_in_context_for_payout_link_status
// File: crates/router/src/services/api/generic_link_response/context.rs
// Module: router
pub fn insert_locales_in_context_for_payout_link_status(context: &mut Context, locale: &str)
|
crates/router/src/services/api/generic_link_response/context.rs
|
router
|
function_signature
| null | null | null | 57
|
insert_locales_in_context_for_payout_link_status
| null | null | null | null | null | null |
// Implementation: impl webhooks::IncomingWebhook for for CtpMastercard
// File: crates/hyperswitch_connectors/src/connectors/ctp_mastercard.rs
// Module: hyperswitch_connectors
// Methods: 3 total (0 public)
impl webhooks::IncomingWebhook for for CtpMastercard
|
crates/hyperswitch_connectors/src/connectors/ctp_mastercard.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 67
| null |
CtpMastercard
|
webhooks::IncomingWebhook for
| 3
| 0
| null | null |
// Struct: Sale
// File: crates/hyperswitch_connectors/src/connectors/worldpayvantiv/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct Sale
|
crates/hyperswitch_connectors/src/connectors/worldpayvantiv/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
Sale
| 0
|
[] | 45
| null | null | null | null | null | null | null |
// Implementation: impl webhooks::IncomingWebhook for for Stripebilling
// File: crates/hyperswitch_connectors/src/connectors/stripebilling.rs
// Module: hyperswitch_connectors
// Methods: 11 total (0 public)
impl webhooks::IncomingWebhook for for Stripebilling
|
crates/hyperswitch_connectors/src/connectors/stripebilling.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 63
| null |
Stripebilling
|
webhooks::IncomingWebhook for
| 11
| 0
| null | null |
// Struct: CustomData
// File: crates/hyperswitch_connectors/src/connectors/bambora/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct CustomData
|
crates/hyperswitch_connectors/src/connectors/bambora/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
CustomData
| 0
|
[] | 46
| null | null | null | null | null | null | null |
// Function: new
// File: crates/hyperswitch_connectors/src/connectors/worldpayvantiv.rs
// Module: hyperswitch_connectors
pub fn new() -> &'static Self
|
crates/hyperswitch_connectors/src/connectors/worldpayvantiv.rs
|
hyperswitch_connectors
|
function_signature
| null | null | null | 40
|
new
| null | null | null | null | null | null |
// Function: check_payment_link_status
// File: crates/router/src/core/payment_link.rs
// Module: router
pub fn check_payment_link_status(
payment_link_expiry: PrimitiveDateTime,
) -> api_models::payments::PaymentLinkStatus
|
crates/router/src/core/payment_link.rs
|
router
|
function_signature
| null | null | null | 49
|
check_payment_link_status
| null | null | null | null | null | null |
// Struct: CardRequestStruct
// File: crates/hyperswitch_connectors/src/connectors/paypal/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct CardRequestStruct
|
crates/hyperswitch_connectors/src/connectors/paypal/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
CardRequestStruct
| 0
|
[] | 47
| null | null | null | null | null | null | null |
// Function: config_key_delete
// File: crates/router/src/routes/configs.rs
// Module: router
pub fn config_key_delete(
state: web::Data<AppState>,
req: HttpRequest,
path: web::Path<String>,
) -> impl Responder
|
crates/router/src/routes/configs.rs
|
router
|
function_signature
| null | null | null | 56
|
config_key_delete
| null | null | null | null | null | null |
// Implementation: impl api::MandateSetup for for Shift4
// File: crates/hyperswitch_connectors/src/connectors/shift4.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::MandateSetup for for Shift4
|
crates/hyperswitch_connectors/src/connectors/shift4.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 62
| null |
Shift4
|
api::MandateSetup for
| 0
| 0
| null | null |
// Implementation: impl api::RefundSync for for Placetopay
// File: crates/hyperswitch_connectors/src/connectors/placetopay.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::RefundSync for for Placetopay
|
crates/hyperswitch_connectors/src/connectors/placetopay.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 65
| null |
Placetopay
|
api::RefundSync for
| 0
| 0
| null | null |
// Struct: Response
// File: crates/pm_auth/src/types.rs
// Module: pm_auth
// Implementations: 0
pub struct Response
|
crates/pm_auth/src/types.rs
|
pm_auth
|
struct_definition
|
Response
| 0
|
[] | 31
| null | null | null | null | null | null | null |
// Implementation: impl api::Payment for for Globepay
// File: crates/hyperswitch_connectors/src/connectors/globepay.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::Payment for for Globepay
|
crates/hyperswitch_connectors/src/connectors/globepay.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 59
| null |
Globepay
|
api::Payment for
| 0
| 0
| null | null |
// Struct: TsysCancelRequest
// File: crates/hyperswitch_connectors/src/connectors/tsys/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct TsysCancelRequest
|
crates/hyperswitch_connectors/src/connectors/tsys/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
TsysCancelRequest
| 0
|
[] | 49
| null | null | null | null | null | null | null |
// Implementation: impl api::ConnectorAccessToken for for Trustpayments
// File: crates/hyperswitch_connectors/src/connectors/trustpayments.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::ConnectorAccessToken for for Trustpayments
|
crates/hyperswitch_connectors/src/connectors/trustpayments.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 58
| null |
Trustpayments
|
api::ConnectorAccessToken for
| 0
| 0
| null | null |
// File: crates/router/src/services/kafka/payment_attempt_event.rs
// Module: router
// Public functions: 2
// Public structs: 2
#[cfg(feature = "v2")]
use common_types::payments;
#[cfg(feature = "v2")]
use common_utils::types;
use common_utils::{id_type, types::MinorUnit};
use diesel_models::enums as storage_enums;
#[cfg(feature = "v2")]
use diesel_models::payment_attempt;
#[cfg(feature = "v2")]
use hyperswitch_domain_models::{
address, payments::payment_attempt::PaymentAttemptFeatureMetadata,
router_response_types::RedirectForm,
};
use hyperswitch_domain_models::{
mandates::MandateDetails, payments::payment_attempt::PaymentAttempt,
};
use time::OffsetDateTime;
#[cfg(feature = "v1")]
#[serde_with::skip_serializing_none]
#[derive(serde::Serialize, Debug)]
pub struct KafkaPaymentAttemptEvent<'a> {
pub payment_id: &'a id_type::PaymentId,
pub merchant_id: &'a id_type::MerchantId,
pub attempt_id: &'a String,
pub status: storage_enums::AttemptStatus,
pub amount: MinorUnit,
pub currency: Option<storage_enums::Currency>,
pub save_to_locker: Option<bool>,
pub connector: Option<&'a String>,
pub error_message: Option<&'a String>,
pub offer_amount: Option<MinorUnit>,
pub surcharge_amount: Option<MinorUnit>,
pub tax_amount: Option<MinorUnit>,
pub payment_method_id: Option<&'a String>,
pub payment_method: Option<storage_enums::PaymentMethod>,
pub connector_transaction_id: Option<&'a String>,
pub capture_method: Option<storage_enums::CaptureMethod>,
#[serde(default, with = "time::serde::timestamp::nanoseconds::option")]
pub capture_on: Option<OffsetDateTime>,
pub confirm: bool,
pub authentication_type: Option<storage_enums::AuthenticationType>,
#[serde(with = "time::serde::timestamp::nanoseconds")]
pub created_at: OffsetDateTime,
#[serde(with = "time::serde::timestamp::nanoseconds")]
pub modified_at: OffsetDateTime,
#[serde(default, with = "time::serde::timestamp::nanoseconds::option")]
pub last_synced: Option<OffsetDateTime>,
pub cancellation_reason: Option<&'a String>,
pub amount_to_capture: Option<MinorUnit>,
pub mandate_id: Option<&'a String>,
pub browser_info: Option<String>,
pub error_code: Option<&'a String>,
pub connector_metadata: Option<String>,
// TODO: These types should implement copy ideally
pub payment_experience: Option<&'a storage_enums::PaymentExperience>,
pub payment_method_type: Option<&'a storage_enums::PaymentMethodType>,
pub payment_method_data: Option<String>,
pub error_reason: Option<&'a String>,
pub multiple_capture_count: Option<i16>,
pub amount_capturable: MinorUnit,
pub merchant_connector_id: Option<&'a id_type::MerchantConnectorAccountId>,
pub net_amount: MinorUnit,
pub unified_code: Option<&'a String>,
pub unified_message: Option<&'a String>,
pub mandate_data: Option<&'a MandateDetails>,
pub client_source: Option<&'a String>,
pub client_version: Option<&'a String>,
pub profile_id: &'a id_type::ProfileId,
pub organization_id: &'a id_type::OrganizationId,
pub card_network: Option<String>,
pub card_discovery: Option<String>,
pub routing_approach: Option<storage_enums::RoutingApproach>,
pub debit_routing_savings: Option<MinorUnit>,
pub signature_network: Option<common_enums::CardNetwork>,
pub is_issuer_regulated: Option<bool>,
}
#[cfg(feature = "v1")]
impl<'a> KafkaPaymentAttemptEvent<'a> {
pub fn from_storage(attempt: &'a PaymentAttempt) -> Self {
let card_payment_method_data = attempt
.get_payment_method_data()
.and_then(|data| data.get_additional_card_info());
Self {
payment_id: &attempt.payment_id,
merchant_id: &attempt.merchant_id,
attempt_id: &attempt.attempt_id,
status: attempt.status,
amount: attempt.net_amount.get_order_amount(),
currency: attempt.currency,
save_to_locker: attempt.save_to_locker,
connector: attempt.connector.as_ref(),
error_message: attempt.error_message.as_ref(),
offer_amount: attempt.offer_amount,
surcharge_amount: attempt.net_amount.get_surcharge_amount(),
tax_amount: attempt.net_amount.get_tax_on_surcharge(),
payment_method_id: attempt.payment_method_id.as_ref(),
payment_method: attempt.payment_method,
connector_transaction_id: attempt.connector_transaction_id.as_ref(),
capture_method: attempt.capture_method,
capture_on: attempt.capture_on.map(|i| i.assume_utc()),
confirm: attempt.confirm,
authentication_type: attempt.authentication_type,
created_at: attempt.created_at.assume_utc(),
modified_at: attempt.modified_at.assume_utc(),
last_synced: attempt.last_synced.map(|i| i.assume_utc()),
cancellation_reason: attempt.cancellation_reason.as_ref(),
amount_to_capture: attempt.amount_to_capture,
mandate_id: attempt.mandate_id.as_ref(),
browser_info: attempt.browser_info.as_ref().map(|v| v.to_string()),
error_code: attempt.error_code.as_ref(),
connector_metadata: attempt.connector_metadata.as_ref().map(|v| v.to_string()),
payment_experience: attempt.payment_experience.as_ref(),
payment_method_type: attempt.payment_method_type.as_ref(),
payment_method_data: attempt.payment_method_data.as_ref().map(|v| v.to_string()),
error_reason: attempt.error_reason.as_ref(),
multiple_capture_count: attempt.multiple_capture_count,
amount_capturable: attempt.amount_capturable,
merchant_connector_id: attempt.merchant_connector_id.as_ref(),
net_amount: attempt.net_amount.get_total_amount(),
unified_code: attempt.unified_code.as_ref(),
unified_message: attempt.unified_message.as_ref(),
mandate_data: attempt.mandate_data.as_ref(),
client_source: attempt.client_source.as_ref(),
client_version: attempt.client_version.as_ref(),
profile_id: &attempt.profile_id,
organization_id: &attempt.organization_id,
card_network: attempt
.payment_method_data
.as_ref()
.and_then(|data| data.as_object())
.and_then(|pm| pm.get("card"))
.and_then(|data| data.as_object())
.and_then(|card| card.get("card_network"))
.and_then(|network| network.as_str())
.map(|network| network.to_string()),
card_discovery: attempt
.card_discovery
.map(|discovery| discovery.to_string()),
routing_approach: attempt.routing_approach.clone(),
debit_routing_savings: attempt.debit_routing_savings,
signature_network: card_payment_method_data
.as_ref()
.and_then(|data| data.signature_network.clone()),
is_issuer_regulated: card_payment_method_data.and_then(|data| data.is_regulated),
}
}
}
#[cfg(feature = "v2")]
#[serde_with::skip_serializing_none]
#[derive(serde::Serialize, Debug)]
pub struct KafkaPaymentAttemptEvent<'a> {
pub payment_id: &'a id_type::GlobalPaymentId,
pub merchant_id: &'a id_type::MerchantId,
pub attempt_id: &'a id_type::GlobalAttemptId,
pub attempts_group_id: Option<&'a String>,
pub status: storage_enums::AttemptStatus,
pub amount: MinorUnit,
pub connector: Option<&'a String>,
pub error_message: Option<&'a String>,
pub surcharge_amount: Option<MinorUnit>,
pub tax_amount: Option<MinorUnit>,
pub payment_method_id: Option<&'a id_type::GlobalPaymentMethodId>,
pub payment_method: storage_enums::PaymentMethod,
pub connector_transaction_id: Option<&'a String>,
pub authentication_type: storage_enums::AuthenticationType,
#[serde(with = "time::serde::timestamp::nanoseconds")]
pub created_at: OffsetDateTime,
#[serde(with = "time::serde::timestamp::nanoseconds")]
pub modified_at: OffsetDateTime,
#[serde(default, with = "time::serde::timestamp::nanoseconds::option")]
pub last_synced: Option<OffsetDateTime>,
pub cancellation_reason: Option<&'a String>,
pub amount_to_capture: Option<MinorUnit>,
pub browser_info: Option<&'a types::BrowserInformation>,
pub error_code: Option<&'a String>,
pub connector_metadata: Option<String>,
// TODO: These types should implement copy ideally
pub payment_experience: Option<&'a storage_enums::PaymentExperience>,
pub payment_method_type: &'a storage_enums::PaymentMethodType,
pub payment_method_data: Option<String>,
pub error_reason: Option<&'a String>,
pub multiple_capture_count: Option<i16>,
pub amount_capturable: MinorUnit,
pub merchant_connector_id: Option<&'a id_type::MerchantConnectorAccountId>,
pub net_amount: MinorUnit,
pub unified_code: Option<&'a String>,
pub unified_message: Option<&'a String>,
pub client_source: Option<&'a String>,
pub client_version: Option<&'a String>,
pub profile_id: &'a id_type::ProfileId,
pub organization_id: &'a id_type::OrganizationId,
pub card_network: Option<String>,
pub card_discovery: Option<String>,
pub connector_payment_id: Option<types::ConnectorTransactionId>,
pub payment_token: Option<String>,
pub preprocessing_step_id: Option<String>,
pub connector_response_reference_id: Option<String>,
pub updated_by: &'a String,
pub encoded_data: Option<&'a masking::Secret<String>>,
pub external_three_ds_authentication_attempted: Option<bool>,
pub authentication_connector: Option<String>,
pub authentication_id: Option<String>,
pub fingerprint_id: Option<String>,
pub customer_acceptance: Option<&'a masking::Secret<payments::CustomerAcceptance>>,
pub shipping_cost: Option<MinorUnit>,
pub order_tax_amount: Option<MinorUnit>,
pub charges: Option<payments::ConnectorChargeResponseData>,
pub processor_merchant_id: &'a id_type::MerchantId,
pub created_by: Option<&'a types::CreatedBy>,
pub payment_method_type_v2: storage_enums::PaymentMethod,
pub payment_method_subtype: storage_enums::PaymentMethodType,
pub routing_result: Option<serde_json::Value>,
pub authentication_applied: Option<common_enums::AuthenticationType>,
pub external_reference_id: Option<String>,
pub tax_on_surcharge: Option<MinorUnit>,
pub payment_method_billing_address: Option<masking::Secret<&'a address::Address>>, // adjusted from Encryption
pub redirection_data: Option<&'a RedirectForm>,
pub connector_payment_data: Option<String>,
pub connector_token_details: Option<&'a payment_attempt::ConnectorTokenDetails>,
pub feature_metadata: Option<&'a PaymentAttemptFeatureMetadata>,
pub network_advice_code: Option<String>,
pub network_decline_code: Option<String>,
pub network_error_message: Option<String>,
pub connector_request_reference_id: Option<String>,
}
#[cfg(feature = "v2")]
impl<'a> KafkaPaymentAttemptEvent<'a> {
pub fn from_storage(attempt: &'a PaymentAttempt) -> Self {
use masking::PeekInterface;
let PaymentAttempt {
payment_id,
merchant_id,
attempts_group_id,
amount_details,
status,
connector,
error,
authentication_type,
created_at,
modified_at,
last_synced,
cancellation_reason,
browser_info,
payment_token,
connector_metadata,
payment_experience,
payment_method_data,
routing_result,
preprocessing_step_id,
multiple_capture_count,
connector_response_reference_id,
updated_by,
redirection_data,
encoded_data,
merchant_connector_id,
external_three_ds_authentication_attempted,
authentication_connector,
authentication_id,
fingerprint_id,
client_source,
client_version,
customer_acceptance,
profile_id,
organization_id,
payment_method_type,
payment_method_id,
connector_payment_id,
payment_method_subtype,
authentication_applied,
external_reference_id,
payment_method_billing_address,
id,
connector_token_details,
card_discovery,
charges,
feature_metadata,
processor_merchant_id,
created_by,
connector_request_reference_id,
network_transaction_id: _,
} = attempt;
let (connector_payment_id, connector_payment_data) = connector_payment_id
.clone()
.map(types::ConnectorTransactionId::form_id_and_data)
.map(|(txn_id, txn_data)| (Some(txn_id), txn_data))
.unwrap_or((None, None));
Self {
payment_id,
merchant_id,
attempt_id: id,
attempts_group_id: attempts_group_id.as_ref(),
status: *status,
amount: amount_details.get_net_amount(),
connector: connector.as_ref(),
error_message: error.as_ref().map(|error_details| &error_details.message),
surcharge_amount: amount_details.get_surcharge_amount(),
tax_amount: amount_details.get_tax_on_surcharge(),
payment_method_id: payment_method_id.as_ref(),
payment_method: *payment_method_type,
connector_transaction_id: connector_response_reference_id.as_ref(),
authentication_type: *authentication_type,
created_at: created_at.assume_utc(),
modified_at: modified_at.assume_utc(),
last_synced: last_synced.map(|i| i.assume_utc()),
cancellation_reason: cancellation_reason.as_ref(),
amount_to_capture: amount_details.get_amount_to_capture(),
browser_info: browser_info.as_ref(),
error_code: error.as_ref().map(|error_details| &error_details.code),
connector_metadata: connector_metadata.as_ref().map(|v| v.peek().to_string()),
payment_experience: payment_experience.as_ref(),
payment_method_type: payment_method_subtype,
payment_method_data: payment_method_data.as_ref().map(|v| v.peek().to_string()),
error_reason: error
.as_ref()
.and_then(|error_details| error_details.reason.as_ref()),
multiple_capture_count: *multiple_capture_count,
amount_capturable: amount_details.get_amount_capturable(),
merchant_connector_id: merchant_connector_id.as_ref(),
net_amount: amount_details.get_net_amount(),
unified_code: error
.as_ref()
.and_then(|error_details| error_details.unified_code.as_ref()),
unified_message: error
.as_ref()
.and_then(|error_details| error_details.unified_message.as_ref()),
client_source: client_source.as_ref(),
client_version: client_version.as_ref(),
profile_id,
organization_id,
card_network: payment_method_data
.as_ref()
.map(|data| data.peek())
.and_then(|data| data.as_object())
.and_then(|pm| pm.get("card"))
.and_then(|data| data.as_object())
.and_then(|card| card.get("card_network"))
.and_then(|network| network.as_str())
.map(|network| network.to_string()),
card_discovery: card_discovery.map(|discovery| discovery.to_string()),
payment_token: payment_token.clone(),
preprocessing_step_id: preprocessing_step_id.clone(),
connector_response_reference_id: connector_response_reference_id.clone(),
updated_by,
encoded_data: encoded_data.as_ref(),
external_three_ds_authentication_attempted: *external_three_ds_authentication_attempted,
authentication_connector: authentication_connector.clone(),
authentication_id: authentication_id
.as_ref()
.map(|id| id.get_string_repr().to_string()),
fingerprint_id: fingerprint_id.clone(),
customer_acceptance: customer_acceptance.as_ref(),
shipping_cost: amount_details.get_shipping_cost(),
order_tax_amount: amount_details.get_order_tax_amount(),
charges: charges.clone(),
processor_merchant_id,
created_by: created_by.as_ref(),
payment_method_type_v2: *payment_method_type,
connector_payment_id: connector_payment_id.as_ref().cloned(),
payment_method_subtype: *payment_method_subtype,
routing_result: routing_result.clone(),
authentication_applied: *authentication_applied,
external_reference_id: external_reference_id.clone(),
tax_on_surcharge: amount_details.get_tax_on_surcharge(),
payment_method_billing_address: payment_method_billing_address
.as_ref()
.map(|v| masking::Secret::new(v.get_inner())),
redirection_data: redirection_data.as_ref(),
connector_payment_data,
connector_token_details: connector_token_details.as_ref(),
feature_metadata: feature_metadata.as_ref(),
network_advice_code: error
.as_ref()
.and_then(|details| details.network_advice_code.clone()),
network_decline_code: error
.as_ref()
.and_then(|details| details.network_decline_code.clone()),
network_error_message: error
.as_ref()
.and_then(|details| details.network_error_message.clone()),
connector_request_reference_id: connector_request_reference_id.clone(),
}
}
}
impl super::KafkaMessage for KafkaPaymentAttemptEvent<'_> {
#[cfg(feature = "v1")]
fn key(&self) -> String {
format!(
"{}_{}_{}",
self.merchant_id.get_string_repr(),
self.payment_id.get_string_repr(),
self.attempt_id
)
}
#[cfg(feature = "v2")]
fn key(&self) -> String {
format!(
"{}_{}_{}",
self.merchant_id.get_string_repr(),
self.payment_id.get_string_repr(),
self.attempt_id.get_string_repr()
)
}
fn event_type(&self) -> crate::events::EventType {
crate::events::EventType::PaymentAttempt
}
}
|
crates/router/src/services/kafka/payment_attempt_event.rs
|
router
|
full_file
| null | null | null | 3,885
| null | null | null | null | null | null | null |
// Implementation: impl api::ConnectorVerifyWebhookSource for for Paypal
// File: crates/hyperswitch_connectors/src/connectors/paypal.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::ConnectorVerifyWebhookSource for for Paypal
|
crates/hyperswitch_connectors/src/connectors/paypal.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 61
| null |
Paypal
|
api::ConnectorVerifyWebhookSource for
| 0
| 0
| null | null |
// Function: populate_bin_details_for_payment_method_create
// File: crates/payment_methods/src/helpers.rs
// Module: payment_methods
pub fn populate_bin_details_for_payment_method_create(
_card_details: api_models::payment_methods::CardDetail,
_db: &dyn state::PaymentMethodsStorageInterface,
) -> api_models::payment_methods::CardDetail
|
crates/payment_methods/src/helpers.rs
|
payment_methods
|
function_signature
| null | null | null | 74
|
populate_bin_details_for_payment_method_create
| null | null | null | null | null | null |
// Trait: FrmMetricAccumulator
// File: crates/analytics/src/frm/accumulator.rs
// Module: analytics
pub trait FrmMetricAccumulator
|
crates/analytics/src/frm/accumulator.rs
|
analytics
|
trait_definition
| null | null | null | 34
| null | null |
FrmMetricAccumulator
| null | null | null | null |
// Implementation: impl RelayUpdate
// File: crates/hyperswitch_domain_models/src/relay.rs
// Module: hyperswitch_domain_models
// Methods: 1 total (1 public)
impl RelayUpdate
|
crates/hyperswitch_domain_models/src/relay.rs
|
hyperswitch_domain_models
|
impl_block
| null | null | null | 43
| null |
RelayUpdate
| null | 1
| 1
| null | null |
// Struct: RapydRefundRequest
// File: crates/hyperswitch_connectors/src/connectors/rapyd/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct RapydRefundRequest
|
crates/hyperswitch_connectors/src/connectors/rapyd/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
RapydRefundRequest
| 0
|
[] | 54
| null | null | null | null | null | null | null |
// Function: generate_profile_dispute_report
// File: crates/router/src/analytics.rs
// Module: router
pub fn generate_profile_dispute_report(
state: web::Data<AppState>,
req: actix_web::HttpRequest,
json_payload: web::Json<ReportRequest>,
) -> impl Responder
|
crates/router/src/analytics.rs
|
router
|
function_signature
| null | null | null | 67
|
generate_profile_dispute_report
| null | null | null | null | null | null |
// Function: get_eligibility_status
// File: crates/router/src/types/api/connector_onboarding/paypal.rs
// Module: router
pub fn get_eligibility_status(&self) -> RouterResult<api::PayPalOnboardingStatus>
|
crates/router/src/types/api/connector_onboarding/paypal.rs
|
router
|
function_signature
| null | null | null | 52
|
get_eligibility_status
| null | null | null | null | null | null |
// Implementation: impl api::PaymentVoid for for Trustpayments
// File: crates/hyperswitch_connectors/src/connectors/trustpayments.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::PaymentVoid for for Trustpayments
|
crates/hyperswitch_connectors/src/connectors/trustpayments.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 58
| null |
Trustpayments
|
api::PaymentVoid for
| 0
| 0
| null | null |
// Struct: Card
// File: crates/hyperswitch_connectors/src/connectors/dlocal/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct Card
|
crates/hyperswitch_connectors/src/connectors/dlocal/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
Card
| 0
|
[] | 43
| null | null | null | null | null | null | null |
// Function: get_incoming_webhook_event
// File: crates/hyperswitch_connectors/src/connectors/getnet/transformers.rs
// Module: hyperswitch_connectors
pub fn get_incoming_webhook_event(
transaction_type: GetnetTransactionType,
transaction_status: GetnetPaymentStatus,
) -> IncomingWebhookEvent
|
crates/hyperswitch_connectors/src/connectors/getnet/transformers.rs
|
hyperswitch_connectors
|
function_signature
| null | null | null | 71
|
get_incoming_webhook_event
| null | null | null | null | null | null |
// Implementation: impl api::PaymentSync for for Bluesnap
// File: crates/hyperswitch_connectors/src/connectors/bluesnap.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::PaymentSync for for Bluesnap
|
crates/hyperswitch_connectors/src/connectors/bluesnap.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 58
| null |
Bluesnap
|
api::PaymentSync for
| 0
| 0
| null | null |
// Implementation: impl BatchSampleDataInterface for for KafkaStore
// File: crates/router/src/db/kafka_store.rs
// Module: router
// Methods: 8 total (0 public)
impl BatchSampleDataInterface for for KafkaStore
|
crates/router/src/db/kafka_store.rs
|
router
|
impl_block
| null | null | null | 49
| null |
KafkaStore
|
BatchSampleDataInterface for
| 8
| 0
| null | null |
// Struct: RefundsRetrieveBody
// File: crates/api_models/src/refunds.rs
// Module: api_models
// Implementations: 0
pub struct RefundsRetrieveBody
|
crates/api_models/src/refunds.rs
|
api_models
|
struct_definition
|
RefundsRetrieveBody
| 0
|
[] | 38
| null | null | null | null | null | null | null |
// Implementation: impl api::Payment for for Worldpayvantiv
// File: crates/hyperswitch_connectors/src/connectors/worldpayvantiv.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::Payment for for Worldpayvantiv
|
crates/hyperswitch_connectors/src/connectors/worldpayvantiv.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 61
| null |
Worldpayvantiv
|
api::Payment for
| 0
| 0
| null | null |
// Function: get_payment_routing_algorithm
// File: crates/hyperswitch_domain_models/src/business_profile.rs
// Module: hyperswitch_domain_models
pub fn get_payment_routing_algorithm(
&self,
) -> CustomResult<
Option<api_models::routing::RoutingAlgorithmRef>,
api_error_response::ApiErrorResponse,
>
|
crates/hyperswitch_domain_models/src/business_profile.rs
|
hyperswitch_domain_models
|
function_signature
| null | null | null | 70
|
get_payment_routing_algorithm
| null | null | null | null | null | null |
// Function: flat_struct
// File: crates/router_derive/src/lib.rs
// Module: router_derive
pub fn flat_struct(&self) -> std::collections::HashMap<String, String>
|
crates/router_derive/src/lib.rs
|
router_derive
|
function_signature
| null | null | null | 41
|
flat_struct
| null | null | null | null | null | null |
// Module Structure
// File: crates/euclid/src/backend.rs
// Module: euclid
// Public submodules:
pub mod inputs;
pub mod interpreter;
pub mod vir_interpreter;
// Public exports:
pub use inputs::BackendInput;
pub use interpreter::InterpreterBackend;
pub use vir_interpreter::VirInterpreterBackend;
|
crates/euclid/src/backend.rs
|
euclid
|
module_structure
| null | null | null | 68
| null | null | null | null | null | 3
| 3
|
// Struct: GlobalpayRefundRequest
// File: crates/hyperswitch_connectors/src/connectors/globalpay/requests.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct GlobalpayRefundRequest
|
crates/hyperswitch_connectors/src/connectors/globalpay/requests.rs
|
hyperswitch_connectors
|
struct_definition
|
GlobalpayRefundRequest
| 0
|
[] | 50
| null | null | null | null | null | null | null |
// Function: validate_for_valid_refunds
// File: crates/router/src/core/utils/refunds_validator.rs
// Module: router
pub fn validate_for_valid_refunds(
payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,
connector: api_models::enums::Connector,
) -> RouterResult<()>
|
crates/router/src/core/utils/refunds_validator.rs
|
router
|
function_signature
| null | null | null | 69
|
validate_for_valid_refunds
| null | null | null | null | null | null |
// Function: new
// File: crates/hyperswitch_connectors/src/connectors/inespay.rs
// Module: hyperswitch_connectors
pub fn new() -> &'static Self
|
crates/hyperswitch_connectors/src/connectors/inespay.rs
|
hyperswitch_connectors
|
function_signature
| null | null | null | 39
|
new
| null | null | null | null | null | null |
// Implementation: impl PaymentCapture for for Riskified
// File: crates/hyperswitch_connectors/src/connectors/riskified.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl PaymentCapture for for Riskified
|
crates/hyperswitch_connectors/src/connectors/riskified.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 54
| null |
Riskified
|
PaymentCapture for
| 0
| 0
| null | null |
// Function: new
// File: crates/router/src/types/domain/user.rs
// Module: router
pub fn new(company_name: String) -> UserResult<Self>
|
crates/router/src/types/domain/user.rs
|
router
|
function_signature
| null | null | null | 34
|
new
| null | null | null | null | null | null |
// Implementation: impl FeatureMetadata
// File: crates/diesel_models/src/types.rs
// Module: diesel_models
// Methods: 3 total (3 public)
impl FeatureMetadata
|
crates/diesel_models/src/types.rs
|
diesel_models
|
impl_block
| null | null | null | 37
| null |
FeatureMetadata
| null | 3
| 3
| null | null |
// Function: get_org_refund_filters
// File: crates/router/src/analytics.rs
// Module: router
pub fn get_org_refund_filters(
state: web::Data<AppState>,
req: actix_web::HttpRequest,
json_payload: web::Json<GetRefundFilterRequest>,
) -> impl Responder
|
crates/router/src/analytics.rs
|
router
|
function_signature
| null | null | null | 70
|
get_org_refund_filters
| null | null | null | null | null | null |
// File: crates/analytics/src/payments/metrics/sessionized_metrics/payment_success_count.rs
// Module: analytics
use std::collections::HashSet;
use api_models::analytics::{
payments::{PaymentDimensions, PaymentFilters, PaymentMetricsBucketIdentifier},
Granularity, TimeRange,
};
use common_utils::errors::ReportSwitchExt;
use diesel_models::enums as storage_enums;
use error_stack::ResultExt;
use time::PrimitiveDateTime;
use super::PaymentMetricRow;
use crate::{
enums::AuthInfo,
query::{Aggregate, GroupByClause, QueryBuilder, QueryFilter, SeriesBucket, ToSql, Window},
types::{AnalyticsCollection, AnalyticsDataSource, MetricsError, MetricsResult},
};
#[derive(Default)]
pub(crate) struct PaymentSuccessCount;
#[async_trait::async_trait]
impl<T> super::PaymentMetric<T> for PaymentSuccessCount
where
T: AnalyticsDataSource + super::PaymentMetricAnalytics,
PrimitiveDateTime: ToSql<T>,
AnalyticsCollection: ToSql<T>,
Granularity: GroupByClause<T>,
Aggregate<&'static str>: ToSql<T>,
Window<&'static str>: ToSql<T>,
{
async fn load_metrics(
&self,
dimensions: &[PaymentDimensions],
auth: &AuthInfo,
filters: &PaymentFilters,
granularity: Option<Granularity>,
time_range: &TimeRange,
pool: &T,
) -> MetricsResult<HashSet<(PaymentMetricsBucketIdentifier, PaymentMetricRow)>> {
let mut query_builder: QueryBuilder<T> =
QueryBuilder::new(AnalyticsCollection::PaymentSessionized);
for dim in dimensions.iter() {
query_builder.add_select_column(dim).switch()?;
}
query_builder
.add_select_column(Aggregate::Count {
field: None,
alias: Some("count"),
})
.switch()?;
query_builder
.add_select_column(Aggregate::Min {
field: "created_at",
alias: Some("start_bucket"),
})
.switch()?;
query_builder
.add_select_column(Aggregate::Max {
field: "created_at",
alias: Some("end_bucket"),
})
.switch()?;
filters.set_filter_clause(&mut query_builder).switch()?;
auth.set_filter_clause(&mut query_builder).switch()?;
time_range
.set_filter_clause(&mut query_builder)
.attach_printable("Error filtering time range")
.switch()?;
for dim in dimensions.iter() {
query_builder
.add_group_by_clause(dim)
.attach_printable("Error grouping by dimensions")
.switch()?;
}
if let Some(granularity) = granularity {
granularity
.set_group_by_clause(&mut query_builder)
.attach_printable("Error adding granularity")
.switch()?;
}
query_builder
.add_filter_clause(
PaymentDimensions::PaymentStatus,
storage_enums::AttemptStatus::Charged,
)
.switch()?;
query_builder
.execute_query::<PaymentMetricRow, _>(pool)
.await
.change_context(MetricsError::QueryBuildingError)?
.change_context(MetricsError::QueryExecutionFailure)?
.into_iter()
.map(|i| {
Ok((
PaymentMetricsBucketIdentifier::new(
i.currency.as_ref().map(|i| i.0),
None,
i.connector.clone(),
i.authentication_type.as_ref().map(|i| i.0),
i.payment_method.clone(),
i.payment_method_type.clone(),
i.client_source.clone(),
i.client_version.clone(),
i.profile_id.clone(),
i.card_network.clone(),
i.merchant_id.clone(),
i.card_last_4.clone(),
i.card_issuer.clone(),
i.error_reason.clone(),
i.routing_approach.as_ref().map(|i| i.0.clone()),
i.signature_network.clone(),
i.is_issuer_regulated,
i.is_debit_routed,
TimeRange {
start_time: match (granularity, i.start_bucket) {
(Some(g), Some(st)) => g.clip_to_start(st)?,
_ => time_range.start_time,
},
end_time: granularity.as_ref().map_or_else(
|| Ok(time_range.end_time),
|g| i.end_bucket.map(|et| g.clip_to_end(et)).transpose(),
)?,
},
),
i,
))
})
.collect::<error_stack::Result<
HashSet<(PaymentMetricsBucketIdentifier, PaymentMetricRow)>,
crate::query::PostProcessingError,
>>()
.change_context(MetricsError::PostProcessingFailure)
}
}
|
crates/analytics/src/payments/metrics/sessionized_metrics/payment_success_count.rs
|
analytics
|
full_file
| null | null | null | 986
| null | null | null | null | null | null | null |
// Implementation: impl ConnectorValidation for for Tokenex
// File: crates/hyperswitch_connectors/src/connectors/tokenex.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl ConnectorValidation for for Tokenex
|
crates/hyperswitch_connectors/src/connectors/tokenex.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 53
| null |
Tokenex
|
ConnectorValidation for
| 0
| 0
| null | null |
// File: crates/hyperswitch_connectors/src/connectors/wellsfargo.rs
// Module: hyperswitch_connectors
// Public functions: 3
// Public structs: 1
pub mod transformers;
use std::sync::LazyLock;
use base64::Engine;
use common_enums::enums;
use common_utils::{
consts,
errors::CustomResult,
ext_traits::BytesExt,
request::{Method, Request, RequestBuilder, RequestContent},
types::{AmountConvertor, MinorUnit, StringMajorUnit, StringMajorUnitForConnector},
};
use error_stack::{report, Report, ResultExt};
use hyperswitch_domain_models::{
payment_method_data::PaymentMethodData,
router_data::{AccessToken, ErrorResponse, RouterData},
router_flow_types::{
access_token_auth::AccessTokenAuth,
mandate_revoke::MandateRevoke,
payments::{
Authorize, Capture, IncrementalAuthorization, PSync, PaymentMethodToken, Session,
SetupMandate, Void,
},
refunds::{Execute, RSync},
},
router_request_types::{
AccessTokenRequestData, MandateRevokeRequestData, PaymentMethodTokenizationData,
PaymentsAuthorizeData, PaymentsCancelData, PaymentsCaptureData,
PaymentsIncrementalAuthorizationData, PaymentsSessionData, PaymentsSyncData, RefundsData,
SetupMandateRequestData,
},
router_response_types::{
ConnectorInfo, MandateRevokeResponseData, PaymentMethodDetails, PaymentsResponseData,
RefundsResponseData, SupportedPaymentMethods, SupportedPaymentMethodsExt,
},
types::{
MandateRevokeRouterData, PaymentsAuthorizeRouterData, PaymentsCancelRouterData,
PaymentsCaptureRouterData, PaymentsIncrementalAuthorizationRouterData,
PaymentsSyncRouterData, RefundExecuteRouterData, RefundSyncRouterData,
SetupMandateRouterData,
},
};
use hyperswitch_interfaces::{
api::{
self,
refunds::{Refund, RefundExecute, RefundSync},
ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications,
ConnectorValidation,
},
configs::Connectors,
errors,
events::connector_api_logs::ConnectorEvent,
types::{
IncrementalAuthorizationType, MandateRevokeType, PaymentsAuthorizeType,
PaymentsCaptureType, PaymentsSyncType, PaymentsVoidType, RefundExecuteType, RefundSyncType,
Response, SetupMandateType,
},
webhooks,
};
use masking::{ExposeInterface, Mask, Maskable, PeekInterface};
use ring::{digest, hmac};
use time::OffsetDateTime;
use transformers as wellsfargo;
use url::Url;
use crate::{
constants::{self, headers},
types::ResponseRouterData,
utils::{self, convert_amount, PaymentMethodDataType, RefundsRequestData},
};
#[derive(Clone)]
pub struct Wellsfargo {
amount_converter: &'static (dyn AmountConvertor<Output = StringMajorUnit> + Sync),
}
impl Wellsfargo {
pub fn new() -> &'static Self {
&Self {
amount_converter: &StringMajorUnitForConnector,
}
}
pub fn generate_digest(&self, payload: &[u8]) -> String {
let payload_digest = digest::digest(&digest::SHA256, payload);
consts::BASE64_ENGINE.encode(payload_digest)
}
pub fn generate_signature(
&self,
auth: wellsfargo::WellsfargoAuthType,
host: String,
resource: &str,
payload: &String,
date: OffsetDateTime,
http_method: Method,
) -> CustomResult<String, errors::ConnectorError> {
let wellsfargo::WellsfargoAuthType {
api_key,
merchant_account,
api_secret,
} = auth;
let is_post_method = matches!(http_method, Method::Post);
let is_patch_method = matches!(http_method, Method::Patch);
let is_delete_method = matches!(http_method, Method::Delete);
let digest_str = if is_post_method || is_patch_method {
"digest "
} else {
""
};
let headers = format!("host date (request-target) {digest_str}v-c-merchant-id");
let request_target = if is_post_method {
format!("(request-target): post {resource}\ndigest: SHA-256={payload}\n")
} else if is_patch_method {
format!("(request-target): patch {resource}\ndigest: SHA-256={payload}\n")
} else if is_delete_method {
format!("(request-target): delete {resource}\n")
} else {
format!("(request-target): get {resource}\n")
};
let signature_string = format!(
"host: {host}\ndate: {date}\n{request_target}v-c-merchant-id: {}",
merchant_account.peek()
);
let key_value = consts::BASE64_ENGINE
.decode(api_secret.expose())
.change_context(errors::ConnectorError::InvalidConnectorConfig {
config: "connector_account_details.api_secret",
})?;
let key = hmac::Key::new(hmac::HMAC_SHA256, &key_value);
let signature_value =
consts::BASE64_ENGINE.encode(hmac::sign(&key, signature_string.as_bytes()).as_ref());
let signature_header = format!(
r#"keyid="{}", algorithm="HmacSHA256", headers="{headers}", signature="{signature_value}""#,
api_key.peek()
);
Ok(signature_header)
}
}
impl ConnectorCommon for Wellsfargo {
fn id(&self) -> &'static str {
"wellsfargo"
}
fn common_get_content_type(&self) -> &'static str {
"application/json;charset=utf-8"
}
fn base_url<'a>(&self, connectors: &'a Connectors) -> &'a str {
connectors.wellsfargo.base_url.as_ref()
}
fn get_currency_unit(&self) -> api::CurrencyUnit {
api::CurrencyUnit::Base
}
fn build_error_response(
&self,
res: Response,
event_builder: Option<&mut ConnectorEvent>,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
let response: Result<
wellsfargo::WellsfargoErrorResponse,
Report<common_utils::errors::ParsingError>,
> = res.response.parse_struct("Wellsfargo ErrorResponse");
let error_message = if res.status_code == 401 {
constants::CONNECTOR_UNAUTHORIZED_ERROR
} else {
hyperswitch_interfaces::consts::NO_ERROR_MESSAGE
};
match response {
Ok(transformers::WellsfargoErrorResponse::StandardError(response)) => {
event_builder.map(|i| i.set_error_response_body(&response));
router_env::logger::info!(connector_response=?response);
let (code, message, reason) = match response.error_information {
Some(ref error_info) => {
let detailed_error_info = error_info.details.as_ref().map(|details| {
details
.iter()
.map(|det| format!("{} : {}", det.field, det.reason))
.collect::<Vec<_>>()
.join(", ")
});
(
error_info.reason.clone(),
error_info.reason.clone(),
transformers::get_error_reason(
Some(error_info.message.clone()),
detailed_error_info,
None,
),
)
}
None => {
let detailed_error_info = response.details.map(|details| {
details
.iter()
.map(|det| format!("{} : {}", det.field, det.reason))
.collect::<Vec<_>>()
.join(", ")
});
(
response.reason.clone().map_or(
hyperswitch_interfaces::consts::NO_ERROR_CODE.to_string(),
|reason| reason.to_string(),
),
response
.reason
.map_or(error_message.to_string(), |reason| reason.to_string()),
transformers::get_error_reason(
response.message,
detailed_error_info,
None,
),
)
}
};
Ok(ErrorResponse {
status_code: res.status_code,
code,
message,
reason,
attempt_status: None,
connector_transaction_id: None,
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
connector_metadata: None,
})
}
Ok(transformers::WellsfargoErrorResponse::AuthenticationError(response)) => {
event_builder.map(|i| i.set_error_response_body(&response));
router_env::logger::info!(connector_response=?response);
Ok(ErrorResponse {
status_code: res.status_code,
code: hyperswitch_interfaces::consts::NO_ERROR_CODE.to_string(),
message: response.response.rmsg.clone(),
reason: Some(response.response.rmsg),
attempt_status: None,
connector_transaction_id: None,
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
connector_metadata: None,
})
}
Ok(transformers::WellsfargoErrorResponse::NotAvailableError(response)) => {
event_builder.map(|i| i.set_error_response_body(&response));
router_env::logger::info!(connector_response=?response);
let error_response = response
.errors
.iter()
.map(|error_info| {
format!(
"{}: {}",
error_info.error_type.clone().unwrap_or("".to_string()),
error_info.message.clone().unwrap_or("".to_string())
)
})
.collect::<Vec<String>>()
.join(" & ");
Ok(ErrorResponse {
status_code: res.status_code,
code: hyperswitch_interfaces::consts::NO_ERROR_CODE.to_string(),
message: error_response.clone(),
reason: Some(error_response),
attempt_status: None,
connector_transaction_id: None,
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
connector_metadata: None,
})
}
Err(error_msg) => {
event_builder.map(|event| event.set_error(serde_json::json!({"error": res.response.escape_ascii().to_string(), "status_code": res.status_code})));
router_env::logger::error!(deserialization_error =? error_msg);
utils::handle_json_response_deserialization_failure(res, "wellsfargo")
}
}
}
}
impl ConnectorValidation for Wellsfargo {
fn validate_mandate_payment(
&self,
pm_type: Option<enums::PaymentMethodType>,
pm_data: PaymentMethodData,
) -> CustomResult<(), errors::ConnectorError> {
let mandate_supported_pmd = std::collections::HashSet::from([
PaymentMethodDataType::Card,
PaymentMethodDataType::ApplePay,
PaymentMethodDataType::GooglePay,
]);
utils::is_mandate_supported(pm_data, pm_type, mandate_supported_pmd, self.id())
}
}
impl<Flow, Request, Response> ConnectorCommonExt<Flow, Request, Response> for Wellsfargo
where
Self: ConnectorIntegration<Flow, Request, Response>,
{
fn build_headers(
&self,
req: &RouterData<Flow, Request, Response>,
connectors: &Connectors,
) -> CustomResult<Vec<(String, Maskable<String>)>, errors::ConnectorError> {
let date = OffsetDateTime::now_utc();
let wellsfargo_req = self.get_request_body(req, connectors)?;
let auth = wellsfargo::WellsfargoAuthType::try_from(&req.connector_auth_type)?;
let merchant_account = auth.merchant_account.clone();
let base_url = connectors.wellsfargo.base_url.as_str();
let wellsfargo_host =
Url::parse(base_url).change_context(errors::ConnectorError::RequestEncodingFailed)?;
let host = wellsfargo_host
.host_str()
.ok_or(errors::ConnectorError::RequestEncodingFailed)?;
let path: String = self
.get_url(req, connectors)?
.chars()
.skip(base_url.len() - 1)
.collect();
let sha256 = self.generate_digest(wellsfargo_req.get_inner_value().expose().as_bytes());
let http_method = self.get_http_method();
let signature = self.generate_signature(
auth,
host.to_string(),
path.as_str(),
&sha256,
date,
http_method,
)?;
let mut headers = vec![
(
headers::CONTENT_TYPE.to_string(),
self.get_content_type().to_string().into(),
),
(
headers::ACCEPT.to_string(),
"application/hal+json;charset=utf-8".to_string().into(),
),
(
"v-c-merchant-id".to_string(),
merchant_account.into_masked(),
),
("Date".to_string(), date.to_string().into()),
("Host".to_string(), host.to_string().into()),
("Signature".to_string(), signature.into_masked()),
];
if matches!(http_method, Method::Post | Method::Put | Method::Patch) {
headers.push((
"Digest".to_string(),
format!("SHA-256={sha256}").into_masked(),
));
}
Ok(headers)
}
}
impl api::Payment for Wellsfargo {}
impl api::PaymentAuthorize for Wellsfargo {}
impl api::PaymentSync for Wellsfargo {}
impl api::PaymentVoid for Wellsfargo {}
impl api::PaymentCapture for Wellsfargo {}
impl api::PaymentIncrementalAuthorization for Wellsfargo {}
impl api::MandateSetup for Wellsfargo {}
impl api::ConnectorAccessToken for Wellsfargo {}
impl api::PaymentToken for Wellsfargo {}
impl api::ConnectorMandateRevoke for Wellsfargo {}
impl ConnectorIntegration<PaymentMethodToken, PaymentMethodTokenizationData, PaymentsResponseData>
for Wellsfargo
{
// Not Implemented (R)
}
impl ConnectorIntegration<SetupMandate, SetupMandateRequestData, PaymentsResponseData>
for Wellsfargo
{
fn get_headers(
&self,
req: &SetupMandateRouterData,
connectors: &Connectors,
) -> CustomResult<Vec<(String, Maskable<String>)>, errors::ConnectorError> {
self.build_headers(req, connectors)
}
fn get_content_type(&self) -> &'static str {
self.common_get_content_type()
}
fn get_url(
&self,
_req: &SetupMandateRouterData,
connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
Ok(format!("{}pts/v2/payments/", self.base_url(connectors)))
}
fn get_request_body(
&self,
req: &SetupMandateRouterData,
_connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
let connector_req = wellsfargo::WellsfargoZeroMandateRequest::try_from(req)?;
Ok(RequestContent::Json(Box::new(connector_req)))
}
fn build_request(
&self,
req: &SetupMandateRouterData,
connectors: &Connectors,
) -> CustomResult<Option<Request>, errors::ConnectorError> {
Ok(Some(
RequestBuilder::new()
.method(Method::Post)
.url(&SetupMandateType::get_url(self, req, connectors)?)
.attach_default_headers()
.headers(SetupMandateType::get_headers(self, req, connectors)?)
.set_body(SetupMandateType::get_request_body(self, req, connectors)?)
.build(),
))
}
fn handle_response(
&self,
data: &SetupMandateRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<SetupMandateRouterData, errors::ConnectorError> {
let response: wellsfargo::WellsfargoPaymentsResponse = res
.response
.parse_struct("WellsfargoSetupMandatesResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
RouterData::try_from(ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
})
}
fn get_error_response(
&self,
res: Response,
event_builder: Option<&mut ConnectorEvent>,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
self.build_error_response(res, event_builder)
}
fn get_5xx_error_response(
&self,
res: Response,
event_builder: Option<&mut ConnectorEvent>,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
let response: wellsfargo::WellsfargoServerErrorResponse = res
.response
.parse_struct("WellsfargoServerErrorResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|event| event.set_response_body(&response));
router_env::logger::info!(error_response=?response);
let attempt_status = match response.reason {
Some(reason) => match reason {
transformers::Reason::SystemError => Some(enums::AttemptStatus::Failure),
transformers::Reason::ServerTimeout | transformers::Reason::ServiceTimeout => None,
},
None => None,
};
Ok(ErrorResponse {
status_code: res.status_code,
reason: response.status.clone(),
code: response
.status
.unwrap_or(hyperswitch_interfaces::consts::NO_ERROR_CODE.to_string()),
message: response
.message
.unwrap_or(hyperswitch_interfaces::consts::NO_ERROR_MESSAGE.to_string()),
attempt_status,
connector_transaction_id: None,
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
connector_metadata: None,
})
}
}
impl ConnectorIntegration<MandateRevoke, MandateRevokeRequestData, MandateRevokeResponseData>
for Wellsfargo
{
fn get_headers(
&self,
req: &MandateRevokeRouterData,
connectors: &Connectors,
) -> CustomResult<Vec<(String, Maskable<String>)>, errors::ConnectorError> {
self.build_headers(req, connectors)
}
fn get_http_method(&self) -> Method {
Method::Delete
}
fn get_content_type(&self) -> &'static str {
self.common_get_content_type()
}
fn get_url(
&self,
req: &MandateRevokeRouterData,
connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
Ok(format!(
"{}tms/v1/paymentinstruments/{}",
self.base_url(connectors),
utils::RevokeMandateRequestData::get_connector_mandate_id(&req.request)?
))
}
fn build_request(
&self,
req: &MandateRevokeRouterData,
connectors: &Connectors,
) -> CustomResult<Option<Request>, errors::ConnectorError> {
Ok(Some(
RequestBuilder::new()
.method(Method::Delete)
.url(&MandateRevokeType::get_url(self, req, connectors)?)
.attach_default_headers()
.headers(MandateRevokeType::get_headers(self, req, connectors)?)
.build(),
))
}
fn handle_response(
&self,
data: &MandateRevokeRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<MandateRevokeRouterData, errors::ConnectorError> {
if matches!(res.status_code, 204) {
event_builder.map(|i| i.set_response_body(&serde_json::json!({"mandate_status": common_enums::MandateStatus::Revoked.to_string()})));
Ok(MandateRevokeRouterData {
response: Ok(MandateRevokeResponseData {
mandate_status: common_enums::MandateStatus::Revoked,
}),
..data.clone()
})
} else {
// If http_code != 204 || http_code != 4xx, we dont know any other response scenario yet.
let response_value: serde_json::Value = serde_json::from_slice(&res.response)
.change_context(errors::ConnectorError::ResponseHandlingFailed)?;
let response_string = response_value.to_string();
event_builder.map(|i| {
i.set_response_body(
&serde_json::json!({"response_string": response_string.clone()}),
)
});
router_env::logger::info!(connector_response=?response_string);
Ok(MandateRevokeRouterData {
response: Err(ErrorResponse {
code: hyperswitch_interfaces::consts::NO_ERROR_CODE.to_string(),
message: response_string.clone(),
reason: Some(response_string),
status_code: res.status_code,
attempt_status: None,
connector_transaction_id: None,
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
connector_metadata: None,
}),
..data.clone()
})
}
}
fn get_error_response(
&self,
res: Response,
event_builder: Option<&mut ConnectorEvent>,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
self.build_error_response(res, event_builder)
}
}
impl ConnectorIntegration<AccessTokenAuth, AccessTokenRequestData, AccessToken> for Wellsfargo {
// Not Implemented (R)
}
impl api::PaymentSession for Wellsfargo {}
impl ConnectorIntegration<Session, PaymentsSessionData, PaymentsResponseData> for Wellsfargo {}
impl ConnectorIntegration<Capture, PaymentsCaptureData, PaymentsResponseData> for Wellsfargo {
fn get_headers(
&self,
req: &PaymentsCaptureRouterData,
connectors: &Connectors,
) -> CustomResult<Vec<(String, Maskable<String>)>, errors::ConnectorError> {
self.build_headers(req, connectors)
}
fn get_content_type(&self) -> &'static str {
self.common_get_content_type()
}
fn get_url(
&self,
req: &PaymentsCaptureRouterData,
connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
let connector_payment_id = req.request.connector_transaction_id.clone();
Ok(format!(
"{}pts/v2/payments/{}/captures",
self.base_url(connectors),
connector_payment_id
))
}
fn get_request_body(
&self,
req: &PaymentsCaptureRouterData,
_connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
let amount = convert_amount(
self.amount_converter,
MinorUnit::new(req.request.amount_to_capture),
req.request.currency,
)?;
let connector_router_data = wellsfargo::WellsfargoRouterData::from((amount, req));
let connector_req =
wellsfargo::WellsfargoPaymentsCaptureRequest::try_from(&connector_router_data)?;
Ok(RequestContent::Json(Box::new(connector_req)))
}
fn build_request(
&self,
req: &PaymentsCaptureRouterData,
connectors: &Connectors,
) -> CustomResult<Option<Request>, errors::ConnectorError> {
Ok(Some(
RequestBuilder::new()
.method(Method::Post)
.url(&PaymentsCaptureType::get_url(self, req, connectors)?)
.attach_default_headers()
.headers(PaymentsCaptureType::get_headers(self, req, connectors)?)
.set_body(PaymentsCaptureType::get_request_body(
self, req, connectors,
)?)
.build(),
))
}
fn handle_response(
&self,
data: &PaymentsCaptureRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<
RouterData<Capture, PaymentsCaptureData, PaymentsResponseData>,
errors::ConnectorError,
> {
let response: wellsfargo::WellsfargoPaymentsResponse = res
.response
.parse_struct("Wellsfargo PaymentResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
RouterData::try_from(ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
})
}
fn get_error_response(
&self,
res: Response,
event_builder: Option<&mut ConnectorEvent>,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
self.build_error_response(res, event_builder)
}
fn get_5xx_error_response(
&self,
res: Response,
event_builder: Option<&mut ConnectorEvent>,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
let response: wellsfargo::WellsfargoServerErrorResponse = res
.response
.parse_struct("WellsfargoServerErrorResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|event| event.set_response_body(&response));
router_env::logger::info!(error_response=?response);
Ok(ErrorResponse {
status_code: res.status_code,
reason: response.status.clone(),
code: response
.status
.unwrap_or(hyperswitch_interfaces::consts::NO_ERROR_CODE.to_string()),
message: response
.message
.unwrap_or(hyperswitch_interfaces::consts::NO_ERROR_MESSAGE.to_string()),
attempt_status: None,
connector_transaction_id: None,
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
connector_metadata: None,
})
}
}
impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for Wellsfargo {
fn get_headers(
&self,
req: &PaymentsSyncRouterData,
connectors: &Connectors,
) -> CustomResult<Vec<(String, Maskable<String>)>, errors::ConnectorError> {
self.build_headers(req, connectors)
}
fn get_http_method(&self) -> Method {
Method::Get
}
fn get_url(
&self,
req: &PaymentsSyncRouterData,
connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
let connector_payment_id = req
.request
.connector_transaction_id
.get_connector_transaction_id()
.change_context(errors::ConnectorError::MissingConnectorTransactionID)?;
Ok(format!(
"{}tss/v2/transactions/{}",
self.base_url(connectors),
connector_payment_id
))
}
fn get_content_type(&self) -> &'static str {
self.common_get_content_type()
}
fn build_request(
&self,
req: &PaymentsSyncRouterData,
connectors: &Connectors,
) -> CustomResult<Option<Request>, errors::ConnectorError> {
Ok(Some(
RequestBuilder::new()
.method(Method::Get)
.url(&PaymentsSyncType::get_url(self, req, connectors)?)
.attach_default_headers()
.headers(PaymentsSyncType::get_headers(self, req, connectors)?)
.build(),
))
}
fn handle_response(
&self,
data: &PaymentsSyncRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<PaymentsSyncRouterData, errors::ConnectorError> {
let response: wellsfargo::WellsfargoTransactionResponse = res
.response
.parse_struct("Wellsfargo PaymentSyncResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
RouterData::try_from(ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
})
}
fn get_error_response(
&self,
res: Response,
event_builder: Option<&mut ConnectorEvent>,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
self.build_error_response(res, event_builder)
}
}
impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData> for Wellsfargo {
fn get_headers(
&self,
req: &PaymentsAuthorizeRouterData,
connectors: &Connectors,
) -> CustomResult<Vec<(String, Maskable<String>)>, errors::ConnectorError> {
self.build_headers(req, connectors)
}
fn get_content_type(&self) -> &'static str {
self.common_get_content_type()
}
fn get_url(
&self,
_req: &PaymentsAuthorizeRouterData,
connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
Ok(format!(
"{}pts/v2/payments/",
ConnectorCommon::base_url(self, connectors)
))
}
fn get_request_body(
&self,
req: &PaymentsAuthorizeRouterData,
_connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
let amount = convert_amount(
self.amount_converter,
MinorUnit::new(req.request.amount),
req.request.currency,
)?;
let connector_router_data = wellsfargo::WellsfargoRouterData::from((amount, req));
let connector_req =
wellsfargo::WellsfargoPaymentsRequest::try_from(&connector_router_data)?;
Ok(RequestContent::Json(Box::new(connector_req)))
}
fn build_request(
&self,
req: &PaymentsAuthorizeRouterData,
connectors: &Connectors,
) -> CustomResult<Option<Request>, errors::ConnectorError> {
let request = RequestBuilder::new()
.method(Method::Post)
.url(&PaymentsAuthorizeType::get_url(self, req, connectors)?)
.attach_default_headers()
.headers(PaymentsAuthorizeType::get_headers(self, req, connectors)?)
.set_body(self.get_request_body(req, connectors)?)
.build();
Ok(Some(request))
}
fn handle_response(
&self,
data: &PaymentsAuthorizeRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<PaymentsAuthorizeRouterData, errors::ConnectorError> {
let response: wellsfargo::WellsfargoPaymentsResponse = res
.response
.parse_struct("Wellsfargo PaymentResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
RouterData::try_from(ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
})
}
fn get_error_response(
&self,
res: Response,
event_builder: Option<&mut ConnectorEvent>,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
self.build_error_response(res, event_builder)
}
fn get_5xx_error_response(
&self,
res: Response,
event_builder: Option<&mut ConnectorEvent>,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
let response: wellsfargo::WellsfargoServerErrorResponse = res
.response
.parse_struct("WellsfargoServerErrorResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|event| event.set_response_body(&response));
router_env::logger::info!(error_response=?response);
let attempt_status = match response.reason {
Some(reason) => match reason {
transformers::Reason::SystemError => Some(enums::AttemptStatus::Failure),
transformers::Reason::ServerTimeout | transformers::Reason::ServiceTimeout => None,
},
None => None,
};
Ok(ErrorResponse {
status_code: res.status_code,
reason: response.status.clone(),
code: response
.status
.unwrap_or(hyperswitch_interfaces::consts::NO_ERROR_CODE.to_string()),
message: response
.message
.unwrap_or(hyperswitch_interfaces::consts::NO_ERROR_MESSAGE.to_string()),
attempt_status,
connector_transaction_id: None,
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
connector_metadata: None,
})
}
}
impl ConnectorIntegration<Void, PaymentsCancelData, PaymentsResponseData> for Wellsfargo {
fn get_headers(
&self,
req: &PaymentsCancelRouterData,
connectors: &Connectors,
) -> CustomResult<Vec<(String, Maskable<String>)>, errors::ConnectorError> {
self.build_headers(req, connectors)
}
fn get_url(
&self,
req: &PaymentsCancelRouterData,
connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
let connector_payment_id = req.request.connector_transaction_id.clone();
Ok(format!(
"{}pts/v2/payments/{connector_payment_id}/reversals",
self.base_url(connectors)
))
}
fn get_content_type(&self) -> &'static str {
self.common_get_content_type()
}
fn get_request_body(
&self,
req: &PaymentsCancelRouterData,
_connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
let amount = convert_amount(
self.amount_converter,
MinorUnit::new(req.request.amount.ok_or(
errors::ConnectorError::MissingRequiredField {
field_name: "Amount",
},
)?),
req.request
.currency
.ok_or(errors::ConnectorError::MissingRequiredField {
field_name: "Currency",
})?,
)?;
let connector_router_data = wellsfargo::WellsfargoRouterData::from((amount, req));
let connector_req = wellsfargo::WellsfargoVoidRequest::try_from(&connector_router_data)?;
Ok(RequestContent::Json(Box::new(connector_req)))
}
fn build_request(
&self,
req: &PaymentsCancelRouterData,
connectors: &Connectors,
) -> CustomResult<Option<Request>, errors::ConnectorError> {
Ok(Some(
RequestBuilder::new()
.method(Method::Post)
.url(&PaymentsVoidType::get_url(self, req, connectors)?)
.attach_default_headers()
.headers(PaymentsVoidType::get_headers(self, req, connectors)?)
.set_body(self.get_request_body(req, connectors)?)
.build(),
))
}
fn handle_response(
&self,
data: &PaymentsCancelRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<PaymentsCancelRouterData, errors::ConnectorError> {
let response: wellsfargo::WellsfargoPaymentsResponse = res
.response
.parse_struct("Wellsfargo PaymentResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
RouterData::try_from(ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
})
}
fn get_error_response(
&self,
res: Response,
event_builder: Option<&mut ConnectorEvent>,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
self.build_error_response(res, event_builder)
}
fn get_5xx_error_response(
&self,
res: Response,
event_builder: Option<&mut ConnectorEvent>,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
let response: wellsfargo::WellsfargoServerErrorResponse = res
.response
.parse_struct("WellsfargoServerErrorResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|event| event.set_response_body(&response));
router_env::logger::info!(error_response=?response);
Ok(ErrorResponse {
status_code: res.status_code,
reason: response.status.clone(),
code: response
.status
.unwrap_or(hyperswitch_interfaces::consts::NO_ERROR_CODE.to_string()),
message: response
.message
.unwrap_or(hyperswitch_interfaces::consts::NO_ERROR_MESSAGE.to_string()),
attempt_status: None,
connector_transaction_id: None,
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
connector_metadata: None,
})
}
}
impl Refund for Wellsfargo {}
impl RefundExecute for Wellsfargo {}
impl RefundSync for Wellsfargo {}
impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Wellsfargo {
fn get_headers(
&self,
req: &RefundExecuteRouterData,
connectors: &Connectors,
) -> CustomResult<Vec<(String, Maskable<String>)>, errors::ConnectorError> {
self.build_headers(req, connectors)
}
fn get_content_type(&self) -> &'static str {
self.common_get_content_type()
}
fn get_url(
&self,
req: &RefundExecuteRouterData,
|
crates/hyperswitch_connectors/src/connectors/wellsfargo.rs#chunk0
|
hyperswitch_connectors
|
chunk
| null | null | null | 8,187
| null | null | null | null | null | null | null |
// Function: get_merchant_id
// File: crates/router/src/types/domain/user.rs
// Module: router
pub fn get_merchant_id(&self) -> id_type::MerchantId
|
crates/router/src/types/domain/user.rs
|
router
|
function_signature
| null | null | null | 39
|
get_merchant_id
| null | null | null | null | null | null |
// Struct: SignatureKey
// File: crates/test_utils/src/connector_auth.rs
// Module: test_utils
// Implementations: 0
pub struct SignatureKey
|
crates/test_utils/src/connector_auth.rs
|
test_utils
|
struct_definition
|
SignatureKey
| 0
|
[] | 35
| null | null | null | null | null | null | null |
// Implementation: impl super::sdk_events::metrics::SdkEventMetricAnalytics for for ClickhouseClient
// File: crates/analytics/src/clickhouse.rs
// Module: analytics
// Methods: 0 total (0 public)
impl super::sdk_events::metrics::SdkEventMetricAnalytics for for ClickhouseClient
|
crates/analytics/src/clickhouse.rs
|
analytics
|
impl_block
| null | null | null | 65
| null |
ClickhouseClient
|
super::sdk_events::metrics::SdkEventMetricAnalytics for
| 0
| 0
| null | null |
// Function: get_dotted_jws
// File: crates/router/src/core/payment_methods/transformers.rs
// Module: router
pub fn get_dotted_jws(jws: encryption::JwsBody) -> String
|
crates/router/src/core/payment_methods/transformers.rs
|
router
|
function_signature
| null | null | null | 46
|
get_dotted_jws
| null | null | null | null | null | null |
// File: crates/openapi/src/routes/tokenization.rs
// Module: openapi
// Public functions: 2
use serde_json::json;
use utoipa::OpenApi;
/// Tokenization - Create
///
/// Create a token with customer_id
#[cfg(feature = "v2")]
#[utoipa::path(
post,
path = "/v2/tokenize",
request_body(
content = GenericTokenizationRequest,
examples(("Create a token with customer_id" = (
value = json!({
"customer_id": "12345_cus_0196d94b9c207333a297cbcf31f2e8c8",
"token_request": {
"payment_method_data": {
"card": {
"card_holder_name": "test name"
}
}
}
})
)))
),
responses(
(status = 200, description = "Token created successfully", body = GenericTokenizationResponse),
(status = 400, description = "Invalid request"),
(status = 401, description = "Unauthorized"),
(status = 500, description = "Internal server error")
),
tag = "Tokenization",
operation_id = "create_token_vault_api",
security(("ephemeral_key" = []),("api_key" = []))
)]
pub async fn create_token_vault_api() {}
/// Tokenization - Delete
///
/// Delete a token entry with customer_id and session_id
#[cfg(feature = "v2")]
#[utoipa::path(
delete,
path = "/v2/tokenize/{id}",
request_body(
content = DeleteTokenDataRequest,
examples(("Delete a token entry with customer_id and session_id" = (
value = json!({
"customer_id": "12345_cus_0196d94b9c207333a297cbcf31f2e8c8",
"session_id": "12345_pms_01926c58bc6e77c09e809964e72af8c8",
})
)))
),
responses(
(status = 200, description = "Token deleted successfully", body = DeleteTokenDataResponse),
(status = 400, description = "Invalid request"),
(status = 401, description = "Unauthorized"),
(status = 500, description = "Internal server error")
),
tag = "Tokenization",
operation_id = "delete_tokenized_data_api",
security(("ephemeral_key" = []),("api_key" = []))
)]
pub async fn delete_tokenized_data_api() {}
|
crates/openapi/src/routes/tokenization.rs
|
openapi
|
full_file
| null | null | null | 614
| null | null | null | null | null | null | null |
// Implementation: impl MerchantId
// File: crates/common_utils/src/id_type/merchant.rs
// Module: common_utils
// Methods: 6 total (6 public)
impl MerchantId
|
crates/common_utils/src/id_type/merchant.rs
|
common_utils
|
impl_block
| null | null | null | 39
| null |
MerchantId
| null | 6
| 6
| null | null |
// Struct: RecipientTokenRequest
// File: crates/hyperswitch_connectors/src/connectors/stripe/transformers/connect.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct RecipientTokenRequest
|
crates/hyperswitch_connectors/src/connectors/stripe/transformers/connect.rs
|
hyperswitch_connectors
|
struct_definition
|
RecipientTokenRequest
| 0
|
[] | 50
| null | null | null | null | null | null | null |
// Function: parent_group_info_request_to_permission_groups
// File: crates/router/src/utils/user_role.rs
// Module: router
pub fn parent_group_info_request_to_permission_groups(
parent_groups: &[role_api::ParentGroupInfoRequest],
) -> Result<Vec<PermissionGroup>, UserErrors>
|
crates/router/src/utils/user_role.rs
|
router
|
function_signature
| null | null | null | 61
|
parent_group_info_request_to_permission_groups
| null | null | null | null | null | null |
// File: crates/hyperswitch_connectors/src/connectors/hyperwallet.rs
// Module: hyperswitch_connectors
// Public functions: 1
// Public structs: 1
pub mod transformers;
use std::sync::LazyLock;
use common_enums::enums;
use common_utils::{
errors::CustomResult,
ext_traits::BytesExt,
request::{Method, Request, RequestBuilder, RequestContent},
types::{AmountConvertor, StringMinorUnit, StringMinorUnitForConnector},
};
use error_stack::{report, ResultExt};
use hyperswitch_domain_models::{
payment_method_data::PaymentMethodData,
router_data::{AccessToken, ConnectorAuthType, ErrorResponse, RouterData},
router_flow_types::{
access_token_auth::AccessTokenAuth,
payments::{Authorize, Capture, PSync, PaymentMethodToken, Session, SetupMandate, Void},
refunds::{Execute, RSync},
},
router_request_types::{
AccessTokenRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
PaymentsCancelData, PaymentsCaptureData, PaymentsSessionData, PaymentsSyncData,
RefundsData, SetupMandateRequestData,
},
router_response_types::{
ConnectorInfo, PaymentsResponseData, RefundsResponseData, SupportedPaymentMethods,
},
types::{
PaymentsAuthorizeRouterData, PaymentsCaptureRouterData, PaymentsSyncRouterData,
RefundSyncRouterData, RefundsRouterData,
},
};
use hyperswitch_interfaces::{
api::{
self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications,
ConnectorValidation,
},
configs::Connectors,
errors,
events::connector_api_logs::ConnectorEvent,
types::{self, Response},
webhooks,
};
use masking::{ExposeInterface, Mask};
use transformers as hyperwallet;
use crate::{constants::headers, types::ResponseRouterData, utils};
#[derive(Clone)]
pub struct Hyperwallet {
amount_converter: &'static (dyn AmountConvertor<Output = StringMinorUnit> + Sync),
}
impl Hyperwallet {
pub fn new() -> &'static Self {
&Self {
amount_converter: &StringMinorUnitForConnector,
}
}
}
impl api::Payment for Hyperwallet {}
impl api::PaymentSession for Hyperwallet {}
impl api::ConnectorAccessToken for Hyperwallet {}
impl api::MandateSetup for Hyperwallet {}
impl api::PaymentAuthorize for Hyperwallet {}
impl api::PaymentSync for Hyperwallet {}
impl api::PaymentCapture for Hyperwallet {}
impl api::PaymentVoid for Hyperwallet {}
impl api::Refund for Hyperwallet {}
impl api::RefundExecute for Hyperwallet {}
impl api::RefundSync for Hyperwallet {}
impl api::PaymentToken for Hyperwallet {}
impl ConnectorIntegration<PaymentMethodToken, PaymentMethodTokenizationData, PaymentsResponseData>
for Hyperwallet
{
// Not Implemented (R)
}
impl<Flow, Request, Response> ConnectorCommonExt<Flow, Request, Response> for Hyperwallet
where
Self: ConnectorIntegration<Flow, Request, Response>,
{
fn build_headers(
&self,
req: &RouterData<Flow, Request, Response>,
_connectors: &Connectors,
) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
let mut header = vec![(
headers::CONTENT_TYPE.to_string(),
self.get_content_type().to_string().into(),
)];
let mut api_key = self.get_auth_header(&req.connector_auth_type)?;
header.append(&mut api_key);
Ok(header)
}
}
impl ConnectorCommon for Hyperwallet {
fn id(&self) -> &'static str {
"hyperwallet"
}
fn get_currency_unit(&self) -> api::CurrencyUnit {
api::CurrencyUnit::Base
}
fn common_get_content_type(&self) -> &'static str {
"application/json"
}
fn base_url<'a>(&self, connectors: &'a Connectors) -> &'a str {
connectors.hyperwallet.base_url.as_ref()
}
fn get_auth_header(
&self,
auth_type: &ConnectorAuthType,
) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
let auth = hyperwallet::HyperwalletAuthType::try_from(auth_type)
.change_context(errors::ConnectorError::FailedToObtainAuthType)?;
Ok(vec![(
headers::AUTHORIZATION.to_string(),
auth.api_key.expose().into_masked(),
)])
}
fn build_error_response(
&self,
res: Response,
event_builder: Option<&mut ConnectorEvent>,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
let response: hyperwallet::HyperwalletErrorResponse = res
.response
.parse_struct("HyperwalletErrorResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
Ok(ErrorResponse {
status_code: res.status_code,
code: response.code,
message: response.message,
reason: response.reason,
attempt_status: None,
connector_transaction_id: None,
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
connector_metadata: None,
})
}
}
impl ConnectorValidation for Hyperwallet {
fn validate_mandate_payment(
&self,
_pm_type: Option<enums::PaymentMethodType>,
pm_data: PaymentMethodData,
) -> CustomResult<(), errors::ConnectorError> {
match pm_data {
PaymentMethodData::Card(_) => Err(errors::ConnectorError::NotImplemented(
"validate_mandate_payment does not support cards".to_string(),
)
.into()),
_ => Ok(()),
}
}
fn validate_psync_reference_id(
&self,
_data: &PaymentsSyncData,
_is_three_ds: bool,
_status: enums::AttemptStatus,
_connector_meta_data: Option<common_utils::pii::SecretSerdeValue>,
) -> CustomResult<(), errors::ConnectorError> {
Ok(())
}
}
impl ConnectorIntegration<Session, PaymentsSessionData, PaymentsResponseData> for Hyperwallet {
//TODO: implement sessions flow
}
impl ConnectorIntegration<AccessTokenAuth, AccessTokenRequestData, AccessToken> for Hyperwallet {}
impl ConnectorIntegration<SetupMandate, SetupMandateRequestData, PaymentsResponseData>
for Hyperwallet
{
}
impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData> for Hyperwallet {
fn get_headers(
&self,
req: &PaymentsAuthorizeRouterData,
connectors: &Connectors,
) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
self.build_headers(req, connectors)
}
fn get_content_type(&self) -> &'static str {
self.common_get_content_type()
}
fn get_url(
&self,
_req: &PaymentsAuthorizeRouterData,
_connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
}
fn get_request_body(
&self,
req: &PaymentsAuthorizeRouterData,
_connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
let amount = utils::convert_amount(
self.amount_converter,
req.request.minor_amount,
req.request.currency,
)?;
let connector_router_data = hyperwallet::HyperwalletRouterData::from((amount, req));
let connector_req =
hyperwallet::HyperwalletPaymentsRequest::try_from(&connector_router_data)?;
Ok(RequestContent::Json(Box::new(connector_req)))
}
fn build_request(
&self,
req: &PaymentsAuthorizeRouterData,
connectors: &Connectors,
) -> CustomResult<Option<Request>, errors::ConnectorError> {
Ok(Some(
RequestBuilder::new()
.method(Method::Post)
.url(&types::PaymentsAuthorizeType::get_url(
self, req, connectors,
)?)
.attach_default_headers()
.headers(types::PaymentsAuthorizeType::get_headers(
self, req, connectors,
)?)
.set_body(types::PaymentsAuthorizeType::get_request_body(
self, req, connectors,
)?)
.build(),
))
}
fn handle_response(
&self,
data: &PaymentsAuthorizeRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<PaymentsAuthorizeRouterData, errors::ConnectorError> {
let response: hyperwallet::HyperwalletPaymentsResponse = res
.response
.parse_struct("Hyperwallet PaymentsAuthorizeResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
RouterData::try_from(ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
})
}
fn get_error_response(
&self,
res: Response,
event_builder: Option<&mut ConnectorEvent>,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
self.build_error_response(res, event_builder)
}
}
impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for Hyperwallet {
fn get_headers(
&self,
req: &PaymentsSyncRouterData,
connectors: &Connectors,
) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
self.build_headers(req, connectors)
}
fn get_content_type(&self) -> &'static str {
self.common_get_content_type()
}
fn get_url(
&self,
_req: &PaymentsSyncRouterData,
_connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
}
fn build_request(
&self,
req: &PaymentsSyncRouterData,
connectors: &Connectors,
) -> CustomResult<Option<Request>, errors::ConnectorError> {
Ok(Some(
RequestBuilder::new()
.method(Method::Get)
.url(&types::PaymentsSyncType::get_url(self, req, connectors)?)
.attach_default_headers()
.headers(types::PaymentsSyncType::get_headers(self, req, connectors)?)
.build(),
))
}
fn handle_response(
&self,
data: &PaymentsSyncRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<PaymentsSyncRouterData, errors::ConnectorError> {
let response: hyperwallet::HyperwalletPaymentsResponse = res
.response
.parse_struct("hyperwallet PaymentsSyncResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
RouterData::try_from(ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
})
}
fn get_error_response(
&self,
res: Response,
event_builder: Option<&mut ConnectorEvent>,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
self.build_error_response(res, event_builder)
}
}
impl ConnectorIntegration<Capture, PaymentsCaptureData, PaymentsResponseData> for Hyperwallet {
fn get_headers(
&self,
req: &PaymentsCaptureRouterData,
connectors: &Connectors,
) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
self.build_headers(req, connectors)
}
fn get_content_type(&self) -> &'static str {
self.common_get_content_type()
}
fn get_url(
&self,
_req: &PaymentsCaptureRouterData,
_connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
}
fn get_request_body(
&self,
_req: &PaymentsCaptureRouterData,
_connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
Err(errors::ConnectorError::NotImplemented("get_request_body method".to_string()).into())
}
fn build_request(
&self,
req: &PaymentsCaptureRouterData,
connectors: &Connectors,
) -> CustomResult<Option<Request>, errors::ConnectorError> {
Ok(Some(
RequestBuilder::new()
.method(Method::Post)
.url(&types::PaymentsCaptureType::get_url(self, req, connectors)?)
.attach_default_headers()
.headers(types::PaymentsCaptureType::get_headers(
self, req, connectors,
)?)
.set_body(types::PaymentsCaptureType::get_request_body(
self, req, connectors,
)?)
.build(),
))
}
fn handle_response(
&self,
data: &PaymentsCaptureRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<PaymentsCaptureRouterData, errors::ConnectorError> {
let response: hyperwallet::HyperwalletPaymentsResponse = res
.response
.parse_struct("Hyperwallet PaymentsCaptureResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
RouterData::try_from(ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
})
}
fn get_error_response(
&self,
res: Response,
event_builder: Option<&mut ConnectorEvent>,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
self.build_error_response(res, event_builder)
}
}
impl ConnectorIntegration<Void, PaymentsCancelData, PaymentsResponseData> for Hyperwallet {}
impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Hyperwallet {
fn get_headers(
&self,
req: &RefundsRouterData<Execute>,
connectors: &Connectors,
) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
self.build_headers(req, connectors)
}
fn get_content_type(&self) -> &'static str {
self.common_get_content_type()
}
fn get_url(
&self,
_req: &RefundsRouterData<Execute>,
_connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
}
fn get_request_body(
&self,
req: &RefundsRouterData<Execute>,
_connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
let refund_amount = utils::convert_amount(
self.amount_converter,
req.request.minor_refund_amount,
req.request.currency,
)?;
let connector_router_data = hyperwallet::HyperwalletRouterData::from((refund_amount, req));
let connector_req =
hyperwallet::HyperwalletRefundRequest::try_from(&connector_router_data)?;
Ok(RequestContent::Json(Box::new(connector_req)))
}
fn build_request(
&self,
req: &RefundsRouterData<Execute>,
connectors: &Connectors,
) -> CustomResult<Option<Request>, errors::ConnectorError> {
let request = RequestBuilder::new()
.method(Method::Post)
.url(&types::RefundExecuteType::get_url(self, req, connectors)?)
.attach_default_headers()
.headers(types::RefundExecuteType::get_headers(
self, req, connectors,
)?)
.set_body(types::RefundExecuteType::get_request_body(
self, req, connectors,
)?)
.build();
Ok(Some(request))
}
fn handle_response(
&self,
data: &RefundsRouterData<Execute>,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<RefundsRouterData<Execute>, errors::ConnectorError> {
let response: hyperwallet::RefundResponse = res
.response
.parse_struct("hyperwallet RefundResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
RouterData::try_from(ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
})
}
fn get_error_response(
&self,
res: Response,
event_builder: Option<&mut ConnectorEvent>,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
self.build_error_response(res, event_builder)
}
}
impl ConnectorIntegration<RSync, RefundsData, RefundsResponseData> for Hyperwallet {
fn get_headers(
&self,
req: &RefundSyncRouterData,
connectors: &Connectors,
) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
self.build_headers(req, connectors)
}
fn get_content_type(&self) -> &'static str {
self.common_get_content_type()
}
fn get_url(
&self,
_req: &RefundSyncRouterData,
_connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
}
fn build_request(
&self,
req: &RefundSyncRouterData,
connectors: &Connectors,
) -> CustomResult<Option<Request>, errors::ConnectorError> {
Ok(Some(
RequestBuilder::new()
.method(Method::Get)
.url(&types::RefundSyncType::get_url(self, req, connectors)?)
.attach_default_headers()
.headers(types::RefundSyncType::get_headers(self, req, connectors)?)
.set_body(types::RefundSyncType::get_request_body(
self, req, connectors,
)?)
.build(),
))
}
fn handle_response(
&self,
data: &RefundSyncRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<RefundSyncRouterData, errors::ConnectorError> {
let response: hyperwallet::RefundResponse = res
.response
.parse_struct("hyperwallet RefundSyncResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
RouterData::try_from(ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
})
}
fn get_error_response(
&self,
res: Response,
event_builder: Option<&mut ConnectorEvent>,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
self.build_error_response(res, event_builder)
}
}
#[async_trait::async_trait]
impl webhooks::IncomingWebhook for Hyperwallet {
fn get_webhook_object_reference_id(
&self,
_request: &webhooks::IncomingWebhookRequestDetails<'_>,
) -> CustomResult<api_models::webhooks::ObjectReferenceId, errors::ConnectorError> {
Err(report!(errors::ConnectorError::WebhooksNotImplemented))
}
fn get_webhook_event_type(
&self,
_request: &webhooks::IncomingWebhookRequestDetails<'_>,
) -> CustomResult<api_models::webhooks::IncomingWebhookEvent, errors::ConnectorError> {
Err(report!(errors::ConnectorError::WebhooksNotImplemented))
}
fn get_webhook_resource_object(
&self,
_request: &webhooks::IncomingWebhookRequestDetails<'_>,
) -> CustomResult<Box<dyn masking::ErasedMaskSerialize>, errors::ConnectorError> {
Err(report!(errors::ConnectorError::WebhooksNotImplemented))
}
}
static HYPERWALLET_SUPPORTED_PAYMENT_METHODS: LazyLock<SupportedPaymentMethods> =
LazyLock::new(SupportedPaymentMethods::new);
static HYPERWALLET_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo {
display_name: "Hyperwallet",
description: "Hyperwallet connector",
connector_type: enums::HyperswitchConnectorCategory::PayoutProcessor,
integration_status: enums::ConnectorIntegrationStatus::Alpha,
};
static HYPERWALLET_SUPPORTED_WEBHOOK_FLOWS: [enums::EventClass; 0] = [];
impl ConnectorSpecifications for Hyperwallet {
fn get_connector_about(&self) -> Option<&'static ConnectorInfo> {
Some(&HYPERWALLET_CONNECTOR_INFO)
}
fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> {
Some(&*HYPERWALLET_SUPPORTED_PAYMENT_METHODS)
}
fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> {
Some(&HYPERWALLET_SUPPORTED_WEBHOOK_FLOWS)
}
}
|
crates/hyperswitch_connectors/src/connectors/hyperwallet.rs
|
hyperswitch_connectors
|
full_file
| null | null | null | 4,672
| null | null | null | null | null | null | null |
// Struct: MerchantDefinedInformation
// File: crates/hyperswitch_connectors/src/connectors/barclaycard/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct MerchantDefinedInformation
|
crates/hyperswitch_connectors/src/connectors/barclaycard/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
MerchantDefinedInformation
| 0
|
[] | 49
| null | null | null | null | null | null | null |
// Function: create_link_token
// File: crates/router/src/core/pm_auth.rs
// Module: router
pub fn create_link_token(
_state: SessionState,
_merchant_context: domain::MerchantContext,
_payload: api_models::pm_auth::LinkTokenCreateRequest,
_headers: Option<hyperswitch_domain_models::payments::HeaderPayload>,
) -> RouterResponse<api_models::pm_auth::LinkTokenCreateResponse>
|
crates/router/src/core/pm_auth.rs
|
router
|
function_signature
| null | null | null | 94
|
create_link_token
| null | null | null | null | null | null |
// Struct: BraintreeRefundResponseData
// File: crates/hyperswitch_connectors/src/connectors/braintree/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct BraintreeRefundResponseData
|
crates/hyperswitch_connectors/src/connectors/braintree/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
BraintreeRefundResponseData
| 0
|
[] | 54
| null | null | null | null | null | null | null |
// Implementation: impl Iterator for for IterMut
// File: crates/hyperswitch_constraint_graph/src/dense_map.rs
// Module: hyperswitch_constraint_graph
// Methods: 1 total (0 public)
impl Iterator for for IterMut
|
crates/hyperswitch_constraint_graph/src/dense_map.rs
|
hyperswitch_constraint_graph
|
impl_block
| null | null | null | 50
| null |
IterMut
|
Iterator for
| 1
| 0
| null | null |
// Struct: DlocalPaymentsResponse
// File: crates/hyperswitch_connectors/src/connectors/dlocal/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct DlocalPaymentsResponse
|
crates/hyperswitch_connectors/src/connectors/dlocal/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
DlocalPaymentsResponse
| 0
|
[] | 49
| null | null | null | null | null | null | null |
// Function: log_authentication
// File: crates/router/src/services/kafka.rs
// Module: router
pub fn log_authentication(
&self,
authentication: &Authentication,
old_authentication: Option<Authentication>,
tenant_id: TenantID,
) -> MQResult<()>
|
crates/router/src/services/kafka.rs
|
router
|
function_signature
| null | null | null | 58
|
log_authentication
| null | null | null | null | null | null |
// File: crates/hyperswitch_domain_models/src/errors.rs
// Module: hyperswitch_domain_models
pub mod api_error_response;
|
crates/hyperswitch_domain_models/src/errors.rs
|
hyperswitch_domain_models
|
full_file
| null | null | null | 28
| null | null | null | null | null | null | null |
// Struct: NuveiItem
// File: crates/hyperswitch_connectors/src/connectors/nuvei/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct NuveiItem
|
crates/hyperswitch_connectors/src/connectors/nuvei/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
NuveiItem
| 0
|
[] | 51
| null | null | null | null | null | null | null |
res,
headers,
request_elapsed_time,
proxy_connector_http_status_code,
),
Err(_) => http_response_err(
r#"{
"error": {
"message": "Error serializing response from connector"
}
}"#,
),
}
}
Err(error) => log_and_return_error_response(error),
};
let response_code = res.status().as_u16();
tracing::Span::current().record("status_code", response_code);
let end_instant = Instant::now();
let request_duration = end_instant.saturating_duration_since(start_instant);
logger::info!(
tag = ?Tag::EndRequest,
time_taken_ms = request_duration.as_millis(),
);
res
}
pub fn log_and_return_error_response<T>(error: Report<T>) -> HttpResponse
where
T: error_stack::Context + Clone + ResponseError,
Report<T>: EmbedError,
{
logger::error!(?error);
HttpResponse::from_error(error.embed().current_context().clone())
}
pub trait EmbedError: Sized {
fn embed(self) -> Self {
self
}
}
impl EmbedError for Report<api_models::errors::types::ApiErrorResponse> {
fn embed(self) -> Self {
#[cfg(feature = "detailed_errors")]
{
let mut report = self;
let error_trace = serde_json::to_value(&report).ok().and_then(|inner| {
serde_json::from_value::<Vec<errors::NestedErrorStack<'_>>>(inner)
.ok()
.map(Into::<errors::VecLinearErrorStack<'_>>::into)
.map(serde_json::to_value)
.transpose()
.ok()
.flatten()
});
match report.downcast_mut::<api_models::errors::types::ApiErrorResponse>() {
None => {}
Some(inner) => {
inner.get_internal_error_mut().stacktrace = error_trace;
}
}
report
}
#[cfg(not(feature = "detailed_errors"))]
self
}
}
impl EmbedError
for Report<hyperswitch_domain_models::errors::api_error_response::ApiErrorResponse>
{
}
pub fn http_response_json<T: body::MessageBody + 'static>(response: T) -> HttpResponse {
HttpResponse::Ok()
.content_type(mime::APPLICATION_JSON)
.body(response)
}
pub fn http_server_error_json_response<T: body::MessageBody + 'static>(
response: T,
) -> HttpResponse {
HttpResponse::InternalServerError()
.content_type(mime::APPLICATION_JSON)
.body(response)
}
pub fn http_response_json_with_headers<T: body::MessageBody + 'static>(
response: T,
headers: Vec<(String, Maskable<String>)>,
request_duration: Option<Duration>,
status_code: Option<http::StatusCode>,
) -> HttpResponse {
let mut response_builder = HttpResponse::build(status_code.unwrap_or(http::StatusCode::OK));
for (header_name, header_value) in headers {
let is_sensitive_header = header_value.is_masked();
let mut header_value = header_value.into_inner();
if header_name == X_HS_LATENCY {
if let Some(request_duration) = request_duration {
if let Ok(external_latency) = header_value.parse::<u128>() {
let updated_duration = request_duration.as_millis() - external_latency;
header_value = updated_duration.to_string();
}
}
}
let mut header_value = match HeaderValue::from_str(header_value.as_str()) {
Ok(header_value) => header_value,
Err(error) => {
logger::error!(?error);
return http_server_error_json_response("Something Went Wrong");
}
};
if is_sensitive_header {
header_value.set_sensitive(true);
}
response_builder.append_header((header_name, header_value));
}
response_builder
.content_type(mime::APPLICATION_JSON)
.body(response)
}
pub fn http_response_plaintext<T: body::MessageBody + 'static>(res: T) -> HttpResponse {
HttpResponse::Ok().content_type(mime::TEXT_PLAIN).body(res)
}
pub fn http_response_file_data<T: body::MessageBody + 'static>(
res: T,
content_type: mime::Mime,
) -> HttpResponse {
HttpResponse::Ok().content_type(content_type).body(res)
}
pub fn http_response_html_data<T: body::MessageBody + 'static>(
res: T,
optional_headers: Option<HashSet<(&'static str, String)>>,
) -> HttpResponse {
let mut res_builder = HttpResponse::Ok();
res_builder.content_type(mime::TEXT_HTML);
if let Some(headers) = optional_headers {
for (key, value) in headers {
if let Ok(header_val) = HeaderValue::try_from(value) {
res_builder.insert_header((HeaderName::from_static(key), header_val));
}
}
}
res_builder.body(res)
}
pub fn http_response_ok() -> HttpResponse {
HttpResponse::Ok().finish()
}
pub fn http_redirect_response<T: body::MessageBody + 'static>(
response: T,
redirection_response: api::RedirectionResponse,
) -> HttpResponse {
HttpResponse::Ok()
.content_type(mime::APPLICATION_JSON)
.append_header((
"Location",
redirection_response.return_url_with_query_params,
))
.status(http::StatusCode::FOUND)
.body(response)
}
pub fn http_response_err<T: body::MessageBody + 'static>(response: T) -> HttpResponse {
HttpResponse::BadRequest()
.content_type(mime::APPLICATION_JSON)
.body(response)
}
pub trait Authenticate {
fn get_client_secret(&self) -> Option<&String> {
None
}
fn should_return_raw_response(&self) -> Option<bool> {
None
}
}
#[cfg(feature = "v2")]
impl Authenticate for api_models::payments::PaymentsConfirmIntentRequest {
fn should_return_raw_response(&self) -> Option<bool> {
self.return_raw_connector_response
}
}
#[cfg(feature = "v2")]
impl Authenticate for api_models::payments::ProxyPaymentsRequest {}
#[cfg(feature = "v2")]
impl Authenticate for api_models::payments::ExternalVaultProxyPaymentsRequest {}
#[cfg(feature = "v1")]
impl Authenticate for api_models::payments::PaymentsRequest {
fn get_client_secret(&self) -> Option<&String> {
self.client_secret.as_ref()
}
fn should_return_raw_response(&self) -> Option<bool> {
// In v1, this maps to `all_keys_required` to retain backward compatibility.
// The equivalent field in v2 is `return_raw_connector_response`.
self.all_keys_required
}
}
#[cfg(feature = "v1")]
impl Authenticate for api_models::payment_methods::PaymentMethodListRequest {
fn get_client_secret(&self) -> Option<&String> {
self.client_secret.as_ref()
}
}
#[cfg(feature = "v1")]
impl Authenticate for api_models::payments::PaymentsSessionRequest {
fn get_client_secret(&self) -> Option<&String> {
Some(&self.client_secret)
}
}
impl Authenticate for api_models::payments::PaymentsDynamicTaxCalculationRequest {
fn get_client_secret(&self) -> Option<&String> {
Some(self.client_secret.peek())
}
}
impl Authenticate for api_models::payments::PaymentsPostSessionTokensRequest {
fn get_client_secret(&self) -> Option<&String> {
Some(self.client_secret.peek())
}
}
impl Authenticate for api_models::payments::PaymentsUpdateMetadataRequest {}
impl Authenticate for api_models::payments::PaymentsRetrieveRequest {
#[cfg(feature = "v2")]
fn should_return_raw_response(&self) -> Option<bool> {
self.return_raw_connector_response
}
#[cfg(feature = "v1")]
fn should_return_raw_response(&self) -> Option<bool> {
// In v1, this maps to `all_keys_required` to retain backward compatibility.
// The equivalent field in v2 is `return_raw_connector_response`.
self.all_keys_required
}
}
impl Authenticate for api_models::payments::PaymentsCancelRequest {}
impl Authenticate for api_models::payments::PaymentsCancelPostCaptureRequest {}
impl Authenticate for api_models::payments::PaymentsCaptureRequest {}
impl Authenticate for api_models::payments::PaymentsIncrementalAuthorizationRequest {}
impl Authenticate for api_models::payments::PaymentsStartRequest {}
// impl Authenticate for api_models::payments::PaymentsApproveRequest {}
impl Authenticate for api_models::payments::PaymentsRejectRequest {}
// #[cfg(feature = "v2")]
// impl Authenticate for api_models::payments::PaymentsIntentResponse {}
pub fn build_redirection_form(
form: &RedirectForm,
payment_method_data: Option<PaymentMethodData>,
amount: String,
currency: String,
config: Settings,
) -> maud::Markup {
use maud::PreEscaped;
let logging_template =
include_str!("redirection/assets/redirect_error_logs_push.js").to_string();
match form {
RedirectForm::Form {
endpoint,
method,
form_fields,
} => maud::html! {
(maud::DOCTYPE)
html {
meta name="viewport" content="width=device-width, initial-scale=1";
head {
style {
r##"
"##
}
(PreEscaped(r##"
<style>
#loader1 {
width: 500px,
}
@media (max-width: 600px) {
#loader1 {
width: 200px
}
}
</style>
"##))
}
body style="background-color: #ffffff; padding: 20px; font-family: Arial, Helvetica, Sans-Serif;" {
div id="loader1" class="lottie" style="height: 150px; display: block; position: relative; margin-left: auto; margin-right: auto;" { "" }
(PreEscaped(r#"<script src="https://cdnjs.cloudflare.com/ajax/libs/bodymovin/5.7.4/lottie.min.js"></script>"#))
(PreEscaped(r#"
<script>
var anime = bodymovin.loadAnimation({
container: document.getElementById('loader1'),
renderer: 'svg',
loop: true,
autoplay: true,
name: 'hyperswitch loader',
animationData: {"v":"4.8.0","meta":{"g":"LottieFiles AE 3.1.1","a":"","k":"","d":"","tc":""},"fr":29.9700012207031,"ip":0,"op":31.0000012626559,"w":400,"h":250,"nm":"loader_shape","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"circle 2","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[278.25,202.671,0],"ix":2},"a":{"a":0,"k":[23.72,23.72,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[12.935,0],[0,-12.936],[-12.935,0],[0,12.935]],"o":[[-12.952,0],[0,12.935],[12.935,0],[0,-12.936]],"v":[[0,-23.471],[-23.47,0.001],[0,23.471],[23.47,0.001]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0,0.427451010311,0.976470648074,1],"ix":4},"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":10,"s":[10]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":19.99,"s":[100]},{"t":29.9800012211104,"s":[10]}],"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[23.72,23.721],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":48.0000019550801,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"square 2","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[196.25,201.271,0],"ix":2},"a":{"a":0,"k":[22.028,22.03,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[1.914,0],[0,0],[0,-1.914],[0,0],[-1.914,0],[0,0],[0,1.914],[0,0]],"o":[[0,0],[-1.914,0],[0,0],[0,1.914],[0,0],[1.914,0],[0,0],[0,-1.914]],"v":[[18.313,-21.779],[-18.312,-21.779],[-21.779,-18.313],[-21.779,18.314],[-18.312,21.779],[18.313,21.779],[21.779,18.314],[21.779,-18.313]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0,0.427451010311,0.976470648074,1],"ix":4},"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":5,"s":[10]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":14.99,"s":[100]},{"t":24.9800010174563,"s":[10]}],"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[22.028,22.029],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":47.0000019143492,"st":0,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"Triangle 2","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[116.25,200.703,0],"ix":2},"a":{"a":0,"k":[27.11,21.243,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0.558,-0.879],[0,0],[-1.133,0],[0,0],[0.609,0.947],[0,0]],"o":[[-0.558,-0.879],[0,0],[-0.609,0.947],[0,0],[1.133,0],[0,0],[0,0]],"v":[[1.209,-20.114],[-1.192,-20.114],[-26.251,18.795],[-25.051,20.993],[25.051,20.993],[26.251,18.795],[1.192,-20.114]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0,0.427451010311,0.976470648074,1],"ix":4},"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":0,"s":[10]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":9.99,"s":[100]},{"t":19.9800008138021,"s":[10]}],"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[27.11,21.243],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":48.0000019550801,"st":0,"bm":0}],"markers":[]}
})
</script>
"#))
h3 style="text-align: center;" { "Please wait while we process your payment..." }
form action=(PreEscaped(endpoint)) method=(method.to_string()) #payment_form {
@for (field, value) in form_fields {
input type="hidden" name=(field) value=(value);
}
}
(PreEscaped(format!(r#"
<script type="text/javascript"> {logging_template}
var frm = document.getElementById("payment_form");
var formFields = frm.querySelectorAll("input");
if (frm.method.toUpperCase() === "GET" && formFields.length === 0) {{
window.setTimeout(function () {{
window.location.href = frm.action;
}}, 300);
}} else {{
window.setTimeout(function () {{
frm.submit();
}}, 300);
}}
</script>
"#)))
}
}
},
RedirectForm::Html { html_data } => {
PreEscaped(format!("{html_data} <script>{logging_template}</script>"))
}
RedirectForm::BarclaycardAuthSetup {
access_token,
ddc_url,
reference_id,
} => {
maud::html! {
(maud::DOCTYPE)
html {
head {
meta name="viewport" content="width=device-width, initial-scale=1";
}
body style="background-color: #ffffff; padding: 20px; font-family: Arial, Helvetica, Sans-Serif;" {
div id="loader1" class="lottie" style="height: 150px; display: block; position: relative; margin-top: 150px; margin-left: auto; margin-right: auto;" { "" }
(PreEscaped(r#"<script src="https://cdnjs.cloudflare.com/ajax/libs/bodymovin/5.7.4/lottie.min.js"></script>"#))
(PreEscaped(r#"
<script>
var anime = bodymovin.loadAnimation({
container: document.getElementById('loader1'),
renderer: 'svg',
loop: true,
autoplay: true,
name: 'hyperswitch loader',
animationData: {"v":"4.8.0","meta":{"g":"LottieFiles AE 3.1.1","a":"","k":"","d":"","tc":""},"fr":29.9700012207031,"ip":0,"op":31.0000012626559,"w":400,"h":250,"nm":"loader_shape","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"circle 2","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[278.25,202.671,0],"ix":2},"a":{"a":0,"k":[23.72,23.72,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[12.935,0],[0,-12.936],[-12.935,0],[0,12.935]],"o":[[-12.952,0],[0,12.935],[12.935,0],[0,-12.936]],"v":[[0,-23.471],[-23.47,0.001],[0,23.471],[23.47,0.001]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0,0.427451010311,0.976470648074,1],"ix":4},"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":10,"s":[10]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":19.99,"s":[100]},{"t":29.9800012211104,"s":[10]}],"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[23.72,23.721],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":48.0000019550801,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"square 2","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[196.25,201.271,0],"ix":2},"a":{"a":0,"k":[22.028,22.03,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[1.914,0],[0,0],[0,-1.914],[0,0],[-1.914,0],[0,0],[0,1.914],[0,0]],"o":[[0,0],[-1.914,0],[0,0],[0,1.914],[0,0],[1.914,0],[0,0],[0,-1.914]],"v":[[18.313,-21.779],[-18.312,-21.779],[-21.779,-18.313],[-21.779,18.314],[-18.312,21.779],[18.313,21.779],[21.779,18.314],[21.779,-18.313]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0,0.427451010311,0.976470648074,1],"ix":4},"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":5,"s":[10]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":14.99,"s":[100]},{"t":24.9800010174563,"s":[10]}],"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[22.028,22.029],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":47.0000019143492,"st":0,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"Triangle 2","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[116.25,200.703,0],"ix":2},"a":{"a":0,"k":[27.11,21.243,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0.558,-0.879],[0,0],[-1.133,0],[0,0],[0.609,0.947],[0,0]],"o":[[-0.558,-0.879],[0,0],[-0.609,0.947],[0,0],[1.133,0],[0,0],[0,0]],"v":[[1.209,-20.114],[-1.192,-20.114],[-26.251,18.795],[-25.051,20.993],[25.051,20.993],[26.251,18.795],[1.192,-20.114]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0,0.427451010311,0.976470648074,1],"ix":4},"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":0,"s":[10]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":9.99,"s":[100]},{"t":19.9800008138021,"s":[10]}],"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[27.11,21.243],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":48.0000019550801,"st":0,"bm":0}],"markers":[]}
})
</script>
"#))
h3 style="text-align: center;" { "Please wait while we process your payment..." }
}
(PreEscaped(r#"<iframe id="cardinal_collection_iframe" name="collectionIframe" height="10" width="10" style="display: none;"></iframe>"#))
(PreEscaped(format!("<form id=\"cardinal_collection_form\" method=\"POST\" target=\"collectionIframe\" action=\"{ddc_url}\">
<input id=\"cardinal_collection_form_input\" type=\"hidden\" name=\"JWT\" value=\"{access_token}\">
</form>")))
(PreEscaped(r#"<script>
window.onload = function() {
var cardinalCollectionForm = document.querySelector('#cardinal_collection_form'); if(cardinalCollectionForm) cardinalCollectionForm.submit();
}
</script>"#))
(PreEscaped(format!("<script>
{logging_template}
window.addEventListener(\"message\", function(event) {{
if (event.origin === \"https://centinelapistag.cardinalcommerce.com\" || event.origin === \"https://centinelapi.cardinalcommerce.com\") {{
window.location.href = window.location.pathname.replace(/payments\\/redirect\\/(\\w+)\\/(\\w+)\\/\\w+/, \"payments/$1/$2/redirect/complete/cybersource?referenceId={reference_id}\");
}}
}}, false);
</script>
")))
}}
}
RedirectForm::BarclaycardConsumerAuth {
access_token,
step_up_url,
} => {
maud::html! {
(maud::DOCTYPE)
html {
head {
meta name="viewport" content="width=device-width, initial-scale=1";
}
body style="background-color: #ffffff; padding: 20px; font-family: Arial, Helvetica, Sans-Serif;" {
div id="loader1" class="lottie" style="height: 150px; display: block; position: relative; margin-top: 150px; margin-left: auto; margin-right: auto;" { "" }
(PreEscaped(r#"<script src="https://cdnjs.cloudflare.com/ajax/libs/bodymovin/5.7.4/lottie.min.js"></script>"#))
(PreEscaped(r#"
<script>
var anime = bodymovin.loadAnimation({
container: document.getElementById('loader1'),
renderer: 'svg',
loop: true,
autoplay: true,
name: 'hyperswitch loader',
|
crates/router/src/services/api.rs#chunk1
|
router
|
chunk
| null | null | null | 8,143
| null | null | null | null | null | null | null |
// Struct: PaymentAttemptRevenueRecoveryData
// File: crates/hyperswitch_domain_models/src/payments/payment_attempt.rs
// Module: hyperswitch_domain_models
// Implementations: 0
pub struct PaymentAttemptRevenueRecoveryData
|
crates/hyperswitch_domain_models/src/payments/payment_attempt.rs
|
hyperswitch_domain_models
|
struct_definition
|
PaymentAttemptRevenueRecoveryData
| 0
|
[] | 50
| null | null | null | null | null | null | null |
// File: crates/euclid_wasm/src/utils.rs
// Module: euclid_wasm
use wasm_bindgen::prelude::*;
pub trait JsResultExt<T> {
fn err_to_js(self) -> Result<T, JsValue>;
}
impl<T, E> JsResultExt<T> for Result<T, E>
where
E: serde::Serialize,
{
fn err_to_js(self) -> Result<T, JsValue> {
match self {
Ok(t) => Ok(t),
Err(e) => Err(serde_wasm_bindgen::to_value(&e)?),
}
}
}
|
crates/euclid_wasm/src/utils.rs
|
euclid_wasm
|
full_file
| null | null | null | 129
| null | null | null | null | null | null | null |
// Function: new
// File: crates/common_types/src/customers.rs
// Module: common_types
// Documentation: Creates a new `ConnectorCustomerMap` from a HashMap
pub fn new(
map: std::collections::HashMap<common_utils::id_type::MerchantConnectorAccountId, String>,
) -> Self
|
crates/common_types/src/customers.rs
|
common_types
|
function_signature
| null | null | null | 66
|
new
| null | null | null | null | null | null |
// Implementation: impl api::RefundExecute for for Hipay
// File: crates/hyperswitch_connectors/src/connectors/hipay.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::RefundExecute for for Hipay
|
crates/hyperswitch_connectors/src/connectors/hipay.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 60
| null |
Hipay
|
api::RefundExecute for
| 0
| 0
| null | null |
// Function: get_best_psp_token_available_for_smart_retry
// File: crates/router/src/workflows/revenue_recovery.rs
// Module: router
pub fn get_best_psp_token_available_for_smart_retry(
state: &SessionState,
connector_customer_id: &str,
payment_intent: &PaymentIntent,
) -> CustomResult<Option<time::PrimitiveDateTime>, errors::ProcessTrackerError>
|
crates/router/src/workflows/revenue_recovery.rs
|
router
|
function_signature
| null | null | null | 83
|
get_best_psp_token_available_for_smart_retry
| null | null | null | null | null | null |
sale_status: SaleStatus,
payme_transaction_id: Option<String>,
status_error_code: Option<u32>,
}
impl TryFrom<RefundsResponseRouterData<Execute, PaymeRefundResponse>>
for RefundsRouterData<Execute>
{
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
item: RefundsResponseRouterData<Execute, PaymeRefundResponse>,
) -> Result<Self, Self::Error> {
let refund_status = enums::RefundStatus::try_from(item.response.sale_status.clone())?;
let response = if utils::is_refund_failure(refund_status) {
let payme_response = &item.response;
let status_error_code = payme_response
.status_error_code
.map(|error_code| error_code.to_string());
Err(ErrorResponse {
code: status_error_code
.clone()
.unwrap_or_else(|| consts::NO_ERROR_CODE.to_string()),
message: status_error_code
.clone()
.unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()),
reason: status_error_code,
status_code: item.http_code,
attempt_status: None,
connector_transaction_id: payme_response.payme_transaction_id.clone(),
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
connector_metadata: None,
})
} else {
Ok(RefundsResponseData {
connector_refund_id: item
.response
.payme_transaction_id
.ok_or(errors::ConnectorError::MissingConnectorRefundID)?,
refund_status,
})
};
Ok(Self {
response,
..item.data
})
}
}
#[derive(Debug, Serialize)]
pub struct PaymeVoidRequest {
sale_currency: enums::Currency,
payme_sale_id: String,
seller_payme_id: Secret<String>,
language: String,
}
impl TryFrom<&PaymeRouterData<&RouterData<Void, PaymentsCancelData, PaymentsResponseData>>>
for PaymeVoidRequest
{
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
item: &PaymeRouterData<&RouterData<Void, PaymentsCancelData, PaymentsResponseData>>,
) -> Result<Self, Self::Error> {
let auth_type = PaymeAuthType::try_from(&item.router_data.connector_auth_type)?;
Ok(Self {
payme_sale_id: item.router_data.request.connector_transaction_id.clone(),
seller_payme_id: auth_type.seller_payme_id,
sale_currency: item.router_data.request.get_currency()?,
language: LANGUAGE.to_string(),
})
}
}
#[derive(Debug, Deserialize, Serialize)]
pub struct PaymeVoidResponse {
sale_status: SaleStatus,
payme_transaction_id: Option<String>,
status_error_code: Option<u32>,
}
impl TryFrom<PaymentsCancelResponseRouterData<PaymeVoidResponse>> for PaymentsCancelRouterData {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
item: PaymentsCancelResponseRouterData<PaymeVoidResponse>,
) -> Result<Self, Self::Error> {
let status = enums::AttemptStatus::from(item.response.sale_status.clone());
let response = if utils::is_payment_failure(status) {
let payme_response = &item.response;
let status_error_code = payme_response
.status_error_code
.map(|error_code| error_code.to_string());
Err(ErrorResponse {
code: status_error_code
.clone()
.unwrap_or_else(|| consts::NO_ERROR_CODE.to_string()),
message: status_error_code
.clone()
.unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()),
reason: status_error_code,
status_code: item.http_code,
attempt_status: None,
connector_transaction_id: payme_response.payme_transaction_id.clone(),
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
connector_metadata: None,
})
} else {
// Since we are not receiving payme_sale_id, we are not populating the transaction response
Ok(PaymentsResponseData::TransactionResponse {
resource_id: ResponseId::NoResponseId,
redirection_data: Box::new(None),
mandate_reference: Box::new(None),
connector_metadata: None,
network_txn_id: None,
connector_response_reference_id: None,
incremental_authorization_allowed: None,
charges: None,
})
};
Ok(Self {
status,
response,
..item.data
})
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct PaymeQueryTransactionResponse {
items: Vec<TransactionQuery>,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct TransactionQuery {
sale_status: SaleStatus,
payme_transaction_id: String,
}
impl<F, T> TryFrom<ResponseRouterData<F, PaymeQueryTransactionResponse, T, RefundsResponseData>>
for RouterData<F, T, RefundsResponseData>
{
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
item: ResponseRouterData<F, PaymeQueryTransactionResponse, T, RefundsResponseData>,
) -> Result<Self, Self::Error> {
let pay_sale_response = item
.response
.items
.first()
.ok_or(errors::ConnectorError::ResponseHandlingFailed)?;
let refund_status = enums::RefundStatus::try_from(pay_sale_response.sale_status.clone())?;
let response = if utils::is_refund_failure(refund_status) {
Err(ErrorResponse {
code: consts::NO_ERROR_CODE.to_string(),
message: consts::NO_ERROR_CODE.to_string(),
reason: None,
status_code: item.http_code,
attempt_status: None,
connector_transaction_id: Some(pay_sale_response.payme_transaction_id.clone()),
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
connector_metadata: None,
})
} else {
Ok(RefundsResponseData {
refund_status,
connector_refund_id: pay_sale_response.payme_transaction_id.clone(),
})
};
Ok(Self {
response,
..item.data
})
}
}
fn get_services(item: &PaymentsPreProcessingRouterData) -> Option<ThreeDs> {
match item.auth_type {
AuthenticationType::ThreeDs => {
let settings = ThreeDsSettings { active: true };
Some(ThreeDs {
name: ThreeDsType::ThreeDs,
settings,
})
}
AuthenticationType::NoThreeDs => None,
}
}
#[derive(Default, Debug, Serialize, Deserialize, PartialEq)]
pub struct PaymeErrorResponse {
pub status_code: u16,
pub status_error_details: String,
pub status_additional_info: serde_json::Value,
pub status_error_code: u32,
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum NotifyType {
SaleComplete,
SaleAuthorized,
Refund,
SaleFailure,
SaleChargeback,
SaleChargebackRefund,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct WebhookEventDataResource {
pub sale_status: SaleStatus,
pub payme_signature: Secret<String>,
pub buyer_key: Option<Secret<String>>,
pub notify_type: NotifyType,
pub payme_sale_id: String,
pub payme_transaction_id: String,
pub status_error_details: Option<String>,
pub status_error_code: Option<u32>,
pub price: MinorUnit,
pub currency: enums::Currency,
}
#[derive(Debug, Deserialize)]
pub struct WebhookEventDataResourceEvent {
pub notify_type: NotifyType,
}
#[derive(Debug, Deserialize)]
pub struct WebhookEventDataResourceSignature {
pub payme_signature: Secret<String>,
}
/// This try_from will ensure that webhook body would be properly parsed into PSync response
impl From<WebhookEventDataResource> for PaymePaySaleResponse {
fn from(value: WebhookEventDataResource) -> Self {
Self {
sale_status: value.sale_status,
payme_sale_id: value.payme_sale_id,
payme_transaction_id: Some(value.payme_transaction_id),
buyer_key: value.buyer_key,
sale_3ds: None,
redirect_url: None,
status_error_code: value.status_error_code,
status_error_details: value.status_error_details,
}
}
}
/// This try_from will ensure that webhook body would be properly parsed into RSync response
impl From<WebhookEventDataResource> for PaymeQueryTransactionResponse {
fn from(value: WebhookEventDataResource) -> Self {
let item = TransactionQuery {
sale_status: value.sale_status,
payme_transaction_id: value.payme_transaction_id,
};
Self { items: vec![item] }
}
}
impl From<NotifyType> for api_models::webhooks::IncomingWebhookEvent {
fn from(value: NotifyType) -> Self {
match value {
NotifyType::SaleComplete => Self::PaymentIntentSuccess,
NotifyType::Refund => Self::RefundSuccess,
NotifyType::SaleFailure => Self::PaymentIntentFailure,
NotifyType::SaleChargeback => Self::DisputeOpened,
NotifyType::SaleChargebackRefund => Self::DisputeWon,
NotifyType::SaleAuthorized => Self::EventNotSupported,
}
}
}
|
crates/hyperswitch_connectors/src/connectors/payme/transformers.rs#chunk1
|
hyperswitch_connectors
|
chunk
| null | null | null | 2,045
| null | null | null | null | null | null | null |
// Struct: AffirmPSyncResponse
// File: crates/hyperswitch_connectors/src/connectors/affirm/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct AffirmPSyncResponse
|
crates/hyperswitch_connectors/src/connectors/affirm/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
AffirmPSyncResponse
| 0
|
[] | 52
| null | null | null | null | null | null | null |
// Struct: TransactionDetailsUiConfiguration
// File: crates/api_models/src/admin.rs
// Module: api_models
// Implementations: 0
pub struct TransactionDetailsUiConfiguration
|
crates/api_models/src/admin.rs
|
api_models
|
struct_definition
|
TransactionDetailsUiConfiguration
| 0
|
[] | 37
| null | null | null | null | null | null | null |
// Module Structure
// File: crates/router/src/core/payments/types.rs
// Module: router
// Public exports:
pub use hyperswitch_domain_models::router_request_types::{
AuthenticationData, SplitRefundsRequest, StripeSplitRefund, SurchargeDetails,
};
|
crates/router/src/core/payments/types.rs
|
router
|
module_structure
| null | null | null | 55
| null | null | null | null | null | 0
| 1
|
// File: crates/diesel_models/src/hyperswitch_ai_interaction.rs
// Module: diesel_models
// Public structs: 2
use common_utils::encryption::Encryption;
use diesel::{self, Identifiable, Insertable, Queryable, Selectable};
use serde::{Deserialize, Serialize};
use time::PrimitiveDateTime;
use crate::schema::hyperswitch_ai_interaction;
#[derive(
Clone,
Debug,
Deserialize,
Identifiable,
Queryable,
Selectable,
Serialize,
router_derive::DebugAsDisplay,
)]
#[diesel(table_name = hyperswitch_ai_interaction, primary_key(id, created_at), check_for_backend(diesel::pg::Pg))]
pub struct HyperswitchAiInteraction {
pub id: String,
pub session_id: Option<String>,
pub user_id: Option<String>,
pub merchant_id: Option<String>,
pub profile_id: Option<String>,
pub org_id: Option<String>,
pub role_id: Option<String>,
pub user_query: Option<Encryption>,
pub response: Option<Encryption>,
pub database_query: Option<String>,
pub interaction_status: Option<String>,
pub created_at: PrimitiveDateTime,
}
#[derive(router_derive::Setter, Clone, Debug, Insertable, router_derive::DebugAsDisplay)]
#[diesel(table_name = hyperswitch_ai_interaction)]
pub struct HyperswitchAiInteractionNew {
pub id: String,
pub session_id: Option<String>,
pub user_id: Option<String>,
pub merchant_id: Option<String>,
pub profile_id: Option<String>,
pub org_id: Option<String>,
pub role_id: Option<String>,
pub user_query: Option<Encryption>,
pub response: Option<Encryption>,
pub database_query: Option<String>,
pub interaction_status: Option<String>,
pub created_at: PrimitiveDateTime,
}
|
crates/diesel_models/src/hyperswitch_ai_interaction.rs
|
diesel_models
|
full_file
| null | null | null | 386
| null | null | null | null | null | null | null |
// Implementation: impl api::RefundSync for for Nexixpay
// File: crates/hyperswitch_connectors/src/connectors/nexixpay.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::RefundSync for for Nexixpay
|
crates/hyperswitch_connectors/src/connectors/nexixpay.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 63
| null |
Nexixpay
|
api::RefundSync for
| 0
| 0
| null | null |
// File: crates/diesel_models/src/query/api_keys.rs
// Module: diesel_models
// Public functions: 6
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods};
use super::generics;
use crate::{
api_keys::{ApiKey, ApiKeyNew, ApiKeyUpdate, ApiKeyUpdateInternal, HashedApiKey},
errors,
schema::api_keys::dsl,
PgPooledConn, StorageResult,
};
impl ApiKeyNew {
pub async fn insert(self, conn: &PgPooledConn) -> StorageResult<ApiKey> {
generics::generic_insert(conn, self).await
}
}
impl ApiKey {
pub async fn update_by_merchant_id_key_id(
conn: &PgPooledConn,
merchant_id: common_utils::id_type::MerchantId,
key_id: common_utils::id_type::ApiKeyId,
api_key_update: ApiKeyUpdate,
) -> StorageResult<Self> {
match generics::generic_update_with_unique_predicate_get_result::<
<Self as HasTable>::Table,
_,
_,
_,
>(
conn,
dsl::merchant_id
.eq(merchant_id.to_owned())
.and(dsl::key_id.eq(key_id.to_owned())),
ApiKeyUpdateInternal::from(api_key_update),
)
.await
{
Err(error) => match error.current_context() {
errors::DatabaseError::NotFound => {
Err(error.attach_printable("API key with the given key ID does not exist"))
}
errors::DatabaseError::NoFieldsToUpdate => {
generics::generic_find_one::<<Self as HasTable>::Table, _, _>(
conn,
dsl::merchant_id
.eq(merchant_id.to_owned())
.and(dsl::key_id.eq(key_id.to_owned())),
)
.await
}
_ => Err(error),
},
result => result,
}
}
pub async fn revoke_by_merchant_id_key_id(
conn: &PgPooledConn,
merchant_id: &common_utils::id_type::MerchantId,
key_id: &common_utils::id_type::ApiKeyId,
) -> StorageResult<bool> {
generics::generic_delete::<<Self as HasTable>::Table, _>(
conn,
dsl::merchant_id
.eq(merchant_id.to_owned())
.and(dsl::key_id.eq(key_id.to_owned())),
)
.await
}
pub async fn find_optional_by_merchant_id_key_id(
conn: &PgPooledConn,
merchant_id: &common_utils::id_type::MerchantId,
key_id: &common_utils::id_type::ApiKeyId,
) -> StorageResult<Option<Self>> {
generics::generic_find_one_optional::<<Self as HasTable>::Table, _, _>(
conn,
dsl::merchant_id
.eq(merchant_id.to_owned())
.and(dsl::key_id.eq(key_id.to_owned())),
)
.await
}
pub async fn find_optional_by_hashed_api_key(
conn: &PgPooledConn,
hashed_api_key: HashedApiKey,
) -> StorageResult<Option<Self>> {
generics::generic_find_one_optional::<<Self as HasTable>::Table, _, _>(
conn,
dsl::hashed_api_key.eq(hashed_api_key),
)
.await
}
pub async fn find_by_merchant_id(
conn: &PgPooledConn,
merchant_id: &common_utils::id_type::MerchantId,
limit: Option<i64>,
offset: Option<i64>,
) -> StorageResult<Vec<Self>> {
generics::generic_filter::<<Self as HasTable>::Table, _, _, _>(
conn,
dsl::merchant_id.eq(merchant_id.to_owned()),
limit,
offset,
Some(dsl::created_at.asc()),
)
.await
}
}
|
crates/diesel_models/src/query/api_keys.rs
|
diesel_models
|
full_file
| null | null | null | 848
| null | null | null | null | null | null | null |
// Function: new
// File: crates/hyperswitch_domain_models/src/router_response_types.rs
// Module: hyperswitch_domain_models
pub fn new(
connector_customer_id: String,
name: Option<String>,
email: Option<String>,
billing_address: Option<AddressDetails>,
) -> Self
|
crates/hyperswitch_domain_models/src/router_response_types.rs
|
hyperswitch_domain_models
|
function_signature
| null | null | null | 64
|
new
| null | null | null | null | null | null |
// Implementation: impl api::Payment for for Tsys
// File: crates/hyperswitch_connectors/src/connectors/tsys.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::Payment for for Tsys
|
crates/hyperswitch_connectors/src/connectors/tsys.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 55
| null |
Tsys
|
api::Payment for
| 0
| 0
| null | null |
// File: crates/router_env/src/vergen.rs
// Module: router_env
// Public functions: 2
/// Configures the [`vergen`][::vergen] crate to generate the `cargo` build instructions.
///
/// This function should be typically called within build scripts to generate `cargo` build
/// instructions for the corresponding crate.
///
/// # Panics
///
/// Panics if `vergen` fails to generate `cargo` build instructions.
#[cfg(feature = "vergen")]
#[allow(clippy::expect_used)]
pub fn generate_cargo_instructions() {
use std::io::Write;
use vergen::EmitBuilder;
EmitBuilder::builder()
.cargo_debug()
.cargo_opt_level()
.cargo_target_triple()
.git_commit_timestamp()
.git_describe(true, true, None)
.git_sha(true)
.rustc_semver()
.rustc_commit_hash()
.emit()
.expect("Failed to generate `cargo` build instructions");
writeln!(
&mut std::io::stdout(),
"cargo:rustc-env=CARGO_PROFILE={}",
std::env::var("PROFILE").expect("Failed to obtain `cargo` profile")
)
.expect("Failed to set `CARGO_PROFILE` environment variable");
}
#[cfg(not(feature = "vergen"))]
pub fn generate_cargo_instructions() {}
|
crates/router_env/src/vergen.rs
|
router_env
|
full_file
| null | null | null | 297
| null | null | null | null | null | null | null |
// Implementation: impl ThemeNew
// File: crates/diesel_models/src/query/user/theme.rs
// Module: diesel_models
// Methods: 1 total (0 public)
impl ThemeNew
|
crates/diesel_models/src/query/user/theme.rs
|
diesel_models
|
impl_block
| null | null | null | 39
| null |
ThemeNew
| null | 1
| 0
| null | null |
// Implementation: impl Cybersource
// File: crates/hyperswitch_connectors/src/connectors/cybersource.rs
// Module: hyperswitch_connectors
// Methods: 2 total (2 public)
impl Cybersource
|
crates/hyperswitch_connectors/src/connectors/cybersource.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 49
| null |
Cybersource
| null | 2
| 2
| null | null |
// Implementation: impl api::PaymentSync for for Vgs
// File: crates/hyperswitch_connectors/src/connectors/vgs.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::PaymentSync for for Vgs
|
crates/hyperswitch_connectors/src/connectors/vgs.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 57
| null |
Vgs
|
api::PaymentSync for
| 0
| 0
| null | null |
// Implementation: impl Webhooks
// File: crates/router/src/compatibility/stripe/app.rs
// Module: router
// Methods: 1 total (1 public)
impl Webhooks
|
crates/router/src/compatibility/stripe/app.rs
|
router
|
impl_block
| null | null | null | 39
| null |
Webhooks
| null | 1
| 1
| null | null |
// File: crates/hyperswitch_connectors/src/connectors/braintree.rs
// Module: hyperswitch_connectors
// Public structs: 1
pub mod transformers;
use std::sync::LazyLock;
use api_models::webhooks::IncomingWebhookEvent;
use base64::Engine;
use common_enums::{enums, CallConnectorAction, PaymentAction};
use common_utils::{
consts::BASE64_ENGINE,
crypto,
errors::{CustomResult, ParsingError},
ext_traits::{BytesExt, XmlExt},
request::{Method, Request, RequestBuilder, RequestContent},
types::{
AmountConvertor, StringMajorUnit, StringMajorUnitForConnector, StringMinorUnit,
StringMinorUnitForConnector,
},
};
use error_stack::{report, Report, ResultExt};
use hyperswitch_domain_models::{
api::ApplicationResponse,
router_data::{AccessToken, ConnectorAuthType, ErrorResponse, RouterData},
router_flow_types::{
access_token_auth::AccessTokenAuth,
mandate_revoke::MandateRevoke,
payments::{Authorize, Capture, PSync, PaymentMethodToken, Session, SetupMandate, Void},
refunds::{Execute, RSync},
CompleteAuthorize,
},
router_request_types::{
AccessTokenRequestData, CompleteAuthorizeData, MandateRevokeRequestData,
PaymentMethodTokenizationData, PaymentsAuthorizeData, PaymentsCancelData,
PaymentsCaptureData, PaymentsSessionData, PaymentsSyncData, RefundsData,
SetupMandateRequestData,
},
router_response_types::{
ConnectorInfo, MandateRevokeResponseData, PaymentMethodDetails, PaymentsResponseData,
RefundsResponseData, SupportedPaymentMethods, SupportedPaymentMethodsExt,
},
types::{
MandateRevokeRouterData, PaymentsAuthorizeRouterData, PaymentsCancelRouterData,
PaymentsCaptureRouterData, PaymentsCompleteAuthorizeRouterData, PaymentsSyncRouterData,
RefundSyncRouterData, RefundsRouterData, TokenizationRouterData,
},
};
use hyperswitch_interfaces::{
api::{
self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorRedirectResponse,
ConnectorSpecifications, ConnectorValidation,
},
configs::Connectors,
consts::{NO_ERROR_CODE, NO_ERROR_MESSAGE},
disputes::DisputePayload,
errors,
events::connector_api_logs::ConnectorEvent,
types::{
MandateRevokeType, PaymentsAuthorizeType, PaymentsCaptureType,
PaymentsCompleteAuthorizeType, PaymentsSyncType, PaymentsVoidType, RefundExecuteType,
RefundSyncType, Response, TokenizationType,
},
webhooks::{IncomingWebhook, IncomingWebhookFlowError, IncomingWebhookRequestDetails},
};
use masking::{ExposeInterface, Mask, PeekInterface, Secret};
use ring::hmac;
use router_env::logger;
use sha1::{Digest, Sha1};
use transformers::{self as braintree, get_status};
use crate::{
constants::headers,
types::ResponseRouterData,
utils::{
self, convert_amount, is_mandate_supported, PaymentMethodDataType,
PaymentsAuthorizeRequestData, PaymentsCompleteAuthorizeRequestData,
},
};
#[derive(Clone)]
pub struct Braintree {
amount_converter: &'static (dyn AmountConvertor<Output = StringMajorUnit> + Sync),
amount_converter_webhooks: &'static (dyn AmountConvertor<Output = StringMinorUnit> + Sync),
}
impl Braintree {
pub const fn new() -> &'static Self {
&Self {
amount_converter: &StringMajorUnitForConnector,
amount_converter_webhooks: &StringMinorUnitForConnector,
}
}
}
pub const BRAINTREE_VERSION: &str = "Braintree-Version";
pub const BRAINTREE_VERSION_VALUE: &str = "2019-01-01";
impl<Flow, Request, Response> ConnectorCommonExt<Flow, Request, Response> for Braintree
where
Self: ConnectorIntegration<Flow, Request, Response>,
{
fn build_headers(
&self,
req: &RouterData<Flow, Request, Response>,
_connectors: &Connectors,
) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
let mut header = vec![
(
headers::CONTENT_TYPE.to_string(),
self.get_content_type().to_string().into(),
),
(
BRAINTREE_VERSION.to_string(),
BRAINTREE_VERSION_VALUE.to_string().into(),
),
];
let mut api_key = self.get_auth_header(&req.connector_auth_type)?;
header.append(&mut api_key);
Ok(header)
}
}
impl ConnectorCommon for Braintree {
fn id(&self) -> &'static str {
"braintree"
}
fn get_currency_unit(&self) -> api::CurrencyUnit {
api::CurrencyUnit::Base
}
fn base_url<'a>(&self, connectors: &'a Connectors) -> &'a str {
connectors.braintree.base_url.as_ref()
}
fn get_auth_header(
&self,
auth_type: &ConnectorAuthType,
) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
let auth = braintree::BraintreeAuthType::try_from(auth_type)
.change_context(errors::ConnectorError::FailedToObtainAuthType)?;
let auth_key = format!("{}:{}", auth.public_key.peek(), auth.private_key.peek());
let auth_header = format!("Basic {}", BASE64_ENGINE.encode(auth_key));
Ok(vec![(
headers::AUTHORIZATION.to_string(),
auth_header.into_masked(),
)])
}
fn build_error_response(
&self,
res: Response,
event_builder: Option<&mut ConnectorEvent>,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
let response: Result<braintree::ErrorResponses, Report<ParsingError>> =
res.response.parse_struct("Braintree Error Response");
match response {
Ok(braintree::ErrorResponses::BraintreeApiErrorResponse(response)) => {
event_builder.map(|i| i.set_error_response_body(&response));
router_env::logger::info!(connector_response=?response);
let error_object = response.api_error_response.errors;
let error = error_object.errors.first().or(error_object
.transaction
.as_ref()
.and_then(|transaction_error| {
transaction_error.errors.first().or(transaction_error
.credit_card
.as_ref()
.and_then(|credit_card_error| credit_card_error.errors.first()))
}));
let (code, message) = error.map_or(
(NO_ERROR_CODE.to_string(), NO_ERROR_MESSAGE.to_string()),
|error| (error.code.clone(), error.message.clone()),
);
Ok(ErrorResponse {
status_code: res.status_code,
code,
message,
reason: Some(response.api_error_response.message),
attempt_status: None,
connector_transaction_id: None,
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
connector_metadata: None,
})
}
Ok(braintree::ErrorResponses::BraintreeErrorResponse(response)) => {
event_builder.map(|i| i.set_error_response_body(&response));
router_env::logger::info!(connector_response=?response);
Ok(ErrorResponse {
status_code: res.status_code,
code: NO_ERROR_CODE.to_string(),
message: NO_ERROR_MESSAGE.to_string(),
reason: Some(response.errors),
attempt_status: None,
connector_transaction_id: None,
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
connector_metadata: None,
})
}
Err(error_msg) => {
event_builder.map(|event| event.set_error(serde_json::json!({"error": res.response.escape_ascii().to_string(), "status_code": res.status_code})));
logger::error!(deserialization_error =? error_msg);
utils::handle_json_response_deserialization_failure(res, "braintree")
}
}
}
}
impl ConnectorValidation for Braintree {
fn validate_mandate_payment(
&self,
pm_type: Option<enums::PaymentMethodType>,
pm_data: hyperswitch_domain_models::payment_method_data::PaymentMethodData,
) -> CustomResult<(), errors::ConnectorError> {
let mandate_supported_pmd = std::collections::HashSet::from([PaymentMethodDataType::Card]);
is_mandate_supported(pm_data, pm_type, mandate_supported_pmd, self.id())
}
}
impl api::Payment for Braintree {}
impl api::PaymentAuthorize for Braintree {}
impl api::PaymentSync for Braintree {}
impl api::PaymentVoid for Braintree {}
impl api::PaymentCapture for Braintree {}
impl api::PaymentsCompleteAuthorize for Braintree {}
impl api::PaymentSession for Braintree {}
impl api::ConnectorAccessToken for Braintree {}
impl api::ConnectorMandateRevoke for Braintree {}
impl ConnectorIntegration<AccessTokenAuth, AccessTokenRequestData, AccessToken> for Braintree {
// Not Implemented (R)
}
impl ConnectorIntegration<Session, PaymentsSessionData, PaymentsResponseData> for Braintree {}
impl api::PaymentToken for Braintree {}
impl ConnectorIntegration<PaymentMethodToken, PaymentMethodTokenizationData, PaymentsResponseData>
for Braintree
{
fn get_headers(
&self,
req: &TokenizationRouterData,
connectors: &Connectors,
) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
self.build_headers(req, connectors)
}
fn get_content_type(&self) -> &'static str {
self.common_get_content_type()
}
fn get_url(
&self,
_req: &TokenizationRouterData,
connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
Ok(self.base_url(connectors).to_string())
}
fn get_request_body(
&self,
req: &TokenizationRouterData,
_connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
let connector_req = transformers::BraintreeTokenRequest::try_from(req)?;
Ok(RequestContent::Json(Box::new(connector_req)))
}
fn build_request(
&self,
req: &TokenizationRouterData,
connectors: &Connectors,
) -> CustomResult<Option<Request>, errors::ConnectorError> {
Ok(Some(
RequestBuilder::new()
.method(Method::Post)
.url(&TokenizationType::get_url(self, req, connectors)?)
.attach_default_headers()
.headers(TokenizationType::get_headers(self, req, connectors)?)
.set_body(TokenizationType::get_request_body(self, req, connectors)?)
.build(),
))
}
fn handle_response(
&self,
data: &TokenizationRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<TokenizationRouterData, errors::ConnectorError>
where
PaymentsResponseData: Clone,
{
let response: transformers::BraintreeTokenResponse = res
.response
.parse_struct("BraintreeTokenResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
RouterData::try_from(ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
})
}
fn get_error_response(
&self,
res: Response,
event_builder: Option<&mut ConnectorEvent>,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
self.build_error_response(res, event_builder)
}
}
impl api::MandateSetup for Braintree {}
#[allow(dead_code)]
impl ConnectorIntegration<SetupMandate, SetupMandateRequestData, PaymentsResponseData>
for Braintree
{
// Not Implemented (R)
fn build_request(
&self,
_req: &RouterData<SetupMandate, SetupMandateRequestData, PaymentsResponseData>,
_connectors: &Connectors,
) -> CustomResult<Option<Request>, errors::ConnectorError> {
Err(
errors::ConnectorError::NotImplemented("Setup Mandate flow for Braintree".to_string())
.into(),
)
}
}
impl ConnectorIntegration<Capture, PaymentsCaptureData, PaymentsResponseData> for Braintree {
fn get_headers(
&self,
req: &PaymentsCaptureRouterData,
connectors: &Connectors,
) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
self.build_headers(req, connectors)
}
fn get_content_type(&self) -> &'static str {
self.common_get_content_type()
}
fn get_url(
&self,
_req: &PaymentsCaptureRouterData,
connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
Ok(self.base_url(connectors).to_string())
}
fn get_request_body(
&self,
req: &PaymentsCaptureRouterData,
_connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
let amount = convert_amount(
self.amount_converter,
req.request.minor_amount_to_capture,
req.request.currency,
)?;
let connector_router_data = braintree::BraintreeRouterData::try_from((amount, req))?;
let connector_req =
transformers::BraintreeCaptureRequest::try_from(&connector_router_data)?;
Ok(RequestContent::Json(Box::new(connector_req)))
}
fn build_request(
&self,
req: &PaymentsCaptureRouterData,
connectors: &Connectors,
) -> CustomResult<Option<Request>, errors::ConnectorError> {
Ok(Some(
RequestBuilder::new()
.method(Method::Post)
.url(&PaymentsCaptureType::get_url(self, req, connectors)?)
.attach_default_headers()
.headers(PaymentsCaptureType::get_headers(self, req, connectors)?)
.set_body(PaymentsCaptureType::get_request_body(
self, req, connectors,
)?)
.build(),
))
}
fn handle_response(
&self,
data: &PaymentsCaptureRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<PaymentsCaptureRouterData, errors::ConnectorError> {
let response: transformers::BraintreeCaptureResponse = res
.response
.parse_struct("Braintree PaymentsCaptureResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
RouterData::try_from(ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
})
}
fn get_error_response(
&self,
res: Response,
event_builder: Option<&mut ConnectorEvent>,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
self.build_error_response(res, event_builder)
}
}
impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for Braintree {
fn get_headers(
&self,
req: &PaymentsSyncRouterData,
connectors: &Connectors,
) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
self.build_headers(req, connectors)
}
fn get_content_type(&self) -> &'static str {
self.common_get_content_type()
}
fn get_url(
&self,
_req: &PaymentsSyncRouterData,
connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
Ok(self.base_url(connectors).to_string())
}
fn get_request_body(
&self,
req: &PaymentsSyncRouterData,
_connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
let connector_req = transformers::BraintreePSyncRequest::try_from(req)?;
Ok(RequestContent::Json(Box::new(connector_req)))
}
fn build_request(
&self,
req: &PaymentsSyncRouterData,
connectors: &Connectors,
) -> CustomResult<Option<Request>, errors::ConnectorError> {
Ok(Some(
RequestBuilder::new()
.method(Method::Post)
.url(&PaymentsSyncType::get_url(self, req, connectors)?)
.attach_default_headers()
.headers(PaymentsSyncType::get_headers(self, req, connectors)?)
.set_body(PaymentsSyncType::get_request_body(self, req, connectors)?)
.build(),
))
}
fn handle_response(
&self,
data: &PaymentsSyncRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<PaymentsSyncRouterData, errors::ConnectorError> {
let response: transformers::BraintreePSyncResponse = res
.response
.parse_struct("Braintree PaymentSyncResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
RouterData::try_from(ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
})
}
fn get_error_response(
&self,
res: Response,
event_builder: Option<&mut ConnectorEvent>,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
self.build_error_response(res, event_builder)
}
}
impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData> for Braintree {
fn get_headers(
&self,
req: &PaymentsAuthorizeRouterData,
connectors: &Connectors,
) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
self.build_headers(req, connectors)
}
fn get_url(
&self,
_req: &PaymentsAuthorizeRouterData,
connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
Ok(self.base_url(connectors).to_string())
}
fn build_request(
&self,
req: &PaymentsAuthorizeRouterData,
connectors: &Connectors,
) -> CustomResult<Option<Request>, errors::ConnectorError> {
Ok(Some(
RequestBuilder::new()
.method(Method::Post)
.url(&PaymentsAuthorizeType::get_url(self, req, connectors)?)
.attach_default_headers()
.headers(PaymentsAuthorizeType::get_headers(self, req, connectors)?)
.set_body(PaymentsAuthorizeType::get_request_body(
self, req, connectors,
)?)
.build(),
))
}
fn get_request_body(
&self,
req: &PaymentsAuthorizeRouterData,
_connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
let amount = convert_amount(
self.amount_converter,
req.request.minor_amount,
req.request.currency,
)?;
let connector_router_data = braintree::BraintreeRouterData::try_from((amount, req))?;
let connector_req: transformers::BraintreePaymentsRequest =
transformers::BraintreePaymentsRequest::try_from(&connector_router_data)?;
Ok(RequestContent::Json(Box::new(connector_req)))
}
fn handle_response(
&self,
data: &PaymentsAuthorizeRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<PaymentsAuthorizeRouterData, errors::ConnectorError> {
match data.request.is_auto_capture()? {
true => {
let response: transformers::BraintreePaymentsResponse = res
.response
.parse_struct("Braintree PaymentsResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
RouterData::try_from(ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
})
}
false => {
let response: transformers::BraintreeAuthResponse = res
.response
.parse_struct("Braintree AuthResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
RouterData::try_from(ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
})
}
}
}
fn get_error_response(
&self,
res: Response,
event_builder: Option<&mut ConnectorEvent>,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
self.build_error_response(res, event_builder)
}
}
impl ConnectorIntegration<MandateRevoke, MandateRevokeRequestData, MandateRevokeResponseData>
for Braintree
{
fn get_headers(
&self,
req: &MandateRevokeRouterData,
connectors: &Connectors,
) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
self.build_headers(req, connectors)
}
fn get_url(
&self,
_req: &MandateRevokeRouterData,
connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
Ok(self.base_url(connectors).to_string())
}
fn build_request(
&self,
req: &MandateRevokeRouterData,
connectors: &Connectors,
) -> CustomResult<Option<Request>, errors::ConnectorError> {
Ok(Some(
RequestBuilder::new()
.method(Method::Post)
.url(&MandateRevokeType::get_url(self, req, connectors)?)
.attach_default_headers()
.headers(MandateRevokeType::get_headers(self, req, connectors)?)
.set_body(MandateRevokeType::get_request_body(self, req, connectors)?)
.build(),
))
}
fn get_request_body(
&self,
req: &MandateRevokeRouterData,
_connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
let connector_req = transformers::BraintreeRevokeMandateRequest::try_from(req)?;
Ok(RequestContent::Json(Box::new(connector_req)))
}
fn handle_response(
&self,
data: &MandateRevokeRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<MandateRevokeRouterData, errors::ConnectorError> {
let response: transformers::BraintreeRevokeMandateResponse = res
.response
.parse_struct("BraintreeRevokeMandateResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
RouterData::try_from(ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
})
}
fn get_error_response(
&self,
res: Response,
event_builder: Option<&mut ConnectorEvent>,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
self.build_error_response(res, event_builder)
}
}
impl ConnectorIntegration<Void, PaymentsCancelData, PaymentsResponseData> for Braintree {
fn get_headers(
&self,
req: &PaymentsCancelRouterData,
connectors: &Connectors,
) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
self.build_headers(req, connectors)
}
fn get_content_type(&self) -> &'static str {
self.common_get_content_type()
}
fn get_url(
&self,
_req: &PaymentsCancelRouterData,
connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
Ok(self.base_url(connectors).to_string())
}
fn build_request(
&self,
req: &PaymentsCancelRouterData,
connectors: &Connectors,
) -> CustomResult<Option<Request>, errors::ConnectorError> {
Ok(Some(
RequestBuilder::new()
.method(Method::Post)
.url(&PaymentsVoidType::get_url(self, req, connectors)?)
.attach_default_headers()
.headers(PaymentsVoidType::get_headers(self, req, connectors)?)
.set_body(PaymentsVoidType::get_request_body(self, req, connectors)?)
.build(),
))
}
fn get_request_body(
&self,
req: &PaymentsCancelRouterData,
_connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
let connector_req = transformers::BraintreeCancelRequest::try_from(req)?;
Ok(RequestContent::Json(Box::new(connector_req)))
}
fn handle_response(
&self,
data: &PaymentsCancelRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<PaymentsCancelRouterData, errors::ConnectorError> {
let response: transformers::BraintreeCancelResponse = res
.response
.parse_struct("Braintree VoidResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
RouterData::try_from(ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
})
}
fn get_error_response(
&self,
res: Response,
event_builder: Option<&mut ConnectorEvent>,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
self.build_error_response(res, event_builder)
}
}
impl api::Refund for Braintree {}
impl api::RefundExecute for Braintree {}
impl api::RefundSync for Braintree {}
impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Braintree {
fn get_headers(
&self,
req: &RefundsRouterData<Execute>,
connectors: &Connectors,
) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
self.build_headers(req, connectors)
}
fn get_content_type(&self) -> &'static str {
self.common_get_content_type()
}
fn get_url(
&self,
_req: &RefundsRouterData<Execute>,
connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
Ok(self.base_url(connectors).to_string())
}
fn get_request_body(
&self,
req: &RefundsRouterData<Execute>,
_connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
let amount = convert_amount(
self.amount_converter,
req.request.minor_refund_amount,
req.request.currency,
)?;
let connector_router_data = braintree::BraintreeRouterData::try_from((amount, req))?;
let connector_req = transformers::BraintreeRefundRequest::try_from(connector_router_data)?;
Ok(RequestContent::Json(Box::new(connector_req)))
}
fn build_request(
&self,
req: &RefundsRouterData<Execute>,
connectors: &Connectors,
) -> CustomResult<Option<Request>, errors::ConnectorError> {
let request = RequestBuilder::new()
.method(Method::Post)
.url(&RefundExecuteType::get_url(self, req, connectors)?)
.attach_default_headers()
.headers(RefundExecuteType::get_headers(self, req, connectors)?)
.set_body(RefundExecuteType::get_request_body(self, req, connectors)?)
.build();
Ok(Some(request))
}
fn handle_response(
&self,
data: &RefundsRouterData<Execute>,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<RefundsRouterData<Execute>, errors::ConnectorError> {
let response: transformers::BraintreeRefundResponse = res
.response
.parse_struct("Braintree RefundResponse")
.change_context(errors::ConnectorError::RequestEncodingFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
RouterData::try_from(ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
})
}
fn get_error_response(
&self,
res: Response,
event_builder: Option<&mut ConnectorEvent>,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
self.build_error_response(res, event_builder)
}
}
impl ConnectorIntegration<RSync, RefundsData, RefundsResponseData> for Braintree {
fn get_headers(
&self,
req: &RefundSyncRouterData,
connectors: &Connectors,
) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
self.build_headers(req, connectors)
}
fn get_content_type(&self) -> &'static str {
self.common_get_content_type()
}
fn get_url(
&self,
_req: &RefundSyncRouterData,
connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
Ok(self.base_url(connectors).to_string())
}
fn get_request_body(
&self,
req: &RefundSyncRouterData,
_connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
let connector_req = transformers::BraintreeRSyncRequest::try_from(req)?;
Ok(RequestContent::Json(Box::new(connector_req)))
}
fn build_request(
&self,
req: &RefundSyncRouterData,
connectors: &Connectors,
) -> CustomResult<Option<Request>, errors::ConnectorError> {
Ok(Some(
RequestBuilder::new()
.method(Method::Post)
.url(&RefundSyncType::get_url(self, req, connectors)?)
.attach_default_headers()
.headers(RefundSyncType::get_headers(self, req, connectors)?)
.set_body(RefundSyncType::get_request_body(self, req, connectors)?)
.build(),
))
}
fn handle_response(
&self,
data: &RefundSyncRouterData,
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<RouterData<RSync, RefundsData, RefundsResponseData>, errors::ConnectorError>
{
let response: transformers::BraintreeRSyncResponse = res
.response
.parse_struct("Braintree RefundResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
RouterData::try_from(ResponseRouterData {
response,
data: data.clone(),
http_code: res.status_code,
})
}
fn get_error_response(
&self,
res: Response,
event_builder: Option<&mut ConnectorEvent>,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
self.build_error_response(res, event_builder)
}
}
#[async_trait::async_trait]
impl IncomingWebhook for Braintree {
fn get_webhook_source_verification_algorithm(
&self,
_request: &IncomingWebhookRequestDetails<'_>,
) -> CustomResult<Box<dyn crypto::VerifySignature + Send>, errors::ConnectorError> {
Ok(Box::new(crypto::HmacSha1))
}
fn get_webhook_source_verification_signature(
&self,
request: &IncomingWebhookRequestDetails<'_>,
connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets,
) -> CustomResult<Vec<u8>, errors::ConnectorError> {
let notif_item = get_webhook_object_from_body(request.body)
.change_context(errors::ConnectorError::WebhookSourceVerificationFailed)?;
let signature_pairs: Vec<(&str, &str)> = notif_item
.bt_signature
.split('&')
.collect::<Vec<&str>>()
.into_iter()
.map(|pair| pair.split_once('|').unwrap_or(("", "")))
.collect::<Vec<(_, _)>>();
let merchant_secret = connector_webhook_secrets
.additional_secret //public key
.clone()
.ok_or(errors::ConnectorError::WebhookVerificationSecretNotFound)?;
let signature = get_matching_webhook_signature(signature_pairs, merchant_secret.expose())
.ok_or(errors::ConnectorError::WebhookSignatureNotFound)?;
Ok(signature.as_bytes().to_vec())
}
fn get_webhook_source_verification_message(
&self,
request: &IncomingWebhookRequestDetails<'_>,
_merchant_id: &common_utils::id_type::MerchantId,
_connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets,
) -> CustomResult<Vec<u8>, errors::ConnectorError> {
let notify = get_webhook_object_from_body(request.body)
.change_context(errors::ConnectorError::WebhookSourceVerificationFailed)?;
let message = notify.bt_payload.to_string();
Ok(message.into_bytes())
}
async fn verify_webhook_source(
&self,
request: &IncomingWebhookRequestDetails<'_>,
merchant_id: &common_utils::id_type::MerchantId,
connector_webhook_details: Option<common_utils::pii::SecretSerdeValue>,
_connector_account_details: crypto::Encryptable<Secret<serde_json::Value>>,
connector_label: &str,
) -> CustomResult<bool, errors::ConnectorError> {
let connector_webhook_secrets = self
.get_webhook_source_verification_merchant_secret(
merchant_id,
connector_label,
connector_webhook_details,
)
.await
.change_context(errors::ConnectorError::WebhookSourceVerificationFailed)?;
let signature = self
.get_webhook_source_verification_signature(request, &connector_webhook_secrets)
.change_context(errors::ConnectorError::WebhookSignatureNotFound)?;
let message = self
.get_webhook_source_verification_message(
request,
merchant_id,
&connector_webhook_secrets,
)
.change_context(errors::ConnectorError::WebhookSourceVerificationFailed)?;
let sha1_hash_key = Sha1::digest(&connector_webhook_secrets.secret);
let signing_key = hmac::Key::new(
hmac::HMAC_SHA1_FOR_LEGACY_USE_ONLY,
sha1_hash_key.as_slice(),
);
let signed_messaged = hmac::sign(&signing_key, &message);
let payload_sign: String = hex::encode(signed_messaged);
Ok(payload_sign.as_bytes().eq(&signature))
}
fn get_webhook_object_reference_id(
&self,
_request: &IncomingWebhookRequestDetails<'_>,
) -> CustomResult<api_models::webhooks::ObjectReferenceId, errors::ConnectorError> {
let notif = get_webhook_object_from_body(_request.body)
.change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?;
let response = decode_webhook_payload(notif.bt_payload.replace('\n', "").as_bytes())?;
match response.dispute {
Some(dispute_data) => Ok(api_models::webhooks::ObjectReferenceId::PaymentId(
api_models::payments::PaymentIdType::ConnectorTransactionId(
dispute_data.transaction.id,
),
)),
None => Err(report!(errors::ConnectorError::WebhookReferenceIdNotFound)),
}
}
fn get_webhook_event_type(
&self,
request: &IncomingWebhookRequestDetails<'_>,
) -> CustomResult<IncomingWebhookEvent, errors::ConnectorError> {
let notif = get_webhook_object_from_body(request.body)
.change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?;
let response = decode_webhook_payload(notif.bt_payload.replace('\n', "").as_bytes())?;
Ok(get_status(response.kind.as_str()))
}
fn get_webhook_resource_object(
&self,
request: &IncomingWebhookRequestDetails<'_>,
) -> CustomResult<Box<dyn masking::ErasedMaskSerialize>, errors::ConnectorError> {
let notif = get_webhook_object_from_body(request.body)
.change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?;
let response = decode_webhook_payload(notif.bt_payload.replace('\n', "").as_bytes())?;
Ok(Box::new(response))
}
fn get_webhook_api_response(
&self,
_request: &IncomingWebhookRequestDetails<'_>,
_error_kind: Option<IncomingWebhookFlowError>,
|
crates/hyperswitch_connectors/src/connectors/braintree.rs#chunk0
|
hyperswitch_connectors
|
chunk
| null | null | null | 8,190
| null | null | null | null | null | null | null |
// Struct: CryptopayErrorData
// File: crates/hyperswitch_connectors/src/connectors/cryptopay/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct CryptopayErrorData
|
crates/hyperswitch_connectors/src/connectors/cryptopay/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
CryptopayErrorData
| 0
|
[] | 53
| null | null | null | null | null | null | null |
// Function: server
// File: crates/router/src/routes/app.rs
// Module: router
pub fn server(state: AppState) -> Scope
|
crates/router/src/routes/app.rs
|
router
|
function_signature
| null | null | null | 29
|
server
| null | null | null | null | null | null |
// Implementation: impl IncomingWebhook for for Nuvei
// File: crates/hyperswitch_connectors/src/connectors/nuvei.rs
// Module: hyperswitch_connectors
// Methods: 7 total (0 public)
impl IncomingWebhook for for Nuvei
|
crates/hyperswitch_connectors/src/connectors/nuvei.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 59
| null |
Nuvei
|
IncomingWebhook for
| 7
| 0
| null | null |
// Struct: AvsResponse
// File: crates/hyperswitch_connectors/src/connectors/fiservemea/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct AvsResponse
|
crates/hyperswitch_connectors/src/connectors/fiservemea/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
AvsResponse
| 0
|
[] | 50
| null | null | null | null | null | null | null |
// Struct: FeatureMatrixListResponse
// File: crates/api_models/src/feature_matrix.rs
// Module: api_models
// Implementations: 1
// Traits: common_utils::events::ApiEventMetric
pub struct FeatureMatrixListResponse
|
crates/api_models/src/feature_matrix.rs
|
api_models
|
struct_definition
|
FeatureMatrixListResponse
| 1
|
[
"common_utils::events::ApiEventMetric"
] | 51
| null | null | null | null | null | null | null |
// Struct: MandateLink
// File: crates/hyperswitch_connectors/src/connectors/gocardless/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct MandateLink
|
crates/hyperswitch_connectors/src/connectors/gocardless/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
MandateLink
| 0
|
[] | 48
| null | null | null | null | null | null | null |
// Struct: StripePaymentRetrieveBody
// File: crates/router/src/compatibility/stripe/payment_intents/types.rs
// Module: router
// Implementations: 0
pub struct StripePaymentRetrieveBody
|
crates/router/src/compatibility/stripe/payment_intents/types.rs
|
router
|
struct_definition
|
StripePaymentRetrieveBody
| 0
|
[] | 43
| null | null | null | null | null | null | null |
// Struct: RoutingEvaluateRequest
// File: crates/api_models/src/routing.rs
// Module: api_models
// Implementations: 1
// Traits: common_utils::events::ApiEventMetric
pub struct RoutingEvaluateRequest
|
crates/api_models/src/routing.rs
|
api_models
|
struct_definition
|
RoutingEvaluateRequest
| 1
|
[
"common_utils::events::ApiEventMetric"
] | 48
| null | null | null | null | null | null | null |
// Function: mk_add_card_response_hs
// File: crates/router/src/core/payment_methods/transformers.rs
// Module: router
pub fn mk_add_card_response_hs(
card: api::CardDetail,
card_reference: String,
req: api::PaymentMethodCreate,
merchant_id: &id_type::MerchantId,
) -> api::PaymentMethodResponse
|
crates/router/src/core/payment_methods/transformers.rs
|
router
|
function_signature
| null | null | null | 77
|
mk_add_card_response_hs
| null | null | null | null | null | null |
// Function: get_optional_stored_credential
// File: crates/hyperswitch_connectors/src/connectors/nuvei/transformers.rs
// Module: hyperswitch_connectors
pub fn get_optional_stored_credential(is_stored_credential: Option<bool>) -> Option<Self>
|
crates/hyperswitch_connectors/src/connectors/nuvei/transformers.rs
|
hyperswitch_connectors
|
function_signature
| null | null | null | 61
|
get_optional_stored_credential
| null | null | null | null | null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.