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
⌀ |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
// Implementation: impl Checkout
// File: crates/hyperswitch_connectors/src/connectors/checkout.rs
// Module: hyperswitch_connectors
// Methods: 1 total (1 public)
impl Checkout
|
crates/hyperswitch_connectors/src/connectors/checkout.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 43
| null |
Checkout
| null | 1
| 1
| null | null |
// Function: get_token
// File: crates/hyperswitch_connectors/src/connectors/novalnet/transformers.rs
// Module: hyperswitch_connectors
pub fn get_token(transaction_data: Option<&Self>) -> Option<String>
|
crates/hyperswitch_connectors/src/connectors/novalnet/transformers.rs
|
hyperswitch_connectors
|
function_signature
| null | null | null | 50
|
get_token
| null | null | null | null | null | null |
// Function: merchant_account_create
// File: crates/openapi/src/routes/merchant_account.rs
// Module: openapi
pub fn merchant_account_create()
|
crates/openapi/src/routes/merchant_account.rs
|
openapi
|
function_signature
| null | null | null | 32
|
merchant_account_create
| null | null | null | null | null | null |
// Implementation: impl api::Payment for for Placetopay
// File: crates/hyperswitch_connectors/src/connectors/placetopay.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::Payment for for Placetopay
|
crates/hyperswitch_connectors/src/connectors/placetopay.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 61
| null |
Placetopay
|
api::Payment for
| 0
| 0
| null | null |
// Implementation: impl api::PaymentSync for for Payeezy
// File: crates/hyperswitch_connectors/src/connectors/payeezy.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::PaymentSync for for Payeezy
|
crates/hyperswitch_connectors/src/connectors/payeezy.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 60
| null |
Payeezy
|
api::PaymentSync for
| 0
| 0
| null | null |
// File: crates/hyperswitch_connectors/src/connectors/nmi/transformers.rs
// Module: hyperswitch_connectors
// Public functions: 2
// Public structs: 31
use api_models::webhooks::IncomingWebhookEvent;
use cards::CardNumber;
use common_enums::{AttemptStatus, AuthenticationType, CountryAlpha2, Currency, RefundStatus};
use common_utils::{errors::CustomResult, ext_traits::XmlExt, pii::Email, types::FloatMajorUnit};
use error_stack::{report, Report, ResultExt};
use hyperswitch_domain_models::{
payment_method_data::{
ApplePayWalletData, Card, GooglePayWalletData, PaymentMethodData, WalletData,
},
router_data::{ConnectorAuthType, ErrorResponse, RouterData},
router_flow_types::{
Authorize, Capture, CompleteAuthorize, Execute, PreProcessing, RSync, SetupMandate, Void,
},
router_request_types::{
CompleteAuthorizeData, PaymentsAuthorizeData, PaymentsCaptureData,
PaymentsPreProcessingData, ResponseId,
},
router_response_types::{PaymentsResponseData, RedirectForm, RefundsResponseData},
types::{
PaymentsAuthorizeRouterData, PaymentsCancelRouterData, PaymentsCaptureRouterData,
PaymentsCompleteAuthorizeRouterData, PaymentsPreProcessingRouterData,
PaymentsSyncRouterData, RefundSyncRouterData, RefundsRouterData, SetupMandateRouterData,
},
};
use hyperswitch_interfaces::errors::ConnectorError;
use masking::{ExposeInterface, PeekInterface, Secret};
use serde::{Deserialize, Serialize};
use crate::{
types::{PaymentsResponseRouterData, RefundsResponseRouterData, ResponseRouterData},
utils::{
get_unimplemented_payment_method_error_message, to_currency_base_unit_asf64,
AddressDetailsData as _, CardData as _, PaymentsAuthorizeRequestData,
PaymentsCompleteAuthorizeRequestData as _, RouterData as _,
},
};
type Error = Report<ConnectorError>;
#[derive(Debug, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum TransactionType {
Auth,
Capture,
Refund,
Sale,
Validate,
Void,
}
pub struct NmiAuthType {
pub(super) api_key: Secret<String>,
pub(super) public_key: Option<Secret<String>>,
}
impl TryFrom<&ConnectorAuthType> for NmiAuthType {
type Error = Error;
fn try_from(auth_type: &ConnectorAuthType) -> Result<Self, Self::Error> {
match auth_type {
ConnectorAuthType::HeaderKey { api_key } => Ok(Self {
api_key: api_key.to_owned(),
public_key: None,
}),
ConnectorAuthType::BodyKey { api_key, key1 } => Ok(Self {
api_key: api_key.to_owned(),
public_key: Some(key1.to_owned()),
}),
_ => Err(ConnectorError::FailedToObtainAuthType.into()),
}
}
}
#[derive(Debug, Serialize)]
pub struct NmiRouterData<T> {
pub amount: FloatMajorUnit,
pub router_data: T,
}
impl<T> From<(FloatMajorUnit, T)> for NmiRouterData<T> {
fn from((amount, router_data): (FloatMajorUnit, T)) -> Self {
Self {
amount,
router_data,
}
}
}
#[derive(Debug, Serialize)]
pub struct NmiVaultRequest {
security_key: Secret<String>,
ccnumber: CardNumber,
ccexp: Secret<String>,
cvv: Secret<String>,
first_name: Secret<String>,
last_name: Secret<String>,
address1: Option<Secret<String>>,
address2: Option<Secret<String>>,
city: Option<String>,
state: Option<Secret<String>>,
zip: Option<Secret<String>>,
country: Option<CountryAlpha2>,
customer_vault: CustomerAction,
}
#[derive(Debug, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum CustomerAction {
AddCustomer,
UpdateCustomer,
}
impl TryFrom<&PaymentsPreProcessingRouterData> for NmiVaultRequest {
type Error = Error;
fn try_from(item: &PaymentsPreProcessingRouterData) -> Result<Self, Self::Error> {
let auth_type: NmiAuthType = (&item.connector_auth_type).try_into()?;
let (ccnumber, ccexp, cvv) = get_card_details(item.request.payment_method_data.clone())?;
let billing_details = item.get_billing_address()?;
let first_name = billing_details.get_first_name()?;
Ok(Self {
security_key: auth_type.api_key,
ccnumber,
ccexp,
cvv,
first_name: first_name.clone(),
last_name: billing_details
.get_last_name()
.unwrap_or(first_name)
.clone(),
address1: billing_details.line1.clone(),
address2: billing_details.line2.clone(),
city: billing_details.city.clone(),
state: billing_details.state.clone(),
country: billing_details.country,
zip: billing_details.zip.clone(),
customer_vault: CustomerAction::AddCustomer,
})
}
}
fn get_card_details(
payment_method_data: Option<PaymentMethodData>,
) -> CustomResult<(CardNumber, Secret<String>, Secret<String>), ConnectorError> {
match payment_method_data {
Some(PaymentMethodData::Card(ref card_details)) => Ok((
card_details.card_number.clone(),
card_details.get_card_expiry_month_year_2_digit_with_delimiter("".to_string())?,
card_details.card_cvc.clone(),
)),
_ => Err(
ConnectorError::NotImplemented(get_unimplemented_payment_method_error_message("Nmi"))
.into(),
),
}
}
#[derive(Debug, Deserialize, Serialize)]
pub struct NmiVaultResponse {
pub response: Response,
pub responsetext: String,
pub customer_vault_id: Option<Secret<String>>,
pub response_code: String,
pub transactionid: String,
}
impl
TryFrom<
ResponseRouterData<
PreProcessing,
NmiVaultResponse,
PaymentsPreProcessingData,
PaymentsResponseData,
>,
> for PaymentsPreProcessingRouterData
{
type Error = Error;
fn try_from(
item: ResponseRouterData<
PreProcessing,
NmiVaultResponse,
PaymentsPreProcessingData,
PaymentsResponseData,
>,
) -> Result<Self, Self::Error> {
let auth_type: NmiAuthType = (&item.data.connector_auth_type).try_into()?;
let amount_data = item
.data
.request
.amount
.ok_or(ConnectorError::MissingRequiredField {
field_name: "amount",
})?;
let currency_data =
item.data
.request
.currency
.ok_or(ConnectorError::MissingRequiredField {
field_name: "currency",
})?;
let (response, status) = match item.response.response {
Response::Approved => (
Ok(PaymentsResponseData::TransactionResponse {
resource_id: ResponseId::NoResponseId,
redirection_data: Box::new(Some(RedirectForm::Nmi {
amount: to_currency_base_unit_asf64(amount_data, currency_data.to_owned())?
.to_string(),
currency: currency_data,
customer_vault_id: item
.response
.customer_vault_id
.ok_or(ConnectorError::MissingRequiredField {
field_name: "customer_vault_id",
})?
.peek()
.to_string(),
public_key: auth_type.public_key.ok_or(
ConnectorError::InvalidConnectorConfig {
config: "public_key",
},
)?,
order_id: item.data.connector_request_reference_id.clone(),
})),
mandate_reference: Box::new(None),
connector_metadata: None,
network_txn_id: None,
connector_response_reference_id: Some(item.response.transactionid),
incremental_authorization_allowed: None,
charges: None,
}),
AttemptStatus::AuthenticationPending,
),
Response::Declined | Response::Error => (
Err(ErrorResponse {
code: item.response.response_code,
message: item.response.responsetext.to_owned(),
reason: Some(item.response.responsetext),
status_code: item.http_code,
attempt_status: None,
connector_transaction_id: Some(item.response.transactionid),
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
connector_metadata: None,
}),
AttemptStatus::Failure,
),
};
Ok(Self {
status,
response,
..item.data
})
}
}
#[derive(Debug, Serialize)]
pub struct NmiCompleteRequest {
amount: FloatMajorUnit,
#[serde(rename = "type")]
transaction_type: TransactionType,
security_key: Secret<String>,
orderid: Option<String>,
customer_vault_id: Secret<String>,
email: Option<Email>,
cardholder_auth: Option<String>,
cavv: Option<String>,
xid: Option<String>,
eci: Option<String>,
cvv: Secret<String>,
three_ds_version: Option<String>,
directory_server_id: Option<Secret<String>>,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
#[serde(untagged)]
pub enum NmiRedirectResponse {
NmiRedirectResponseData(NmiRedirectResponseData),
NmiErrorResponseData(NmiErrorResponseData),
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct NmiErrorResponseData {
pub code: String,
pub message: String,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct NmiRedirectResponseData {
cavv: Option<String>,
xid: Option<String>,
eci: Option<String>,
card_holder_auth: Option<String>,
three_ds_version: Option<String>,
order_id: Option<String>,
directory_server_id: Option<Secret<String>>,
customer_vault_id: Secret<String>,
}
impl TryFrom<&NmiRouterData<&PaymentsCompleteAuthorizeRouterData>> for NmiCompleteRequest {
type Error = Error;
fn try_from(
item: &NmiRouterData<&PaymentsCompleteAuthorizeRouterData>,
) -> Result<Self, Self::Error> {
let transaction_type = match item.router_data.request.is_auto_capture()? {
true => TransactionType::Sale,
false => TransactionType::Auth,
};
let auth_type: NmiAuthType = (&item.router_data.connector_auth_type).try_into()?;
let payload_data = item
.router_data
.request
.get_redirect_response_payload()?
.expose();
let three_ds_data: NmiRedirectResponseData = serde_json::from_value(payload_data)
.change_context(ConnectorError::MissingConnectorRedirectionPayload {
field_name: "three_ds_data",
})?;
let (_, _, cvv) = get_card_details(item.router_data.request.payment_method_data.clone())?;
Ok(Self {
amount: item.amount,
transaction_type,
security_key: auth_type.api_key,
orderid: three_ds_data.order_id,
customer_vault_id: three_ds_data.customer_vault_id,
email: item.router_data.request.email.clone(),
cvv,
cardholder_auth: three_ds_data.card_holder_auth,
cavv: three_ds_data.cavv,
xid: three_ds_data.xid,
eci: three_ds_data.eci,
three_ds_version: three_ds_data.three_ds_version,
directory_server_id: three_ds_data.directory_server_id,
})
}
}
#[derive(Debug, Deserialize, Serialize)]
pub struct NmiCompleteResponse {
pub response: Response,
pub responsetext: String,
pub authcode: Option<String>,
pub transactionid: String,
pub avsresponse: Option<String>,
pub cvvresponse: Option<String>,
pub orderid: String,
pub response_code: String,
customer_vault_id: Option<Secret<String>>,
}
impl
TryFrom<
ResponseRouterData<
CompleteAuthorize,
NmiCompleteResponse,
CompleteAuthorizeData,
PaymentsResponseData,
>,
> for PaymentsCompleteAuthorizeRouterData
{
type Error = Error;
fn try_from(
item: ResponseRouterData<
CompleteAuthorize,
NmiCompleteResponse,
CompleteAuthorizeData,
PaymentsResponseData,
>,
) -> Result<Self, Self::Error> {
let (response, status) = match item.response.response {
Response::Approved => (
Ok(PaymentsResponseData::TransactionResponse {
resource_id: ResponseId::ConnectorTransactionId(item.response.transactionid),
redirection_data: Box::new(None),
mandate_reference: match item.response.customer_vault_id {
Some(vault_id) => Box::new(Some(
hyperswitch_domain_models::router_response_types::MandateReference {
connector_mandate_id: Some(vault_id.expose()),
payment_method_id: None,
mandate_metadata: None,
connector_mandate_request_reference_id: None,
},
)),
None => Box::new(None),
},
connector_metadata: None,
network_txn_id: None,
connector_response_reference_id: Some(item.response.orderid),
incremental_authorization_allowed: None,
charges: None,
}),
if item.data.request.is_auto_capture()? {
AttemptStatus::Charged
} else {
AttemptStatus::Authorized
},
),
Response::Declined | Response::Error => (
Err(get_nmi_error_response(item.response, item.http_code)),
AttemptStatus::Failure,
),
};
Ok(Self {
status,
response,
..item.data
})
}
}
fn get_nmi_error_response(response: NmiCompleteResponse, http_code: u16) -> ErrorResponse {
ErrorResponse {
code: response.response_code,
message: response.responsetext.to_owned(),
reason: Some(response.responsetext),
status_code: http_code,
attempt_status: None,
connector_transaction_id: Some(response.transactionid),
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
connector_metadata: None,
}
}
#[derive(Debug, Serialize)]
pub struct NmiValidateRequest {
#[serde(rename = "type")]
transaction_type: TransactionType,
security_key: Secret<String>,
ccnumber: CardNumber,
ccexp: Secret<String>,
cvv: Secret<String>,
orderid: String,
customer_vault: CustomerAction,
}
#[derive(Debug, Serialize)]
pub struct NmiPaymentsRequest {
#[serde(rename = "type")]
transaction_type: TransactionType,
amount: FloatMajorUnit,
security_key: Secret<String>,
currency: Currency,
#[serde(flatten)]
payment_method: PaymentMethod,
#[serde(flatten)]
merchant_defined_field: Option<NmiMerchantDefinedField>,
orderid: String,
#[serde(skip_serializing_if = "Option::is_none")]
customer_vault: Option<CustomerAction>,
}
#[derive(Debug, Serialize)]
pub struct NmiMerchantDefinedField {
#[serde(flatten)]
inner: std::collections::BTreeMap<String, Secret<String>>,
}
impl NmiMerchantDefinedField {
pub fn new(metadata: &serde_json::Value) -> Self {
let metadata_as_string = metadata.to_string();
let hash_map: std::collections::BTreeMap<String, serde_json::Value> =
serde_json::from_str(&metadata_as_string).unwrap_or(std::collections::BTreeMap::new());
let inner = hash_map
.into_iter()
.enumerate()
.map(|(index, (hs_key, hs_value))| {
let nmi_key = format!("merchant_defined_field_{}", index + 1);
let nmi_value = format!("{hs_key}={hs_value}");
(nmi_key, Secret::new(nmi_value))
})
.collect();
Self { inner }
}
}
#[derive(Debug, Serialize)]
#[serde(untagged)]
pub enum PaymentMethod {
CardNonThreeDs(Box<CardData>),
CardThreeDs(Box<CardThreeDsData>),
GPay(Box<GooglePayData>),
ApplePay(Box<ApplePayData>),
MandatePayment(Box<MandatePayment>),
}
#[derive(Debug, Serialize)]
pub struct MandatePayment {
customer_vault_id: Secret<String>,
}
#[derive(Debug, Serialize)]
pub struct CardData {
ccnumber: CardNumber,
ccexp: Secret<String>,
cvv: Secret<String>,
}
#[derive(Debug, Serialize)]
pub struct CardThreeDsData {
ccnumber: CardNumber,
ccexp: Secret<String>,
email: Option<Email>,
cardholder_auth: Option<String>,
cavv: Option<Secret<String>>,
eci: Option<String>,
cvv: Secret<String>,
three_ds_version: Option<String>,
directory_server_id: Option<Secret<String>>,
}
#[derive(Debug, Serialize)]
pub struct GooglePayData {
googlepay_payment_data: Secret<String>,
}
#[derive(Debug, Serialize)]
pub struct ApplePayData {
applepay_payment_data: Secret<String>,
}
impl TryFrom<&NmiRouterData<&PaymentsAuthorizeRouterData>> for NmiPaymentsRequest {
type Error = Error;
fn try_from(item: &NmiRouterData<&PaymentsAuthorizeRouterData>) -> Result<Self, Self::Error> {
let transaction_type = match item.router_data.request.is_auto_capture()? {
true => TransactionType::Sale,
false => TransactionType::Auth,
};
let auth_type: NmiAuthType = (&item.router_data.connector_auth_type).try_into()?;
let amount = item.amount;
match item
.router_data
.request
.mandate_id
.clone()
.and_then(|mandate_ids| mandate_ids.mandate_reference_id)
{
Some(api_models::payments::MandateReferenceId::ConnectorMandateId(
connector_mandate_id,
)) => Ok(Self {
transaction_type,
security_key: auth_type.api_key,
amount,
currency: item.router_data.request.currency,
payment_method: PaymentMethod::MandatePayment(Box::new(MandatePayment {
customer_vault_id: Secret::new(
connector_mandate_id
.get_connector_mandate_id()
.ok_or(ConnectorError::MissingConnectorMandateID)?,
),
})),
merchant_defined_field: item
.router_data
.request
.metadata
.as_ref()
.map(NmiMerchantDefinedField::new),
orderid: item.router_data.connector_request_reference_id.clone(),
customer_vault: None,
}),
Some(api_models::payments::MandateReferenceId::NetworkMandateId(_))
| Some(api_models::payments::MandateReferenceId::NetworkTokenWithNTI(_)) => {
Err(ConnectorError::NotImplemented(
get_unimplemented_payment_method_error_message("nmi"),
))?
}
None => {
let payment_method = PaymentMethod::try_from((
&item.router_data.request.payment_method_data,
Some(item.router_data),
))?;
Ok(Self {
transaction_type,
security_key: auth_type.api_key,
amount,
currency: item.router_data.request.currency,
payment_method,
merchant_defined_field: item
.router_data
.request
.metadata
.as_ref()
.map(NmiMerchantDefinedField::new),
orderid: item.router_data.connector_request_reference_id.clone(),
customer_vault: item
.router_data
.request
.is_mandate_payment()
.then_some(CustomerAction::AddCustomer),
})
}
}
}
}
impl TryFrom<(&PaymentMethodData, Option<&PaymentsAuthorizeRouterData>)> for PaymentMethod {
type Error = Error;
fn try_from(
item: (&PaymentMethodData, Option<&PaymentsAuthorizeRouterData>),
) -> Result<Self, Self::Error> {
let (payment_method_data, router_data) = item;
match payment_method_data {
PaymentMethodData::Card(ref card) => match router_data {
Some(data) => match data.auth_type {
AuthenticationType::NoThreeDs => Ok(Self::try_from(card)?),
AuthenticationType::ThreeDs => Ok(Self::try_from((card, &data.request))?),
},
None => Ok(Self::try_from(card)?),
},
PaymentMethodData::Wallet(ref wallet_type) => match wallet_type {
WalletData::GooglePay(ref googlepay_data) => Ok(Self::try_from(googlepay_data)?),
WalletData::ApplePay(ref applepay_data) => Ok(Self::try_from(applepay_data)?),
WalletData::AliPayQr(_)
| WalletData::AliPayRedirect(_)
| WalletData::AliPayHkRedirect(_)
| WalletData::AmazonPayRedirect(_)
| WalletData::Paysera(_)
| WalletData::Skrill(_)
| WalletData::BluecodeRedirect {}
| WalletData::MomoRedirect(_)
| WalletData::KakaoPayRedirect(_)
| WalletData::GoPayRedirect(_)
| WalletData::GcashRedirect(_)
| WalletData::ApplePayRedirect(_)
| WalletData::ApplePayThirdPartySdk(_)
| WalletData::DanaRedirect {}
| WalletData::GooglePayRedirect(_)
| WalletData::GooglePayThirdPartySdk(_)
| WalletData::MbWayRedirect(_)
| WalletData::MobilePayRedirect(_)
| WalletData::PaypalRedirect(_)
| WalletData::PaypalSdk(_)
| WalletData::Paze(_)
| WalletData::SamsungPay(_)
| WalletData::AmazonPay(_)
| WalletData::TwintRedirect {}
| WalletData::VippsRedirect {}
| WalletData::TouchNGoRedirect(_)
| WalletData::WeChatPayRedirect(_)
| WalletData::WeChatPayQr(_)
| WalletData::CashappQr(_)
| WalletData::SwishQr(_)
| WalletData::Mifinity(_)
| WalletData::RevolutPay(_) => Err(report!(ConnectorError::NotImplemented(
get_unimplemented_payment_method_error_message("nmi"),
))),
},
PaymentMethodData::CardRedirect(_)
| PaymentMethodData::PayLater(_)
| PaymentMethodData::BankRedirect(_)
| PaymentMethodData::BankDebit(_)
| PaymentMethodData::BankTransfer(_)
| PaymentMethodData::Crypto(_)
| PaymentMethodData::MandatePayment
| PaymentMethodData::Reward
| PaymentMethodData::RealTimePayment(_)
| PaymentMethodData::MobilePayment(_)
| PaymentMethodData::Upi(_)
| PaymentMethodData::Voucher(_)
| PaymentMethodData::GiftCard(_)
| PaymentMethodData::OpenBanking(_)
| PaymentMethodData::CardToken(_)
| PaymentMethodData::NetworkToken(_)
| PaymentMethodData::CardDetailsForNetworkTransactionId(_) => Err(
ConnectorError::NotImplemented(get_unimplemented_payment_method_error_message(
"nmi",
))
.into(),
),
}
}
}
impl TryFrom<(&Card, &PaymentsAuthorizeData)> for PaymentMethod {
type Error = Error;
fn try_from(val: (&Card, &PaymentsAuthorizeData)) -> Result<Self, Self::Error> {
let (card_data, item) = val;
let auth_data = &item.get_authentication_data()?;
let ccexp = card_data.get_card_expiry_month_year_2_digit_with_delimiter("".to_string())?;
let card_3ds_details = CardThreeDsData {
ccnumber: card_data.card_number.clone(),
ccexp,
cvv: card_data.card_cvc.clone(),
email: item.email.clone(),
cavv: Some(auth_data.cavv.clone()),
eci: auth_data.eci.clone(),
cardholder_auth: None,
three_ds_version: auth_data
.message_version
.clone()
.map(|version| version.to_string()),
directory_server_id: auth_data
.threeds_server_transaction_id
.clone()
.map(Secret::new),
};
Ok(Self::CardThreeDs(Box::new(card_3ds_details)))
}
}
impl TryFrom<&Card> for PaymentMethod {
type Error = Error;
fn try_from(card: &Card) -> Result<Self, Self::Error> {
let ccexp = card.get_card_expiry_month_year_2_digit_with_delimiter("".to_string())?;
let card = CardData {
ccnumber: card.card_number.clone(),
ccexp,
cvv: card.card_cvc.clone(),
};
Ok(Self::CardNonThreeDs(Box::new(card)))
}
}
impl TryFrom<&GooglePayWalletData> for PaymentMethod {
type Error = Report<ConnectorError>;
fn try_from(wallet_data: &GooglePayWalletData) -> Result<Self, Self::Error> {
let gpay_data = GooglePayData {
googlepay_payment_data: Secret::new(
wallet_data
.tokenization_data
.get_encrypted_google_pay_token()
.change_context(ConnectorError::MissingRequiredField {
field_name: "gpay wallet_token",
})?
.clone(),
),
};
Ok(Self::GPay(Box::new(gpay_data)))
}
}
impl TryFrom<&ApplePayWalletData> for PaymentMethod {
type Error = Error;
fn try_from(apple_pay_wallet_data: &ApplePayWalletData) -> Result<Self, Self::Error> {
let apple_pay_encrypted_data = apple_pay_wallet_data
.payment_data
.get_encrypted_apple_pay_payment_data_mandatory()
.change_context(ConnectorError::MissingRequiredField {
field_name: "Apple pay encrypted data",
})?;
let apple_pay_data = ApplePayData {
applepay_payment_data: Secret::new(apple_pay_encrypted_data.clone()),
};
Ok(Self::ApplePay(Box::new(apple_pay_data)))
}
}
impl TryFrom<&SetupMandateRouterData> for NmiValidateRequest {
type Error = Error;
fn try_from(item: &SetupMandateRouterData) -> Result<Self, Self::Error> {
match item.request.amount {
Some(amount) if amount > 0 => Err(ConnectorError::FlowNotSupported {
flow: "Setup Mandate with non zero amount".to_string(),
connector: "NMI".to_string(),
}
.into()),
_ => {
if let PaymentMethodData::Card(card_details) = &item.request.payment_method_data {
let auth_type: NmiAuthType = (&item.connector_auth_type).try_into()?;
Ok(Self {
transaction_type: TransactionType::Validate,
security_key: auth_type.api_key,
ccnumber: card_details.card_number.clone(),
ccexp: card_details
.get_card_expiry_month_year_2_digit_with_delimiter("".to_string())?,
cvv: card_details.card_cvc.clone(),
orderid: item.connector_request_reference_id.clone(),
customer_vault: CustomerAction::AddCustomer,
})
} else {
Err(ConnectorError::NotImplemented(
get_unimplemented_payment_method_error_message("Nmi"),
)
.into())
}
}
}
}
}
#[derive(Debug, Serialize)]
pub struct NmiSyncRequest {
pub order_id: String,
pub security_key: Secret<String>,
}
impl TryFrom<&PaymentsSyncRouterData> for NmiSyncRequest {
type Error = Error;
fn try_from(item: &PaymentsSyncRouterData) -> Result<Self, Self::Error> {
let auth = NmiAuthType::try_from(&item.connector_auth_type)?;
Ok(Self {
security_key: auth.api_key,
order_id: item.attempt_id.clone(),
})
}
}
#[derive(Debug, Serialize)]
pub struct NmiCaptureRequest {
#[serde(rename = "type")]
pub transaction_type: TransactionType,
pub security_key: Secret<String>,
pub transactionid: String,
pub amount: Option<FloatMajorUnit>,
}
impl TryFrom<&NmiRouterData<&PaymentsCaptureRouterData>> for NmiCaptureRequest {
type Error = Error;
fn try_from(item: &NmiRouterData<&PaymentsCaptureRouterData>) -> Result<Self, Self::Error> {
let auth = NmiAuthType::try_from(&item.router_data.connector_auth_type)?;
Ok(Self {
transaction_type: TransactionType::Capture,
security_key: auth.api_key,
transactionid: item.router_data.request.connector_transaction_id.clone(),
amount: Some(item.amount),
})
}
}
impl
TryFrom<
ResponseRouterData<Capture, StandardResponse, PaymentsCaptureData, PaymentsResponseData>,
> for RouterData<Capture, PaymentsCaptureData, PaymentsResponseData>
{
type Error = Error;
fn try_from(
item: ResponseRouterData<
Capture,
StandardResponse,
PaymentsCaptureData,
PaymentsResponseData,
>,
) -> Result<Self, Self::Error> {
let (response, status) = match item.response.response {
Response::Approved => (
Ok(PaymentsResponseData::TransactionResponse {
resource_id: ResponseId::ConnectorTransactionId(
item.response.transactionid.to_owned(),
),
redirection_data: Box::new(None),
mandate_reference: Box::new(None),
connector_metadata: None,
network_txn_id: None,
connector_response_reference_id: Some(item.response.orderid),
incremental_authorization_allowed: None,
charges: None,
}),
AttemptStatus::Charged,
),
Response::Declined | Response::Error => (
Err(get_standard_error_response(item.response, item.http_code)),
AttemptStatus::CaptureFailed,
),
};
Ok(Self {
status,
response,
..item.data
})
}
}
#[derive(Debug, Serialize)]
pub struct NmiCancelRequest {
#[serde(rename = "type")]
pub transaction_type: TransactionType,
pub security_key: Secret<String>,
pub transactionid: String,
pub void_reason: NmiVoidReason,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum NmiVoidReason {
Fraud,
UserCancel,
IccRejected,
IccCardRemoved,
IccNoConfirmation,
PosTimeout,
}
impl TryFrom<&PaymentsCancelRouterData> for NmiCancelRequest {
type Error = Error;
fn try_from(item: &PaymentsCancelRouterData) -> Result<Self, Self::Error> {
let auth = NmiAuthType::try_from(&item.connector_auth_type)?;
match &item.request.cancellation_reason {
Some(cancellation_reason) => {
let void_reason: NmiVoidReason = serde_json::from_str(&format!("\"{cancellation_reason}\"", ))
.map_err(|_| ConnectorError::NotSupported {
message: format!("Json deserialise error: unknown variant `{cancellation_reason}` expected to be one of `fraud`, `user_cancel`, `icc_rejected`, `icc_card_removed`, `icc_no_confirmation`, `pos_timeout`. This cancellation_reason"),
connector: "nmi"
})?;
Ok(Self {
transaction_type: TransactionType::Void,
security_key: auth.api_key,
transactionid: item.request.connector_transaction_id.clone(),
void_reason,
})
}
None => Err(ConnectorError::MissingRequiredField {
field_name: "cancellation_reason",
}
.into()),
}
}
}
#[derive(Debug, Deserialize, Serialize)]
pub enum Response {
#[serde(alias = "1")]
Approved,
#[serde(alias = "2")]
Declined,
#[serde(alias = "3")]
Error,
}
#[derive(Debug, Deserialize, Serialize)]
pub struct StandardResponse {
pub response: Response,
pub responsetext: String,
pub authcode: Option<String>,
pub transactionid: String,
pub avsresponse: Option<String>,
pub cvvresponse: Option<String>,
pub orderid: String,
pub response_code: String,
pub customer_vault_id: Option<Secret<String>>,
}
impl<T> TryFrom<ResponseRouterData<SetupMandate, StandardResponse, T, PaymentsResponseData>>
for RouterData<SetupMandate, T, PaymentsResponseData>
{
type Error = Error;
fn try_from(
item: ResponseRouterData<SetupMandate, StandardResponse, T, PaymentsResponseData>,
) -> Result<Self, Self::Error> {
let (response, status) = match item.response.response {
Response::Approved => (
Ok(PaymentsResponseData::TransactionResponse {
resource_id: ResponseId::ConnectorTransactionId(
item.response.transactionid.clone(),
),
redirection_data: Box::new(None),
mandate_reference: match item.response.customer_vault_id {
Some(vault_id) => Box::new(Some(
hyperswitch_domain_models::router_response_types::MandateReference {
connector_mandate_id: Some(vault_id.expose()),
payment_method_id: None,
mandate_metadata: None,
connector_mandate_request_reference_id: None,
},
)),
None => Box::new(None),
},
connector_metadata: None,
network_txn_id: None,
connector_response_reference_id: Some(item.response.orderid),
incremental_authorization_allowed: None,
charges: None,
}),
AttemptStatus::Charged,
),
Response::Declined | Response::Error => (
Err(get_standard_error_response(item.response, item.http_code)),
AttemptStatus::Failure,
),
};
Ok(Self {
status,
response,
..item.data
})
}
}
fn get_standard_error_response(response: StandardResponse, http_code: u16) -> ErrorResponse {
ErrorResponse {
code: response.response_code,
message: response.responsetext.to_owned(),
reason: Some(response.responsetext),
status_code: http_code,
attempt_status: None,
connector_transaction_id: Some(response.transactionid),
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
connector_metadata: None,
}
}
impl TryFrom<PaymentsResponseRouterData<StandardResponse>>
for RouterData<Authorize, PaymentsAuthorizeData, PaymentsResponseData>
{
type Error = Error;
fn try_from(
item: ResponseRouterData<
Authorize,
StandardResponse,
PaymentsAuthorizeData,
PaymentsResponseData,
>,
) -> Result<Self, Self::Error> {
let (response, status) = match item.response.response {
Response::Approved => (
Ok(PaymentsResponseData::TransactionResponse {
resource_id: ResponseId::ConnectorTransactionId(
item.response.transactionid.clone(),
),
redirection_data: Box::new(None),
mandate_reference: match item.response.customer_vault_id {
Some(vault_id) => Box::new(Some(
hyperswitch_domain_models::router_response_types::MandateReference {
connector_mandate_id: Some(vault_id.expose()),
payment_method_id: None,
mandate_metadata: None,
connector_mandate_request_reference_id: None,
},
)),
None => Box::new(None),
},
connector_metadata: None,
network_txn_id: None,
connector_response_reference_id: Some(item.response.orderid),
incremental_authorization_allowed: None,
charges: None,
}),
if item.data.request.is_auto_capture()? {
AttemptStatus::Charged
} else {
AttemptStatus::Authorized
},
),
Response::Declined | Response::Error => (
Err(get_standard_error_response(item.response, item.http_code)),
AttemptStatus::Failure,
),
};
Ok(Self {
status,
response,
..item.data
})
}
}
impl<T> TryFrom<ResponseRouterData<Void, StandardResponse, T, PaymentsResponseData>>
for RouterData<Void, T, PaymentsResponseData>
{
type Error = Error;
fn try_from(
item: ResponseRouterData<Void, StandardResponse, T, PaymentsResponseData>,
) -> Result<Self, Self::Error> {
let (response, status) = match item.response.response {
Response::Approved => (
Ok(PaymentsResponseData::TransactionResponse {
resource_id: ResponseId::ConnectorTransactionId(
item.response.transactionid.clone(),
),
redirection_data: Box::new(None),
mandate_reference: Box::new(None),
connector_metadata: None,
network_txn_id: None,
connector_response_reference_id: Some(item.response.orderid),
incremental_authorization_allowed: None,
charges: None,
}),
AttemptStatus::VoidInitiated,
),
Response::Declined | Response::Error => (
Err(get_standard_error_response(item.response, item.http_code)),
AttemptStatus::VoidFailed,
),
};
Ok(Self {
status,
response,
..item.data
})
}
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum NmiStatus {
Abandoned,
Cancelled,
Pendingsettlement,
Pending,
Failed,
Complete,
InProgress,
Unknown,
}
impl<F, T> TryFrom<ResponseRouterData<F, SyncResponse, T, PaymentsResponseData>>
for RouterData<F, T, PaymentsResponseData>
{
type Error = Error;
fn try_from(
item: ResponseRouterData<F, SyncResponse, T, PaymentsResponseData>,
) -> Result<Self, Self::Error> {
match item.response.transaction {
|
crates/hyperswitch_connectors/src/connectors/nmi/transformers.rs#chunk0
|
hyperswitch_connectors
|
chunk
| null | null | null | 8,186
| null | null | null | null | null | null | null |
// Function: generate_env_specific_merchant_id
// File: crates/router/src/utils/user.rs
// Module: router
pub fn generate_env_specific_merchant_id(value: String) -> UserResult<id_type::MerchantId>
|
crates/router/src/utils/user.rs
|
router
|
function_signature
| null | null | null | 47
|
generate_env_specific_merchant_id
| null | null | null | null | null | null |
// Implementation: impl api::PaymentVoid for for Fiservemea
// File: crates/hyperswitch_connectors/src/connectors/fiservemea.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::PaymentVoid for for Fiservemea
|
crates/hyperswitch_connectors/src/connectors/fiservemea.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 66
| null |
Fiservemea
|
api::PaymentVoid for
| 0
| 0
| null | null |
// File: crates/analytics/src/sdk_events/accumulator.rs
// Module: analytics
// Public functions: 1
// Public structs: 3
use api_models::analytics::sdk_events::SdkEventMetricsBucketValue;
use router_env::logger;
use super::metrics::SdkEventMetricRow;
#[derive(Debug, Default)]
pub struct SdkEventMetricsAccumulator {
pub payment_attempts: CountAccumulator,
pub payment_methods_call_count: CountAccumulator,
pub average_payment_time: CountAccumulator,
pub load_time: CountAccumulator,
pub sdk_initiated_count: CountAccumulator,
pub sdk_rendered_count: CountAccumulator,
pub payment_method_selected_count: CountAccumulator,
pub payment_data_filled_count: CountAccumulator,
}
#[derive(Debug, Default)]
#[repr(transparent)]
pub struct CountAccumulator {
pub count: Option<i64>,
}
#[derive(Debug, Default)]
pub struct AverageAccumulator {
pub total: u32,
pub count: u32,
}
pub trait SdkEventMetricAccumulator {
type MetricOutput;
fn add_metrics_bucket(&mut self, metrics: &SdkEventMetricRow);
fn collect(self) -> Self::MetricOutput;
}
impl SdkEventMetricAccumulator for CountAccumulator {
type MetricOutput = Option<u64>;
#[inline]
fn add_metrics_bucket(&mut self, metrics: &SdkEventMetricRow) {
self.count = match (self.count, metrics.count) {
(None, None) => None,
(None, i @ Some(_)) | (i @ Some(_), None) => i,
(Some(a), Some(b)) => Some(a + b),
}
}
#[inline]
fn collect(self) -> Self::MetricOutput {
self.count.and_then(|i| u64::try_from(i).ok())
}
}
impl SdkEventMetricAccumulator for AverageAccumulator {
type MetricOutput = Option<f64>;
fn add_metrics_bucket(&mut self, metrics: &SdkEventMetricRow) {
let total = metrics
.total
.as_ref()
.and_then(bigdecimal::ToPrimitive::to_u32);
let count = metrics.count.and_then(|total| u32::try_from(total).ok());
match (total, count) {
(Some(total), Some(count)) => {
self.total += total;
self.count += count;
}
_ => {
logger::error!(message="Dropping metrics for average accumulator", metric=?metrics);
}
}
}
fn collect(self) -> Self::MetricOutput {
if self.count == 0 {
None
} else {
Some(f64::from(self.total) / f64::from(self.count))
}
}
}
impl SdkEventMetricsAccumulator {
#[allow(dead_code)]
pub fn collect(self) -> SdkEventMetricsBucketValue {
SdkEventMetricsBucketValue {
payment_attempts: self.payment_attempts.collect(),
payment_methods_call_count: self.payment_methods_call_count.collect(),
average_payment_time: self.average_payment_time.collect(),
load_time: self.load_time.collect(),
sdk_initiated_count: self.sdk_initiated_count.collect(),
sdk_rendered_count: self.sdk_rendered_count.collect(),
payment_method_selected_count: self.payment_method_selected_count.collect(),
payment_data_filled_count: self.payment_data_filled_count.collect(),
}
}
}
|
crates/analytics/src/sdk_events/accumulator.rs
|
analytics
|
full_file
| null | null | null | 755
| null | null | null | null | null | null | null |
// Struct: BarclaycardAuthValidateRequest
// File: crates/hyperswitch_connectors/src/connectors/barclaycard/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct BarclaycardAuthValidateRequest
|
crates/hyperswitch_connectors/src/connectors/barclaycard/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
BarclaycardAuthValidateRequest
| 0
|
[] | 55
| null | null | null | null | null | null | null |
// Implementation: impl api::MandateSetup for for Hipay
// File: crates/hyperswitch_connectors/src/connectors/hipay.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::MandateSetup for for Hipay
|
crates/hyperswitch_connectors/src/connectors/hipay.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 62
| null |
Hipay
|
api::MandateSetup for
| 0
| 0
| null | null |
// Function: payouts_list_available_filters_core
// File: crates/router/src/core/payouts.rs
// Module: router
pub fn payouts_list_available_filters_core(
state: SessionState,
merchant_context: domain::MerchantContext,
profile_id_list: Option<Vec<id_type::ProfileId>>,
time_range: common_utils::types::TimeRange,
) -> RouterResponse<api::PayoutListFilters>
|
crates/router/src/core/payouts.rs
|
router
|
function_signature
| null | null | null | 87
|
payouts_list_available_filters_core
| null | null | null | null | null | null |
// Struct: ZenPaymentData
// File: crates/hyperswitch_connectors/src/connectors/zen/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct ZenPaymentData
|
crates/hyperswitch_connectors/src/connectors/zen/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
ZenPaymentData
| 0
|
[] | 47
| 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 api::PaymentSession for for Stripebilling
// File: crates/hyperswitch_connectors/src/connectors/stripebilling.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::PaymentSession for for Stripebilling
|
crates/hyperswitch_connectors/src/connectors/stripebilling.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 58
| null |
Stripebilling
|
api::PaymentSession for
| 0
| 0
| null | null |
// Implementation: impl ProxyRecord
// File: crates/router/src/core/proxy/utils.rs
// Module: router
// Methods: 3 total (0 public)
impl ProxyRecord
|
crates/router/src/core/proxy/utils.rs
|
router
|
impl_block
| null | null | null | 37
| null |
ProxyRecord
| null | 3
| 0
| null | null |
// Struct: MandateData
// File: crates/router/src/compatibility/stripe/payment_intents/types.rs
// Module: router
// Implementations: 0
pub struct MandateData
|
crates/router/src/compatibility/stripe/payment_intents/types.rs
|
router
|
struct_definition
|
MandateData
| 0
|
[] | 41
| null | null | null | null | null | null | null |
// Function: qr_code_next_steps_check
// File: crates/router/src/core/payments/transformers.rs
// Module: router
pub fn qr_code_next_steps_check(
payment_attempt: storage::PaymentAttempt,
) -> RouterResult<Option<api_models::payments::QrCodeInformation>>
|
crates/router/src/core/payments/transformers.rs
|
router
|
function_signature
| null | null | null | 61
|
qr_code_next_steps_check
| null | null | null | null | null | null |
// Struct: ArchipelCaptureOrderRequest
// File: crates/hyperswitch_connectors/src/connectors/archipel/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct ArchipelCaptureOrderRequest
|
crates/hyperswitch_connectors/src/connectors/archipel/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
ArchipelCaptureOrderRequest
| 0
|
[] | 51
| null | null | null | null | null | null | null |
// Function: get_internal_error_mut
// File: crates/api_models/src/errors/types.rs
// Module: api_models
pub fn get_internal_error_mut(&mut self) -> &mut ApiError
|
crates/api_models/src/errors/types.rs
|
api_models
|
function_signature
| null | null | null | 40
|
get_internal_error_mut
| null | null | null | null | null | null |
// Struct: DynamicAlgorithmWithTimestamp
// File: crates/api_models/src/routing.rs
// Module: api_models
// Implementations: 1
pub struct DynamicAlgorithmWithTimestamp<T>
|
crates/api_models/src/routing.rs
|
api_models
|
struct_definition
|
DynamicAlgorithmWithTimestamp
| 1
|
[] | 40
| null | null | null | null | null | null | null |
// Implementation: impl Capturable for for SdkPaymentsSessionUpdateData
// File: crates/router/src/types.rs
// Module: router
// Methods: 0 total (0 public)
impl Capturable for for SdkPaymentsSessionUpdateData
|
crates/router/src/types.rs
|
router
|
impl_block
| null | null | null | 50
| null |
SdkPaymentsSessionUpdateData
|
Capturable for
| 0
| 0
| null | null |
// Struct: TokenizedBankRedirectValue1
// File: crates/api_models/src/payment_methods.rs
// Module: api_models
// Implementations: 0
pub struct TokenizedBankRedirectValue1
|
crates/api_models/src/payment_methods.rs
|
api_models
|
struct_definition
|
TokenizedBankRedirectValue1
| 0
|
[] | 42
| null | null | null | null | null | null | null |
// Implementation: impl api::Payment for for Bitpay
// File: crates/hyperswitch_connectors/src/connectors/bitpay.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::Payment for for Bitpay
|
crates/hyperswitch_connectors/src/connectors/bitpay.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 55
| null |
Bitpay
|
api::Payment for
| 0
| 0
| null | null |
// Struct: ForteRouterData
// File: crates/hyperswitch_connectors/src/connectors/forte/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct ForteRouterData<T>
|
crates/hyperswitch_connectors/src/connectors/forte/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
ForteRouterData
| 0
|
[] | 52
| null | null | null | null | null | null | null |
// Function: generic_user_roles_list_for_user
// File: crates/diesel_models/src/query/user_role.rs
// Module: diesel_models
pub fn generic_user_roles_list_for_user(
conn: &PgPooledConn,
user_id: String,
tenant_id: id_type::TenantId,
org_id: Option<id_type::OrganizationId>,
merchant_id: Option<id_type::MerchantId>,
profile_id: Option<id_type::ProfileId>,
entity_id: Option<String>,
status: Option<UserStatus>,
version: Option<UserRoleVersion>,
limit: Option<u32>,
) -> StorageResult<Vec<Self>>
|
crates/diesel_models/src/query/user_role.rs
|
diesel_models
|
function_signature
| null | null | null | 137
|
generic_user_roles_list_for_user
| null | null | null | null | null | null |
// Implementation: impl FraudCheckRecordReturn for for Signifyd
// File: crates/hyperswitch_connectors/src/connectors/signifyd.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl FraudCheckRecordReturn for for Signifyd
|
crates/hyperswitch_connectors/src/connectors/signifyd.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 60
| null |
Signifyd
|
FraudCheckRecordReturn for
| 0
| 0
| null | null |
"parsing failed with error: '{param}' at position: {position}"
),
param: Some(param),
},
serde_qs::Error::Unsupported => Self::SerdeQsError {
error_message: "Given request format is not supported".to_owned(),
param: None,
},
serde_qs::Error::FromUtf8(_) => Self::SerdeQsError {
error_message: "Failed to parse request to from utf-8".to_owned(),
param: None,
},
serde_qs::Error::Io(_) => Self::SerdeQsError {
error_message: "Failed to parse request".to_owned(),
param: None,
},
serde_qs::Error::ParseInt(_) => Self::SerdeQsError {
error_message: "Failed to parse integer in request".to_owned(),
param: None,
},
serde_qs::Error::Utf8(_) => Self::SerdeQsError {
error_message: "Failed to convert utf8 to string".to_owned(),
param: None,
},
}
}
}
impl ErrorSwitch<StripeErrorCode> for errors::ApiErrorResponse {
fn switch(&self) -> StripeErrorCode {
self.clone().into()
}
}
impl crate::services::EmbedError for error_stack::Report<StripeErrorCode> {}
impl ErrorSwitch<StripeErrorCode> for CustomersErrorResponse {
fn switch(&self) -> StripeErrorCode {
use StripeErrorCode as SC;
match self {
Self::CustomerRedacted => SC::CustomerRedacted,
Self::InternalServerError => SC::InternalServerError,
Self::MandateActive => SC::MandateActive,
Self::CustomerNotFound => SC::CustomerNotFound,
Self::CustomerAlreadyExists => SC::DuplicateCustomer,
}
}
}
|
crates/router/src/compatibility/stripe/errors.rs#chunk1
|
router
|
chunk
| null | null | null | 382
| null | null | null | null | null | null | null |
// Struct: VoidStatus
// File: crates/hyperswitch_connectors/src/connectors/silverflow/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct VoidStatus
|
crates/hyperswitch_connectors/src/connectors/silverflow/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
VoidStatus
| 0
|
[] | 46
| null | null | null | null | null | null | null |
// Implementation: impl api::Refund for for Nmi
// File: crates/hyperswitch_connectors/src/connectors/nmi.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::Refund for for Nmi
|
crates/hyperswitch_connectors/src/connectors/nmi.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 57
| null |
Nmi
|
api::Refund for
| 0
| 0
| null | null |
// Implementation: impl api::MandateSetup for for Payu
// File: crates/hyperswitch_connectors/src/connectors/payu.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::MandateSetup for for Payu
|
crates/hyperswitch_connectors/src/connectors/payu.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 61
| null |
Payu
|
api::MandateSetup for
| 0
| 0
| null | null |
// Implementation: impl ConnectorCommon for for Worldpay
// File: crates/hyperswitch_connectors/src/connectors/worldpay.rs
// Module: hyperswitch_connectors
// Methods: 6 total (0 public)
impl ConnectorCommon for for Worldpay
|
crates/hyperswitch_connectors/src/connectors/worldpay.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 53
| null |
Worldpay
|
ConnectorCommon for
| 6
| 0
| null | null |
// Struct: InvoiceEstimate
// File: crates/hyperswitch_connectors/src/connectors/chargebee/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct InvoiceEstimate
|
crates/hyperswitch_connectors/src/connectors/chargebee/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
InvoiceEstimate
| 0
|
[] | 48
| null | null | null | null | null | null | null |
// Struct: TokenioPaymentObjectV2
// File: crates/hyperswitch_connectors/src/connectors/tokenio/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct TokenioPaymentObjectV2
|
crates/hyperswitch_connectors/src/connectors/tokenio/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
TokenioPaymentObjectV2
| 0
|
[] | 53
| null | null | null | null | null | null | null |
// Function: get_default_payout_connector
// File: crates/router/src/core/payouts/helpers.rs
// Module: router
pub fn get_default_payout_connector(
_state: &SessionState,
request_connector: Option<serde_json::Value>,
) -> CustomResult<api::ConnectorChoice, errors::ApiErrorResponse>
|
crates/router/src/core/payouts/helpers.rs
|
router
|
function_signature
| null | null | null | 69
|
get_default_payout_connector
| null | null | null | null | null | null |
// Struct: MpgsErrorResponse
// File: crates/hyperswitch_connectors/src/connectors/mpgs/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct MpgsErrorResponse
|
crates/hyperswitch_connectors/src/connectors/mpgs/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
MpgsErrorResponse
| 0
|
[] | 49
| null | null | null | null | null | null | null |
// Implementation: impl Sift
// File: crates/hyperswitch_connectors/src/connectors/sift.rs
// Module: hyperswitch_connectors
// Methods: 1 total (1 public)
impl Sift
|
crates/hyperswitch_connectors/src/connectors/sift.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 45
| null |
Sift
| null | 1
| 1
| null | null |
// Implementation: impl api::Payment for for Barclaycard
// File: crates/hyperswitch_connectors/src/connectors/barclaycard.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::Payment for for Barclaycard
|
crates/hyperswitch_connectors/src/connectors/barclaycard.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 59
| null |
Barclaycard
|
api::Payment for
| 0
| 0
| null | null |
// File: crates/hyperswitch_connectors/src/connectors/paysafe/transformers.rs
// Module: hyperswitch_connectors
// Public functions: 8
// Public structs: 41
use std::collections::HashMap;
use base64::Engine;
use cards::CardNumber;
use common_enums::{enums, Currency};
use common_types::payments::{ApplePayPaymentData, ApplePayPredecryptData};
use common_utils::{
id_type,
pii::{Email, IpAddress, SecretSerdeValue},
request::Method,
types::MinorUnit,
};
use error_stack::ResultExt;
use hyperswitch_domain_models::{
payment_method_data::{
ApplePayWalletData, BankRedirectData, GiftCardData, PaymentMethodData, WalletData,
},
router_data::{ConnectorAuthType, PaymentMethodToken, RouterData},
router_flow_types::refunds::{Execute, RSync},
router_request_types::{
CompleteAuthorizeData, PaymentsAuthorizeData, PaymentsPreProcessingData, PaymentsSyncData,
ResponseId,
},
router_response_types::{PaymentsResponseData, RedirectForm, RefundsResponseData},
types::{
PaymentsAuthorizeRouterData, PaymentsCancelRouterData, PaymentsCaptureRouterData,
PaymentsCompleteAuthorizeRouterData, PaymentsPreProcessingRouterData, RefundsRouterData,
},
};
use hyperswitch_interfaces::{consts, errors};
use masking::{ExposeInterface, PeekInterface, Secret};
use serde::{Deserialize, Serialize};
use crate::{
types::{RefundsResponseRouterData, ResponseRouterData},
utils::{
self, missing_field_err, to_connector_meta, BrowserInformationData, CardData,
PaymentsAuthorizeRequestData, PaymentsCompleteAuthorizeRequestData,
PaymentsPreProcessingRequestData, RouterData as _,
},
};
pub struct PaysafeRouterData<T> {
pub amount: MinorUnit, // The type of amount that a connector accepts, for example, String, i64, f64, etc.
pub router_data: T,
}
impl<T> From<(MinorUnit, T)> for PaysafeRouterData<T> {
fn from((amount, item): (MinorUnit, T)) -> Self {
Self {
amount,
router_data: item,
}
}
}
#[derive(Debug, Default, Serialize, Deserialize)]
pub struct PaysafeConnectorMetadataObject {
pub account_id: PaysafePaymentMethodDetails,
}
#[derive(Debug, Default, Serialize, Deserialize)]
pub struct PaysafePaymentMethodDetails {
pub apple_pay: Option<HashMap<Currency, ApplePayAccountDetails>>,
pub card: Option<HashMap<Currency, CardAccountId>>,
pub interac: Option<HashMap<Currency, RedirectAccountId>>,
pub pay_safe_card: Option<HashMap<Currency, RedirectAccountId>>,
pub skrill: Option<HashMap<Currency, RedirectAccountId>>,
}
#[derive(Debug, Default, Serialize, Deserialize)]
pub struct CardAccountId {
no_three_ds: Option<Secret<String>>,
three_ds: Option<Secret<String>>,
}
#[derive(Debug, Default, Serialize, Deserialize)]
pub struct ApplePayAccountDetails {
encrypt: Option<Secret<String>>,
decrypt: Option<Secret<String>>,
}
#[derive(Debug, Default, Serialize, Deserialize)]
pub struct RedirectAccountId {
three_ds: Option<Secret<String>>,
}
impl TryFrom<&Option<SecretSerdeValue>> for PaysafeConnectorMetadataObject {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(meta_data: &Option<SecretSerdeValue>) -> Result<Self, Self::Error> {
let metadata: Self = utils::to_connector_meta_from_secret::<Self>(meta_data.clone())
.change_context(errors::ConnectorError::InvalidConnectorConfig {
config: "merchant_connector_account.metadata",
})?;
Ok(metadata)
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ThreeDs {
pub merchant_url: String,
pub device_channel: DeviceChannel,
pub message_category: ThreeDsMessageCategory,
pub authentication_purpose: ThreeDsAuthenticationPurpose,
pub requestor_challenge_preference: ThreeDsChallengePreference,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "UPPERCASE")]
pub enum DeviceChannel {
Browser,
Sdk,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum ThreeDsMessageCategory {
Payment,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum ThreeDsAuthenticationPurpose {
PaymentTransaction,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum ThreeDsChallengePreference {
ChallengeMandated,
NoPreference,
NoChallengeRequested,
ChallengeRequested,
}
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct PaysafePaymentHandleRequest {
pub merchant_ref_num: String,
pub amount: MinorUnit,
pub settle_with_auth: bool,
#[serde(flatten)]
pub payment_method: PaysafePaymentMethod,
pub currency_code: Currency,
pub payment_type: PaysafePaymentType,
pub transaction_type: TransactionType,
pub return_links: Vec<ReturnLink>,
pub account_id: Secret<String>,
pub three_ds: Option<ThreeDs>,
pub profile: Option<PaysafeProfile>,
}
#[derive(Debug, Serialize, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct PaysafeProfile {
pub first_name: Secret<String>,
pub last_name: Secret<String>,
pub email: Email,
}
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
#[serde(untagged)]
pub enum PaysafePaymentMethod {
ApplePay {
#[serde(rename = "applePay")]
apple_pay: Box<PaysafeApplepayPayment>,
},
Card {
card: PaysafeCard,
},
Interac {
#[serde(rename = "interacEtransfer")]
interac_etransfer: InteracBankRedirect,
},
PaysafeCard {
#[serde(rename = "paysafecard")]
pay_safe_card: PaysafeGiftCard,
},
Skrill {
skrill: SkrillWallet,
},
}
#[derive(Debug, Eq, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct PaysafeApplepayPayment {
pub label: Option<String>,
pub request_billing_address: Option<bool>,
#[serde(rename = "applePayPaymentToken")]
pub apple_pay_payment_token: PaysafeApplePayPaymentToken,
}
#[derive(Debug, Eq, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct PaysafeApplePayPaymentToken {
pub token: PaysafeApplePayToken,
#[serde(skip_serializing_if = "Option::is_none")]
pub billing_contact: Option<PaysafeApplePayBillingContact>,
}
#[derive(Debug, Eq, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct PaysafeApplePayToken {
pub payment_data: PaysafeApplePayPaymentData,
pub payment_method: PaysafeApplePayPaymentMethod,
pub transaction_identifier: String,
}
#[derive(Debug, Eq, PartialEq, Serialize)]
#[serde(untagged)]
pub enum PaysafeApplePayPaymentData {
Encrypted(PaysafeApplePayEncryptedData),
Decrypted(PaysafeApplePayDecryptedDataWrapper),
}
#[derive(Debug, Eq, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct PaysafeApplePayEncryptedData {
pub data: Secret<String>,
pub signature: Secret<String>,
pub header: PaysafeApplePayHeader,
pub version: Secret<String>,
}
#[derive(Debug, Eq, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct PaysafeApplePayDecryptedDataWrapper {
pub decrypted_data: PaysafeApplePayDecryptedData,
}
#[derive(Debug, Eq, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct PaysafeApplePayDecryptedData {
pub application_primary_account_number: CardNumber,
pub application_expiration_date: Secret<String>,
pub currency_code: String,
pub transaction_amount: Option<MinorUnit>,
pub cardholder_name: Option<Secret<String>>,
pub device_manufacturer_identifier: Option<String>,
pub payment_data_type: Option<String>,
pub payment_data: PaysafeApplePayDecryptedPaymentData,
}
#[derive(Debug, Eq, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct PaysafeApplePayDecryptedPaymentData {
pub online_payment_cryptogram: Secret<String>,
pub eci_indicator: Option<String>,
}
#[derive(Debug, Eq, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct PaysafeApplePayHeader {
pub public_key_hash: String,
pub ephemeral_public_key: String,
pub transaction_id: String,
}
#[derive(Debug, Eq, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct PaysafeApplePayPaymentMethod {
pub display_name: Secret<String>,
pub network: Secret<String>,
#[serde(rename = "type")]
pub method_type: Secret<String>,
}
#[derive(Debug, Eq, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct PaysafeApplePayBillingContact {
pub address_lines: Vec<Option<Secret<String>>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub administrative_area: Option<Secret<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub country: Option<String>,
pub country_code: api_models::enums::CountryAlpha2,
#[serde(skip_serializing_if = "Option::is_none")]
pub family_name: Option<Secret<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub given_name: Option<Secret<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub locality: Option<Secret<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub phonetic_family_name: Option<Secret<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub phonetic_given_name: Option<Secret<String>>,
pub postal_code: Secret<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub sub_administrative_area: Option<Secret<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub sub_locality: Option<Secret<String>>,
}
#[derive(Debug, Serialize, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct SkrillWallet {
pub consumer_id: Email,
pub country_code: Option<api_models::enums::CountryAlpha2>,
}
#[derive(Debug, Serialize, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct InteracBankRedirect {
pub consumer_id: Email,
}
#[derive(Debug, Serialize, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct PaysafeGiftCard {
pub consumer_id: id_type::CustomerId,
}
#[derive(Debug, Serialize)]
pub struct ReturnLink {
pub rel: LinkType,
pub href: String,
pub method: String,
}
#[derive(Debug, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum LinkType {
OnCompleted,
OnFailed,
OnCancelled,
Default,
}
#[derive(Debug, Serialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum PaysafePaymentType {
// For Apple Pay and Google Pay, paymentType is 'CARD' as per Paysafe docs and is not reserved for card payments only
Card,
Skrill,
InteracEtransfer,
Paysafecard,
}
#[derive(Debug, Serialize)]
pub enum TransactionType {
#[serde(rename = "PAYMENT")]
Payment,
}
impl PaysafePaymentMethodDetails {
pub fn get_applepay_encrypt_account_id(
&self,
currency: Currency,
) -> Result<Secret<String>, errors::ConnectorError> {
self.apple_pay
.as_ref()
.and_then(|apple_pay| apple_pay.get(¤cy))
.and_then(|flow| flow.encrypt.clone())
.ok_or_else(|| errors::ConnectorError::InvalidConnectorConfig {
config: "Missing ApplePay encrypt account_id",
})
}
pub fn get_applepay_decrypt_account_id(
&self,
currency: Currency,
) -> Result<Secret<String>, errors::ConnectorError> {
self.apple_pay
.as_ref()
.and_then(|apple_pay| apple_pay.get(¤cy))
.and_then(|flow| flow.decrypt.clone())
.ok_or_else(|| errors::ConnectorError::InvalidConnectorConfig {
config: "Missing ApplePay decrypt account_id",
})
}
pub fn get_no_three_ds_account_id(
&self,
currency: Currency,
) -> Result<Secret<String>, errors::ConnectorError> {
self.card
.as_ref()
.and_then(|cards| cards.get(¤cy))
.and_then(|card| card.no_three_ds.clone())
.ok_or(errors::ConnectorError::InvalidConnectorConfig {
config: "Missing no_3ds account_id",
})
}
pub fn get_three_ds_account_id(
&self,
currency: Currency,
) -> Result<Secret<String>, errors::ConnectorError> {
self.card
.as_ref()
.and_then(|cards| cards.get(¤cy))
.and_then(|card| card.three_ds.clone())
.ok_or(errors::ConnectorError::InvalidConnectorConfig {
config: "Missing 3ds account_id",
})
}
pub fn get_skrill_account_id(
&self,
currency: Currency,
) -> Result<Secret<String>, errors::ConnectorError> {
self.skrill
.as_ref()
.and_then(|wallets| wallets.get(¤cy))
.and_then(|skrill| skrill.three_ds.clone())
.ok_or(errors::ConnectorError::InvalidConnectorConfig {
config: "Missing skrill account_id",
})
}
pub fn get_interac_account_id(
&self,
currency: Currency,
) -> Result<Secret<String>, errors::ConnectorError> {
self.interac
.as_ref()
.and_then(|redirects| redirects.get(¤cy))
.and_then(|interac| interac.three_ds.clone())
.ok_or(errors::ConnectorError::InvalidConnectorConfig {
config: "Missing interac account_id",
})
}
pub fn get_paysafe_gift_card_account_id(
&self,
currency: Currency,
) -> Result<Secret<String>, errors::ConnectorError> {
self.pay_safe_card
.as_ref()
.and_then(|gift_cards| gift_cards.get(¤cy))
.and_then(|pay_safe_card| pay_safe_card.three_ds.clone())
.ok_or(errors::ConnectorError::InvalidConnectorConfig {
config: "Missing paysafe gift card account_id",
})
}
}
impl TryFrom<&PaysafeRouterData<&PaymentsPreProcessingRouterData>> for PaysafePaymentHandleRequest {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
item: &PaysafeRouterData<&PaymentsPreProcessingRouterData>,
) -> Result<Self, Self::Error> {
let metadata: PaysafeConnectorMetadataObject =
utils::to_connector_meta_from_secret(item.router_data.connector_meta_data.clone())
.change_context(errors::ConnectorError::InvalidConnectorConfig {
config: "merchant_connector_account.metadata",
})?;
let amount = item.amount;
let currency_code = item.router_data.request.get_currency()?;
let redirect_url = item.router_data.request.get_router_return_url()?;
let return_links = vec![
ReturnLink {
rel: LinkType::Default,
href: redirect_url.clone(),
method: Method::Get.to_string(),
},
ReturnLink {
rel: LinkType::OnCompleted,
href: redirect_url.clone(),
method: Method::Get.to_string(),
},
ReturnLink {
rel: LinkType::OnFailed,
href: redirect_url.clone(),
method: Method::Get.to_string(),
},
ReturnLink {
rel: LinkType::OnCancelled,
href: redirect_url.clone(),
method: Method::Get.to_string(),
},
];
let settle_with_auth = matches!(
item.router_data.request.capture_method,
Some(enums::CaptureMethod::Automatic) | None
);
let transaction_type = TransactionType::Payment;
let (payment_method, payment_type, account_id) =
match item.router_data.request.get_payment_method_data()?.clone() {
PaymentMethodData::Card(req_card) => {
let card = PaysafeCard {
card_num: req_card.card_number.clone(),
card_expiry: PaysafeCardExpiry {
month: req_card.card_exp_month.clone(),
year: req_card.get_expiry_year_4_digit(),
},
cvv: if req_card.card_cvc.clone().expose().is_empty() {
None
} else {
Some(req_card.card_cvc.clone())
},
holder_name: item.router_data.get_optional_billing_full_name(),
};
let payment_method = PaysafePaymentMethod::Card { card: card.clone() };
let payment_type = PaysafePaymentType::Card;
let account_id = metadata
.account_id
.get_no_three_ds_account_id(currency_code)?;
(payment_method, payment_type, account_id)
}
PaymentMethodData::Wallet(wallet_data) => match wallet_data {
WalletData::ApplePay(applepay_data) => {
let is_encrypted = matches!(
applepay_data.payment_data,
ApplePayPaymentData::Encrypted(_)
);
let account_id = if is_encrypted {
metadata
.account_id
.get_applepay_encrypt_account_id(currency_code)?
} else {
metadata
.account_id
.get_applepay_decrypt_account_id(currency_code)?
};
let applepay_payment =
PaysafeApplepayPayment::try_from((&applepay_data, item))?;
let payment_method = PaysafePaymentMethod::ApplePay {
apple_pay: Box::new(applepay_payment),
};
let payment_type = PaysafePaymentType::Card;
(payment_method, payment_type, account_id)
}
WalletData::AliPayQr(_)
| WalletData::AliPayRedirect(_)
| WalletData::AliPayHkRedirect(_)
| WalletData::AmazonPay(_)
| WalletData::AmazonPayRedirect(_)
| WalletData::Paysera(_)
| WalletData::Skrill(_)
| WalletData::BluecodeRedirect {}
| WalletData::MomoRedirect(_)
| WalletData::KakaoPayRedirect(_)
| WalletData::GoPayRedirect(_)
| WalletData::GcashRedirect(_)
| WalletData::ApplePayRedirect(_)
| WalletData::ApplePayThirdPartySdk(_)
| WalletData::DanaRedirect {}
| WalletData::GooglePayRedirect(_)
| WalletData::GooglePay(_)
| WalletData::GooglePayThirdPartySdk(_)
| WalletData::MbWayRedirect(_)
| WalletData::MobilePayRedirect(_)
| WalletData::PaypalSdk(_)
| WalletData::PaypalRedirect(_)
| WalletData::Paze(_)
| WalletData::SamsungPay(_)
| WalletData::TwintRedirect {}
| WalletData::VippsRedirect {}
| WalletData::TouchNGoRedirect(_)
| WalletData::WeChatPayRedirect(_)
| WalletData::CashappQr(_)
| WalletData::SwishQr(_)
| WalletData::WeChatPayQr(_)
| WalletData::RevolutPay(_)
| WalletData::Mifinity(_) => Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("Paysafe"),
))?,
},
_ => Err(errors::ConnectorError::NotImplemented(
"Payment Method".to_string(),
))?,
};
Ok(Self {
merchant_ref_num: item.router_data.connector_request_reference_id.clone(),
amount,
settle_with_auth,
payment_method,
currency_code,
payment_type,
transaction_type,
return_links,
account_id,
three_ds: None,
profile: None,
})
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PaysafePaymentHandleResponse {
pub id: String,
pub merchant_ref_num: String,
pub payment_handle_token: Secret<String>,
pub status: PaysafePaymentHandleStatus,
pub links: Option<Vec<PaymentLink>>,
pub error: Option<Error>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PaymentLink {
pub rel: String,
pub href: String,
}
#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "UPPERCASE")]
pub enum PaysafePaymentHandleStatus {
Initiated,
Payable,
#[default]
Processing,
Failed,
Expired,
Completed,
Error,
}
impl TryFrom<PaysafePaymentHandleStatus> for common_enums::AttemptStatus {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(item: PaysafePaymentHandleStatus) -> Result<Self, Self::Error> {
match item {
PaysafePaymentHandleStatus::Completed => Ok(Self::Authorized),
PaysafePaymentHandleStatus::Failed
| PaysafePaymentHandleStatus::Expired
| PaysafePaymentHandleStatus::Error => Ok(Self::Failure),
// We get an `Initiated` status, with a redirection link from the connector, which indicates that further action is required by the customer,
PaysafePaymentHandleStatus::Initiated => Ok(Self::AuthenticationPending),
PaysafePaymentHandleStatus::Payable | PaysafePaymentHandleStatus::Processing => {
Ok(Self::Pending)
}
}
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct PaysafeMeta {
pub payment_handle_token: Secret<String>,
}
impl<F>
TryFrom<
ResponseRouterData<
F,
PaysafePaymentHandleResponse,
PaymentsPreProcessingData,
PaymentsResponseData,
>,
> for RouterData<F, PaymentsPreProcessingData, PaymentsResponseData>
{
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
item: ResponseRouterData<
F,
PaysafePaymentHandleResponse,
PaymentsPreProcessingData,
PaymentsResponseData,
>,
) -> Result<Self, Self::Error> {
Ok(Self {
status: enums::AttemptStatus::try_from(item.response.status)?,
preprocessing_id: Some(
item.response
.payment_handle_token
.to_owned()
.peek()
.to_string(),
),
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,
}),
..item.data
})
}
}
impl<F>
TryFrom<
ResponseRouterData<F, PaysafePaymentsResponse, PaymentsAuthorizeData, PaymentsResponseData>,
> for RouterData<F, PaymentsAuthorizeData, PaymentsResponseData>
{
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
item: ResponseRouterData<
F,
PaysafePaymentsResponse,
PaymentsAuthorizeData,
PaymentsResponseData,
>,
) -> Result<Self, Self::Error> {
Ok(Self {
status: get_paysafe_payment_status(
item.response.status,
item.data.request.capture_method,
),
response: Ok(PaymentsResponseData::TransactionResponse {
resource_id: ResponseId::ConnectorTransactionId(item.response.id),
redirection_data: Box::new(None),
mandate_reference: Box::new(None),
connector_metadata: None,
network_txn_id: None,
connector_response_reference_id: None,
incremental_authorization_allowed: None,
charges: None,
}),
..item.data
})
}
}
impl<F>
TryFrom<
ResponseRouterData<
F,
PaysafePaymentHandleResponse,
PaymentsAuthorizeData,
PaymentsResponseData,
>,
> for RouterData<F, PaymentsAuthorizeData, PaymentsResponseData>
{
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
item: ResponseRouterData<
F,
PaysafePaymentHandleResponse,
PaymentsAuthorizeData,
PaymentsResponseData,
>,
) -> Result<Self, Self::Error> {
let redirection_data = item
.response
.links
.as_ref()
.and_then(|links| links.first())
.map(|link| RedirectForm::Form {
endpoint: link.href.clone(),
method: Method::Get,
form_fields: Default::default(),
});
let connector_metadata = serde_json::json!(PaysafeMeta {
payment_handle_token: item.response.payment_handle_token.clone(),
});
Ok(Self {
status: common_enums::AttemptStatus::try_from(item.response.status)?,
response: Ok(PaymentsResponseData::TransactionResponse {
resource_id: ResponseId::NoResponseId,
redirection_data: Box::new(redirection_data),
mandate_reference: Box::new(None),
connector_metadata: Some(connector_metadata),
network_txn_id: None,
connector_response_reference_id: None,
incremental_authorization_allowed: None,
charges: None,
}),
..item.data
})
}
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PaysafePaymentsRequest {
pub merchant_ref_num: String,
pub amount: MinorUnit,
pub settle_with_auth: bool,
pub payment_handle_token: Secret<String>,
pub currency_code: Currency,
pub customer_ip: Option<Secret<String, IpAddress>>,
}
#[derive(Debug, Serialize, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct PaysafeCard {
pub card_num: CardNumber,
pub card_expiry: PaysafeCardExpiry,
#[serde(skip_serializing_if = "Option::is_none")]
pub cvv: Option<Secret<String>>,
pub holder_name: Option<Secret<String>>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct PaysafeCardExpiry {
pub month: Secret<String>,
pub year: Secret<String>,
}
#[derive(Debug, Deserialize)]
struct DecryptedApplePayTokenData {
data: Secret<String>,
signature: Secret<String>,
header: DecryptedApplePayTokenHeader,
version: Secret<String>,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
struct DecryptedApplePayTokenHeader {
public_key_hash: String,
ephemeral_public_key: String,
transaction_id: String,
}
fn get_apple_pay_decrypt_data(
apple_pay_predecrypt_data: &ApplePayPredecryptData,
item: &PaysafeRouterData<&PaymentsPreProcessingRouterData>,
) -> Result<PaysafeApplePayDecryptedData, error_stack::Report<errors::ConnectorError>> {
Ok(PaysafeApplePayDecryptedData {
application_primary_account_number: apple_pay_predecrypt_data
.application_primary_account_number
.clone(),
application_expiration_date: apple_pay_predecrypt_data
.get_expiry_date_as_yymm()
.change_context(errors::ConnectorError::InvalidDataFormat {
field_name: "application_expiration_date",
})?,
currency_code: Currency::iso_4217(
item.router_data
.request
.currency
.ok_or_else(missing_field_err("currency"))?,
)
.to_string(),
transaction_amount: Some(item.amount),
cardholder_name: None,
device_manufacturer_identifier: Some("Apple".to_string()),
payment_data_type: Some("3DSecure".to_string()),
payment_data: PaysafeApplePayDecryptedPaymentData {
online_payment_cryptogram: apple_pay_predecrypt_data
.payment_data
.online_payment_cryptogram
.clone(),
eci_indicator: apple_pay_predecrypt_data.payment_data.eci_indicator.clone(),
},
})
}
impl
TryFrom<(
&ApplePayWalletData,
&PaysafeRouterData<&PaymentsPreProcessingRouterData>,
)> for PaysafeApplepayPayment
{
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
(wallet_data, item): (
&ApplePayWalletData,
&PaysafeRouterData<&PaymentsPreProcessingRouterData>,
),
) -> Result<Self, Self::Error> {
let apple_pay_payment_token = PaysafeApplePayPaymentToken {
token: PaysafeApplePayToken {
payment_data: if let Ok(PaymentMethodToken::ApplePayDecrypt(ref token)) =
item.router_data.get_payment_method_token()
{
PaysafeApplePayPaymentData::Decrypted(PaysafeApplePayDecryptedDataWrapper {
decrypted_data: get_apple_pay_decrypt_data(token, item)?,
})
} else {
match &wallet_data.payment_data {
ApplePayPaymentData::Decrypted(applepay_predecrypt_data) => {
PaysafeApplePayPaymentData::Decrypted(
PaysafeApplePayDecryptedDataWrapper {
decrypted_data: get_apple_pay_decrypt_data(
applepay_predecrypt_data,
item,
)?,
},
)
}
ApplePayPaymentData::Encrypted(applepay_encrypt_data) => {
let decoded_data = base64::prelude::BASE64_STANDARD
.decode(applepay_encrypt_data)
.change_context(errors::ConnectorError::InvalidDataFormat {
field_name: "apple_pay_encrypted_data",
})?;
let apple_pay_token: DecryptedApplePayTokenData =
serde_json::from_slice(&decoded_data).change_context(
errors::ConnectorError::InvalidDataFormat {
field_name: "apple_pay_token_json",
},
)?;
PaysafeApplePayPaymentData::Encrypted(PaysafeApplePayEncryptedData {
data: apple_pay_token.data,
signature: apple_pay_token.signature,
header: PaysafeApplePayHeader {
public_key_hash: apple_pay_token.header.public_key_hash,
ephemeral_public_key: apple_pay_token
.header
.ephemeral_public_key,
transaction_id: apple_pay_token.header.transaction_id,
},
version: apple_pay_token.version,
})
}
}
},
payment_method: PaysafeApplePayPaymentMethod {
display_name: Secret::new(wallet_data.payment_method.display_name.clone()),
network: Secret::new(wallet_data.payment_method.network.clone()),
method_type: Secret::new(wallet_data.payment_method.pm_type.clone()),
},
transaction_identifier: wallet_data.transaction_identifier.clone(),
},
billing_contact: Some(PaysafeApplePayBillingContact {
address_lines: vec![
item.router_data.get_optional_billing_line1(),
item.router_data.get_optional_billing_line2(),
],
postal_code: item.router_data.get_billing_zip()?,
country_code: item.router_data.get_billing_country()?,
country: None,
family_name: None,
given_name: None,
locality: None,
phonetic_family_name: None,
phonetic_given_name: None,
sub_administrative_area: None,
administrative_area: None,
sub_locality: None,
}),
};
Ok(Self {
label: None,
request_billing_address: Some(false),
apple_pay_payment_token,
})
}
}
impl TryFrom<&PaysafeRouterData<&PaymentsAuthorizeRouterData>> for PaysafePaymentsRequest {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
item: &PaysafeRouterData<&PaymentsAuthorizeRouterData>,
) -> Result<Self, Self::Error> {
let payment_handle_token = Secret::new(item.router_data.get_preprocessing_id()?);
let amount = item.amount;
let customer_ip = Some(
item.router_data
.request
.get_browser_info()?
.get_ip_address()?,
);
Ok(Self {
merchant_ref_num: item.router_data.connector_request_reference_id.clone(),
payment_handle_token,
amount,
settle_with_auth: item.router_data.request.is_auto_capture()?,
currency_code: item.router_data.request.currency,
customer_ip,
})
}
}
impl TryFrom<&PaysafeRouterData<&PaymentsAuthorizeRouterData>> for PaysafePaymentHandleRequest {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
item: &PaysafeRouterData<&PaymentsAuthorizeRouterData>,
) -> Result<Self, Self::Error> {
let metadata: PaysafeConnectorMetadataObject =
utils::to_connector_meta_from_secret(item.router_data.connector_meta_data.clone())
.change_context(errors::ConnectorError::InvalidConnectorConfig {
config: "merchant_connector_account.metadata",
})?;
let redirect_url_success = item.router_data.request.get_complete_authorize_url()?;
let redirect_url = item.router_data.request.get_router_return_url()?;
let return_links = vec![
ReturnLink {
rel: LinkType::Default,
href: redirect_url.clone(),
method: Method::Get.to_string(),
},
ReturnLink {
rel: LinkType::OnCompleted,
href: redirect_url_success.clone(),
method: Method::Get.to_string(),
},
ReturnLink {
rel: LinkType::OnFailed,
href: redirect_url.clone(),
method: Method::Get.to_string(),
},
ReturnLink {
rel: LinkType::OnCancelled,
href: redirect_url.clone(),
method: Method::Get.to_string(),
},
];
let amount = item.amount;
let currency_code = item.router_data.request.currency;
let settle_with_auth = matches!(
item.router_data.request.capture_method,
Some(enums::CaptureMethod::Automatic) | None
);
let transaction_type = TransactionType::Payment;
let (payment_method, payment_type, account_id, three_ds, profile) =
match item.router_data.request.payment_method_data.clone() {
PaymentMethodData::Card(req_card) => {
let card = PaysafeCard {
card_num: req_card.card_number.clone(),
card_expiry: PaysafeCardExpiry {
month: req_card.card_exp_month.clone(),
year: req_card.get_expiry_year_4_digit(),
},
cvv: if req_card.card_cvc.clone().expose().is_empty() {
None
} else {
Some(req_card.card_cvc.clone())
},
holder_name: item.router_data.get_optional_billing_full_name(),
};
let payment_method = PaysafePaymentMethod::Card { card: card.clone() };
let payment_type = PaysafePaymentType::Card;
let headers = item.router_data.header_payload.clone();
let platform = headers.as_ref().and_then(|h| h.x_client_platform.clone());
let device_channel = match platform {
Some(common_enums::ClientPlatform::Web)
| Some(common_enums::ClientPlatform::Unknown)
| None => DeviceChannel::Browser,
Some(common_enums::ClientPlatform::Ios)
| Some(common_enums::ClientPlatform::Android) => DeviceChannel::Sdk,
};
let account_id = metadata.account_id.get_three_ds_account_id(currency_code)?;
let three_ds = Some(ThreeDs {
merchant_url: item.router_data.request.get_router_return_url()?,
device_channel,
message_category: ThreeDsMessageCategory::Payment,
authentication_purpose: ThreeDsAuthenticationPurpose::PaymentTransaction,
requestor_challenge_preference:
ThreeDsChallengePreference::ChallengeMandated,
});
(payment_method, payment_type, account_id, three_ds, None)
}
PaymentMethodData::Wallet(WalletData::Skrill(_)) => {
let payment_method = PaysafePaymentMethod::Skrill {
skrill: SkrillWallet {
consumer_id: item.router_data.get_billing_email()?,
country_code: item.router_data.get_optional_billing_country(),
},
};
let payment_type = PaysafePaymentType::Skrill;
let account_id = metadata.account_id.get_skrill_account_id(currency_code)?;
(payment_method, payment_type, account_id, None, None)
}
PaymentMethodData::Wallet(_) => Err(errors::ConnectorError::NotImplemented(
"Payment Method".to_string(),
))?,
PaymentMethodData::BankRedirect(BankRedirectData::Interac { .. }) => {
let payment_method = PaysafePaymentMethod::Interac {
interac_etransfer: InteracBankRedirect {
consumer_id: item.router_data.get_billing_email()?,
},
};
let payment_type = PaysafePaymentType::InteracEtransfer;
let account_id = metadata.account_id.get_interac_account_id(currency_code)?;
let profile = Some(PaysafeProfile {
first_name: item.router_data.get_billing_first_name()?,
last_name: item.router_data.get_billing_last_name()?,
email: item.router_data.get_billing_email()?,
});
(payment_method, payment_type, account_id, None, profile)
}
PaymentMethodData::BankRedirect(_) => Err(errors::ConnectorError::NotImplemented(
"Payment Method".to_string(),
))?,
|
crates/hyperswitch_connectors/src/connectors/paysafe/transformers.rs#chunk0
|
hyperswitch_connectors
|
chunk
| null | null | null | 8,192
| null | null | null | null | null | null | null |
// Function: call_psync_api
// File: crates/router/src/core/revenue_recovery/api.rs
// Module: router
pub fn call_psync_api(
state: &SessionState,
global_payment_id: &id_type::GlobalPaymentId,
revenue_recovery_data: &revenue_recovery_types::RevenueRecoveryPaymentData,
force_sync_bool: bool,
expand_attempts_bool: bool,
) -> RouterResult<payments_domain::PaymentStatusData<api_types::PSync>>
|
crates/router/src/core/revenue_recovery/api.rs
|
router
|
function_signature
| null | null | null | 103
|
call_psync_api
| null | null | null | null | null | null |
// Function: skip_ws
// File: crates/euclid/src/frontend/ast/parser.rs
// Module: euclid
pub fn skip_ws<'a, F, O>(inner: F) -> impl FnMut(&'a str) -> ParseResult<&'a str, O>
where
F: FnMut(&'a str) -> ParseResult<&'a str, O> + 'a,
|
crates/euclid/src/frontend/ast/parser.rs
|
euclid
|
function_signature
| null | null | null | 86
|
skip_ws
| null | null | null | null | null | null |
// Struct: StripeUpdateRefundRequest
// File: crates/router/src/compatibility/stripe/refunds/types.rs
// Module: router
// Implementations: 0
pub struct StripeUpdateRefundRequest
|
crates/router/src/compatibility/stripe/refunds/types.rs
|
router
|
struct_definition
|
StripeUpdateRefundRequest
| 0
|
[] | 44
| null | null | null | null | null | null | null |
// File: crates/router/src/types/api/payments_v2.rs
// Module: router
pub use hyperswitch_interfaces::api::payments_v2::{
ConnectorCustomerV2, MandateSetupV2, PaymentApproveV2, PaymentAuthorizeSessionTokenV2,
PaymentAuthorizeV2, PaymentCaptureV2, PaymentIncrementalAuthorizationV2,
PaymentPostCaptureVoidV2, PaymentPostSessionTokensV2, PaymentRejectV2, PaymentSessionUpdateV2,
PaymentSessionV2, PaymentSyncV2, PaymentTokenV2, PaymentUpdateMetadataV2, PaymentV2,
PaymentVoidV2, PaymentsCompleteAuthorizeV2, PaymentsPostProcessingV2, PaymentsPreProcessingV2,
TaxCalculationV2,
};
|
crates/router/src/types/api/payments_v2.rs
|
router
|
full_file
| null | null | null | 158
| null | null | null | null | null | null | null |
// Implementation: impl api::RefundSync for for Cryptopay
// File: crates/hyperswitch_connectors/src/connectors/cryptopay.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::RefundSync for for Cryptopay
|
crates/hyperswitch_connectors/src/connectors/cryptopay.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 63
| null |
Cryptopay
|
api::RefundSync for
| 0
| 0
| null | null |
// Struct: CompleteAuthorizeData
// File: crates/hyperswitch_domain_models/src/router_request_types.rs
// Module: hyperswitch_domain_models
// Implementations: 0
pub struct CompleteAuthorizeData
|
crates/hyperswitch_domain_models/src/router_request_types.rs
|
hyperswitch_domain_models
|
struct_definition
|
CompleteAuthorizeData
| 0
|
[] | 43
| null | null | null | null | null | null | null |
// Struct: BankAccountConnectorDetails
// File: crates/api_models/src/payment_methods.rs
// Module: api_models
// Implementations: 0
pub struct BankAccountConnectorDetails
|
crates/api_models/src/payment_methods.rs
|
api_models
|
struct_definition
|
BankAccountConnectorDetails
| 0
|
[] | 38
| null | null | null | null | null | null | null |
// Implementation: impl PayoutAttemptNew
// File: crates/diesel_models/src/query/payout_attempt.rs
// Module: diesel_models
// Methods: 1 total (0 public)
impl PayoutAttemptNew
|
crates/diesel_models/src/query/payout_attempt.rs
|
diesel_models
|
impl_block
| null | null | null | 44
| null |
PayoutAttemptNew
| null | 1
| 0
| null | null |
// Implementation: impl api::MandateSetup for for Nuvei
// File: crates/hyperswitch_connectors/src/connectors/nuvei.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::MandateSetup for for Nuvei
|
crates/hyperswitch_connectors/src/connectors/nuvei.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 65
| null |
Nuvei
|
api::MandateSetup for
| 0
| 0
| null | null |
// Implementation: impl ConnectorCommon for for Mifinity
// File: crates/hyperswitch_connectors/src/connectors/mifinity.rs
// Module: hyperswitch_connectors
// Methods: 6 total (0 public)
impl ConnectorCommon for for Mifinity
|
crates/hyperswitch_connectors/src/connectors/mifinity.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 56
| null |
Mifinity
|
ConnectorCommon for
| 6
| 0
| null | null |
// Struct: BamboraPaymentsResponse
// File: crates/hyperswitch_connectors/src/connectors/bambora/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct BamboraPaymentsResponse
|
crates/hyperswitch_connectors/src/connectors/bambora/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
BamboraPaymentsResponse
| 0
|
[] | 52
| null | null | null | null | null | null | null |
// Implementation: impl SecretsHandler for for AnalyticsConfig
// File: crates/analytics/src/lib.rs
// Module: analytics
// Methods: 1 total (0 public)
impl SecretsHandler for for AnalyticsConfig
|
crates/analytics/src/lib.rs
|
analytics
|
impl_block
| null | null | null | 43
| null |
AnalyticsConfig
|
SecretsHandler for
| 1
| 0
| null | null |
// File: crates/hyperswitch_domain_models/src/ext_traits.rs
// Module: hyperswitch_domain_models
use common_utils::{
errors::{self, CustomResult},
ext_traits::ValueExt,
fp_utils::when,
};
use error_stack::ResultExt;
use crate::errors::api_error_response;
pub type DomainResult<T> = CustomResult<T, api_error_response::ApiErrorResponse>;
pub trait OptionExt<T> {
fn check_value_present(&self, field_name: &'static str) -> DomainResult<()>;
fn get_required_value(self, field_name: &'static str) -> DomainResult<T>;
fn parse_enum<E>(self, enum_name: &'static str) -> CustomResult<E, errors::ParsingError>
where
T: AsRef<str>,
E: std::str::FromStr,
// Requirement for converting the `Err` variant of `FromStr` to `Report<Err>`
<E as std::str::FromStr>::Err: std::error::Error + Send + Sync + 'static;
fn parse_value<U>(self, type_name: &'static str) -> CustomResult<U, errors::ParsingError>
where
T: ValueExt,
U: serde::de::DeserializeOwned;
fn update_value(&mut self, value: Option<T>);
}
impl<T> OptionExt<T> for Option<T> {
fn check_value_present(&self, field_name: &'static str) -> DomainResult<()> {
when(self.is_none(), || {
Err(error_stack::Report::new(
api_error_response::ApiErrorResponse::MissingRequiredField { field_name },
)
.attach_printable(format!("Missing required field {field_name}")))
})
}
// This will allow the error message that was generated in this function to point to the call site
#[track_caller]
fn get_required_value(self, field_name: &'static str) -> DomainResult<T> {
match self {
Some(v) => Ok(v),
None => Err(error_stack::Report::new(
api_error_response::ApiErrorResponse::MissingRequiredField { field_name },
)
.attach_printable(format!("Missing required field {field_name}"))),
}
}
fn parse_enum<E>(self, enum_name: &'static str) -> CustomResult<E, errors::ParsingError>
where
T: AsRef<str>,
E: std::str::FromStr,
<E as std::str::FromStr>::Err: std::error::Error + Send + Sync + 'static,
{
let value = self
.get_required_value(enum_name)
.change_context(errors::ParsingError::UnknownError)?;
E::from_str(value.as_ref())
.change_context(errors::ParsingError::UnknownError)
.attach_printable_lazy(|| format!("Invalid {{ {enum_name} }} "))
}
fn parse_value<U>(self, type_name: &'static str) -> CustomResult<U, errors::ParsingError>
where
T: ValueExt,
U: serde::de::DeserializeOwned,
{
let value = self
.get_required_value(type_name)
.change_context(errors::ParsingError::UnknownError)?;
value.parse_value(type_name)
}
fn update_value(&mut self, value: Self) {
if let Some(a) = value {
*self = Some(a)
}
}
}
|
crates/hyperswitch_domain_models/src/ext_traits.rs
|
hyperswitch_domain_models
|
full_file
| null | null | null | 728
| null | null | null | null | null | null | null |
// Struct: FiservResponseOrders
// File: crates/hyperswitch_connectors/src/connectors/fiserv/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct FiservResponseOrders
|
crates/hyperswitch_connectors/src/connectors/fiserv/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
FiservResponseOrders
| 0
|
[] | 52
| null | null | null | null | null | null | null |
// Struct: PayeezyErrorResponse
// File: crates/hyperswitch_connectors/src/connectors/payeezy/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct PayeezyErrorResponse
|
crates/hyperswitch_connectors/src/connectors/payeezy/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
PayeezyErrorResponse
| 0
|
[] | 50
| null | null | null | null | null | null | null |
// Module Structure
// File: crates/router/src/routes/disputes.rs
// Module: router
// Public submodules:
pub mod utils;
|
crates/router/src/routes/disputes.rs
|
router
|
module_structure
| null | null | null | 30
| null | null | null | null | null | 1
| 0
|
// Implementation: impl api::MandateSetup for for Phonepe
// File: crates/hyperswitch_connectors/src/connectors/phonepe.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::MandateSetup for for Phonepe
|
crates/hyperswitch_connectors/src/connectors/phonepe.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 62
| null |
Phonepe
|
api::MandateSetup for
| 0
| 0
| null | null |
// Struct: DestinationChargeRefund
// File: crates/hyperswitch_domain_models/src/router_request_types.rs
// Module: hyperswitch_domain_models
// Implementations: 0
pub struct DestinationChargeRefund
|
crates/hyperswitch_domain_models/src/router_request_types.rs
|
hyperswitch_domain_models
|
struct_definition
|
DestinationChargeRefund
| 0
|
[] | 45
| null | null | null | null | null | null | null |
// Struct: FiuuPaymentRedirectResponse
// File: crates/hyperswitch_connectors/src/connectors/fiuu/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct FiuuPaymentRedirectResponse
|
crates/hyperswitch_connectors/src/connectors/fiuu/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
FiuuPaymentRedirectResponse
| 0
|
[] | 54
| null | null | null | null | null | null | null |
// Struct: GlobepayPaymentsResponse
// File: crates/hyperswitch_connectors/src/connectors/globepay/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct GlobepayPaymentsResponse
|
crates/hyperswitch_connectors/src/connectors/globepay/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
GlobepayPaymentsResponse
| 0
|
[] | 53
| null | null | null | null | null | null | null |
// Struct: Links
// File: crates/hyperswitch_connectors/src/connectors/checkout/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct Links
|
crates/hyperswitch_connectors/src/connectors/checkout/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
Links
| 0
|
[] | 43
| null | null | null | null | null | null | null |
// File: crates/router/src/routes/user.rs
// Module: router
// Public functions: 50
pub mod theme;
use actix_web::{web, HttpRequest, HttpResponse};
#[cfg(feature = "dummy_connector")]
use api_models::user::sample_data::SampleDataRequest;
use api_models::{
errors::types::ApiErrorResponse,
user::{self as user_api},
};
use common_enums::TokenPurpose;
use common_utils::errors::ReportSwitchExt;
use router_env::Flow;
use super::AppState;
use crate::{
core::{api_locking, user as user_core},
services::{
api,
authentication::{self as auth},
authorization::permissions::Permission,
},
utils::user::dashboard_metadata::{parse_string_to_enums, set_ip_address_if_required},
};
pub async fn get_user_details(state: web::Data<AppState>, req: HttpRequest) -> HttpResponse {
let flow = Flow::GetUserDetails;
Box::pin(api::server_wrap(
flow,
state,
&req,
(),
|state, user, _, _| user_core::get_user_details(state, user),
&auth::DashboardNoPermissionAuth,
api_locking::LockAction::NotApplicable,
))
.await
}
#[cfg(feature = "email")]
pub async fn user_signup_with_merchant_id(
state: web::Data<AppState>,
http_req: HttpRequest,
json_payload: web::Json<user_api::SignUpWithMerchantIdRequest>,
query: web::Query<user_api::AuthIdAndThemeIdQueryParam>,
) -> HttpResponse {
let flow = Flow::UserSignUpWithMerchantId;
let req_payload = json_payload.into_inner();
let query_params = query.into_inner();
Box::pin(api::server_wrap(
flow.clone(),
state,
&http_req,
req_payload.clone(),
|state, _, req_body, _| {
user_core::signup_with_merchant_id(
state,
req_body,
query_params.auth_id.clone(),
query_params.theme_id.clone(),
)
},
&auth::AdminApiAuth,
api_locking::LockAction::NotApplicable,
))
.await
}
pub async fn user_signup(
state: web::Data<AppState>,
http_req: HttpRequest,
json_payload: web::Json<user_api::SignUpRequest>,
) -> HttpResponse {
let flow = Flow::UserSignUp;
let req_payload = json_payload.into_inner();
Box::pin(api::server_wrap(
flow.clone(),
state,
&http_req,
req_payload.clone(),
|state, _: (), req_body, _| async move {
user_core::signup_token_only_flow(state, req_body).await
},
&auth::NoAuth,
api_locking::LockAction::NotApplicable,
))
.await
}
pub async fn user_signin(
state: web::Data<AppState>,
http_req: HttpRequest,
json_payload: web::Json<user_api::SignInRequest>,
) -> HttpResponse {
let flow = Flow::UserSignIn;
let req_payload = json_payload.into_inner();
Box::pin(api::server_wrap(
flow.clone(),
state,
&http_req,
req_payload.clone(),
|state, _: (), req_body, _| async move {
user_core::signin_token_only_flow(state, req_body).await
},
&auth::NoAuth,
api_locking::LockAction::NotApplicable,
))
.await
}
#[cfg(feature = "email")]
pub async fn user_connect_account(
state: web::Data<AppState>,
http_req: HttpRequest,
json_payload: web::Json<user_api::ConnectAccountRequest>,
query: web::Query<user_api::AuthIdAndThemeIdQueryParam>,
) -> HttpResponse {
let flow = Flow::UserConnectAccount;
let req_payload = json_payload.into_inner();
let query_params = query.into_inner();
Box::pin(api::server_wrap(
flow.clone(),
state,
&http_req,
req_payload.clone(),
|state, _: (), req_body, _| {
user_core::connect_account(
state,
req_body,
query_params.auth_id.clone(),
query_params.theme_id.clone(),
)
},
&auth::NoAuth,
api_locking::LockAction::NotApplicable,
))
.await
}
pub async fn signout(state: web::Data<AppState>, http_req: HttpRequest) -> HttpResponse {
let flow = Flow::Signout;
Box::pin(api::server_wrap(
flow,
state.clone(),
&http_req,
(),
|state, user, _, _| user_core::signout(state, user),
&auth::AnyPurposeOrLoginTokenAuth,
api_locking::LockAction::NotApplicable,
))
.await
}
pub async fn change_password(
state: web::Data<AppState>,
http_req: HttpRequest,
json_payload: web::Json<user_api::ChangePasswordRequest>,
) -> HttpResponse {
let flow = Flow::ChangePassword;
Box::pin(api::server_wrap(
flow,
state.clone(),
&http_req,
json_payload.into_inner(),
|state, user, req, _| user_core::change_password(state, req, user),
&auth::DashboardNoPermissionAuth,
api_locking::LockAction::NotApplicable,
))
.await
}
pub async fn set_dashboard_metadata(
state: web::Data<AppState>,
req: HttpRequest,
json_payload: web::Json<user_api::dashboard_metadata::SetMetaDataRequest>,
) -> HttpResponse {
let flow = Flow::SetDashboardMetadata;
let mut payload = json_payload.into_inner();
if let Err(e) = ReportSwitchExt::<(), ApiErrorResponse>::switch(set_ip_address_if_required(
&mut payload,
req.headers(),
)) {
return api::log_and_return_error_response(e);
}
Box::pin(api::server_wrap(
flow,
state,
&req,
payload,
user_core::dashboard_metadata::set_metadata,
&auth::JWTAuth {
permission: Permission::ProfileAccountWrite,
},
api_locking::LockAction::NotApplicable,
))
.await
}
pub async fn get_multiple_dashboard_metadata(
state: web::Data<AppState>,
req: HttpRequest,
query: web::Query<user_api::dashboard_metadata::GetMultipleMetaDataRequest>,
) -> HttpResponse {
let flow = Flow::GetMultipleDashboardMetadata;
let payload = match ReportSwitchExt::<_, ApiErrorResponse>::switch(parse_string_to_enums(
query.into_inner().keys,
)) {
Ok(payload) => payload,
Err(e) => {
return api::log_and_return_error_response(e);
}
};
Box::pin(api::server_wrap(
flow,
state,
&req,
payload,
user_core::dashboard_metadata::get_multiple_metadata,
&auth::DashboardNoPermissionAuth,
api_locking::LockAction::NotApplicable,
))
.await
}
pub async fn internal_user_signup(
state: web::Data<AppState>,
http_req: HttpRequest,
json_payload: web::Json<user_api::CreateInternalUserRequest>,
) -> HttpResponse {
let flow = Flow::InternalUserSignup;
Box::pin(api::server_wrap(
flow,
state.clone(),
&http_req,
json_payload.into_inner(),
|state, _, req, _| user_core::create_internal_user(state, req),
&auth::AdminApiAuth,
api_locking::LockAction::NotApplicable,
))
.await
}
pub async fn create_tenant_user(
state: web::Data<AppState>,
http_req: HttpRequest,
json_payload: web::Json<user_api::CreateTenantUserRequest>,
) -> HttpResponse {
let flow = Flow::TenantUserCreate;
Box::pin(api::server_wrap(
flow,
state.clone(),
&http_req,
json_payload.into_inner(),
|state, _, req, _| user_core::create_tenant_user(state, req),
&auth::AdminApiAuth,
api_locking::LockAction::NotApplicable,
))
.await
}
#[cfg(feature = "v1")]
pub async fn create_platform(
state: web::Data<AppState>,
req: HttpRequest,
json_payload: web::Json<user_api::PlatformAccountCreateRequest>,
) -> HttpResponse {
let flow = Flow::CreatePlatformAccount;
Box::pin(api::server_wrap(
flow,
state,
&req,
json_payload.into_inner(),
|state, user: auth::UserFromToken, json_payload, _| {
user_core::create_platform_account(state, user, json_payload)
},
&auth::JWTAuth {
permission: Permission::OrganizationAccountWrite,
},
api_locking::LockAction::NotApplicable,
))
.await
}
#[cfg(feature = "v1")]
pub async fn user_org_create(
state: web::Data<AppState>,
req: HttpRequest,
json_payload: web::Json<user_api::UserOrgMerchantCreateRequest>,
) -> HttpResponse {
let flow = Flow::UserOrgMerchantCreate;
Box::pin(api::server_wrap(
flow,
state,
&req,
json_payload.into_inner(),
|state, _auth: auth::UserFromToken, json_payload, _| {
user_core::create_org_merchant_for_user(state, json_payload)
},
&auth::JWTAuth {
permission: Permission::TenantAccountWrite,
},
api_locking::LockAction::NotApplicable,
))
.await
}
pub async fn user_merchant_account_create(
state: web::Data<AppState>,
req: HttpRequest,
json_payload: web::Json<user_api::UserMerchantCreate>,
) -> HttpResponse {
let flow = Flow::UserMerchantAccountCreate;
Box::pin(api::server_wrap(
flow,
state,
&req,
json_payload.into_inner(),
|state, auth: auth::UserFromToken, json_payload, _| {
user_core::create_merchant_account(state, auth, json_payload)
},
&auth::JWTAuth {
permission: Permission::OrganizationAccountWrite,
},
api_locking::LockAction::NotApplicable,
))
.await
}
#[cfg(all(feature = "dummy_connector", feature = "v1"))]
pub async fn generate_sample_data(
state: web::Data<AppState>,
http_req: HttpRequest,
payload: web::Json<SampleDataRequest>,
) -> impl actix_web::Responder {
use crate::core::user::sample_data;
let flow = Flow::GenerateSampleData;
Box::pin(api::server_wrap(
flow,
state,
&http_req,
payload.into_inner(),
sample_data::generate_sample_data_for_user,
&auth::JWTAuth {
permission: Permission::MerchantPaymentWrite,
},
api_locking::LockAction::NotApplicable,
))
.await
}
#[cfg(all(feature = "dummy_connector", feature = "v1"))]
pub async fn delete_sample_data(
state: web::Data<AppState>,
http_req: HttpRequest,
payload: web::Json<SampleDataRequest>,
) -> impl actix_web::Responder {
use crate::core::user::sample_data;
let flow = Flow::DeleteSampleData;
Box::pin(api::server_wrap(
flow,
state,
&http_req,
payload.into_inner(),
sample_data::delete_sample_data_for_user,
&auth::JWTAuth {
permission: Permission::MerchantAccountWrite,
},
api_locking::LockAction::NotApplicable,
))
.await
}
pub async fn list_user_roles_details(
state: web::Data<AppState>,
req: HttpRequest,
payload: web::Json<user_api::GetUserRoleDetailsRequest>,
) -> HttpResponse {
let flow = Flow::GetUserRoleDetails;
Box::pin(api::server_wrap(
flow,
state.clone(),
&req,
payload.into_inner(),
user_core::list_user_roles_details,
&auth::JWTAuth {
permission: Permission::ProfileUserRead,
},
api_locking::LockAction::NotApplicable,
))
.await
}
pub async fn rotate_password(
state: web::Data<AppState>,
req: HttpRequest,
payload: web::Json<user_api::RotatePasswordRequest>,
) -> HttpResponse {
let flow = Flow::RotatePassword;
Box::pin(api::server_wrap(
flow,
state.clone(),
&req,
payload.into_inner(),
user_core::rotate_password,
&auth::SinglePurposeJWTAuth(TokenPurpose::ForceSetPassword),
api_locking::LockAction::NotApplicable,
))
.await
}
#[cfg(feature = "email")]
pub async fn forgot_password(
state: web::Data<AppState>,
req: HttpRequest,
payload: web::Json<user_api::ForgotPasswordRequest>,
query: web::Query<user_api::AuthIdAndThemeIdQueryParam>,
) -> HttpResponse {
let flow = Flow::ForgotPassword;
let query_params = query.into_inner();
Box::pin(api::server_wrap(
flow,
state.clone(),
&req,
payload.into_inner(),
|state, _: (), payload, _| {
user_core::forgot_password(
state,
payload,
query_params.auth_id.clone(),
query_params.theme_id.clone(),
)
},
&auth::NoAuth,
api_locking::LockAction::NotApplicable,
))
.await
}
#[cfg(feature = "email")]
pub async fn reset_password(
state: web::Data<AppState>,
req: HttpRequest,
payload: web::Json<user_api::ResetPasswordRequest>,
) -> HttpResponse {
let flow = Flow::ResetPassword;
Box::pin(api::server_wrap(
flow,
state.clone(),
&req,
payload.into_inner(),
|state, user, payload, _| user_core::reset_password_token_only_flow(state, user, payload),
&auth::SinglePurposeJWTAuth(TokenPurpose::ResetPassword),
api_locking::LockAction::NotApplicable,
))
.await
}
pub async fn invite_multiple_user(
state: web::Data<AppState>,
req: HttpRequest,
payload: web::Json<Vec<user_api::InviteUserRequest>>,
auth_id_query_param: web::Query<user_api::AuthIdAndThemeIdQueryParam>,
) -> HttpResponse {
let flow = Flow::InviteMultipleUser;
let auth_id = auth_id_query_param.into_inner().auth_id;
Box::pin(api::server_wrap(
flow,
state.clone(),
&req,
payload.into_inner(),
|state, user, payload, req_state| {
user_core::invite_multiple_user(state, user, payload, req_state, auth_id.clone())
},
&auth::JWTAuth {
permission: Permission::ProfileUserWrite,
},
api_locking::LockAction::NotApplicable,
))
.await
}
#[cfg(feature = "email")]
pub async fn resend_invite(
state: web::Data<AppState>,
req: HttpRequest,
payload: web::Json<user_api::ReInviteUserRequest>,
query: web::Query<user_api::AuthIdAndThemeIdQueryParam>,
) -> HttpResponse {
let flow = Flow::ReInviteUser;
let auth_id = query.into_inner().auth_id;
Box::pin(api::server_wrap(
flow,
state.clone(),
&req,
payload.into_inner(),
|state, user, req_payload, _| {
user_core::resend_invite(state, user, req_payload, auth_id.clone())
},
&auth::JWTAuth {
permission: Permission::ProfileUserWrite,
},
api_locking::LockAction::NotApplicable,
))
.await
}
#[cfg(feature = "email")]
pub async fn accept_invite_from_email(
state: web::Data<AppState>,
req: HttpRequest,
payload: web::Json<user_api::AcceptInviteFromEmailRequest>,
) -> HttpResponse {
let flow = Flow::AcceptInviteFromEmail;
Box::pin(api::server_wrap(
flow.clone(),
state,
&req,
payload.into_inner(),
|state, user, req_payload, _| {
user_core::accept_invite_from_email_token_only_flow(state, user, req_payload)
},
&auth::SinglePurposeJWTAuth(TokenPurpose::AcceptInvitationFromEmail),
api_locking::LockAction::NotApplicable,
))
.await
}
#[cfg(feature = "email")]
pub async fn verify_email(
state: web::Data<AppState>,
http_req: HttpRequest,
json_payload: web::Json<user_api::VerifyEmailRequest>,
) -> HttpResponse {
let flow = Flow::VerifyEmail;
Box::pin(api::server_wrap(
flow.clone(),
state,
&http_req,
json_payload.into_inner(),
|state, user, req_payload, _| {
user_core::verify_email_token_only_flow(state, user, req_payload)
},
&auth::SinglePurposeJWTAuth(TokenPurpose::VerifyEmail),
api_locking::LockAction::NotApplicable,
))
.await
}
#[cfg(feature = "email")]
pub async fn verify_email_request(
state: web::Data<AppState>,
http_req: HttpRequest,
json_payload: web::Json<user_api::SendVerifyEmailRequest>,
query: web::Query<user_api::AuthIdAndThemeIdQueryParam>,
) -> HttpResponse {
let flow = Flow::VerifyEmailRequest;
let query_params = query.into_inner();
Box::pin(api::server_wrap(
flow,
state.clone(),
&http_req,
json_payload.into_inner(),
|state, _: (), req_body, _| {
user_core::send_verification_mail(
state,
req_body,
query_params.auth_id.clone(),
query_params.theme_id.clone(),
)
},
&auth::NoAuth,
api_locking::LockAction::NotApplicable,
))
.await
}
pub async fn update_user_account_details(
state: web::Data<AppState>,
req: HttpRequest,
json_payload: web::Json<user_api::UpdateUserAccountDetailsRequest>,
) -> HttpResponse {
let flow = Flow::UpdateUserAccountDetails;
Box::pin(api::server_wrap(
flow,
state.clone(),
&req,
json_payload.into_inner(),
user_core::update_user_details,
&auth::DashboardNoPermissionAuth,
api_locking::LockAction::NotApplicable,
))
.await
}
#[cfg(feature = "email")]
pub async fn user_from_email(
state: web::Data<AppState>,
req: HttpRequest,
json_payload: web::Json<user_api::UserFromEmailRequest>,
) -> HttpResponse {
let flow = Flow::UserFromEmail;
Box::pin(api::server_wrap(
flow,
state.clone(),
&req,
json_payload.into_inner(),
|state, _: (), req_body, _| user_core::user_from_email(state, req_body),
&auth::NoAuth,
api_locking::LockAction::NotApplicable,
))
.await
}
pub async fn totp_begin(state: web::Data<AppState>, req: HttpRequest) -> HttpResponse {
let flow = Flow::TotpBegin;
Box::pin(api::server_wrap(
flow,
state.clone(),
&req,
(),
|state, user, _, _| user_core::begin_totp(state, user),
&auth::SinglePurposeJWTAuth(TokenPurpose::TOTP),
api_locking::LockAction::NotApplicable,
))
.await
}
pub async fn totp_reset(state: web::Data<AppState>, req: HttpRequest) -> HttpResponse {
let flow = Flow::TotpReset;
Box::pin(api::server_wrap(
flow,
state.clone(),
&req,
(),
|state, user, _, _| user_core::reset_totp(state, user),
&auth::DashboardNoPermissionAuth,
api_locking::LockAction::NotApplicable,
))
.await
}
pub async fn totp_verify(
state: web::Data<AppState>,
req: HttpRequest,
json_payload: web::Json<user_api::VerifyTotpRequest>,
) -> HttpResponse {
let flow = Flow::TotpVerify;
Box::pin(api::server_wrap(
flow,
state.clone(),
&req,
json_payload.into_inner(),
|state, user, req_body, _| user_core::verify_totp(state, user, req_body),
&auth::SinglePurposeOrLoginTokenAuth(TokenPurpose::TOTP),
api_locking::LockAction::NotApplicable,
))
.await
}
pub async fn verify_recovery_code(
state: web::Data<AppState>,
req: HttpRequest,
json_payload: web::Json<user_api::VerifyRecoveryCodeRequest>,
) -> HttpResponse {
let flow = Flow::RecoveryCodeVerify;
Box::pin(api::server_wrap(
flow,
state.clone(),
&req,
json_payload.into_inner(),
|state, user, req_body, _| user_core::verify_recovery_code(state, user, req_body),
&auth::SinglePurposeOrLoginTokenAuth(TokenPurpose::TOTP),
api_locking::LockAction::NotApplicable,
))
.await
}
pub async fn totp_update(
state: web::Data<AppState>,
req: HttpRequest,
json_payload: web::Json<user_api::VerifyTotpRequest>,
) -> HttpResponse {
let flow = Flow::TotpUpdate;
Box::pin(api::server_wrap(
flow,
state.clone(),
&req,
json_payload.into_inner(),
|state, user, req_body, _| user_core::update_totp(state, user, req_body),
&auth::SinglePurposeOrLoginTokenAuth(TokenPurpose::TOTP),
api_locking::LockAction::NotApplicable,
))
.await
}
pub async fn generate_recovery_codes(state: web::Data<AppState>, req: HttpRequest) -> HttpResponse {
let flow = Flow::RecoveryCodesGenerate;
Box::pin(api::server_wrap(
flow,
state.clone(),
&req,
(),
|state, user, _, _| user_core::generate_recovery_codes(state, user),
&auth::SinglePurposeOrLoginTokenAuth(TokenPurpose::TOTP),
api_locking::LockAction::NotApplicable,
))
.await
}
pub async fn terminate_two_factor_auth(
state: web::Data<AppState>,
req: HttpRequest,
query: web::Query<user_api::SkipTwoFactorAuthQueryParam>,
) -> HttpResponse {
let flow = Flow::TerminateTwoFactorAuth;
let skip_two_factor_auth = query.into_inner().skip_two_factor_auth.unwrap_or(false);
Box::pin(api::server_wrap(
flow,
state.clone(),
&req,
(),
|state, user, _, _| user_core::terminate_two_factor_auth(state, user, skip_two_factor_auth),
&auth::SinglePurposeJWTAuth(TokenPurpose::TOTP),
api_locking::LockAction::NotApplicable,
))
.await
}
pub async fn check_two_factor_auth_status(
state: web::Data<AppState>,
req: HttpRequest,
) -> HttpResponse {
let flow = Flow::TwoFactorAuthStatus;
Box::pin(api::server_wrap(
flow,
state.clone(),
&req,
(),
|state, user, _, _| user_core::check_two_factor_auth_status(state, user),
&auth::DashboardNoPermissionAuth,
api_locking::LockAction::NotApplicable,
))
.await
}
pub async fn check_two_factor_auth_status_with_attempts(
state: web::Data<AppState>,
req: HttpRequest,
) -> HttpResponse {
let flow = Flow::TwoFactorAuthStatus;
Box::pin(api::server_wrap(
flow,
state.clone(),
&req,
(),
|state, user, _, _| user_core::check_two_factor_auth_status_with_attempts(state, user),
&auth::SinglePurposeOrLoginTokenAuth(TokenPurpose::TOTP),
api_locking::LockAction::NotApplicable,
))
.await
}
#[cfg(feature = "v1")]
pub async fn get_sso_auth_url(
state: web::Data<AppState>,
req: HttpRequest,
query: web::Query<user_api::GetSsoAuthUrlRequest>,
) -> HttpResponse {
let flow = Flow::GetSsoAuthUrl;
let payload = query.into_inner();
Box::pin(api::server_wrap(
flow,
state.clone(),
&req,
payload,
|state, _: (), req, _| user_core::get_sso_auth_url(state, req),
&auth::NoAuth,
api_locking::LockAction::NotApplicable,
))
.await
}
pub async fn sso_sign(
state: web::Data<AppState>,
req: HttpRequest,
json_payload: web::Json<user_api::SsoSignInRequest>,
) -> HttpResponse {
let flow = Flow::SignInWithSso;
let payload = json_payload.into_inner();
Box::pin(api::server_wrap(
flow,
state.clone(),
&req,
payload,
|state, user: Option<auth::UserFromSinglePurposeToken>, payload, _| {
user_core::sso_sign(state, payload, user)
},
auth::auth_type(
&auth::NoAuth,
&auth::SinglePurposeJWTAuth(TokenPurpose::SSO),
req.headers(),
),
api_locking::LockAction::NotApplicable,
))
.await
}
pub async fn create_user_authentication_method(
state: web::Data<AppState>,
req: HttpRequest,
json_payload: web::Json<user_api::CreateUserAuthenticationMethodRequest>,
) -> HttpResponse {
let flow = Flow::CreateUserAuthenticationMethod;
Box::pin(api::server_wrap(
flow,
state.clone(),
&req,
json_payload.into_inner(),
|state, _, req_body, _| user_core::create_user_authentication_method(state, req_body),
&auth::AdminApiAuth,
api_locking::LockAction::NotApplicable,
))
.await
}
pub async fn update_user_authentication_method(
state: web::Data<AppState>,
req: HttpRequest,
json_payload: web::Json<user_api::UpdateUserAuthenticationMethodRequest>,
) -> HttpResponse {
let flow = Flow::UpdateUserAuthenticationMethod;
Box::pin(api::server_wrap(
flow,
state.clone(),
&req,
json_payload.into_inner(),
|state, _, req_body, _| user_core::update_user_authentication_method(state, req_body),
&auth::AdminApiAuth,
api_locking::LockAction::NotApplicable,
))
.await
}
pub async fn list_user_authentication_methods(
state: web::Data<AppState>,
req: HttpRequest,
query: web::Query<user_api::GetUserAuthenticationMethodsRequest>,
) -> HttpResponse {
let flow = Flow::ListUserAuthenticationMethods;
Box::pin(api::server_wrap(
flow,
state.clone(),
&req,
query.into_inner(),
|state, _: (), req, _| user_core::list_user_authentication_methods(state, req),
&auth::NoAuth,
api_locking::LockAction::NotApplicable,
))
.await
}
pub async fn terminate_auth_select(
state: web::Data<AppState>,
req: HttpRequest,
json_payload: web::Json<user_api::AuthSelectRequest>,
) -> HttpResponse {
let flow = Flow::AuthSelect;
Box::pin(api::server_wrap(
flow,
state.clone(),
&req,
json_payload.into_inner(),
|state, user, req, _| user_core::terminate_auth_select(state, user, req),
&auth::SinglePurposeJWTAuth(TokenPurpose::AuthSelect),
api_locking::LockAction::NotApplicable,
))
.await
}
pub async fn transfer_user_key(
state: web::Data<AppState>,
req: HttpRequest,
payload: web::Json<user_api::UserKeyTransferRequest>,
) -> HttpResponse {
let flow = Flow::UserTransferKey;
Box::pin(api::server_wrap(
flow,
state.clone(),
&req,
payload.into_inner(),
|state, _, req, _| user_core::transfer_user_key_store_keymanager(state, req),
&auth::AdminApiAuth,
api_locking::LockAction::NotApplicable,
))
.await
}
pub async fn list_orgs_for_user(state: web::Data<AppState>, req: HttpRequest) -> HttpResponse {
let flow = Flow::ListOrgForUser;
Box::pin(api::server_wrap(
flow,
state.clone(),
&req,
(),
|state, user_from_token, _, _| user_core::list_orgs_for_user(state, user_from_token),
&auth::DashboardNoPermissionAuth,
api_locking::LockAction::NotApplicable,
))
.await
}
pub async fn list_merchants_for_user_in_org(
state: web::Data<AppState>,
req: HttpRequest,
) -> HttpResponse {
let flow = Flow::ListMerchantsForUserInOrg;
Box::pin(api::server_wrap(
flow,
state.clone(),
&req,
(),
|state, user_from_token, _, _| {
user_core::list_merchants_for_user_in_org(state, user_from_token)
},
&auth::DashboardNoPermissionAuth,
api_locking::LockAction::NotApplicable,
))
.await
}
pub async fn list_profiles_for_user_in_org_and_merchant(
state: web::Data<AppState>,
req: HttpRequest,
) -> HttpResponse {
let flow = Flow::ListProfileForUserInOrgAndMerchant;
Box::pin(api::server_wrap(
flow,
state.clone(),
&req,
(),
|state, user_from_token, _, _| {
user_core::list_profiles_for_user_in_org_and_merchant_account(state, user_from_token)
},
&auth::DashboardNoPermissionAuth,
api_locking::LockAction::NotApplicable,
))
.await
}
pub async fn switch_org_for_user(
state: web::Data<AppState>,
http_req: HttpRequest,
json_payload: web::Json<user_api::SwitchOrganizationRequest>,
) -> HttpResponse {
let flow = Flow::SwitchOrg;
Box::pin(api::server_wrap(
flow,
state.clone(),
&http_req,
json_payload.into_inner(),
|state, user, req, _| user_core::switch_org_for_user(state, req, user),
&auth::DashboardNoPermissionAuth,
api_locking::LockAction::NotApplicable,
))
.await
}
pub async fn switch_merchant_for_user_in_org(
state: web::Data<AppState>,
http_req: HttpRequest,
json_payload: web::Json<user_api::SwitchMerchantRequest>,
) -> HttpResponse {
let flow = Flow::SwitchMerchantV2;
Box::pin(api::server_wrap(
flow,
state.clone(),
&http_req,
json_payload.into_inner(),
|state, user, req, _| user_core::switch_merchant_for_user_in_org(state, req, user),
&auth::DashboardNoPermissionAuth,
api_locking::LockAction::NotApplicable,
))
.await
}
pub async fn switch_profile_for_user_in_org_and_merchant(
state: web::Data<AppState>,
http_req: HttpRequest,
json_payload: web::Json<user_api::SwitchProfileRequest>,
) -> HttpResponse {
let flow = Flow::SwitchProfile;
Box::pin(api::server_wrap(
flow,
state.clone(),
&http_req,
json_payload.into_inner(),
|state, user, req, _| {
user_core::switch_profile_for_user_in_org_and_merchant(state, req, user)
},
&auth::DashboardNoPermissionAuth,
api_locking::LockAction::NotApplicable,
))
.await
}
#[cfg(feature = "v1")]
pub async fn clone_connector(
state: web::Data<AppState>,
req: HttpRequest,
json_payload: web::Json<user_api::CloneConnectorRequest>,
) -> HttpResponse {
let flow = Flow::CloneConnector;
Box::pin(api::server_wrap(
flow,
state.clone(),
&req,
json_payload.into_inner(),
|state, _: auth::UserFromToken, req, _| user_core::clone_connector(state, req),
&auth::JWTAuth {
permission: Permission::MerchantInternalConnectorWrite,
},
api_locking::LockAction::NotApplicable,
))
.await
}
|
crates/router/src/routes/user.rs
|
router
|
full_file
| null | null | null | 7,101
| null | null | null | null | null | null | null |
// Struct: OrderRequestAmount
// File: crates/hyperswitch_connectors/src/connectors/paypal/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct OrderRequestAmount
|
crates/hyperswitch_connectors/src/connectors/paypal/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
OrderRequestAmount
| 0
|
[] | 47
| null | null | null | null | null | null | null |
// Implementation: impl Payment for for Riskified
// File: crates/hyperswitch_connectors/src/connectors/riskified.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl Payment for for Riskified
|
crates/hyperswitch_connectors/src/connectors/riskified.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 52
| null |
Riskified
|
Payment for
| 0
| 0
| null | null |
// Function: payment_get
// File: crates/external_services/src/grpc_client/unified_connector_service.rs
// Module: external_services
// Documentation: Performs Payment Sync/Get
pub fn payment_get(
&self,
payment_get_request: payments_grpc::PaymentServiceGetRequest,
connector_auth_metadata: ConnectorAuthMetadata,
grpc_headers: GrpcHeadersUcs,
) -> UnifiedConnectorServiceResult<tonic::Response<payments_grpc::PaymentServiceGetResponse>>
|
crates/external_services/src/grpc_client/unified_connector_service.rs
|
external_services
|
function_signature
| null | null | null | 102
|
payment_get
| null | null | null | null | null | null |
// Implementation: impl Responder
// File: crates/router/src/routes/payments.rs
// Module: router
// Methods: 0 total (0 public)
impl Responder
|
crates/router/src/routes/payments.rs
|
router
|
impl_block
| null | null | null | 36
| null |
Responder
| null | 0
| 0
| null | null |
// Implementation: impl Payouts for for Payone
// File: crates/hyperswitch_connectors/src/connectors/payone.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl Payouts for for Payone
|
crates/hyperswitch_connectors/src/connectors/payone.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 55
| null |
Payone
|
Payouts for
| 0
| 0
| null | null |
// Implementation: impl UserPassword
// File: crates/router/src/types/domain/user.rs
// Module: router
// Methods: 3 total (3 public)
impl UserPassword
|
crates/router/src/types/domain/user.rs
|
router
|
impl_block
| null | null | null | 36
| null |
UserPassword
| null | 3
| 3
| null | null |
// Struct: AuthenticationResponse
// File: crates/hyperswitch_connectors/src/connectors/worldpay/response.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct AuthenticationResponse
|
crates/hyperswitch_connectors/src/connectors/worldpay/response.rs
|
hyperswitch_connectors
|
struct_definition
|
AuthenticationResponse
| 0
|
[] | 43
| null | null | null | null | null | null | null |
// Struct: ConnectorVolumeSplit
// File: crates/euclid/src/frontend/ast.rs
// Module: euclid
// Implementations: 0
pub struct ConnectorVolumeSplit
|
crates/euclid/src/frontend/ast.rs
|
euclid
|
struct_definition
|
ConnectorVolumeSplit
| 0
|
[] | 38
| null | null | null | null | null | null | null |
// Implementation: impl api::PaymentCapture for for Prophetpay
// File: crates/hyperswitch_connectors/src/connectors/prophetpay.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::PaymentCapture for for Prophetpay
|
crates/hyperswitch_connectors/src/connectors/prophetpay.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 58
| null |
Prophetpay
|
api::PaymentCapture for
| 0
| 0
| null | null |
// Struct: ThreeDSAuthResult
// File: crates/hyperswitch_connectors/src/connectors/nexixpay/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct ThreeDSAuthResult
|
crates/hyperswitch_connectors/src/connectors/nexixpay/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
ThreeDSAuthResult
| 0
|
[] | 51
| null | null | null | null | null | null | null |
// Struct: PaymentsIncrementalAuthorizationData
// File: crates/hyperswitch_domain_models/src/router_request_types.rs
// Module: hyperswitch_domain_models
// Implementations: 0
pub struct PaymentsIncrementalAuthorizationData
|
crates/hyperswitch_domain_models/src/router_request_types.rs
|
hyperswitch_domain_models
|
struct_definition
|
PaymentsIncrementalAuthorizationData
| 0
|
[] | 47
| null | null | null | null | null | null | null |
// Implementation: impl PayoutAttemptInterface for for RouterStore
// File: crates/storage_impl/src/lib.rs
// Module: storage_impl
// Methods: 0 total (0 public)
impl PayoutAttemptInterface for for RouterStore
|
crates/storage_impl/src/lib.rs
|
storage_impl
|
impl_block
| null | null | null | 48
| null |
RouterStore
|
PayoutAttemptInterface for
| 0
| 0
| null | null |
// Struct: BluesnapWallet
// File: crates/hyperswitch_connectors/src/connectors/bluesnap/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct BluesnapWallet
|
crates/hyperswitch_connectors/src/connectors/bluesnap/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
BluesnapWallet
| 0
|
[] | 48
| null | null | null | null | null | null | null |
if status == BankofamericaRefundStatus::Voided {
Err(get_error_response(
&Some(BankOfAmericaErrorInformation {
message: Some(constants::REFUND_VOIDED.to_string()),
reason: Some(constants::REFUND_VOIDED.to_string()),
details: None,
}),
&None,
&None,
None,
item.http_code,
item.response.id.clone(),
))
} else {
Err(get_error_response(
&item.response.error_information,
&None,
&None,
None,
item.http_code,
item.response.id.clone(),
))
}
} else {
Ok(RefundsResponseData {
connector_refund_id: item.response.id,
refund_status,
})
}
}
None => Ok(RefundsResponseData {
connector_refund_id: item.response.id.clone(),
refund_status: match item.data.response {
Ok(response) => response.refund_status,
Err(_) => common_enums::RefundStatus::Pending,
},
}),
};
Ok(Self {
response,
..item.data
})
}
}
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct BankOfAmericaStandardErrorResponse {
pub error_information: Option<ErrorInformation>,
pub status: Option<String>,
pub message: Option<String>,
pub reason: Option<String>,
pub details: Option<Vec<Details>>,
}
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct BankOfAmericaServerErrorResponse {
pub status: Option<String>,
pub message: Option<String>,
pub reason: Option<Reason>,
}
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum Reason {
SystemError,
ServerTimeout,
ServiceTimeout,
}
#[derive(Debug, Deserialize, Serialize)]
pub struct BankOfAmericaAuthenticationErrorResponse {
pub response: AuthenticationErrorInformation,
}
#[derive(Debug, Deserialize, Serialize)]
#[serde(untagged)]
pub enum BankOfAmericaErrorResponse {
AuthenticationError(BankOfAmericaAuthenticationErrorResponse),
StandardError(BankOfAmericaStandardErrorResponse),
}
#[derive(Debug, Deserialize, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Details {
pub field: String,
pub reason: String,
}
#[derive(Debug, Default, Deserialize, Serialize)]
pub struct ErrorInformation {
pub message: String,
pub reason: String,
pub details: Option<Vec<Details>>,
}
#[derive(Debug, Default, Deserialize, Serialize)]
pub struct AuthenticationErrorInformation {
pub rmsg: String,
}
fn get_error_response(
error_data: &Option<BankOfAmericaErrorInformation>,
processor_information: &Option<ClientProcessorInformation>,
risk_information: &Option<ClientRiskInformation>,
attempt_status: Option<enums::AttemptStatus>,
status_code: u16,
transaction_id: String,
) -> ErrorResponse {
let avs_message = risk_information
.clone()
.map(|client_risk_information| {
client_risk_information.rules.map(|rules| {
rules
.iter()
.map(|risk_info| {
risk_info.name.clone().map_or("".to_string(), |name| {
format!(" , {}", name.clone().expose())
})
})
.collect::<Vec<String>>()
.join("")
})
})
.unwrap_or(Some("".to_string()));
let detailed_error_info = error_data.to_owned().and_then(|error_info| {
error_info.details.map(|error_details| {
error_details
.iter()
.map(|details| format!("{} : {}", details.field, details.reason))
.collect::<Vec<_>>()
.join(", ")
})
});
let network_decline_code = processor_information
.as_ref()
.and_then(|info| info.response_code.clone());
let network_advice_code = processor_information.as_ref().and_then(|info| {
info.merchant_advice
.as_ref()
.and_then(|merchant_advice| merchant_advice.code_raw.clone())
});
let reason = get_error_reason(
error_data
.clone()
.and_then(|error_details| error_details.message),
detailed_error_info,
avs_message,
);
let error_message = error_data
.clone()
.and_then(|error_details| error_details.reason);
ErrorResponse {
code: error_message
.clone()
.unwrap_or(hyperswitch_interfaces::consts::NO_ERROR_CODE.to_string()),
message: error_message
.clone()
.unwrap_or(hyperswitch_interfaces::consts::NO_ERROR_MESSAGE.to_string()),
reason,
status_code,
attempt_status,
connector_transaction_id: Some(transaction_id.clone()),
network_advice_code,
network_decline_code,
network_error_message: None,
connector_metadata: None,
}
}
impl
TryFrom<(
&SetupMandateRouterData,
hyperswitch_domain_models::payment_method_data::Card,
)> for BankOfAmericaPaymentsRequest
{
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
(item, ccard): (
&SetupMandateRouterData,
hyperswitch_domain_models::payment_method_data::Card,
),
) -> Result<Self, Self::Error> {
if item.is_three_ds() {
Err(errors::ConnectorError::NotSupported {
message: "Card 3DS".to_string(),
connector: "BankOfAmerica",
})?
};
let order_information = OrderInformationWithBill::try_from(item)?;
let client_reference_information = ClientReferenceInformation::from(item);
let merchant_defined_information =
item.request.metadata.clone().map(|metadata| {
convert_metadata_to_merchant_defined_info(metadata.peek().to_owned())
});
let payment_information = PaymentInformation::try_from(&ccard)?;
let processing_information = ProcessingInformation::try_from((None, None))?;
Ok(Self {
processing_information,
payment_information,
order_information,
client_reference_information,
consumer_authentication_information: None,
merchant_defined_information,
})
}
}
impl TryFrom<(&SetupMandateRouterData, ApplePayWalletData)> for BankOfAmericaPaymentsRequest {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
(item, apple_pay_data): (&SetupMandateRouterData, ApplePayWalletData),
) -> Result<Self, Self::Error> {
let order_information = OrderInformationWithBill::try_from(item)?;
let client_reference_information = ClientReferenceInformation::from(item);
let merchant_defined_information =
item.request.metadata.clone().map(|metadata| {
convert_metadata_to_merchant_defined_info(metadata.peek().to_owned())
});
let payment_information = match item.payment_method_token.clone() {
Some(payment_method_token) => match payment_method_token {
PaymentMethodToken::ApplePayDecrypt(decrypt_data) => {
PaymentInformation::try_from(&decrypt_data)?
}
PaymentMethodToken::Token(_) => Err(unimplemented_payment_method!(
"Apple Pay",
"Manual",
"Bank Of America"
))?,
PaymentMethodToken::PazeDecrypt(_) => {
Err(unimplemented_payment_method!("Paze", "Bank Of America"))?
}
PaymentMethodToken::GooglePayDecrypt(_) => Err(unimplemented_payment_method!(
"Google Pay",
"Bank Of America"
))?,
},
None => PaymentInformation::try_from(&apple_pay_data)?,
};
let processing_information = ProcessingInformation::try_from((
Some(PaymentSolution::ApplePay),
Some(apple_pay_data.payment_method.network.clone()),
))?;
let ucaf_collection_indicator = match apple_pay_data
.payment_method
.network
.to_lowercase()
.as_str()
{
"mastercard" => Some("2".to_string()),
_ => None,
};
let consumer_authentication_information = Some(BankOfAmericaConsumerAuthInformation {
ucaf_collection_indicator,
cavv: None,
ucaf_authentication_data: None,
xid: None,
directory_server_transaction_id: None,
specification_version: None,
});
Ok(Self {
processing_information,
payment_information,
order_information,
client_reference_information,
merchant_defined_information,
consumer_authentication_information,
})
}
}
impl TryFrom<(&SetupMandateRouterData, GooglePayWalletData)> for BankOfAmericaPaymentsRequest {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
(item, google_pay_data): (&SetupMandateRouterData, GooglePayWalletData),
) -> Result<Self, Self::Error> {
let order_information = OrderInformationWithBill::try_from(item)?;
let client_reference_information = ClientReferenceInformation::from(item);
let merchant_defined_information =
item.request.metadata.clone().map(|metadata| {
convert_metadata_to_merchant_defined_info(metadata.peek().to_owned())
});
let payment_information = PaymentInformation::try_from(&google_pay_data)?;
let processing_information =
ProcessingInformation::try_from((Some(PaymentSolution::GooglePay), None))?;
Ok(Self {
processing_information,
payment_information,
order_information,
client_reference_information,
merchant_defined_information,
consumer_authentication_information: None,
})
}
}
// specific for setupMandate flow
impl TryFrom<(Option<PaymentSolution>, Option<String>)> for ProcessingInformation {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
(solution, network): (Option<PaymentSolution>, Option<String>),
) -> Result<Self, Self::Error> {
let (action_list, action_token_types, authorization_options) =
get_boa_mandate_action_details();
let commerce_indicator = get_commerce_indicator(network);
Ok(Self {
capture: Some(false),
capture_options: None,
action_list,
action_token_types,
authorization_options,
commerce_indicator,
payment_solution: solution.map(String::from),
})
}
}
impl TryFrom<&SetupMandateRouterData> for OrderInformationWithBill {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(item: &SetupMandateRouterData) -> Result<Self, Self::Error> {
let email = item.request.get_email()?;
let bill_to = build_bill_to(item.get_optional_billing(), email)?;
Ok(Self {
amount_details: Amount {
total_amount: StringMajorUnit::zero(),
currency: item.request.currency,
},
bill_to: Some(bill_to),
})
}
}
impl TryFrom<&hyperswitch_domain_models::payment_method_data::Card> for PaymentInformation {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
ccard: &hyperswitch_domain_models::payment_method_data::Card,
) -> Result<Self, Self::Error> {
let card_type = match ccard.card_network.clone().and_then(get_boa_card_type) {
Some(card_network) => Some(card_network.to_string()),
None => ccard.get_card_issuer().ok().map(String::from),
};
Ok(Self::Cards(Box::new(CardPaymentInformation {
card: Card {
number: ccard.card_number.clone(),
expiration_month: ccard.card_exp_month.clone(),
expiration_year: ccard.card_exp_year.clone(),
security_code: ccard.card_cvc.clone(),
card_type,
},
})))
}
}
impl TryFrom<&Box<ApplePayPredecryptData>> for PaymentInformation {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(apple_pay_data: &Box<ApplePayPredecryptData>) -> Result<Self, Self::Error> {
let expiration_month = apple_pay_data.get_expiry_month().change_context(
errors::ConnectorError::InvalidDataFormat {
field_name: "expiration_month",
},
)?;
let expiration_year = apple_pay_data.get_four_digit_expiry_year();
Ok(Self::ApplePay(Box::new(ApplePayPaymentInformation {
tokenized_card: TokenizedCard {
number: apple_pay_data.application_primary_account_number.clone(),
cryptogram: apple_pay_data
.payment_data
.online_payment_cryptogram
.clone(),
transaction_type: TransactionType::ApplePay,
expiration_year,
expiration_month,
},
})))
}
}
impl TryFrom<&ApplePayWalletData> for PaymentInformation {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(apple_pay_data: &ApplePayWalletData) -> Result<Self, Self::Error> {
let apple_pay_encrypted_data = apple_pay_data
.payment_data
.get_encrypted_apple_pay_payment_data_mandatory()
.change_context(errors::ConnectorError::MissingRequiredField {
field_name: "Apple pay encrypted data",
})?;
Ok(Self::ApplePayToken(Box::new(
ApplePayTokenPaymentInformation {
fluid_data: FluidData {
value: Secret::from(apple_pay_encrypted_data.clone()),
descriptor: None,
},
tokenized_card: ApplePayTokenizedCard {
transaction_type: TransactionType::ApplePay,
},
},
)))
}
}
impl TryFrom<&GooglePayWalletData> for PaymentInformation {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(google_pay_data: &GooglePayWalletData) -> Result<Self, Self::Error> {
Ok(Self::GooglePay(Box::new(GooglePayPaymentInformation {
fluid_data: FluidData {
value: Secret::from(
consts::BASE64_ENGINE.encode(
google_pay_data
.tokenization_data
.get_encrypted_google_pay_token()
.change_context(errors::ConnectorError::MissingRequiredField {
field_name: "gpay wallet_token",
})?
.clone(),
),
),
descriptor: None,
},
})))
}
}
fn convert_to_error_response_from_error_info(
error_response: &BankOfAmericaErrorInformationResponse,
status_code: u16,
) -> ErrorResponse {
let detailed_error_info =
error_response
.error_information
.to_owned()
.details
.map(|error_details| {
error_details
.iter()
.map(|details| format!("{} : {}", details.field, details.reason))
.collect::<Vec<_>>()
.join(", ")
});
let reason = get_error_reason(
error_response.error_information.message.to_owned(),
detailed_error_info,
None,
);
ErrorResponse {
code: error_response
.error_information
.reason
.clone()
.unwrap_or(hyperswitch_interfaces::consts::NO_ERROR_CODE.to_string()),
message: error_response
.error_information
.reason
.clone()
.unwrap_or(hyperswitch_interfaces::consts::NO_ERROR_MESSAGE.to_string()),
reason,
status_code,
attempt_status: None,
connector_transaction_id: Some(error_response.id.clone()),
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
connector_metadata: None,
}
}
fn get_boa_mandate_action_details() -> (
Option<Vec<BankOfAmericaActionsList>>,
Option<Vec<BankOfAmericaActionsTokenType>>,
Option<BankOfAmericaAuthorizationOptions>,
) {
(
Some(vec![BankOfAmericaActionsList::TokenCreate]),
Some(vec![
BankOfAmericaActionsTokenType::PaymentInstrument,
BankOfAmericaActionsTokenType::Customer,
]),
Some(BankOfAmericaAuthorizationOptions {
initiator: Some(BankOfAmericaPaymentInitiator {
initiator_type: Some(BankOfAmericaPaymentInitiatorTypes::Customer),
credential_stored_on_file: Some(true),
stored_credential_used: None,
}),
merchant_intitiated_transaction: None,
}),
)
}
fn get_commerce_indicator(network: Option<String>) -> String {
match network {
Some(card_network) => match card_network.to_lowercase().as_str() {
"amex" => "aesk",
"discover" => "dipb",
"mastercard" => "spa",
"visa" => "internet",
_ => "internet",
},
None => "internet",
}
.to_string()
}
pub fn get_error_reason(
error_info: Option<String>,
detailed_error_info: Option<String>,
avs_error_info: Option<String>,
) -> Option<String> {
match (error_info, detailed_error_info, avs_error_info) {
(Some(message), Some(details), Some(avs_message)) => Some(format!(
"{message}, detailed_error_information: {details}, avs_message: {avs_message}",
)),
(Some(message), Some(details), None) => {
Some(format!("{message}, detailed_error_information: {details}"))
}
(Some(message), None, Some(avs_message)) => {
Some(format!("{message}, avs_message: {avs_message}"))
}
(None, Some(details), Some(avs_message)) => {
Some(format!("{details}, avs_message: {avs_message}"))
}
(Some(message), None, None) => Some(message),
(None, Some(details), None) => Some(details),
(None, None, Some(avs_message)) => Some(avs_message),
(None, None, None) => None,
}
}
|
crates/hyperswitch_connectors/src/connectors/bankofamerica/transformers.rs#chunk2
|
hyperswitch_connectors
|
chunk
| null | null | null | 3,795
| null | null | null | null | null | null | null |
// File: crates/events/src/lib.rs
// Module: events
// Public functions: 8
// Public structs: 2
#![cfg_attr(docsrs, feature(doc_auto_cfg, doc_cfg_hide))]
#![cfg_attr(docsrs, doc(cfg_hide(doc)))]
#![warn(missing_docs)]
//! A generic event handler system.
//! This library consists of 4 parts:
//! Event Sink: A trait that defines how events are published. This could be a simple logger, a message queue, or a database.
//! EventContext: A struct that holds the event sink and metadata about the event. This is used to create events. This can be used to add metadata to all events, such as the user who triggered the event.
//! EventInfo: A trait that defines the metadata that is sent with the event. It works with the EventContext to add metadata to all events.
//! Event: A trait that defines the event itself. This trait is used to define the data that is sent with the event and defines the event's type & identifier.
mod actix;
use std::{collections::HashMap, sync::Arc};
use error_stack::{Result, ResultExt};
use masking::{ErasedMaskSerialize, Serialize};
use router_env::logger;
use serde::Serializer;
use serde_json::Value;
use time::PrimitiveDateTime;
/// Errors that can occur when working with events.
#[derive(Debug, Clone, thiserror::Error)]
pub enum EventsError {
/// An error occurred when publishing the event.
#[error("Generic Error")]
GenericError,
/// An error occurred when serializing the event.
#[error("Event serialization error")]
SerializationError,
/// An error occurred when publishing/producing the event.
#[error("Event publishing error")]
PublishError,
}
/// An event that can be published.
pub trait Event: EventInfo {
/// The type of the event.
type EventType;
/// The timestamp of the event.
fn timestamp(&self) -> PrimitiveDateTime;
/// The (unique) identifier of the event.
fn identifier(&self) -> String;
/// The class/type of the event. This is used to group/categorize events together.
fn class(&self) -> Self::EventType;
/// Metadata associated with the event
fn metadata(&self) -> HashMap<String, String> {
HashMap::new()
}
}
/// Hold the context information for any events
#[derive(Clone)]
pub struct EventContext<T, A>
where
A: MessagingInterface<MessageClass = T>,
{
message_sink: Arc<A>,
metadata: HashMap<String, Value>,
}
/// intermediary structure to build events with in-place info.
#[must_use = "make sure to call `emit` or `try_emit` to actually emit the event"]
pub struct EventBuilder<T, A, E, D>
where
A: MessagingInterface<MessageClass = T>,
E: Event<EventType = T, Data = D>,
{
message_sink: Arc<A>,
metadata: HashMap<String, Value>,
event: E,
}
/// A flattened event that flattens the context provided to it along with the actual event.
struct FlatMapEvent<T, A: Event<EventType = T>>(HashMap<String, Value>, A);
impl<T, A, E, D> EventBuilder<T, A, E, D>
where
A: MessagingInterface<MessageClass = T>,
E: Event<EventType = T, Data = D>,
{
/// Add metadata to the event.
pub fn with<F: ErasedMaskSerialize, G: EventInfo<Data = F> + 'static>(
mut self,
info: G,
) -> Self {
info.data()
.and_then(|i| {
i.masked_serialize()
.change_context(EventsError::SerializationError)
})
.map_err(|e| {
logger::error!("Error adding event info: {:?}", e);
})
.ok()
.and_then(|data| self.metadata.insert(info.key(), data));
self
}
/// Emit the event and log any errors.
pub fn emit(self) {
self.try_emit()
.map_err(|e| {
logger::error!("Error emitting event: {:?}", e);
})
.ok();
}
/// Emit the event.
pub fn try_emit(self) -> Result<(), EventsError> {
let ts = self.event.timestamp();
let metadata = self.event.metadata();
self.message_sink
.send_message(FlatMapEvent(self.metadata, self.event), metadata, ts)
}
}
impl<T, A> Serialize for FlatMapEvent<T, A>
where
A: Event<EventType = T>,
{
fn serialize<S>(&self, serializer: S) -> core::result::Result<S::Ok, S::Error>
where
S: Serializer,
{
let mut serialize_map: HashMap<_, _> = self
.0
.iter()
.filter_map(|(k, v)| Some((k.clone(), v.masked_serialize().ok()?)))
.collect();
match self.1.data().map(|i| i.masked_serialize()) {
Ok(Ok(Value::Object(map))) => {
for (k, v) in map.into_iter() {
serialize_map.insert(k, v);
}
}
Ok(Ok(i)) => {
serialize_map.insert(self.1.key(), i);
}
i => {
logger::error!("Error serializing event: {:?}", i);
}
};
serialize_map.serialize(serializer)
}
}
impl<T, A> EventContext<T, A>
where
A: MessagingInterface<MessageClass = T>,
{
/// Create a new event context.
pub fn new(message_sink: A) -> Self {
Self {
message_sink: Arc::new(message_sink),
metadata: HashMap::new(),
}
}
/// Add metadata to the event context.
#[track_caller]
pub fn record_info<G: ErasedMaskSerialize, E: EventInfo<Data = G> + 'static>(
&mut self,
info: E,
) {
match info.data().and_then(|i| {
i.masked_serialize()
.change_context(EventsError::SerializationError)
}) {
Ok(data) => {
self.metadata.insert(info.key(), data);
}
Err(e) => {
logger::error!("Error recording event info: {:?}", e);
}
}
}
/// Emit an event.
pub fn try_emit<E: Event<EventType = T>>(&self, event: E) -> Result<(), EventsError> {
EventBuilder {
message_sink: self.message_sink.clone(),
metadata: self.metadata.clone(),
event,
}
.try_emit()
}
/// Emit an event.
pub fn emit<D, E: Event<EventType = T, Data = D>>(&self, event: E) {
EventBuilder {
message_sink: self.message_sink.clone(),
metadata: self.metadata.clone(),
event,
}
.emit()
}
/// Create an event builder.
pub fn event<D, E: Event<EventType = T, Data = D>>(
&self,
event: E,
) -> EventBuilder<T, A, E, D> {
EventBuilder {
message_sink: self.message_sink.clone(),
metadata: self.metadata.clone(),
event,
}
}
}
/// Add information/metadata to the current context of an event.
pub trait EventInfo {
/// The data that is sent with the event.
type Data: ErasedMaskSerialize;
/// The data that is sent with the event.
fn data(&self) -> Result<Self::Data, EventsError>;
/// The key identifying the data for an event.
fn key(&self) -> String;
}
impl EventInfo for (String, String) {
type Data = String;
fn data(&self) -> Result<String, EventsError> {
Ok(self.1.clone())
}
fn key(&self) -> String {
self.0.clone()
}
}
/// A messaging interface for sending messages/events.
/// This can be implemented for any messaging system, such as a message queue, a logger, or a database.
pub trait MessagingInterface {
/// The type of the event used for categorization by the event publisher.
type MessageClass;
/// Send a message that follows the defined message class.
fn send_message<T>(
&self,
data: T,
metadata: HashMap<String, String>,
timestamp: PrimitiveDateTime,
) -> Result<(), EventsError>
where
T: Message<Class = Self::MessageClass> + ErasedMaskSerialize;
}
/// A message that can be sent.
pub trait Message {
/// The type of the event used for categorization by the event publisher.
type Class;
/// The type of the event used for categorization by the event publisher.
fn get_message_class(&self) -> Self::Class;
/// The (unique) identifier of the event.
fn identifier(&self) -> String;
}
impl<T, A> Message for FlatMapEvent<T, A>
where
A: Event<EventType = T>,
{
type Class = T;
fn get_message_class(&self) -> Self::Class {
self.1.class()
}
fn identifier(&self) -> String {
self.1.identifier()
}
}
|
crates/events/src/lib.rs
|
events
|
full_file
| null | null | null | 1,987
| null | null | null | null | null | null | null |
// Function: get_metadata
// File: crates/hyperswitch_domain_models/src/mandates.rs
// Module: hyperswitch_domain_models
pub fn get_metadata(&self) -> Option<pii::SecretSerdeValue>
|
crates/hyperswitch_domain_models/src/mandates.rs
|
hyperswitch_domain_models
|
function_signature
| null | null | null | 47
|
get_metadata
| null | null | null | null | null | null |
// Function: payments_create_intent
// File: crates/router/src/routes/payments.rs
// Module: router
pub fn payments_create_intent(
state: web::Data<app::AppState>,
req: actix_web::HttpRequest,
json_payload: web::Json<payment_types::PaymentsCreateIntentRequest>,
) -> impl Responder
|
crates/router/src/routes/payments.rs
|
router
|
function_signature
| null | null | null | 70
|
payments_create_intent
| null | null | null | null | null | null |
// Implementation: impl PartialEq for for FrmMetricsBucketIdentifier
// File: crates/api_models/src/analytics/frm.rs
// Module: api_models
// Methods: 1 total (0 public)
impl PartialEq for for FrmMetricsBucketIdentifier
|
crates/api_models/src/analytics/frm.rs
|
api_models
|
impl_block
| null | null | null | 49
| null |
FrmMetricsBucketIdentifier
|
PartialEq for
| 1
| 0
| null | null |
// Struct: User
// File: crates/router/src/routes/app.rs
// Module: router
// Implementations: 2
pub struct User
|
crates/router/src/routes/app.rs
|
router
|
struct_definition
|
User
| 2
|
[] | 30
| null | null | null | null | null | null | null |
// File: crates/router/src/services/authorization.rs
// Module: router
// Public functions: 5
use std::sync::Arc;
use common_utils::id_type;
use error_stack::ResultExt;
use redis_interface::RedisConnectionPool;
use router_env::logger;
use super::authentication::AuthToken;
use crate::{
consts,
core::errors::{ApiErrorResponse, RouterResult, StorageErrorExt},
routes::app::SessionStateInfo,
};
#[cfg(feature = "olap")]
pub mod info;
pub mod permission_groups;
pub mod permissions;
pub mod roles;
pub async fn get_role_info<A>(state: &A, token: &AuthToken) -> RouterResult<roles::RoleInfo>
where
A: SessionStateInfo + Sync,
{
if let Some(role_info) = roles::predefined_roles::PREDEFINED_ROLES.get(token.role_id.as_str()) {
return Ok(role_info.clone());
}
if let Ok(role_info) = get_role_info_from_cache(state, &token.role_id)
.await
.map_err(|e| logger::error!("Failed to get permissions from cache {e:?}"))
{
return Ok(role_info.clone());
}
let role_info = get_role_info_from_db(
state,
&token.role_id,
&token.org_id,
token
.tenant_id
.as_ref()
.unwrap_or(&state.session_state().tenant.tenant_id),
)
.await?;
let token_expiry =
i64::try_from(token.exp).change_context(ApiErrorResponse::InternalServerError)?;
let cache_ttl = token_expiry - common_utils::date_time::now_unix_timestamp();
if cache_ttl > 0 {
set_role_info_in_cache(state, &token.role_id, &role_info, cache_ttl)
.await
.map_err(|e| logger::error!("Failed to set role info in cache {e:?}"))
.ok();
}
Ok(role_info)
}
async fn get_role_info_from_cache<A>(state: &A, role_id: &str) -> RouterResult<roles::RoleInfo>
where
A: SessionStateInfo + Sync,
{
let redis_conn = get_redis_connection_for_global_tenant(state)?;
redis_conn
.get_and_deserialize_key(&get_cache_key_from_role_id(role_id).into(), "RoleInfo")
.await
.change_context(ApiErrorResponse::InternalServerError)
}
pub fn get_cache_key_from_role_id(role_id: &str) -> String {
format!("{}{}", consts::ROLE_INFO_CACHE_PREFIX, role_id)
}
async fn get_role_info_from_db<A>(
state: &A,
role_id: &str,
org_id: &id_type::OrganizationId,
tenant_id: &id_type::TenantId,
) -> RouterResult<roles::RoleInfo>
where
A: SessionStateInfo + Sync,
{
state
.session_state()
.global_store
.find_by_role_id_org_id_tenant_id(role_id, org_id, tenant_id)
.await
.map(roles::RoleInfo::from)
.to_not_found_response(ApiErrorResponse::InvalidJwtToken)
}
pub async fn set_role_info_in_cache<A>(
state: &A,
role_id: &str,
role_info: &roles::RoleInfo,
expiry: i64,
) -> RouterResult<()>
where
A: SessionStateInfo + Sync,
{
let redis_conn = get_redis_connection_for_global_tenant(state)?;
redis_conn
.serialize_and_set_key_with_expiry(
&get_cache_key_from_role_id(role_id).into(),
role_info,
expiry,
)
.await
.change_context(ApiErrorResponse::InternalServerError)
}
pub fn check_permission(
required_permission: permissions::Permission,
role_info: &roles::RoleInfo,
) -> RouterResult<()> {
role_info
.check_permission_exists(required_permission)
.then_some(())
.ok_or(
ApiErrorResponse::AccessForbidden {
resource: required_permission.to_string(),
}
.into(),
)
}
pub fn check_tenant(
token_tenant_id: Option<id_type::TenantId>,
header_tenant_id: &id_type::TenantId,
) -> RouterResult<()> {
if let Some(tenant_id) = token_tenant_id {
if tenant_id != *header_tenant_id {
return Err(ApiErrorResponse::InvalidJwtToken).attach_printable(format!(
"Token tenant ID: '{}' does not match Header tenant ID: '{}'",
tenant_id.get_string_repr().to_owned(),
header_tenant_id.get_string_repr().to_owned()
));
}
}
Ok(())
}
fn get_redis_connection_for_global_tenant<A: SessionStateInfo>(
state: &A,
) -> RouterResult<Arc<RedisConnectionPool>> {
state
.global_store()
.get_redis_conn()
.change_context(ApiErrorResponse::InternalServerError)
.attach_printable("Failed to get redis connection")
}
|
crates/router/src/services/authorization.rs
|
router
|
full_file
| null | null | null | 1,066
| null | null | null | null | null | null | null |
// Implementation: impl api::PaymentCapture for for Adyen
// File: crates/hyperswitch_connectors/src/connectors/adyen.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::PaymentCapture for for Adyen
|
crates/hyperswitch_connectors/src/connectors/adyen.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 58
| null |
Adyen
|
api::PaymentCapture for
| 0
| 0
| null | null |
// Implementation: impl webhooks::IncomingWebhook for for Nomupay
// File: crates/hyperswitch_connectors/src/connectors/nomupay.rs
// Module: hyperswitch_connectors
// Methods: 3 total (0 public)
impl webhooks::IncomingWebhook for for Nomupay
|
crates/hyperswitch_connectors/src/connectors/nomupay.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 65
| null |
Nomupay
|
webhooks::IncomingWebhook for
| 3
| 0
| null | null |
// Function: from_pii_email
// File: crates/router/src/types/domain/user.rs
// Module: router
pub fn from_pii_email(email: pii::Email) -> UserResult<Self>
|
crates/router/src/types/domain/user.rs
|
router
|
function_signature
| null | null | null | 41
|
from_pii_email
| null | null | null | null | null | null |
// Implementation: impl AnalyticsProvider
// File: crates/analytics/src/lib.rs
// Module: analytics
// Methods: 12 total (0 public)
impl AnalyticsProvider
|
crates/analytics/src/lib.rs
|
analytics
|
impl_block
| null | null | null | 36
| null |
AnalyticsProvider
| null | 12
| 0
| null | null |
// Struct: TransactionConfirmRequest
// File: crates/hyperswitch_connectors/src/connectors/authorizedotnet/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct TransactionConfirmRequest
|
crates/hyperswitch_connectors/src/connectors/authorizedotnet/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
TransactionConfirmRequest
| 0
|
[] | 49
| null | null | null | null | null | null | null |
// Implementation: impl ConnectorCommon for for Stripe
// File: crates/hyperswitch_connectors/src/connectors/stripe.rs
// Module: hyperswitch_connectors
// Methods: 5 total (0 public)
impl ConnectorCommon for for Stripe
|
crates/hyperswitch_connectors/src/connectors/stripe.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 51
| null |
Stripe
|
ConnectorCommon for
| 5
| 0
| null | null |
// Implementation: impl api::RefundSync for for Billwerk
// File: crates/hyperswitch_connectors/src/connectors/billwerk.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::RefundSync for for Billwerk
|
crates/hyperswitch_connectors/src/connectors/billwerk.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 60
| null |
Billwerk
|
api::RefundSync for
| 0
| 0
| null | null |
// Implementation: impl api::PaymentVoid for for Authorizedotnet
// File: crates/hyperswitch_connectors/src/connectors/authorizedotnet.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)
impl api::PaymentVoid for for Authorizedotnet
|
crates/hyperswitch_connectors/src/connectors/authorizedotnet.rs
|
hyperswitch_connectors
|
impl_block
| null | null | null | 61
| null |
Authorizedotnet
|
api::PaymentVoid for
| 0
| 0
| null | null |
// File: crates/connector_configs/src/common_config.rs
// Module: connector_configs
// Public structs: 12
use api_models::{payment_methods, payments};
use serde::{Deserialize, Serialize};
use utoipa::ToSchema;
#[serde_with::skip_serializing_none]
#[derive(Debug, Deserialize, serde::Serialize, Clone)]
#[serde(rename_all = "snake_case")]
pub struct ZenApplePay {
pub terminal_uuid: Option<String>,
pub pay_wall_secret: Option<String>,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Deserialize, serde::Serialize, Clone)]
#[serde(untagged)]
pub enum ApplePayData {
ApplePay(payments::ApplePayMetadata),
ApplePayCombined(payments::ApplePayCombinedMetadata),
Zen(ZenApplePay),
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct GpayDashboardPayLoad {
#[serde(skip_serializing_if = "Option::is_none")]
pub gateway_merchant_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none", rename = "stripe:version")]
pub stripe_version: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename(
serialize = "stripe_publishable_key",
deserialize = "stripe:publishable_key"
))]
#[serde(alias = "stripe:publishable_key")]
#[serde(alias = "stripe_publishable_key")]
pub stripe_publishable_key: Option<String>,
pub merchant_name: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub merchant_id: Option<String>,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Deserialize, serde::Serialize, Clone)]
#[serde(rename_all = "snake_case")]
pub struct ZenGooglePay {
pub terminal_uuid: Option<String>,
pub pay_wall_secret: Option<String>,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Deserialize, serde::Serialize, Clone)]
#[serde(untagged)]
pub enum GooglePayData {
Standard(GpayDashboardPayLoad),
Zen(ZenGooglePay),
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct PaypalSdkData {
pub client_id: Option<String>,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Deserialize, serde::Serialize, Clone)]
#[serde(untagged)]
pub enum GoogleApiModelData {
Standard(payments::GpayMetaData),
Zen(ZenGooglePay),
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]
#[serde(rename_all = "snake_case")]
pub struct PaymentMethodsEnabled {
pub payment_method: api_models::enums::PaymentMethod,
pub payment_method_types: Option<Vec<payment_methods::RequestPaymentMethodTypes>>,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
#[serde(rename_all = "snake_case")]
pub struct ApiModelMetaData {
pub merchant_config_currency: Option<api_models::enums::Currency>,
pub merchant_account_id: Option<String>,
pub account_name: Option<String>,
pub terminal_id: Option<String>,
pub merchant_id: Option<String>,
pub google_pay: Option<GoogleApiModelData>,
pub paypal_sdk: Option<PaypalSdkData>,
pub apple_pay: Option<ApplePayData>,
pub apple_pay_combined: Option<ApplePayData>,
pub endpoint_prefix: Option<String>,
pub mcc: Option<String>,
pub merchant_country_code: Option<String>,
pub merchant_name: Option<String>,
pub acquirer_bin: Option<String>,
pub acquirer_merchant_id: Option<String>,
pub acquirer_country_code: Option<String>,
pub three_ds_requestor_name: Option<String>,
pub three_ds_requestor_id: Option<String>,
pub pull_mechanism_for_external_3ds_enabled: Option<bool>,
pub klarna_region: Option<KlarnaEndpoint>,
pub source_balance_account: Option<String>,
pub brand_id: Option<String>,
pub destination_account_number: Option<String>,
pub dpa_id: Option<String>,
pub dpa_name: Option<String>,
pub locale: Option<String>,
pub card_brands: Option<Vec<String>>,
pub merchant_category_code: Option<String>,
pub merchant_configuration_id: Option<String>,
pub tenant_id: Option<String>,
pub platform_url: Option<String>,
pub account_id: Option<serde_json::Value>,
pub site: Option<String>,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub enum KlarnaEndpoint {
Europe,
NorthAmerica,
Oceania,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, ToSchema, Deserialize)]
#[serde(rename_all = "snake_case")]
pub struct CardProvider {
pub payment_method_type: api_models::enums::CardNetwork,
/// List of currencies accepted or has the processing capabilities of the processor
#[schema(example = json!(
{
"type": "specific_accepted",
"list": ["USD", "INR"]
}
), value_type = Option<AcceptedCurrencies>)]
pub accepted_currencies: Option<api_models::admin::AcceptedCurrencies>,
#[schema(example = json!(
{
"type": "specific_accepted",
"list": ["UK", "AU"]
}
), value_type = Option<AcceptedCountries>)]
pub accepted_countries: Option<api_models::admin::AcceptedCountries>,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, ToSchema, Deserialize)]
#[serde(rename_all = "snake_case")]
pub struct Provider {
pub payment_method_type: api_models::enums::PaymentMethodType,
/// List of currencies accepted or has the processing capabilities of the processor
#[schema(example = json!(
{
"type": "specific_accepted",
"list": ["USD", "INR"]
}
), value_type = Option<AcceptedCurrencies>)]
pub accepted_currencies: Option<api_models::admin::AcceptedCurrencies>,
#[schema(example = json!(
{
"type": "specific_accepted",
"list": ["UK", "AU"]
}
), value_type = Option<AcceptedCountries>)]
pub accepted_countries: Option<api_models::admin::AcceptedCountries>,
pub payment_experience: Option<api_models::enums::PaymentExperience>,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]
#[serde(rename_all = "snake_case")]
pub struct ConnectorApiIntegrationPayload {
pub connector_type: String,
pub profile_id: common_utils::id_type::ProfileId,
pub connector_name: api_models::enums::Connector,
#[serde(skip_deserializing)]
#[schema(example = "stripe_US_travel")]
pub connector_label: Option<String>,
pub merchant_connector_id: Option<String>,
pub disabled: bool,
pub test_mode: bool,
pub payment_methods_enabled: Option<Vec<PaymentMethodsEnabled>>,
pub metadata: Option<ApiModelMetaData>,
pub connector_webhook_details: Option<api_models::admin::MerchantConnectorWebhookDetails>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub struct DashboardPaymentMethodPayload {
pub payment_method: api_models::enums::PaymentMethod,
pub payment_method_type: String,
pub provider: Option<Vec<Provider>>,
pub card_provider: Option<Vec<CardProvider>>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde_with::skip_serializing_none]
#[serde(rename_all = "snake_case")]
pub struct DashboardRequestPayload {
pub connector: api_models::enums::Connector,
pub payment_methods_enabled: Option<Vec<DashboardPaymentMethodPayload>>,
pub metadata: Option<ApiModelMetaData>,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Deserialize, serde::Serialize, Clone)]
#[serde(tag = "type", content = "options")]
pub enum InputType {
Text,
Number,
Toggle,
Radio(Vec<String>),
Select(Vec<String>),
MultiSelect(Vec<String>),
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Deserialize, serde::Serialize, Clone)]
#[serde(rename_all = "snake_case")]
pub struct InputData {
pub name: String,
pub label: String,
pub placeholder: String,
pub required: bool,
#[serde(flatten)]
pub input_type: InputType,
}
|
crates/connector_configs/src/common_config.rs
|
connector_configs
|
full_file
| null | null | null | 1,833
| null | null | null | null | null | null | null |
// Function: build_case_insensitive_filters
// File: crates/analytics/src/opensearch.rs
// Module: analytics
pub fn build_case_insensitive_filters(
&self,
mut payload: Value,
case_insensitive_filters: &[&(String, Vec<Value>)
|
crates/analytics/src/opensearch.rs
|
analytics
|
function_signature
| null | null | null | 57
|
build_case_insensitive_filters
| null | null | null | null | null | null |
// Function: get_connector_label
// File: crates/api_models/src/admin.rs
// Module: api_models
pub fn get_connector_label(&self, profile_name: String) -> String
|
crates/api_models/src/admin.rs
|
api_models
|
function_signature
| null | null | null | 38
|
get_connector_label
| null | null | null | null | null | null |
// Struct: StripebillingWebhookBody
// File: crates/hyperswitch_connectors/src/connectors/stripebilling/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 1
pub struct StripebillingWebhookBody
|
crates/hyperswitch_connectors/src/connectors/stripebilling/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
StripebillingWebhookBody
| 1
|
[] | 52
| null | null | null | null | null | null | null |
// File: crates/router/src/core/pm_auth/helpers.rs
// Module: router
// Public functions: 1
use common_utils::ext_traits::ValueExt;
use error_stack::ResultExt;
use pm_auth::types::{self as pm_auth_types, api::BoxedPaymentAuthConnector};
use crate::{
core::errors::{self, ApiErrorResponse},
types::{self, domain, transformers::ForeignTryFrom},
};
pub trait PaymentAuthConnectorDataExt {
fn get_connector_by_name(name: &str) -> errors::CustomResult<Self, ApiErrorResponse>
where
Self: Sized;
fn convert_connector(
connector_name: pm_auth_types::PaymentMethodAuthConnectors,
) -> errors::CustomResult<BoxedPaymentAuthConnector, ApiErrorResponse>;
}
pub fn get_connector_auth_type(
merchant_connector_account: domain::MerchantConnectorAccount,
) -> errors::CustomResult<pm_auth_types::ConnectorAuthType, ApiErrorResponse> {
let auth_type: types::ConnectorAuthType = merchant_connector_account
.connector_account_details
.parse_value("ConnectorAuthType")
.change_context(ApiErrorResponse::MerchantConnectorAccountNotFound {
id: "ConnectorAuthType".to_string(),
})?;
pm_auth_types::ConnectorAuthType::foreign_try_from(auth_type)
.change_context(ApiErrorResponse::InternalServerError)
.attach_printable("Failed while converting ConnectorAuthType")
}
|
crates/router/src/core/pm_auth/helpers.rs
|
router
|
full_file
| null | null | null | 292
| null | null | null | null | null | null | null |
// Implementation: impl Customer
// File: crates/diesel_models/src/query/customers.rs
// Module: diesel_models
// Methods: 9 total (0 public)
impl Customer
|
crates/diesel_models/src/query/customers.rs
|
diesel_models
|
impl_block
| null | null | null | 37
| null |
Customer
| null | 9
| 0
| null | null |
// Function: insert_payment_attempts
// File: crates/diesel_models/src/query/user/sample_data.rs
// Module: diesel_models
pub fn insert_payment_attempts(
conn: &PgPooledConn,
batch: Vec<user::sample_data::PaymentAttemptBatchNew>,
) -> StorageResult<Vec<PaymentAttempt>>
|
crates/diesel_models/src/query/user/sample_data.rs
|
diesel_models
|
function_signature
| null | null | null | 66
|
insert_payment_attempts
| null | null | null | null | null | null |
// Function: get_two_letter_country_code
// File: crates/euclid_wasm/src/lib.rs
// Module: euclid_wasm
pub fn get_two_letter_country_code() -> JsResult
|
crates/euclid_wasm/src/lib.rs
|
euclid_wasm
|
function_signature
| null | null | null | 41
|
get_two_letter_country_code
| null | null | null | null | null | null |
// Function: make_payment_attempt
// File: crates/router/src/core/payments/operations/payment_create.rs
// Module: router
pub fn make_payment_attempt(
payment_id: &common_utils::id_type::PaymentId,
merchant_id: &common_utils::id_type::MerchantId,
organization_id: &common_utils::id_type::OrganizationId,
money: (api::Amount, enums::Currency)
|
crates/router/src/core/payments/operations/payment_create.rs
|
router
|
function_signature
| null | null | null | 87
|
make_payment_attempt
| null | null | null | null | null | null |
// Struct: CancelResponseStatus
// File: crates/hyperswitch_connectors/src/connectors/forte/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0
pub struct CancelResponseStatus
|
crates/hyperswitch_connectors/src/connectors/forte/transformers.rs
|
hyperswitch_connectors
|
struct_definition
|
CancelResponseStatus
| 0
|
[] | 46
| null | null | null | null | null | null | null |
// Implementation: impl BusinessPaymentLinkConfig
// File: crates/api_models/src/admin.rs
// Module: api_models
// Methods: 1 total (1 public)
impl BusinessPaymentLinkConfig
|
crates/api_models/src/admin.rs
|
api_models
|
impl_block
| null | null | null | 40
| null |
BusinessPaymentLinkConfig
| null | 1
| 1
| null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.