id stringlengths 20 153 | type stringclasses 1
value | granularity stringclasses 14
values | content stringlengths 16 84.3k | metadata dict |
|---|---|---|---|---|
connector-service_mini_domain_types_-7881285798716424113_13 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
grpc_api_types::payments::Currency::Mop => Ok(Self::MOP),
grpc_api_types::payments::Currency::Mru => Ok(Self::MRU),
grpc_api_types::payments::Currency::Mur => Ok(Self::MUR),
grpc_api_types::payments::Currency::Mvr => Ok(Self::MVR),
grpc_api_types::payments::Currency::Mwk => Ok(Self::MWK),
grpc_api_types::payments::Currency::Mxn => Ok(Self::MXN),
grpc_api_types::payments::Currency::Myr => Ok(Self::MYR),
grpc_api_types::payments::Currency::Mzn => Ok(Self::MZN),
grpc_api_types::payments::Currency::Nad => Ok(Self::NAD),
grpc_api_types::payments::Currency::Ngn => Ok(Self::NGN),
grpc_api_types::payments::Currency::Nio => Ok(Self::NIO),
grpc_api_types::payments::Currency::Nok => Ok(Self::NOK),
grpc_api_types::payments::Currency::Npr => Ok(Self::NPR),
grpc_api_types::payments::Currency::Nzd => Ok(Self::NZD),
grpc_api_types::payments::Currency::Omr => Ok(Self::OMR),
grpc_api_types::payments::Currency::Pab => Ok(Self::PAB),
grpc_api_types::payments::Currency::Pen => Ok(Self::PEN),
grpc_api_types::payments::Currency::Pgk => Ok(Self::PGK),
grpc_api_types::payments::Currency::Php => Ok(Self::PHP),
grpc_api_types::payments::Currency::Pkr => Ok(Self::PKR),
grpc_api_types::payments::Currency::Pln => Ok(Self::PLN),
grpc_api_types::payments::Currency::Pyg => Ok(Self::PYG),
grpc_api_types::payments::Currency::Qar => Ok(Self::QAR),
grpc_api_types::payments::Currency::Ron => Ok(Self::RON),
grpc_api_types::payments::Currency::Rsd => Ok(Self::RSD),
grpc_api_types::payments::Currency::Rub => Ok(Self::RUB),
grpc_api_types::payments::Currency::Rwf => Ok(Self::RWF),
grpc_api_types::payments::Currency::Sar => Ok(Self::SAR),
grpc_api_types::payments::Currency::Sbd => Ok(Self::SBD),
grpc_api_types::payments::Currency::Scr => Ok(Self::SCR),
grpc_api_types::payments::Currency::Sek => Ok(Self::SEK),
grpc_api_types::payments::Currency::Sgd => Ok(Self::SGD),
grpc_api_types::payments::Currency::Shp => Ok(Self::SHP),
grpc_api_types::payments::Currency::Sle => Ok(Self::SLE),
grpc_api_types::payments::Currency::Sll => Ok(Self::SLL),
grpc_api_types::payments::Currency::Sos => Ok(Self::SOS),
grpc_api_types::payments::Currency::Srd => Ok(Self::SRD),
grpc_api_types::payments::Currency::Ssp => Ok(Self::SSP),
grpc_api_types::payments::Currency::Stn => Ok(Self::STN),
grpc_api_types::payments::Currency::Svc => Ok(Self::SVC),
grpc_api_types::payments::Currency::Szl => Ok(Self::SZL),
grpc_api_types::payments::Currency::Thb => Ok(Self::THB),
grpc_api_types::payments::Currency::Tnd => Ok(Self::TND),
grpc_api_types::payments::Currency::Top => Ok(Self::TOP),
grpc_api_types::payments::Currency::Try => Ok(Self::TRY),
grpc_api_types::payments::Currency::Ttd => Ok(Self::TTD),
grpc_api_types::payments::Currency::Twd => Ok(Self::TWD),
grpc_api_types::payments::Currency::Tzs => Ok(Self::TZS),
grpc_api_types::payments::Currency::Uah => Ok(Self::UAH),
grpc_api_types::payments::Currency::Ugx => Ok(Self::UGX),
grpc_api_types::payments::Currency::Usd => Ok(Self::USD),
grpc_api_types::payments::Currency::Uyu => Ok(Self::UYU),
grpc_api_types::payments::Currency::Uzs => Ok(Self::UZS),
grpc_api_types::payments::Currency::Ves => Ok(Self::VES),
grpc_api_types::payments::Currency::Vnd => Ok(Self::VND),
grpc_api_types::payments::Currency::Vuv => Ok(Self::VUV),
grpc_api_types::payments::Currency::Wst => Ok(Self::WST),
grpc_api_types::payments::Currency::Xaf => Ok(Self::XAF),
grpc_api_types::payments::Currency::Xcd => Ok(Self::XCD),
grpc_api_types::payments::Currency::Xof => Ok(Self::XOF),
| {
"chunk": 13,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_14 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
grpc_api_types::payments::Currency::Xpf => Ok(Self::XPF),
grpc_api_types::payments::Currency::Yer => Ok(Self::YER),
grpc_api_types::payments::Currency::Zar => Ok(Self::ZAR),
grpc_api_types::payments::Currency::Zmw => Ok(Self::ZMW),
_ => Err(report!(ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "unsupported_currency".to_string(),
error_identifier: 4001,
error_message: format!("Currency {value:?} is not supported"),
error_object: None,
}))),
}
}
}
impl<
T: PaymentMethodDataTypes
+ Default
+ Debug
+ Send
+ Eq
+ PartialEq
+ serde::Serialize
+ serde::de::DeserializeOwned
+ Clone
+ CardConversionHelper<T>,
> ForeignTryFrom<PaymentServiceAuthorizeRequest> for PaymentsAuthorizeData<T>
{
type Error = ApplicationErrorResponse;
fn foreign_try_from(
value: PaymentServiceAuthorizeRequest,
) -> Result<Self, error_stack::Report<Self::Error>> {
let email: Option<Email> = match value.email {
Some(ref email_str) => {
Some(Email::try_from(email_str.clone().expose()).map_err(|_| {
error_stack::Report::new(ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "INVALID_EMAIL_FORMAT".to_owned(),
error_identifier: 400,
error_message: "Invalid email".to_owned(),
error_object: None,
}))
})?)
}
None => None,
};
let merchant_config_currency = common_enums::Currency::foreign_try_from(value.currency())?;
// Extract merchant_account_id from metadata before moving it
let merchant_account_id = value.metadata.get("merchant_account_id").cloned();
// Store merchant_account_metadata for connector use
let merchant_account_metadata = (!value.merchant_account_metadata.is_empty())
.then(|| {
serde_json::to_value(&value.merchant_account_metadata)
.map(common_utils::pii::SecretSerdeValue::new)
.map_err(|_| {
error_stack::Report::new(ApplicationErrorResponse::InternalServerError(
crate::errors::ApiError {
sub_code: "SERDE_JSON_ERROR".to_owned(),
error_identifier: 500,
error_message: "Failed to serialize merchant_account_metadata"
.to_owned(),
error_object: None,
},
))
})
})
.transpose()?;
let setup_future_usage = value
.setup_future_usage
.map(|usage| {
grpc_api_types::payments::FutureUsage::try_from(usage)
.map_err(|_| {
error_stack::Report::new(ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "INVALID_SETUP_FUTURE_USAGE".to_owned(),
error_identifier: 400,
error_message: "Invalid setup future usage value".to_owned(),
error_object: None,
}))
})
.and_then(|proto_usage| {
common_enums::FutureUsage::foreign_try_from(proto_usage)
})
})
.transpose()?;
let customer_acceptance = value.customer_acceptance.clone();
let authentication_data = value
.authentication_data
.clone()
.map(router_request_types::AuthenticationData::try_from)
.transpose()?;
let access_token = value
.state
.as_ref()
.and_then(|state| state.access_token.as_ref())
.map(|token| crate::connector_types::AccessTokenResponseData {
access_token: token.token.clone(),
token_type: None,
| {
"chunk": 14,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_15 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
expires_in: token.expires_in_seconds,
});
Ok(Self {
authentication_data,
capture_method: Some(common_enums::CaptureMethod::foreign_try_from(
value.capture_method(),
)?),
payment_method_data: PaymentMethodData::<T>::foreign_try_from(
value.payment_method.clone().ok_or_else(|| {
ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "INVALID_PAYMENT_METHOD_DATA".to_owned(),
error_identifier: 400,
error_message: "Payment method data is required".to_owned(),
error_object: None,
})
})?,
)
.change_context(ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "INVALID_PAYMENT_METHOD_DATA".to_owned(),
error_identifier: 400,
error_message: "Payment method data construction failed".to_owned(),
error_object: None,
}))?,
amount: value.amount,
currency: common_enums::Currency::foreign_try_from(value.currency())?,
confirm: true,
webhook_url: value.webhook_url.clone(),
browser_info: value
.browser_info
.as_ref()
.cloned()
.map(BrowserInformation::foreign_try_from)
.transpose()?,
payment_method_type: <Option<PaymentMethodType>>::foreign_try_from(
value.payment_method.clone().ok_or_else(|| {
ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "INVALID_PAYMENT_METHOD_DATA".to_owned(),
error_identifier: 400,
error_message: "Payment method data is required".to_owned(),
error_object: None,
})
})?,
)?,
minor_amount: common_utils::types::MinorUnit::new(value.minor_amount),
email,
customer_name: None,
statement_descriptor_suffix: value.statement_descriptor_suffix,
statement_descriptor: value.statement_descriptor_name,
router_return_url: value.return_url.clone(),
complete_authorize_url: value.complete_authorize_url,
setup_future_usage,
mandate_id: None,
off_session: value.off_session,
order_category: value.order_category,
session_token: None,
access_token,
customer_acceptance: customer_acceptance
.map(mandates::CustomerAcceptance::foreign_try_from)
.transpose()?,
enrolled_for_3ds: false,
related_transaction_id: None,
payment_experience: None,
customer_id: value
.customer_id
.clone()
.map(|customer_id| CustomerId::try_from(Cow::from(customer_id)))
.transpose()
.change_context(ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "INVALID_CUSTOMER_ID".to_owned(),
error_identifier: 400,
error_message: "Failed to parse Customer Id".to_owned(),
error_object: None,
}))?,
request_incremental_authorization: false,
metadata: if value.metadata.is_empty() {
None
} else {
Some(serde_json::Value::Object(
value
.metadata
.into_iter()
.map(|(k, v)| (k, serde_json::Value::String(v)))
.collect(),
))
},
merchant_order_reference_id: value.merchant_order_reference_id,
order_tax_amount: None,
shipping_cost: None,
merchant_account_id,
integrity_object: None,
merchant_config_currency: Some(merchant_config_currency),
all_keys_required: None, // Field not available in new proto structure
split_payments: None,
enable_overcapture: None,
| {
"chunk": 15,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_16 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
setup_mandate_details: value
.setup_mandate_details
.map(mandates::MandateData::foreign_try_from)
.transpose()?,
request_extended_authorization: value.request_extended_authorization,
merchant_account_metadata,
})
}
}
impl ForeignTryFrom<grpc_api_types::payments::PaymentAddress> for payment_address::PaymentAddress {
type Error = ApplicationErrorResponse;
fn foreign_try_from(
value: grpc_api_types::payments::PaymentAddress,
) -> Result<Self, error_stack::Report<Self::Error>> {
let shipping = match value.shipping_address {
Some(address) => Some(Address::foreign_try_from(address)?),
None => None,
};
let billing = match value.billing_address.clone() {
Some(address) => Some(Address::foreign_try_from(address)?),
None => None,
};
let payment_method_billing = match value.billing_address {
Some(address) => Some(Address::foreign_try_from(address)?),
None => None,
};
Ok(Self::new(
shipping,
billing,
payment_method_billing,
Some(false), // should_unify_address set to false
))
}
}
impl ForeignTryFrom<grpc_api_types::payments::Address> for Address {
type Error = ApplicationErrorResponse;
fn foreign_try_from(
value: grpc_api_types::payments::Address,
) -> Result<Self, error_stack::Report<Self::Error>> {
let email = match value.email.clone() {
Some(email) => Some(
common_utils::pii::Email::from_str(&email.expose()).change_context(
ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "INVALID_EMAIL".to_owned(),
error_identifier: 400,
error_message: "Invalid email".to_owned(),
error_object: None,
}),
)?,
),
None => None,
};
Ok(Self {
address: Some(AddressDetails::foreign_try_from(value.clone())?),
phone: value.phone_number.map(|phone_number| PhoneDetails {
number: Some(phone_number),
country_code: value.phone_country_code,
}),
email,
})
}
}
impl ForeignTryFrom<grpc_api_types::payments::CountryAlpha2> for common_enums::CountryAlpha2 {
type Error = ApplicationErrorResponse;
fn foreign_try_from(
value: grpc_api_types::payments::CountryAlpha2,
) -> Result<Self, error_stack::Report<Self::Error>> {
match value {
grpc_api_types::payments::CountryAlpha2::Us => Ok(Self::US),
grpc_api_types::payments::CountryAlpha2::Af => Ok(Self::AF),
grpc_api_types::payments::CountryAlpha2::Ax => Ok(Self::AX),
grpc_api_types::payments::CountryAlpha2::Al => Ok(Self::AL),
grpc_api_types::payments::CountryAlpha2::Dz => Ok(Self::DZ),
grpc_api_types::payments::CountryAlpha2::As => Ok(Self::AS),
grpc_api_types::payments::CountryAlpha2::Ad => Ok(Self::AD),
grpc_api_types::payments::CountryAlpha2::Ao => Ok(Self::AO),
grpc_api_types::payments::CountryAlpha2::Ai => Ok(Self::AI),
grpc_api_types::payments::CountryAlpha2::Aq => Ok(Self::AQ),
grpc_api_types::payments::CountryAlpha2::Ag => Ok(Self::AG),
grpc_api_types::payments::CountryAlpha2::Ar => Ok(Self::AR),
grpc_api_types::payments::CountryAlpha2::Am => Ok(Self::AM),
grpc_api_types::payments::CountryAlpha2::Aw => Ok(Self::AW),
grpc_api_types::payments::CountryAlpha2::Au => Ok(Self::AU),
grpc_api_types::payments::CountryAlpha2::At => Ok(Self::AT),
grpc_api_types::payments::CountryAlpha2::Az => Ok(Self::AZ),
grpc_api_types::payments::CountryAlpha2::Bs => Ok(Self::BS),
grpc_api_types::payments::CountryAlpha2::Bh => Ok(Self::BH),
grpc_api_types::payments::CountryAlpha2::Bd => Ok(Self::BD),
grpc_api_types::payments::CountryAlpha2::Bb => Ok(Self::BB),
| {
"chunk": 16,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_17 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
grpc_api_types::payments::CountryAlpha2::By => Ok(Self::BY),
grpc_api_types::payments::CountryAlpha2::Be => Ok(Self::BE),
grpc_api_types::payments::CountryAlpha2::Bz => Ok(Self::BZ),
grpc_api_types::payments::CountryAlpha2::Bj => Ok(Self::BJ),
grpc_api_types::payments::CountryAlpha2::Bm => Ok(Self::BM),
grpc_api_types::payments::CountryAlpha2::Bt => Ok(Self::BT),
grpc_api_types::payments::CountryAlpha2::Bo => Ok(Self::BO),
grpc_api_types::payments::CountryAlpha2::Bq => Ok(Self::BQ),
grpc_api_types::payments::CountryAlpha2::Ba => Ok(Self::BA),
grpc_api_types::payments::CountryAlpha2::Bw => Ok(Self::BW),
grpc_api_types::payments::CountryAlpha2::Bv => Ok(Self::BV),
grpc_api_types::payments::CountryAlpha2::Br => Ok(Self::BR),
grpc_api_types::payments::CountryAlpha2::Io => Ok(Self::IO),
grpc_api_types::payments::CountryAlpha2::Bn => Ok(Self::BN),
grpc_api_types::payments::CountryAlpha2::Bg => Ok(Self::BG),
grpc_api_types::payments::CountryAlpha2::Bf => Ok(Self::BF),
grpc_api_types::payments::CountryAlpha2::Bi => Ok(Self::BI),
grpc_api_types::payments::CountryAlpha2::Kh => Ok(Self::KH),
grpc_api_types::payments::CountryAlpha2::Cm => Ok(Self::CM),
grpc_api_types::payments::CountryAlpha2::Ca => Ok(Self::CA),
grpc_api_types::payments::CountryAlpha2::Cv => Ok(Self::CV),
grpc_api_types::payments::CountryAlpha2::Ky => Ok(Self::KY),
grpc_api_types::payments::CountryAlpha2::Cf => Ok(Self::CF),
grpc_api_types::payments::CountryAlpha2::Td => Ok(Self::TD),
grpc_api_types::payments::CountryAlpha2::Cl => Ok(Self::CL),
grpc_api_types::payments::CountryAlpha2::Cn => Ok(Self::CN),
grpc_api_types::payments::CountryAlpha2::Cx => Ok(Self::CX),
grpc_api_types::payments::CountryAlpha2::Cc => Ok(Self::CC),
grpc_api_types::payments::CountryAlpha2::Co => Ok(Self::CO),
grpc_api_types::payments::CountryAlpha2::Km => Ok(Self::KM),
grpc_api_types::payments::CountryAlpha2::Cg => Ok(Self::CG),
grpc_api_types::payments::CountryAlpha2::Cd => Ok(Self::CD),
grpc_api_types::payments::CountryAlpha2::Ck => Ok(Self::CK),
grpc_api_types::payments::CountryAlpha2::Cr => Ok(Self::CR),
grpc_api_types::payments::CountryAlpha2::Ci => Ok(Self::CI),
grpc_api_types::payments::CountryAlpha2::Hr => Ok(Self::HR),
grpc_api_types::payments::CountryAlpha2::Cu => Ok(Self::CU),
grpc_api_types::payments::CountryAlpha2::Cw => Ok(Self::CW),
grpc_api_types::payments::CountryAlpha2::Cy => Ok(Self::CY),
grpc_api_types::payments::CountryAlpha2::Cz => Ok(Self::CZ),
grpc_api_types::payments::CountryAlpha2::Dk => Ok(Self::DK),
grpc_api_types::payments::CountryAlpha2::Dj => Ok(Self::DJ),
grpc_api_types::payments::CountryAlpha2::Dm => Ok(Self::DM),
grpc_api_types::payments::CountryAlpha2::Do => Ok(Self::DO),
grpc_api_types::payments::CountryAlpha2::Ec => Ok(Self::EC),
grpc_api_types::payments::CountryAlpha2::Eg => Ok(Self::EG),
grpc_api_types::payments::CountryAlpha2::Sv => Ok(Self::SV),
grpc_api_types::payments::CountryAlpha2::Gq => Ok(Self::GQ),
grpc_api_types::payments::CountryAlpha2::Er => Ok(Self::ER),
grpc_api_types::payments::CountryAlpha2::Ee => Ok(Self::EE),
grpc_api_types::payments::CountryAlpha2::Et => Ok(Self::ET),
grpc_api_types::payments::CountryAlpha2::Fk => Ok(Self::FK),
grpc_api_types::payments::CountryAlpha2::Fo => Ok(Self::FO),
grpc_api_types::payments::CountryAlpha2::Fj => Ok(Self::FJ),
grpc_api_types::payments::CountryAlpha2::Fi => Ok(Self::FI),
grpc_api_types::payments::CountryAlpha2::Fr => Ok(Self::FR),
| {
"chunk": 17,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_18 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
grpc_api_types::payments::CountryAlpha2::Gf => Ok(Self::GF),
grpc_api_types::payments::CountryAlpha2::Pf => Ok(Self::PF),
grpc_api_types::payments::CountryAlpha2::Tf => Ok(Self::TF),
grpc_api_types::payments::CountryAlpha2::Ga => Ok(Self::GA),
grpc_api_types::payments::CountryAlpha2::Gm => Ok(Self::GM),
grpc_api_types::payments::CountryAlpha2::Ge => Ok(Self::GE),
grpc_api_types::payments::CountryAlpha2::De => Ok(Self::DE),
grpc_api_types::payments::CountryAlpha2::Gh => Ok(Self::GH),
grpc_api_types::payments::CountryAlpha2::Gi => Ok(Self::GI),
grpc_api_types::payments::CountryAlpha2::Gr => Ok(Self::GR),
grpc_api_types::payments::CountryAlpha2::Gl => Ok(Self::GL),
grpc_api_types::payments::CountryAlpha2::Gd => Ok(Self::GD),
grpc_api_types::payments::CountryAlpha2::Gp => Ok(Self::GP),
grpc_api_types::payments::CountryAlpha2::Gu => Ok(Self::GU),
grpc_api_types::payments::CountryAlpha2::Gt => Ok(Self::GT),
grpc_api_types::payments::CountryAlpha2::Gg => Ok(Self::GG),
grpc_api_types::payments::CountryAlpha2::Gn => Ok(Self::GN),
grpc_api_types::payments::CountryAlpha2::Gw => Ok(Self::GW),
grpc_api_types::payments::CountryAlpha2::Gy => Ok(Self::GY),
grpc_api_types::payments::CountryAlpha2::Ht => Ok(Self::HT),
grpc_api_types::payments::CountryAlpha2::Hm => Ok(Self::HM),
grpc_api_types::payments::CountryAlpha2::Va => Ok(Self::VA),
grpc_api_types::payments::CountryAlpha2::Hn => Ok(Self::HN),
grpc_api_types::payments::CountryAlpha2::Hk => Ok(Self::HK),
grpc_api_types::payments::CountryAlpha2::Hu => Ok(Self::HU),
grpc_api_types::payments::CountryAlpha2::Is => Ok(Self::IS),
grpc_api_types::payments::CountryAlpha2::In => Ok(Self::IN),
grpc_api_types::payments::CountryAlpha2::Id => Ok(Self::ID),
grpc_api_types::payments::CountryAlpha2::Ir => Ok(Self::IR),
grpc_api_types::payments::CountryAlpha2::Iq => Ok(Self::IQ),
grpc_api_types::payments::CountryAlpha2::Ie => Ok(Self::IE),
grpc_api_types::payments::CountryAlpha2::Im => Ok(Self::IM),
grpc_api_types::payments::CountryAlpha2::Il => Ok(Self::IL),
grpc_api_types::payments::CountryAlpha2::It => Ok(Self::IT),
grpc_api_types::payments::CountryAlpha2::Jm => Ok(Self::JM),
grpc_api_types::payments::CountryAlpha2::Jp => Ok(Self::JP),
grpc_api_types::payments::CountryAlpha2::Je => Ok(Self::JE),
grpc_api_types::payments::CountryAlpha2::Jo => Ok(Self::JO),
grpc_api_types::payments::CountryAlpha2::Kz => Ok(Self::KZ),
grpc_api_types::payments::CountryAlpha2::Ke => Ok(Self::KE),
grpc_api_types::payments::CountryAlpha2::Ki => Ok(Self::KI),
grpc_api_types::payments::CountryAlpha2::Kp => Ok(Self::KP),
grpc_api_types::payments::CountryAlpha2::Kr => Ok(Self::KR),
grpc_api_types::payments::CountryAlpha2::Kw => Ok(Self::KW),
grpc_api_types::payments::CountryAlpha2::Kg => Ok(Self::KG),
grpc_api_types::payments::CountryAlpha2::La => Ok(Self::LA),
grpc_api_types::payments::CountryAlpha2::Lv => Ok(Self::LV),
grpc_api_types::payments::CountryAlpha2::Lb => Ok(Self::LB),
grpc_api_types::payments::CountryAlpha2::Ls => Ok(Self::LS),
grpc_api_types::payments::CountryAlpha2::Lr => Ok(Self::LR),
grpc_api_types::payments::CountryAlpha2::Ly => Ok(Self::LY),
grpc_api_types::payments::CountryAlpha2::Li => Ok(Self::LI),
grpc_api_types::payments::CountryAlpha2::Lt => Ok(Self::LT),
grpc_api_types::payments::CountryAlpha2::Lu => Ok(Self::LU),
grpc_api_types::payments::CountryAlpha2::Mo => Ok(Self::MO),
grpc_api_types::payments::CountryAlpha2::Mk => Ok(Self::MK),
| {
"chunk": 18,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_19 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
grpc_api_types::payments::CountryAlpha2::Mg => Ok(Self::MG),
grpc_api_types::payments::CountryAlpha2::Mw => Ok(Self::MW),
grpc_api_types::payments::CountryAlpha2::My => Ok(Self::MY),
grpc_api_types::payments::CountryAlpha2::Mv => Ok(Self::MV),
grpc_api_types::payments::CountryAlpha2::Ml => Ok(Self::ML),
grpc_api_types::payments::CountryAlpha2::Mt => Ok(Self::MT),
grpc_api_types::payments::CountryAlpha2::Mh => Ok(Self::MH),
grpc_api_types::payments::CountryAlpha2::Mq => Ok(Self::MQ),
grpc_api_types::payments::CountryAlpha2::Mr => Ok(Self::MR),
grpc_api_types::payments::CountryAlpha2::Mu => Ok(Self::MU),
grpc_api_types::payments::CountryAlpha2::Yt => Ok(Self::YT),
grpc_api_types::payments::CountryAlpha2::Mx => Ok(Self::MX),
grpc_api_types::payments::CountryAlpha2::Fm => Ok(Self::FM),
grpc_api_types::payments::CountryAlpha2::Md => Ok(Self::MD),
grpc_api_types::payments::CountryAlpha2::Mc => Ok(Self::MC),
grpc_api_types::payments::CountryAlpha2::Mn => Ok(Self::MN),
grpc_api_types::payments::CountryAlpha2::Me => Ok(Self::ME),
grpc_api_types::payments::CountryAlpha2::Ms => Ok(Self::MS),
grpc_api_types::payments::CountryAlpha2::Ma => Ok(Self::MA),
grpc_api_types::payments::CountryAlpha2::Mz => Ok(Self::MZ),
grpc_api_types::payments::CountryAlpha2::Mm => Ok(Self::MM),
grpc_api_types::payments::CountryAlpha2::Na => Ok(Self::NA),
grpc_api_types::payments::CountryAlpha2::Nr => Ok(Self::NR),
grpc_api_types::payments::CountryAlpha2::Np => Ok(Self::NP),
grpc_api_types::payments::CountryAlpha2::Nl => Ok(Self::NL),
grpc_api_types::payments::CountryAlpha2::Nc => Ok(Self::NC),
grpc_api_types::payments::CountryAlpha2::Nz => Ok(Self::NZ),
grpc_api_types::payments::CountryAlpha2::Ni => Ok(Self::NI),
grpc_api_types::payments::CountryAlpha2::Ne => Ok(Self::NE),
grpc_api_types::payments::CountryAlpha2::Ng => Ok(Self::NG),
grpc_api_types::payments::CountryAlpha2::Nu => Ok(Self::NU),
grpc_api_types::payments::CountryAlpha2::Nf => Ok(Self::NF),
grpc_api_types::payments::CountryAlpha2::Mp => Ok(Self::MP),
grpc_api_types::payments::CountryAlpha2::No => Ok(Self::NO),
grpc_api_types::payments::CountryAlpha2::Om => Ok(Self::OM),
grpc_api_types::payments::CountryAlpha2::Pk => Ok(Self::PK),
grpc_api_types::payments::CountryAlpha2::Pw => Ok(Self::PW),
grpc_api_types::payments::CountryAlpha2::Ps => Ok(Self::PS),
grpc_api_types::payments::CountryAlpha2::Pa => Ok(Self::PA),
grpc_api_types::payments::CountryAlpha2::Pg => Ok(Self::PG),
grpc_api_types::payments::CountryAlpha2::Py => Ok(Self::PY),
grpc_api_types::payments::CountryAlpha2::Pe => Ok(Self::PE),
grpc_api_types::payments::CountryAlpha2::Ph => Ok(Self::PH),
grpc_api_types::payments::CountryAlpha2::Pn => Ok(Self::PN),
grpc_api_types::payments::CountryAlpha2::Pl => Ok(Self::PL),
grpc_api_types::payments::CountryAlpha2::Pt => Ok(Self::PT),
grpc_api_types::payments::CountryAlpha2::Pr => Ok(Self::PR),
grpc_api_types::payments::CountryAlpha2::Qa => Ok(Self::QA),
grpc_api_types::payments::CountryAlpha2::Re => Ok(Self::RE),
grpc_api_types::payments::CountryAlpha2::Ro => Ok(Self::RO),
grpc_api_types::payments::CountryAlpha2::Ru => Ok(Self::RU),
grpc_api_types::payments::CountryAlpha2::Rw => Ok(Self::RW),
grpc_api_types::payments::CountryAlpha2::Bl => Ok(Self::BL),
grpc_api_types::payments::CountryAlpha2::Sh => Ok(Self::SH),
grpc_api_types::payments::CountryAlpha2::Kn => Ok(Self::KN),
grpc_api_types::payments::CountryAlpha2::Lc => Ok(Self::LC),
| {
"chunk": 19,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_20 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
grpc_api_types::payments::CountryAlpha2::Mf => Ok(Self::MF),
grpc_api_types::payments::CountryAlpha2::Pm => Ok(Self::PM),
grpc_api_types::payments::CountryAlpha2::Vc => Ok(Self::VC),
grpc_api_types::payments::CountryAlpha2::Ws => Ok(Self::WS),
grpc_api_types::payments::CountryAlpha2::Sm => Ok(Self::SM),
grpc_api_types::payments::CountryAlpha2::St => Ok(Self::ST),
grpc_api_types::payments::CountryAlpha2::Sa => Ok(Self::SA),
grpc_api_types::payments::CountryAlpha2::Sn => Ok(Self::SN),
grpc_api_types::payments::CountryAlpha2::Rs => Ok(Self::RS),
grpc_api_types::payments::CountryAlpha2::Sc => Ok(Self::SC),
grpc_api_types::payments::CountryAlpha2::Sl => Ok(Self::SL),
grpc_api_types::payments::CountryAlpha2::Sg => Ok(Self::SG),
grpc_api_types::payments::CountryAlpha2::Sx => Ok(Self::SX),
grpc_api_types::payments::CountryAlpha2::Sk => Ok(Self::SK),
grpc_api_types::payments::CountryAlpha2::Si => Ok(Self::SI),
grpc_api_types::payments::CountryAlpha2::Sb => Ok(Self::SB),
grpc_api_types::payments::CountryAlpha2::So => Ok(Self::SO),
grpc_api_types::payments::CountryAlpha2::Za => Ok(Self::ZA),
grpc_api_types::payments::CountryAlpha2::Gs => Ok(Self::GS),
grpc_api_types::payments::CountryAlpha2::Ss => Ok(Self::SS),
grpc_api_types::payments::CountryAlpha2::Es => Ok(Self::ES),
grpc_api_types::payments::CountryAlpha2::Lk => Ok(Self::LK),
grpc_api_types::payments::CountryAlpha2::Sd => Ok(Self::SD),
grpc_api_types::payments::CountryAlpha2::Sr => Ok(Self::SR),
grpc_api_types::payments::CountryAlpha2::Sj => Ok(Self::SJ),
grpc_api_types::payments::CountryAlpha2::Sz => Ok(Self::SZ),
grpc_api_types::payments::CountryAlpha2::Se => Ok(Self::SE),
grpc_api_types::payments::CountryAlpha2::Ch => Ok(Self::CH),
grpc_api_types::payments::CountryAlpha2::Sy => Ok(Self::SY),
grpc_api_types::payments::CountryAlpha2::Tw => Ok(Self::TW),
grpc_api_types::payments::CountryAlpha2::Tj => Ok(Self::TJ),
grpc_api_types::payments::CountryAlpha2::Tz => Ok(Self::TZ),
grpc_api_types::payments::CountryAlpha2::Th => Ok(Self::TH),
grpc_api_types::payments::CountryAlpha2::Tl => Ok(Self::TL),
grpc_api_types::payments::CountryAlpha2::Tg => Ok(Self::TG),
grpc_api_types::payments::CountryAlpha2::Tk => Ok(Self::TK),
grpc_api_types::payments::CountryAlpha2::To => Ok(Self::TO),
grpc_api_types::payments::CountryAlpha2::Tt => Ok(Self::TT),
grpc_api_types::payments::CountryAlpha2::Tn => Ok(Self::TN),
grpc_api_types::payments::CountryAlpha2::Tr => Ok(Self::TR),
grpc_api_types::payments::CountryAlpha2::Tm => Ok(Self::TM),
grpc_api_types::payments::CountryAlpha2::Tc => Ok(Self::TC),
grpc_api_types::payments::CountryAlpha2::Tv => Ok(Self::TV),
grpc_api_types::payments::CountryAlpha2::Ug => Ok(Self::UG),
grpc_api_types::payments::CountryAlpha2::Ua => Ok(Self::UA),
grpc_api_types::payments::CountryAlpha2::Ae => Ok(Self::AE),
grpc_api_types::payments::CountryAlpha2::Gb => Ok(Self::GB),
grpc_api_types::payments::CountryAlpha2::Um => Ok(Self::UM),
grpc_api_types::payments::CountryAlpha2::Uy => Ok(Self::UY),
grpc_api_types::payments::CountryAlpha2::Uz => Ok(Self::UZ),
grpc_api_types::payments::CountryAlpha2::Vu => Ok(Self::VU),
grpc_api_types::payments::CountryAlpha2::Ve => Ok(Self::VE),
grpc_api_types::payments::CountryAlpha2::Vn => Ok(Self::VN),
grpc_api_types::payments::CountryAlpha2::Vg => Ok(Self::VG),
grpc_api_types::payments::CountryAlpha2::Vi => Ok(Self::VI),
grpc_api_types::payments::CountryAlpha2::Wf => Ok(Self::WF),
| {
"chunk": 20,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_21 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
grpc_api_types::payments::CountryAlpha2::Eh => Ok(Self::EH),
grpc_api_types::payments::CountryAlpha2::Ye => Ok(Self::YE),
grpc_api_types::payments::CountryAlpha2::Zm => Ok(Self::ZM),
grpc_api_types::payments::CountryAlpha2::Zw => Ok(Self::ZW),
grpc_api_types::payments::CountryAlpha2::Unspecified => Ok(Self::US), // Default to US if unspecified
}
}
}
impl ForeignTryFrom<grpc_api_types::payments::Address> for AddressDetails {
type Error = ApplicationErrorResponse;
fn foreign_try_from(
value: grpc_api_types::payments::Address,
) -> Result<Self, error_stack::Report<Self::Error>> {
Ok(Self {
city: value.city.clone().map(|city| city.expose()),
country: Some(common_enums::CountryAlpha2::foreign_try_from(
value.country_alpha2_code(),
)?),
line1: value.line1,
line2: value.line2,
line3: value.line3,
zip: value.zip_code,
state: value.state,
first_name: value.first_name,
last_name: value.last_name,
})
}
}
// PhoneDetails conversion removed - phone info is now embedded in Address
impl ForeignTryFrom<(PaymentServiceAuthorizeRequest, Connectors, &MaskedMetadata)>
for PaymentFlowData
{
type Error = ApplicationErrorResponse;
fn foreign_try_from(
(value, connectors, metadata): (
PaymentServiceAuthorizeRequest,
Connectors,
&MaskedMetadata,
),
) -> Result<Self, error_stack::Report<Self::Error>> {
let address = match &value.address {
// Borrow value.address
Some(address_value) => {
// address_value is &grpc_api_types::payments::PaymentAddress
payment_address::PaymentAddress::foreign_try_from(
(*address_value).clone(), // Clone the grpc_api_types::payments::PaymentAddress
)?
}
None => {
return Err(ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "INVALID_ADDRESS".to_owned(),
error_identifier: 400,
error_message: "Address is required".to_owned(),
error_object: None,
}))?
}
};
let merchant_id_from_header = extract_merchant_id_from_metadata(metadata)?;
// Extract specific headers for vault and other integrations
let vault_headers = extract_headers_from_metadata(metadata);
let connector_meta_data = serde_json::to_value(&value.merchant_account_metadata)
.map(common_utils::pii::SecretSerdeValue::new)
.map_err(|_| {
error_stack::Report::new(ApplicationErrorResponse::InternalServerError(
crate::errors::ApiError {
sub_code: "SERDE_JSON_ERROR".to_owned(),
error_identifier: 500,
error_message: "Failed to serialize merchant_account_metadata".to_owned(),
error_object: None,
},
))
})?;
Ok(Self {
merchant_id: merchant_id_from_header,
payment_id: "IRRELEVANT_PAYMENT_ID".to_string(),
attempt_id: "IRRELEVANT_ATTEMPT_ID".to_string(),
status: common_enums::AttemptStatus::Pending,
payment_method: common_enums::PaymentMethod::foreign_try_from(
value.payment_method.unwrap_or_default(),
)?, // Use direct enum
address,
auth_type: common_enums::AuthenticationType::foreign_try_from(
grpc_api_types::payments::AuthenticationType::try_from(value.auth_type)
.unwrap_or_default(),
)?, // Use direct enum
connector_request_reference_id: extract_connector_request_reference_id(
&value.request_ref_id,
),
customer_id: value
.customer_id
.clone()
.map(|customer_id| CustomerId::try_from(Cow::from(customer_id)))
.transpose()
.change_context(ApplicationErrorResponse::BadRequest(ApiError {
| {
"chunk": 21,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_22 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
sub_code: "INVALID_CUSTOMER_ID".to_owned(),
error_identifier: 400,
error_message: "Failed to parse Customer Id".to_owned(),
error_object: None,
}))?,
connector_customer: value.connector_customer_id,
description: value.description,
return_url: value.return_url.clone(),
connector_meta_data: {
value.metadata.get("connector_meta_data").map(|json_string| {
Ok::<Secret<serde_json::Value>, error_stack::Report<ApplicationErrorResponse>>(Secret::new(serde_json::Value::String(json_string.clone())))
}).transpose()?
.or(Some(connector_meta_data)) // Converts Option<Result<T, E>> to Result<Option<T>, E> and propagates E if it's an Err
},
amount_captured: None,
minor_amount_captured: None,
minor_amount_capturable: None,
access_token: None,
session_token: None,
reference_id: None,
payment_method_token: None,
preprocessing_id: None,
connector_api_version: None,
test_mode: value.test_mode,
connector_http_status_code: None,
external_latency: None,
connectors,
raw_connector_response: None,
raw_connector_request: None,
connector_response_headers: None,
connector_response: None,
vault_headers,
recurring_mandate_payment_data: None,
})
}
}
impl
ForeignTryFrom<(
grpc_api_types::payments::PaymentServiceRepeatEverythingRequest,
Connectors,
&MaskedMetadata,
)> for PaymentFlowData
{
type Error = ApplicationErrorResponse;
fn foreign_try_from(
(value, connectors, metadata): (
grpc_api_types::payments::PaymentServiceRepeatEverythingRequest,
Connectors,
&MaskedMetadata,
),
) -> Result<Self, error_stack::Report<Self::Error>> {
let address = match &value.address {
// Borrow value.address
Some(address_value) => {
// address_value is &grpc_api_types::payments::PaymentAddress
payment_address::PaymentAddress::foreign_try_from(
(*address_value).clone(), // Clone the grpc_api_types::payments::PaymentAddress
)?
}
None => {
// For repeat payment operations, address information is typically not available or required
payment_address::PaymentAddress::new(
None, // shipping
None, // billing
None, // payment_method_billing
Some(false), // should_unify_address = false for repeat operations
)
}
};
let merchant_id_from_header = extract_merchant_id_from_metadata(metadata)?;
Ok(Self {
merchant_id: merchant_id_from_header,
payment_id: "IRRELEVANT_PAYMENT_ID".to_string(),
attempt_id: "IRRELEVANT_ATTEMPT_ID".to_string(),
status: common_enums::AttemptStatus::Pending,
payment_method: common_enums::PaymentMethod::Card, //TODO
address,
auth_type: common_enums::AuthenticationType::default(),
connector_request_reference_id: extract_connector_request_reference_id(
&value.request_ref_id,
),
customer_id: None,
connector_customer: value.connector_customer_id,
description: value.description,
return_url: None,
connector_meta_data: None,
amount_captured: None,
minor_amount_captured: None,
minor_amount_capturable: None,
access_token: None,
session_token: None,
reference_id: None,
payment_method_token: None,
preprocessing_id: None,
connector_api_version: None,
test_mode: value.test_mode,
connector_http_status_code: None,
external_latency: None,
connectors,
raw_connector_response: None,
raw_connector_request: None,
| {
"chunk": 22,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_23 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
connector_response_headers: None,
connector_response: None,
vault_headers: None,
recurring_mandate_payment_data: None,
})
}
}
impl
ForeignTryFrom<(
grpc_api_types::payments::PaymentServiceGetRequest,
Connectors,
&MaskedMetadata,
)> for PaymentFlowData
{
type Error = ApplicationErrorResponse;
fn foreign_try_from(
(value, connectors, metadata): (
grpc_api_types::payments::PaymentServiceGetRequest,
Connectors,
&MaskedMetadata,
),
) -> Result<Self, error_stack::Report<Self::Error>> {
// For sync operations, address information is typically not available or required
let address: PaymentAddress = crate::payment_address::PaymentAddress::new(
None, // shipping
None, // billing
None, // payment_method_billing
Some(false), // should_unify_address = false for sync operations
);
let merchant_id_from_header = extract_merchant_id_from_metadata(metadata)?;
let access_token = value
.state
.as_ref()
.and_then(|state| state.access_token.as_ref())
.map(|token| crate::connector_types::AccessTokenResponseData {
access_token: token.token.clone(),
token_type: None,
expires_in: token.expires_in_seconds,
});
Ok(Self {
merchant_id: merchant_id_from_header,
payment_id: "IRRELEVANT_PAYMENT_ID".to_string(),
attempt_id: "IRRELEVANT_ATTEMPT_ID".to_string(),
status: common_enums::AttemptStatus::Pending,
payment_method: common_enums::PaymentMethod::Card, //TODO
address,
auth_type: common_enums::AuthenticationType::default(),
connector_request_reference_id: extract_connector_request_reference_id(
&value.request_ref_id,
),
customer_id: None,
connector_customer: None,
description: None,
return_url: None,
connector_meta_data: None,
amount_captured: None,
minor_amount_captured: None,
minor_amount_capturable: None,
access_token,
session_token: None,
reference_id: None,
payment_method_token: None,
preprocessing_id: None,
connector_api_version: None,
test_mode: None,
connector_http_status_code: None,
external_latency: None,
connectors,
raw_connector_response: None,
raw_connector_request: None,
connector_response_headers: None,
vault_headers: None,
connector_response: None,
recurring_mandate_payment_data: None,
})
}
}
impl ForeignTryFrom<(PaymentServiceVoidRequest, Connectors, &MaskedMetadata)> for PaymentFlowData {
type Error = ApplicationErrorResponse;
fn foreign_try_from(
(value, connectors, metadata): (PaymentServiceVoidRequest, Connectors, &MaskedMetadata),
) -> Result<Self, error_stack::Report<Self::Error>> {
// For void operations, address information is typically not available or required
// Since this is a PaymentServiceVoidRequest, we use default address values
let address: PaymentAddress = payment_address::PaymentAddress::new(
None, // shipping
None, // billing
None, // payment_method_billing
Some(false), // should_unify_address = false for void operations
);
let merchant_id_from_header = extract_merchant_id_from_metadata(metadata)?;
Ok(Self {
merchant_id: merchant_id_from_header,
payment_id: "IRRELEVANT_PAYMENT_ID".to_string(),
attempt_id: "IRRELEVANT_ATTEMPT_ID".to_string(),
status: common_enums::AttemptStatus::Pending,
payment_method: common_enums::PaymentMethod::Card, //TODO
address,
auth_type: common_enums::AuthenticationType::default(),
connector_request_reference_id: extract_connector_request_reference_id(
&value.request_ref_id,
),
| {
"chunk": 23,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_24 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
customer_id: None,
connector_customer: None,
description: None,
return_url: None,
connector_meta_data: None,
amount_captured: None,
minor_amount_captured: None,
minor_amount_capturable: None,
access_token: None,
session_token: None,
reference_id: None,
payment_method_token: None,
preprocessing_id: None,
connector_api_version: None,
test_mode: None,
connector_http_status_code: None,
external_latency: None,
connectors,
raw_connector_response: None,
raw_connector_request: None,
connector_response_headers: None,
vault_headers: None,
connector_response: None,
recurring_mandate_payment_data: None,
})
}
}
impl ForeignTryFrom<ResponseId> for grpc_api_types::payments::Identifier {
type Error = ApplicationErrorResponse;
fn foreign_try_from(value: ResponseId) -> Result<Self, error_stack::Report<Self::Error>> {
Ok(match value {
ResponseId::ConnectorTransactionId(id) => Self {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(id)),
},
ResponseId::EncodedData(data) => Self {
id_type: Some(grpc_api_types::payments::identifier::IdType::EncodedData(
data,
)),
},
ResponseId::NoResponseId => Self {
id_type: Some(grpc_api_types::payments::identifier::IdType::NoResponseIdMarker(())),
},
})
}
}
impl ForeignTryFrom<router_request_types::AuthenticationData>
for grpc_api_types::payments::AuthenticationData
{
type Error = ApplicationErrorResponse;
fn foreign_try_from(
value: router_request_types::AuthenticationData,
) -> error_stack::Result<Self, Self::Error> {
use hyperswitch_masking::ExposeInterface;
let trans_status = value
.trans_status
.map(|ts| grpc_api_types::payments::TransactionStatus::foreign_from(ts).into());
Ok(Self {
ucaf_collection_indicator: value.ucaf_collection_indicator,
eci: value.eci,
cavv: value.cavv.map(|cavv| cavv.expose()),
threeds_server_transaction_id: value.threeds_server_transaction_id.map(|id| {
grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(id)),
}
}),
message_version: value.message_version.map(|v| v.to_string()),
ds_transaction_id: value.ds_trans_id,
trans_status,
acs_transaction_id: value.acs_transaction_id,
transaction_id: value.transaction_id,
})
}
}
impl ForeignFrom<common_enums::TransactionStatus> for grpc_api_types::payments::TransactionStatus {
fn foreign_from(from: common_enums::TransactionStatus) -> Self {
match from {
common_enums::TransactionStatus::Success => grpc_api_types::payments::TransactionStatus::Success,
common_enums::TransactionStatus::Failure => grpc_api_types::payments::TransactionStatus::Failure,
common_enums::TransactionStatus::VerificationNotPerformed => grpc_api_types::payments::TransactionStatus::VerificationNotPerformed,
common_enums::TransactionStatus::NotVerified => grpc_api_types::payments::TransactionStatus::NotVerified,
common_enums::TransactionStatus::Rejected => grpc_api_types::payments::TransactionStatus::Rejected,
common_enums::TransactionStatus::ChallengeRequired => grpc_api_types::payments::TransactionStatus::ChallengeRequired,
common_enums::TransactionStatus::ChallengeRequiredDecoupledAuthentication => grpc_api_types::payments::TransactionStatus::ChallengeRequiredDecoupledAuthentication,
common_enums::TransactionStatus::InformationOnly => grpc_api_types::payments::TransactionStatus::InformationOnly,
}
}
}
impl ForeignFrom<grpc_api_types::payments::TransactionStatus> for common_enums::TransactionStatus {
| {
"chunk": 24,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_25 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
fn foreign_from(value: grpc_api_types::payments::TransactionStatus) -> Self {
match value {
grpc_api_types::payments::TransactionStatus::Success => common_enums::TransactionStatus::Success,
grpc_api_types::payments::TransactionStatus::Failure => common_enums::TransactionStatus::Failure,
grpc_api_types::payments::TransactionStatus::VerificationNotPerformed => common_enums::TransactionStatus::VerificationNotPerformed,
grpc_api_types::payments::TransactionStatus::NotVerified => common_enums::TransactionStatus::NotVerified,
grpc_api_types::payments::TransactionStatus::Rejected => common_enums::TransactionStatus::Rejected,
grpc_api_types::payments::TransactionStatus::ChallengeRequired => common_enums::TransactionStatus::ChallengeRequired,
grpc_api_types::payments::TransactionStatus::ChallengeRequiredDecoupledAuthentication => common_enums::TransactionStatus::ChallengeRequiredDecoupledAuthentication,
grpc_api_types::payments::TransactionStatus::InformationOnly => common_enums::TransactionStatus::InformationOnly,
}
}
}
impl ForeignTryFrom<ConnectorResponseData> for grpc_api_types::payments::ConnectorResponseData {
type Error = ApplicationErrorResponse;
fn foreign_try_from(
value: ConnectorResponseData,
) -> Result<Self, error_stack::Report<Self::Error>> {
Ok(Self {
additional_payment_method_data: value.additional_payment_method_data.as_ref().map(
|additional_payment_method_connector_response| {
match additional_payment_method_connector_response {
AdditionalPaymentMethodConnectorResponse::Card {
authentication_data,
payment_checks,
card_network,
domestic_network,
} => grpc_api_types::payments::AdditionalPaymentMethodConnectorResponse {
card: Some(grpc_api_types::payments::CardConnectorResponse {
authentication_data: authentication_data
.as_ref()
.and_then(|data| serde_json::to_vec(data).ok()),
payment_checks: payment_checks
.as_ref()
.and_then(|checks| serde_json::to_vec(checks).ok()),
card_network: card_network.clone(),
domestic_network: domestic_network.clone(),
}),
},
}
},
),
extended_authorization_response_data: value
.get_extended_authorization_response_data()
.map(|extended_authorization_response_data| {
grpc_api_types::payments::ExtendedAuthorizationResponseData {
extended_authentication_applied: extended_authorization_response_data
.extended_authentication_applied,
capture_before: extended_authorization_response_data
.capture_before
.map(|dt| dt.assume_utc().unix_timestamp()),
}
}),
is_overcapture_enabled: value.is_overcapture_enabled(),
})
}
}
pub fn generate_create_order_response(
router_data_v2: RouterDataV2<
CreateOrder,
PaymentFlowData,
PaymentCreateOrderData,
PaymentCreateOrderResponse,
>,
) -> Result<PaymentServiceAuthorizeResponse, error_stack::Report<ApplicationErrorResponse>> {
let transaction_response = router_data_v2.response;
let status = router_data_v2.resource_common_data.status;
let grpc_status = grpc_api_types::payments::PaymentStatus::foreign_from(status);
let raw_connector_response = router_data_v2
.resource_common_data
.get_raw_connector_response();
let raw_connector_request = router_data_v2
.resource_common_data
.get_raw_connector_request();
let response = match transaction_response {
| {
"chunk": 25,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_26 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
Ok(response) => {
// For successful order creation, return basic success response
PaymentServiceAuthorizeResponse {
transaction_id: Some(grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(
response.order_id,
)),
}),
redirection_data: None,
network_txn_id: None,
response_ref_id: None,
incremental_authorization_allowed: None,
status: grpc_status as i32,
error_message: None,
error_code: None,
status_code: 200,
raw_connector_response,
raw_connector_request,
response_headers: router_data_v2
.resource_common_data
.get_connector_response_headers_as_map(),
connector_metadata: std::collections::HashMap::new(),
state: None,
captured_amount: None,
minor_captured_amount: None,
minor_amount_capturable: None,
mandate_reference: None,
connector_response: None,
}
}
Err(err) => {
let status = err
.attempt_status
.map(grpc_api_types::payments::PaymentStatus::foreign_from)
.unwrap_or_default();
PaymentServiceAuthorizeResponse {
transaction_id: Some(grpc_api_types::payments::Identifier {
id_type: Some(
grpc_api_types::payments::identifier::IdType::NoResponseIdMarker(()),
),
}),
redirection_data: None,
network_txn_id: None,
response_ref_id: err.connector_transaction_id.map(|id| {
grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(id)),
}
}),
incremental_authorization_allowed: None,
status: status as i32,
error_message: Some(err.message),
error_code: Some(err.code),
status_code: err.status_code as u32,
response_headers: router_data_v2
.resource_common_data
.get_connector_response_headers_as_map(),
connector_metadata: std::collections::HashMap::new(),
raw_connector_response,
raw_connector_request,
state: None,
captured_amount: None,
minor_captured_amount: None,
minor_amount_capturable: None,
mandate_reference: None,
connector_response: None,
}
}
};
Ok(response)
}
pub fn generate_payment_authorize_response<T: PaymentMethodDataTypes>(
router_data_v2: RouterDataV2<
Authorize,
PaymentFlowData,
PaymentsAuthorizeData<T>,
PaymentsResponseData,
>,
) -> Result<PaymentServiceAuthorizeResponse, error_stack::Report<ApplicationErrorResponse>> {
let transaction_response = router_data_v2.response;
let status = router_data_v2.resource_common_data.status;
info!("Payment authorize response status: {:?}", status);
let order_id = router_data_v2.resource_common_data.reference_id.clone();
let response_headers = router_data_v2
.resource_common_data
.get_connector_response_headers_as_map();
let grpc_status = grpc_api_types::payments::PaymentStatus::foreign_from(status);
let raw_connector_response = router_data_v2
.resource_common_data
.get_raw_connector_response();
let raw_connector_request = router_data_v2
.resource_common_data
.get_raw_connector_request();
// Create state if either access token or connector customer is available
let state = if router_data_v2.resource_common_data.access_token.is_some()
|| router_data_v2
.resource_common_data
.connector_customer
.is_some()
{
Some(ConnectorState {
access_token: router_data_v2
| {
"chunk": 26,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_27 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
.resource_common_data
.access_token
.as_ref()
.map(|token_data| grpc_api_types::payments::AccessToken {
token: token_data.access_token.clone(),
expires_in_seconds: token_data.expires_in,
token_type: token_data.token_type.clone(),
}),
connector_customer_id: router_data_v2
.resource_common_data
.connector_customer
.clone(),
})
} else {
None
};
let connector_response = router_data_v2
.resource_common_data
.connector_response
.as_ref()
.map(|connector_response_data| {
grpc_api_types::payments::ConnectorResponseData::foreign_try_from(
connector_response_data.clone(),
)
})
.transpose()?;
let response = match transaction_response {
Ok(response) => match response {
PaymentsResponseData::TransactionResponse {
resource_id,
redirection_data,
connector_metadata,
network_txn_id,
connector_response_reference_id,
incremental_authorization_allowed,
mandate_reference,
status_code,
} => {
let mandate_reference_grpc =
mandate_reference.map(|m| grpc_api_types::payments::MandateReference {
mandate_id: m.connector_mandate_id,
payment_method_id: m.payment_method_id,
});
PaymentServiceAuthorizeResponse {
transaction_id: Some(grpc_api_types::payments::Identifier::foreign_try_from(resource_id)?),
redirection_data: redirection_data.map(
|form| {
match *form {
crate::router_response_types::RedirectForm::Form { endpoint, method, form_fields } => {
Ok::<grpc_api_types::payments::RedirectForm, ApplicationErrorResponse>(grpc_api_types::payments::RedirectForm {
form_type: Some(grpc_api_types::payments::redirect_form::FormType::Form(
grpc_api_types::payments::FormData {
endpoint,
method: grpc_api_types::payments::HttpMethod::foreign_from(method) as i32,
form_fields, //TODO
}
))
})
},
router_response_types::RedirectForm::Html { html_data } => {
Ok(grpc_api_types::payments::RedirectForm {
form_type: Some(grpc_api_types::payments::redirect_form::FormType::Html(
grpc_api_types::payments::HtmlData {
html_data,
}
))
})
},
router_response_types::RedirectForm::Uri { uri } => {
Ok(grpc_api_types::payments::RedirectForm {
form_type: Some(grpc_api_types::payments::redirect_form::FormType::Uri(
grpc_api_types::payments::UriData {
uri,
}
))
})
},
crate::router_response_types::RedirectForm::Mifinity { initialization_token } => {
Ok(grpc_api_types::payments::RedirectForm {
form_type: Some(grpc_api_types::payments::redirect_form::FormType::Uri(
| {
"chunk": 27,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_28 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
grpc_api_types::payments::UriData {
uri: initialization_token,
}
))
})
},
_ => Err(
ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "INVALID_RESPONSE".to_owned(),
error_identifier: 400,
error_message: "Invalid response from connector".to_owned(),
error_object: None,
}))?,
}
}
).transpose()?,
connector_metadata: connector_metadata
.and_then(|value| value.as_object().cloned())
.map(|map| {map.into_iter().filter_map(|(k, v)| v.as_str()
.map(|s| (k, s.to_string())))
.collect::<HashMap<_, _>>()}).unwrap_or_default(),
network_txn_id,
response_ref_id: connector_response_reference_id.map(|id| grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(id)),
}),
mandate_reference: mandate_reference_grpc,
incremental_authorization_allowed,
status: grpc_status as i32,
error_message: None,
error_code: None,
raw_connector_response,
raw_connector_request,
status_code: status_code as u32,
response_headers,
state,
captured_amount: router_data_v2.resource_common_data.amount_captured,
minor_captured_amount: router_data_v2
.resource_common_data
.minor_amount_captured
.map(|amount_captured| amount_captured.get_amount_as_i64()),
minor_amount_capturable: router_data_v2
.resource_common_data
.minor_amount_capturable
.map(|amount_capturable| amount_capturable.get_amount_as_i64()),
connector_response,
}
}
_ => Err(ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "INVALID_RESPONSE".to_owned(),
error_identifier: 400,
error_message: "Invalid response from connector".to_owned(),
error_object: None,
}))?,
},
Err(err) => {
let status = err
.attempt_status
.map(grpc_api_types::payments::PaymentStatus::foreign_from)
.unwrap_or_default();
PaymentServiceAuthorizeResponse {
transaction_id: Some(grpc_api_types::payments::Identifier {
id_type: Some(
grpc_api_types::payments::identifier::IdType::NoResponseIdMarker(()),
),
}),
redirection_data: None,
network_txn_id: None,
response_ref_id: order_id.map(|id| grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(id)),
}),
mandate_reference: None,
incremental_authorization_allowed: None,
status: status as i32,
error_message: Some(err.message),
error_code: Some(err.code),
status_code: err.status_code as u32,
response_headers,
raw_connector_response,
raw_connector_request,
connector_metadata: std::collections::HashMap::new(),
state,
captured_amount: None,
minor_captured_amount: None,
minor_amount_capturable: None,
| {
"chunk": 28,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_29 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
connector_response: None,
}
}
};
Ok(response)
}
// ForeignTryFrom for PaymentMethod gRPC enum to internal enum
impl ForeignTryFrom<grpc_api_types::payments::PaymentMethod> for common_enums::PaymentMethod {
type Error = ApplicationErrorResponse;
fn foreign_try_from(
item: grpc_api_types::payments::PaymentMethod,
) -> Result<Self, error_stack::Report<Self::Error>> {
match item {
grpc_api_types::payments::PaymentMethod {
payment_method:
Some(grpc_api_types::payments::payment_method::PaymentMethod::Card(_)),
} => Ok(Self::Card),
grpc_api_types::payments::PaymentMethod {
payment_method:
Some(grpc_api_types::payments::payment_method::PaymentMethod::Token(_)),
} => Ok(Self::Wallet),
grpc_api_types::payments::PaymentMethod {
payment_method:
Some(grpc_api_types::payments::payment_method::PaymentMethod::UpiCollect(_)),
} => Ok(Self::Upi),
grpc_api_types::payments::PaymentMethod {
payment_method:
Some(grpc_api_types::payments::payment_method::PaymentMethod::UpiIntent(_)),
} => Ok(Self::Upi),
grpc_api_types::payments::PaymentMethod {
payment_method:
Some(grpc_api_types::payments::payment_method::PaymentMethod::UpiQr(_)),
} => Ok(Self::Upi),
grpc_api_types::payments::PaymentMethod {
payment_method:
Some(grpc_api_types::payments::payment_method::PaymentMethod::Reward(_)),
} => Ok(Self::Reward),
grpc_api_types::payments::PaymentMethod {
payment_method:
Some(grpc_api_types::payments::payment_method::PaymentMethod::Wallet(_)),
} => Ok(Self::Wallet),
_ => Ok(Self::Card), // Default fallback
}
}
}
// ForeignTryFrom for AuthenticationType gRPC enum to internal enum
impl ForeignTryFrom<grpc_api_types::payments::AuthenticationType>
for common_enums::AuthenticationType
{
type Error = ApplicationErrorResponse;
fn foreign_try_from(
item: grpc_api_types::payments::AuthenticationType,
) -> Result<Self, error_stack::Report<Self::Error>> {
match item {
grpc_api_types::payments::AuthenticationType::Unspecified => Ok(Self::NoThreeDs), // Default to NoThreeDs for unspecified
grpc_api_types::payments::AuthenticationType::ThreeDs => Ok(Self::ThreeDs),
grpc_api_types::payments::AuthenticationType::NoThreeDs => Ok(Self::NoThreeDs),
}
}
}
impl ForeignTryFrom<grpc_api_types::payments::PaymentServiceGetRequest> for PaymentsSyncData {
type Error = ApplicationErrorResponse;
fn foreign_try_from(
value: grpc_api_types::payments::PaymentServiceGetRequest,
) -> Result<Self, error_stack::Report<Self::Error>> {
let capture_method = Some(common_enums::CaptureMethod::foreign_try_from(
value.capture_method(),
)?);
let currency = common_enums::Currency::foreign_try_from(value.currency())?;
let amount = common_utils::types::MinorUnit::new(value.amount);
// Create ResponseId from resource_id
let connector_transaction_id = ResponseId::ConnectorTransactionId(
value
.transaction_id
.clone()
.and_then(|id| id.id_type)
.and_then(|id_type| match id_type {
grpc_api_types::payments::identifier::IdType::Id(id) => Some(id),
_ => None,
})
.unwrap_or_default(),
);
let encoded_data = value
.transaction_id
.and_then(|id| id.id_type)
.and_then(|id_type| match id_type {
grpc_api_types::payments::identifier::IdType::EncodedData(data) => Some(data),
_ => None,
});
Ok(Self {
connector_transaction_id,
encoded_data,
capture_method,
connector_meta: None,
sync_type: router_request_types::SyncRequestType::SinglePaymentSync,
mandate_id: None,
| {
"chunk": 29,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_30 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
payment_method_type: None,
currency,
payment_experience: None,
amount,
integrity_object: None,
all_keys_required: None, // Field not available in new proto structure
split_payments: None,
})
}
}
impl
ForeignTryFrom<(
grpc_api_types::payments::PaymentServiceGetRequest,
Connectors,
)> for PaymentFlowData
{
type Error = ApplicationErrorResponse;
fn foreign_try_from(
(value, connectors): (
grpc_api_types::payments::PaymentServiceGetRequest,
Connectors,
),
) -> Result<Self, error_stack::Report<Self::Error>> {
Ok(Self {
merchant_id: common_utils::id_type::MerchantId::default(),
payment_id: "PAYMENT_ID".to_string(),
attempt_id: "ATTEMPT_ID".to_string(),
status: common_enums::AttemptStatus::Pending,
payment_method: common_enums::PaymentMethod::Card, // Default
address: payment_address::PaymentAddress::default(),
auth_type: common_enums::AuthenticationType::default(),
connector_request_reference_id: extract_connector_request_reference_id(
&value.request_ref_id,
),
customer_id: None,
connector_customer: None,
description: None,
return_url: None,
connector_meta_data: None,
amount_captured: None,
minor_amount_captured: None,
minor_amount_capturable: None,
access_token: None,
session_token: None,
reference_id: None,
payment_method_token: None,
preprocessing_id: None,
connector_api_version: None,
test_mode: None,
connector_http_status_code: None,
external_latency: None,
connectors,
raw_connector_response: None,
raw_connector_request: None,
connector_response_headers: None,
vault_headers: None,
connector_response: None,
recurring_mandate_payment_data: None,
})
}
}
impl ForeignFrom<common_enums::AttemptStatus> for grpc_api_types::payments::PaymentStatus {
fn foreign_from(status: common_enums::AttemptStatus) -> Self {
match status {
common_enums::AttemptStatus::Charged => Self::Charged,
common_enums::AttemptStatus::Pending => Self::Pending,
common_enums::AttemptStatus::Failure => Self::Failure,
common_enums::AttemptStatus::Authorized => Self::Authorized,
common_enums::AttemptStatus::Started => Self::Started,
common_enums::AttemptStatus::AuthenticationFailed => Self::AuthenticationFailed,
common_enums::AttemptStatus::AuthenticationPending => Self::AuthenticationPending,
common_enums::AttemptStatus::AuthenticationSuccessful => Self::AuthenticationSuccessful,
common_enums::AttemptStatus::Authorizing => Self::Authorizing,
common_enums::AttemptStatus::CaptureInitiated => Self::CaptureInitiated,
common_enums::AttemptStatus::CaptureFailed => Self::CaptureFailed,
common_enums::AttemptStatus::VoidInitiated => Self::VoidInitiated,
common_enums::AttemptStatus::VoidPostCaptureInitiated => Self::VoidInitiated,
common_enums::AttemptStatus::VoidFailed => Self::VoidFailed,
common_enums::AttemptStatus::Voided => Self::Voided,
common_enums::AttemptStatus::VoidedPostCapture => Self::VoidedPostCapture,
common_enums::AttemptStatus::Unresolved => Self::Unresolved,
common_enums::AttemptStatus::PaymentMethodAwaited => Self::PaymentMethodAwaited,
common_enums::AttemptStatus::ConfirmationAwaited => Self::ConfirmationAwaited,
common_enums::AttemptStatus::DeviceDataCollectionPending => {
Self::DeviceDataCollectionPending
}
common_enums::AttemptStatus::RouterDeclined => Self::RouterDeclined,
common_enums::AttemptStatus::AuthorizationFailed => Self::AuthorizationFailed,
common_enums::AttemptStatus::CodInitiated => Self::CodInitiated,
| {
"chunk": 30,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_31 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
common_enums::AttemptStatus::AutoRefunded => Self::AutoRefunded,
common_enums::AttemptStatus::PartialCharged => Self::PartialCharged,
common_enums::AttemptStatus::PartialChargedAndChargeable => {
Self::PartialChargedAndChargeable
}
common_enums::AttemptStatus::IntegrityFailure => Self::Failure,
common_enums::AttemptStatus::Unknown => Self::AttemptStatusUnspecified,
}
}
}
impl ForeignTryFrom<grpc_api_types::payments::PaymentStatus> for common_enums::AttemptStatus {
type Error = ApplicationErrorResponse;
fn foreign_try_from(
status: grpc_api_types::payments::PaymentStatus,
) -> Result<Self, error_stack::Report<Self::Error>> {
match status {
grpc_api_types::payments::PaymentStatus::Charged => Ok(Self::Charged),
grpc_api_types::payments::PaymentStatus::Pending => Ok(Self::Pending),
grpc_api_types::payments::PaymentStatus::Failure => Ok(Self::Failure),
grpc_api_types::payments::PaymentStatus::Authorized => Ok(Self::Authorized),
grpc_api_types::payments::PaymentStatus::Started => Ok(Self::Started),
grpc_api_types::payments::PaymentStatus::AuthenticationFailed => {
Ok(Self::AuthenticationFailed)
}
grpc_api_types::payments::PaymentStatus::AuthenticationPending => {
Ok(Self::AuthenticationPending)
}
grpc_api_types::payments::PaymentStatus::AuthenticationSuccessful => {
Ok(Self::AuthenticationSuccessful)
}
grpc_api_types::payments::PaymentStatus::Authorizing => Ok(Self::Authorizing),
grpc_api_types::payments::PaymentStatus::CaptureInitiated => Ok(Self::CaptureInitiated),
grpc_api_types::payments::PaymentStatus::CaptureFailed => Ok(Self::CaptureFailed),
grpc_api_types::payments::PaymentStatus::VoidInitiated => Ok(Self::VoidInitiated),
grpc_api_types::payments::PaymentStatus::VoidFailed => Ok(Self::VoidFailed),
grpc_api_types::payments::PaymentStatus::Voided => Ok(Self::Voided),
grpc_api_types::payments::PaymentStatus::VoidedPostCapture => {
Ok(Self::VoidedPostCapture)
}
grpc_api_types::payments::PaymentStatus::Unresolved => Ok(Self::Unresolved),
grpc_api_types::payments::PaymentStatus::PaymentMethodAwaited => {
Ok(Self::PaymentMethodAwaited)
}
grpc_api_types::payments::PaymentStatus::ConfirmationAwaited => {
Ok(Self::ConfirmationAwaited)
}
grpc_api_types::payments::PaymentStatus::DeviceDataCollectionPending => {
Ok(Self::DeviceDataCollectionPending)
}
grpc_api_types::payments::PaymentStatus::RouterDeclined => Ok(Self::RouterDeclined),
grpc_api_types::payments::PaymentStatus::AuthorizationFailed => {
Ok(Self::AuthorizationFailed)
}
grpc_api_types::payments::PaymentStatus::CodInitiated => Ok(Self::CodInitiated),
grpc_api_types::payments::PaymentStatus::AutoRefunded => Ok(Self::AutoRefunded),
grpc_api_types::payments::PaymentStatus::PartialCharged => Ok(Self::PartialCharged),
grpc_api_types::payments::PaymentStatus::PartialChargedAndChargeable => {
Ok(Self::PartialChargedAndChargeable)
}
grpc_api_types::payments::PaymentStatus::AttemptStatusUnspecified => Ok(Self::Unknown),
}
}
}
impl ForeignFrom<common_enums::RefundStatus> for grpc_api_types::payments::RefundStatus {
fn foreign_from(status: common_enums::RefundStatus) -> Self {
match status {
common_enums::RefundStatus::Failure => Self::RefundFailure,
common_enums::RefundStatus::ManualReview => Self::RefundManualReview,
common_enums::RefundStatus::Pending => Self::RefundPending,
common_enums::RefundStatus::Success => Self::RefundSuccess,
common_enums::RefundStatus::TransactionFailure => Self::RefundTransactionFailure,
}
}
}
pub fn generate_payment_void_response(
| {
"chunk": 31,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_32 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
router_data_v2: RouterDataV2<Void, PaymentFlowData, PaymentVoidData, PaymentsResponseData>,
) -> Result<PaymentServiceVoidResponse, error_stack::Report<ApplicationErrorResponse>> {
let transaction_response = router_data_v2.response;
// Create state if either access token or connector customer is available
let state = if router_data_v2.resource_common_data.access_token.is_some()
|| router_data_v2
.resource_common_data
.connector_customer
.is_some()
{
Some(ConnectorState {
access_token: router_data_v2
.resource_common_data
.access_token
.as_ref()
.map(|token_data| grpc_api_types::payments::AccessToken {
token: token_data.access_token.clone(),
expires_in_seconds: token_data.expires_in,
token_type: token_data.token_type.clone(),
}),
connector_customer_id: router_data_v2
.resource_common_data
.connector_customer
.clone(),
})
} else {
None
};
let raw_connector_request = router_data_v2
.resource_common_data
.get_raw_connector_request();
match transaction_response {
Ok(response) => match response {
PaymentsResponseData::TransactionResponse {
resource_id,
redirection_data: _,
connector_metadata: _,
network_txn_id: _,
connector_response_reference_id,
incremental_authorization_allowed,
mandate_reference,
status_code,
} => {
let status = router_data_v2.resource_common_data.status;
let grpc_status = grpc_api_types::payments::PaymentStatus::foreign_from(status);
let grpc_resource_id =
grpc_api_types::payments::Identifier::foreign_try_from(resource_id)?;
let mandate_reference_grpc =
mandate_reference.map(|m| grpc_api_types::payments::MandateReference {
mandate_id: m.connector_mandate_id,
payment_method_id: m.payment_method_id,
});
Ok(PaymentServiceVoidResponse {
transaction_id: Some(grpc_resource_id),
status: grpc_status.into(),
response_ref_id: connector_response_reference_id.map(|id| {
grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(id)),
}
}),
error_code: None,
error_message: None,
status_code: u32::from(status_code),
response_headers: router_data_v2
.resource_common_data
.get_connector_response_headers_as_map(),
raw_connector_request,
state,
mandate_reference: mandate_reference_grpc,
incremental_authorization_allowed,
})
}
_ => Err(report!(ApplicationErrorResponse::InternalServerError(
ApiError {
sub_code: "INVALID_RESPONSE_TYPE".to_owned(),
error_identifier: 500,
error_message: "Invalid response type received from connector".to_owned(),
error_object: None,
}
))),
},
Err(e) => {
let status = e
.attempt_status
.map(grpc_api_types::payments::PaymentStatus::foreign_from)
.unwrap_or_default();
Ok(PaymentServiceVoidResponse {
transaction_id: Some(grpc_api_types::payments::Identifier {
id_type: Some(
grpc_api_types::payments::identifier::IdType::NoResponseIdMarker(()),
),
}),
response_ref_id: e.connector_transaction_id.map(|id| {
grpc_api_types::payments::Identifier {
| {
"chunk": 32,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_33 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(id)),
}
}),
status: status as i32,
error_message: Some(e.message),
error_code: Some(e.code),
status_code: e.status_code as u32,
response_headers: router_data_v2
.resource_common_data
.get_connector_response_headers_as_map(),
state: None,
raw_connector_request,
mandate_reference: None,
incremental_authorization_allowed: None,
})
}
}
}
pub fn generate_payment_void_post_capture_response(
router_data_v2: RouterDataV2<
VoidPC,
PaymentFlowData,
crate::connector_types::PaymentsCancelPostCaptureData,
PaymentsResponseData,
>,
) -> Result<PaymentServiceVoidPostCaptureResponse, error_stack::Report<ApplicationErrorResponse>> {
let transaction_response = router_data_v2.response;
// If there's an access token in PaymentFlowData, it must be newly generated (needs caching)
let _state = router_data_v2
.resource_common_data
.access_token
.as_ref()
.map(|token_data| ConnectorState {
access_token: Some(grpc_api_types::payments::AccessToken {
token: token_data.access_token.clone(),
expires_in_seconds: token_data.expires_in,
token_type: token_data.token_type.clone(),
}),
connector_customer_id: router_data_v2
.resource_common_data
.connector_customer
.clone(),
});
match transaction_response {
Ok(response) => match response {
PaymentsResponseData::TransactionResponse {
resource_id,
redirection_data: _,
connector_metadata: _,
network_txn_id: _,
connector_response_reference_id,
incremental_authorization_allowed: _,
mandate_reference: _,
status_code,
} => {
let status = router_data_v2.resource_common_data.status;
let grpc_status = grpc_api_types::payments::PaymentStatus::foreign_from(status);
let grpc_resource_id =
grpc_api_types::payments::Identifier::foreign_try_from(resource_id)?;
Ok(PaymentServiceVoidPostCaptureResponse {
transaction_id: Some(grpc_resource_id),
status: grpc_status.into(),
response_ref_id: connector_response_reference_id.map(|id| {
grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(id)),
}
}),
error_code: None,
error_message: None,
status_code: u32::from(status_code),
response_headers: router_data_v2
.resource_common_data
.get_connector_response_headers_as_map(),
})
}
_ => Err(report!(ApplicationErrorResponse::InternalServerError(
ApiError {
sub_code: "INVALID_RESPONSE_TYPE".to_owned(),
error_identifier: 500,
error_message: "Invalid response type received from connector".to_owned(),
error_object: None,
}
))),
},
Err(e) => {
let status = e
.attempt_status
.map(grpc_api_types::payments::PaymentStatus::foreign_from)
.unwrap_or_default();
Ok(PaymentServiceVoidPostCaptureResponse {
transaction_id: Some(grpc_api_types::payments::Identifier {
id_type: Some(
grpc_api_types::payments::identifier::IdType::NoResponseIdMarker(()),
),
}),
status: status.into(),
response_ref_id: e.connector_transaction_id.map(|id| {
grpc_api_types::payments::Identifier {
| {
"chunk": 33,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_34 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(id)),
}
}),
error_code: Some(e.code),
error_message: Some(e.message),
status_code: u32::from(e.status_code),
response_headers: router_data_v2
.resource_common_data
.get_connector_response_headers_as_map(),
})
}
}
}
impl ForeignFrom<common_enums::DisputeStage> for grpc_api_types::payments::DisputeStage {
fn foreign_from(status: common_enums::DisputeStage) -> Self {
match status {
common_enums::DisputeStage::PreDispute => Self::PreDispute,
common_enums::DisputeStage::Dispute => Self::ActiveDispute,
common_enums::DisputeStage::PreArbitration => Self::PreArbitration,
}
}
}
pub fn generate_payment_sync_response(
router_data_v2: RouterDataV2<PSync, PaymentFlowData, PaymentsSyncData, PaymentsResponseData>,
) -> Result<PaymentServiceGetResponse, error_stack::Report<ApplicationErrorResponse>> {
let transaction_response = router_data_v2.response;
let raw_connector_response = router_data_v2
.resource_common_data
.get_raw_connector_response();
// Create state if either access token or connector customer is available
let state = if router_data_v2.resource_common_data.access_token.is_some()
|| router_data_v2
.resource_common_data
.connector_customer
.is_some()
{
Some(ConnectorState {
access_token: router_data_v2
.resource_common_data
.access_token
.as_ref()
.map(|token_data| grpc_api_types::payments::AccessToken {
token: token_data.access_token.clone(),
expires_in_seconds: token_data.expires_in,
token_type: token_data.token_type.clone(),
}),
connector_customer_id: router_data_v2
.resource_common_data
.connector_customer
.clone(),
})
} else {
None
};
let raw_connector_request = router_data_v2
.resource_common_data
.get_raw_connector_request();
let connector_response = router_data_v2
.resource_common_data
.connector_response
.as_ref()
.map(|connector_response_data| {
grpc_api_types::payments::ConnectorResponseData::foreign_try_from(
connector_response_data.clone(),
)
})
.transpose()?;
match transaction_response {
Ok(response) => match response {
PaymentsResponseData::TransactionResponse {
resource_id,
redirection_data: _,
connector_metadata: _,
network_txn_id,
connector_response_reference_id,
incremental_authorization_allowed: _,
mandate_reference,
status_code,
} => {
let status = router_data_v2.resource_common_data.status;
let grpc_status = grpc_api_types::payments::PaymentStatus::foreign_from(status);
let grpc_resource_id =
grpc_api_types::payments::Identifier::foreign_try_from(resource_id)?;
let mandate_reference_grpc =
mandate_reference.map(|m| grpc_api_types::payments::MandateReference {
mandate_id: m.connector_mandate_id,
payment_method_id: m.payment_method_id,
});
Ok(PaymentServiceGetResponse {
transaction_id: Some(grpc_resource_id),
status: grpc_status as i32,
mandate_reference: mandate_reference_grpc,
error_code: None,
error_message: None,
network_txn_id,
response_ref_id: connector_response_reference_id.map(|id| {
grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(id)),
}
}),
amount: None,
| {
"chunk": 34,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_35 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
minor_amount: None,
currency: None,
captured_amount: router_data_v2.resource_common_data.amount_captured,
minor_captured_amount: router_data_v2
.resource_common_data
.minor_amount_captured
.map(|amount_captured| amount_captured.get_amount_as_i64()),
payment_method_type: None,
capture_method: None,
auth_type: None,
created_at: None,
updated_at: None,
authorized_at: None,
captured_at: None,
customer_name: None,
email: None,
connector_customer_id: None,
merchant_order_reference_id: None,
metadata: std::collections::HashMap::new(),
status_code: status_code as u32,
raw_connector_response,
response_headers: router_data_v2
.resource_common_data
.get_connector_response_headers_as_map(),
state,
raw_connector_request,
connector_response,
})
}
_ => Err(report!(ApplicationErrorResponse::InternalServerError(
ApiError {
sub_code: "INVALID_RESPONSE_TYPE".to_owned(),
error_identifier: 500,
error_message: "Invalid response type received from connector".to_owned(),
error_object: None,
}
))),
},
Err(e) => {
let status = e
.attempt_status
.map(grpc_api_types::payments::PaymentStatus::foreign_from)
.unwrap_or_default();
Ok(PaymentServiceGetResponse {
transaction_id: Some(grpc_api_types::payments::Identifier {
id_type: Some(if let Some(txn_id) = e.connector_transaction_id {
grpc_api_types::payments::identifier::IdType::Id(txn_id)
} else {
grpc_api_types::payments::identifier::IdType::NoResponseIdMarker(())
}),
}),
mandate_reference: None,
status: status as i32,
error_message: Some(e.message),
error_code: Some(e.code),
network_txn_id: None,
response_ref_id: None,
amount: None,
minor_amount: None,
currency: None,
captured_amount: None,
minor_captured_amount: None,
payment_method_type: None,
capture_method: None,
auth_type: None,
created_at: None,
updated_at: None,
authorized_at: None,
captured_at: None,
customer_name: None,
email: None,
connector_customer_id: None,
merchant_order_reference_id: None,
metadata: std::collections::HashMap::new(),
raw_connector_response,
status_code: e.status_code as u32,
response_headers: router_data_v2
.resource_common_data
.get_connector_response_headers_as_map(),
state,
raw_connector_request,
connector_response: None,
})
}
}
}
impl ForeignTryFrom<grpc_api_types::payments::RefundServiceGetRequest> for RefundSyncData {
type Error = ApplicationErrorResponse;
fn foreign_try_from(
value: grpc_api_types::payments::RefundServiceGetRequest,
) -> Result<Self, error_stack::Report<Self::Error>> {
// Extract transaction_id as connector_transaction_id
let connector_transaction_id = value
.transaction_id
.and_then(|id| id.id_type)
.and_then(|id_type| match id_type {
grpc_api_types::payments::identifier::IdType::Id(id) => Some(id),
_ => None,
})
.unwrap_or_default();
Ok(RefundSyncData {
| {
"chunk": 35,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_36 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
browser_info: value
.browser_info
.map(BrowserInformation::foreign_try_from)
.transpose()?,
connector_transaction_id,
connector_refund_id: value.refund_id.clone(),
reason: value.refund_reason.clone(),
refund_status: common_enums::RefundStatus::Pending,
refund_connector_metadata: (!value.refund_metadata.is_empty()).then(|| {
Secret::new(serde_json::Value::Object(
value
.refund_metadata
.into_iter()
.map(|(k, v)| (k, serde_json::Value::String(v)))
.collect(),
))
}),
all_keys_required: None, // Field not available in new proto structure
integrity_object: None,
split_refunds: None,
})
}
}
impl
ForeignTryFrom<(
grpc_api_types::payments::RefundServiceGetRequest,
Connectors,
)> for RefundFlowData
{
type Error = ApplicationErrorResponse;
fn foreign_try_from(
(value, connectors): (
grpc_api_types::payments::RefundServiceGetRequest,
Connectors,
),
) -> Result<Self, error_stack::Report<Self::Error>> {
Ok(RefundFlowData {
status: common_enums::RefundStatus::Pending,
refund_id: None,
connectors,
connector_request_reference_id: extract_connector_request_reference_id(
&value.request_ref_id,
),
raw_connector_response: None,
raw_connector_request: None,
connector_response_headers: None,
})
}
}
impl
ForeignTryFrom<(
grpc_api_types::payments::RefundServiceGetRequest,
Connectors,
&MaskedMetadata,
)> for RefundFlowData
{
type Error = ApplicationErrorResponse;
fn foreign_try_from(
(value, connectors, _metadata): (
grpc_api_types::payments::RefundServiceGetRequest,
Connectors,
&MaskedMetadata,
),
) -> Result<Self, error_stack::Report<Self::Error>> {
Ok(RefundFlowData {
connector_request_reference_id: extract_connector_request_reference_id(
&value.request_ref_id,
),
status: common_enums::RefundStatus::Pending,
refund_id: None,
connectors,
raw_connector_response: None,
raw_connector_request: None,
connector_response_headers: None,
})
}
}
impl
ForeignTryFrom<(
grpc_api_types::payments::PaymentServiceRefundRequest,
Connectors,
)> for RefundFlowData
{
type Error = ApplicationErrorResponse;
fn foreign_try_from(
(value, connectors): (
grpc_api_types::payments::PaymentServiceRefundRequest,
Connectors,
),
) -> Result<Self, error_stack::Report<Self::Error>> {
Ok(RefundFlowData {
status: common_enums::RefundStatus::Pending,
refund_id: Some(value.refund_id),
connectors,
connector_request_reference_id: extract_connector_request_reference_id(
&value.request_ref_id,
),
raw_connector_response: None,
raw_connector_request: None,
connector_response_headers: None,
})
}
}
impl
ForeignTryFrom<(
grpc_api_types::payments::PaymentServiceRefundRequest,
Connectors,
&MaskedMetadata,
)> for RefundFlowData
{
type Error = ApplicationErrorResponse;
fn foreign_try_from(
(value, connectors, _metadata): (
grpc_api_types::payments::PaymentServiceRefundRequest,
Connectors,
&MaskedMetadata,
),
) -> Result<Self, error_stack::Report<Self::Error>> {
Ok(RefundFlowData {
connector_request_reference_id: extract_connector_request_reference_id(
&value.request_ref_id,
),
status: common_enums::RefundStatus::Pending,
refund_id: Some(value.refund_id),
connectors,
raw_connector_response: None,
raw_connector_request: None,
connector_response_headers: None,
})
}
}
| {
"chunk": 36,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_37 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
impl ForeignFrom<common_enums::DisputeStatus> for grpc_api_types::payments::DisputeStatus {
fn foreign_from(status: common_enums::DisputeStatus) -> Self {
match status {
common_enums::DisputeStatus::DisputeOpened => Self::DisputeOpened,
common_enums::DisputeStatus::DisputeAccepted => Self::DisputeAccepted,
common_enums::DisputeStatus::DisputeCancelled => Self::DisputeCancelled,
common_enums::DisputeStatus::DisputeChallenged => Self::DisputeChallenged,
common_enums::DisputeStatus::DisputeExpired => Self::DisputeExpired,
common_enums::DisputeStatus::DisputeLost => Self::DisputeLost,
common_enums::DisputeStatus::DisputeWon => Self::DisputeWon,
}
}
}
impl ForeignFrom<common_utils::Method> for grpc_api_types::payments::HttpMethod {
fn foreign_from(method: common_utils::Method) -> Self {
match method {
common_utils::Method::Post => Self::Post,
common_utils::Method::Get => Self::Get,
common_utils::Method::Put => Self::Put,
common_utils::Method::Delete => Self::Delete,
common_utils::Method::Patch => Self::Post, // Patch is not defined in gRPC, using Post
// as a fallback
}
}
}
pub fn generate_accept_dispute_response(
router_data_v2: RouterDataV2<Accept, DisputeFlowData, AcceptDisputeData, DisputeResponseData>,
) -> Result<AcceptDisputeResponse, error_stack::Report<ApplicationErrorResponse>> {
let dispute_response = router_data_v2.response;
let response_headers = router_data_v2
.resource_common_data
.get_connector_response_headers_as_map();
let raw_connector_request = router_data_v2
.resource_common_data
.get_raw_connector_request();
match dispute_response {
Ok(response) => {
let grpc_status =
grpc_api_types::payments::DisputeStatus::foreign_from(response.dispute_status);
Ok(AcceptDisputeResponse {
dispute_status: grpc_status.into(),
dispute_id: response.connector_dispute_id,
connector_status_code: None,
error_message: None,
error_code: None,
response_ref_id: None,
status_code: response.status_code as u32,
response_headers,
raw_connector_request,
})
}
Err(e) => {
let grpc_dispute_status = grpc_api_types::payments::DisputeStatus::default();
Ok(AcceptDisputeResponse {
dispute_status: grpc_dispute_status as i32,
dispute_id: e.connector_transaction_id.unwrap_or_default(),
connector_status_code: None,
error_message: Some(e.message),
error_code: Some(e.code),
response_ref_id: None,
status_code: e.status_code as u32,
response_headers,
raw_connector_request,
})
}
}
}
impl ForeignTryFrom<(grpc_api_types::payments::AcceptDisputeRequest, Connectors)>
for DisputeFlowData
{
type Error = ApplicationErrorResponse;
fn foreign_try_from(
(value, connectors): (grpc_api_types::payments::AcceptDisputeRequest, Connectors),
) -> Result<Self, error_stack::Report<Self::Error>> {
Ok(DisputeFlowData {
dispute_id: None,
connectors,
connector_dispute_id: value.dispute_id,
defense_reason_code: None,
connector_request_reference_id: extract_connector_request_reference_id(
&value.request_ref_id,
),
raw_connector_response: None,
raw_connector_request: None,
connector_response_headers: None,
})
}
}
impl
ForeignTryFrom<(
grpc_api_types::payments::AcceptDisputeRequest,
Connectors,
&MaskedMetadata,
)> for DisputeFlowData
{
type Error = ApplicationErrorResponse;
fn foreign_try_from(
(value, connectors, _metadata): (
grpc_api_types::payments::AcceptDisputeRequest,
Connectors,
&MaskedMetadata,
),
) -> Result<Self, error_stack::Report<Self::Error>> {
| {
"chunk": 37,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_38 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
Ok(DisputeFlowData {
connector_request_reference_id: extract_connector_request_reference_id(
&value.request_ref_id,
),
dispute_id: None,
connectors,
connector_dispute_id: value.dispute_id,
defense_reason_code: None,
raw_connector_response: None,
raw_connector_request: None,
connector_response_headers: None,
})
}
}
pub fn generate_submit_evidence_response(
router_data_v2: RouterDataV2<
SubmitEvidence,
DisputeFlowData,
SubmitEvidenceData,
DisputeResponseData,
>,
) -> Result<DisputeServiceSubmitEvidenceResponse, error_stack::Report<ApplicationErrorResponse>> {
let dispute_response = router_data_v2.response;
let response_headers = router_data_v2
.resource_common_data
.get_connector_response_headers_as_map();
let raw_connector_request = router_data_v2
.resource_common_data
.get_raw_connector_request();
match dispute_response {
Ok(response) => {
let grpc_status =
grpc_api_types::payments::DisputeStatus::foreign_from(response.dispute_status);
Ok(DisputeServiceSubmitEvidenceResponse {
dispute_status: grpc_status.into(),
dispute_id: Some(response.connector_dispute_id),
submitted_evidence_ids: vec![],
connector_status_code: None,
error_message: None,
error_code: None,
response_ref_id: None,
status_code: response.status_code as u32,
response_headers,
raw_connector_request,
})
}
Err(e) => {
let grpc_attempt_status = e
.attempt_status
.map(grpc_api_types::payments::PaymentStatus::foreign_from)
.unwrap_or_default();
Ok(DisputeServiceSubmitEvidenceResponse {
dispute_status: grpc_attempt_status.into(),
dispute_id: e.connector_transaction_id,
submitted_evidence_ids: vec![],
connector_status_code: None,
error_message: Some(e.message),
error_code: Some(e.code),
response_ref_id: None,
status_code: e.status_code as u32,
response_headers,
raw_connector_request,
})
}
}
}
impl
ForeignTryFrom<(
grpc_api_types::payments::DisputeServiceSubmitEvidenceRequest,
Connectors,
)> for DisputeFlowData
{
type Error = ApplicationErrorResponse;
fn foreign_try_from(
(value, connectors): (
grpc_api_types::payments::DisputeServiceSubmitEvidenceRequest,
Connectors,
),
) -> Result<Self, error_stack::Report<Self::Error>> {
Ok(DisputeFlowData {
dispute_id: None,
connectors,
connector_dispute_id: value.dispute_id,
defense_reason_code: None,
connector_request_reference_id: extract_connector_request_reference_id(
&value.request_ref_id,
),
raw_connector_response: None,
raw_connector_request: None,
connector_response_headers: None,
})
}
}
impl
ForeignTryFrom<(
grpc_api_types::payments::DisputeServiceSubmitEvidenceRequest,
Connectors,
&MaskedMetadata,
)> for DisputeFlowData
{
type Error = ApplicationErrorResponse;
fn foreign_try_from(
(value, connectors, _metadata): (
grpc_api_types::payments::DisputeServiceSubmitEvidenceRequest,
Connectors,
&MaskedMetadata,
),
) -> Result<Self, error_stack::Report<Self::Error>> {
Ok(DisputeFlowData {
connector_request_reference_id: extract_connector_request_reference_id(
&value.request_ref_id,
),
dispute_id: None,
connectors,
connector_dispute_id: value.dispute_id,
defense_reason_code: None,
raw_connector_response: None,
raw_connector_request: None,
connector_response_headers: None,
})
}
}
pub fn generate_refund_sync_response(
| {
"chunk": 38,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_39 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
router_data_v2: RouterDataV2<RSync, RefundFlowData, RefundSyncData, RefundsResponseData>,
) -> Result<RefundResponse, error_stack::Report<ApplicationErrorResponse>> {
let refunds_response = router_data_v2.response;
let raw_connector_response = router_data_v2
.resource_common_data
.get_raw_connector_response();
let raw_connector_request = router_data_v2
.resource_common_data
.get_raw_connector_request();
match refunds_response {
Ok(response) => {
let status = response.refund_status;
let grpc_status = grpc_api_types::payments::RefundStatus::foreign_from(status);
let response_headers = router_data_v2
.resource_common_data
.get_connector_response_headers_as_map();
Ok(RefundResponse {
transaction_id: Some(grpc_api_types::payments::Identifier::default()),
refund_id: response.connector_refund_id.clone(),
status: grpc_status as i32,
response_ref_id: Some(grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(
response.connector_refund_id.clone(),
)),
}),
error_code: None,
error_message: None,
refund_amount: None,
minor_refund_amount: None,
refund_currency: None,
payment_amount: None,
minor_payment_amount: None,
refund_reason: None,
created_at: None,
updated_at: None,
processed_at: None,
customer_name: None,
email: None,
merchant_order_reference_id: None,
metadata: std::collections::HashMap::new(),
refund_metadata: std::collections::HashMap::new(),
raw_connector_response,
status_code: response.status_code as u32,
response_headers,
state: None,
raw_connector_request,
})
}
Err(e) => {
let status = e
.attempt_status
.map(grpc_api_types::payments::PaymentStatus::foreign_from)
.unwrap_or_default();
let response_headers = router_data_v2
.resource_common_data
.get_connector_response_headers_as_map();
Ok(RefundResponse {
transaction_id: Some(
e.connector_transaction_id
.as_ref()
.map(|id| grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(
id.clone(),
)),
})
.unwrap_or_default(),
),
refund_id: String::new(),
status: status as i32,
response_ref_id: e.connector_transaction_id.map(|id| {
grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(id)),
}
}),
error_code: Some(e.code),
error_message: Some(e.message),
refund_amount: None,
minor_refund_amount: None,
refund_currency: None,
payment_amount: None,
minor_payment_amount: None,
refund_reason: None,
created_at: None,
updated_at: None,
processed_at: None,
customer_name: None,
email: None,
raw_connector_response,
merchant_order_reference_id: None,
metadata: std::collections::HashMap::new(),
refund_metadata: std::collections::HashMap::new(),
status_code: e.status_code as u32,
response_headers,
state: None,
raw_connector_request,
})
}
}
}
impl ForeignTryFrom<WebhookDetailsResponse> for PaymentServiceGetResponse {
| {
"chunk": 39,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_40 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
type Error = ApplicationErrorResponse;
fn foreign_try_from(
value: WebhookDetailsResponse,
) -> Result<Self, error_stack::Report<Self::Error>> {
let status = grpc_api_types::payments::PaymentStatus::foreign_from(value.status);
let response_headers = value
.response_headers
.map(|headers| {
headers
.iter()
.filter_map(|(name, value)| {
value
.to_str()
.ok()
.map(|v| (name.to_string(), v.to_string()))
})
.collect()
})
.unwrap_or_default();
let mandate_reference_grpc =
value
.mandate_reference
.map(|m| grpc_api_types::payments::MandateReference {
mandate_id: m.connector_mandate_id,
payment_method_id: m.payment_method_id,
});
Ok(Self {
transaction_id: value
.resource_id
.map(|resource_id| {
grpc_api_types::payments::Identifier::foreign_try_from(resource_id)
})
.transpose()?,
status: status as i32,
mandate_reference: mandate_reference_grpc,
error_code: value.error_code,
error_message: value.error_message,
network_txn_id: value.network_txn_id,
response_ref_id: value.connector_response_reference_id.map(|id| {
grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(id)),
}
}),
amount: None,
minor_amount: None,
currency: None,
captured_amount: value.amount_captured,
minor_captured_amount: value
.minor_amount_captured
.map(|amount_captured| amount_captured.get_amount_as_i64()),
payment_method_type: None,
capture_method: None,
auth_type: None,
created_at: None,
updated_at: None,
authorized_at: None,
captured_at: None,
customer_name: None,
email: None,
connector_customer_id: None,
merchant_order_reference_id: None,
metadata: std::collections::HashMap::new(),
status_code: value.status_code as u32,
raw_connector_response: None,
response_headers,
state: None,
raw_connector_request: None,
connector_response: None,
})
}
}
impl ForeignTryFrom<PaymentServiceVoidRequest> for PaymentVoidData {
type Error = ApplicationErrorResponse;
fn foreign_try_from(
value: PaymentServiceVoidRequest,
) -> Result<Self, error_stack::Report<Self::Error>> {
let amount = Some(common_utils::types::MinorUnit::new(value.amount()));
// If currency is unspecified, send None, otherwise try to convert it
let currency = if value.currency() == grpc_api_types::payments::Currency::Unspecified {
None
} else {
Some(common_enums::Currency::foreign_try_from(value.currency())?)
};
Ok(Self {
browser_info: value
.browser_info
.map(BrowserInformation::foreign_try_from)
.transpose()?,
connector_transaction_id: value
.transaction_id
.and_then(|id| id.id_type)
.and_then(|id_type| match id_type {
grpc_api_types::payments::identifier::IdType::Id(id) => Some(id),
_ => None,
})
.unwrap_or_default(),
connector_metadata: (!value.connector_metadata.is_empty()).then(|| {
Secret::new(serde_json::Value::Object(
value
.connector_metadata
.into_iter()
.map(|(k, v)| (k, serde_json::Value::String(v)))
.collect(),
))
}),
cancellation_reason: value.cancellation_reason,
raw_connector_response: None,
| {
"chunk": 40,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_41 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
integrity_object: None,
amount,
currency,
})
}
}
impl ForeignTryFrom<grpc_api_types::payments::PaymentServiceVoidPostCaptureRequest>
for crate::connector_types::PaymentsCancelPostCaptureData
{
type Error = ApplicationErrorResponse;
fn foreign_try_from(
value: grpc_api_types::payments::PaymentServiceVoidPostCaptureRequest,
) -> Result<Self, error_stack::Report<Self::Error>> {
Ok(Self {
browser_info: value
.browser_info
.map(BrowserInformation::foreign_try_from)
.transpose()?,
connector_transaction_id: value
.transaction_id
.and_then(|id| id.id_type)
.and_then(|id_type| match id_type {
grpc_api_types::payments::identifier::IdType::Id(id) => Some(id),
_ => None,
})
.unwrap_or_default(),
cancellation_reason: value.cancellation_reason,
raw_connector_response: None,
integrity_object: None,
})
}
}
impl
ForeignTryFrom<(
grpc_api_types::payments::PaymentServiceVoidPostCaptureRequest,
Connectors,
&MaskedMetadata,
)> for PaymentFlowData
{
type Error = ApplicationErrorResponse;
fn foreign_try_from(
(value, connectors, metadata): (
grpc_api_types::payments::PaymentServiceVoidPostCaptureRequest,
Connectors,
&MaskedMetadata,
),
) -> Result<Self, error_stack::Report<Self::Error>> {
// For void post capture operations, address information is typically not available or required
// Since this is a PaymentServiceVoidPostCaptureRequest, we use default address values
let address: PaymentAddress = payment_address::PaymentAddress::new(
None, // shipping
None, // billing
None, // payment_method_billing
Some(false), // should_unify_address = false for void post capture operations
);
let merchant_id_from_header = extract_merchant_id_from_metadata(metadata)?;
Ok(Self {
merchant_id: merchant_id_from_header,
payment_id: "IRRELEVANT_PAYMENT_ID".to_string(),
attempt_id: "IRRELEVANT_ATTEMPT_ID".to_string(),
status: common_enums::AttemptStatus::Pending,
payment_method: common_enums::PaymentMethod::Card, //TODO
address,
auth_type: common_enums::AuthenticationType::default(),
connector_request_reference_id: extract_connector_request_reference_id(
&value.request_ref_id,
),
customer_id: None,
connector_customer: None,
description: None,
return_url: None,
connector_meta_data: None,
amount_captured: None,
minor_amount_captured: None,
access_token: None,
session_token: None,
reference_id: None,
payment_method_token: None,
preprocessing_id: None,
connector_api_version: None,
test_mode: None,
connector_http_status_code: None,
external_latency: None,
connectors,
raw_connector_response: None,
raw_connector_request: None,
connector_response_headers: None,
vault_headers: None,
minor_amount_capturable: None,
connector_response: None,
recurring_mandate_payment_data: None,
})
}
}
impl ForeignTryFrom<RefundWebhookDetailsResponse> for RefundResponse {
type Error = ApplicationErrorResponse;
fn foreign_try_from(
value: RefundWebhookDetailsResponse,
) -> Result<Self, error_stack::Report<Self::Error>> {
let status = grpc_api_types::payments::RefundStatus::foreign_from(value.status);
let response_headers = value
.response_headers
.map(|headers| {
headers
.iter()
.filter_map(|(name, value)| {
value
.to_str()
.ok()
.map(|v| (name.to_string(), v.to_string()))
})
| {
"chunk": 41,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_42 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
.collect()
})
.unwrap_or_default();
Ok(Self {
transaction_id: Some(grpc_api_types::payments::Identifier::default()),
refund_id: value.connector_refund_id.unwrap_or_default(),
status: status.into(),
response_ref_id: value.connector_response_reference_id.map(|id| {
grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(id)),
}
}),
error_code: value.error_code,
error_message: value.error_message,
raw_connector_response: None,
refund_amount: None,
minor_refund_amount: None,
refund_currency: None,
payment_amount: None,
minor_payment_amount: None,
refund_reason: None,
created_at: None,
updated_at: None,
processed_at: None,
customer_name: None,
email: None,
merchant_order_reference_id: None,
metadata: std::collections::HashMap::new(),
refund_metadata: std::collections::HashMap::new(),
status_code: value.status_code as u32,
response_headers,
state: None,
raw_connector_request: None,
})
}
}
impl ForeignTryFrom<DisputeWebhookDetailsResponse> for DisputeResponse {
type Error = ApplicationErrorResponse;
fn foreign_try_from(
value: DisputeWebhookDetailsResponse,
) -> Result<Self, error_stack::Report<Self::Error>> {
let grpc_status = grpc_api_types::payments::DisputeStatus::foreign_from(value.status);
let grpc_stage = grpc_api_types::payments::DisputeStage::foreign_from(value.stage);
let response_headers = value
.response_headers
.map(|headers| {
headers
.iter()
.filter_map(|(name, value)| {
value
.to_str()
.ok()
.map(|v| (name.to_string(), v.to_string()))
})
.collect()
})
.unwrap_or_default();
Ok(Self {
dispute_id: Some(value.dispute_id),
transaction_id: None,
dispute_status: grpc_status.into(),
dispute_stage: grpc_stage.into(),
connector_status_code: None,
error_code: None,
error_message: None,
dispute_amount: None,
dispute_currency: None,
dispute_date: None,
service_date: None,
shipping_date: None,
due_date: None,
evidence_documents: vec![],
dispute_reason: None,
dispute_message: value.dispute_message,
response_ref_id: value.connector_response_reference_id.map(|id| {
grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(id)),
}
}),
status_code: value.status_code as u32,
response_headers,
raw_connector_request: None,
})
}
}
impl ForeignTryFrom<grpc_api_types::payments::PaymentServiceRefundRequest> for RefundsData {
type Error = ApplicationErrorResponse;
fn foreign_try_from(
value: grpc_api_types::payments::PaymentServiceRefundRequest,
) -> Result<Self, error_stack::Report<Self::Error>> {
let minor_refund_amount = common_utils::types::MinorUnit::new(value.minor_refund_amount);
let minor_payment_amount = common_utils::types::MinorUnit::new(value.minor_payment_amount);
// Extract transaction_id as connector_transaction_id
let connector_transaction_id = value
.transaction_id
.clone()
.and_then(|id| id.id_type)
.and_then(|id_type| match id_type {
grpc_api_types::payments::identifier::IdType::Id(id) => Some(id),
_ => None,
})
.unwrap_or_default();
Ok(RefundsData {
refund_id: value.refund_id.to_string(),
connector_transaction_id,
| {
"chunk": 42,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_43 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
connector_refund_id: None, // refund_id field is used as refund_id, not connector_refund_id
currency: common_enums::Currency::foreign_try_from(value.currency())?,
payment_amount: value.payment_amount,
reason: value.reason.clone(),
webhook_url: value.webhook_url,
refund_amount: value.refund_amount,
connector_metadata: {
value
.metadata
.get("connector_metadata")
.map(|json_string| {
Ok::<serde_json::Value, error_stack::Report<ApplicationErrorResponse>>(
serde_json::Value::String(json_string.clone()),
)
})
.transpose()? // Should be Option<serde_json::Value>, not Secret
},
refund_connector_metadata: {
value.refund_metadata.get("refund_metadata").map(|json_string| {
Ok::<Secret<serde_json::Value>, error_stack::Report<ApplicationErrorResponse>>(Secret::new(serde_json::Value::String(json_string.clone())))
}).transpose()?
},
minor_payment_amount,
minor_refund_amount,
refund_status: common_enums::RefundStatus::Pending,
merchant_account_id: value.merchant_account_id,
capture_method: value
.capture_method
.map(|cm| {
common_enums::CaptureMethod::foreign_try_from(
grpc_api_types::payments::CaptureMethod::try_from(cm).unwrap_or_default(),
)
})
.transpose()?,
browser_info: value
.browser_info
.map(BrowserInformation::foreign_try_from)
.transpose()?,
integrity_object: None,
split_refunds: None,
})
}
}
impl ForeignTryFrom<grpc_api_types::payments::AcceptDisputeRequest> for AcceptDisputeData {
type Error = ApplicationErrorResponse;
fn foreign_try_from(
value: grpc_api_types::payments::AcceptDisputeRequest,
) -> Result<Self, error_stack::Report<Self::Error>> {
Ok(AcceptDisputeData {
connector_dispute_id: value.dispute_id,
integrity_object: None,
})
}
}
impl ForeignTryFrom<grpc_api_types::payments::DisputeServiceSubmitEvidenceRequest>
for SubmitEvidenceData
{
type Error = ApplicationErrorResponse;
fn foreign_try_from(
value: grpc_api_types::payments::DisputeServiceSubmitEvidenceRequest,
) -> Result<Self, error_stack::Report<Self::Error>> {
// Initialize all fields to None
let mut result = SubmitEvidenceData {
dispute_id: Some(value.dispute_id.clone()),
connector_dispute_id: value.dispute_id,
integrity_object: None,
access_activity_log: None,
billing_address: None,
cancellation_policy: None,
cancellation_policy_file_type: None,
cancellation_policy_provider_file_id: None,
cancellation_policy_disclosure: None,
cancellation_rebuttal: None,
customer_communication: None,
customer_communication_file_type: None,
customer_communication_provider_file_id: None,
customer_email_address: None,
customer_name: None,
customer_purchase_ip: None,
customer_signature: None,
customer_signature_file_type: None,
customer_signature_provider_file_id: None,
product_description: None,
receipt: None,
receipt_file_type: None,
receipt_provider_file_id: None,
refund_policy: None,
refund_policy_file_type: None,
refund_policy_provider_file_id: None,
refund_policy_disclosure: None,
refund_refusal_explanation: None,
service_date: value.service_date.map(|date| date.to_string()),
service_documentation: None,
service_documentation_file_type: None,
service_documentation_provider_file_id: None,
shipping_address: None,
shipping_carrier: None,
| {
"chunk": 43,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_44 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
shipping_date: value.shipping_date.map(|date| date.to_string()),
shipping_documentation: None,
shipping_documentation_file_type: None,
shipping_documentation_provider_file_id: None,
shipping_tracking_number: None,
invoice_showing_distinct_transactions: None,
invoice_showing_distinct_transactions_file_type: None,
invoice_showing_distinct_transactions_provider_file_id: None,
recurring_transaction_agreement: None,
recurring_transaction_agreement_file_type: None,
recurring_transaction_agreement_provider_file_id: None,
uncategorized_file: None,
uncategorized_file_type: None,
uncategorized_file_provider_file_id: None,
uncategorized_text: None,
};
// Extract evidence from evidence_documents array
for document in value.evidence_documents {
let evidence_type =
grpc_api_types::payments::EvidenceType::try_from(document.evidence_type)
.unwrap_or(grpc_api_types::payments::EvidenceType::Unspecified);
match evidence_type {
grpc_api_types::payments::EvidenceType::CancellationPolicy => {
result.cancellation_policy = document.file_content;
result.cancellation_policy_file_type = document.file_mime_type;
result.cancellation_policy_provider_file_id = document.provider_file_id;
}
grpc_api_types::payments::EvidenceType::CustomerCommunication => {
result.customer_communication = document.file_content;
result.customer_communication_file_type = document.file_mime_type;
result.customer_communication_provider_file_id = document.provider_file_id;
}
grpc_api_types::payments::EvidenceType::CustomerSignature => {
result.customer_signature = document.file_content;
result.customer_signature_file_type = document.file_mime_type;
result.customer_signature_provider_file_id = document.provider_file_id;
}
grpc_api_types::payments::EvidenceType::Receipt => {
result.receipt = document.file_content;
result.receipt_file_type = document.file_mime_type;
result.receipt_provider_file_id = document.provider_file_id;
}
grpc_api_types::payments::EvidenceType::RefundPolicy => {
result.refund_policy = document.file_content;
result.refund_policy_file_type = document.file_mime_type;
result.refund_policy_provider_file_id = document.provider_file_id;
}
grpc_api_types::payments::EvidenceType::ServiceDocumentation => {
result.service_documentation = document.file_content;
result.service_documentation_file_type = document.file_mime_type;
result.service_documentation_provider_file_id = document.provider_file_id;
}
grpc_api_types::payments::EvidenceType::ShippingDocumentation => {
result.shipping_documentation = document.file_content;
result.shipping_documentation_file_type = document.file_mime_type;
result.shipping_documentation_provider_file_id = document.provider_file_id;
}
grpc_api_types::payments::EvidenceType::InvoiceShowingDistinctTransactions => {
result.invoice_showing_distinct_transactions = document.file_content;
result.invoice_showing_distinct_transactions_file_type =
document.file_mime_type;
result.invoice_showing_distinct_transactions_provider_file_id =
document.provider_file_id;
}
grpc_api_types::payments::EvidenceType::RecurringTransactionAgreement => {
result.recurring_transaction_agreement = document.file_content;
| {
"chunk": 44,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_45 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
result.recurring_transaction_agreement_file_type = document.file_mime_type;
result.recurring_transaction_agreement_provider_file_id =
document.provider_file_id;
}
grpc_api_types::payments::EvidenceType::UncategorizedFile => {
result.uncategorized_file = document.file_content;
result.uncategorized_file_type = document.file_mime_type;
result.uncategorized_file_provider_file_id = document.provider_file_id;
result.uncategorized_text = document.text_content;
}
grpc_api_types::payments::EvidenceType::Unspecified => {
// Skip unspecified evidence types
}
}
}
Ok(result)
}
}
pub fn generate_refund_response(
router_data_v2: RouterDataV2<Refund, RefundFlowData, RefundsData, RefundsResponseData>,
) -> Result<RefundResponse, error_stack::Report<ApplicationErrorResponse>> {
let refund_response = router_data_v2.response;
let raw_connector_response = router_data_v2
.resource_common_data
.get_raw_connector_response();
// RefundFlowData doesn't have access_token field, so no state to return
let state = None;
let raw_connector_request = router_data_v2
.resource_common_data
.get_raw_connector_request();
match refund_response {
Ok(response) => {
let status = response.refund_status;
let grpc_status = grpc_api_types::payments::RefundStatus::foreign_from(status);
Ok(RefundResponse {
transaction_id: Some(grpc_api_types::payments::Identifier::default()),
refund_id: response.connector_refund_id,
status: grpc_status as i32,
response_ref_id: None,
error_code: None,
error_message: None,
refund_amount: None,
minor_refund_amount: None,
refund_currency: None,
payment_amount: None,
minor_payment_amount: None,
refund_reason: None,
created_at: None,
updated_at: None,
processed_at: None,
customer_name: None,
email: None,
merchant_order_reference_id: None,
raw_connector_response,
metadata: std::collections::HashMap::new(),
refund_metadata: std::collections::HashMap::new(),
status_code: response.status_code as u32,
response_headers: router_data_v2
.resource_common_data
.get_connector_response_headers_as_map(),
state,
raw_connector_request,
})
}
Err(e) => {
let status = e
.attempt_status
.map(grpc_api_types::payments::PaymentStatus::foreign_from)
.unwrap_or_default();
Ok(RefundResponse {
transaction_id: Some(
e.connector_transaction_id
.map(|id| grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(id)),
})
.unwrap_or_default(),
),
refund_id: String::new(),
status: status as i32,
response_ref_id: None,
error_code: Some(e.code),
error_message: Some(e.message),
refund_amount: None,
minor_refund_amount: None,
refund_currency: None,
payment_amount: None,
minor_payment_amount: None,
refund_reason: None,
created_at: None,
updated_at: None,
processed_at: None,
customer_name: None,
email: None,
raw_connector_response,
merchant_order_reference_id: None,
metadata: std::collections::HashMap::new(),
refund_metadata: std::collections::HashMap::new(),
status_code: e.status_code as u32,
| {
"chunk": 45,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_46 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
response_headers: router_data_v2
.resource_common_data
.get_connector_response_headers_as_map(),
state,
raw_connector_request,
})
}
}
}
impl ForeignTryFrom<grpc_api_types::payments::PaymentServiceCaptureRequest>
for PaymentsCaptureData
{
type Error = ApplicationErrorResponse;
fn foreign_try_from(
value: grpc_api_types::payments::PaymentServiceCaptureRequest,
) -> Result<Self, error_stack::Report<Self::Error>> {
let capture_method = Some(common_enums::CaptureMethod::foreign_try_from(
value.capture_method(),
)?);
let connector_transaction_id = ResponseId::ConnectorTransactionId(
value
.transaction_id
.clone()
.and_then(|id| id.id_type)
.and_then(|id_type| match id_type {
grpc_api_types::payments::identifier::IdType::Id(id) => Some(id),
_ => None,
})
.unwrap_or_default(),
);
let multiple_capture_data =
value
.multiple_capture_data
.clone()
.map(|data| MultipleCaptureRequestData {
capture_sequence: data.capture_sequence,
capture_reference: data.capture_reference,
});
let minor_amount = common_utils::types::MinorUnit::new(value.amount_to_capture);
Ok(Self {
amount_to_capture: value.amount_to_capture,
minor_amount_to_capture: minor_amount,
currency: common_enums::Currency::foreign_try_from(value.currency())?,
connector_transaction_id,
multiple_capture_data,
connector_metadata: (!value.connector_metadata.is_empty()).then(|| {
serde_json::Value::Object(
value
.connector_metadata
.into_iter()
.map(|(k, v)| (k, serde_json::Value::String(v)))
.collect(),
)
}),
browser_info: value
.browser_info
.map(BrowserInformation::foreign_try_from)
.transpose()?,
integrity_object: None,
capture_method,
})
}
}
impl
ForeignTryFrom<(
grpc_api_types::payments::PaymentServiceCaptureRequest,
Connectors,
)> for PaymentFlowData
{
type Error = ApplicationErrorResponse;
fn foreign_try_from(
(value, connectors): (
grpc_api_types::payments::PaymentServiceCaptureRequest,
Connectors,
),
) -> Result<Self, error_stack::Report<Self::Error>> {
Ok(Self {
raw_connector_response: None,
merchant_id: common_utils::id_type::MerchantId::default(),
payment_id: "PAYMENT_ID".to_string(),
attempt_id: "ATTEMPT_ID".to_string(),
status: common_enums::AttemptStatus::Pending,
payment_method: common_enums::PaymentMethod::Card, // Default
address: payment_address::PaymentAddress::default(),
auth_type: common_enums::AuthenticationType::default(),
connector_request_reference_id: extract_connector_request_reference_id(
&value.request_ref_id,
),
customer_id: None,
connector_customer: None,
description: None,
return_url: None,
connector_meta_data: None,
amount_captured: None,
minor_amount_captured: None,
minor_amount_capturable: None,
access_token: None,
session_token: None,
reference_id: None,
payment_method_token: None,
preprocessing_id: None,
connector_api_version: None,
test_mode: None,
connector_http_status_code: None,
external_latency: None,
connectors,
raw_connector_request: None,
connector_response_headers: None,
vault_headers: None,
connector_response: None,
recurring_mandate_payment_data: None,
})
}
}
impl
ForeignTryFrom<(
| {
"chunk": 46,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_47 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
grpc_api_types::payments::PaymentServiceCaptureRequest,
Connectors,
&MaskedMetadata,
)> for PaymentFlowData
{
type Error = ApplicationErrorResponse;
fn foreign_try_from(
(value, connectors, metadata): (
grpc_api_types::payments::PaymentServiceCaptureRequest,
Connectors,
&MaskedMetadata,
),
) -> Result<Self, error_stack::Report<Self::Error>> {
let merchant_id_from_header = extract_merchant_id_from_metadata(metadata)?;
Ok(Self {
merchant_id: merchant_id_from_header,
payment_id: "PAYMENT_ID".to_string(),
attempt_id: "ATTEMPT_ID".to_string(),
status: common_enums::AttemptStatus::Pending,
payment_method: common_enums::PaymentMethod::Card, // Default
address: payment_address::PaymentAddress::default(),
auth_type: common_enums::AuthenticationType::default(),
connector_request_reference_id: extract_connector_request_reference_id(
&value.request_ref_id,
),
customer_id: None,
connector_customer: None,
description: None,
return_url: None,
connector_meta_data: None,
amount_captured: None,
minor_amount_captured: None,
minor_amount_capturable: None,
access_token: None,
session_token: None,
reference_id: None,
payment_method_token: None,
preprocessing_id: None,
connector_api_version: None,
test_mode: None,
connector_http_status_code: None,
external_latency: None,
connectors,
raw_connector_response: None,
raw_connector_request: None,
connector_response_headers: None,
vault_headers: None,
connector_response: None,
recurring_mandate_payment_data: None,
})
}
}
pub fn generate_payment_capture_response(
router_data_v2: RouterDataV2<
Capture,
PaymentFlowData,
PaymentsCaptureData,
PaymentsResponseData,
>,
) -> Result<PaymentServiceCaptureResponse, error_stack::Report<ApplicationErrorResponse>> {
let transaction_response = router_data_v2.response;
// Create state if either access token or connector customer is available
let state = if router_data_v2.resource_common_data.access_token.is_some()
|| router_data_v2
.resource_common_data
.connector_customer
.is_some()
{
Some(ConnectorState {
access_token: router_data_v2
.resource_common_data
.access_token
.as_ref()
.map(|token_data| grpc_api_types::payments::AccessToken {
token: token_data.access_token.clone(),
expires_in_seconds: token_data.expires_in,
token_type: token_data.token_type.clone(),
}),
connector_customer_id: router_data_v2
.resource_common_data
.connector_customer
.clone(),
})
} else {
None
};
let raw_connector_request = router_data_v2
.resource_common_data
.get_raw_connector_request();
match transaction_response {
Ok(response) => match response {
PaymentsResponseData::TransactionResponse {
resource_id,
redirection_data: _,
connector_metadata: _,
network_txn_id: _,
connector_response_reference_id,
incremental_authorization_allowed,
mandate_reference,
status_code,
} => {
let status = router_data_v2.resource_common_data.status;
let grpc_status = grpc_api_types::payments::PaymentStatus::foreign_from(status);
let grpc_resource_id =
grpc_api_types::payments::Identifier::foreign_try_from(resource_id)?;
let mandate_reference_grpc =
mandate_reference.map(|m| grpc_api_types::payments::MandateReference {
mandate_id: m.connector_mandate_id,
| {
"chunk": 47,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_48 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
payment_method_id: m.payment_method_id,
});
Ok(PaymentServiceCaptureResponse {
transaction_id: Some(grpc_resource_id),
response_ref_id: connector_response_reference_id.map(|id| {
grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(id)),
}
}),
error_code: None,
error_message: None,
status: grpc_status.into(),
status_code: status_code as u32,
response_headers: router_data_v2
.resource_common_data
.get_connector_response_headers_as_map(),
state,
raw_connector_request,
incremental_authorization_allowed,
mandate_reference: mandate_reference_grpc,
captured_amount: router_data_v2.resource_common_data.amount_captured,
minor_captured_amount: router_data_v2
.resource_common_data
.minor_amount_captured
.map(|amount_captured| amount_captured.get_amount_as_i64()),
})
}
_ => Err(report!(ApplicationErrorResponse::InternalServerError(
ApiError {
sub_code: "INVALID_RESPONSE_TYPE".to_owned(),
error_identifier: 500,
error_message: "Invalid response type received from connector".to_owned(),
error_object: None,
}
))),
},
Err(e) => {
let status = e
.attempt_status
.map(grpc_api_types::payments::PaymentStatus::foreign_from)
.unwrap_or_default();
Ok(PaymentServiceCaptureResponse {
transaction_id: Some(grpc_api_types::payments::Identifier {
id_type: Some(
grpc_api_types::payments::identifier::IdType::NoResponseIdMarker(()),
),
}),
response_ref_id: e.connector_transaction_id.map(|id| {
grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(id)),
}
}),
status: status.into(),
error_message: Some(e.message),
error_code: Some(e.code),
status_code: e.status_code as u32,
response_headers: router_data_v2
.resource_common_data
.get_connector_response_headers_as_map(),
state,
raw_connector_request,
incremental_authorization_allowed: None,
mandate_reference: None,
captured_amount: None,
minor_captured_amount: None,
})
}
}
}
impl
ForeignTryFrom<(
PaymentServiceRegisterRequest,
Connectors,
consts::Env,
&MaskedMetadata,
)> for PaymentFlowData
{
type Error = ApplicationErrorResponse;
fn foreign_try_from(
(value, connectors, environment, metadata): (
PaymentServiceRegisterRequest,
Connectors,
consts::Env,
&MaskedMetadata,
),
) -> Result<Self, error_stack::Report<Self::Error>> {
let address = match value.address {
Some(address) => payment_address::PaymentAddress::foreign_try_from(address)?,
None => {
return Err(ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "INVALID_ADDRESS".to_owned(),
error_identifier: 400,
error_message: "Address is required".to_owned(),
error_object: None,
}))?
}
};
let test_mode = match environment {
consts::Env::Development => Some(true),
consts::Env::Production => Some(false),
_ => Some(true),
};
| {
"chunk": 48,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_49 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
let merchant_id_from_header = extract_merchant_id_from_metadata(metadata)?;
Ok(Self {
merchant_id: merchant_id_from_header,
payment_id: "IRRELEVANT_PAYMENT_ID".to_string(),
attempt_id: "IRRELEVANT_ATTEMPT_ID".to_string(),
status: common_enums::AttemptStatus::Pending,
payment_method: common_enums::PaymentMethod::Card, //TODO
address,
auth_type: common_enums::AuthenticationType::default(),
connector_request_reference_id: extract_connector_request_reference_id(
&value.request_ref_id,
),
customer_id: value
.customer_id
.clone()
.map(|customer_id| CustomerId::try_from(Cow::from(customer_id)))
.transpose()
.change_context(ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "INVALID_CUSTOMER_ID".to_owned(),
error_identifier: 400,
error_message: "Failed to parse Customer Id".to_owned(),
error_object: None,
}))?,
connector_customer: value.connector_customer_id,
description: value.metadata.get("description").cloned(),
return_url: None,
connector_meta_data: None,
amount_captured: None,
minor_amount_captured: None,
minor_amount_capturable: None,
access_token: None,
session_token: None,
reference_id: None,
payment_method_token: None,
preprocessing_id: None,
connector_api_version: None,
test_mode,
connector_http_status_code: None,
external_latency: None,
connectors,
raw_connector_response: None,
raw_connector_request: None,
connector_response_headers: None,
vault_headers: None,
connector_response: None,
recurring_mandate_payment_data: None,
})
}
}
impl ForeignTryFrom<PaymentServiceRegisterRequest> for SetupMandateRequestData<DefaultPCIHolder> {
type Error = ApplicationErrorResponse;
fn foreign_try_from(
value: PaymentServiceRegisterRequest,
) -> Result<Self, error_stack::Report<Self::Error>> {
let email: Option<Email> = match value.email {
Some(ref email_str) => {
Some(Email::try_from(email_str.clone().expose()).map_err(|_| {
error_stack::Report::new(ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "INVALID_EMAIL_FORMAT".to_owned(),
error_identifier: 400,
error_message: "Invalid email".to_owned(),
error_object: None,
}))
})?)
}
None => None,
};
let customer_acceptance = value.customer_acceptance.clone().ok_or_else(|| {
error_stack::Report::new(ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "MISSING_CUSTOMER_ACCEPTANCE".to_owned(),
error_identifier: 400,
error_message: "Customer acceptance is missing".to_owned(),
error_object: None,
}))
})?;
let setup_future_usage = value.setup_future_usage();
let setup_mandate_details = MandateData {
update_mandate_id: None,
customer_acceptance: Some(mandates::CustomerAcceptance::foreign_try_from(
customer_acceptance.clone(),
)?),
mandate_type: None,
};
Ok(Self {
currency: common_enums::Currency::foreign_try_from(value.currency())?,
payment_method_data: PaymentMethodData::foreign_try_from(
value.payment_method.ok_or_else(|| {
ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "INVALID_PAYMENT_METHOD_DATA".to_owned(),
error_identifier: 400,
error_message: "Payment method data is required".to_owned(),
error_object: None,
})
})?,
)?,
amount: Some(0),
| {
"chunk": 49,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_50 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
confirm: true,
statement_descriptor_suffix: None,
customer_acceptance: Some(mandates::CustomerAcceptance::foreign_try_from(
customer_acceptance.clone(),
)?),
mandate_id: None,
setup_future_usage: Some(common_enums::FutureUsage::foreign_try_from(
setup_future_usage,
)?),
off_session: value.off_session,
setup_mandate_details: Some(setup_mandate_details),
router_return_url: value.return_url.clone(),
webhook_url: value.webhook_url,
browser_info: value
.browser_info
.map(BrowserInformation::foreign_try_from)
.transpose()?,
email,
customer_name: None,
return_url: value.return_url.clone(),
payment_method_type: None,
request_incremental_authorization: false,
metadata: if value.metadata.is_empty() {
None
} else {
Some(serde_json::Value::Object(
value
.metadata
.into_iter()
.map(|(k, v)| (k, serde_json::Value::String(v)))
.collect(),
))
},
complete_authorize_url: None,
capture_method: None,
integrity_object: None,
minor_amount: Some(common_utils::types::MinorUnit::new(0)),
shipping_cost: None,
customer_id: value
.customer_id
.clone()
.map(|customer_id| CustomerId::try_from(Cow::from(customer_id)))
.transpose()
.change_context(ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "INVALID_CUSTOMER_ID".to_owned(),
error_identifier: 400,
error_message: "Failed to parse Customer Id".to_owned(),
error_object: None,
}))?,
statement_descriptor: None,
merchant_order_reference_id: None,
merchant_account_metadata: (!value.merchant_account_metadata.is_empty())
.then(|| {
serde_json::to_value(&value.merchant_account_metadata)
.map(common_utils::pii::SecretSerdeValue::new)
.map_err(|_| {
error_stack::Report::new(ApplicationErrorResponse::InternalServerError(
crate::errors::ApiError {
sub_code: "SERDE_JSON_ERROR".to_owned(),
error_identifier: 500,
error_message: "Failed to serialize merchant_account_metadata"
.to_owned(),
error_object: None,
},
))
})
})
.transpose()?,
})
}
}
impl ForeignTryFrom<grpc_api_types::payments::CustomerAcceptance> for mandates::CustomerAcceptance {
type Error = ApplicationErrorResponse;
fn foreign_try_from(
_value: grpc_api_types::payments::CustomerAcceptance,
) -> Result<Self, error_stack::Report<Self::Error>> {
Ok(mandates::CustomerAcceptance {
acceptance_type: mandates::AcceptanceType::Offline,
accepted_at: None,
online: None,
})
}
}
impl ForeignTryFrom<grpc_api_types::payments::SetupMandateDetails> for mandates::MandateData {
type Error = ApplicationErrorResponse;
fn foreign_try_from(
value: grpc_api_types::payments::SetupMandateDetails,
) -> Result<Self, error_stack::Report<Self::Error>> {
Ok(Self {
update_mandate_id: value.update_mandate_id,
customer_acceptance: value
.customer_acceptance
.map(mandates::CustomerAcceptance::foreign_try_from)
.transpose()?,
mandate_type: None,
})
}
}
impl ForeignTryFrom<grpc_api_types::payments::FutureUsage> for common_enums::FutureUsage {
type Error = ApplicationErrorResponse;
fn foreign_try_from(
| {
"chunk": 50,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_51 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
value: grpc_api_types::payments::FutureUsage,
) -> Result<Self, error_stack::Report<Self::Error>> {
match value {
grpc_api_types::payments::FutureUsage::OffSession => {
Ok(common_enums::FutureUsage::OffSession)
}
grpc_api_types::payments::FutureUsage::OnSession => {
Ok(common_enums::FutureUsage::OnSession)
}
grpc_api_types::payments::FutureUsage::Unspecified => {
Err(ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "UNSPECIFIED_FUTURE_USAGE".to_owned(),
error_identifier: 401,
error_message: "Future usage must be specified".to_owned(),
error_object: None,
})
.into())
}
}
}
}
pub fn generate_setup_mandate_response<T: PaymentMethodDataTypes>(
router_data_v2: RouterDataV2<
SetupMandate,
PaymentFlowData,
SetupMandateRequestData<T>,
PaymentsResponseData,
>,
) -> Result<PaymentServiceRegisterResponse, error_stack::Report<ApplicationErrorResponse>> {
let transaction_response = router_data_v2.response;
let status = router_data_v2.resource_common_data.status;
let grpc_status = grpc_api_types::payments::PaymentStatus::foreign_from(status);
// Create state if either access token or connector customer is available
let state = if router_data_v2.resource_common_data.access_token.is_some()
|| router_data_v2
.resource_common_data
.connector_customer
.is_some()
{
Some(ConnectorState {
access_token: router_data_v2
.resource_common_data
.access_token
.as_ref()
.map(|token_data| grpc_api_types::payments::AccessToken {
token: token_data.access_token.clone(),
expires_in_seconds: token_data.expires_in,
token_type: token_data.token_type.clone(),
}),
connector_customer_id: router_data_v2
.resource_common_data
.connector_customer
.clone(),
})
} else {
None
};
let raw_connector_request = router_data_v2
.resource_common_data
.get_raw_connector_request();
let connector_response = router_data_v2
.resource_common_data
.connector_response
.as_ref()
.map(|connector_response_data| {
grpc_api_types::payments::ConnectorResponseData::foreign_try_from(
connector_response_data.clone(),
)
})
.transpose()?;
let response = match transaction_response {
Ok(response) => match response {
PaymentsResponseData::TransactionResponse {
resource_id,
redirection_data,
connector_metadata: _,
network_txn_id,
connector_response_reference_id,
incremental_authorization_allowed,
mandate_reference,
status_code,
} => {
PaymentServiceRegisterResponse {
registration_id: Some(grpc_api_types::payments::Identifier::foreign_try_from(resource_id)?),
redirection_data: redirection_data.map(
|form| {
match *form {
router_response_types::RedirectForm::Form { endpoint, method, form_fields: _ } => {
Ok::<grpc_api_types::payments::RedirectForm, ApplicationErrorResponse>(grpc_api_types::payments::RedirectForm {
form_type: Some(grpc_api_types::payments::redirect_form::FormType::Form(
grpc_api_types::payments::FormData {
endpoint,
method: match method {
Method::Get => 1,
Method::Post => 2,
Method::Put => 3,
| {
"chunk": 51,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_52 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
Method::Delete => 4,
_ => 0,
},
form_fields: HashMap::default(), //TODO
}
))
})
},
router_response_types::RedirectForm::Html { html_data } => {
Ok(grpc_api_types::payments::RedirectForm {
form_type: Some(grpc_api_types::payments::redirect_form::FormType::Html(
grpc_api_types::payments::HtmlData {
html_data,
}
))
})
},
_ => Err(
ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "INVALID_RESPONSE".to_owned(),
error_identifier: 400,
error_message: "Invalid response from connector".to_owned(),
error_object: None,
}))?,
}
}
).transpose()?,
network_txn_id,
response_ref_id: connector_response_reference_id.map(|id| grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(id)),
}),
status: grpc_status as i32,
mandate_reference: Some(grpc_api_types::payments::MandateReference {
mandate_id: mandate_reference.clone().and_then(|m| m.connector_mandate_id),
payment_method_id: mandate_reference.and_then(|m| m.payment_method_id),
}),
incremental_authorization_allowed,
error_message: None,
error_code: None,
status_code: status_code as u32,
response_headers: router_data_v2
.resource_common_data
.get_connector_response_headers_as_map(),
state,
raw_connector_request,
connector_response,
}
}
_ => Err(ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "INVALID_RESPONSE".to_owned(),
error_identifier: 400,
error_message: "Invalid response from connector".to_owned(),
error_object: None,
}))?,
},
Err(err) => PaymentServiceRegisterResponse {
registration_id: Some(grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::NoResponseIdMarker(())),
}),
redirection_data: None,
network_txn_id: None,
response_ref_id: err.connector_transaction_id.map(|id| {
grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(id)),
}
}),
status: grpc_status as i32,
mandate_reference: None,
incremental_authorization_allowed: None,
error_message: Some(err.message),
error_code: Some(err.code),
status_code: err.status_code as u32,
response_headers: router_data_v2
.resource_common_data
.get_connector_response_headers_as_map(),
state,
raw_connector_request,
connector_response: None,
},
};
Ok(response)
}
impl ForeignTryFrom<(DisputeDefendRequest, Connectors)> for DisputeFlowData {
type Error = ApplicationErrorResponse;
fn foreign_try_from(
| {
"chunk": 52,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_53 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
(value, connectors): (DisputeDefendRequest, Connectors),
) -> Result<Self, error_stack::Report<Self::Error>> {
Ok(DisputeFlowData {
dispute_id: Some(value.dispute_id.clone()),
connectors,
connector_dispute_id: value.dispute_id,
defense_reason_code: Some(value.reason_code.unwrap_or_default()),
connector_request_reference_id: extract_connector_request_reference_id(
&value.request_ref_id,
),
raw_connector_response: None,
raw_connector_request: None,
connector_response_headers: None,
})
}
}
impl ForeignTryFrom<(DisputeDefendRequest, Connectors, &MaskedMetadata)> for DisputeFlowData {
type Error = ApplicationErrorResponse;
fn foreign_try_from(
(value, connectors, _metadata): (DisputeDefendRequest, Connectors, &MaskedMetadata),
) -> Result<Self, error_stack::Report<Self::Error>> {
Ok(DisputeFlowData {
connector_request_reference_id: extract_connector_request_reference_id(
&value.request_ref_id,
),
dispute_id: Some(value.dispute_id.clone()),
connectors,
connector_dispute_id: value.dispute_id,
defense_reason_code: Some(value.reason_code.unwrap_or_default()),
raw_connector_response: None,
raw_connector_request: None,
connector_response_headers: None,
})
}
}
impl ForeignTryFrom<DisputeDefendRequest> for DisputeDefendData {
type Error = ApplicationErrorResponse;
fn foreign_try_from(
value: DisputeDefendRequest,
) -> Result<Self, error_stack::Report<Self::Error>> {
let connector_dispute_id = value.dispute_id;
Ok(Self {
dispute_id: connector_dispute_id.clone(),
connector_dispute_id,
defense_reason_code: value.reason_code.unwrap_or_default(),
integrity_object: None,
})
}
}
pub fn generate_defend_dispute_response(
router_data_v2: RouterDataV2<
DefendDispute,
DisputeFlowData,
DisputeDefendData,
DisputeResponseData,
>,
) -> Result<DisputeDefendResponse, error_stack::Report<ApplicationErrorResponse>> {
let defend_dispute_response = router_data_v2.response;
let raw_connector_request = router_data_v2
.resource_common_data
.get_raw_connector_request();
match defend_dispute_response {
Ok(response) => Ok(DisputeDefendResponse {
dispute_id: response.connector_dispute_id,
dispute_status: response.dispute_status as i32,
connector_status_code: None,
error_message: None,
error_code: None,
response_ref_id: None,
status_code: response.status_code as u32,
response_headers: router_data_v2
.resource_common_data
.get_connector_response_headers_as_map(),
raw_connector_request,
}),
Err(e) => Ok(DisputeDefendResponse {
dispute_id: e
.connector_transaction_id
.unwrap_or_else(|| NO_ERROR_CODE.to_string()),
dispute_status: common_enums::DisputeStatus::DisputeLost as i32,
connector_status_code: None,
error_message: Some(e.message),
error_code: Some(e.code),
response_ref_id: None,
status_code: e.status_code as u32,
response_headers: router_data_v2
.resource_common_data
.get_connector_response_headers_as_map(),
raw_connector_request,
}),
}
}
pub fn generate_session_token_response(
router_data_v2: RouterDataV2<
CreateSessionToken,
PaymentFlowData,
SessionTokenRequestData,
SessionTokenResponseData,
>,
) -> Result<String, error_stack::Report<ApplicationErrorResponse>> {
let session_token_response = router_data_v2.response;
match session_token_response {
Ok(response) => Ok(response.session_token),
Err(e) => Err(report!(ApplicationErrorResponse::InternalServerError(
ApiError {
sub_code: "SESSION_TOKEN_ERROR".to_string(),
error_identifier: 500,
| {
"chunk": 53,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_54 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
error_message: format!("Session token creation failed: {}", e.message),
error_object: None,
}
))),
}
}
pub fn generate_payment_method_token_response<T: PaymentMethodDataTypes>(
router_data_v2: RouterDataV2<
PaymentMethodToken,
PaymentFlowData,
PaymentMethodTokenizationData<T>,
PaymentMethodTokenResponse,
>,
) -> Result<String, error_stack::Report<ApplicationErrorResponse>> {
let payment_method_token_response = router_data_v2.response;
match payment_method_token_response {
Ok(response) => Ok(response.token),
Err(e) => Err(report!(ApplicationErrorResponse::InternalServerError(
ApiError {
sub_code: "PAYMENT_METHOD_TOKEN_ERROR".to_string(),
error_identifier: 500,
error_message: format!("Payment method token creation failed: {}", e.message),
error_object: None,
}
))),
}
}
#[derive(Debug, Clone, ToSchema, Serialize)]
pub struct CardSpecificFeatures {
/// Indicates whether three_ds card payments are supported
// #[schema(value_type = FeatureStatus)]
pub three_ds: FeatureStatus,
/// Indicates whether non three_ds card payments are supported
// #[schema(value_type = FeatureStatus)]
pub no_three_ds: FeatureStatus,
/// List of supported card networks
// #[schema(value_type = Vec<CardNetwork>)]
pub supported_card_networks: Vec<CardNetwork>,
}
#[derive(Debug, Clone, ToSchema, Serialize)]
#[serde(untagged)]
pub enum PaymentMethodSpecificFeatures {
/// Card specific features
Card(CardSpecificFeatures),
}
/// Represents details of a payment method.
#[derive(Debug, Clone)]
pub struct PaymentMethodDetails {
/// Indicates whether mandates are supported by this payment method.
pub mandates: FeatureStatus,
/// Indicates whether refund is supported by this payment method.
pub refunds: FeatureStatus,
/// List of supported capture methods
pub supported_capture_methods: Vec<CaptureMethod>,
/// Payment method specific features
pub specific_features: Option<PaymentMethodSpecificFeatures>,
}
/// The status of the feature
#[derive(
Clone,
Copy,
Debug,
Eq,
PartialEq,
serde::Deserialize,
serde::Serialize,
strum::Display,
ToSchema,
)]
#[strum(serialize_all = "snake_case")]
#[serde(rename_all = "snake_case")]
pub enum FeatureStatus {
NotSupported,
Supported,
}
pub type PaymentMethodTypeMetadata = HashMap<PaymentMethodType, PaymentMethodDetails>;
pub type SupportedPaymentMethods = HashMap<PaymentMethod, PaymentMethodTypeMetadata>;
#[derive(Debug, Clone)]
pub struct ConnectorInfo {
/// Display name of the Connector
pub display_name: &'static str,
/// Description of the connector.
pub description: &'static str,
/// Connector Type
pub connector_type: PaymentConnectorCategory,
}
/// Connector Access Method
#[derive(
Clone,
Copy,
Debug,
Eq,
Hash,
PartialEq,
serde::Deserialize,
serde::Serialize,
strum::Display,
ToSchema,
)]
#[strum(serialize_all = "snake_case")]
#[serde(rename_all = "snake_case")]
pub enum PaymentConnectorCategory {
PaymentGateway,
AlternativePaymentMethod,
BankAcquirer,
}
#[derive(Debug, strum::Display, Eq, PartialEq, Hash)]
pub enum PaymentMethodDataType {
Card,
Bluecode,
Knet,
Benefit,
MomoAtm,
CardRedirect,
AliPayQr,
AliPayRedirect,
AliPayHkRedirect,
AmazonPayRedirect,
MomoRedirect,
KakaoPayRedirect,
GoPayRedirect,
GcashRedirect,
ApplePay,
ApplePayRedirect,
ApplePayThirdPartySdk,
DanaRedirect,
DuitNow,
GooglePay,
GooglePayRedirect,
GooglePayThirdPartySdk,
MbWayRedirect,
MobilePayRedirect,
PaypalRedirect,
PaypalSdk,
Paze,
SamsungPay,
TwintRedirect,
VippsRedirect,
TouchNGoRedirect,
WeChatPayRedirect,
WeChatPayQr,
CashappQr,
SwishQr,
KlarnaRedirect,
KlarnaSdk,
AffirmRedirect,
AfterpayClearpayRedirect,
PayBrightRedirect,
WalleyRedirect,
AlmaRedirect,
AtomeRedirect,
BancontactCard,
Bizum,
Blik,
Eft,
Eps,
Giropay,
Ideal,
Interac,
LocalBankRedirect,
OnlineBankingCzechRepublic,
OnlineBankingFinland,
OnlineBankingPoland,
OnlineBankingSlovakia,
OpenBankingUk,
Przelewy24,
Sofort,
Trustly,
OnlineBankingFpx,
| {
"chunk": 54,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_55 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
OnlineBankingThailand,
AchBankDebit,
SepaBankDebit,
BecsBankDebit,
BacsBankDebit,
AchBankTransfer,
SepaBankTransfer,
BacsBankTransfer,
MultibancoBankTransfer,
PermataBankTransfer,
BcaBankTransfer,
BniVaBankTransfer,
BriVaBankTransfer,
CimbVaBankTransfer,
DanamonVaBankTransfer,
MandiriVaBankTransfer,
Pix,
Pse,
Crypto,
MandatePayment,
Reward,
Upi,
Boleto,
Efecty,
PagoEfectivo,
RedCompra,
RedPagos,
Alfamart,
Indomaret,
Oxxo,
SevenEleven,
Lawson,
MiniStop,
FamilyMart,
Seicomart,
PayEasy,
Givex,
PaySafeCar,
CardToken,
LocalBankTransfer,
Mifinity,
Fps,
PromptPay,
VietQr,
OpenBanking,
NetworkToken,
NetworkTransactionIdAndCardDetails,
DirectCarrierBilling,
InstantBankTransfer,
InstantBankTransferPoland,
InstantBankTransferFinland,
CardDetailsForNetworkTransactionId,
RevolutPay,
}
impl ForeignTryFrom<String> for hyperswitch_masking::Secret<time::Date> {
type Error = ApplicationErrorResponse;
fn foreign_try_from(date_string: String) -> Result<Self, error_stack::Report<Self::Error>> {
let date = time::Date::parse(
&date_string,
&time::format_description::well_known::Iso8601::DATE,
)
.map_err(|err| {
tracing::error!("Failed to parse date string: {}", err);
ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "INVALID_DATE_FORMAT".to_owned(),
error_identifier: 400,
error_message: "Invalid date format".to_owned(),
error_object: None,
})
})?;
Ok(hyperswitch_masking::Secret::new(date))
}
}
impl ForeignTryFrom<grpc_api_types::payments::BrowserInformation> for BrowserInformation {
type Error = ApplicationErrorResponse;
fn foreign_try_from(
value: grpc_api_types::payments::BrowserInformation,
) -> Result<Self, error_stack::Report<Self::Error>> {
Ok(Self {
color_depth: value.color_depth.map(|cd| cd as u8),
java_enabled: value.java_enabled,
java_script_enabled: value.java_script_enabled,
language: value.language,
screen_height: value.screen_height,
screen_width: value.screen_width,
time_zone: value.time_zone_offset_minutes,
ip_address: value.ip_address.and_then(|ip| ip.parse().ok()),
accept_header: value.accept_header,
user_agent: value.user_agent,
os_type: value.os_type,
os_version: value.os_version,
device_model: value.device_model,
accept_language: value.accept_language,
referer: value.referer,
})
}
}
impl ForeignTryFrom<grpc_api_types::payments::PaymentServiceAuthorizeRequest>
for SessionTokenRequestData
{
type Error = ApplicationErrorResponse;
fn foreign_try_from(
value: grpc_api_types::payments::PaymentServiceAuthorizeRequest,
) -> Result<Self, error_stack::Report<Self::Error>> {
let currency = common_enums::Currency::foreign_try_from(value.currency())?;
Ok(Self {
amount: common_utils::types::MinorUnit::new(value.minor_amount),
currency,
})
}
}
impl ForeignTryFrom<grpc_api_types::payments::PaymentServiceAuthorizeRequest>
for AccessTokenRequestData
{
type Error = ApplicationErrorResponse;
fn foreign_try_from(
_value: grpc_api_types::payments::PaymentServiceAuthorizeRequest,
) -> Result<Self, error_stack::Report<Self::Error>> {
Ok(Self {
grant_type: "client_credentials".to_string(),
})
}
}
// Generic implementation for access token request from connector auth
impl ForeignTryFrom<&ConnectorAuthType> for AccessTokenRequestData {
type Error = ApplicationErrorResponse;
fn foreign_try_from(
_auth_type: &ConnectorAuthType,
) -> Result<Self, error_stack::Report<Self::Error>> {
// Default to client_credentials grant type for OAuth
// Connectors can override this with their own specific implementations
Ok(Self {
grant_type: "client_credentials".to_string(),
})
}
}
impl ForeignTryFrom<grpc_api_types::payments::PaymentServiceAuthorizeRequest>
for ConnectorCustomerData
{
| {
"chunk": 55,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_56 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
type Error = ApplicationErrorResponse;
fn foreign_try_from(
value: grpc_api_types::payments::PaymentServiceAuthorizeRequest,
) -> Result<Self, error_stack::Report<Self::Error>> {
let email = value
.email
.and_then(|email_str| Email::try_from(email_str.expose()).ok());
Ok(Self {
customer_id: value.customer_id.map(Secret::new),
email: email.map(Secret::new),
name: value.customer_name.map(Secret::new),
description: None,
split_payments: None,
phone: None,
preprocessing_id: None,
})
}
}
impl ForeignTryFrom<grpc_api_types::payments::PaymentServiceRegisterRequest>
for ConnectorCustomerData
{
type Error = ApplicationErrorResponse;
fn foreign_try_from(
value: grpc_api_types::payments::PaymentServiceRegisterRequest,
) -> Result<Self, error_stack::Report<Self::Error>> {
let email = value
.email
.and_then(|email_str| Email::try_from(email_str.expose()).ok());
Ok(Self {
customer_id: value.customer_id.map(Secret::new),
email: email.map(Secret::new),
name: value.customer_name.map(Secret::new),
description: None,
split_payments: None,
phone: None,
preprocessing_id: None,
})
}
}
impl<
T: PaymentMethodDataTypes
+ Default
+ Debug
+ Send
+ Eq
+ PartialEq
+ serde::Serialize
+ serde::de::DeserializeOwned
+ Clone
+ CardConversionHelper<T>,
> ForeignTryFrom<grpc_api_types::payments::PaymentServiceAuthorizeRequest>
for PaymentMethodTokenizationData<T>
{
type Error = ApplicationErrorResponse;
fn foreign_try_from(
value: grpc_api_types::payments::PaymentServiceAuthorizeRequest,
) -> Result<Self, error_stack::Report<Self::Error>> {
let currency = common_enums::Currency::foreign_try_from(value.currency())?;
let customer_acceptance = value.customer_acceptance.clone();
Ok(Self {
amount: common_utils::types::MinorUnit::new(value.amount),
currency,
payment_method_data: PaymentMethodData::<T>::foreign_try_from(
value.payment_method.ok_or_else(|| {
ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "INVALID_PAYMENT_METHOD_DATA".to_owned(),
error_identifier: 400,
error_message: "Payment method data is required".to_owned(),
error_object: None,
})
})?,
)?,
browser_info: value
.browser_info
.map(BrowserInformation::foreign_try_from)
.transpose()?,
customer_acceptance: customer_acceptance
.map(mandates::CustomerAcceptance::foreign_try_from)
.transpose()?,
setup_future_usage: value
.setup_future_usage
.map(|fu| {
common_enums::FutureUsage::foreign_try_from(
grpc_api_types::payments::FutureUsage::try_from(fu).unwrap_or_default(),
)
})
.transpose()?,
mandate_id: None,
setup_mandate_details: None,
integrity_object: None,
})
}
}
impl ForeignTryFrom<grpc_api_types::payments::PaymentServiceRepeatEverythingRequest>
for RepeatPaymentData
{
type Error = ApplicationErrorResponse;
fn foreign_try_from(
value: grpc_api_types::payments::PaymentServiceRepeatEverythingRequest,
) -> Result<Self, error_stack::Report<Self::Error>> {
// Extract values first to avoid partial move
let amount = value.amount;
let minor_amount = value.minor_amount;
let currency = value.currency();
let payment_method_type =
<Option<PaymentMethodType>>::foreign_try_from(value.payment_method_type())?;
let capture_method = value.capture_method();
let merchant_order_reference_id = value.merchant_order_reference_id;
let webhook_url = value.webhook_url;
| {
"chunk": 56,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_57 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
// Extract mandate reference
let mandate_reference = value.mandate_reference.clone().ok_or_else(|| {
ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "MISSING_MANDATE_REFERENCE".to_owned(),
error_identifier: 400,
error_message: "Mandate reference is required for repeat payments".to_owned(),
error_object: None,
})
})?;
let email: Option<Email> = match value.email {
Some(ref email_str) => {
Some(Email::try_from(email_str.clone().expose()).map_err(|_| {
error_stack::Report::new(ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "INVALID_EMAIL_FORMAT".to_owned(),
error_identifier: 400,
error_message: "Invalid email".to_owned(),
error_object: None,
}))
})?)
}
None => None,
};
// Convert mandate reference to domain type
let mandate_ref = match mandate_reference.mandate_id {
Some(id) => MandateReferenceId::ConnectorMandateId(ConnectorMandateReferenceId::new(
Some(id),
mandate_reference.payment_method_id,
None,
None,
)),
None => {
return Err(ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "INVALID_MANDATE_REFERENCE".to_owned(),
error_identifier: 400,
error_message: "Mandate ID is required".to_owned(),
error_object: None,
})
.into())
}
};
Ok(Self {
mandate_reference: mandate_ref,
amount,
minor_amount: common_utils::types::MinorUnit::new(minor_amount),
currency: common_enums::Currency::foreign_try_from(currency)?,
merchant_order_reference_id,
metadata: (!value.metadata.is_empty()).then(|| {
Secret::new(serde_json::Value::Object(
value
.metadata
.into_iter()
.map(|(k, v)| (k, serde_json::Value::String(v)))
.collect(),
))
}),
webhook_url,
router_return_url: value.return_url,
integrity_object: None,
capture_method: Some(common_enums::CaptureMethod::foreign_try_from(
capture_method,
)?),
email,
browser_info: value
.browser_info
.map(BrowserInformation::foreign_try_from)
.transpose()?,
payment_method_type,
merchant_account_metadata: (!value.merchant_account_metadata.is_empty())
.then(|| {
serde_json::to_value(&value.merchant_account_metadata)
.map(common_utils::pii::SecretSerdeValue::new)
.map_err(|_| {
error_stack::Report::new(ApplicationErrorResponse::InternalServerError(
crate::errors::ApiError {
sub_code: "SERDE_JSON_ERROR".to_owned(),
error_identifier: 500,
error_message: "Failed to serialize merchant_account_metadata"
.to_owned(),
error_object: None,
},
))
})
})
.transpose()?,
off_session: value.off_session,
split_payments: None,
recurring_mandate_payment_data: value.recurring_mandate_payment_data.map(|v| {
RecurringMandatePaymentData {
payment_method_type: None,
original_payment_authorized_amount: v.original_payment_authorized_amount,
original_payment_authorized_currency: Some(
common_enums::Currency::foreign_try_from(
| {
"chunk": 57,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_58 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
v.original_payment_authorized_currency(),
)
.unwrap_or_default(),
),
mandate_metadata: None,
}
}),
})
}
}
impl
ForeignTryFrom<(
grpc_api_types::payments::PaymentServiceRepeatEverythingRequest,
Connectors,
)> for PaymentFlowData
{
type Error = ApplicationErrorResponse;
fn foreign_try_from(
(value, connectors): (
grpc_api_types::payments::PaymentServiceRepeatEverythingRequest,
Connectors,
),
) -> Result<Self, error_stack::Report<Self::Error>> {
// For MIT, address is optional
let address = payment_address::PaymentAddress::default();
Ok(Self {
merchant_id: common_utils::id_type::MerchantId::default(),
payment_id: "REPEAT_PAYMENT_ID".to_string(),
attempt_id: "REPEAT_ATTEMPT_ID".to_string(),
status: common_enums::AttemptStatus::Pending,
payment_method: common_enums::PaymentMethod::Card, // Default, actual method depends on mandate
address,
auth_type: common_enums::AuthenticationType::NoThreeDs, // MIT typically doesn't use 3DS
connector_request_reference_id: extract_connector_request_reference_id(
&value.request_ref_id,
),
customer_id: None,
connector_customer: None,
description: Some("Repeat payment transaction".to_string()),
return_url: None,
connector_meta_data: None,
amount_captured: None,
minor_amount_captured: None,
minor_amount_capturable: None,
access_token: None,
session_token: None,
reference_id: value.merchant_order_reference_id,
payment_method_token: None,
preprocessing_id: None,
connector_api_version: None,
test_mode: value.test_mode,
connector_http_status_code: None,
external_latency: None,
connectors,
raw_connector_response: None,
raw_connector_request: None,
connector_response_headers: None,
vault_headers: None,
connector_response: None,
recurring_mandate_payment_data: None,
})
}
}
pub fn generate_repeat_payment_response(
router_data_v2: RouterDataV2<
RepeatPayment,
PaymentFlowData,
RepeatPaymentData,
PaymentsResponseData,
>,
) -> Result<
grpc_api_types::payments::PaymentServiceRepeatEverythingResponse,
error_stack::Report<ApplicationErrorResponse>,
> {
let transaction_response = router_data_v2.response;
let status = router_data_v2.resource_common_data.status;
let grpc_status = grpc_api_types::payments::PaymentStatus::foreign_from(status);
// Create state if either access token or connector customer is available
let state = if router_data_v2.resource_common_data.access_token.is_some()
|| router_data_v2
.resource_common_data
.connector_customer
.is_some()
{
Some(ConnectorState {
access_token: router_data_v2
.resource_common_data
.access_token
.as_ref()
.map(|token_data| grpc_api_types::payments::AccessToken {
token: token_data.access_token.clone(),
expires_in_seconds: token_data.expires_in,
token_type: token_data.token_type.clone(),
}),
connector_customer_id: router_data_v2
.resource_common_data
.connector_customer
.clone(),
})
} else {
None
};
let raw_connector_response = router_data_v2
.resource_common_data
.get_raw_connector_response();
let raw_connector_request = router_data_v2
.resource_common_data
.get_raw_connector_request();
match transaction_response {
Ok(response) => match response {
PaymentsResponseData::TransactionResponse {
resource_id,
network_txn_id,
connector_response_reference_id,
connector_metadata,
| {
"chunk": 58,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_59 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
mandate_reference,
status_code,
..
} => Ok(
grpc_api_types::payments::PaymentServiceRepeatEverythingResponse {
transaction_id: Some(grpc_api_types::payments::Identifier::foreign_try_from(
resource_id,
)?),
status: grpc_status as i32,
error_code: None,
error_message: None,
network_txn_id,
response_ref_id: connector_response_reference_id.map(|id| {
grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(id)),
}
}),
connector_metadata: connector_metadata
.and_then(|value| value.as_object().cloned())
.map(|map| {
map.into_iter()
.filter_map(|(k, v)| v.as_str().map(|s| (k, s.to_string())))
.collect::<HashMap<_, _>>()
})
.unwrap_or_default(),
mandate_reference: mandate_reference.map(|m| {
grpc_api_types::payments::MandateReference {
mandate_id: m.connector_mandate_id,
payment_method_id: m.payment_method_id,
}
}),
status_code: status_code as u32,
raw_connector_response,
response_headers: router_data_v2
.resource_common_data
.get_connector_response_headers_as_map(),
state,
raw_connector_request,
connector_response: router_data_v2
.resource_common_data
.connector_response
.and_then(|data| {
grpc_api_types::payments::ConnectorResponseData::foreign_try_from(data)
.ok()
}),
captured_amount: router_data_v2.resource_common_data.amount_captured,
minor_captured_amount: router_data_v2
.resource_common_data
.minor_amount_captured
.map(|amount_captured| amount_captured.get_amount_as_i64()),
},
),
_ => Err(ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "INVALID_RESPONSE".to_owned(),
error_identifier: 400,
error_message: "Invalid response from connector".to_owned(),
error_object: None,
}))?,
},
Err(err) => {
let status = err
.attempt_status
.map(grpc_api_types::payments::PaymentStatus::foreign_from)
.unwrap_or_default();
Ok(
grpc_api_types::payments::PaymentServiceRepeatEverythingResponse {
transaction_id: Some(grpc_api_types::payments::Identifier {
id_type: Some(
grpc_api_types::payments::identifier::IdType::NoResponseIdMarker(()),
),
}),
status: status as i32,
error_code: Some(err.code),
error_message: Some(err.message),
network_txn_id: None,
response_ref_id: err.connector_transaction_id.map(|id| {
grpc_api_types::payments::Identifier {
id_type: Some(grpc_api_types::payments::identifier::IdType::Id(id)),
}
}),
connector_metadata: HashMap::new(),
raw_connector_response: None,
status_code: err.status_code as u32,
response_headers: router_data_v2
.resource_common_data
.get_connector_response_headers_as_map(),
state,
| {
"chunk": 59,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_60 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
mandate_reference: None,
raw_connector_request,
connector_response: None,
captured_amount: None,
minor_captured_amount: None,
},
)
}
}
}
impl ForeignTryFrom<grpc_api_types::payments::BankNames> for common_enums::BankNames {
type Error = ApplicationErrorResponse;
fn foreign_try_from(
value: grpc_api_types::payments::BankNames,
) -> Result<Self, error_stack::Report<Self::Error>> {
match value {
grpc_api_types::payments::BankNames::Unspecified => {
Err(report!(ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "UNSPECIFIED_BANK_NAME".to_owned(),
error_identifier: 401,
error_message: "Bank name must be specified".to_owned(),
error_object: None,
})))
}
grpc_api_types::payments::BankNames::AmericanExpress => Ok(Self::AmericanExpress),
grpc_api_types::payments::BankNames::AffinBank => Ok(Self::AffinBank),
grpc_api_types::payments::BankNames::AgroBank => Ok(Self::AgroBank),
grpc_api_types::payments::BankNames::AllianceBank => Ok(Self::AllianceBank),
grpc_api_types::payments::BankNames::AmBank => Ok(Self::AmBank),
grpc_api_types::payments::BankNames::BankOfAmerica => Ok(Self::BankOfAmerica),
grpc_api_types::payments::BankNames::BankOfChina => Ok(Self::BankOfChina),
grpc_api_types::payments::BankNames::BankIslam => Ok(Self::BankIslam),
grpc_api_types::payments::BankNames::BankMuamalat => Ok(Self::BankMuamalat),
grpc_api_types::payments::BankNames::BankRakyat => Ok(Self::BankRakyat),
grpc_api_types::payments::BankNames::BankSimpananNasional => {
Ok(Self::BankSimpananNasional)
}
grpc_api_types::payments::BankNames::Barclays => Ok(Self::Barclays),
grpc_api_types::payments::BankNames::BlikPsp => Ok(Self::BlikPSP),
grpc_api_types::payments::BankNames::CapitalOne => Ok(Self::CapitalOne),
grpc_api_types::payments::BankNames::Chase => Ok(Self::Chase),
grpc_api_types::payments::BankNames::Citi => Ok(Self::Citi),
grpc_api_types::payments::BankNames::CimbBank => Ok(Self::CimbBank),
grpc_api_types::payments::BankNames::Discover => Ok(Self::Discover),
grpc_api_types::payments::BankNames::NavyFederalCreditUnion => {
Ok(Self::NavyFederalCreditUnion)
}
grpc_api_types::payments::BankNames::PentagonFederalCreditUnion => {
Ok(Self::PentagonFederalCreditUnion)
}
grpc_api_types::payments::BankNames::SynchronyBank => Ok(Self::SynchronyBank),
grpc_api_types::payments::BankNames::WellsFargo => Ok(Self::WellsFargo),
grpc_api_types::payments::BankNames::AbnAmro => Ok(Self::AbnAmro),
grpc_api_types::payments::BankNames::AsnBank => Ok(Self::AsnBank),
grpc_api_types::payments::BankNames::Bunq => Ok(Self::Bunq),
grpc_api_types::payments::BankNames::Handelsbanken => Ok(Self::Handelsbanken),
grpc_api_types::payments::BankNames::HongLeongBank => Ok(Self::HongLeongBank),
grpc_api_types::payments::BankNames::HsbcBank => Ok(Self::HsbcBank),
grpc_api_types::payments::BankNames::Ing => Ok(Self::Ing),
grpc_api_types::payments::BankNames::Knab => Ok(Self::Knab),
grpc_api_types::payments::BankNames::KuwaitFinanceHouse => Ok(Self::KuwaitFinanceHouse),
grpc_api_types::payments::BankNames::Moneyou => Ok(Self::Moneyou),
grpc_api_types::payments::BankNames::Rabobank => Ok(Self::Rabobank),
grpc_api_types::payments::BankNames::Regiobank => Ok(Self::Regiobank),
grpc_api_types::payments::BankNames::Revolut => Ok(Self::Revolut),
grpc_api_types::payments::BankNames::SnsBank => Ok(Self::SnsBank),
grpc_api_types::payments::BankNames::TriodosBank => Ok(Self::TriodosBank),
| {
"chunk": 60,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_61 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
grpc_api_types::payments::BankNames::VanLanschot => Ok(Self::VanLanschot),
grpc_api_types::payments::BankNames::ArzteUndApothekerBank => {
Ok(Self::ArzteUndApothekerBank)
}
grpc_api_types::payments::BankNames::AustrianAnadiBankAg => {
Ok(Self::AustrianAnadiBankAg)
}
grpc_api_types::payments::BankNames::BankAustria => Ok(Self::BankAustria),
grpc_api_types::payments::BankNames::Bank99Ag => Ok(Self::Bank99Ag),
grpc_api_types::payments::BankNames::BankhausCarlSpangler => {
Ok(Self::BankhausCarlSpangler)
}
grpc_api_types::payments::BankNames::BankhausSchelhammerUndSchatteraAg => {
Ok(Self::BankhausSchelhammerUndSchatteraAg)
}
grpc_api_types::payments::BankNames::BankMillennium => Ok(Self::BankMillennium),
grpc_api_types::payments::BankNames::BawagPskAg => Ok(Self::BawagPskAg),
grpc_api_types::payments::BankNames::BksBankAg => Ok(Self::BksBankAg),
grpc_api_types::payments::BankNames::BrullKallmusBankAg => Ok(Self::BrullKallmusBankAg),
grpc_api_types::payments::BankNames::BtvVierLanderBank => Ok(Self::BtvVierLanderBank),
grpc_api_types::payments::BankNames::CapitalBankGraweGruppeAg => {
Ok(Self::CapitalBankGraweGruppeAg)
}
grpc_api_types::payments::BankNames::CeskaSporitelna => Ok(Self::CeskaSporitelna),
grpc_api_types::payments::BankNames::Dolomitenbank => Ok(Self::Dolomitenbank),
grpc_api_types::payments::BankNames::EasybankAg => Ok(Self::EasybankAg),
grpc_api_types::payments::BankNames::EPlatbyVub => Ok(Self::EPlatbyVUB),
grpc_api_types::payments::BankNames::ErsteBankUndSparkassen => {
Ok(Self::ErsteBankUndSparkassen)
}
grpc_api_types::payments::BankNames::FrieslandBank => Ok(Self::FrieslandBank),
grpc_api_types::payments::BankNames::HypoAlpeadriabankInternationalAg => {
Ok(Self::HypoAlpeadriabankInternationalAg)
}
grpc_api_types::payments::BankNames::HypoNoeLbFurNiederosterreichUWien => {
Ok(Self::HypoNoeLbFurNiederosterreichUWien)
}
grpc_api_types::payments::BankNames::HypoOberosterreichSalzburgSteiermark => {
Ok(Self::HypoOberosterreichSalzburgSteiermark)
}
grpc_api_types::payments::BankNames::HypoTirolBankAg => Ok(Self::HypoTirolBankAg),
grpc_api_types::payments::BankNames::HypoVorarlbergBankAg => {
Ok(Self::HypoVorarlbergBankAg)
}
grpc_api_types::payments::BankNames::HypoBankBurgenlandAktiengesellschaft => {
Ok(Self::HypoBankBurgenlandAktiengesellschaft)
}
grpc_api_types::payments::BankNames::KomercniBanka => Ok(Self::KomercniBanka),
grpc_api_types::payments::BankNames::MBank => Ok(Self::MBank),
grpc_api_types::payments::BankNames::MarchfelderBank => Ok(Self::MarchfelderBank),
grpc_api_types::payments::BankNames::Maybank => Ok(Self::Maybank),
grpc_api_types::payments::BankNames::OberbankAg => Ok(Self::OberbankAg),
grpc_api_types::payments::BankNames::OsterreichischeArzteUndApothekerbank => {
Ok(Self::OsterreichischeArzteUndApothekerbank)
}
grpc_api_types::payments::BankNames::OcbcBank => Ok(Self::OcbcBank),
grpc_api_types::payments::BankNames::PayWithIng => Ok(Self::PayWithING),
grpc_api_types::payments::BankNames::PlaceZipko => Ok(Self::PlaceZIPKO),
grpc_api_types::payments::BankNames::PlatnoscOnlineKartaPlatnicza => {
Ok(Self::PlatnoscOnlineKartaPlatnicza)
}
grpc_api_types::payments::BankNames::PosojilnicaBankEGen => {
Ok(Self::PosojilnicaBankEGen)
}
grpc_api_types::payments::BankNames::PostovaBanka => Ok(Self::PostovaBanka),
grpc_api_types::payments::BankNames::PublicBank => Ok(Self::PublicBank),
| {
"chunk": 61,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_62 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
grpc_api_types::payments::BankNames::RaiffeisenBankengruppeOsterreich => {
Ok(Self::RaiffeisenBankengruppeOsterreich)
}
grpc_api_types::payments::BankNames::RhbBank => Ok(Self::RhbBank),
grpc_api_types::payments::BankNames::SchelhammerCapitalBankAg => {
Ok(Self::SchelhammerCapitalBankAg)
}
grpc_api_types::payments::BankNames::StandardCharteredBank => {
Ok(Self::StandardCharteredBank)
}
grpc_api_types::payments::BankNames::SchoellerbankAg => Ok(Self::SchoellerbankAg),
grpc_api_types::payments::BankNames::SpardaBankWien => Ok(Self::SpardaBankWien),
grpc_api_types::payments::BankNames::SporoPay => Ok(Self::SporoPay),
grpc_api_types::payments::BankNames::SantanderPrzelew24 => Ok(Self::SantanderPrzelew24),
grpc_api_types::payments::BankNames::TatraPay => Ok(Self::TatraPay),
grpc_api_types::payments::BankNames::Viamo => Ok(Self::Viamo),
grpc_api_types::payments::BankNames::VolksbankGruppe => Ok(Self::VolksbankGruppe),
grpc_api_types::payments::BankNames::VolkskreditbankAg => Ok(Self::VolkskreditbankAg),
grpc_api_types::payments::BankNames::VrBankBraunau => Ok(Self::VrBankBraunau),
grpc_api_types::payments::BankNames::UobBank => Ok(Self::UobBank),
grpc_api_types::payments::BankNames::PayWithAliorBank => Ok(Self::PayWithAliorBank),
grpc_api_types::payments::BankNames::BankiSpoldzielcze => Ok(Self::BankiSpoldzielcze),
grpc_api_types::payments::BankNames::PayWithInteligo => Ok(Self::PayWithInteligo),
grpc_api_types::payments::BankNames::BnpParibasPoland => Ok(Self::BNPParibasPoland),
grpc_api_types::payments::BankNames::BankNowySa => Ok(Self::BankNowySA),
grpc_api_types::payments::BankNames::CreditAgricole => Ok(Self::CreditAgricole),
grpc_api_types::payments::BankNames::PayWithBos => Ok(Self::PayWithBOS),
grpc_api_types::payments::BankNames::PayWithCitiHandlowy => {
Ok(Self::PayWithCitiHandlowy)
}
grpc_api_types::payments::BankNames::PayWithPlusBank => Ok(Self::PayWithPlusBank),
grpc_api_types::payments::BankNames::ToyotaBank => Ok(Self::ToyotaBank),
grpc_api_types::payments::BankNames::VeloBank => Ok(Self::VeloBank),
grpc_api_types::payments::BankNames::ETransferPocztowy24 => {
Ok(Self::ETransferPocztowy24)
}
grpc_api_types::payments::BankNames::PlusBank => Ok(Self::PlusBank),
grpc_api_types::payments::BankNames::BankiSpbdzielcze => Ok(Self::BankiSpbdzielcze),
grpc_api_types::payments::BankNames::BankNowyBfgSa => Ok(Self::BankNowyBfgSa),
grpc_api_types::payments::BankNames::GetinBank => Ok(Self::GetinBank),
grpc_api_types::payments::BankNames::BlikPoland => Ok(Self::Blik),
grpc_api_types::payments::BankNames::NoblePay => Ok(Self::NoblePay),
grpc_api_types::payments::BankNames::IdeaBank => Ok(Self::IdeaBank),
grpc_api_types::payments::BankNames::EnveloBank => Ok(Self::EnveloBank),
grpc_api_types::payments::BankNames::NestPrzelew => Ok(Self::NestPrzelew),
grpc_api_types::payments::BankNames::MbankMtransfer => Ok(Self::MbankMtransfer),
grpc_api_types::payments::BankNames::Inteligo => Ok(Self::Inteligo),
grpc_api_types::payments::BankNames::PbacZIpko => Ok(Self::PbacZIpko),
grpc_api_types::payments::BankNames::BnpParibas => Ok(Self::BnpParibas),
grpc_api_types::payments::BankNames::BankPekaoSa => Ok(Self::BankPekaoSa),
grpc_api_types::payments::BankNames::VolkswagenBank => Ok(Self::VolkswagenBank),
grpc_api_types::payments::BankNames::AliorBank => Ok(Self::AliorBank),
grpc_api_types::payments::BankNames::Boz => Ok(Self::Boz),
grpc_api_types::payments::BankNames::BangkokBank => Ok(Self::BangkokBank),
grpc_api_types::payments::BankNames::KrungsriBank => Ok(Self::KrungsriBank),
| {
"chunk": 62,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_63 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
grpc_api_types::payments::BankNames::KrungThaiBank => Ok(Self::KrungThaiBank),
grpc_api_types::payments::BankNames::TheSiamCommercialBank => {
Ok(Self::TheSiamCommercialBank)
}
grpc_api_types::payments::BankNames::KasikornBank => Ok(Self::KasikornBank),
grpc_api_types::payments::BankNames::OpenBankSuccess => Ok(Self::OpenBankSuccess),
grpc_api_types::payments::BankNames::OpenBankFailure => Ok(Self::OpenBankFailure),
grpc_api_types::payments::BankNames::OpenBankCancelled => Ok(Self::OpenBankCancelled),
grpc_api_types::payments::BankNames::Aib => Ok(Self::Aib),
grpc_api_types::payments::BankNames::BankOfScotland => Ok(Self::BankOfScotland),
grpc_api_types::payments::BankNames::DanskeBank => Ok(Self::DanskeBank),
grpc_api_types::payments::BankNames::FirstDirect => Ok(Self::FirstDirect),
grpc_api_types::payments::BankNames::FirstTrust => Ok(Self::FirstTrust),
grpc_api_types::payments::BankNames::Halifax => Ok(Self::Halifax),
grpc_api_types::payments::BankNames::Lloyds => Ok(Self::Lloyds),
grpc_api_types::payments::BankNames::Monzo => Ok(Self::Monzo),
grpc_api_types::payments::BankNames::NatWest => Ok(Self::NatWest),
grpc_api_types::payments::BankNames::NationwideBank => Ok(Self::NationwideBank),
grpc_api_types::payments::BankNames::RoyalBankOfScotland => {
Ok(Self::RoyalBankOfScotland)
}
grpc_api_types::payments::BankNames::Starling => Ok(Self::Starling),
grpc_api_types::payments::BankNames::TsbBank => Ok(Self::TsbBank),
grpc_api_types::payments::BankNames::TescoBank => Ok(Self::TescoBank),
grpc_api_types::payments::BankNames::UlsterBank => Ok(Self::UlsterBank),
grpc_api_types::payments::BankNames::Yoursafe => Ok(Self::Yoursafe),
grpc_api_types::payments::BankNames::N26 => Ok(Self::N26),
grpc_api_types::payments::BankNames::NationaleNederlanden => {
Ok(Self::NationaleNederlanden)
}
}
}
}
// New ForeignTryFrom implementations for individual 3DS authentication flow proto definitions
impl<
T: PaymentMethodDataTypes
+ Default
+ Debug
+ Send
+ Eq
+ PartialEq
+ serde::Serialize
+ serde::de::DeserializeOwned
+ Clone
+ CardConversionHelper<T>,
> ForeignTryFrom<grpc_api_types::payments::PaymentServicePreAuthenticateRequest>
for PaymentsPreAuthenticateData<T>
{
type Error = ApplicationErrorResponse;
fn foreign_try_from(
value: grpc_api_types::payments::PaymentServicePreAuthenticateRequest,
) -> Result<Self, error_stack::Report<Self::Error>> {
let email: Option<Email> = match value.email {
Some(ref email_str) => {
Some(Email::try_from(email_str.clone().expose()).map_err(|_| {
error_stack::Report::new(ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "INVALID_EMAIL_FORMAT".to_owned(),
error_identifier: 400,
error_message: "Invalid email".to_owned(),
error_object: None,
}))
})?)
}
None => None,
};
let minor_amount = common_utils::types::MinorUnit::new(value.minor_amount);
let currency = common_enums::Currency::foreign_try_from(value.currency())?;
let return_url = value.return_url;
let enrolled_for_3ds = value.enrolled_for_3ds;
// Clone payment_method to avoid ownership issues
let payment_method_clone = value.payment_method.clone();
// Create redirect response from metadata if present
// This is used to pass connector-specific data (e.g., collectionReference for Worldpay)
let redirect_response = if !value.metadata.is_empty() {
let params_string = serde_urlencoded::to_string(&value.metadata).change_context(
ApplicationErrorResponse::BadRequest(ApiError {
| {
"chunk": 63,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_64 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
sub_code: "INVALID_METADATA".to_owned(),
error_identifier: 400,
error_message: "Failed to serialize metadata".to_owned(),
error_object: None,
}),
)?;
Some(ContinueRedirectionResponse {
params: Some(Secret::new(params_string)),
payload: None,
})
} else {
None
};
Ok(Self {
payment_method_data: value
.payment_method
.map(PaymentMethodData::<T>::foreign_try_from)
.transpose()
.change_context(ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "INVALID_PAYMENT_METHOD_DATA".to_owned(),
error_identifier: 400,
error_message: "Payment method data construction failed".to_owned(),
error_object: None,
}))?,
amount: minor_amount,
email,
currency: Some(currency),
payment_method_type: <Option<PaymentMethodType>>::foreign_try_from(
payment_method_clone.unwrap_or_default(),
)?,
continue_redirection_url: value
.continue_redirection_url
.map(|url_str| {
url::Url::parse(&url_str).change_context(ApplicationErrorResponse::BadRequest(
ApiError {
sub_code: "INVALID_URL".to_owned(),
error_identifier: 400,
error_message: "Invalid continue redirection URL".to_owned(),
error_object: None,
},
))
})
.transpose()?,
router_return_url: return_url
.map(|url_str| {
url::Url::parse(&url_str).change_context(ApplicationErrorResponse::BadRequest(
ApiError {
sub_code: "INVALID_URL".to_owned(),
error_identifier: 400,
error_message: "Invalid router return URL".to_owned(),
error_object: None,
},
))
})
.transpose()?,
browser_info: value
.browser_info
.map(BrowserInformation::foreign_try_from)
.transpose()?,
enrolled_for_3ds,
redirect_response,
})
}
}
impl<
T: PaymentMethodDataTypes
+ Default
+ Debug
+ Send
+ Eq
+ PartialEq
+ serde::Serialize
+ serde::de::DeserializeOwned
+ Clone
+ CardConversionHelper<T>,
> ForeignTryFrom<grpc_api_types::payments::PaymentServiceAuthenticateRequest>
for PaymentsAuthenticateData<T>
{
type Error = ApplicationErrorResponse;
fn foreign_try_from(
value: grpc_api_types::payments::PaymentServiceAuthenticateRequest,
) -> Result<Self, error_stack::Report<Self::Error>> {
let email: Option<Email> = match value.email {
Some(ref email_str) => {
Some(Email::try_from(email_str.clone().expose()).map_err(|_| {
error_stack::Report::new(ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "INVALID_EMAIL_FORMAT".to_owned(),
error_identifier: 400,
error_message: "Invalid email".to_owned(),
error_object: None,
}))
})?)
}
None => None,
};
let minor_amount = common_utils::types::MinorUnit::new(value.minor_amount);
let currency = common_enums::Currency::foreign_try_from(value.currency())?;
let return_url = value.return_url;
// Clone payment_method to avoid ownership issues
let payment_method_clone = value.payment_method.clone();
let redirect_response =
value
.redirection_response
.map(|redirection_response| ContinueRedirectionResponse {
params: redirection_response.params.map(Secret::new),
| {
"chunk": 64,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_65 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
payload: Some(Secret::new(serde_json::Value::Object(
redirection_response
.payload
.into_iter()
.map(|(k, v)| (k, serde_json::Value::String(v)))
.collect(),
))),
});
Ok(Self {
payment_method_data: value
.payment_method
.map(PaymentMethodData::<T>::foreign_try_from)
.transpose()
.change_context(ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "INVALID_PAYMENT_METHOD_DATA".to_owned(),
error_identifier: 400,
error_message: "Payment method data construction failed".to_owned(),
error_object: None,
}))?,
amount: minor_amount,
email,
currency: Some(currency),
payment_method_type: <Option<PaymentMethodType>>::foreign_try_from(
payment_method_clone.unwrap_or_default(),
)?,
router_return_url: return_url
.map(|url_str| {
url::Url::parse(&url_str).change_context(ApplicationErrorResponse::BadRequest(
ApiError {
sub_code: "INVALID_URL".to_owned(),
error_identifier: 400,
error_message: "Invalid router return URL".to_owned(),
error_object: None,
},
))
})
.transpose()?,
continue_redirection_url: value
.continue_redirection_url
.map(|url_str| {
url::Url::parse(&url_str).change_context(ApplicationErrorResponse::BadRequest(
ApiError {
sub_code: "INVALID_URL".to_owned(),
error_identifier: 400,
error_message: "Invalid continue redirection URL".to_owned(),
error_object: None,
},
))
})
.transpose()?,
browser_info: value
.browser_info
.map(BrowserInformation::foreign_try_from)
.transpose()?,
enrolled_for_3ds: false,
redirect_response,
})
}
}
impl<
T: PaymentMethodDataTypes
+ Default
+ Debug
+ Send
+ Eq
+ PartialEq
+ serde::Serialize
+ serde::de::DeserializeOwned
+ Clone
+ CardConversionHelper<T>,
> ForeignTryFrom<grpc_api_types::payments::PaymentServicePostAuthenticateRequest>
for PaymentsPostAuthenticateData<T>
{
type Error = ApplicationErrorResponse;
fn foreign_try_from(
value: grpc_api_types::payments::PaymentServicePostAuthenticateRequest,
) -> Result<Self, error_stack::Report<Self::Error>> {
let email: Option<Email> = match value.email {
Some(ref email_str) => {
Some(Email::try_from(email_str.clone().expose()).map_err(|_| {
error_stack::Report::new(ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "INVALID_EMAIL_FORMAT".to_owned(),
error_identifier: 400,
error_message: "Invalid email".to_owned(),
error_object: None,
}))
})?)
}
None => None,
};
let minor_amount = common_utils::types::MinorUnit::new(value.minor_amount);
let currency = common_enums::Currency::foreign_try_from(value.currency())?;
let return_url = value.return_url;
// Clone payment_method to avoid ownership issues
let payment_method_clone = value.payment_method.clone();
let redirect_response =
value
.redirection_response
.map(|redirection_response| ContinueRedirectionResponse {
params: redirection_response.params.map(Secret::new),
| {
"chunk": 65,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_66 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
payload: Some(Secret::new(serde_json::Value::Object(
redirection_response
.payload
.into_iter()
.map(|(k, v)| (k, serde_json::Value::String(v)))
.collect(),
))),
});
Ok(Self {
payment_method_data: value
.payment_method
.map(PaymentMethodData::<T>::foreign_try_from)
.transpose()
.change_context(ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "INVALID_PAYMENT_METHOD_DATA".to_owned(),
error_identifier: 400,
error_message: "Payment method data construction failed".to_owned(),
error_object: None,
}))?,
amount: minor_amount,
email,
currency: Some(currency),
payment_method_type: <Option<PaymentMethodType>>::foreign_try_from(
payment_method_clone.unwrap_or_default(),
)?,
router_return_url: return_url
.map(|url_str| {
url::Url::parse(&url_str).change_context(ApplicationErrorResponse::BadRequest(
ApiError {
sub_code: "INVALID_URL".to_owned(),
error_identifier: 400,
error_message: "Invalid router return URL".to_owned(),
error_object: None,
},
))
})
.transpose()?,
continue_redirection_url: value
.continue_redirection_url
.map(|url_str| {
url::Url::parse(&url_str).change_context(ApplicationErrorResponse::BadRequest(
ApiError {
sub_code: "INVALID_URL".to_owned(),
error_identifier: 400,
error_message: "Invalid continue redirection URL".to_owned(),
error_object: None,
},
))
})
.transpose()?,
browser_info: value
.browser_info
.map(BrowserInformation::foreign_try_from)
.transpose()?,
enrolled_for_3ds: false,
redirect_response,
})
}
}
// PaymentFlowData implementations for new proto definitions
impl
ForeignTryFrom<(
grpc_api_types::payments::PaymentServicePreAuthenticateRequest,
Connectors,
&common_utils::metadata::MaskedMetadata,
)> for PaymentFlowData
{
type Error = ApplicationErrorResponse;
fn foreign_try_from(
(value, connectors, metadata): (
grpc_api_types::payments::PaymentServicePreAuthenticateRequest,
Connectors,
&common_utils::metadata::MaskedMetadata,
),
) -> Result<Self, error_stack::Report<Self::Error>> {
let address = match value.address {
Some(address) => payment_address::PaymentAddress::foreign_try_from(address)?,
None => {
return Err(ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "INVALID_ADDRESS".to_owned(),
error_identifier: 400,
error_message: "Address is required".to_owned(),
error_object: None,
}))?
}
};
let merchant_id_from_header = extract_merchant_id_from_metadata(metadata)?;
let vault_headers = extract_headers_from_metadata(metadata);
Ok(Self {
merchant_id: merchant_id_from_header,
payment_id: "IRRELEVANT_PAYMENT_ID".to_string(),
attempt_id: "IRRELEVANT_ATTEMPT_ID".to_string(),
status: common_enums::AttemptStatus::Pending,
payment_method: common_enums::PaymentMethod::foreign_try_from(
value.payment_method.unwrap_or_default(),
)?,
address,
auth_type: common_enums::AuthenticationType::ThreeDs, // Pre-auth typically uses 3DS
| {
"chunk": 66,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_67 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
connector_request_reference_id: extract_connector_request_reference_id(
&value.request_ref_id,
),
customer_id: None,
connector_customer: None,
description: None,
return_url: value.return_url.clone(),
connector_meta_data: {
(!value.merchant_account_metadata.is_empty())
.then(|| {
serde_json::to_value(&value.merchant_account_metadata)
.map(common_utils::pii::SecretSerdeValue::new)
.map_err(|_| {
error_stack::Report::new(
ApplicationErrorResponse::InternalServerError(
crate::errors::ApiError {
sub_code: "SERDE_JSON_ERROR".to_owned(),
error_identifier: 500,
error_message:
"Failed to serialize merchant_account_metadata"
.to_owned(),
error_object: None,
},
),
)
})
})
.transpose()?
},
amount_captured: None,
minor_amount_captured: None,
minor_amount_capturable: None,
access_token: None,
session_token: None,
reference_id: None,
payment_method_token: None,
preprocessing_id: None,
connector_api_version: None,
test_mode: None,
connector_http_status_code: None,
external_latency: None,
connectors,
raw_connector_response: None,
connector_response_headers: None,
vault_headers,
raw_connector_request: None,
connector_response: None,
recurring_mandate_payment_data: None,
})
}
}
impl
ForeignTryFrom<(
grpc_api_types::payments::PaymentServiceAuthenticateRequest,
Connectors,
&common_utils::metadata::MaskedMetadata,
)> for PaymentFlowData
{
type Error = ApplicationErrorResponse;
fn foreign_try_from(
(value, connectors, metadata): (
grpc_api_types::payments::PaymentServiceAuthenticateRequest,
Connectors,
&common_utils::metadata::MaskedMetadata,
),
) -> Result<Self, error_stack::Report<Self::Error>> {
let address = match &value.address {
Some(address_value) => {
payment_address::PaymentAddress::foreign_try_from((*address_value).clone())?
}
None => {
return Err(ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "INVALID_ADDRESS".to_owned(),
error_identifier: 400,
error_message: "Address is required".to_owned(),
error_object: None,
}))?
}
};
let merchant_id_from_header = extract_merchant_id_from_metadata(metadata)?;
let vault_headers = extract_headers_from_metadata(metadata);
Ok(Self {
merchant_id: merchant_id_from_header,
payment_id: "IRRELEVANT_PAYMENT_ID".to_string(),
attempt_id: "IRRELEVANT_ATTEMPT_ID".to_string(),
status: common_enums::AttemptStatus::Pending,
payment_method: common_enums::PaymentMethod::foreign_try_from(
value.payment_method.unwrap_or_default(),
)?,
address,
auth_type: common_enums::AuthenticationType::ThreeDs, // Auth step uses 3DS
connector_request_reference_id: extract_connector_request_reference_id(
&value.request_ref_id,
),
customer_id: None,
connector_customer: None,
description: value.metadata.get("description").cloned(),
return_url: value.return_url.clone(),
connector_meta_data: {
| {
"chunk": 67,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_68 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
(!value.merchant_account_metadata.is_empty())
.then(|| {
serde_json::to_value(&value.merchant_account_metadata)
.map(common_utils::pii::SecretSerdeValue::new)
.map_err(|_| {
error_stack::Report::new(
ApplicationErrorResponse::InternalServerError(
crate::errors::ApiError {
sub_code: "SERDE_JSON_ERROR".to_owned(),
error_identifier: 500,
error_message:
"Failed to serialize merchant_account_metadata"
.to_owned(),
error_object: None,
},
),
)
})
})
.transpose()?
},
amount_captured: None,
minor_amount_captured: None,
access_token: None,
session_token: None,
reference_id: None,
payment_method_token: None,
preprocessing_id: None,
connector_api_version: None,
test_mode: None,
connector_http_status_code: None,
external_latency: None,
connectors,
raw_connector_response: None,
connector_response_headers: None,
vault_headers,
raw_connector_request: None,
minor_amount_capturable: None,
connector_response: None,
recurring_mandate_payment_data: None,
})
}
}
impl
ForeignTryFrom<(
grpc_api_types::payments::PaymentServicePostAuthenticateRequest,
Connectors,
&common_utils::metadata::MaskedMetadata,
)> for PaymentFlowData
{
type Error = ApplicationErrorResponse;
fn foreign_try_from(
(value, connectors, metadata): (
grpc_api_types::payments::PaymentServicePostAuthenticateRequest,
Connectors,
&common_utils::metadata::MaskedMetadata,
),
) -> Result<Self, error_stack::Report<Self::Error>> {
let address = match &value.address {
Some(address_value) => {
payment_address::PaymentAddress::foreign_try_from((*address_value).clone())?
}
None => {
return Err(ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "INVALID_ADDRESS".to_owned(),
error_identifier: 400,
error_message: "Address is required".to_owned(),
error_object: None,
}))?
}
};
let merchant_id_from_header = extract_merchant_id_from_metadata(metadata)?;
let vault_headers = extract_headers_from_metadata(metadata);
Ok(Self {
merchant_id: merchant_id_from_header,
payment_id: "IRRELEVANT_PAYMENT_ID".to_string(),
attempt_id: "IRRELEVANT_ATTEMPT_ID".to_string(),
status: common_enums::AttemptStatus::Pending,
payment_method: common_enums::PaymentMethod::foreign_try_from(
value.payment_method.unwrap_or_default(),
)?,
address,
auth_type: common_enums::AuthenticationType::ThreeDs, // Post-auth uses 3DS
connector_request_reference_id: extract_connector_request_reference_id(
&value.request_ref_id,
),
customer_id: None,
connector_customer: None,
description: value.metadata.get("description").cloned(),
return_url: value.return_url.clone(),
connector_meta_data: {
(!value.merchant_account_metadata.is_empty())
.then(|| {
serde_json::to_value(&value.merchant_account_metadata)
.map(common_utils::pii::SecretSerdeValue::new)
.map_err(|_| {
error_stack::Report::new(
| {
"chunk": 68,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-7881285798716424113_69 | clm | mini_chunk | // connector-service/backend/domain_types/src/types.rs
ApplicationErrorResponse::InternalServerError(
crate::errors::ApiError {
sub_code: "SERDE_JSON_ERROR".to_owned(),
error_identifier: 500,
error_message:
"Failed to serialize merchant_account_metadata"
.to_owned(),
error_object: None,
},
),
)
})
})
.transpose()?
},
amount_captured: None,
minor_amount_captured: None,
access_token: None,
session_token: None,
reference_id: None,
payment_method_token: None,
preprocessing_id: None,
connector_api_version: None,
test_mode: None,
connector_http_status_code: None,
external_latency: None,
connectors,
raw_connector_response: None,
connector_response_headers: None,
vault_headers,
raw_connector_request: None,
minor_amount_capturable: None,
connector_response: None,
recurring_mandate_payment_data: None,
})
}
}
| {
"chunk": 69,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_4794849861800683444_0 | clm | mini_chunk | // connector-service/backend/domain_types/src/payment_address.rs
use common_enums::ProductType;
use common_utils::{ext_traits::ConfigExt, Email, MinorUnit};
use hyperswitch_masking::{PeekInterface, Secret, SerializableSecret};
use crate::utils::{convert_us_state_to_code, missing_field_err, Error};
#[derive(Clone, Default, Debug)]
pub struct PaymentAddress {
shipping: Option<Address>,
billing: Option<Address>,
unified_payment_method_billing: Option<Address>,
payment_method_billing: Option<Address>,
}
impl PaymentAddress {
pub fn new(
shipping: Option<Address>,
billing: Option<Address>,
payment_method_billing: Option<Address>,
should_unify_address: Option<bool>,
) -> Self {
// billing -> .billing, this is the billing details passed in the root of payments request
// payment_method_billing -> .payment_method_data.billing
let unified_payment_method_billing = if should_unify_address.unwrap_or(true) {
// Merge the billing details field from both `payment.billing` and `payment.payment_method_data.billing`
// The unified payment_method_billing will be used as billing address and passed to the connector module
// This unification is required in order to provide backwards compatibility
// so that if `payment.billing` is passed it should be sent to the connector module
// Unify the billing details with `payment_method_data.billing`
payment_method_billing
.as_ref()
.map(|payment_method_billing| {
payment_method_billing
.clone()
.unify_address(billing.as_ref())
})
.or(billing.clone())
} else {
payment_method_billing.clone()
};
Self {
shipping,
billing,
unified_payment_method_billing,
payment_method_billing,
}
}
pub fn get_shipping(&self) -> Option<&Address> {
self.shipping.as_ref()
}
pub fn get_payment_method_billing(&self) -> Option<&Address> {
self.unified_payment_method_billing.as_ref()
}
/// Unify the billing details from `payment_method_data.[payment_method_data].billing details`.
pub fn unify_with_payment_method_data_billing(
self,
payment_method_data_billing: Option<Address>,
) -> Self {
// Unify the billing details with `payment_method_data.billing_details`
let unified_payment_method_billing = payment_method_data_billing
.map(|payment_method_data_billing| {
payment_method_data_billing.unify_address(self.get_payment_method_billing())
})
.or(self.get_payment_method_billing().cloned());
Self {
shipping: self.shipping,
billing: self.billing,
unified_payment_method_billing,
payment_method_billing: self.payment_method_billing,
}
}
pub fn get_request_payment_method_billing(&self) -> Option<&Address> {
self.payment_method_billing.as_ref()
}
pub fn get_payment_billing(&self) -> Option<&Address> {
self.billing.as_ref()
}
}
#[derive(Default, Clone, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize)]
#[serde(deny_unknown_fields)]
pub struct Address {
/// Provide the address details
pub address: Option<AddressDetails>,
pub phone: Option<PhoneDetails>,
pub email: Option<Email>,
}
impl SerializableSecret for Address {}
impl Address {
/// Unify the address, giving priority to `self` when details are present in both
pub fn unify_address(self, other: Option<&Self>) -> Self {
let other_address_details = other.and_then(|address| address.address.as_ref());
Self {
address: self
.address
.map(|address| address.unify_address_details(other_address_details))
.or(other_address_details.cloned()),
email: self.email.or(other.and_then(|other| other.email.clone())),
phone: self.phone.or(other.and_then(|other| other.phone.clone())),
}
}
}
impl Address {
pub fn get_email(&self) -> Result<Email, Error> {
self.email.clone().ok_or_else(missing_field_err("email"))
}
pub fn get_phone_with_country_code(
| {
"chunk": 0,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_4794849861800683444_1 | clm | mini_chunk | // connector-service/backend/domain_types/src/payment_address.rs
&self,
) -> Result<Secret<String>, error_stack::Report<crate::errors::ConnectorError>> {
self.phone
.clone()
.map(|phone_details| phone_details.get_number_with_country_code())
.transpose()?
.ok_or_else(missing_field_err("phone"))
}
pub fn get_optional_country(&self) -> Option<common_enums::CountryAlpha2> {
self.address
.as_ref()
.and_then(|billing_details| billing_details.country)
}
pub fn get_optional_full_name(&self) -> Option<Secret<String>> {
self.address
.as_ref()
.and_then(|billing_address| billing_address.get_optional_full_name())
}
pub fn get_optional_first_name(&self) -> Option<Secret<String>> {
self.address
.as_ref()
.and_then(|billing_address| billing_address.get_optional_first_name())
}
pub fn get_optional_last_name(&self) -> Option<Secret<String>> {
self.address
.as_ref()
.and_then(|billing_address| billing_address.get_optional_last_name())
}
}
// used by customers also, could be moved outside
/// Address details
#[derive(Clone, Default, Debug, Eq, serde::Deserialize, serde::Serialize, PartialEq)]
#[serde(deny_unknown_fields)]
pub struct AddressDetails {
/// The city, district, suburb, town, or village of the address.
pub city: Option<String>,
/// The two-letter ISO 3166-1 alpha-2 country code (e.g., US, GB).
pub country: Option<common_enums::CountryAlpha2>,
/// The first line of the street address or P.O. Box.
pub line1: Option<Secret<String>>,
/// The second line of the street address or P.O. Box (e.g., apartment, suite, unit, or building).
pub line2: Option<Secret<String>>,
/// The third line of the street address, if applicable.
pub line3: Option<Secret<String>>,
/// The zip/postal code for the address
pub zip: Option<Secret<String>>,
/// The address state
pub state: Option<Secret<String>>,
/// The first name for the address
pub first_name: Option<Secret<String>>,
/// The last name for the address
pub last_name: Option<Secret<String>>,
}
impl AddressDetails {
pub fn get_optional_full_name(&self) -> Option<Secret<String>> {
match (self.first_name.as_ref(), self.last_name.as_ref()) {
(Some(first_name), Some(last_name)) => Some(Secret::new(format!(
"{} {}",
first_name.peek(),
last_name.peek()
))),
(Some(name), None) | (None, Some(name)) => Some(name.to_owned()),
_ => None,
}
}
pub fn get_optional_first_name(&self) -> Option<Secret<String>> {
self.first_name.clone()
}
pub fn get_optional_last_name(&self) -> Option<Secret<String>> {
self.last_name.clone()
}
pub fn unify_address_details(self, other: Option<&Self>) -> Self {
if let Some(other) = other {
let (first_name, last_name) = if self
.first_name
.as_ref()
.is_some_and(|first_name| !first_name.is_empty_after_trim())
{
(self.first_name, self.last_name)
} else {
(other.first_name.clone(), other.last_name.clone())
};
Self {
first_name,
last_name,
city: self.city.or(other.city.clone()),
country: self.country.or(other.country),
line1: self.line1.or(other.line1.clone()),
line2: self.line2.or(other.line2.clone()),
line3: self.line3.or(other.line3.clone()),
zip: self.zip.or(other.zip.clone()),
state: self.state.or(other.state.clone()),
}
} else {
self
}
}
}
impl AddressDetails {
pub fn get_first_name(&self) -> Result<&Secret<String>, Error> {
self.first_name
.as_ref()
.ok_or_else(missing_field_err("address.first_name"))
}
pub fn get_last_name(&self) -> Result<&Secret<String>, Error> {
self.last_name
.as_ref()
.ok_or_else(missing_field_err("address.last_name"))
}
pub fn get_full_name(&self) -> Result<Secret<String>, Error> {
| {
"chunk": 1,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_4794849861800683444_2 | clm | mini_chunk | // connector-service/backend/domain_types/src/payment_address.rs
let first_name = self.get_first_name()?.peek().to_owned();
let last_name = self
.get_last_name()
.ok()
.cloned()
.unwrap_or(Secret::new("".to_string()));
let last_name = last_name.peek();
let full_name = format!("{first_name} {last_name}").trim().to_string();
Ok(Secret::new(full_name))
}
pub fn get_line1(&self) -> Result<&Secret<String>, Error> {
self.line1
.as_ref()
.ok_or_else(missing_field_err("address.line1"))
}
pub fn get_city(&self) -> Result<&String, Error> {
self.city
.as_ref()
.ok_or_else(missing_field_err("address.city"))
}
pub fn get_state(&self) -> Result<&Secret<String>, Error> {
self.state
.as_ref()
.ok_or_else(missing_field_err("address.state"))
}
pub fn get_line2(&self) -> Result<&Secret<String>, Error> {
self.line2
.as_ref()
.ok_or_else(missing_field_err("address.line2"))
}
pub fn get_zip(&self) -> Result<&Secret<String>, Error> {
self.zip
.as_ref()
.ok_or_else(missing_field_err("address.zip"))
}
pub fn get_country(&self) -> Result<&common_enums::CountryAlpha2, Error> {
self.country
.as_ref()
.ok_or_else(missing_field_err("address.country"))
}
pub fn get_combined_address_line(&self) -> Result<Secret<String>, Error> {
Ok(Secret::new(format!(
"{},{}",
self.get_line1()?.peek(),
self.get_line2()?.peek()
)))
}
pub fn get_optional_line2(&self) -> Option<Secret<String>> {
self.line2.clone()
}
pub fn get_optional_country(&self) -> Option<common_enums::CountryAlpha2> {
self.country
}
pub fn to_state_code(&self) -> Result<Secret<String>, Error> {
let country = self.get_country()?;
let state = self.get_state()?;
match country {
common_enums::CountryAlpha2::US => Ok(Secret::new(
convert_us_state_to_code(&state.peek().to_string()).to_string(),
)),
_ => Ok(state.clone()),
}
}
pub fn to_state_code_as_optional(&self) -> Result<Option<Secret<String>>, Error> {
self.state
.as_ref()
.map(|state| {
if state.peek().len() == 2 {
Ok(state.to_owned())
} else {
self.to_state_code()
}
})
.transpose()
}
}
#[derive(Debug, Clone, Default, Eq, PartialEq, serde::Deserialize, serde::Serialize)]
pub struct PhoneDetails {
/// The contact number
pub number: Option<Secret<String>>,
/// The country code attached to the number
pub country_code: Option<String>,
}
impl PhoneDetails {
pub fn get_country_code(&self) -> Result<String, Error> {
self.country_code
.clone()
.ok_or_else(missing_field_err("billing.phone.country_code"))
}
pub fn extract_country_code(&self) -> Result<String, Error> {
self.get_country_code()
.map(|cc| cc.trim_start_matches('+').to_string())
}
pub fn get_number(&self) -> Result<Secret<String>, Error> {
self.number
.clone()
.ok_or_else(missing_field_err("billing.phone.number"))
}
pub fn get_number_with_country_code(&self) -> Result<Secret<String>, Error> {
let number = self.get_number()?;
let country_code = self.get_country_code()?;
Ok(Secret::new(format!("{}{}", country_code, number.peek())))
}
pub fn get_number_with_hash_country_code(&self) -> Result<Secret<String>, Error> {
let number = self.get_number()?;
let country_code = self.get_country_code()?;
let number_without_plus = country_code.trim_start_matches('+');
Ok(Secret::new(format!(
"{}#{}",
number_without_plus,
number.peek()
)))
}
}
#[derive(Debug, serde::Serialize, PartialEq, Eq, serde::Deserialize)]
pub struct RedirectionResponse {
pub return_url_with_query_params: String,
}
#[derive(Debug, Default, PartialEq, serde::Deserialize, serde::Serialize, Clone)]
pub struct OrderDetailsWithAmount {
/// Name of the product that is being purchased
| {
"chunk": 2,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_4794849861800683444_3 | clm | mini_chunk | // connector-service/backend/domain_types/src/payment_address.rs
pub product_name: String,
/// The quantity of the product to be purchased
pub quantity: u16,
/// the amount per quantity of product
pub amount: MinorUnit,
/// tax rate applicable to the product
pub tax_rate: Option<f64>,
/// total tax amount applicable to the product
pub total_tax_amount: Option<MinorUnit>,
// Does the order includes shipping
pub requires_shipping: Option<bool>,
/// The image URL of the product
pub product_img_link: Option<String>,
/// ID of the product that is being purchased
pub product_id: Option<String>,
/// Category of the product that is being purchased
pub category: Option<String>,
/// Sub category of the product that is being purchased
pub sub_category: Option<String>,
/// Brand of the product that is being purchased
pub brand: Option<String>,
/// Type of the product that is being purchased
pub product_type: Option<ProductType>,
/// The tax code for the product
pub product_tax_code: Option<String>,
}
impl hyperswitch_masking::SerializableSecret for OrderDetailsWithAmount {}
| {
"chunk": 3,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-8778740194381731474_0 | clm | mini_chunk | // connector-service/backend/domain_types/src/router_data_v2.rs
use std::marker::PhantomData;
use crate::router_data::{ConnectorAuthType, ErrorResponse};
#[derive(Debug, Clone)]
pub struct RouterDataV2<Flow, ResourceCommonData, FlowSpecificRequest, FlowSpecificResponse> {
pub flow: PhantomData<Flow>,
// pub tenant_id: id_type::TenantId, // TODO: Should we add this
pub resource_common_data: ResourceCommonData,
pub connector_auth_type: ConnectorAuthType,
/// Contains flow-specific data required to construct a request and send it to the connector.
pub request: FlowSpecificRequest,
/// Contains flow-specific data that the connector responds with.
pub response: Result<FlowSpecificResponse, ErrorResponse>,
}
| {
"chunk": 0,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-6262692988738800615_0 | clm | mini_chunk | // connector-service/backend/domain_types/src/connector_types.rs
use std::collections::HashMap;
use common_enums::{
AttemptStatus, AuthenticationType, Currency, DisputeStatus, EventClass, PaymentMethod,
PaymentMethodType,
};
use common_utils::{
errors,
ext_traits::{OptionExt, ValueExt},
pii::IpAddress,
types::{MinorUnit, StringMinorUnit},
CustomResult, CustomerId, Email, SecretSerdeValue,
};
use error_stack::ResultExt;
use hyperswitch_masking::Secret;
use serde::{Deserialize, Serialize};
use strum::{Display, EnumString};
use crate::{
errors::{ApiError, ApplicationErrorResponse, ConnectorError},
mandates::{CustomerAcceptance, MandateData},
payment_address::{self, Address, AddressDetails, PhoneDetails},
payment_method_data::{self, Card, PaymentMethodData, PaymentMethodDataTypes},
router_data::{self, ConnectorResponseData, PaymentMethodToken},
router_request_types::{
self, AcceptDisputeIntegrityObject, AuthoriseIntegrityObject, BrowserInformation,
CaptureIntegrityObject, CreateOrderIntegrityObject, DefendDisputeIntegrityObject,
PaymentMethodTokenIntegrityObject, PaymentSynIntegrityObject, PaymentVoidIntegrityObject,
PaymentVoidPostCaptureIntegrityObject, RefundIntegrityObject, RefundSyncIntegrityObject,
RepeatPaymentIntegrityObject, SetupMandateIntegrityObject, SubmitEvidenceIntegrityObject,
SyncRequestType,
},
router_response_types::RedirectForm,
types::{
ConnectorInfo, Connectors, PaymentMethodDataType, PaymentMethodDetails,
PaymentMethodTypeMetadata, SupportedPaymentMethods,
},
utils::{missing_field_err, Error, ForeignTryFrom},
};
use url::Url;
// snake case for enum variants
#[derive(Clone, Copy, Debug, Display, EnumString)]
#[strum(serialize_all = "snake_case")]
pub enum ConnectorEnum {
Adyen,
Razorpay,
RazorpayV2,
Fiserv,
Elavon,
Xendit,
Checkout,
Authorizedotnet,
Mifinity,
Phonepe,
Cashfree,
Paytm,
Fiuu,
Payu,
Cashtocode,
Novalnet,
Nexinets,
Noon,
Braintree,
Volt,
Bluecode,
Cryptopay,
Helcim,
Dlocal,
Placetopay,
Rapyd,
Aci,
Trustpay,
Stripe,
Cybersource,
Worldpay,
Worldpayvantiv,
Payload,
}
impl ForeignTryFrom<grpc_api_types::payments::Connector> for ConnectorEnum {
type Error = ApplicationErrorResponse;
fn foreign_try_from(
connector: grpc_api_types::payments::Connector,
) -> Result<Self, error_stack::Report<Self::Error>> {
match connector {
grpc_api_types::payments::Connector::Adyen => Ok(Self::Adyen),
grpc_api_types::payments::Connector::Razorpay => Ok(Self::Razorpay),
grpc_api_types::payments::Connector::Fiserv => Ok(Self::Fiserv),
grpc_api_types::payments::Connector::Elavon => Ok(Self::Elavon),
grpc_api_types::payments::Connector::Xendit => Ok(Self::Xendit),
grpc_api_types::payments::Connector::Checkout => Ok(Self::Checkout),
grpc_api_types::payments::Connector::Authorizedotnet => Ok(Self::Authorizedotnet),
grpc_api_types::payments::Connector::Phonepe => Ok(Self::Phonepe),
grpc_api_types::payments::Connector::Cashfree => Ok(Self::Cashfree),
grpc_api_types::payments::Connector::Paytm => Ok(Self::Paytm),
grpc_api_types::payments::Connector::Fiuu => Ok(Self::Fiuu),
grpc_api_types::payments::Connector::Payu => Ok(Self::Payu),
grpc_api_types::payments::Connector::Cashtocode => Ok(Self::Cashtocode),
grpc_api_types::payments::Connector::Novalnet => Ok(Self::Novalnet),
grpc_api_types::payments::Connector::Nexinets => Ok(Self::Nexinets),
grpc_api_types::payments::Connector::Noon => Ok(Self::Noon),
grpc_api_types::payments::Connector::Mifinity => Ok(Self::Mifinity),
grpc_api_types::payments::Connector::Braintree => Ok(Self::Braintree),
grpc_api_types::payments::Connector::Volt => Ok(Self::Volt),
grpc_api_types::payments::Connector::Bluecode => Ok(Self::Bluecode),
grpc_api_types::payments::Connector::Cryptopay => Ok(Self::Cryptopay),
grpc_api_types::payments::Connector::Helcim => Ok(Self::Helcim),
grpc_api_types::payments::Connector::Dlocal => Ok(Self::Dlocal),
| {
"chunk": 0,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-6262692988738800615_1 | clm | mini_chunk | // connector-service/backend/domain_types/src/connector_types.rs
grpc_api_types::payments::Connector::Placetopay => Ok(Self::Placetopay),
grpc_api_types::payments::Connector::Rapyd => Ok(Self::Rapyd),
grpc_api_types::payments::Connector::Aci => Ok(Self::Aci),
grpc_api_types::payments::Connector::Trustpay => Ok(Self::Trustpay),
grpc_api_types::payments::Connector::Stripe => Ok(Self::Stripe),
grpc_api_types::payments::Connector::Cybersource => Ok(Self::Cybersource),
grpc_api_types::payments::Connector::Worldpay => Ok(Self::Worldpayvantiv),
grpc_api_types::payments::Connector::Payload => Ok(Self::Payload),
grpc_api_types::payments::Connector::Unspecified => {
Err(ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "UNSPECIFIED_CONNECTOR".to_owned(),
error_identifier: 400,
error_message: "Connector must be specified".to_owned(),
error_object: None,
})
.into())
}
_ => Err(ApplicationErrorResponse::BadRequest(ApiError {
sub_code: "INVALID_CONNECTOR".to_owned(),
error_identifier: 400,
error_message: format!("Connector {connector:?} is not supported"),
error_object: None,
})
.into()),
}
}
}
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, Eq, PartialEq)]
pub struct PaymentId(pub String);
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, Eq, PartialEq)]
pub struct UpdateHistory {
pub connector_mandate_id: Option<String>,
pub payment_method_id: String,
pub original_payment_id: Option<PaymentId>,
}
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, Eq, PartialEq)]
pub struct ConnectorMandateReferenceId {
connector_mandate_id: Option<String>,
payment_method_id: Option<String>,
update_history: Option<Vec<UpdateHistory>>,
mandate_metadata: Option<SecretSerdeValue>,
}
impl ConnectorMandateReferenceId {
pub fn new(
connector_mandate_id: Option<String>,
payment_method_id: Option<String>,
update_history: Option<Vec<UpdateHistory>>,
mandate_metadata: Option<SecretSerdeValue>,
) -> Self {
Self {
connector_mandate_id,
payment_method_id,
update_history,
mandate_metadata,
}
}
pub fn get_connector_mandate_id(&self) -> Option<String> {
self.connector_mandate_id.clone()
}
pub fn get_payment_method_id(&self) -> Option<&String> {
self.payment_method_id.as_ref()
}
pub fn get_update_history(&self) -> Option<&Vec<UpdateHistory>> {
self.update_history.as_ref()
}
pub fn get_mandate_metadata(&self) -> Option<SecretSerdeValue> {
self.mandate_metadata.clone()
}
}
pub trait RawConnectorRequestResponse {
fn set_raw_connector_response(&mut self, response: Option<Secret<String>>);
fn get_raw_connector_response(&self) -> Option<Secret<String>>;
fn set_raw_connector_request(&mut self, request: Option<Secret<String>>);
fn get_raw_connector_request(&self) -> Option<Secret<String>>;
}
pub trait ConnectorResponseHeaders {
fn set_connector_response_headers(&mut self, headers: Option<http::HeaderMap>);
fn get_connector_response_headers(&self) -> Option<&http::HeaderMap>;
fn get_connector_response_headers_as_map(&self) -> std::collections::HashMap<String, String> {
self.get_connector_response_headers()
.map(|headers| {
headers
.iter()
.filter_map(|(name, value)| {
value
.to_str()
.ok()
.map(|v| (name.to_string(), v.to_string()))
})
.collect()
})
.unwrap_or_default()
}
}
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, Eq, PartialEq)]
pub struct NetworkTokenWithNTIRef {
pub network_transaction_id: String,
pub token_exp_month: Option<Secret<String>>,
pub token_exp_year: Option<Secret<String>>,
}
#[derive(Eq, PartialEq, Debug, serde::Deserialize, serde::Serialize, Clone)]
| {
"chunk": 1,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-6262692988738800615_2 | clm | mini_chunk | // connector-service/backend/domain_types/src/connector_types.rs
pub enum MandateReferenceId {
ConnectorMandateId(ConnectorMandateReferenceId), // mandate_id send by connector
NetworkMandateId(String), // network_txns_id send by Issuer to connector, Used for PG agnostic mandate txns along with card data
NetworkTokenWithNTI(NetworkTokenWithNTIRef), // network_txns_id send by Issuer to connector, Used for PG agnostic mandate txns along with network token data
}
#[derive(Default, Eq, PartialEq, Debug, serde::Deserialize, serde::Serialize, Clone)]
pub struct MandateIds {
pub mandate_id: Option<String>,
pub mandate_reference_id: Option<MandateReferenceId>,
}
impl MandateIds {
pub fn is_network_transaction_id_flow(&self) -> bool {
matches!(
self.mandate_reference_id,
Some(MandateReferenceId::NetworkMandateId(_))
)
}
pub fn new(mandate_id: String) -> Self {
Self {
mandate_id: Some(mandate_id),
mandate_reference_id: None,
}
}
}
#[derive(Debug, Default, Clone)]
pub struct PaymentsSyncData {
pub connector_transaction_id: ResponseId,
pub encoded_data: Option<String>,
pub capture_method: Option<common_enums::CaptureMethod>,
pub connector_meta: Option<serde_json::Value>,
pub sync_type: SyncRequestType,
pub mandate_id: Option<MandateIds>,
pub payment_method_type: Option<common_enums::PaymentMethodType>,
pub currency: common_enums::Currency,
pub payment_experience: Option<common_enums::PaymentExperience>,
pub amount: MinorUnit,
pub all_keys_required: Option<bool>,
pub integrity_object: Option<PaymentSynIntegrityObject>,
pub split_payments: Option<SplitPaymentsRequest>,
}
impl PaymentsSyncData {
pub fn is_auto_capture(&self) -> Result<bool, Error> {
match self.capture_method {
Some(common_enums::CaptureMethod::Automatic)
| None
| Some(common_enums::CaptureMethod::SequentialAutomatic) => Ok(true),
Some(common_enums::CaptureMethod::Manual) => Ok(false),
Some(_) => Err(ConnectorError::CaptureMethodNotSupported.into()),
}
}
pub fn get_connector_transaction_id(&self) -> CustomResult<String, ConnectorError> {
match self.connector_transaction_id.clone() {
ResponseId::ConnectorTransactionId(txn_id) => Ok(txn_id),
_ => Err(errors::ValidationError::IncorrectValueProvided {
field_name: "connector_transaction_id",
})
.attach_printable("Expected connector transaction ID not found")
.change_context(ConnectorError::MissingConnectorTransactionID)?,
}
}
}
#[derive(Debug, Clone)]
pub struct PaymentFlowData {
pub merchant_id: common_utils::id_type::MerchantId,
pub customer_id: Option<common_utils::id_type::CustomerId>,
pub connector_customer: Option<String>,
pub payment_id: String,
pub attempt_id: String,
pub status: AttemptStatus,
pub payment_method: PaymentMethod,
pub description: Option<String>,
pub return_url: Option<String>,
pub address: payment_address::PaymentAddress,
pub auth_type: AuthenticationType,
pub connector_meta_data: Option<common_utils::pii::SecretSerdeValue>,
pub amount_captured: Option<i64>,
// minor amount for amount frameworka
pub minor_amount_captured: Option<MinorUnit>,
pub minor_amount_capturable: Option<MinorUnit>,
pub access_token: Option<AccessTokenResponseData>,
pub session_token: Option<String>,
pub reference_id: Option<String>,
pub payment_method_token: Option<PaymentMethodToken>,
pub preprocessing_id: Option<String>,
///for switching between two different versions of the same connector
pub connector_api_version: Option<String>,
/// Contains a reference ID that should be sent in the connector request
pub connector_request_reference_id: String,
pub test_mode: Option<bool>,
pub connector_http_status_code: Option<u16>,
pub connector_response_headers: Option<http::HeaderMap>,
pub external_latency: Option<u128>,
pub connectors: Connectors,
pub raw_connector_response: Option<Secret<String>>,
pub raw_connector_request: Option<Secret<String>>,
pub vault_headers: Option<std::collections::HashMap<String, Secret<String>>>,
| {
"chunk": 2,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-6262692988738800615_3 | clm | mini_chunk | // connector-service/backend/domain_types/src/connector_types.rs
/// This field is used to store various data regarding the response from connector
pub connector_response: Option<ConnectorResponseData>,
pub recurring_mandate_payment_data: Option<RecurringMandatePaymentData>,
}
impl PaymentFlowData {
pub fn set_status(&mut self, status: AttemptStatus) {
self.status = status;
}
pub fn get_billing(&self) -> Result<&Address, Error> {
self.address
.get_payment_method_billing()
.ok_or_else(missing_field_err("billing"))
}
pub fn get_billing_country(&self) -> Result<common_enums::CountryAlpha2, Error> {
self.address
.get_payment_method_billing()
.and_then(|a| a.address.as_ref())
.and_then(|ad| ad.country)
.ok_or_else(missing_field_err(
"payment_method_data.billing.address.country",
))
}
pub fn get_billing_phone(&self) -> Result<&PhoneDetails, Error> {
self.address
.get_payment_method_billing()
.and_then(|a| a.phone.as_ref())
.ok_or_else(missing_field_err("billing.phone"))
}
pub fn get_optional_billing(&self) -> Option<&Address> {
self.address.get_payment_method_billing()
}
pub fn get_optional_shipping(&self) -> Option<&Address> {
self.address.get_shipping()
}
pub fn get_optional_shipping_first_name(&self) -> Option<Secret<String>> {
self.address.get_shipping().and_then(|shipping_address| {
shipping_address
.clone()
.address
.and_then(|shipping_details| shipping_details.first_name)
})
}
pub fn get_optional_shipping_last_name(&self) -> Option<Secret<String>> {
self.address.get_shipping().and_then(|shipping_address| {
shipping_address
.clone()
.address
.and_then(|shipping_details| shipping_details.last_name)
})
}
pub fn get_optional_shipping_line1(&self) -> Option<Secret<String>> {
self.address.get_shipping().and_then(|shipping_address| {
shipping_address
.clone()
.address
.and_then(|shipping_details| shipping_details.line1)
})
}
pub fn get_optional_shipping_line2(&self) -> Option<Secret<String>> {
self.address.get_shipping().and_then(|shipping_address| {
shipping_address
.clone()
.address
.and_then(|shipping_details| shipping_details.line2)
})
}
pub fn get_optional_shipping_city(&self) -> Option<String> {
self.address.get_shipping().and_then(|shipping_address| {
shipping_address
.clone()
.address
.and_then(|shipping_details| shipping_details.city)
})
}
pub fn get_optional_shipping_state(&self) -> Option<Secret<String>> {
self.address.get_shipping().and_then(|shipping_address| {
shipping_address
.clone()
.address
.and_then(|shipping_details| shipping_details.state)
})
}
pub fn get_optional_shipping_full_name(&self) -> Option<Secret<String>> {
self.get_optional_shipping()
.and_then(|shipping_details| shipping_details.address.as_ref())
.and_then(|shipping_address| shipping_address.get_optional_full_name())
}
pub fn get_optional_shipping_country(&self) -> Option<common_enums::CountryAlpha2> {
self.address.get_shipping().and_then(|shipping_address| {
shipping_address
.clone()
.address
.and_then(|shipping_details| shipping_details.country)
})
}
pub fn get_optional_shipping_zip(&self) -> Option<Secret<String>> {
self.address.get_shipping().and_then(|shipping_address| {
shipping_address
.clone()
.address
.and_then(|shipping_details| shipping_details.zip)
})
}
pub fn get_optional_shipping_email(&self) -> Option<Email> {
self.address
.get_shipping()
.and_then(|shipping_address| shipping_address.clone().email)
}
| {
"chunk": 3,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-6262692988738800615_4 | clm | mini_chunk | // connector-service/backend/domain_types/src/connector_types.rs
pub fn get_optional_shipping_phone_number(&self) -> Option<Secret<String>> {
self.address
.get_shipping()
.and_then(|shipping_address| shipping_address.clone().phone)
.and_then(|phone_details| phone_details.get_number_with_country_code().ok())
}
pub fn get_description(&self) -> Result<String, Error> {
self.description
.clone()
.ok_or_else(missing_field_err("description"))
}
pub fn get_billing_address(&self) -> Result<&AddressDetails, Error> {
self.address
.get_payment_method_billing()
.as_ref()
.and_then(|a| a.address.as_ref())
.ok_or_else(missing_field_err("billing.address"))
}
pub fn get_connector_meta(&self) -> Result<SecretSerdeValue, Error> {
self.connector_meta_data
.clone()
.ok_or_else(missing_field_err("connector_meta_data"))
}
pub fn get_session_token(&self) -> Result<String, Error> {
self.session_token
.clone()
.ok_or_else(missing_field_err("session_token"))
}
pub fn get_access_token(&self) -> Result<String, Error> {
self.access_token
.as_ref()
.map(|token_data| token_data.access_token.clone())
.ok_or_else(missing_field_err("access_token"))
}
pub fn get_access_token_data(&self) -> Result<AccessTokenResponseData, Error> {
self.access_token
.clone()
.ok_or_else(missing_field_err("access_token"))
}
pub fn set_access_token(mut self, access_token: Option<AccessTokenResponseData>) -> Self {
self.access_token = access_token;
self
}
pub fn get_billing_first_name(&self) -> Result<Secret<String>, Error> {
self.address
.get_payment_method_billing()
.and_then(|billing_address| {
billing_address
.clone()
.address
.and_then(|billing_details| billing_details.first_name.clone())
})
.ok_or_else(missing_field_err(
"payment_method_data.billing.address.first_name",
))
}
pub fn get_billing_full_name(&self) -> Result<Secret<String>, Error> {
self.get_optional_billing()
.and_then(|billing_details| billing_details.address.as_ref())
.and_then(|billing_address| billing_address.get_optional_full_name())
.ok_or_else(missing_field_err(
"payment_method_data.billing.address.first_name",
))
}
pub fn get_billing_last_name(&self) -> Result<Secret<String>, Error> {
self.address
.get_payment_method_billing()
.and_then(|billing_address| {
billing_address
.clone()
.address
.and_then(|billing_details| billing_details.last_name.clone())
})
.ok_or_else(missing_field_err(
"payment_method_data.billing.address.last_name",
))
}
pub fn get_billing_line1(&self) -> Result<Secret<String>, Error> {
self.address
.get_payment_method_billing()
.and_then(|billing_address| {
billing_address
.clone()
.address
.and_then(|billing_details| billing_details.line1.clone())
})
.ok_or_else(missing_field_err(
"payment_method_data.billing.address.line1",
))
}
pub fn get_billing_city(&self) -> Result<String, Error> {
self.address
.get_payment_method_billing()
.and_then(|billing_address| {
billing_address
.clone()
.address
.and_then(|billing_details| billing_details.city)
})
.ok_or_else(missing_field_err(
"payment_method_data.billing.address.city",
))
}
pub fn get_billing_email(&self) -> Result<Email, Error> {
self.address
.get_payment_method_billing()
.and_then(|billing_address| billing_address.email.clone())
.ok_or_else(missing_field_err("payment_method_data.billing.email"))
}
| {
"chunk": 4,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-6262692988738800615_5 | clm | mini_chunk | // connector-service/backend/domain_types/src/connector_types.rs
pub fn get_billing_phone_number(&self) -> Result<Secret<String>, Error> {
self.address
.get_payment_method_billing()
.and_then(|billing_address| billing_address.clone().phone)
.map(|phone_details| phone_details.get_number_with_country_code())
.transpose()?
.ok_or_else(missing_field_err("payment_method_data.billing.phone"))
}
pub fn get_optional_billing_line1(&self) -> Option<Secret<String>> {
self.address
.get_payment_method_billing()
.and_then(|billing_address| {
billing_address
.clone()
.address
.and_then(|billing_details| billing_details.line1)
})
}
pub fn get_optional_billing_line2(&self) -> Option<Secret<String>> {
self.address
.get_payment_method_billing()
.and_then(|billing_address| {
billing_address
.clone()
.address
.and_then(|billing_details| billing_details.line2)
})
}
pub fn get_optional_billing_city(&self) -> Option<String> {
self.address
.get_payment_method_billing()
.and_then(|billing_address| {
billing_address
.clone()
.address
.and_then(|billing_details| billing_details.city)
})
}
pub fn get_optional_billing_country(&self) -> Option<common_enums::CountryAlpha2> {
self.address
.get_payment_method_billing()
.and_then(|billing_address| {
billing_address
.clone()
.address
.and_then(|billing_details| billing_details.country)
})
}
pub fn get_optional_billing_zip(&self) -> Option<Secret<String>> {
self.address
.get_payment_method_billing()
.and_then(|billing_address| {
billing_address
.clone()
.address
.and_then(|billing_details| billing_details.zip)
})
}
pub fn get_optional_billing_state(&self) -> Option<Secret<String>> {
self.address
.get_payment_method_billing()
.and_then(|billing_address| {
billing_address
.clone()
.address
.and_then(|billing_details| billing_details.state)
})
}
pub fn get_optional_billing_first_name(&self) -> Option<Secret<String>> {
self.address
.get_payment_method_billing()
.and_then(|billing_address| {
billing_address
.clone()
.address
.and_then(|billing_details| billing_details.first_name)
})
}
pub fn get_optional_billing_last_name(&self) -> Option<Secret<String>> {
self.address
.get_payment_method_billing()
.and_then(|billing_address| {
billing_address
.clone()
.address
.and_then(|billing_details| billing_details.last_name)
})
}
pub fn get_optional_billing_phone_number(&self) -> Option<Secret<String>> {
self.address
.get_payment_method_billing()
.and_then(|billing_address| {
billing_address
.clone()
.phone
.and_then(|phone_data| phone_data.number)
})
}
pub fn get_optional_billing_email(&self) -> Option<Email> {
self.address
.get_payment_method_billing()
.and_then(|billing_address| billing_address.clone().email)
}
pub fn to_connector_meta<T>(&self) -> Result<T, Error>
where
T: serde::de::DeserializeOwned,
{
self.get_connector_meta()?
.parse_value(std::any::type_name::<T>())
.change_context(ConnectorError::NoConnectorMetaData)
}
pub fn is_three_ds(&self) -> bool {
matches!(self.auth_type, common_enums::AuthenticationType::ThreeDs)
}
pub fn get_shipping_address(&self) -> Result<&AddressDetails, Error> {
| {
"chunk": 5,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-6262692988738800615_6 | clm | mini_chunk | // connector-service/backend/domain_types/src/connector_types.rs
self.address
.get_shipping()
.and_then(|a| a.address.as_ref())
.ok_or_else(missing_field_err("shipping.address"))
}
pub fn get_shipping_address_with_phone_number(&self) -> Result<&Address, Error> {
self.address
.get_shipping()
.ok_or_else(missing_field_err("shipping"))
}
pub fn get_payment_method_token(&self) -> Result<PaymentMethodToken, Error> {
self.payment_method_token
.clone()
.ok_or_else(missing_field_err("payment_method_token"))
}
pub fn get_customer_id(&self) -> Result<CustomerId, Error> {
self.customer_id
.to_owned()
.ok_or_else(missing_field_err("customer_id"))
}
pub fn get_connector_customer_id(&self) -> Result<String, Error> {
self.connector_customer
.to_owned()
.ok_or_else(missing_field_err("connector_customer_id"))
}
pub fn get_preprocessing_id(&self) -> Result<String, Error> {
self.preprocessing_id
.to_owned()
.ok_or_else(missing_field_err("preprocessing_id"))
}
pub fn get_optional_billing_full_name(&self) -> Option<Secret<String>> {
self.get_optional_billing()
.and_then(|billing_details| billing_details.address.as_ref())
.and_then(|billing_address| billing_address.get_optional_full_name())
}
pub fn set_order_reference_id(mut self, reference_id: Option<String>) -> Self {
if reference_id.is_some() && self.reference_id.is_none() {
self.reference_id = reference_id;
}
self
}
pub fn set_session_token_id(mut self, session_token_id: Option<String>) -> Self {
if session_token_id.is_some() && self.session_token.is_none() {
self.session_token = session_token_id;
}
self
}
pub fn set_payment_method_token(mut self, payment_method_token: Option<String>) -> Self {
if payment_method_token.is_some() && self.payment_method_token.is_none() {
self.payment_method_token =
payment_method_token.map(|token| PaymentMethodToken::Token(Secret::new(token)));
}
self
}
pub fn set_connector_customer_id(mut self, connector_customer_id: Option<String>) -> Self {
if connector_customer_id.is_some() && self.connector_customer.is_none() {
self.connector_customer = connector_customer_id;
}
self
}
pub fn set_access_token_id(mut self, access_token_id: Option<String>) -> Self {
if let (Some(token_id), None) = (access_token_id, &self.access_token) {
self.access_token = Some(AccessTokenResponseData {
access_token: token_id,
token_type: None,
expires_in: None,
});
}
self
}
pub fn get_return_url(&self) -> Option<String> {
self.return_url.clone()
}
// Helper methods for additional headers
pub fn get_header(&self, key: &str) -> Option<&Secret<String>> {
self.vault_headers.as_ref().and_then(|h| h.get(key))
}
}
impl RawConnectorRequestResponse for PaymentFlowData {
fn set_raw_connector_response(&mut self, response: Option<Secret<String>>) {
self.raw_connector_response = response;
}
fn get_raw_connector_response(&self) -> Option<Secret<String>> {
self.raw_connector_response.clone()
}
fn get_raw_connector_request(&self) -> Option<Secret<String>> {
self.raw_connector_request.clone()
}
fn set_raw_connector_request(&mut self, request: Option<Secret<String>>) {
self.raw_connector_request = request;
}
}
impl ConnectorResponseHeaders for PaymentFlowData {
fn set_connector_response_headers(&mut self, headers: Option<http::HeaderMap>) {
self.connector_response_headers = headers;
}
fn get_connector_response_headers(&self) -> Option<&http::HeaderMap> {
self.connector_response_headers.as_ref()
}
}
#[derive(Debug, Clone)]
pub struct PaymentVoidData {
pub connector_transaction_id: String,
pub cancellation_reason: Option<String>,
pub integrity_object: Option<PaymentVoidIntegrityObject>,
pub raw_connector_response: Option<String>,
pub browser_info: Option<BrowserInformation>,
| {
"chunk": 6,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-6262692988738800615_7 | clm | mini_chunk | // connector-service/backend/domain_types/src/connector_types.rs
pub amount: Option<MinorUnit>,
pub currency: Option<Currency>,
pub connector_metadata: Option<common_utils::pii::SecretSerdeValue>,
}
impl PaymentVoidData {
// fn get_amount(&self) -> Result<i64, Error> {
// self.amount.ok_or_else(missing_field_err("amount"))
// }
// fn get_currency(&self) -> Result<common_enums::Currency, Error> {
// self.currency.ok_or_else(missing_field_err("currency"))
// }
pub fn get_cancellation_reason(&self) -> Result<String, Error> {
self.cancellation_reason
.clone()
.ok_or_else(missing_field_err("cancellation_reason"))
}
// fn get_browser_info(&self) -> Result<BrowserInformation, Error> {
// self.browser_info
// .clone()
// .ok_or_else(missing_field_err("browser_info"))
// }
pub fn get_optional_language_from_browser_info(&self) -> Option<String> {
self.browser_info
.clone()
.and_then(|browser_info| browser_info.language)
}
pub fn get_ip_address_as_optional(&self) -> Option<Secret<String, IpAddress>> {
self.browser_info.clone().and_then(|browser_info| {
browser_info
.ip_address
.map(|ip| Secret::new(ip.to_string()))
})
}
pub fn get_ip_address(&self) -> Result<Secret<String, IpAddress>, Error> {
self.get_ip_address_as_optional()
.ok_or_else(missing_field_err("browser_info.ip_address"))
}
}
#[derive(Debug, Clone)]
pub struct PaymentsCancelPostCaptureData {
pub connector_transaction_id: String,
pub cancellation_reason: Option<String>,
pub integrity_object: Option<PaymentVoidPostCaptureIntegrityObject>,
pub raw_connector_response: Option<String>,
pub browser_info: Option<BrowserInformation>,
}
impl PaymentsCancelPostCaptureData {
pub fn get_cancellation_reason(&self) -> Result<String, Error> {
self.cancellation_reason
.clone()
.ok_or_else(missing_field_err("cancellation_reason"))
}
pub fn get_optional_language_from_browser_info(&self) -> Option<String> {
self.browser_info
.clone()
.and_then(|browser_info| browser_info.language)
}
}
#[derive(Debug, Clone)]
pub struct PaymentsAuthorizeData<T: PaymentMethodDataTypes> {
pub payment_method_data: payment_method_data::PaymentMethodData<T>,
/// total amount (original_amount + surcharge_amount + tax_on_surcharge_amount)
/// If connector supports separate field for surcharge amount, consider using below functions defined on `PaymentsAuthorizeData` to fetch original amount and surcharge amount separately
/// ```text
/// get_original_amount()
/// get_surcharge_amount()
/// get_tax_on_surcharge_amount()
/// get_total_surcharge_amount() // returns surcharge_amount + tax_on_surcharge_amount
/// ```
pub amount: i64,
pub order_tax_amount: Option<MinorUnit>,
pub email: Option<common_utils::pii::Email>,
pub customer_name: Option<String>,
pub currency: Currency,
pub confirm: bool,
pub statement_descriptor_suffix: Option<String>,
pub statement_descriptor: Option<String>,
pub capture_method: Option<common_enums::CaptureMethod>,
pub router_return_url: Option<String>,
pub webhook_url: Option<String>,
pub complete_authorize_url: Option<String>,
// Mandates
pub mandate_id: Option<MandateIds>,
pub setup_future_usage: Option<common_enums::FutureUsage>,
pub off_session: Option<bool>,
pub browser_info: Option<BrowserInformation>,
pub order_category: Option<String>,
pub session_token: Option<String>,
pub access_token: Option<AccessTokenResponseData>,
pub customer_acceptance: Option<CustomerAcceptance>,
pub enrolled_for_3ds: bool,
pub related_transaction_id: Option<String>,
pub payment_experience: Option<common_enums::PaymentExperience>,
pub payment_method_type: Option<common_enums::PaymentMethodType>,
pub customer_id: Option<common_utils::id_type::CustomerId>,
pub request_incremental_authorization: bool,
pub metadata: Option<serde_json::Value>,
pub authentication_data: Option<router_request_types::AuthenticationData>,
pub split_payments: Option<SplitPaymentsRequest>,
// New amount for amount frame work
| {
"chunk": 7,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-6262692988738800615_8 | clm | mini_chunk | // connector-service/backend/domain_types/src/connector_types.rs
pub minor_amount: MinorUnit,
/// Merchant's identifier for the payment/invoice. This will be sent to the connector
/// if the connector provides support to accept multiple reference ids.
/// In case the connector supports only one reference id, Hyperswitch's Payment ID will be sent as reference.
pub merchant_order_reference_id: Option<String>,
pub shipping_cost: Option<MinorUnit>,
pub merchant_account_id: Option<String>,
pub integrity_object: Option<AuthoriseIntegrityObject>,
pub merchant_config_currency: Option<common_enums::Currency>,
pub all_keys_required: Option<bool>,
pub request_extended_authorization: Option<bool>,
pub enable_overcapture: Option<bool>,
pub setup_mandate_details: Option<MandateData>,
pub merchant_account_metadata: Option<common_utils::pii::SecretSerdeValue>,
}
impl<T: PaymentMethodDataTypes> PaymentsAuthorizeData<T> {
pub fn is_auto_capture(&self) -> Result<bool, Error> {
match self.capture_method {
Some(common_enums::CaptureMethod::Automatic)
| None
| Some(common_enums::CaptureMethod::SequentialAutomatic) => Ok(true),
Some(common_enums::CaptureMethod::Manual) => Ok(false),
Some(_) => Err(ConnectorError::CaptureMethodNotSupported.into()),
}
}
pub fn get_email(&self) -> Result<Email, Error> {
self.email.clone().ok_or_else(missing_field_err("email"))
}
pub fn get_optional_email(&self) -> Option<Email> {
self.email.clone()
}
pub fn get_browser_info(&self) -> Result<BrowserInformation, Error> {
self.browser_info
.clone()
.ok_or_else(missing_field_err("browser_info"))
}
pub fn get_optional_language_from_browser_info(&self) -> Option<String> {
self.browser_info
.clone()
.and_then(|browser_info| browser_info.language)
}
// pub fn get_order_details(&self) -> Result<Vec<OrderDetailsWithAmount>, Error> {
// self.order_details
// .clone()
// .ok_or_else(missing_field_err("order_details"))
// }
pub fn get_card(&self) -> Result<Card<T>, Error> {
match &self.payment_method_data {
PaymentMethodData::Card(card) => Ok(card.clone()),
_ => Err(missing_field_err("card")()),
}
}
pub fn get_complete_authorize_url(&self) -> Result<String, Error> {
self.complete_authorize_url
.clone()
.ok_or_else(missing_field_err("complete_authorize_url"))
}
pub fn connector_mandate_id(&self) -> Option<String> {
self.mandate_id
.as_ref()
.and_then(|mandate_ids| match &mandate_ids.mandate_reference_id {
Some(MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => {
connector_mandate_ids.get_connector_mandate_id()
}
Some(MandateReferenceId::NetworkMandateId(_))
| None
| Some(MandateReferenceId::NetworkTokenWithNTI(_)) => None,
})
}
pub fn get_optional_network_transaction_id(&self) -> Option<String> {
self.mandate_id
.as_ref()
.and_then(|mandate_ids| match &mandate_ids.mandate_reference_id {
Some(MandateReferenceId::NetworkMandateId(network_transaction_id)) => {
Some(network_transaction_id.clone())
}
Some(MandateReferenceId::ConnectorMandateId(_))
| Some(MandateReferenceId::NetworkTokenWithNTI(_))
| None => None,
})
}
pub fn is_mandate_payment(&self) -> bool {
((self.customer_acceptance.is_some() || self.setup_mandate_details.is_some())
&& self.setup_future_usage == Some(common_enums::FutureUsage::OffSession))
|| self
.mandate_id
.as_ref()
.and_then(|mandate_ids| mandate_ids.mandate_reference_id.as_ref())
.is_some()
}
// fn is_cit_mandate_payment(&self) -> bool {
// (self.customer_acceptance.is_some() || self.setup_mandate_details.is_some())
// && self.setup_future_usage == Some(storage_enums::FutureUsage::OffSession)
// }
| {
"chunk": 8,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-6262692988738800615_9 | clm | mini_chunk | // connector-service/backend/domain_types/src/connector_types.rs
pub fn get_webhook_url(&self) -> Result<String, Error> {
self.webhook_url
.clone()
.ok_or_else(missing_field_err("webhook_url"))
}
pub fn get_router_return_url(&self) -> Result<String, Error> {
self.router_return_url
.clone()
.ok_or_else(missing_field_err("return_url"))
}
pub fn is_wallet(&self) -> bool {
matches!(self.payment_method_data, PaymentMethodData::Wallet(_))
}
pub fn is_card(&self) -> bool {
matches!(self.payment_method_data, PaymentMethodData::Card(_))
}
pub fn get_payment_method_type(&self) -> Result<common_enums::PaymentMethodType, Error> {
self.payment_method_type
.to_owned()
.ok_or_else(missing_field_err("payment_method_type"))
}
pub fn get_connector_mandate_id(&self) -> Result<String, Error> {
self.connector_mandate_id()
.ok_or_else(missing_field_err("connector_mandate_id"))
}
pub fn get_ip_address_as_optional(&self) -> Option<Secret<String, IpAddress>> {
self.browser_info.clone().and_then(|browser_info| {
browser_info
.ip_address
.map(|ip| Secret::new(ip.to_string()))
})
}
pub fn get_ip_address(&self) -> Result<Secret<String, IpAddress>, Error> {
self.get_ip_address_as_optional()
.ok_or_else(missing_field_err("browser_info.ip_address"))
}
// fn get_original_amount(&self) -> i64 {
// self.surcharge_details
// .as_ref()
// .map(|surcharge_details| surcharge_details.original_amount.get_amount_as_i64())
// .unwrap_or(self.amount)
// }
// fn get_surcharge_amount(&self) -> Option<i64> {
// self.surcharge_details
// .as_ref()
// .map(|surcharge_details| surcharge_details.surcharge_amount.get_amount_as_i64())
// }
// fn get_tax_on_surcharge_amount(&self) -> Option<i64> {
// self.surcharge_details.as_ref().map(|surcharge_details| {
// surcharge_details
// .tax_on_surcharge_amount
// .get_amount_as_i64()
// })
// }
// fn get_total_surcharge_amount(&self) -> Option<i64> {
// self.surcharge_details.as_ref().map(|surcharge_details| {
// surcharge_details
// .get_total_surcharge_amount()
// .get_amount_as_i64()
// })
// }
pub fn is_customer_initiated_mandate_payment(&self) -> bool {
(self.customer_acceptance.is_some() || self.setup_mandate_details.is_some())
&& self.setup_future_usage == Some(common_enums::FutureUsage::OffSession)
}
pub fn get_metadata_as_object(&self) -> Option<SecretSerdeValue> {
self.metadata.clone().and_then(|meta_data| match meta_data {
serde_json::Value::Null
| serde_json::Value::Bool(_)
| serde_json::Value::Number(_)
| serde_json::Value::String(_)
| serde_json::Value::Array(_) => None,
serde_json::Value::Object(_) => Some(meta_data.into()),
})
}
// fn get_authentication_data(&self) -> Result<AuthenticationData, Error> {
// self.authentication_data
// .clone()
// .ok_or_else(missing_field_err("authentication_data"))
// }
// fn get_connector_mandate_request_reference_id(&self) -> Result<String, Error> {
// self.mandate_id
// .as_ref()
// .and_then(|mandate_ids| match &mandate_ids.mandate_reference_id {
// Some(MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => {
// connector_mandate_ids.get_connector_mandate_request_reference_id()
// }
// Some(MandateReferenceId::NetworkMandateId(_))
// | None
// | Some(MandateReferenceId::NetworkTokenWithNTI(_)) => None,
// })
// .ok_or_else(missing_field_err("connector_mandate_request_reference_id"))
// }
pub fn set_session_token(mut self, session_token: Option<String>) -> Self {
self.session_token = session_token;
self
}
pub fn set_access_token(mut self, access_token: Option<String>) -> Self {
| {
"chunk": 9,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-6262692988738800615_10 | clm | mini_chunk | // connector-service/backend/domain_types/src/connector_types.rs
self.access_token = access_token.map(|token| AccessTokenResponseData {
access_token: token,
token_type: None,
expires_in: None,
});
self
}
pub fn get_access_token_optional(&self) -> Option<&String> {
self.access_token
.as_ref()
.map(|token_data| &token_data.access_token)
}
}
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub enum ResponseId {
ConnectorTransactionId(String),
EncodedData(String),
#[default]
NoResponseId,
}
impl ResponseId {
pub fn get_connector_transaction_id(
&self,
) -> errors::CustomResult<String, errors::ValidationError> {
match self {
Self::ConnectorTransactionId(txn_id) => Ok(txn_id.to_string()),
_ => Err(errors::ValidationError::IncorrectValueProvided {
field_name: "connector_transaction_id",
})
.attach_printable("Expected connector transaction ID not found"),
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum PaymentsResponseData {
TransactionResponse {
resource_id: ResponseId,
redirection_data: Option<Box<RedirectForm>>,
connector_metadata: Option<serde_json::Value>,
mandate_reference: Option<Box<MandateReference>>,
network_txn_id: Option<String>,
connector_response_reference_id: Option<String>,
incremental_authorization_allowed: Option<bool>,
status_code: u16,
},
SessionResponse {
session_token: String,
status_code: u16,
},
PreAuthenticateResponse {
/// For Device Data Collection
redirection_data: Option<Box<RedirectForm>>,
connector_response_reference_id: Option<String>,
status_code: u16,
},
AuthenticateResponse {
/// For friction flow
redirection_data: Option<Box<RedirectForm>>,
/// For frictionles flow
authentication_data: Option<router_request_types::AuthenticationData>,
connector_response_reference_id: Option<String>,
status_code: u16,
},
PostAuthenticateResponse {
authentication_data: Option<router_request_types::AuthenticationData>,
connector_response_reference_id: Option<String>,
status_code: u16,
},
}
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)]
pub struct MandateReference {
pub connector_mandate_id: Option<String>,
pub payment_method_id: Option<String>,
}
#[derive(Debug, Clone)]
pub struct PaymentCreateOrderData {
pub amount: MinorUnit,
pub currency: Currency,
pub integrity_object: Option<CreateOrderIntegrityObject>,
pub metadata: Option<serde_json::Value>,
pub webhook_url: Option<String>,
}
#[derive(Debug, Clone)]
pub struct PaymentCreateOrderResponse {
pub order_id: String,
}
#[derive(Debug, Clone)]
pub struct PaymentMethodTokenizationData<T: PaymentMethodDataTypes> {
pub payment_method_data: payment_method_data::PaymentMethodData<T>,
pub browser_info: Option<BrowserInformation>,
pub currency: Currency,
pub amount: MinorUnit,
pub customer_acceptance: Option<CustomerAcceptance>,
pub setup_future_usage: Option<common_enums::FutureUsage>,
pub setup_mandate_details: Option<MandateData>,
pub mandate_id: Option<MandateIds>,
pub integrity_object: Option<PaymentMethodTokenIntegrityObject>,
// pub split_payments: Option<SplitPaymentsRequest>,
}
#[derive(Debug, Clone)]
pub struct PaymentMethodTokenResponse {
pub token: String,
}
#[derive(Debug, Clone)]
pub struct PaymentsPreAuthenticateData<T: PaymentMethodDataTypes> {
pub payment_method_data: Option<payment_method_data::PaymentMethodData<T>>,
pub amount: MinorUnit,
pub email: Option<Email>,
pub currency: Option<Currency>,
pub payment_method_type: Option<PaymentMethodType>,
pub router_return_url: Option<Url>,
pub continue_redirection_url: Option<Url>,
pub browser_info: Option<BrowserInformation>,
pub enrolled_for_3ds: bool,
pub redirect_response: Option<ContinueRedirectionResponse>,
}
#[derive(Debug, Clone)]
pub struct PaymentsAuthenticateData<T: PaymentMethodDataTypes> {
pub payment_method_data: Option<payment_method_data::PaymentMethodData<T>>,
pub amount: MinorUnit,
pub email: Option<Email>,
pub currency: Option<Currency>,
| {
"chunk": 10,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-6262692988738800615_11 | clm | mini_chunk | // connector-service/backend/domain_types/src/connector_types.rs
pub payment_method_type: Option<PaymentMethodType>,
pub router_return_url: Option<Url>,
pub continue_redirection_url: Option<Url>,
pub browser_info: Option<BrowserInformation>,
pub enrolled_for_3ds: bool,
pub redirect_response: Option<ContinueRedirectionResponse>,
}
#[derive(Debug, Clone)]
pub struct PaymentsPostAuthenticateData<T: PaymentMethodDataTypes> {
pub payment_method_data: Option<payment_method_data::PaymentMethodData<T>>,
pub amount: MinorUnit,
pub email: Option<Email>,
pub currency: Option<Currency>,
pub payment_method_type: Option<PaymentMethodType>,
pub router_return_url: Option<Url>,
pub continue_redirection_url: Option<Url>,
pub browser_info: Option<BrowserInformation>,
pub enrolled_for_3ds: bool,
pub redirect_response: Option<ContinueRedirectionResponse>,
}
#[derive(Debug, Clone)]
pub struct ContinueRedirectionResponse {
pub params: Option<Secret<String>>,
pub payload: Option<SecretSerdeValue>,
}
#[derive(Debug, Clone)]
pub struct SessionTokenRequestData {
pub amount: MinorUnit,
pub currency: Currency,
}
#[derive(Debug, Clone)]
pub struct SessionTokenResponseData {
pub session_token: String,
}
#[derive(Debug, Clone)]
pub struct AccessTokenRequestData {
pub grant_type: String,
}
#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)]
pub struct AccessTokenResponseData {
pub access_token: String,
pub token_type: Option<String>,
pub expires_in: Option<i64>,
}
#[derive(Debug, Clone)]
pub struct ConnectorCustomerData {
pub customer_id: Option<Secret<String>>,
pub email: Option<Secret<Email>>,
pub name: Option<Secret<String>>,
pub description: Option<String>,
pub phone: Option<Secret<String>>,
pub preprocessing_id: Option<String>,
pub split_payments: Option<SplitPaymentsRequest>,
}
#[derive(Debug, Clone)]
pub struct ConnectorCustomerResponse {
pub connector_customer_id: String,
}
#[derive(Debug, Default, Clone)]
pub struct RefundSyncData {
pub connector_transaction_id: String,
pub connector_refund_id: String,
pub reason: Option<String>,
pub refund_connector_metadata: Option<common_utils::pii::SecretSerdeValue>,
pub refund_status: common_enums::RefundStatus,
pub all_keys_required: Option<bool>,
pub integrity_object: Option<RefundSyncIntegrityObject>,
pub browser_info: Option<BrowserInformation>,
/// Charges associated with the payment
pub split_refunds: Option<SplitRefundsRequest>,
}
impl RefundSyncData {
pub fn get_optional_language_from_browser_info(&self) -> Option<String> {
self.browser_info
.clone()
.and_then(|browser_info| browser_info.language)
}
}
#[derive(Debug, Clone)]
pub struct RefundsResponseData {
pub connector_refund_id: String,
pub refund_status: common_enums::RefundStatus,
pub status_code: u16,
}
#[derive(Debug, Clone)]
pub struct RefundFlowData {
pub status: common_enums::RefundStatus,
pub refund_id: Option<String>,
pub connectors: Connectors,
pub connector_request_reference_id: String,
pub raw_connector_response: Option<Secret<String>>,
pub connector_response_headers: Option<http::HeaderMap>,
pub raw_connector_request: Option<Secret<String>>,
}
impl RawConnectorRequestResponse for RefundFlowData {
fn set_raw_connector_response(&mut self, response: Option<Secret<String>>) {
self.raw_connector_response = response;
}
fn get_raw_connector_response(&self) -> Option<Secret<String>> {
self.raw_connector_response.clone()
}
fn get_raw_connector_request(&self) -> Option<Secret<String>> {
self.raw_connector_request.clone()
}
fn set_raw_connector_request(&mut self, request: Option<Secret<String>>) {
self.raw_connector_request = request;
}
}
impl ConnectorResponseHeaders for RefundFlowData {
fn set_connector_response_headers(&mut self, headers: Option<http::HeaderMap>) {
self.connector_response_headers = headers;
}
fn get_connector_response_headers(&self) -> Option<&http::HeaderMap> {
self.connector_response_headers.as_ref()
}
}
#[derive(Debug, Clone)]
pub struct WebhookDetailsResponse {
pub resource_id: Option<ResponseId>,
pub status: common_enums::AttemptStatus,
pub connector_response_reference_id: Option<String>,
| {
"chunk": 11,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-6262692988738800615_12 | clm | mini_chunk | // connector-service/backend/domain_types/src/connector_types.rs
pub mandate_reference: Option<Box<MandateReference>>,
pub error_code: Option<String>,
pub error_message: Option<String>,
pub error_reason: Option<String>,
pub raw_connector_response: Option<String>,
pub status_code: u16,
pub response_headers: Option<http::HeaderMap>,
pub transformation_status: common_enums::WebhookTransformationStatus,
pub amount_captured: Option<i64>,
// minor amount for amount framework
pub minor_amount_captured: Option<MinorUnit>,
pub network_txn_id: Option<String>,
}
#[derive(Debug, Clone)]
pub struct RefundWebhookDetailsResponse {
pub connector_refund_id: Option<String>,
pub status: common_enums::RefundStatus,
pub connector_response_reference_id: Option<String>,
pub error_code: Option<String>,
pub error_message: Option<String>,
pub raw_connector_response: Option<String>,
pub status_code: u16,
pub response_headers: Option<http::HeaderMap>,
}
#[derive(Debug, Clone)]
pub struct DisputeWebhookDetailsResponse {
pub amount: StringMinorUnit,
pub currency: common_enums::enums::Currency,
pub dispute_id: String,
pub status: common_enums::DisputeStatus,
pub stage: common_enums::DisputeStage,
pub connector_response_reference_id: Option<String>,
pub dispute_message: Option<String>,
pub raw_connector_response: Option<String>,
pub status_code: u16,
pub response_headers: Option<http::HeaderMap>,
/// connector_reason
pub connector_reason_code: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum HttpMethod {
Options,
Get,
Post,
Put,
Delete,
Head,
Trace,
Connect,
Patch,
}
#[derive(Debug, Clone)]
pub struct RequestDetails {
pub method: HttpMethod,
pub uri: Option<String>,
pub headers: HashMap<String, String>,
pub body: Vec<u8>,
pub query_params: Option<String>,
}
#[derive(Debug, Clone)]
pub struct ConnectorWebhookSecrets {
pub secret: Vec<u8>,
pub additional_secret: Option<hyperswitch_masking::Secret<String>>,
}
#[derive(Debug, Clone, PartialEq)]
pub enum EventType {
// Payment intent events
PaymentIntentFailure,
PaymentIntentSuccess,
PaymentIntentProcessing,
PaymentIntentPartiallyFunded,
PaymentIntentCancelled,
PaymentIntentCancelFailure,
PaymentIntentAuthorizationSuccess,
PaymentIntentAuthorizationFailure,
PaymentIntentCaptureSuccess,
PaymentIntentCaptureFailure,
PaymentIntentExpired,
PaymentActionRequired,
// Source events
SourceChargeable,
SourceTransactionCreated,
// Refund events
RefundFailure,
RefundSuccess,
// Dispute events
DisputeOpened,
DisputeExpired,
DisputeAccepted,
DisputeCancelled,
DisputeChallenged,
DisputeWon,
DisputeLost,
// Mandate events
MandateActive,
MandateRevoked,
// Misc events
EndpointVerification,
ExternalAuthenticationAres,
FrmApproved,
FrmRejected,
// Payout events
PayoutSuccess,
PayoutFailure,
PayoutProcessing,
PayoutCancelled,
PayoutCreated,
PayoutExpired,
PayoutReversed,
// Recovery events
RecoveryPaymentFailure,
RecoveryPaymentSuccess,
RecoveryPaymentPending,
RecoveryInvoiceCancel,
IncomingWebhookEventUnspecified,
// Legacy broad categories (for backward compatibility)
Payment,
Refund,
Dispute,
}
impl EventType {
/// Returns true if this event type is payment-related
pub fn is_payment_event(&self) -> bool {
matches!(
self,
Self::PaymentIntentFailure
| Self::PaymentIntentSuccess
| Self::PaymentIntentProcessing
| Self::PaymentIntentPartiallyFunded
| Self::PaymentIntentCancelled
| Self::PaymentIntentCancelFailure
| Self::PaymentIntentAuthorizationSuccess
| Self::PaymentIntentAuthorizationFailure
| Self::PaymentIntentCaptureSuccess
| Self::PaymentIntentCaptureFailure
| Self::PaymentIntentExpired
| Self::PaymentActionRequired
| Self::SourceChargeable
| Self::SourceTransactionCreated
| Self::Payment
)
}
/// Returns true if this event type is refund-related
pub fn is_refund_event(&self) -> bool {
matches!(
self,
| {
"chunk": 12,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-6262692988738800615_13 | clm | mini_chunk | // connector-service/backend/domain_types/src/connector_types.rs
Self::RefundFailure | Self::RefundSuccess | Self::Refund
)
}
/// Returns true if this event type is dispute-related
pub fn is_dispute_event(&self) -> bool {
matches!(
self,
Self::DisputeOpened
| Self::DisputeExpired
| Self::DisputeAccepted
| Self::DisputeCancelled
| Self::DisputeChallenged
| Self::DisputeWon
| Self::DisputeLost
| Self::Dispute
)
}
/// Returns true if this event type is mandate-related
pub fn is_mandate_event(&self) -> bool {
matches!(self, Self::MandateActive | Self::MandateRevoked)
}
/// Returns true if this event type is payout-related
pub fn is_payout_event(&self) -> bool {
matches!(
self,
Self::PayoutSuccess
| Self::PayoutFailure
| Self::PayoutProcessing
| Self::PayoutCancelled
| Self::PayoutCreated
| Self::PayoutExpired
| Self::PayoutReversed
)
}
/// Returns true if this event type is recovery-related
pub fn is_recovery_event(&self) -> bool {
matches!(
self,
Self::RecoveryPaymentFailure
| Self::RecoveryPaymentSuccess
| Self::RecoveryPaymentPending
| Self::RecoveryInvoiceCancel
)
}
/// Returns true if this event type is miscellaneous
pub fn is_misc_event(&self) -> bool {
matches!(
self,
Self::EndpointVerification
| Self::ExternalAuthenticationAres
| Self::FrmApproved
| Self::FrmRejected
| Self::IncomingWebhookEventUnspecified
)
}
}
impl ForeignTryFrom<grpc_api_types::payments::WebhookEventType> for EventType {
type Error = ApplicationErrorResponse;
fn foreign_try_from(
value: grpc_api_types::payments::WebhookEventType,
) -> Result<Self, error_stack::Report<Self::Error>> {
match value {
grpc_api_types::payments::WebhookEventType::PaymentIntentFailure => {
Ok(Self::PaymentIntentFailure)
}
grpc_api_types::payments::WebhookEventType::PaymentIntentSuccess => {
Ok(Self::PaymentIntentSuccess)
}
grpc_api_types::payments::WebhookEventType::PaymentIntentProcessing => {
Ok(Self::PaymentIntentProcessing)
}
grpc_api_types::payments::WebhookEventType::PaymentIntentPartiallyFunded => {
Ok(Self::PaymentIntentPartiallyFunded)
}
grpc_api_types::payments::WebhookEventType::PaymentIntentCancelled => {
Ok(Self::PaymentIntentCancelled)
}
grpc_api_types::payments::WebhookEventType::PaymentIntentCancelFailure => {
Ok(Self::PaymentIntentCancelFailure)
}
grpc_api_types::payments::WebhookEventType::PaymentIntentAuthorizationSuccess => {
Ok(Self::PaymentIntentAuthorizationSuccess)
}
grpc_api_types::payments::WebhookEventType::PaymentIntentAuthorizationFailure => {
Ok(Self::PaymentIntentAuthorizationFailure)
}
grpc_api_types::payments::WebhookEventType::PaymentIntentCaptureSuccess => {
Ok(Self::PaymentIntentCaptureSuccess)
}
grpc_api_types::payments::WebhookEventType::PaymentIntentCaptureFailure => {
Ok(Self::PaymentIntentCaptureFailure)
}
grpc_api_types::payments::WebhookEventType::PaymentIntentExpired => {
Ok(Self::PaymentIntentExpired)
}
grpc_api_types::payments::WebhookEventType::PaymentActionRequired => {
Ok(Self::PaymentActionRequired)
}
grpc_api_types::payments::WebhookEventType::SourceChargeable => {
Ok(Self::SourceChargeable)
}
grpc_api_types::payments::WebhookEventType::SourceTransactionCreated => {
Ok(Self::SourceTransactionCreated)
}
grpc_api_types::payments::WebhookEventType::WebhookRefundFailure => {
| {
"chunk": 13,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-6262692988738800615_14 | clm | mini_chunk | // connector-service/backend/domain_types/src/connector_types.rs
Ok(Self::RefundFailure)
}
grpc_api_types::payments::WebhookEventType::WebhookRefundSuccess => {
Ok(Self::RefundSuccess)
}
grpc_api_types::payments::WebhookEventType::WebhookDisputeOpened => {
Ok(Self::DisputeOpened)
}
grpc_api_types::payments::WebhookEventType::WebhookDisputeExpired => {
Ok(Self::DisputeExpired)
}
grpc_api_types::payments::WebhookEventType::WebhookDisputeAccepted => {
Ok(Self::DisputeAccepted)
}
grpc_api_types::payments::WebhookEventType::WebhookDisputeCancelled => {
Ok(Self::DisputeCancelled)
}
grpc_api_types::payments::WebhookEventType::WebhookDisputeChallenged => {
Ok(Self::DisputeChallenged)
}
grpc_api_types::payments::WebhookEventType::WebhookDisputeWon => Ok(Self::DisputeWon),
grpc_api_types::payments::WebhookEventType::WebhookDisputeLost => Ok(Self::DisputeLost),
grpc_api_types::payments::WebhookEventType::MandateActive => Ok(Self::MandateActive),
grpc_api_types::payments::WebhookEventType::MandateRevoked => Ok(Self::MandateRevoked),
grpc_api_types::payments::WebhookEventType::EndpointVerification => {
Ok(Self::EndpointVerification)
}
grpc_api_types::payments::WebhookEventType::ExternalAuthenticationAres => {
Ok(Self::ExternalAuthenticationAres)
}
grpc_api_types::payments::WebhookEventType::FrmApproved => Ok(Self::FrmApproved),
grpc_api_types::payments::WebhookEventType::FrmRejected => Ok(Self::FrmRejected),
grpc_api_types::payments::WebhookEventType::PayoutSuccess => Ok(Self::PayoutSuccess),
grpc_api_types::payments::WebhookEventType::PayoutFailure => Ok(Self::PayoutFailure),
grpc_api_types::payments::WebhookEventType::PayoutProcessing => {
Ok(Self::PayoutProcessing)
}
grpc_api_types::payments::WebhookEventType::PayoutCancelled => {
Ok(Self::PayoutCancelled)
}
grpc_api_types::payments::WebhookEventType::PayoutCreated => Ok(Self::PayoutCreated),
grpc_api_types::payments::WebhookEventType::PayoutExpired => Ok(Self::PayoutExpired),
grpc_api_types::payments::WebhookEventType::PayoutReversed => Ok(Self::PayoutReversed),
grpc_api_types::payments::WebhookEventType::RecoveryPaymentFailure => {
Ok(Self::RecoveryPaymentFailure)
}
grpc_api_types::payments::WebhookEventType::RecoveryPaymentSuccess => {
Ok(Self::RecoveryPaymentSuccess)
}
grpc_api_types::payments::WebhookEventType::RecoveryPaymentPending => {
Ok(Self::RecoveryPaymentPending)
}
grpc_api_types::payments::WebhookEventType::RecoveryInvoiceCancel => {
Ok(Self::RecoveryInvoiceCancel)
}
grpc_api_types::payments::WebhookEventType::IncomingWebhookEventUnspecified => {
Ok(Self::IncomingWebhookEventUnspecified)
}
}
}
}
impl ForeignTryFrom<EventType> for grpc_api_types::payments::WebhookEventType {
type Error = ApplicationErrorResponse;
fn foreign_try_from(value: EventType) -> Result<Self, error_stack::Report<Self::Error>> {
match value {
EventType::PaymentIntentFailure => Ok(Self::PaymentIntentFailure),
EventType::PaymentIntentSuccess => Ok(Self::PaymentIntentSuccess),
EventType::PaymentIntentProcessing => Ok(Self::PaymentIntentProcessing),
EventType::PaymentIntentPartiallyFunded => Ok(Self::PaymentIntentPartiallyFunded),
EventType::PaymentIntentCancelled => Ok(Self::PaymentIntentCancelled),
EventType::PaymentIntentCancelFailure => Ok(Self::PaymentIntentCancelFailure),
EventType::PaymentIntentAuthorizationSuccess => {
Ok(Self::PaymentIntentAuthorizationSuccess)
}
EventType::PaymentIntentAuthorizationFailure => {
| {
"chunk": 14,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-6262692988738800615_15 | clm | mini_chunk | // connector-service/backend/domain_types/src/connector_types.rs
Ok(Self::PaymentIntentAuthorizationFailure)
}
EventType::PaymentIntentCaptureSuccess => Ok(Self::PaymentIntentCaptureSuccess),
EventType::PaymentIntentCaptureFailure => Ok(Self::PaymentIntentCaptureFailure),
EventType::PaymentIntentExpired => Ok(Self::PaymentIntentExpired),
EventType::PaymentActionRequired => Ok(Self::PaymentActionRequired),
EventType::SourceChargeable => Ok(Self::SourceChargeable),
EventType::SourceTransactionCreated => Ok(Self::SourceTransactionCreated),
EventType::RefundFailure => Ok(Self::WebhookRefundFailure),
EventType::RefundSuccess => Ok(Self::WebhookRefundSuccess),
EventType::DisputeOpened => Ok(Self::WebhookDisputeOpened),
EventType::DisputeExpired => Ok(Self::WebhookDisputeExpired),
EventType::DisputeAccepted => Ok(Self::WebhookDisputeAccepted),
EventType::DisputeCancelled => Ok(Self::WebhookDisputeCancelled),
EventType::DisputeChallenged => Ok(Self::WebhookDisputeChallenged),
EventType::DisputeWon => Ok(Self::WebhookDisputeWon),
EventType::DisputeLost => Ok(Self::WebhookDisputeLost),
EventType::MandateActive => Ok(Self::MandateActive),
EventType::MandateRevoked => Ok(Self::MandateRevoked),
EventType::EndpointVerification => Ok(Self::EndpointVerification),
EventType::ExternalAuthenticationAres => Ok(Self::ExternalAuthenticationAres),
EventType::FrmApproved => Ok(Self::FrmApproved),
EventType::FrmRejected => Ok(Self::FrmRejected),
EventType::PayoutSuccess => Ok(Self::PayoutSuccess),
EventType::PayoutFailure => Ok(Self::PayoutFailure),
EventType::PayoutProcessing => Ok(Self::PayoutProcessing),
EventType::PayoutCancelled => Ok(Self::PayoutCancelled),
EventType::PayoutCreated => Ok(Self::PayoutCreated),
EventType::PayoutExpired => Ok(Self::PayoutExpired),
EventType::PayoutReversed => Ok(Self::PayoutReversed),
EventType::RecoveryPaymentFailure => Ok(Self::RecoveryPaymentFailure),
EventType::RecoveryPaymentSuccess => Ok(Self::RecoveryPaymentSuccess),
EventType::RecoveryPaymentPending => Ok(Self::RecoveryPaymentPending),
EventType::RecoveryInvoiceCancel => Ok(Self::RecoveryInvoiceCancel),
EventType::IncomingWebhookEventUnspecified => Ok(Self::IncomingWebhookEventUnspecified),
// Legacy broad categories (for backward compatibility)
EventType::Payment => Ok(Self::PaymentIntentSuccess), // Map broad Payment to PaymentIntentSuccess
EventType::Refund => Ok(Self::WebhookRefundSuccess), // Map broad Refund to WebhookRefundSuccess
EventType::Dispute => Ok(Self::WebhookDisputeOpened), // Map broad Dispute to WebhookDisputeOpened
}
}
}
impl ForeignTryFrom<grpc_api_types::payments::HttpMethod> for HttpMethod {
type Error = ApplicationErrorResponse;
fn foreign_try_from(
value: grpc_api_types::payments::HttpMethod,
) -> Result<Self, error_stack::Report<Self::Error>> {
match value {
grpc_api_types::payments::HttpMethod::Unspecified => Ok(Self::Get), // Default
grpc_api_types::payments::HttpMethod::Get => Ok(Self::Get),
grpc_api_types::payments::HttpMethod::Post => Ok(Self::Post),
grpc_api_types::payments::HttpMethod::Put => Ok(Self::Put),
grpc_api_types::payments::HttpMethod::Delete => Ok(Self::Delete),
}
}
}
impl ForeignTryFrom<grpc_api_types::payments::RequestDetails> for RequestDetails {
type Error = ApplicationErrorResponse;
fn foreign_try_from(
value: grpc_api_types::payments::RequestDetails,
) -> Result<Self, error_stack::Report<Self::Error>> {
let method = HttpMethod::foreign_try_from(value.method())?;
Ok(Self {
method,
uri: value.uri,
headers: value.headers,
body: value.body,
query_params: value.query_params,
})
}
}
| {
"chunk": 15,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-6262692988738800615_16 | clm | mini_chunk | // connector-service/backend/domain_types/src/connector_types.rs
impl ForeignTryFrom<grpc_api_types::payments::WebhookSecrets> for ConnectorWebhookSecrets {
type Error = ApplicationErrorResponse;
fn foreign_try_from(
value: grpc_api_types::payments::WebhookSecrets,
) -> Result<Self, error_stack::Report<Self::Error>> {
Ok(Self {
secret: value.secret.into(),
additional_secret: value.additional_secret.map(Secret::new),
})
}
}
#[derive(Debug, Default, Clone)]
pub struct RefundsData {
pub refund_id: String,
pub connector_transaction_id: String,
pub connector_refund_id: Option<String>,
pub currency: Currency,
pub payment_amount: i64,
pub reason: Option<String>,
pub webhook_url: Option<String>,
pub refund_amount: i64,
pub connector_metadata: Option<serde_json::Value>,
pub refund_connector_metadata: Option<common_utils::pii::SecretSerdeValue>,
pub minor_payment_amount: MinorUnit,
pub minor_refund_amount: MinorUnit,
pub refund_status: common_enums::RefundStatus,
pub merchant_account_id: Option<String>,
pub capture_method: Option<common_enums::CaptureMethod>,
pub integrity_object: Option<RefundIntegrityObject>,
pub browser_info: Option<BrowserInformation>,
/// Charges associated with the payment
pub split_refunds: Option<SplitRefundsRequest>,
}
impl RefundsData {
#[track_caller]
pub fn get_connector_refund_id(&self) -> Result<String, Error> {
self.connector_refund_id
.clone()
.get_required_value("connector_refund_id")
.change_context(ConnectorError::MissingConnectorTransactionID)
}
pub fn get_webhook_url(&self) -> Result<String, Error> {
self.webhook_url
.clone()
.ok_or_else(missing_field_err("webhook_url"))
}
pub fn get_connector_metadata(&self) -> Result<serde_json::Value, Error> {
self.connector_metadata
.clone()
.ok_or_else(missing_field_err("connector_metadata"))
}
pub fn get_optional_language_from_browser_info(&self) -> Option<String> {
self.browser_info
.clone()
.and_then(|browser_info| browser_info.language)
}
pub fn get_ip_address_as_optional(&self) -> Option<Secret<String, IpAddress>> {
self.browser_info.clone().and_then(|browser_info| {
browser_info
.ip_address
.map(|ip| Secret::new(ip.to_string()))
})
}
pub fn get_ip_address(&self) -> Result<Secret<String, IpAddress>, Error> {
self.get_ip_address_as_optional()
.ok_or_else(missing_field_err("browser_info.ip_address"))
}
}
#[derive(Debug, Clone, Default)]
pub struct MultipleCaptureRequestData {
pub capture_sequence: i64,
pub capture_reference: String,
}
#[derive(Debug, Default, Clone)]
pub struct PaymentsCaptureData {
pub amount_to_capture: i64,
pub minor_amount_to_capture: MinorUnit,
pub currency: Currency,
pub connector_transaction_id: ResponseId,
pub multiple_capture_data: Option<MultipleCaptureRequestData>,
pub connector_metadata: Option<serde_json::Value>,
pub integrity_object: Option<CaptureIntegrityObject>,
pub browser_info: Option<BrowserInformation>,
pub capture_method: Option<common_enums::CaptureMethod>,
}
impl PaymentsCaptureData {
pub fn is_multiple_capture(&self) -> bool {
self.multiple_capture_data.is_some()
}
pub fn get_connector_transaction_id(&self) -> CustomResult<String, ConnectorError> {
match self.connector_transaction_id.clone() {
ResponseId::ConnectorTransactionId(txn_id) => Ok(txn_id),
_ => Err(errors::ValidationError::IncorrectValueProvided {
field_name: "connector_transaction_id",
})
.attach_printable("Expected connector transaction ID not found")
.change_context(ConnectorError::MissingConnectorTransactionID)?,
}
}
pub fn get_optional_language_from_browser_info(&self) -> Option<String> {
self.browser_info
.clone()
.and_then(|browser_info| browser_info.language)
}
pub fn get_ip_address_as_optional(&self) -> Option<Secret<String, IpAddress>> {
self.browser_info.clone().and_then(|browser_info| {
browser_info
| {
"chunk": 16,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-6262692988738800615_17 | clm | mini_chunk | // connector-service/backend/domain_types/src/connector_types.rs
.ip_address
.map(|ip| Secret::new(ip.to_string()))
})
}
pub fn get_ip_address(&self) -> Result<Secret<String, IpAddress>, Error> {
self.get_ip_address_as_optional()
.ok_or_else(missing_field_err("browser_info.ip_address"))
}
}
#[derive(Debug, Clone)]
pub struct SetupMandateRequestData<T: PaymentMethodDataTypes> {
pub currency: Currency,
pub payment_method_data: payment_method_data::PaymentMethodData<T>,
pub amount: Option<i64>,
pub confirm: bool,
pub statement_descriptor_suffix: Option<String>,
pub statement_descriptor: Option<String>,
pub customer_acceptance: Option<CustomerAcceptance>,
pub mandate_id: Option<MandateIds>,
pub setup_future_usage: Option<common_enums::FutureUsage>,
pub off_session: Option<bool>,
pub setup_mandate_details: Option<MandateData>,
pub router_return_url: Option<String>,
pub webhook_url: Option<String>,
pub browser_info: Option<BrowserInformation>,
pub email: Option<common_utils::pii::Email>,
pub customer_name: Option<String>,
pub return_url: Option<String>,
pub payment_method_type: Option<common_enums::PaymentMethodType>,
pub request_incremental_authorization: bool,
pub metadata: Option<serde_json::Value>,
pub complete_authorize_url: Option<String>,
pub capture_method: Option<common_enums::CaptureMethod>,
pub merchant_order_reference_id: Option<String>,
pub minor_amount: Option<MinorUnit>,
pub shipping_cost: Option<MinorUnit>,
pub customer_id: Option<common_utils::id_type::CustomerId>,
pub integrity_object: Option<SetupMandateIntegrityObject>,
pub merchant_account_metadata: Option<common_utils::pii::SecretSerdeValue>,
}
impl<T: PaymentMethodDataTypes> SetupMandateRequestData<T> {
pub fn get_browser_info(&self) -> Result<BrowserInformation, Error> {
self.browser_info
.clone()
.ok_or_else(missing_field_err("browser_info"))
}
pub fn get_email(&self) -> Result<Email, Error> {
self.email.clone().ok_or_else(missing_field_err("email"))
}
pub fn is_card(&self) -> bool {
matches!(self.payment_method_data, PaymentMethodData::Card(_))
}
pub fn get_optional_language_from_browser_info(&self) -> Option<String> {
self.browser_info
.clone()
.and_then(|browser_info| browser_info.language)
}
pub fn get_webhook_url(&self) -> Result<String, Error> {
self.webhook_url
.clone()
.ok_or_else(missing_field_err("webhook_url"))
}
pub fn get_router_return_url(&self) -> Result<String, Error> {
self.router_return_url
.clone()
.ok_or_else(missing_field_err("return_url"))
}
pub fn get_ip_address_as_optional(&self) -> Option<Secret<String, IpAddress>> {
self.browser_info.clone().and_then(|browser_info| {
browser_info
.ip_address
.map(|ip| Secret::new(ip.to_string()))
})
}
pub fn get_ip_address(&self) -> Result<Secret<String, IpAddress>, Error> {
self.get_ip_address_as_optional()
.ok_or_else(missing_field_err("browser_info.ip_address"))
}
}
#[derive(Debug, Clone)]
pub struct RepeatPaymentData {
pub mandate_reference: MandateReferenceId,
pub amount: i64,
pub minor_amount: MinorUnit,
pub currency: Currency,
pub merchant_order_reference_id: Option<String>,
pub metadata: Option<SecretSerdeValue>,
pub webhook_url: Option<String>,
pub integrity_object: Option<RepeatPaymentIntegrityObject>,
pub capture_method: Option<common_enums::CaptureMethod>,
pub browser_info: Option<BrowserInformation>,
pub email: Option<common_utils::pii::Email>,
pub payment_method_type: Option<common_enums::PaymentMethodType>,
pub merchant_account_metadata: Option<common_utils::pii::SecretSerdeValue>,
pub off_session: Option<bool>,
pub router_return_url: Option<String>,
pub split_payments: Option<SplitPaymentsRequest>,
pub recurring_mandate_payment_data: Option<router_data::RecurringMandatePaymentData>,
}
impl RepeatPaymentData {
pub fn get_mandate_reference(&self) -> &MandateReferenceId {
&self.mandate_reference
}
| {
"chunk": 17,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-6262692988738800615_18 | clm | mini_chunk | // connector-service/backend/domain_types/src/connector_types.rs
pub fn is_auto_capture(&self) -> Result<bool, Error> {
match self.capture_method {
Some(common_enums::CaptureMethod::Automatic)
| None
| Some(common_enums::CaptureMethod::SequentialAutomatic) => Ok(true),
Some(common_enums::CaptureMethod::Manual) => Ok(false),
Some(_) => Err(ConnectorError::CaptureMethodNotSupported.into()),
}
}
pub fn get_optional_language_from_browser_info(&self) -> Option<String> {
self.browser_info
.clone()
.and_then(|browser_info| browser_info.language)
}
pub fn get_webhook_url(&self) -> Result<String, Error> {
self.webhook_url
.clone()
.ok_or_else(missing_field_err("webhook_url"))
}
pub fn get_email(&self) -> Result<Email, Error> {
self.email.clone().ok_or_else(missing_field_err("email"))
}
pub fn get_recurring_mandate_payment_data(
&self,
) -> Result<router_data::RecurringMandatePaymentData, Error> {
self.recurring_mandate_payment_data
.to_owned()
.ok_or_else(missing_field_err("recurring_mandate_payment_data"))
}
}
#[derive(Debug, Clone)]
pub struct AcceptDisputeData {
pub connector_dispute_id: String,
pub integrity_object: Option<AcceptDisputeIntegrityObject>,
}
#[derive(Debug, Clone)]
pub struct DisputeFlowData {
pub dispute_id: Option<String>,
pub connector_dispute_id: String,
pub connectors: Connectors,
pub defense_reason_code: Option<String>,
pub connector_request_reference_id: String,
pub raw_connector_response: Option<Secret<String>>,
pub raw_connector_request: Option<Secret<String>>,
pub connector_response_headers: Option<http::HeaderMap>,
}
impl RawConnectorRequestResponse for DisputeFlowData {
fn set_raw_connector_response(&mut self, response: Option<Secret<String>>) {
self.raw_connector_response = response;
}
fn get_raw_connector_response(&self) -> Option<Secret<String>> {
self.raw_connector_response.clone()
}
fn set_raw_connector_request(&mut self, request: Option<Secret<String>>) {
self.raw_connector_request = request;
}
fn get_raw_connector_request(&self) -> Option<Secret<String>> {
self.raw_connector_request.clone()
}
}
impl ConnectorResponseHeaders for DisputeFlowData {
fn set_connector_response_headers(&mut self, headers: Option<http::HeaderMap>) {
self.connector_response_headers = headers;
}
fn get_connector_response_headers(&self) -> Option<&http::HeaderMap> {
self.connector_response_headers.as_ref()
}
}
#[derive(Debug, Clone)]
pub struct DisputeResponseData {
pub connector_dispute_id: String,
pub dispute_status: DisputeStatus,
pub connector_dispute_status: Option<String>,
pub status_code: u16,
}
#[derive(Debug, Clone, Default)]
pub struct SubmitEvidenceData {
pub dispute_id: Option<String>,
pub connector_dispute_id: String,
pub integrity_object: Option<SubmitEvidenceIntegrityObject>,
pub access_activity_log: Option<String>,
pub billing_address: Option<String>,
pub cancellation_policy: Option<Vec<u8>>,
pub cancellation_policy_file_type: Option<String>,
pub cancellation_policy_provider_file_id: Option<String>,
pub cancellation_policy_disclosure: Option<String>,
pub cancellation_rebuttal: Option<String>,
pub customer_communication: Option<Vec<u8>>,
pub customer_communication_file_type: Option<String>,
pub customer_communication_provider_file_id: Option<String>,
pub customer_email_address: Option<String>,
pub customer_name: Option<String>,
pub customer_purchase_ip: Option<String>,
pub customer_signature: Option<Vec<u8>>,
pub customer_signature_file_type: Option<String>,
pub customer_signature_provider_file_id: Option<String>,
pub product_description: Option<String>,
pub receipt: Option<Vec<u8>>,
pub receipt_file_type: Option<String>,
pub receipt_provider_file_id: Option<String>,
pub refund_policy: Option<Vec<u8>>,
pub refund_policy_file_type: Option<String>,
pub refund_policy_provider_file_id: Option<String>,
pub refund_policy_disclosure: Option<String>,
pub refund_refusal_explanation: Option<String>,
pub service_date: Option<String>,
| {
"chunk": 18,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-6262692988738800615_19 | clm | mini_chunk | // connector-service/backend/domain_types/src/connector_types.rs
pub service_documentation: Option<Vec<u8>>,
pub service_documentation_file_type: Option<String>,
pub service_documentation_provider_file_id: Option<String>,
pub shipping_address: Option<String>,
pub shipping_carrier: Option<String>,
pub shipping_date: Option<String>,
pub shipping_documentation: Option<Vec<u8>>,
pub shipping_documentation_file_type: Option<String>,
pub shipping_documentation_provider_file_id: Option<String>,
pub shipping_tracking_number: Option<String>,
pub invoice_showing_distinct_transactions: Option<Vec<u8>>,
pub invoice_showing_distinct_transactions_file_type: Option<String>,
pub invoice_showing_distinct_transactions_provider_file_id: Option<String>,
pub recurring_transaction_agreement: Option<Vec<u8>>,
pub recurring_transaction_agreement_file_type: Option<String>,
pub recurring_transaction_agreement_provider_file_id: Option<String>,
pub uncategorized_file: Option<Vec<u8>>,
pub uncategorized_file_type: Option<String>,
pub uncategorized_file_provider_file_id: Option<String>,
pub uncategorized_text: Option<String>,
}
/// The trait that provides specifications about the connector
pub trait ConnectorSpecifications {
/// Details related to payment method supported by the connector
fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> {
None
}
/// Supported webhooks flows
fn get_supported_webhook_flows(&self) -> Option<&'static [EventClass]> {
None
}
/// About the connector
fn get_connector_about(&self) -> Option<&'static ConnectorInfo> {
None
}
}
#[macro_export]
macro_rules! capture_method_not_supported {
($connector:expr, $capture_method:expr) => {
Err(errors::ConnectorError::NotSupported {
message: format!("{} for selected payment method", $capture_method),
connector: $connector,
}
.into())
};
($connector:expr, $capture_method:expr, $payment_method_type:expr) => {
Err(errors::ConnectorError::NotSupported {
message: format!("{} for {}", $capture_method, $payment_method_type),
connector: $connector,
}
.into())
};
}
#[macro_export]
macro_rules! payment_method_not_supported {
($connector:expr, $payment_method:expr, $payment_method_type:expr) => {
Err(errors::ConnectorError::NotSupported {
message: format!(
"Payment method {} with type {} is not supported",
$payment_method, $payment_method_type
),
connector: $connector,
}
.into())
};
}
impl<T: PaymentMethodDataTypes> From<PaymentMethodData<T>> for PaymentMethodDataType {
fn from(pm_data: PaymentMethodData<T>) -> Self {
match pm_data {
PaymentMethodData::Card(_) => Self::Card,
PaymentMethodData::CardRedirect(card_redirect_data) => match card_redirect_data {
payment_method_data::CardRedirectData::Knet {} => Self::Knet,
payment_method_data::CardRedirectData::Benefit {} => Self::Benefit,
payment_method_data::CardRedirectData::MomoAtm {} => Self::MomoAtm,
payment_method_data::CardRedirectData::CardRedirect {} => Self::CardRedirect,
},
PaymentMethodData::Wallet(wallet_data) => match wallet_data {
payment_method_data::WalletData::BluecodeRedirect { .. } => Self::Bluecode,
payment_method_data::WalletData::AliPayQr(_) => Self::AliPayQr,
payment_method_data::WalletData::AliPayRedirect(_) => Self::AliPayRedirect,
payment_method_data::WalletData::AliPayHkRedirect(_) => Self::AliPayHkRedirect,
payment_method_data::WalletData::MomoRedirect(_) => Self::MomoRedirect,
payment_method_data::WalletData::KakaoPayRedirect(_) => Self::KakaoPayRedirect,
payment_method_data::WalletData::GoPayRedirect(_) => Self::GoPayRedirect,
payment_method_data::WalletData::GcashRedirect(_) => Self::GcashRedirect,
payment_method_data::WalletData::ApplePay(_) => Self::ApplePay,
payment_method_data::WalletData::ApplePayRedirect(_) => Self::ApplePayRedirect,
| {
"chunk": 19,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-6262692988738800615_20 | clm | mini_chunk | // connector-service/backend/domain_types/src/connector_types.rs
payment_method_data::WalletData::ApplePayThirdPartySdk(_) => {
Self::ApplePayThirdPartySdk
}
payment_method_data::WalletData::DanaRedirect {} => Self::DanaRedirect,
payment_method_data::WalletData::GooglePay(_) => Self::GooglePay,
payment_method_data::WalletData::GooglePayRedirect(_) => Self::GooglePayRedirect,
payment_method_data::WalletData::GooglePayThirdPartySdk(_) => {
Self::GooglePayThirdPartySdk
}
payment_method_data::WalletData::MbWayRedirect(_) => Self::MbWayRedirect,
payment_method_data::WalletData::MobilePayRedirect(_) => Self::MobilePayRedirect,
payment_method_data::WalletData::PaypalRedirect(_) => Self::PaypalRedirect,
payment_method_data::WalletData::PaypalSdk(_) => Self::PaypalSdk,
payment_method_data::WalletData::SamsungPay(_) => Self::SamsungPay,
payment_method_data::WalletData::TwintRedirect {} => Self::TwintRedirect,
payment_method_data::WalletData::VippsRedirect {} => Self::VippsRedirect,
payment_method_data::WalletData::TouchNGoRedirect(_) => Self::TouchNGoRedirect,
payment_method_data::WalletData::WeChatPayRedirect(_) => Self::WeChatPayRedirect,
payment_method_data::WalletData::WeChatPayQr(_) => Self::WeChatPayQr,
payment_method_data::WalletData::CashappQr(_) => Self::CashappQr,
payment_method_data::WalletData::SwishQr(_) => Self::SwishQr,
payment_method_data::WalletData::Mifinity(_) => Self::Mifinity,
payment_method_data::WalletData::AmazonPayRedirect(_) => Self::AmazonPayRedirect,
payment_method_data::WalletData::Paze(_) => Self::Paze,
payment_method_data::WalletData::RevolutPay(_) => Self::RevolutPay,
},
PaymentMethodData::PayLater(pay_later_data) => match pay_later_data {
payment_method_data::PayLaterData::KlarnaRedirect { .. } => Self::KlarnaRedirect,
payment_method_data::PayLaterData::KlarnaSdk { .. } => Self::KlarnaSdk,
payment_method_data::PayLaterData::AffirmRedirect {} => Self::AffirmRedirect,
payment_method_data::PayLaterData::AfterpayClearpayRedirect { .. } => {
Self::AfterpayClearpayRedirect
}
payment_method_data::PayLaterData::PayBrightRedirect {} => Self::PayBrightRedirect,
payment_method_data::PayLaterData::WalleyRedirect {} => Self::WalleyRedirect,
payment_method_data::PayLaterData::AlmaRedirect {} => Self::AlmaRedirect,
payment_method_data::PayLaterData::AtomeRedirect {} => Self::AtomeRedirect,
},
PaymentMethodData::BankRedirect(bank_redirect_data) => match bank_redirect_data {
payment_method_data::BankRedirectData::BancontactCard { .. } => {
Self::BancontactCard
}
payment_method_data::BankRedirectData::Bizum {} => Self::Bizum,
payment_method_data::BankRedirectData::Blik { .. } => Self::Blik,
payment_method_data::BankRedirectData::Eps { .. } => Self::Eps,
payment_method_data::BankRedirectData::Giropay { .. } => Self::Giropay,
payment_method_data::BankRedirectData::Ideal { .. } => Self::Ideal,
payment_method_data::BankRedirectData::Interac { .. } => Self::Interac,
payment_method_data::BankRedirectData::OnlineBankingCzechRepublic { .. } => {
Self::OnlineBankingCzechRepublic
}
payment_method_data::BankRedirectData::OnlineBankingFinland { .. } => {
Self::OnlineBankingFinland
}
payment_method_data::BankRedirectData::OnlineBankingPoland { .. } => {
Self::OnlineBankingPoland
}
payment_method_data::BankRedirectData::OnlineBankingSlovakia { .. } => {
Self::OnlineBankingSlovakia
}
| {
"chunk": 20,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-6262692988738800615_21 | clm | mini_chunk | // connector-service/backend/domain_types/src/connector_types.rs
payment_method_data::BankRedirectData::OpenBankingUk { .. } => Self::OpenBankingUk,
payment_method_data::BankRedirectData::Przelewy24 { .. } => Self::Przelewy24,
payment_method_data::BankRedirectData::Sofort { .. } => Self::Sofort,
payment_method_data::BankRedirectData::Trustly { .. } => Self::Trustly,
payment_method_data::BankRedirectData::OnlineBankingFpx { .. } => {
Self::OnlineBankingFpx
}
payment_method_data::BankRedirectData::OnlineBankingThailand { .. } => {
Self::OnlineBankingThailand
}
payment_method_data::BankRedirectData::LocalBankRedirect {} => {
Self::LocalBankRedirect
}
payment_method_data::BankRedirectData::Eft { .. } => Self::Eft,
},
PaymentMethodData::BankDebit(bank_debit_data) => match bank_debit_data {
payment_method_data::BankDebitData::AchBankDebit { .. } => Self::AchBankDebit,
payment_method_data::BankDebitData::SepaBankDebit { .. } => Self::SepaBankDebit,
payment_method_data::BankDebitData::BecsBankDebit { .. } => Self::BecsBankDebit,
payment_method_data::BankDebitData::BacsBankDebit { .. } => Self::BacsBankDebit,
},
PaymentMethodData::BankTransfer(bank_transfer_data) => match *bank_transfer_data {
payment_method_data::BankTransferData::AchBankTransfer { .. } => {
Self::AchBankTransfer
}
payment_method_data::BankTransferData::SepaBankTransfer { .. } => {
Self::SepaBankTransfer
}
payment_method_data::BankTransferData::BacsBankTransfer { .. } => {
Self::BacsBankTransfer
}
payment_method_data::BankTransferData::MultibancoBankTransfer { .. } => {
Self::MultibancoBankTransfer
}
payment_method_data::BankTransferData::PermataBankTransfer { .. } => {
Self::PermataBankTransfer
}
payment_method_data::BankTransferData::BcaBankTransfer { .. } => {
Self::BcaBankTransfer
}
payment_method_data::BankTransferData::BniVaBankTransfer { .. } => {
Self::BniVaBankTransfer
}
payment_method_data::BankTransferData::BriVaBankTransfer { .. } => {
Self::BriVaBankTransfer
}
payment_method_data::BankTransferData::CimbVaBankTransfer { .. } => {
Self::CimbVaBankTransfer
}
payment_method_data::BankTransferData::DanamonVaBankTransfer { .. } => {
Self::DanamonVaBankTransfer
}
payment_method_data::BankTransferData::MandiriVaBankTransfer { .. } => {
Self::MandiriVaBankTransfer
}
payment_method_data::BankTransferData::Pix { .. } => Self::Pix,
payment_method_data::BankTransferData::Pse {} => Self::Pse,
payment_method_data::BankTransferData::LocalBankTransfer { .. } => {
Self::LocalBankTransfer
}
payment_method_data::BankTransferData::InstantBankTransfer { .. } => {
Self::InstantBankTransfer
}
payment_method_data::BankTransferData::InstantBankTransferFinland { .. } => {
Self::InstantBankTransferFinland
}
payment_method_data::BankTransferData::InstantBankTransferPoland { .. } => {
Self::InstantBankTransferPoland
}
},
PaymentMethodData::Crypto(_) => Self::Crypto,
PaymentMethodData::MandatePayment => Self::MandatePayment,
PaymentMethodData::Reward => Self::Reward,
PaymentMethodData::Upi(_) => Self::Upi,
PaymentMethodData::Voucher(voucher_data) => match voucher_data {
| {
"chunk": 21,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-6262692988738800615_22 | clm | mini_chunk | // connector-service/backend/domain_types/src/connector_types.rs
payment_method_data::VoucherData::Boleto(_) => Self::Boleto,
payment_method_data::VoucherData::Efecty => Self::Efecty,
payment_method_data::VoucherData::PagoEfectivo => Self::PagoEfectivo,
payment_method_data::VoucherData::RedCompra => Self::RedCompra,
payment_method_data::VoucherData::RedPagos => Self::RedPagos,
payment_method_data::VoucherData::Alfamart(_) => Self::Alfamart,
payment_method_data::VoucherData::Indomaret(_) => Self::Indomaret,
payment_method_data::VoucherData::Oxxo => Self::Oxxo,
payment_method_data::VoucherData::SevenEleven(_) => Self::SevenEleven,
payment_method_data::VoucherData::Lawson(_) => Self::Lawson,
payment_method_data::VoucherData::MiniStop(_) => Self::MiniStop,
payment_method_data::VoucherData::FamilyMart(_) => Self::FamilyMart,
payment_method_data::VoucherData::Seicomart(_) => Self::Seicomart,
payment_method_data::VoucherData::PayEasy(_) => Self::PayEasy,
},
PaymentMethodData::RealTimePayment(real_time_payment_data) => {
match *real_time_payment_data {
payment_method_data::RealTimePaymentData::DuitNow {} => Self::DuitNow,
payment_method_data::RealTimePaymentData::Fps {} => Self::Fps,
payment_method_data::RealTimePaymentData::PromptPay {} => Self::PromptPay,
payment_method_data::RealTimePaymentData::VietQr {} => Self::VietQr,
}
}
PaymentMethodData::GiftCard(gift_card_data) => match *gift_card_data {
payment_method_data::GiftCardData::Givex(_) => Self::Givex,
payment_method_data::GiftCardData::PaySafeCard {} => Self::PaySafeCar,
},
PaymentMethodData::CardToken(_) => Self::CardToken,
PaymentMethodData::OpenBanking(data) => match data {
payment_method_data::OpenBankingData::OpenBankingPIS {} => Self::OpenBanking,
},
PaymentMethodData::CardDetailsForNetworkTransactionId(_) => {
Self::CardDetailsForNetworkTransactionId
}
PaymentMethodData::NetworkToken(_) => Self::NetworkToken,
PaymentMethodData::MobilePayment(mobile_payment_data) => match mobile_payment_data {
payment_method_data::MobilePaymentData::DirectCarrierBilling { .. } => {
Self::DirectCarrierBilling
}
},
}
}
}
#[derive(Debug, Clone)]
pub struct DisputeDefendData {
pub dispute_id: String,
pub connector_dispute_id: String,
pub defense_reason_code: String,
pub integrity_object: Option<DefendDisputeIntegrityObject>,
}
pub trait SupportedPaymentMethodsExt {
fn add(
&mut self,
payment_method: PaymentMethod,
payment_method_type: PaymentMethodType,
payment_method_details: PaymentMethodDetails,
);
}
impl SupportedPaymentMethodsExt for SupportedPaymentMethods {
fn add(
&mut self,
payment_method: PaymentMethod,
payment_method_type: PaymentMethodType,
payment_method_details: PaymentMethodDetails,
) {
if let Some(payment_method_data) = self.get_mut(&payment_method) {
payment_method_data.insert(payment_method_type, payment_method_details);
} else {
let mut payment_method_type_metadata = PaymentMethodTypeMetadata::new();
payment_method_type_metadata.insert(payment_method_type, payment_method_details);
self.insert(payment_method, payment_method_type_metadata);
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
#[serde(deny_unknown_fields)]
/// Fee information for Split Payments to be charged on the payment being collected
pub enum SplitPaymentsRequest {
/// StripeSplitPayment
StripeSplitPayment(StripeSplitPaymentRequest),
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
/// Fee information for Split Payments to be charged on the payment being collected for Stripe
| {
"chunk": 22,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-6262692988738800615_23 | clm | mini_chunk | // connector-service/backend/domain_types/src/connector_types.rs
pub struct StripeSplitPaymentRequest {
/// Stripe's charge type
pub charge_type: common_enums::PaymentChargeType,
/// Platform fees to be collected on the payment
pub application_fees: Option<MinorUnit>,
/// Identifier for the reseller's account where the funds were transferred
pub transfer_account_id: String,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
#[serde(deny_unknown_fields)]
pub enum ConnectorChargeResponseData {
/// StripeChargeResponseData
StripeSplitPayment(StripeChargeResponseData),
}
/// Fee information to be charged on the payment being collected via Stripe
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct StripeChargeResponseData {
/// Identifier for charge created for the payment
pub charge_id: Option<String>,
/// Type of charge (connector specific)
pub charge_type: common_enums::PaymentChargeType,
/// Platform fees collected on the payment
pub application_fees: Option<MinorUnit>,
/// Identifier for the reseller's account where the funds were transferred
pub transfer_account_id: String,
}
#[derive(Debug, serde::Deserialize, Clone)]
pub enum SplitRefundsRequest {
StripeSplitRefund(StripeSplitRefund),
}
#[derive(Debug, serde::Deserialize, Clone)]
pub struct StripeSplitRefund {
pub charge_id: String,
pub transfer_account_id: String,
pub charge_type: common_enums::PaymentChargeType,
pub options: ChargeRefundsOptions,
}
#[derive(Clone, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize)]
pub enum ChargeRefundsOptions {
Destination(DestinationChargeRefund),
Direct(DirectChargeRefund),
}
#[derive(Clone, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize)]
pub struct DirectChargeRefund {
pub revert_platform_fee: bool,
}
#[derive(Clone, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize)]
pub struct DestinationChargeRefund {
pub revert_platform_fee: bool,
pub revert_transfer: bool,
}
#[derive(Debug, Default, Clone, Serialize)]
pub struct RecurringMandatePaymentData {
pub payment_method_type: Option<common_enums::PaymentMethodType>, //required for making recurring payment using saved payment method through stripe
pub original_payment_authorized_amount: Option<MinorUnit>,
pub original_payment_authorized_currency: Option<common_enums::Currency>,
pub mandate_metadata: Option<common_utils::pii::SecretSerdeValue>,
}
| {
"chunk": 23,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_2301475437378205030_0 | clm | mini_chunk | // connector-service/backend/domain_types/src/lib.rs
pub mod api;
pub mod connector_flow;
pub mod connector_types;
pub mod errors;
pub mod mandates;
pub mod payment_address;
pub mod payment_method_data;
pub mod router_data;
pub mod router_data_v2;
pub mod router_flow_types;
pub mod router_request_types;
pub mod router_response_types;
pub mod types;
pub mod utils;
| {
"chunk": 0,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_-764259173922624356_0 | clm | mini_chunk | // connector-service/backend/domain_types/src/router_flow_types.rs
use serde::Serialize;
#[derive(Clone, Debug)]
pub struct VerifyWebhookSource;
#[derive(Debug, Clone, Serialize)]
pub struct ConnectorMandateDetails {
pub connector_mandate_id: hyperswitch_masking::Secret<String>,
}
#[derive(Debug, Clone, Serialize)]
pub struct ConnectorNetworkTxnId(hyperswitch_masking::Secret<String>);
impl ConnectorNetworkTxnId {
pub fn new(txn_id: hyperswitch_masking::Secret<String>) -> Self {
Self(txn_id)
}
pub fn get_id(&self) -> &hyperswitch_masking::Secret<String> {
&self.0
}
}
| {
"chunk": 0,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_7969894047322031300_0 | clm | mini_chunk | // connector-service/backend/domain_types/src/router_data.rs
use std::collections::HashMap;
use cards::{
validate::{CardExpirationMonth, CardExpirationYear},
NetworkToken,
};
use common_utils::ext_traits::{OptionExt, ValueExt};
use error_stack::ResultExt;
use hyperswitch_masking::{ExposeInterface, Secret};
use crate::utils::missing_field_err;
pub type Error = error_stack::Report<crate::errors::ConnectorError>;
#[derive(Default, Debug, Clone, serde::Deserialize, serde::Serialize)]
#[serde(tag = "auth_type")]
pub enum ConnectorAuthType {
TemporaryAuth,
HeaderKey {
api_key: Secret<String>,
},
BodyKey {
api_key: Secret<String>,
key1: Secret<String>,
},
SignatureKey {
api_key: Secret<String>,
key1: Secret<String>,
api_secret: Secret<String>,
},
MultiAuthKey {
api_key: Secret<String>,
key1: Secret<String>,
api_secret: Secret<String>,
key2: Secret<String>,
},
CurrencyAuthKey {
auth_key_map: HashMap<common_enums::enums::Currency, common_utils::pii::SecretSerdeValue>,
},
CertificateAuth {
certificate: Secret<String>,
private_key: Secret<String>,
},
#[default]
NoKey,
}
impl ConnectorAuthType {
pub fn from_option_secret_value(
value: Option<common_utils::pii::SecretSerdeValue>,
) -> common_utils::errors::CustomResult<Self, common_utils::errors::ParsingError> {
value
.parse_value::<Self>("ConnectorAuthType")
.change_context(common_utils::errors::ParsingError::StructParseFailure(
"ConnectorAuthType",
))
}
pub fn from_secret_value(
value: common_utils::pii::SecretSerdeValue,
) -> common_utils::errors::CustomResult<Self, common_utils::errors::ParsingError> {
value
.parse_value::<Self>("ConnectorAuthType")
.change_context(common_utils::errors::ParsingError::StructParseFailure(
"ConnectorAuthType",
))
}
// show only first and last two digits of the key and mask others with *
// mask the entire key if it's length is less than or equal to 4
fn mask_key(&self, key: String) -> Secret<String> {
let key_len = key.len();
let masked_key = if key_len <= 4 {
"*".repeat(key_len)
} else {
// Show the first two and last two characters, mask the rest with '*'
let mut masked_key = String::new();
let key_len = key.len();
// Iterate through characters by their index
for (index, character) in key.chars().enumerate() {
if index < 2 || index >= key_len - 2 {
masked_key.push(character); // Keep the first two and last two characters
} else {
masked_key.push('*'); // Mask the middle characters
}
}
masked_key
};
Secret::new(masked_key)
}
// Mask the keys in the auth_type
pub fn get_masked_keys(&self) -> Self {
match self {
Self::TemporaryAuth => Self::TemporaryAuth,
Self::NoKey => Self::NoKey,
Self::HeaderKey { api_key } => Self::HeaderKey {
api_key: self.mask_key(api_key.clone().expose()),
},
Self::BodyKey { api_key, key1 } => Self::BodyKey {
api_key: self.mask_key(api_key.clone().expose()),
key1: self.mask_key(key1.clone().expose()),
},
Self::SignatureKey {
api_key,
key1,
api_secret,
} => Self::SignatureKey {
api_key: self.mask_key(api_key.clone().expose()),
key1: self.mask_key(key1.clone().expose()),
api_secret: self.mask_key(api_secret.clone().expose()),
},
Self::MultiAuthKey {
api_key,
key1,
api_secret,
key2,
} => Self::MultiAuthKey {
api_key: self.mask_key(api_key.clone().expose()),
key1: self.mask_key(key1.clone().expose()),
api_secret: self.mask_key(api_secret.clone().expose()),
key2: self.mask_key(key2.clone().expose()),
},
Self::CurrencyAuthKey { auth_key_map } => Self::CurrencyAuthKey {
| {
"chunk": 0,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_7969894047322031300_1 | clm | mini_chunk | // connector-service/backend/domain_types/src/router_data.rs
auth_key_map: auth_key_map.clone(),
},
Self::CertificateAuth {
certificate,
private_key,
} => Self::CertificateAuth {
certificate: self.mask_key(certificate.clone().expose()),
private_key: self.mask_key(private_key.clone().expose()),
},
}
}
}
#[derive(Clone, Debug, serde::Serialize)]
pub struct ErrorResponse {
pub code: String,
pub message: String,
pub reason: Option<String>,
pub status_code: u16,
pub attempt_status: Option<common_enums::enums::AttemptStatus>,
pub connector_transaction_id: Option<String>,
pub network_decline_code: Option<String>,
pub network_advice_code: Option<String>,
pub network_error_message: Option<String>,
}
impl Default for ErrorResponse {
fn default() -> Self {
Self {
code: "HE_00".to_string(),
message: "Something went wrong".to_string(),
reason: None,
status_code: http::StatusCode::INTERNAL_SERVER_ERROR.as_u16(),
attempt_status: None,
connector_transaction_id: None,
network_decline_code: None,
network_advice_code: None,
network_error_message: None,
}
}
}
impl ErrorResponse {
pub fn get_not_implemented() -> Self {
Self {
code: "IR_00".to_string(),
message: "This API is under development and will be made available soon.".to_string(),
reason: None,
status_code: http::StatusCode::INTERNAL_SERVER_ERROR.as_u16(),
attempt_status: None,
connector_transaction_id: None,
network_decline_code: None,
network_advice_code: None,
network_error_message: None,
}
}
}
#[derive(Debug, Clone, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ApplePayCryptogramData {
pub online_payment_cryptogram: Secret<String>,
pub eci_indicator: Option<String>,
}
#[derive(Debug, Clone, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ApplePayPredecryptData {
pub application_primary_account_number: Secret<String>,
pub application_expiration_date: String,
pub currency_code: String,
pub transaction_amount: i64,
pub device_manufacturer_identifier: Secret<String>,
pub payment_data_type: Secret<String>,
pub payment_data: ApplePayCryptogramData,
}
impl ApplePayPredecryptData {
pub fn get_four_digit_expiry_year(&self) -> Result<Secret<String>, Error> {
Ok(Secret::new(format!(
"20{}",
self.application_expiration_date
.get(0..2)
.ok_or(crate::errors::ConnectorError::RequestEncodingFailed)?
)))
}
pub fn get_expiry_month(&self) -> Result<Secret<String>, Error> {
Ok(Secret::new(
self.application_expiration_date
.get(2..4)
.ok_or(crate::errors::ConnectorError::RequestEncodingFailed)?
.to_owned(),
))
}
}
#[derive(Debug, Clone, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct GooglePayDecryptedData {
pub message_expiration: String,
pub message_id: String,
#[serde(rename = "paymentMethod")]
pub payment_method_type: String,
pub payment_method_details: GooglePayPaymentMethodDetails,
}
#[derive(Debug, Clone, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct GooglePayPaymentMethodDetails {
pub auth_method: common_enums::enums::GooglePayAuthMethod,
pub expiration_month: CardExpirationMonth,
pub expiration_year: CardExpirationYear,
pub pan: cards::CardNumber,
pub cryptogram: Option<Secret<String>>,
pub eci_indicator: Option<String>,
}
#[derive(Debug, Clone, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PazeDecryptedData {
pub client_id: Secret<String>,
pub profile_id: String,
pub token: PazeToken,
pub payment_card_network: common_enums::enums::CardNetwork,
pub dynamic_data: Vec<PazeDynamicData>,
pub billing_address: PazeAddress,
pub consumer: PazeConsumer,
pub eci: Option<String>,
}
#[derive(Debug, Clone, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PazeToken {
pub payment_token: NetworkTokenNumber,
pub token_expiration_month: Secret<String>,
| {
"chunk": 1,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_7969894047322031300_2 | clm | mini_chunk | // connector-service/backend/domain_types/src/router_data.rs
pub token_expiration_year: Secret<String>,
pub payment_account_reference: Secret<String>,
}
pub type NetworkTokenNumber = NetworkToken;
#[derive(Debug, Clone, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PazeConsumer {
// This is consumer data not customer data.
pub first_name: Option<Secret<String>>,
pub last_name: Option<Secret<String>>,
pub full_name: Secret<String>,
pub email_address: common_utils::pii::Email,
pub mobile_number: Option<PazePhoneNumber>,
pub country_code: Option<common_enums::enums::CountryAlpha2>,
pub language_code: Option<String>,
}
#[derive(Debug, Clone, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PazePhoneNumber {
pub country_code: Secret<String>,
pub phone_number: Secret<String>,
}
#[derive(Debug, Clone, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PazeAddress {
pub name: Option<Secret<String>>,
pub line1: Option<Secret<String>>,
pub line2: Option<Secret<String>>,
pub line3: Option<Secret<String>>,
pub city: Option<Secret<String>>,
pub state: Option<Secret<String>>,
pub zip: Option<Secret<String>>,
pub country_code: Option<common_enums::enums::CountryAlpha2>,
}
#[derive(Debug, Clone, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PazeDynamicData {
pub dynamic_data_value: Option<Secret<String>>,
pub dynamic_data_type: Option<String>,
pub dynamic_data_expiration: Option<String>,
}
#[derive(Debug, Clone, serde::Deserialize)]
pub enum PaymentMethodToken {
Token(Secret<String>),
ApplePayDecrypt(Box<ApplePayPredecryptData>),
GooglePayDecrypt(Box<GooglePayDecryptedData>),
PazeDecrypt(Box<PazeDecryptedData>),
}
#[derive(Debug, Default, Clone)]
pub struct RecurringMandatePaymentData {
pub payment_method_type: Option<common_enums::enums::PaymentMethodType>, //required for making recurring payment using saved payment method through stripe
pub original_payment_authorized_amount: Option<i64>,
pub original_payment_authorized_currency: Option<common_enums::enums::Currency>,
pub mandate_metadata: Option<common_utils::pii::SecretSerdeValue>,
}
impl RecurringMandatePaymentData {
pub fn get_original_payment_amount(&self) -> Result<i64, Error> {
self.original_payment_authorized_amount
.ok_or_else(missing_field_err("original_payment_authorized_amount"))
}
pub fn get_original_payment_currency(&self) -> Result<common_enums::Currency, Error> {
self.original_payment_authorized_currency
.ok_or_else(missing_field_err("original_payment_authorized_currency"))
}
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct ConnectorResponseData {
pub additional_payment_method_data: Option<AdditionalPaymentMethodConnectorResponse>,
extended_authorization_response_data: Option<ExtendedAuthorizationResponseData>,
is_overcapture_enabled: Option<bool>,
}
impl ConnectorResponseData {
pub fn with_additional_payment_method_data(
additional_payment_method_data: AdditionalPaymentMethodConnectorResponse,
) -> Self {
Self {
additional_payment_method_data: Some(additional_payment_method_data),
extended_authorization_response_data: None,
is_overcapture_enabled: None,
}
}
pub fn new(
additional_payment_method_data: Option<AdditionalPaymentMethodConnectorResponse>,
is_overcapture_enabled: Option<bool>,
extended_authorization_response_data: Option<ExtendedAuthorizationResponseData>,
) -> Self {
Self {
additional_payment_method_data,
extended_authorization_response_data,
is_overcapture_enabled,
}
}
pub fn get_extended_authorization_response_data(
&self,
) -> Option<&ExtendedAuthorizationResponseData> {
self.extended_authorization_response_data.as_ref()
}
pub fn is_overcapture_enabled(&self) -> Option<bool> {
self.is_overcapture_enabled
}
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub enum AdditionalPaymentMethodConnectorResponse {
Card {
/// Details regarding the authentication details of the connector, if this is a 3ds payment.
authentication_data: Option<serde_json::Value>,
| {
"chunk": 2,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_7969894047322031300_3 | clm | mini_chunk | // connector-service/backend/domain_types/src/router_data.rs
/// Various payment checks that are done for a payment
payment_checks: Option<serde_json::Value>,
/// Card Network returned by the processor
card_network: Option<String>,
/// Domestic(Co-Branded) Card network returned by the processor
domestic_network: Option<String>,
},
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct ExtendedAuthorizationResponseData {
pub extended_authentication_applied: Option<bool>,
pub capture_before: Option<time::PrimitiveDateTime>,
}
| {
"chunk": 3,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_4311916100995806462_0 | clm | mini_chunk | // connector-service/backend/domain_types/src/errors.rs
use common_utils::errors::ErrorSwitch;
// use api_models::errors::types::{ Extra};
use strum::Display;
#[derive(Debug, thiserror::Error, PartialEq, Clone)]
pub enum ApiClientError {
#[error("Header map construction failed")]
HeaderMapConstructionFailed,
#[error("Invalid proxy configuration")]
InvalidProxyConfiguration,
#[error("Client construction failed")]
ClientConstructionFailed,
#[error("Certificate decode failed")]
CertificateDecodeFailed,
#[error("Request body serialization failed")]
BodySerializationFailed,
#[error("Unexpected state reached/Invariants conflicted")]
UnexpectedState,
#[error("Url Parsing Failed")]
UrlParsingFailed,
#[error("URL encoding of request payload failed")]
UrlEncodingFailed,
#[error("Failed to send request to connector {0}")]
RequestNotSent(String),
#[error("Failed to decode response")]
ResponseDecodingFailed,
#[error("Server responded with Request Timeout")]
RequestTimeoutReceived,
#[error("connection closed before a message could complete")]
ConnectionClosedIncompleteMessage,
#[error("Server responded with Internal Server Error")]
InternalServerErrorReceived,
#[error("Server responded with Bad Gateway")]
BadGatewayReceived,
#[error("Server responded with Service Unavailable")]
ServiceUnavailableReceived,
#[error("Server responded with Gateway Timeout")]
GatewayTimeoutReceived,
#[error("Server responded with unexpected response")]
UnexpectedServerResponse,
}
#[derive(Debug, Clone, thiserror::Error, Display)]
pub enum ApplicationErrorResponse {
Unauthorized(ApiError),
ForbiddenCommonResource(ApiError),
ForbiddenPrivateResource(ApiError),
Conflict(ApiError),
Gone(ApiError),
Unprocessable(ApiError),
InternalServerError(ApiError),
NotImplemented(ApiError),
NotFound(ApiError),
MethodNotAllowed(ApiError),
BadRequest(ApiError),
DomainError(ApiError),
}
#[derive(Debug, serde::Serialize, Clone)]
pub struct ApiError {
pub sub_code: String,
pub error_identifier: u16,
pub error_message: String,
pub error_object: Option<serde_json::Value>,
}
#[derive(Debug, thiserror::Error)]
pub enum ParsingError {
#[error("Failed to parse struct: {0}")]
StructParseFailure(&'static str),
#[error("Failed to serialize to {0} format")]
EncodeError(&'static str),
}
#[derive(Clone, Debug, serde::Serialize)]
#[serde(rename_all = "snake_case")]
pub enum ErrorType {
InvalidRequestError,
ObjectNotFound,
RouterError,
ProcessingError,
BadGateway,
ServerNotAvailable,
DuplicateRequest,
ValidationError,
ConnectorError,
LockTimeout,
}
// CE Connector Error Errors originating from connector's end
// HE Hyperswitch Error Errors originating from Hyperswitch's end
// IR Invalid Request Error Error caused due to invalid fields and values in API request
// WE Webhook Error Errors related to Webhooks
#[derive(Debug, Clone, router_derive::ApiError)]
#[error(error_type_enum = ErrorType)]
pub enum ApiErrorResponse {
#[error(error_type = ErrorType::ConnectorError, code = "CE_00", message = "{code}: {message}", ignore = "status_code")]
ExternalConnectorError {
code: String,
message: String,
connector: String,
status_code: u16,
reason: Option<String>,
},
#[error(error_type = ErrorType::ProcessingError, code = "CE_01", message = "Payment failed during authorization with connector. Retry payment")]
PaymentAuthorizationFailed { data: Option<serde_json::Value> },
#[error(error_type = ErrorType::ProcessingError, code = "CE_02", message = "Payment failed during authentication with connector. Retry payment")]
PaymentAuthenticationFailed { data: Option<serde_json::Value> },
#[error(error_type = ErrorType::ProcessingError, code = "CE_03", message = "Capture attempt failed while processing with connector")]
PaymentCaptureFailed { data: Option<serde_json::Value> },
#[error(error_type = ErrorType::ProcessingError, code = "CE_04", message = "The card data is invalid")]
InvalidCardData { data: Option<serde_json::Value> },
#[error(error_type = ErrorType::ProcessingError, code = "CE_05", message = "The card has expired")]
CardExpired { data: Option<serde_json::Value> },
| {
"chunk": 0,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_4311916100995806462_1 | clm | mini_chunk | // connector-service/backend/domain_types/src/errors.rs
#[error(error_type = ErrorType::ProcessingError, code = "CE_06", message = "Refund failed while processing with connector. Retry refund")]
RefundFailed { data: Option<serde_json::Value> },
#[error(error_type = ErrorType::ProcessingError, code = "CE_07", message = "Verification failed while processing with connector. Retry operation")]
VerificationFailed { data: Option<serde_json::Value> },
#[error(error_type = ErrorType::ProcessingError, code = "CE_08", message = "Dispute operation failed while processing with connector. Retry operation")]
DisputeFailed { data: Option<serde_json::Value> },
#[error(error_type = ErrorType::LockTimeout, code = "HE_00", message = "Resource is busy. Please try again later.")]
ResourceBusy,
#[error(error_type = ErrorType::ServerNotAvailable, code = "HE_00", message = "Something went wrong")]
InternalServerError,
#[error(error_type = ErrorType::ServerNotAvailable, code= "HE_00", message = "{component} health check is failing with error: {message}")]
HealthCheckError {
component: &'static str,
message: String,
},
#[error(error_type = ErrorType::ValidationError, code = "HE_00", message = "Failed to convert currency to minor unit")]
CurrencyConversionFailed,
#[error(error_type = ErrorType::DuplicateRequest, code = "HE_01", message = "Duplicate refund request. Refund already attempted with the refund ID")]
DuplicateRefundRequest,
#[error(error_type = ErrorType::DuplicateRequest, code = "HE_01", message = "Duplicate mandate request. Mandate already attempted with the Mandate ID")]
DuplicateMandate,
#[error(error_type = ErrorType::DuplicateRequest, code = "HE_01", message = "The merchant account with the specified details already exists in our records")]
DuplicateMerchantAccount,
#[error(error_type = ErrorType::DuplicateRequest, code = "HE_01", message = "The merchant connector account with the specified profile_id '{profile_id}' and connector_label '{connector_label}' already exists in our records")]
DuplicateMerchantConnectorAccount {
profile_id: String,
connector_label: String,
},
#[error(error_type = ErrorType::DuplicateRequest, code = "HE_01", message = "The payment method with the specified details already exists in our records")]
DuplicatePaymentMethod,
#[error(error_type = ErrorType::DuplicateRequest, code = "HE_01", message = "The payment with the specified payment_id already exists in our records")]
DuplicatePayment {
payment_id: common_utils::id_type::PaymentId,
},
#[error(error_type = ErrorType::DuplicateRequest, code = "HE_01", message = "The payout with the specified payout_id '{payout_id}' already exists in our records")]
DuplicatePayout { payout_id: String },
#[error(error_type = ErrorType::DuplicateRequest, code = "HE_01", message = "The config with the specified key already exists in our records")]
DuplicateConfig,
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Refund does not exist in our records")]
RefundNotFound,
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Payment Link does not exist in our records")]
PaymentLinkNotFound,
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Customer does not exist in our records")]
CustomerNotFound,
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Config key does not exist in our records.")]
ConfigNotFound,
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Payment does not exist in our records")]
PaymentNotFound,
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Payment method does not exist in our records")]
PaymentMethodNotFound,
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Merchant account does not exist in our records")]
MerchantAccountNotFound,
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Merchant connector account does not exist in our records")]
MerchantConnectorAccountNotFound { id: String },
| {
"chunk": 1,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_4311916100995806462_2 | clm | mini_chunk | // connector-service/backend/domain_types/src/errors.rs
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Business profile with the given id '{id}' does not exist in our records")]
ProfileNotFound { id: String },
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Profile acquirer with id '{profile_acquirer_id}' not found for profile '{profile_id}'.")]
ProfileAcquirerNotFound {
profile_acquirer_id: String,
profile_id: String,
},
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Poll with the given id '{id}' does not exist in our records")]
PollNotFound { id: String },
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Resource ID does not exist in our records")]
ResourceIdNotFound,
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Mandate does not exist in our records")]
MandateNotFound,
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Authentication does not exist in our records")]
AuthenticationNotFound { id: String },
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Failed to update mandate")]
MandateUpdateFailed,
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "API Key does not exist in our records")]
ApiKeyNotFound,
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Payout does not exist in our records")]
PayoutNotFound,
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_02", message = "Event does not exist in our records")]
EventNotFound,
#[error(error_type = ErrorType::ValidationError, code = "HE_03", message = "Invalid mandate id passed from connector")]
MandateSerializationFailed,
#[error(error_type = ErrorType::ValidationError, code = "HE_03", message = "Unable to parse the mandate identifier passed from connector")]
MandateDeserializationFailed,
#[error(error_type = ErrorType::ValidationError, code = "HE_03", message = "Return URL is not configured and not passed in payments request")]
ReturnUrlUnavailable,
#[error(error_type = ErrorType::ValidationError, code = "HE_03", message = "This refund is not possible through Hyperswitch. Please raise the refund through {connector} dashboard")]
RefundNotPossible { connector: String },
#[error(error_type = ErrorType::ValidationError, code = "HE_03", message = "Mandate Validation Failed" )]
MandateValidationFailed { reason: String },
#[error(error_type= ErrorType::ValidationError, code = "HE_03", message = "The payment has not succeeded yet. Please pass a successful payment to initiate refund")]
PaymentNotSucceeded,
#[error(error_type = ErrorType::ValidationError, code = "HE_03", message = "The specified merchant connector account is disabled")]
MerchantConnectorAccountDisabled,
#[error(error_type = ErrorType::ValidationError, code = "HE_03", message = "{code}: {message}")]
PaymentBlockedError {
code: u16,
message: String,
status: String,
reason: String,
},
#[error(error_type = ErrorType::ValidationError, code = "HE_03", message = "File validation failed")]
FileValidationFailed { reason: String },
#[error(error_type = ErrorType::ValidationError, code = "HE_03", message = "Dispute status validation failed")]
DisputeStatusValidationFailed { reason: String },
#[error(error_type= ErrorType::ObjectNotFound, code = "HE_04", message = "Successful payment not found for the given payment id")]
SuccessfulPaymentNotFound,
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_04", message = "The connector provided in the request is incorrect or not available")]
IncorrectConnectorNameGiven,
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_04", message = "Address does not exist in our records")]
AddressNotFound,
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_04", message = "Dispute does not exist in our records")]
DisputeNotFound { dispute_id: String },
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_04", message = "File does not exist in our records")]
FileNotFound,
| {
"chunk": 2,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_4311916100995806462_3 | clm | mini_chunk | // connector-service/backend/domain_types/src/errors.rs
#[error(error_type = ErrorType::ObjectNotFound, code = "HE_04", message = "File not available")]
FileNotAvailable,
#[error(error_type = ErrorType::ProcessingError, code = "HE_05", message = "Missing tenant id")]
MissingTenantId,
#[error(error_type = ErrorType::ProcessingError, code = "HE_05", message = "Invalid tenant id: {tenant_id}")]
InvalidTenant { tenant_id: String },
#[error(error_type = ErrorType::ValidationError, code = "HE_06", message = "Failed to convert amount to {amount_type} type")]
AmountConversionFailed { amount_type: &'static str },
#[error(error_type = ErrorType::ServerNotAvailable, code = "IR_00", message = "{message:?}")]
NotImplemented { message: NotImplementedMessage },
#[error(
error_type = ErrorType::InvalidRequestError, code = "IR_01",
message = "API key not provided or invalid API key used"
)]
Unauthorized,
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_02", message = "Unrecognized request URL")]
InvalidRequestUrl,
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_03", message = "The HTTP method is not applicable for this API")]
InvalidHttpMethod,
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_04", message = "Missing required param: {field_name}")]
MissingRequiredField { field_name: &'static str },
#[error(
error_type = ErrorType::InvalidRequestError, code = "IR_05",
message = "{field_name} contains invalid data. Expected format is {expected_format}"
)]
InvalidDataFormat {
field_name: String,
expected_format: String,
},
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_06", message = "{message}")]
InvalidRequestData { message: String },
/// Typically used when a field has invalid value, or deserialization of the value contained in a field fails.
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_07", message = "Invalid value provided: {field_name}")]
InvalidDataValue { field_name: &'static str },
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_08", message = "Client secret was not provided")]
ClientSecretNotGiven,
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_08", message = "Client secret has expired")]
ClientSecretExpired,
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_09", message = "The client_secret provided does not match the client_secret associated with the Payment")]
ClientSecretInvalid,
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_10", message = "Customer has active mandate/subsciption")]
MandateActive,
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_11", message = "Customer has already been redacted")]
CustomerRedacted,
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_12", message = "Reached maximum refund attempts")]
MaximumRefundCount,
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_13", message = "The refund amount exceeds the amount captured")]
RefundAmountExceedsPaymentAmount,
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_14", message = "This Payment could not be {current_flow} because it has a {field_name} of {current_value}. The expected state is {states}")]
PaymentUnexpectedState {
current_flow: String,
field_name: String,
current_value: String,
states: String,
},
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_15", message = "Invalid Ephemeral Key for the customer")]
InvalidEphemeralKey,
/// Typically used when information involving multiple fields or previously provided information doesn't satisfy a condition.
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_16", message = "{message}")]
PreconditionFailed { message: String },
#[error(
error_type = ErrorType::InvalidRequestError, code = "IR_17",
message = "Access forbidden, invalid JWT token was used"
)]
InvalidJwtToken,
#[error(
error_type = ErrorType::InvalidRequestError, code = "IR_18",
message = "{message}",
| {
"chunk": 3,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_4311916100995806462_4 | clm | mini_chunk | // connector-service/backend/domain_types/src/errors.rs
)]
GenericUnauthorized { message: String },
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_19", message = "{message}")]
NotSupported { message: String },
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_20", message = "{flow} flow not supported by the {connector} connector")]
FlowNotSupported { flow: String, connector: String },
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_21", message = "Missing required params")]
MissingRequiredFields { field_names: Vec<&'static str> },
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_22", message = "Access forbidden. Not authorized to access this resource {resource}")]
AccessForbidden { resource: String },
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_23", message = "{message}")]
FileProviderNotSupported { message: String },
#[error(
error_type = ErrorType::ProcessingError, code = "IR_24",
message = "Invalid {wallet_name} wallet token"
)]
InvalidWalletToken { wallet_name: String },
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_25", message = "Cannot delete the default payment method")]
PaymentMethodDeleteFailed,
#[error(
error_type = ErrorType::InvalidRequestError, code = "IR_26",
message = "Invalid Cookie"
)]
InvalidCookie,
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_27", message = "Extended card info does not exist")]
ExtendedCardInfoNotFound,
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_28", message = "{message}")]
CurrencyNotSupported { message: String },
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_29", message = "{message}")]
UnprocessableEntity { message: String },
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_30", message = "Merchant connector account is configured with invalid {config}")]
InvalidConnectorConfiguration { config: String },
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_31", message = "Card with the provided iin does not exist")]
InvalidCardIin,
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_32", message = "The provided card IIN length is invalid, please provide an iin with 6 or 8 digits")]
InvalidCardIinLength,
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_33", message = "File not found / valid in the request")]
MissingFile,
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_34", message = "Dispute id not found in the request")]
MissingDisputeId,
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_35", message = "File purpose not found in the request or is invalid")]
MissingFilePurpose,
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_36", message = "File content type not found / valid")]
MissingFileContentType,
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_37", message = "{message}")]
GenericNotFoundError { message: String },
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_38", message = "{message}")]
GenericDuplicateError { message: String },
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_39", message = "required payment method is not configured or configured incorrectly for all configured connectors")]
IncorrectPaymentMethodConfiguration,
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_40", message = "{message}")]
LinkConfigurationError { message: String },
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_41", message = "Payout validation failed")]
PayoutFailed { data: Option<serde_json::Value> },
#[error(
error_type = ErrorType::InvalidRequestError, code = "IR_42",
message = "Cookies are not found in the request"
)]
CookieNotFound,
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_43", message = "API does not support platform account operation")]
PlatformAccountAuthNotSupported,
| {
"chunk": 4,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_4311916100995806462_5 | clm | mini_chunk | // connector-service/backend/domain_types/src/errors.rs
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_44", message = "Invalid platform account operation")]
InvalidPlatformOperation,
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_45", message = "External vault failed during processing with connector")]
ExternalVaultFailed,
#[error(error_type = ErrorType::InvalidRequestError, code = "WE_01", message = "Failed to authenticate the webhook")]
WebhookAuthenticationFailed,
#[error(error_type = ErrorType::InvalidRequestError, code = "WE_02", message = "Bad request received in webhook")]
WebhookBadRequest,
#[error(error_type = ErrorType::RouterError, code = "WE_03", message = "There was some issue processing the webhook")]
WebhookProcessingFailure,
#[error(error_type = ErrorType::ObjectNotFound, code = "WE_04", message = "Webhook resource not found")]
WebhookResourceNotFound,
#[error(error_type = ErrorType::InvalidRequestError, code = "WE_05", message = "Unable to process the webhook body")]
WebhookUnprocessableEntity,
#[error(error_type = ErrorType::InvalidRequestError, code = "WE_06", message = "Merchant Secret set my merchant for webhook source verification is invalid")]
WebhookInvalidMerchantSecret,
#[error(error_type = ErrorType::ServerNotAvailable, code = "IE", message = "{reason} as data mismatched for {field_names}")]
IntegrityCheckFailed {
reason: String,
field_names: String,
connector_transaction_id: Option<String>,
},
}
#[derive(Clone)]
pub enum NotImplementedMessage {
Reason(String),
Default,
}
impl std::fmt::Debug for NotImplementedMessage {
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Reason(message) => write!(fmt, "{message} is not implemented"),
Self::Default => {
write!(
fmt,
"This API is under development and will be made available soon."
)
}
}
}
}
impl ::core::fmt::Display for ApiErrorResponse {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
r#"{{"error":{}}}"#,
serde_json::to_string(self).unwrap_or_else(|_| "API error response".to_string())
)
}
}
// impl ErrorSwitch<api_models::errors::types::ApiErrorResponse> for ApiErrorResponse {
// fn switch(&self) -> api_models::errors::types::ApiErrorResponse {
// use api_models::errors::types::{ApiError, ApiErrorResponse as AER};
// match self {
// Self::ExternalConnectorError {
// code,
// message,
// connector,
// reason,
// status_code,
// } => AER::ConnectorError(ApiError::new("CE", 0, format!("{code}: {message}"), Some(Extra {connector: Some(connector.clone()), reason: reason.to_owned(), ..Default::default()})), StatusCode::from_u16(*status_code).unwrap_or(StatusCode::INTERNAL_SERVER_ERROR)),
// Self::PaymentAuthorizationFailed { data } => {
// AER::BadRequest(ApiError::new("CE", 1, "Payment failed during authorization with connector. Retry payment", Some(Extra { data: data.clone(), ..Default::default()})))
// }
// Self::PaymentAuthenticationFailed { data } => {
// AER::BadRequest(ApiError::new("CE", 2, "Payment failed during authentication with connector. Retry payment", Some(Extra { data: data.clone(), ..Default::default()})))
// }
// Self::PaymentCaptureFailed { data } => {
// AER::BadRequest(ApiError::new("CE", 3, "Capture attempt failed while processing with connector", Some(Extra { data: data.clone(), ..Default::default()})))
// }
// Self::InvalidCardData { data } => AER::BadRequest(ApiError::new("CE", 4, "The card data is invalid", Some(Extra { data: data.clone(), ..Default::default()}))),
// Self::CardExpired { data } => AER::BadRequest(ApiError::new("CE", 5, "The card has expired", Some(Extra { data: data.clone(), ..Default::default()}))),
| {
"chunk": 5,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_4311916100995806462_6 | clm | mini_chunk | // connector-service/backend/domain_types/src/errors.rs
// Self::RefundFailed { data } => AER::BadRequest(ApiError::new("CE", 6, "Refund failed while processing with connector. Retry refund", Some(Extra { data: data.clone(), ..Default::default()}))),
// Self::VerificationFailed { data } => {
// AER::BadRequest(ApiError::new("CE", 7, "Verification failed while processing with connector. Retry operation", Some(Extra { data: data.clone(), ..Default::default()})))
// },
// Self::DisputeFailed { data } => {
// AER::BadRequest(ApiError::new("CE", 8, "Dispute operation failed while processing with connector. Retry operation", Some(Extra { data: data.clone(), ..Default::default()})))
// }
// Self::ResourceBusy => {
// AER::Unprocessable(ApiError::new("HE", 0, "There was an issue processing the webhook body", None))
// }
// Self::CurrencyConversionFailed => {
// AER::Unprocessable(ApiError::new("HE", 0, "Failed to convert currency to minor unit", None))
// }
// Self::InternalServerError => {
// AER::InternalServerError(ApiError::new("HE", 0, "Something went wrong", None))
// },
// Self::HealthCheckError { message,component } => {
// AER::InternalServerError(ApiError::new("HE",0,format!("{} health check failed with error: {}",component,message),None))
// },
// Self::DuplicateRefundRequest => AER::BadRequest(ApiError::new("HE", 1, "Duplicate refund request. Refund already attempted with the refund ID", None)),
// Self::DuplicateMandate => AER::BadRequest(ApiError::new("HE", 1, "Duplicate mandate request. Mandate already attempted with the Mandate ID", None)),
// Self::DuplicateMerchantAccount => AER::BadRequest(ApiError::new("HE", 1, "The merchant account with the specified details already exists in our records", None)),
// Self::DuplicateMerchantConnectorAccount { profile_id, connector_label: connector_name } => {
// AER::BadRequest(ApiError::new("HE", 1, format!("The merchant connector account with the specified profile_id '{profile_id}' and connector_label '{connector_name}' already exists in our records"), None))
// }
// Self::DuplicatePaymentMethod => AER::BadRequest(ApiError::new("HE", 1, "The payment method with the specified details already exists in our records", None)),
// Self::DuplicatePayment { payment_id } => {
// AER::BadRequest(ApiError::new("HE", 1, "The payment with the specified payment_id already exists in our records", Some(Extra {reason: Some(format!("{payment_id:?} already exists")), ..Default::default()})))
// }
// Self::DuplicatePayout { payout_id } => {
// AER::BadRequest(ApiError::new("HE", 1, format!("The payout with the specified payout_id '{payout_id}' already exists in our records"), None))
// }
// Self::DuplicateConfig => {
// AER::BadRequest(ApiError::new("HE", 1, "The config with the specified key already exists in our records", None))
// }
// Self::RefundNotFound => {
// AER::NotFound(ApiError::new("HE", 2, "Refund does not exist in our records.", None))
// }
// Self::PaymentLinkNotFound => {
// AER::NotFound(ApiError::new("HE", 2, "Payment Link does not exist in our records", None))
// }
// Self::CustomerNotFound => {
// AER::NotFound(ApiError::new("HE", 2, "Customer does not exist in our records", None))
// }
// Self::ConfigNotFound => {
// AER::NotFound(ApiError::new("HE", 2, "Config key does not exist in our records.", None))
// },
// Self::PaymentNotFound => {
// AER::NotFound(ApiError::new("HE", 2, "Payment does not exist in our records", None))
// }
// Self::PaymentMethodNotFound => {
// AER::NotFound(ApiError::new("HE", 2, "Payment method does not exist in our records", None))
| {
"chunk": 6,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_mini_domain_types_4311916100995806462_7 | clm | mini_chunk | // connector-service/backend/domain_types/src/errors.rs
// }
// Self::MerchantAccountNotFound => {
// AER::NotFound(ApiError::new("HE", 2, "Merchant account does not exist in our records", None))
// }
// Self::MerchantConnectorAccountNotFound {id } => {
// AER::NotFound(ApiError::new("HE", 2, "Merchant connector account does not exist in our records", Some(Extra {reason: Some(format!("{id} does not exist")), ..Default::default()})))
// }
// Self::ProfileNotFound { id } => {
// AER::NotFound(ApiError::new("HE", 2, format!("Business profile with the given id {id} does not exist"), None))
// }
// Self::ProfileAcquirerNotFound { profile_acquirer_id, profile_id } => {
// AER::NotFound(ApiError::new("HE", 2, format!("Profile acquirer with id '{profile_acquirer_id}' not found for profile '{profile_id}'."), None))
// }
// Self::PollNotFound { .. } => {
// AER::NotFound(ApiError::new("HE", 2, "Poll does not exist in our records", None))
// },
// Self::ResourceIdNotFound => {
// AER::NotFound(ApiError::new("HE", 2, "Resource ID does not exist in our records", None))
// }
// Self::MandateNotFound => {
// AER::NotFound(ApiError::new("HE", 2, "Mandate does not exist in our records", None))
// }
// Self::AuthenticationNotFound { .. } => {
// AER::NotFound(ApiError::new("HE", 2, "Authentication does not exist in our records", None))
// },
// Self::MandateUpdateFailed => {
// AER::InternalServerError(ApiError::new("HE", 2, "Mandate update failed", None))
// },
// Self::ApiKeyNotFound => {
// AER::NotFound(ApiError::new("HE", 2, "API Key does not exist in our records", None))
// }
// Self::PayoutNotFound => {
// AER::NotFound(ApiError::new("HE", 2, "Payout does not exist in our records", None))
// }
// Self::EventNotFound => {
// AER::NotFound(ApiError::new("HE", 2, "Event does not exist in our records", None))
// }
// Self::MandateSerializationFailed | Self::MandateDeserializationFailed => {
// AER::InternalServerError(ApiError::new("HE", 3, "Something went wrong", None))
// },
// Self::ReturnUrlUnavailable => AER::NotFound(ApiError::new("HE", 3, "Return URL is not configured and not passed in payments request", None)),
// Self::RefundNotPossible { connector } => {
// AER::BadRequest(ApiError::new("HE", 3, format!("This refund is not possible through Hyperswitch. Please raise the refund through {connector} dashboard"), None))
// }
// Self::MandateValidationFailed { reason } => {
// AER::BadRequest(ApiError::new("HE", 3, "Mandate Validation Failed", Some(Extra { reason: Some(reason.to_owned()), ..Default::default() })))
// }
// Self::PaymentNotSucceeded => AER::BadRequest(ApiError::new("HE", 3, "The payment has not succeeded yet. Please pass a successful payment to initiate refund", None)),
// Self::MerchantConnectorAccountDisabled => {
// AER::BadRequest(ApiError::new("HE", 3, "The selected merchant connector account is disabled", None))
// }
// Self::PaymentBlockedError {
// message,
// reason,
// ..
// } => AER::DomainError(ApiError::new("HE", 3, message, Some(Extra { reason: Some(reason.clone()), ..Default::default() }))),
// Self::FileValidationFailed { reason } => {
// AER::BadRequest(ApiError::new("HE", 3, format!("File validation failed {reason}"), None))
// }
// Self::DisputeStatusValidationFailed { .. } => {
// AER::BadRequest(ApiError::new("HE", 3, "Dispute status validation failed", None))
// }
// Self::SuccessfulPaymentNotFound => {
| {
"chunk": 7,
"crate": "domain_types",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.