id stringlengths 11 116 | type stringclasses 1 value | granularity stringclasses 4 values | content stringlengths 16 477k | metadata dict |
|---|---|---|---|---|
fn_clm_hyperswitch_connectors_get_checkout_status_4163975418731467342 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/klarna/transformers
fn get_checkout_status(
klarna_status: KlarnaCheckoutStatus,
is_auto_capture: bool,
) -> common_enums::AttemptStatus {
match klarna_status {
KlarnaCheckoutStatus::CheckoutIncomplete => {
if is_auto_capture {
common_enums::AttemptStatus::AuthenticationPending
} else {
common_enums::AttemptStatus::Authorized
}
}
KlarnaCheckoutStatus::CheckoutComplete => common_enums::AttemptStatus::Charged,
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 0,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_try_from_-5181798244873136414 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/chargebee/transformers
// Implementation of RouterData<F, T, GetSubscriptionPlanPricesResponse> for TryFrom<
ResponseRouterData<F, ChargebeeGetPlanPricesResponse, T, GetSubscriptionPlanPricesResponse>,
>
fn try_from(
item: ResponseRouterData<
F,
ChargebeeGetPlanPricesResponse,
T,
GetSubscriptionPlanPricesResponse,
>,
) -> Result<Self, Self::Error> {
let plan_prices = item
.response
.list
.into_iter()
.map(|prices| subscriptions::SubscriptionPlanPrices {
price_id: prices.item_price.id,
plan_id: prices.item_price.item_id,
amount: prices.item_price.price,
currency: prices.item_price.currency_code,
interval: match prices.item_price.period_unit {
ChargebeePeriodUnit::Day => subscriptions::PeriodUnit::Day,
ChargebeePeriodUnit::Week => subscriptions::PeriodUnit::Week,
ChargebeePeriodUnit::Month => subscriptions::PeriodUnit::Month,
ChargebeePeriodUnit::Year => subscriptions::PeriodUnit::Year,
},
interval_count: prices.item_price.period,
trial_period: prices.item_price.trial_period,
trial_period_unit: match prices.item_price.trial_period_unit {
Some(ChargebeeTrialPeriodUnit::Day) => Some(subscriptions::PeriodUnit::Day),
Some(ChargebeeTrialPeriodUnit::Month) => Some(subscriptions::PeriodUnit::Month),
None => None,
},
})
.collect();
Ok(Self {
response: Ok(GetSubscriptionPlanPricesResponse { list: plan_prices }),
..item.data
})
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2663,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_from_-5181798244873136414 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/chargebee/transformers
// Implementation of connector_enums::InvoiceStatus for From<ChargebeeInvoiceStatus>
fn from(status: ChargebeeInvoiceStatus) -> Self {
match status {
ChargebeeInvoiceStatus::Paid => Self::InvoicePaid,
ChargebeeInvoiceStatus::Posted => Self::PaymentPendingTimeout,
ChargebeeInvoiceStatus::PaymentDue => Self::PaymentPending,
ChargebeeInvoiceStatus::NotPaid => Self::PaymentFailed,
ChargebeeInvoiceStatus::Voided => Self::Voided,
ChargebeeInvoiceStatus::Pending => Self::InvoiceCreated,
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2600,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_get_webhook_object_from_body_-5181798244873136414 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/chargebee/transformers
// Inherent implementation for ChargebeeWebhookBody
pub fn get_webhook_object_from_body(body: &[u8]) -> CustomResult<Self, errors::ConnectorError> {
let webhook_body = body
.parse_struct::<Self>("ChargebeeWebhookBody")
.change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?;
Ok(webhook_body)
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 140,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_get_invoice_webhook_data_from_body_-5181798244873136414 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/chargebee/transformers
// Inherent implementation for ChargebeeInvoiceBody
pub fn get_invoice_webhook_data_from_body(
body: &[u8],
) -> CustomResult<Self, errors::ConnectorError> {
let webhook_body = body
.parse_struct::<Self>("ChargebeeInvoiceBody")
.change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?;
Ok(webhook_body)
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 41,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_find_connector_ids_-5181798244873136414 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/chargebee/transformers
// Implementation of None for ChargebeeCustomer
pub fn find_connector_ids(&self) -> Result<ChargebeeMandateDetails, errors::ConnectorError> {
match self.payment_method.gateway {
ChargebeeGateway::Stripe | ChargebeeGateway::Braintree => {
let mut parts = self.payment_method.reference_id.split('/');
let customer_id = parts
.next()
.ok_or(errors::ConnectorError::WebhookBodyDecodingFailed)?
.to_string();
let mandate_id = parts
.next_back()
.ok_or(errors::ConnectorError::WebhookBodyDecodingFailed)?
.to_string();
Ok(ChargebeeMandateDetails {
customer_id,
mandate_id,
})
}
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 32,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_try_from_7515447025025330370 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/nordea/transformers
// Implementation of PaymentsSyncRouterData for TryFrom<PaymentsSyncResponseRouterData<NordeaPaymentsInitiateResponse>>
fn try_from(
item: PaymentsSyncResponseRouterData<NordeaPaymentsInitiateResponse>,
) -> Result<Self, Self::Error> {
let (response, status) = convert_nordea_payment_response(&item.response)?;
Ok(Self {
status,
response: Ok(response),
..item.data
})
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2659,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_from_7515447025025330370 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/nordea/transformers
// Implementation of common_enums::AttemptStatus for From<NordeaPaymentStatus>
fn from(item: NordeaPaymentStatus) -> Self {
match item {
NordeaPaymentStatus::Confirmed | NordeaPaymentStatus::Paid => Self::Charged,
NordeaPaymentStatus::PendingConfirmation
| NordeaPaymentStatus::PendingSecondConfirmation => Self::ConfirmationAwaited,
NordeaPaymentStatus::PendingUserApproval => Self::AuthenticationPending,
NordeaPaymentStatus::OnHold | NordeaPaymentStatus::Unknown => Self::Pending,
NordeaPaymentStatus::Rejected
| NordeaPaymentStatus::InsufficientFunds
| NordeaPaymentStatus::LimitExceeded
| NordeaPaymentStatus::UserApprovalFailed
| NordeaPaymentStatus::UserApprovalTimeout
| NordeaPaymentStatus::UserApprovalCancelled => Self::Failure,
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2600,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_deserialize_7515447025025330370 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/nordea/transformers
// Implementation of PaymentsUrgency for Deserialize<'de>
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
let s = String::deserialize(deserializer)?.to_lowercase();
match s.as_str() {
"standard" => Ok(Self::Standard),
"express" => Ok(Self::Express),
"sameday" => Ok(Self::Sameday),
_ => Err(serde::de::Error::unknown_variant(
&s,
&["standard", "express", "sameday"],
)),
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 142,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_get_error_data_7515447025025330370 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/nordea/transformers
pub fn get_error_data(error_response: Option<&NordeaErrorBody>) -> Option<&NordeaFailures> {
error_response
.and_then(|error| error.nordea_failures.as_ref())
.and_then(|failures| failures.first())
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 27,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_get_creditor_account_from_metadata_7515447025025330370 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/nordea/transformers
fn get_creditor_account_from_metadata(
router_data: &PaymentsPreProcessingRouterData,
) -> Result<CreditorAccount, Error> {
let metadata: NordeaConnectorMetadataObject =
utils::to_connector_meta_from_secret(router_data.connector_meta_data.clone())
.change_context(errors::ConnectorError::InvalidConnectorConfig {
config: "merchant_connector_account.metadata",
})?;
let creditor_account = CreditorAccount {
account: AccountNumber {
account_type: AccountType::try_from(metadata.account_type.as_str())
.unwrap_or(AccountType::Iban),
currency: router_data.request.currency,
value: metadata.destination_account_number,
},
country: router_data.get_optional_billing_country(),
// Merchant is the beneficiary in this case
name: Some(metadata.merchant_name),
message: router_data
.description
.as_ref()
.map(|desc| desc.chars().take(20).collect::<String>()),
bank: Some(CreditorBank {
address: None,
bank_code: None,
bank_name: None,
business_identifier_code: None,
country: router_data.get_billing_country()?,
}),
creditor_address: None,
// Either Reference or Message must be supplied in the request
reference: None,
};
Ok(creditor_account)
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 24,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_try_from_3125594657675169093 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/helcim/transformers
// Implementation of RefundsRouterData<RSync> for TryFrom<RefundsResponseRouterData<RSync, RefundResponse>>
fn try_from(
item: RefundsResponseRouterData<RSync, RefundResponse>,
) -> Result<Self, Self::Error> {
Ok(Self {
response: Ok(RefundsResponseData {
connector_refund_id: item.response.transaction_id.to_string(),
refund_status: enums::RefundStatus::from(item.response),
}),
..item.data
})
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2661,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_from_3125594657675169093 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/helcim/transformers
// Implementation of enums::RefundStatus for From<RefundResponse>
fn from(item: RefundResponse) -> Self {
match item.transaction_type {
HelcimRefundTransactionType::Refund => match item.status {
HelcimPaymentStatus::Approved => Self::Success,
HelcimPaymentStatus::Declined => Self::Failure,
},
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2600,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_check_currency_3125594657675169093 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/helcim/transformers
pub fn check_currency(
currency: enums::Currency,
) -> Result<enums::Currency, errors::ConnectorError> {
if currency == enums::Currency::USD {
Ok(currency)
} else {
Err(errors::ConnectorError::NotSupported {
message: format!("currency {currency} is not supported for this merchant account"),
connector: "Helcim",
})?
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 10,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_try_from_-3794189006622480709 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/airwallex/transformers
// Implementation of api_models::webhooks::IncomingWebhookEvent for TryFrom<AirwallexWebhookEventType>
fn try_from(value: AirwallexWebhookEventType) -> Result<Self, Self::Error> {
Ok(match value {
AirwallexWebhookEventType::PaymentAttemptFailedToProcess => Self::PaymentIntentFailure,
AirwallexWebhookEventType::PaymentAttemptAuthorized => Self::PaymentIntentSuccess,
AirwallexWebhookEventType::RefundSucceeded => Self::RefundSuccess,
AirwallexWebhookEventType::RefundFailed => Self::RefundFailure,
AirwallexWebhookEventType::DisputeAccepted
| AirwallexWebhookEventType::DisputePreChargebackAccepted => Self::DisputeAccepted,
AirwallexWebhookEventType::DisputeRespondedByMerchant => Self::DisputeChallenged,
AirwallexWebhookEventType::DisputeWon | AirwallexWebhookEventType::DisputeReversed => {
Self::DisputeWon
}
AirwallexWebhookEventType::DisputeLost => Self::DisputeLost,
AirwallexWebhookEventType::Unknown
| AirwallexWebhookEventType::PaymentAttemptAuthenticationRedirected
| AirwallexWebhookEventType::PaymentIntentCreated
| AirwallexWebhookEventType::PaymentIntentRequiresPaymentMethod
| AirwallexWebhookEventType::PaymentIntentCancelled
| AirwallexWebhookEventType::PaymentIntentSucceeded
| AirwallexWebhookEventType::PaymentIntentRequiresCapture
| AirwallexWebhookEventType::PaymentIntentRequiresCustomerAction
| AirwallexWebhookEventType::PaymentAttemptAuthorizationFailed
| AirwallexWebhookEventType::PaymentAttemptCaptureRequested
| AirwallexWebhookEventType::PaymentAttemptCaptureFailed
| AirwallexWebhookEventType::PaymentAttemptAuthenticationFailed
| AirwallexWebhookEventType::PaymentAttemptCancelled
| AirwallexWebhookEventType::PaymentAttemptExpired
| AirwallexWebhookEventType::PaymentAttemptRiskDeclined
| AirwallexWebhookEventType::PaymentAttemptSettled
| AirwallexWebhookEventType::PaymentAttemptPaid
| AirwallexWebhookEventType::RefundReceived
| AirwallexWebhookEventType::RefundAccepted
| AirwallexWebhookEventType::DisputeRfiRespondedByMerchant
| AirwallexWebhookEventType::DisputeReceivedByMerchant => Self::EventNotSupported,
})
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2657,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_from_-3794189006622480709 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/airwallex/transformers
// Implementation of api_models::enums::DisputeStage for From<AirwallexDisputeStage>
fn from(code: AirwallexDisputeStage) -> Self {
match code {
AirwallexDisputeStage::Rfi => Self::PreDispute,
AirwallexDisputeStage::Dispute => Self::Dispute,
AirwallexDisputeStage::Arbitration => Self::PreArbitration,
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2600,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_foreign_try_from_-3794189006622480709 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/airwallex/transformers
// Implementation of RouterData<F, T, PaymentsResponseData> for ForeignTryFrom<ResponseRouterData<F, AirwallexAuthorizeResponse, T, PaymentsResponseData>>
fn foreign_try_from(
item: ResponseRouterData<F, AirwallexAuthorizeResponse, T, PaymentsResponseData>,
) -> Result<Self, Self::Error> {
let ResponseRouterData {
response,
data,
http_code,
} = item;
match response {
AirwallexAuthorizeResponse::AirwallexPaymentsResponse(res) => {
Self::try_from(ResponseRouterData::<
F,
AirwallexPaymentsResponse,
T,
PaymentsResponseData,
> {
response: res,
data,
http_code,
})
}
AirwallexAuthorizeResponse::AirwallexRedirectResponse(res) => {
Self::try_from(ResponseRouterData::<
F,
AirwallexRedirectResponse,
T,
PaymentsResponseData,
> {
response: res,
data,
http_code,
})
}
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 432,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_get_wallet_details_-3794189006622480709 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/airwallex/transformers
fn get_wallet_details(
wallet_data: &WalletData,
item: &AirwallexRouterData<&types::PaymentsAuthorizeRouterData>,
) -> Result<AirwallexPaymentMethod, errors::ConnectorError> {
let wallet_details: AirwallexPaymentMethod = match wallet_data {
WalletData::GooglePay(gpay_details) => {
let token = gpay_details
.tokenization_data
.get_encrypted_google_pay_token()
.attach_printable("Failed to get gpay wallet token")
.map_err(|_| errors::ConnectorError::MissingRequiredField {
field_name: "gpay wallet_token",
})?;
AirwallexPaymentMethod::Wallets(AirwallexWalletData::GooglePay(GooglePayData {
googlepay: GooglePayDetails {
encrypted_payment_token: Secret::new(token.clone()),
payment_data_type: GpayPaymentDataType::EncryptedPaymentToken,
},
payment_method_type: AirwallexPaymentType::Googlepay,
}))
}
WalletData::PaypalRedirect(_paypal_details) => {
AirwallexPaymentMethod::Wallets(AirwallexWalletData::Paypal(PaypalData {
paypal: PaypalDetails {
shopper_name: item
.router_data
.request
.customer_name
.as_ref()
.cloned()
.or_else(|| item.router_data.get_billing_full_name().ok())
.ok_or(errors::ConnectorError::MissingRequiredField {
field_name: "shopper_name",
})?,
country_code: item.router_data.get_billing_country().map_err(|_| {
errors::ConnectorError::MissingRequiredField {
field_name: "country_code",
}
})?,
},
payment_method_type: AirwallexPaymentType::Paypal,
}))
}
WalletData::Skrill(_skrill_details) => {
AirwallexPaymentMethod::Wallets(AirwallexWalletData::Skrill(SkrillData {
skrill: SkrillDetails {
shopper_name: item
.router_data
.request
.customer_name
.as_ref()
.cloned()
.or_else(|| item.router_data.get_billing_full_name().ok())
.ok_or(errors::ConnectorError::MissingRequiredField {
field_name: "shopper_name",
})?,
shopper_email: item.router_data.get_billing_email().map_err(|_| {
errors::ConnectorError::MissingRequiredField {
field_name: "shopper_email",
}
})?,
country_code: item.router_data.get_billing_country().map_err(|_| {
errors::ConnectorError::MissingRequiredField {
field_name: "country_code",
}
})?,
},
payment_method_type: AirwallexPaymentType::Skrill,
}))
}
WalletData::AliPayQr(_)
| WalletData::AliPayRedirect(_)
| WalletData::AliPayHkRedirect(_)
| WalletData::AmazonPayRedirect(_)
| WalletData::Paysera(_)
| WalletData::MomoRedirect(_)
| WalletData::KakaoPayRedirect(_)
| WalletData::GoPayRedirect(_)
| WalletData::GcashRedirect(_)
| WalletData::AmazonPay(_)
| WalletData::ApplePay(_)
| WalletData::BluecodeRedirect {}
| WalletData::ApplePayRedirect(_)
| WalletData::ApplePayThirdPartySdk(_)
| WalletData::DanaRedirect {}
| WalletData::GooglePayRedirect(_)
| WalletData::GooglePayThirdPartySdk(_)
| WalletData::MbWayRedirect(_)
| WalletData::MobilePayRedirect(_)
| WalletData::PaypalSdk(_)
| WalletData::Paze(_)
| WalletData::SamsungPay(_)
| WalletData::TwintRedirect {}
| WalletData::VippsRedirect {}
| WalletData::TouchNGoRedirect(_)
| WalletData::WeChatPayRedirect(_)
| WalletData::WeChatPayQr(_)
| WalletData::CashappQr(_)
| WalletData::SwishQr(_)
| WalletData::Mifinity(_)
| WalletData::RevolutPay(_) => Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("airwallex"),
))?,
};
Ok(wallet_details)
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 65,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_get_device_data_-3794189006622480709 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/airwallex/transformers
fn get_device_data(
item: &types::PaymentsAuthorizeRouterData,
) -> Result<DeviceData, error_stack::Report<errors::ConnectorError>> {
let info = item.request.get_browser_info()?;
let browser = Browser {
java_enabled: info.get_java_enabled()?,
javascript_enabled: info.get_java_script_enabled()?,
user_agent: info.get_user_agent()?,
};
let mobile = {
let device_model = info.get_device_model().ok();
let os_type = info.get_os_type().ok();
let os_version = info.get_os_version().ok();
if device_model.is_some() || os_type.is_some() || os_version.is_some() {
Some(Mobile {
device_model,
os_type,
os_version,
})
} else {
None
}
};
Ok(DeviceData {
accept_header: info.get_accept_header()?,
browser,
ip_address: info.get_ip_address()?,
mobile,
screen_color_depth: info.get_color_depth()?,
screen_height: info.get_screen_height()?,
screen_width: info.get_screen_width()?,
timezone: info.get_time_zone()?.to_string(),
language: info.get_language()?,
})
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 42,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_try_from_-4764944015692148313 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/dwolla/transformers
// Implementation of api_models::webhooks::IncomingWebhookEvent for TryFrom<DwollaWebhookDetails>
fn try_from(details: DwollaWebhookDetails) -> Result<Self, Self::Error> {
let correlation_id = match details.correlation_id.as_deref() {
Some(cid) => cid,
None => {
return Ok(Self::EventNotSupported);
}
};
let event_type = DwollaWebhookEventType::from(details.topic.as_str());
let is_refund = correlation_id.starts_with("refund_");
Ok(match (event_type, is_refund) {
(DwollaWebhookEventType::CustomerTransferCompleted, true)
| (DwollaWebhookEventType::CustomerBankTransferCompleted, true) => Self::RefundSuccess,
(DwollaWebhookEventType::CustomerTransferFailed, true)
| (DwollaWebhookEventType::CustomerBankTransferFailed, true) => Self::RefundFailure,
(DwollaWebhookEventType::CustomerTransferCreated, false)
| (DwollaWebhookEventType::CustomerBankTransferCreated, false) => {
Self::PaymentIntentProcessing
}
(DwollaWebhookEventType::CustomerTransferCompleted, false)
| (DwollaWebhookEventType::CustomerBankTransferCompleted, false) => {
Self::PaymentIntentSuccess
}
(DwollaWebhookEventType::CustomerTransferFailed, false)
| (DwollaWebhookEventType::CustomerBankTransferFailed, false) => {
Self::PaymentIntentFailure
}
_ => Self::EventNotSupported,
})
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2665,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_from_-4764944015692148313 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/dwolla/transformers
// Implementation of DwollaWebhookEventType for From<&str>
fn from(topic: &str) -> Self {
match topic {
"customer_created" => Self::CustomerCreated,
"customer_verified" => Self::CustomerVerified,
"customer_funding_source_added" => Self::CustomerFundingSourceAdded,
"customer_funding_source_removed" => Self::CustomerFundingSourceRemoved,
"customer_funding_source_verified" => Self::CustomerFundingSourceVerified,
"customer_funding_source_unverified" => Self::CustomerFundingSourceUnverified,
"customer_microdeposits_added" => Self::CustomerMicrodepositsAdded,
"customer_microdeposits_failed" => Self::CustomerMicrodepositsFailed,
"customer_microdeposits_completed" => Self::CustomerMicrodepositsCompleted,
"customer_microdeposits_maxattempts" => Self::CustomerMicrodepositsMaxAttempts,
"customer_bank_transfer_creation_failed" => Self::CustomerBankTransferCreationFailed,
"customer_bank_transfer_created" => Self::CustomerBankTransferCreated,
"customer_transfer_created" => Self::CustomerTransferCreated,
"customer_bank_transfer_failed" => Self::CustomerBankTransferFailed,
"customer_bank_transfer_completed" => Self::CustomerBankTransferCompleted,
"customer_transfer_completed" => Self::CustomerTransferCompleted,
"customer_transfer_failed" => Self::CustomerTransferFailed,
"transfer_created" => Self::TransferCreated,
"transfer_pending" => Self::TransferPending,
"transfer_completed" => Self::TransferCompleted,
"transfer_failed" => Self::TransferFailed,
_ => Self::Unknown,
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2600,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_extract_token_from_body_-4764944015692148313 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/dwolla/transformers
pub fn extract_token_from_body(body: &[u8]) -> CustomResult<String, errors::ConnectorError> {
let parsed: serde_json::Value = serde_json::from_slice(body)
.map_err(|_| report!(errors::ConnectorError::ResponseDeserializationFailed))?;
parsed
.get("_links")
.and_then(|links| links.get("about"))
.and_then(|about| about.get("href"))
.and_then(|href| href.as_str())
.and_then(|url| url.rsplit('/').next())
.map(|id| id.to_string())
.ok_or_else(|| report!(errors::ConnectorError::ResponseHandlingFailed))
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 40,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_map_topic_to_status_-4764944015692148313 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/dwolla/transformers
fn map_topic_to_status(topic: &str) -> DwollaPaymentStatus {
match topic {
"customer_transfer_created" | "customer_bank_transfer_created" => {
DwollaPaymentStatus::Pending
}
"customer_transfer_completed" | "customer_bank_transfer_completed" => {
DwollaPaymentStatus::Succeeded
}
"customer_transfer_failed" | "customer_bank_transfer_failed" => DwollaPaymentStatus::Failed,
_ => DwollaPaymentStatus::Pending,
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 0,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_try_from_-2655540848630004204 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/braintree/transformers
// Implementation of CardPaymentRequest for TryFrom<&BraintreeRouterData<&types::PaymentsCompleteAuthorizeRouterData>>
fn try_from(
item: &BraintreeRouterData<&types::PaymentsCompleteAuthorizeRouterData>,
) -> Result<Self, Self::Error> {
let metadata: BraintreeMeta = if let (
Some(merchant_account_id),
Some(merchant_config_currency),
) = (
item.router_data.request.merchant_account_id.clone(),
item.router_data.request.merchant_config_currency,
) {
router_env::logger::info!(
"BRAINTREE: Picking merchant_account_id and merchant_config_currency from payments request"
);
BraintreeMeta {
merchant_account_id,
merchant_config_currency,
}
} else {
utils::to_connector_meta_from_secret(item.router_data.connector_meta_data.clone())
.change_context(errors::ConnectorError::InvalidConnectorConfig {
config: "metadata",
})?
};
utils::validate_currency(
item.router_data.request.currency,
Some(metadata.merchant_config_currency),
)?;
let payload_data = PaymentsCompleteAuthorizeRequestData::get_redirect_response_payload(
&item.router_data.request,
)?
.expose();
let redirection_response: BraintreeRedirectionResponse = serde_json::from_value(
payload_data,
)
.change_context(errors::ConnectorError::MissingConnectorRedirectionPayload {
field_name: "redirection_response",
})?;
let three_ds_data = serde_json::from_str::<BraintreeThreeDsResponse>(
&redirection_response.authentication_response,
)
.change_context(errors::ConnectorError::MissingConnectorRedirectionPayload {
field_name: "three_ds_data",
})?;
let (query, transaction_body) = if item.router_data.request.is_mandate_payment() {
(
match item.router_data.request.is_auto_capture()? {
true => CHARGE_AND_VAULT_TRANSACTION_MUTATION.to_string(),
false => AUTHORIZE_AND_VAULT_CREDIT_CARD_MUTATION.to_string(),
},
TransactionBody::Vault(VaultTransactionBody {
amount: item.amount.to_owned(),
merchant_account_id: metadata.merchant_account_id,
vault_payment_method_after_transacting: TransactionTiming {
when: "ALWAYS".to_string(),
},
customer_details: item
.router_data
.get_billing_email()
.ok()
.map(|email| CustomerBody { email }),
order_id: item.router_data.connector_request_reference_id.clone(),
}),
)
} else {
(
match item.router_data.request.is_auto_capture()? {
true => CHARGE_CREDIT_CARD_MUTATION.to_string(),
false => AUTHORIZE_CREDIT_CARD_MUTATION.to_string(),
},
TransactionBody::Regular(RegularTransactionBody {
amount: item.amount.to_owned(),
merchant_account_id: metadata.merchant_account_id,
channel: CHANNEL_CODE.to_string(),
customer_details: item
.router_data
.get_billing_email()
.ok()
.map(|email| CustomerBody { email }),
order_id: item.router_data.connector_request_reference_id.clone(),
}),
)
};
Ok(Self {
query,
variables: VariablePaymentInput {
input: PaymentInput {
payment_method_id: three_ds_data.nonce,
transaction: transaction_body,
},
},
})
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2719,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_from_-2655540848630004204 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/braintree/transformers
// Implementation of payment_types::PaypalFlow for From<PaypalFlow>
fn from(item: PaypalFlow) -> Self {
match item {
PaypalFlow::Checkout => Self::Checkout,
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2600,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_foreign_try_from_-2655540848630004204 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/braintree/transformers
// Implementation of types::PaymentsSessionRouterData for ForeignTryFrom<(
PaymentsSessionResponseRouterData<BraintreeSessionResponse>,
Self,
)>
fn foreign_try_from(
(item, data): (
PaymentsSessionResponseRouterData<BraintreeSessionResponse>,
Self,
),
) -> Result<Self, Self::Error> {
let response = &item.response;
match response {
BraintreeSessionResponse::SessionTokenResponse(res) => {
let session_token = match data.payment_method_type {
Some(common_enums::PaymentMethodType::ApplePay) => {
let payment_request_data: payment_types::PaymentRequestMetadata =
if let Some(connector_meta) = data.connector_meta_data.clone() {
let meta_value: serde_json::Value = connector_meta.expose();
meta_value
.get("apple_pay_combined")
.ok_or(errors::ConnectorError::NoConnectorMetaData)
.attach_printable("Missing apple_pay_combined metadata")?
.get("manual")
.ok_or(errors::ConnectorError::NoConnectorMetaData)
.attach_printable("Missing manual metadata")?
.get("payment_request_data")
.ok_or(errors::ConnectorError::NoConnectorMetaData)
.attach_printable("Missing payment_request_data metadata")?
.clone()
.parse_value("PaymentRequestMetadata")
.change_context(errors::ConnectorError::ParsingFailed)
.attach_printable(
"Failed to parse apple_pay_combined.manual.payment_request_data metadata",
)?
} else {
return Err(errors::ConnectorError::NoConnectorMetaData)
.attach_printable("connector_meta_data is None");
};
let session_token_data = Some(ApplePaySessionResponse::ThirdPartySdk(
payment_types::ThirdPartySdkSessionResponse {
secrets: payment_types::SecretInfoToInitiateSdk {
display: res.data.create_client_token.client_token.clone(),
payment: None,
},
},
));
SessionToken::ApplePay(Box::new(
api_models::payments::ApplepaySessionTokenResponse {
session_token_data,
payment_request_data: Some(
api_models::payments::ApplePayPaymentRequest {
country_code: data.request.country.ok_or(
errors::ConnectorError::MissingRequiredField {
field_name: "country",
},
)?,
currency_code: data.request.currency,
total: api_models::payments::AmountInfo {
label: payment_request_data.label,
total_type: None,
amount: StringMajorUnitForConnector
.convert(
MinorUnit::new(data.request.amount),
data.request.currency,
)
.change_context(
errors::ConnectorError::AmountConversionFailed,
)?,
},
merchant_capabilities: Some(
payment_request_data.merchant_capabilities,
),
supported_networks: Some(
payment_request_data.supported_networks,
),
merchant_identifier: None,
required_billing_contact_fields: None,
required_shipping_contact_fields: None,
recurring_payment_request: None,
},
),
connector: data.connector.clone(),
delayed_session_token: false,
sdk_next_action: api_models::payments::SdkNextAction {
next_action: api_models::payments::NextActionCall::Confirm,
},
connector_reference_id: None,
connector_sdk_public_key: None,
connector_merchant_id: None,
},
))
}
Some(common_enums::PaymentMethodType::GooglePay) => {
let gpay_data: payment_types::GpaySessionTokenData =
if let Some(connector_meta) = data.connector_meta_data.clone() {
connector_meta
.expose()
.parse_value("GpaySessionTokenData")
.change_context(errors::ConnectorError::ParsingFailed)
.attach_printable("Failed to parse gpay metadata")?
} else {
return Err(errors::ConnectorError::NoConnectorMetaData)
.attach_printable("connector_meta_data is None");
};
SessionToken::GooglePay(Box::new(
api_models::payments::GpaySessionTokenResponse::GooglePaySession(
api_models::payments::GooglePaySessionResponse {
merchant_info: payment_types::GpayMerchantInfo {
merchant_name: gpay_data.data.merchant_info.merchant_name,
merchant_id: gpay_data.data.merchant_info.merchant_id,
},
shipping_address_required: false,
email_required: false,
shipping_address_parameters:
payment_types::GpayShippingAddressParameters {
phone_number_required: false,
},
allowed_payment_methods: gpay_data.data.allowed_payment_methods,
transaction_info: payment_types::GpayTransactionInfo {
country_code: data.request.country.ok_or(
errors::ConnectorError::MissingRequiredField {
field_name: "country",
},
)?,
currency_code: data.request.currency,
total_price_status: GooglePayPriceStatus::Final.to_string(),
total_price: StringMajorUnitForConnector
.convert(
MinorUnit::new(data.request.amount),
data.request.currency,
)
.change_context(
errors::ConnectorError::AmountConversionFailed,
)?,
},
secrets: Some(payment_types::SecretInfoToInitiateSdk {
display: res.data.create_client_token.client_token.clone(),
payment: None,
}),
delayed_session_token: false,
connector: data.connector.clone(),
sdk_next_action: payment_types::SdkNextAction {
next_action: payment_types::NextActionCall::Confirm,
},
},
),
))
}
Some(common_enums::PaymentMethodType::Paypal) => {
let paypal_sdk_data = data
.connector_meta_data
.clone()
.parse_value::<payment_types::PaypalSdkSessionTokenData>(
"PaypalSdkSessionTokenData",
)
.change_context(errors::ConnectorError::NoConnectorMetaData)
.attach_printable("Failed to parse paypal_sdk metadata.".to_string())?;
SessionToken::Paypal(Box::new(
api_models::payments::PaypalSessionTokenResponse {
connector: data.connector.clone(),
session_token: paypal_sdk_data.data.client_id,
sdk_next_action: api_models::payments::SdkNextAction {
next_action: api_models::payments::NextActionCall::Confirm,
},
client_token: Some(
res.data.create_client_token.client_token.clone().expose(),
),
transaction_info: Some(
api_models::payments::PaypalTransactionInfo {
flow: PaypalFlow::Checkout.into(),
currency_code: data.request.currency,
total_price: StringMajorUnitForConnector
.convert(
MinorUnit::new(data.request.amount),
data.request.currency,
)
.change_context(
errors::ConnectorError::AmountConversionFailed,
)?,
},
),
},
))
}
_ => {
return Err(errors::ConnectorError::NotImplemented(
format!(
"SDK session token generation is not supported for payment method: {:?}",
data.payment_method_type
)
)
.into());
}
};
Ok(Self {
response: Ok(PaymentsResponseData::SessionResponse { session_token }),
..data
})
}
BraintreeSessionResponse::ErrorResponse(error_response) => {
let err = build_error_response(error_response.errors.as_ref(), item.http_code)
.map_err(|err| *err);
Ok(Self {
response: err,
..data
})
}
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 546,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_build_error_response_-2655540848630004204 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/braintree/transformers
fn build_error_response<T>(
response: &[ErrorDetails],
http_code: u16,
) -> Result<T, Box<hyperswitch_domain_models::router_data::ErrorResponse>> {
let error_messages = response
.iter()
.map(|error| error.message.to_string())
.collect::<Vec<String>>();
let reason = match !error_messages.is_empty() {
true => Some(error_messages.join(" ")),
false => None,
};
get_error_response(
response
.first()
.and_then(|err_details| err_details.extensions.as_ref())
.and_then(|extensions| extensions.legacy_code.clone()),
response
.first()
.map(|err_details| err_details.message.clone()),
reason,
http_code,
)
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 451,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_get_error_response_-2655540848630004204 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/braintree/transformers
fn get_error_response<T>(
error_code: Option<String>,
error_msg: Option<String>,
error_reason: Option<String>,
http_code: u16,
) -> Result<T, Box<hyperswitch_domain_models::router_data::ErrorResponse>> {
Err(Box::new(
hyperswitch_domain_models::router_data::ErrorResponse {
code: error_code.unwrap_or_else(|| NO_ERROR_CODE.to_string()),
message: error_msg.unwrap_or_else(|| NO_ERROR_MESSAGE.to_string()),
reason: error_reason,
status_code: http_code,
attempt_status: None,
connector_transaction_id: None,
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
connector_metadata: None,
},
))
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 61,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_new_-7875012607095300223 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/worldpay/response
// Inherent implementation for PaymentsResponseScheme
pub fn new(reference: String) -> Self {
Self { reference }
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 14463,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_default_-7875012607095300223 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/worldpay/response
// Inherent implementation for WorldpayErrorResponse
pub fn default(status_code: u16) -> Self {
match status_code {
code @ 404 => Self {
error_name: format!("{code} Not found"),
message: "Resource not found".to_string(),
validation_errors: None,
},
code => Self {
error_name: code.to_string(),
message: "Unknown error".to_string(),
validation_errors: None,
},
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 7719,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_get_resource_id_-7875012607095300223 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/worldpay/response
pub fn get_resource_id<T, F>(
response: WorldpayPaymentsResponse,
connector_transaction_id: Option<String>,
transform_fn: F,
) -> Result<T, error_stack::Report<errors::ConnectorError>>
where
F: Fn(String) -> T,
{
let optional_reference_id = response
.other_fields
.as_ref()
.and_then(|other_fields| match other_fields {
WorldpayPaymentResponseFields::AuthorizedResponse(res) => res
.links
.as_ref()
.and_then(|link| link.self_link.href.rsplit_once('/').map(|(_, h)| h)),
WorldpayPaymentResponseFields::DDCResponse(res) => {
res.actions.supply_ddc_data.href.split('/').nth_back(1)
}
WorldpayPaymentResponseFields::ThreeDsChallenged(res) => res
.actions
.complete_three_ds_challenge
.href
.split('/')
.nth_back(1),
WorldpayPaymentResponseFields::FraudHighRisk(_)
| WorldpayPaymentResponseFields::RefusedResponse(_) => None,
})
.map(|href| {
urlencoding::decode(href)
.map(|s| transform_fn(s.into_owned()))
.change_context(errors::ConnectorError::ResponseHandlingFailed)
})
.transpose()?;
optional_reference_id
.or_else(|| connector_transaction_id.map(transform_fn))
.ok_or_else(|| {
errors::ConnectorError::MissingRequiredField {
field_name: "_links.self.href",
}
.into()
})
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 55,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_fmt_-7875012607095300223 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/worldpay/response
// Implementation of PaymentOutcome for std::fmt::Display
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Authorized => write!(f, "authorized"),
Self::Refused => write!(f, "refused"),
Self::SentForSettlement => write!(f, "sentForSettlement"),
Self::SentForRefund => write!(f, "sentForRefund"),
Self::FraudHighRisk => write!(f, "fraudHighRisk"),
Self::ThreeDsDeviceDataRequired => write!(f, "3dsDeviceDataRequired"),
Self::SentForCancellation => write!(f, "sentForCancellation"),
Self::ThreeDsAuthenticationFailed => write!(f, "3dsAuthenticationFailed"),
Self::SentForPartialRefund => write!(f, "sentForPartialRefund"),
Self::ThreeDsChallenged => write!(f, "3dsChallenged"),
Self::ThreeDsUnavailable => write!(f, "3dsUnavailable"),
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 38,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_try_from_-5777553329999577915 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/worldpay/transformers
// Implementation of WorldpayCompleteAuthorizationRequest for TryFrom<&types::PaymentsCompleteAuthorizeRouterData>
fn try_from(item: &types::PaymentsCompleteAuthorizeRouterData) -> Result<Self, Self::Error> {
let params = item
.request
.redirect_response
.as_ref()
.and_then(|redirect_response| redirect_response.params.as_ref())
.ok_or(errors::ConnectorError::ResponseDeserializationFailed)?;
let parsed_request = serde_urlencoded::from_str::<Self>(params.peek())
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
match item.status {
enums::AttemptStatus::DeviceDataCollectionPending => Ok(parsed_request),
enums::AttemptStatus::AuthenticationPending => {
if parsed_request.collection_reference.is_some() {
return Err(errors::ConnectorError::InvalidDataFormat {
field_name:
"collection_reference not allowed in AuthenticationPending state",
}
.into());
}
Ok(parsed_request)
}
_ => Err(
errors::ConnectorError::RequestEncodingFailedWithReason(format!(
"Invalid payment status for complete authorize: {:?}",
item.status
))
.into(),
),
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2677,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_from_-5777553329999577915 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/worldpay/transformers
// Implementation of enums::RefundStatus for From<EventType>
fn from(value: EventType) -> Self {
match value {
EventType::Refunded | EventType::SentForRefund => Self::Success,
EventType::RefundFailed => Self::Failure,
EventType::Authorized
| EventType::Cancelled
| EventType::Settled
| EventType::Refused
| EventType::Error
| EventType::SentForSettlement
| EventType::SentForAuthorization
| EventType::SettlementFailed
| EventType::Expired
| EventType::Unknown => Self::Pending,
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2600,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_foreign_try_from_-5777553329999577915 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/worldpay/transformers
// Implementation of ResponseId for ForeignTryFrom<(WorldpayPaymentsResponse, Option<String>)>
fn foreign_try_from(
item: (WorldpayPaymentsResponse, Option<String>),
) -> Result<Self, Self::Error> {
get_resource_id(item.0, item.1, Self::ConnectorTransactionId)
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 430,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_get_payment_method_type_-5777553329999577915 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/worldpay/transformers
// Implementation of RouterData<Authorize, PaymentsAuthorizeData, PaymentsResponseData> for WorldpayPaymentsRequestData
fn get_payment_method_type(&self) -> Option<enums::PaymentMethodType> {
self.request.payment_method_type
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 119,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_get_payment_method_data_-5777553329999577915 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/worldpay/transformers
// Implementation of RouterData<Authorize, PaymentsAuthorizeData, PaymentsResponseData> for WorldpayPaymentsRequestData
fn get_payment_method_data(&self) -> &PaymentMethodData {
&self.request.payment_method_data
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 92,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_try_from_-2775288965072090863 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/worldpay/payout_transformers
// Implementation of types::PayoutsRouterData<PoFulfill> for TryFrom<PayoutsResponseRouterData<PoFulfill, WorldpayPayoutResponse>>
fn try_from(
item: PayoutsResponseRouterData<PoFulfill, WorldpayPayoutResponse>,
) -> Result<Self, Self::Error> {
Ok(Self {
response: Ok(PayoutsResponseData {
status: Some(enums::PayoutStatus::from(item.response.outcome.clone())),
connector_payout_id: None,
payout_eligible: None,
should_add_next_step_to_process_tracker: false,
error_code: None,
error_message: None,
payout_connector_metadata: None,
}),
..item.data
})
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2661,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_from_-2775288965072090863 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/worldpay/payout_transformers
// Implementation of enums::PayoutStatus for From<PayoutOutcome>
fn from(item: PayoutOutcome) -> Self {
match item {
PayoutOutcome::RequestReceived => Self::Initiated,
PayoutOutcome::Error | PayoutOutcome::Refused => Self::Failed,
PayoutOutcome::QueryRequired => Self::Pending,
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2600,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_try_from_567269656879971462 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/billwerk/transformers
// Implementation of types::RefundsRouterData<RSync> for TryFrom<RefundsResponseRouterData<RSync, RefundResponse>>
fn try_from(
item: RefundsResponseRouterData<RSync, RefundResponse>,
) -> Result<Self, Self::Error> {
Ok(Self {
response: Ok(RefundsResponseData {
connector_refund_id: item.response.id.to_string(),
refund_status: enums::RefundStatus::from(item.response.state),
}),
..item.data
})
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2661,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_from_567269656879971462 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/billwerk/transformers
// Implementation of enums::RefundStatus for From<RefundState>
fn from(item: RefundState) -> Self {
match item {
RefundState::Refunded => Self::Success,
RefundState::Failed => Self::Failure,
RefundState::Processing => Self::Pending,
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2600,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_try_from_-1188861715832568952 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/payu/transformers
// Implementation of types::RefundsRouterData<RSync> for TryFrom<RefundsResponseRouterData<RSync, RefundSyncResponse>>
fn try_from(
item: RefundsResponseRouterData<RSync, RefundSyncResponse>,
) -> Result<Self, Self::Error> {
let refund = match item.response.refunds.first() {
Some(refund) => refund,
_ => Err(errors::ConnectorError::ResponseHandlingFailed)?,
};
Ok(Self {
response: Ok(RefundsResponseData {
connector_refund_id: refund.refund_id.clone(),
refund_status: enums::RefundStatus::from(refund.status.clone()),
}),
..item.data
})
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2665,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_from_-1188861715832568952 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/payu/transformers
// Implementation of enums::RefundStatus for From<RefundStatus>
fn from(item: RefundStatus) -> Self {
match item {
RefundStatus::Finalized | RefundStatus::Completed => Self::Success,
RefundStatus::Canceled => Self::Failure,
RefundStatus::Pending => Self::Pending,
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2600,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_try_from_2187960702515948812 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/elavon/transformers
// Implementation of RefundsRouterData<Execute> for TryFrom<RefundsResponseRouterData<Execute, ElavonPaymentsResponse>>
fn try_from(
item: RefundsResponseRouterData<Execute, ElavonPaymentsResponse>,
) -> Result<Self, Self::Error> {
let status = enums::RefundStatus::from(&item.response.result);
let response = match &item.response.result {
ElavonResult::Error(error) => Err(ErrorResponse {
code: error
.error_code
.clone()
.unwrap_or(NO_ERROR_CODE.to_string()),
message: error.error_message.clone(),
reason: Some(error.error_message.clone()),
attempt_status: None,
connector_transaction_id: None,
status_code: item.http_code,
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
connector_metadata: None,
}),
ElavonResult::Success(response) => {
if status == enums::RefundStatus::Failure {
Err(ErrorResponse {
code: response.ssl_result_message.clone(),
message: response.ssl_result_message.clone(),
reason: Some(response.ssl_result_message.clone()),
attempt_status: None,
connector_transaction_id: None,
status_code: item.http_code,
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
connector_metadata: None,
})
} else {
Ok(RefundsResponseData {
connector_refund_id: response.ssl_txn_id.clone(),
refund_status: enums::RefundStatus::from(&item.response.result),
})
}
}
};
Ok(Self {
response,
..item.data
})
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2679,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_from_2187960702515948812 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/elavon/transformers
// Implementation of enums::AttemptStatus for From<&ElavonSyncResponse>
fn from(item: &ElavonSyncResponse) -> Self {
match item.ssl_trans_status {
TransactionSyncStatus::REV
| TransactionSyncStatus::OPN
| TransactionSyncStatus::PEN => Self::Pending,
TransactionSyncStatus::STL => match item.ssl_transaction_type {
SyncTransactionType::Sale => Self::Charged,
SyncTransactionType::AuthOnly => Self::Authorized,
SyncTransactionType::Return => Self::Pending,
},
TransactionSyncStatus::PST
| TransactionSyncStatus::FPR
| TransactionSyncStatus::PRE => Self::Failure,
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2600,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_deserialize_2187960702515948812 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/elavon/transformers
// Implementation of ElavonPaymentsResponse for Deserialize<'de>
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
#[derive(Deserialize, Debug)]
#[serde(rename = "txn")]
struct XmlResponse {
// Error fields
#[serde(rename = "errorCode", default)]
error_code: Option<String>,
#[serde(rename = "errorMessage", default)]
error_message: Option<String>,
#[serde(rename = "errorName", default)]
error_name: Option<String>,
// Success fields
#[serde(rename = "ssl_result", default)]
ssl_result: Option<SslResult>,
#[serde(rename = "ssl_txn_id", default)]
ssl_txn_id: Option<String>,
#[serde(rename = "ssl_result_message", default)]
ssl_result_message: Option<String>,
#[serde(rename = "ssl_token", default)]
ssl_token: Option<Secret<String>>,
}
let xml_res = XmlResponse::deserialize(deserializer)?;
let result = match (xml_res.error_message.clone(), xml_res.error_name.clone()) {
(Some(error_message), Some(error_name)) => ElavonResult::Error(ElavonErrorResponse {
error_code: xml_res.error_code.clone(),
error_message,
error_name,
}),
_ => {
if let (Some(ssl_result), Some(ssl_txn_id), Some(ssl_result_message)) = (
xml_res.ssl_result.clone(),
xml_res.ssl_txn_id.clone(),
xml_res.ssl_result_message.clone(),
) {
ElavonResult::Success(PaymentResponse {
ssl_result,
ssl_txn_id,
ssl_result_message,
ssl_token: xml_res.ssl_token.clone(),
})
} else {
return Err(serde::de::Error::custom(
"Invalid Response XML structure - neither error nor success",
));
}
}
};
Ok(Self { result })
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 156,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_is_successful_2187960702515948812 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/elavon/transformers
// Implementation of ElavonResult for ElavonResponseValidator
fn is_successful(&self) -> bool {
matches!(self, Self::Success(response) if response.ssl_result == SslResult::ImportedBatchFile)
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 14,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_get_refund_status_2187960702515948812 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/elavon/transformers
fn get_refund_status(
prev_status: enums::RefundStatus,
item: &ElavonSyncResponse,
) -> enums::RefundStatus {
match item.ssl_trans_status {
TransactionSyncStatus::REV | TransactionSyncStatus::OPN | TransactionSyncStatus::PEN => {
prev_status
}
TransactionSyncStatus::STL => enums::RefundStatus::Success,
TransactionSyncStatus::PST | TransactionSyncStatus::FPR | TransactionSyncStatus::PRE => {
enums::RefundStatus::Failure
}
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 6,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_try_from_-4504990425491236041 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/gigadat/transformers
// Implementation of PayoutsRouterData<F> for TryFrom<PayoutsResponseRouterData<F, GigadatPayoutSyncResponse>>
fn try_from(
item: PayoutsResponseRouterData<F, GigadatPayoutSyncResponse>,
) -> Result<Self, Self::Error> {
Ok(Self {
response: Ok(PayoutsResponseData {
status: Some(enums::PayoutStatus::from(item.response.status)),
connector_payout_id: None,
payout_eligible: None,
should_add_next_step_to_process_tracker: false,
error_code: None,
error_message: None,
payout_connector_metadata: None,
}),
..item.data
})
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2659,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_from_-4504990425491236041 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/gigadat/transformers
// Implementation of enums::PayoutStatus for From<GigadatPayoutStatus>
fn from(item: GigadatPayoutStatus) -> Self {
match item {
GigadatPayoutStatus::StatusSuccess => Self::Success,
GigadatPayoutStatus::StatusPending => Self::RequiresFulfillment,
GigadatPayoutStatus::StatusInited => Self::Pending,
GigadatPayoutStatus::StatusRejected
| GigadatPayoutStatus::StatusExpired
| GigadatPayoutStatus::StatusRejected1
| GigadatPayoutStatus::StatusAborted1
| GigadatPayoutStatus::StatusFailed => Self::Failed,
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2600,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_try_from_5961796454670220683 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/payme/transformers
// Implementation of RouterData<F, T, RefundsResponseData> for TryFrom<ResponseRouterData<F, PaymeQueryTransactionResponse, T, RefundsResponseData>>
fn try_from(
item: ResponseRouterData<F, PaymeQueryTransactionResponse, T, RefundsResponseData>,
) -> Result<Self, Self::Error> {
let pay_sale_response = item
.response
.items
.first()
.ok_or(errors::ConnectorError::ResponseHandlingFailed)?;
let refund_status = enums::RefundStatus::try_from(pay_sale_response.sale_status.clone())?;
let response = if utils::is_refund_failure(refund_status) {
Err(ErrorResponse {
code: consts::NO_ERROR_CODE.to_string(),
message: consts::NO_ERROR_CODE.to_string(),
reason: None,
status_code: item.http_code,
attempt_status: None,
connector_transaction_id: Some(pay_sale_response.payme_transaction_id.clone()),
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
connector_metadata: None,
})
} else {
Ok(RefundsResponseData {
refund_status,
connector_refund_id: pay_sale_response.payme_transaction_id.clone(),
})
};
Ok(Self {
response,
..item.data
})
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2675,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_from_5961796454670220683 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/payme/transformers
// Implementation of api_models::webhooks::IncomingWebhookEvent for From<NotifyType>
fn from(value: NotifyType) -> Self {
match value {
NotifyType::SaleComplete => Self::PaymentIntentSuccess,
NotifyType::Refund => Self::RefundSuccess,
NotifyType::SaleFailure => Self::PaymentIntentFailure,
NotifyType::SaleChargeback => Self::DisputeOpened,
NotifyType::SaleChargebackRefund => Self::DisputeWon,
NotifyType::SaleAuthorized => Self::EventNotSupported,
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2600,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_foreign_try_from_5961796454670220683 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/payme/transformers
// Implementation of RouterData<F, PaymentsPreProcessingData, PaymentsResponseData> for utils::ForeignTryFrom<(
ResponseRouterData<
F,
GenerateSaleResponse,
PaymentsPreProcessingData,
PaymentsResponseData,
>,
StringMajorUnit,
)>
fn foreign_try_from(
(item, apple_pay_amount): (
ResponseRouterData<
F,
GenerateSaleResponse,
PaymentsPreProcessingData,
PaymentsResponseData,
>,
StringMajorUnit,
),
) -> Result<Self, Self::Error> {
match item.data.payment_method {
PaymentMethod::Card => {
match item.data.auth_type {
AuthenticationType::NoThreeDs => {
Ok(Self {
// We don't get any status from payme, so defaulting it to pending
// then move to authorize flow
status: enums::AttemptStatus::Pending,
preprocessing_id: Some(item.response.payme_sale_id.to_owned()),
response: Ok(PaymentsResponseData::PreProcessingResponse {
pre_processing_id: PreprocessingResponseId::ConnectorTransactionId(
item.response.payme_sale_id,
),
connector_metadata: None,
session_token: None,
connector_response_reference_id: None,
}),
..item.data
})
}
AuthenticationType::ThreeDs => Ok(Self {
// We don't go to authorize flow in 3ds,
// Response is send directly after preprocessing flow
// redirection data is send to run script along
// status is made authentication_pending to show redirection
status: enums::AttemptStatus::AuthenticationPending,
preprocessing_id: Some(item.response.payme_sale_id.to_owned()),
response: Ok(PaymentsResponseData::TransactionResponse {
resource_id: ResponseId::ConnectorTransactionId(
item.response.payme_sale_id.to_owned(),
),
redirection_data: Box::new(Some(RedirectForm::Payme)),
mandate_reference: Box::new(None),
connector_metadata: None,
network_txn_id: None,
connector_response_reference_id: None,
incremental_authorization_allowed: None,
charges: None,
}),
..item.data
}),
}
}
_ => {
let currency_code = item.data.request.get_currency()?;
let pmd = item.data.request.payment_method_data.to_owned();
let payme_auth_type = PaymeAuthType::try_from(&item.data.connector_auth_type)?;
let session_token = match pmd {
Some(PaymentMethodData::Wallet(WalletData::ApplePayThirdPartySdk(
_,
))) => Some(api_models::payments::SessionToken::ApplePay(Box::new(
api_models::payments::ApplepaySessionTokenResponse {
session_token_data: Some(
api_models::payments::ApplePaySessionResponse::NoSessionResponse(api_models::payments::NullObject),
),
payment_request_data: Some(
api_models::payments::ApplePayPaymentRequest {
country_code: item.data.get_billing_country()?,
currency_code,
total: api_models::payments::AmountInfo {
label: "Apple Pay".to_string(),
total_type: None,
amount: apple_pay_amount,
},
merchant_capabilities: None,
supported_networks: None,
merchant_identifier: None,
required_billing_contact_fields: None,
required_shipping_contact_fields: None,
recurring_payment_request: None,
},
),
connector: "payme".to_string(),
delayed_session_token: true,
sdk_next_action: api_models::payments::SdkNextAction {
next_action: api_models::payments::NextActionCall::Sync,
},
connector_reference_id: Some(item.response.payme_sale_id.to_owned()),
connector_sdk_public_key: Some(
payme_auth_type.payme_public_key.expose(),
),
connector_merchant_id: payme_auth_type
.payme_merchant_id
.map(|mid| mid.expose()),
},
))),
_ => None,
};
Ok(Self {
// We don't get any status from payme, so defaulting it to pending
status: enums::AttemptStatus::Pending,
preprocessing_id: Some(item.response.payme_sale_id.to_owned()),
response: Ok(PaymentsResponseData::PreProcessingResponse {
pre_processing_id: PreprocessingResponseId::ConnectorTransactionId(
item.response.payme_sale_id,
),
connector_metadata: None,
session_token,
connector_response_reference_id: None,
}),
..item.data
})
}
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 472,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_get_pay_sale_error_response_5961796454670220683 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/payme/transformers
fn get_pay_sale_error_response(
(pay_sale_response, http_code): (&PaymePaySaleResponse, u16),
) -> ErrorResponse {
let code = pay_sale_response
.status_error_code
.map(|error_code| error_code.to_string())
.unwrap_or(consts::NO_ERROR_CODE.to_string());
ErrorResponse {
code,
message: pay_sale_response
.status_error_details
.clone()
.unwrap_or(consts::NO_ERROR_MESSAGE.to_string()),
reason: pay_sale_response.status_error_details.to_owned(),
status_code: http_code,
attempt_status: None,
connector_transaction_id: Some(pay_sale_response.payme_sale_id.clone()),
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
connector_metadata: None,
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 18,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_get_sale_query_error_response_5961796454670220683 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/payme/transformers
fn get_sale_query_error_response(
(sale_query_response, http_code): (&SaleQuery, u16),
) -> ErrorResponse {
ErrorResponse {
code: sale_query_response
.sale_error_code
.clone()
.unwrap_or(consts::NO_ERROR_CODE.to_string()),
message: sale_query_response
.sale_error_text
.clone()
.unwrap_or(consts::NO_ERROR_MESSAGE.to_string()),
reason: sale_query_response.sale_error_text.clone(),
status_code: http_code,
attempt_status: None,
connector_transaction_id: Some(sale_query_response.sale_payme_id.clone()),
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
connector_metadata: None,
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 16,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_try_from_-8892303589338660640 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/thunes/transformers
// Implementation of RefundsRouterData<RSync> for TryFrom<RefundsResponseRouterData<RSync, RefundResponse>>
fn try_from(
item: RefundsResponseRouterData<RSync, RefundResponse>,
) -> Result<Self, Self::Error> {
Ok(Self {
response: Ok(RefundsResponseData {
connector_refund_id: item.response.id.to_string(),
refund_status: enums::RefundStatus::from(item.response.status),
}),
..item.data
})
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2661,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_from_-8892303589338660640 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/thunes/transformers
// Implementation of enums::RefundStatus for From<RefundStatus>
fn from(item: RefundStatus) -> Self {
match item {
RefundStatus::Succeeded => Self::Success,
RefundStatus::Failed => Self::Failure,
RefundStatus::Processing => Self::Pending,
//TODO: Review mapping
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2600,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_try_from_-6626624719266719418 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/threedsecureio/transformers
// Implementation of ThreedsecureioPreAuthenticationRequest for TryFrom<&ThreedsecureioRouterData<&PreAuthNRouterData>>
fn try_from(
value: &ThreedsecureioRouterData<&PreAuthNRouterData>,
) -> Result<Self, Self::Error> {
let router_data = value.router_data;
Ok(Self {
acct_number: router_data.request.card.card_number.clone(),
ds: None,
})
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2659,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_from_-6626624719266719418 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/threedsecureio/transformers
// Implementation of common_enums::TransactionStatus for From<ThreedsecureioTransStatus>
fn from(value: ThreedsecureioTransStatus) -> Self {
match value {
ThreedsecureioTransStatus::Y => Self::Success,
ThreedsecureioTransStatus::N => Self::Failure,
ThreedsecureioTransStatus::U => Self::VerificationNotPerformed,
ThreedsecureioTransStatus::A => Self::NotVerified,
ThreedsecureioTransStatus::R => Self::Rejected,
ThreedsecureioTransStatus::C => Self::ChallengeRequired,
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2600,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_try_from_823302579075018741 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/globalpay/transformers
// Implementation of PaymentMethodData for TryFrom<&payment_method_data::BankRedirectData>
fn try_from(value: &payment_method_data::BankRedirectData) -> Result<Self, Self::Error> {
match value {
payment_method_data::BankRedirectData::Eps { .. } => Ok(Self::Apm(requests::Apm {
provider: Some(ApmProvider::Eps),
})),
payment_method_data::BankRedirectData::Giropay { .. } => Ok(Self::Apm(requests::Apm {
provider: Some(ApmProvider::Giropay),
})),
payment_method_data::BankRedirectData::Ideal { .. } => Ok(Self::Apm(requests::Apm {
provider: Some(ApmProvider::Ideal),
})),
payment_method_data::BankRedirectData::Sofort { .. } => Ok(Self::Apm(requests::Apm {
provider: Some(ApmProvider::Sofort),
})),
_ => Err(errors::ConnectorError::NotImplemented("Payment method".to_string()).into()),
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2671,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_from_823302579075018741 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/globalpay/transformers
// Implementation of requests::CaptureMode for From<Option<common_enums::CaptureMethod>>
fn from(capture_method: Option<common_enums::CaptureMethod>) -> Self {
match capture_method {
Some(common_enums::CaptureMethod::Manual) => Self::Later,
Some(common_enums::CaptureMethod::ManualMultiple) => Self::Multiple,
_ => Self::Auto,
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2600,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_foreign_try_from_823302579075018741 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/globalpay/transformers
// Implementation of PaymentsSyncRouterData for ForeignTryFrom<(
PaymentsSyncResponseRouterData<GlobalpayPaymentsResponse>,
bool,
)>
fn foreign_try_from(
(value, is_multiple_capture_sync): (
PaymentsSyncResponseRouterData<GlobalpayPaymentsResponse>,
bool,
),
) -> Result<Self, Self::Error> {
if is_multiple_capture_sync {
let capture_sync_response_list =
construct_captures_response_hashmap(vec![value.response])?;
Ok(Self {
response: Ok(PaymentsResponseData::MultipleCaptureResponse {
capture_sync_response_list,
}),
..value.data
})
} else {
Self::try_from(value)
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 432,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_get_wallet_data_823302579075018741 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/globalpay/transformers
fn get_wallet_data(
wallet_data: &payment_method_data::WalletData,
) -> Result<PaymentMethodData, Error> {
match wallet_data {
payment_method_data::WalletData::PaypalRedirect(_) => {
Ok(PaymentMethodData::Apm(requests::Apm {
provider: Some(ApmProvider::Paypal),
}))
}
payment_method_data::WalletData::GooglePay(_) => {
Ok(PaymentMethodData::DigitalWallet(requests::DigitalWallet {
provider: Some(requests::DigitalWalletProvider::PayByGoogle),
payment_token: wallet_data.get_wallet_token_as_json("Google Pay".to_string())?,
}))
}
_ => Err(errors::ConnectorError::NotImplemented(
"Payment method".to_string(),
))?,
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 21,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_get_amount_captured_823302579075018741 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/globalpay/transformers
// Implementation of GlobalpayPaymentsResponse for MultipleCaptureSyncResponse
fn get_amount_captured(&self) -> Result<Option<MinorUnit>, error_stack::Report<ParsingError>> {
match self.amount.clone() {
Some(amount) => {
let minor_amount = StringMinorUnitForConnector::convert_back(
&StringMinorUnitForConnector,
amount,
self.currency.unwrap_or_default(), //it is ignored in convert_back function
)?;
Ok(Some(minor_amount))
}
None => Ok(None),
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 20,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_try_from_3871576064319702410 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/phonepe/transformers
// Implementation of RefundsRouterData<RSync> for TryFrom<RefundsResponseRouterData<RSync, RefundResponse>>
fn try_from(
item: RefundsResponseRouterData<RSync, RefundResponse>,
) -> Result<Self, Self::Error> {
Ok(Self {
response: Ok(RefundsResponseData {
connector_refund_id: item.response.id.to_string(),
refund_status: enums::RefundStatus::from(item.response.status),
}),
..item.data
})
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2661,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_from_3871576064319702410 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/phonepe/transformers
// Implementation of enums::RefundStatus for From<RefundStatus>
fn from(item: RefundStatus) -> Self {
match item {
RefundStatus::Succeeded => Self::Success,
RefundStatus::Failed => Self::Failure,
RefundStatus::Processing => Self::Pending,
//TODO: Review mapping
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2600,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_try_from_-6931196945585363961 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/finix/transformers
// Implementation of RefundsRouterData<RSync> for TryFrom<RefundsResponseRouterData<RSync, FinixPaymentsResponse>>
fn try_from(
item: RefundsResponseRouterData<RSync, FinixPaymentsResponse>,
) -> Result<Self, Self::Error> {
Ok(Self {
response: Ok(RefundsResponseData {
connector_refund_id: item.response.id.to_string(),
refund_status: enums::RefundStatus::from(item.response.state),
}),
..item.data
})
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2661,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_from_-6931196945585363961 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/finix/transformers
// Implementation of enums::RefundStatus for From<FinixState>
fn from(item: FinixState) -> Self {
match item {
FinixState::PENDING => Self::Pending,
FinixState::SUCCEEDED => Self::Success,
FinixState::FAILED | FinixState::CANCELED | FinixState::UNKNOWN => Self::Failure,
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2600,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_get_message_-6931196945585363961 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/finix/transformers
// Inherent implementation for FinixErrorResponse
pub fn get_message(&self) -> String {
self.embedded
.as_ref()
.and_then(|embedded| embedded.errors.as_ref())
.and_then(|errors| errors.first())
.and_then(|error| error.message.clone())
.unwrap_or(consts::NO_ERROR_MESSAGE.to_string())
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 45,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_get_code_-6931196945585363961 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/finix/transformers
// Inherent implementation for FinixErrorResponse
pub fn get_code(&self) -> String {
self.embedded
.as_ref()
.and_then(|embedded| embedded.errors.as_ref())
.and_then(|errors| errors.first())
.and_then(|error| error.code.clone())
.unwrap_or(consts::NO_ERROR_MESSAGE.to_string())
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 39,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_get_finix_response_-6931196945585363961 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/finix/transformers
pub(crate) fn get_finix_response<F, T>(
router_data: ResponseRouterData<F, FinixPaymentsResponse, T, PaymentsResponseData>,
finix_flow: FinixFlow,
) -> Result<RouterData<F, T, PaymentsResponseData>, error_stack::Report<ConnectorError>> {
let status = get_attempt_status(
router_data.response.state.clone(),
finix_flow,
router_data.response.is_void,
);
Ok(RouterData {
status,
response: if router_data.response.state.is_failure() {
Err(ErrorResponse {
code: router_data
.response
.failure_code
.unwrap_or(consts::NO_ERROR_CODE.to_string()),
message: router_data
.response
.messages
.map_or(consts::NO_ERROR_MESSAGE.to_string(), |msg| msg.join(",")),
reason: router_data.response.failure_message,
status_code: router_data.http_code,
attempt_status: Some(status),
connector_transaction_id: Some(router_data.response.id.clone()),
network_decline_code: None,
network_advice_code: None,
network_error_message: None,
connector_metadata: None,
})
} else {
Ok(PaymentsResponseData::TransactionResponse {
resource_id: ResponseId::ConnectorTransactionId(
router_data
.response
.transfer
.unwrap_or(router_data.response.id),
),
redirection_data: Box::new(None),
mandate_reference: Box::new(None),
connector_metadata: None,
network_txn_id: None,
connector_response_reference_id: None,
incremental_authorization_allowed: None,
charges: None,
})
},
..router_data.data
})
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 36,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_new_-7387618648713164196 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/finix/transformers/request
// Inherent implementation for FinixCreateRefundRequest
pub fn new(refund_amount: MinorUnit) -> Self {
Self { refund_amount }
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 14463,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_from_-7387618648713164196 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/finix/transformers/request
// Implementation of FinixId for From<String>
fn from(id: String) -> Self {
if id.starts_with("AU") {
Self::Auth(id)
} else if id.starts_with("TR") {
Self::Transfer(id)
} else {
// Default to Auth if the prefix doesn't match
Self::Auth(id)
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2610,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_fmt_-7387618648713164196 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/finix/transformers/request
// Implementation of FinixId for std::fmt::Display
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Auth(id) => write!(f, "{}", id),
Self::Transfer(id) => write!(f, "{}", id),
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 38,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_is_failure_-7387618648713164196 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/finix/transformers/request
// Inherent implementation for FinixState
pub fn is_failure(&self) -> bool {
match self {
Self::PENDING | Self::SUCCEEDED => false,
Self::FAILED | Self::CANCELED | Self::UNKNOWN => true,
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 21,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_get_flow_for_auth_-7387618648713164196 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/finix/transformers/request
// Inherent implementation for FinixFlow
pub fn get_flow_for_auth(capture_method: CaptureMethod) -> Self {
match capture_method {
CaptureMethod::SequentialAutomatic | CaptureMethod::Automatic => Self::Transfer,
CaptureMethod::Manual | CaptureMethod::ManualMultiple | CaptureMethod::Scheduled => {
Self::Auth
}
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 18,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_new_2346984914605397825 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/nexixpay/transformers
// Implementation of ShippingAddress for AddressConstructor
fn new(
name: Option<Secret<String>>,
street: Option<Secret<String>>,
city: Option<String>,
post_code: Option<Secret<String>>,
country: Option<CountryAlpha3>,
) -> Self {
Self {
name,
street,
city,
post_code,
country,
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 14453,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_try_from_2346984914605397825 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/nexixpay/transformers
// Implementation of RouterData<SetupMandate, SetupMandateRequestData, PaymentsResponseData> for TryFrom<
ResponseRouterData<
SetupMandate,
PaymentsResponse,
SetupMandateRequestData,
PaymentsResponseData,
>,
>
fn try_from(
item: ResponseRouterData<
SetupMandate,
PaymentsResponse,
SetupMandateRequestData,
PaymentsResponseData,
>,
) -> Result<Self, Self::Error> {
let complete_authorize_url = item.data.request.get_complete_authorize_url()?;
let operation_id: String = item.response.operation.operation_id.clone();
let redirection_form = nexixpay_threeds_link(NexixpayRedirectionRequest {
three_d_s_auth_url: item
.response
.three_d_s_auth_url
.clone()
.expose()
.to_string(),
three_ds_request: item.response.three_d_s_auth_request.clone(),
return_url: complete_authorize_url.clone(),
transaction_id: operation_id.clone(),
})?;
let is_auto_capture = item.data.request.is_auto_capture()?;
let connector_metadata = Some(serde_json::json!(NexixpayConnectorMetaData {
three_d_s_auth_result: None,
three_d_s_auth_response: None,
authorization_operation_id: Some(operation_id.clone()),
cancel_operation_id: None,
capture_operation_id: {
if is_auto_capture {
Some(operation_id)
} else {
None
}
},
psync_flow: NexixpayPaymentIntent::Authorize
}));
let status = AttemptStatus::from(item.response.operation.operation_result.clone());
match status {
AttemptStatus::Failure => {
let response = Err(get_error_response(
item.response.operation.operation_result.clone(),
item.http_code,
));
Ok(Self {
response,
..item.data
})
}
_ => Ok(Self {
status,
response: Ok(PaymentsResponseData::TransactionResponse {
resource_id: ResponseId::ConnectorTransactionId(
item.response.operation.order_id.clone(),
),
redirection_data: Box::new(Some(redirection_form.clone())),
mandate_reference: Box::new(Some(MandateReference {
connector_mandate_id: item
.data
.connector_mandate_request_reference_id
.clone(),
payment_method_id: None,
mandate_metadata: None,
connector_mandate_request_reference_id: None,
})),
connector_metadata,
network_txn_id: None,
connector_response_reference_id: Some(item.response.operation.order_id.clone()),
incremental_authorization_allowed: None,
charges: None,
}),
..item.data
}),
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2699,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_from_2346984914605397825 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/nexixpay/transformers
// Implementation of RefundStatus for From<NexixpayRefundResultStatus>
fn from(item: NexixpayRefundResultStatus) -> Self {
match item {
NexixpayRefundResultStatus::Voided
| NexixpayRefundResultStatus::Refunded
| NexixpayRefundResultStatus::Executed => Self::Success,
NexixpayRefundResultStatus::Pending => Self::Pending,
NexixpayRefundResultStatus::Failed => Self::Failure,
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2600,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_get_validated_address_details_generic_2346984914605397825 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/nexixpay/transformers
fn get_validated_address_details_generic<RouterContextDataAlias, AddressOutput>(
data: &RouterContextDataAlias,
address_kind: AddressKind,
) -> Result<Option<AddressOutput>, error_stack::Report<errors::ConnectorError>>
where
RouterContextDataAlias: crate::utils::RouterData,
AddressOutput: AddressConstructor + Sized,
{
let (
opt_line1,
opt_line2,
opt_full_name,
opt_city,
opt_zip,
opt_country,
has_address_details_check,
address_type_str,
max_name_len,
max_street_len,
max_city_len,
max_post_code_len,
max_country_len,
) = match address_kind {
AddressKind::Billing => (
data.get_optional_billing_line1(),
data.get_optional_billing_line2(),
data.get_optional_billing_full_name(),
data.get_optional_billing_city(),
data.get_optional_billing_zip(),
data.get_optional_billing_country()
.map(CountryAlpha2::from_alpha2_to_alpha3),
data.get_optional_billing().is_some(),
"billing",
MAX_BILLING_ADDRESS_NAME_LENGTH,
MAX_BILLING_ADDRESS_STREET_LENGTH,
MAX_BILLING_ADDRESS_CITY_LENGTH,
MAX_BILLING_ADDRESS_POST_CODE_LENGTH,
MAX_BILLING_ADDRESS_COUNTRY_LENGTH,
),
AddressKind::Shipping => (
data.get_optional_shipping_line1(),
data.get_optional_shipping_line2(),
data.get_optional_shipping_full_name(),
data.get_optional_shipping_city(),
data.get_optional_shipping_zip(),
data.get_optional_shipping_country()
.map(CountryAlpha2::from_alpha2_to_alpha3),
data.get_optional_shipping().is_some(),
"shipping",
MAX_BILLING_ADDRESS_NAME_LENGTH,
MAX_BILLING_ADDRESS_STREET_LENGTH,
MAX_BILLING_ADDRESS_CITY_LENGTH,
MAX_BILLING_ADDRESS_POST_CODE_LENGTH,
MAX_BILLING_ADDRESS_COUNTRY_LENGTH,
),
};
let street_val = match (opt_line1.clone(), opt_line2.clone()) {
(Some(l1), Some(l2)) => Some(Secret::new(format!("{}, {}", l1.expose(), l2.expose()))),
(Some(l1), None) => Some(l1),
(None, Some(l2)) => Some(l2),
(None, None) => None,
};
if has_address_details_check {
let name_val = opt_full_name;
if let Some(ref val) = name_val {
let length = val.clone().expose().len();
if length > max_name_len {
return Err(error_stack::Report::from(
errors::ConnectorError::MaxFieldLengthViolated {
field_name: format!(
"{address_type_str}.address.first_name & {address_type_str}.address.last_name",
),
connector: "Nexixpay".to_string(),
max_length: max_name_len,
received_length: length,
},
));
}
}
if let Some(ref val) = street_val {
let length = val.clone().expose().len();
if length > max_street_len {
return Err(error_stack::Report::from(
errors::ConnectorError::MaxFieldLengthViolated {
field_name: format!(
"{address_type_str}.address.line1 & {address_type_str}.address.line2",
),
connector: "Nexixpay".to_string(),
max_length: max_street_len,
received_length: length,
},
));
}
}
let city_val = opt_city;
if let Some(ref val) = city_val {
let length = val.len();
if length > max_city_len {
return Err(error_stack::Report::from(
errors::ConnectorError::MaxFieldLengthViolated {
field_name: format!("{address_type_str}.address.city"),
connector: "Nexixpay".to_string(),
max_length: max_city_len,
received_length: length,
},
));
}
}
let post_code_val = opt_zip;
if let Some(ref val) = post_code_val {
let length = val.clone().expose().len();
if length > max_post_code_len {
return Err(error_stack::Report::from(
errors::ConnectorError::MaxFieldLengthViolated {
field_name: format!("{address_type_str}.address.zip"),
connector: "Nexixpay".to_string(),
max_length: max_post_code_len,
received_length: length,
},
));
}
}
let country_val = opt_country;
if let Some(ref val) = country_val {
let length = val.to_string().len();
if length > max_country_len {
return Err(error_stack::Report::from(
errors::ConnectorError::MaxFieldLengthViolated {
field_name: format!("{address_type_str}.address.country"),
connector: "Nexixpay".to_string(),
max_length: max_country_len,
received_length: length,
},
));
}
}
Ok(Some(AddressOutput::new(
name_val,
street_val,
city_val,
post_code_val,
country_val,
)))
} else {
Ok(None)
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 94,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_get_error_response_2346984914605397825 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/nexixpay/transformers
pub fn get_error_response(
operation_result: NexixpayPaymentStatus,
status_code: u16,
) -> ErrorResponse {
ErrorResponse {
status_code,
code: NO_ERROR_CODE.to_string(),
message: operation_result.to_string(),
reason: Some(operation_result.to_string()),
attempt_status: None,
connector_transaction_id: None,
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
connector_metadata: None,
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 67,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_try_from_1863258471422242738 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/novalnet/transformers
// Implementation of NovalnetPaymentsRequest for TryFrom<&SetupMandateRouterData>
fn try_from(item: &SetupMandateRouterData) -> Result<Self, Self::Error> {
let auth = NovalnetAuthType::try_from(&item.connector_auth_type)?;
let merchant = NovalnetPaymentsRequestMerchant {
signature: auth.product_activation_key,
tariff: auth.tariff_id,
};
let enforce_3d = match item.auth_type {
enums::AuthenticationType::ThreeDs => Some(1),
enums::AuthenticationType::NoThreeDs => None,
};
let test_mode = get_test_mode(item.test_mode);
let req_address = item.get_optional_billing();
let billing = NovalnetPaymentsRequestBilling {
house_no: item.get_optional_billing_line1(),
street: item.get_optional_billing_line2(),
city: item.get_optional_billing_city().map(Secret::new),
zip: item.get_optional_billing_zip(),
country_code: item.get_optional_billing_country(),
};
let email = item.get_billing_email().or(item.request.get_email())?;
let customer = NovalnetPaymentsRequestCustomer {
first_name: req_address.and_then(|addr| addr.get_optional_first_name()),
last_name: req_address.and_then(|addr| addr.get_optional_last_name()),
email,
mobile: item.get_optional_billing_phone_number(),
billing: Some(billing),
// no_nc is used to indicate if minimal customer data is passed or not
no_nc: MINIMAL_CUSTOMER_DATA_PASSED,
birth_date: Some(String::from("1992-06-10")),
};
let lang = item
.request
.get_optional_language_from_browser_info()
.unwrap_or(consts::DEFAULT_LOCALE.to_string().to_string());
let custom = NovalnetCustom { lang };
let hook_url = item.request.get_webhook_url()?;
let return_url = item.request.get_return_url()?;
let create_token = Some(CREATE_TOKEN_REQUIRED);
match item.request.payment_method_data {
PaymentMethodData::Card(ref req_card) => {
let novalnet_card = NovalNetPaymentData::Card(NovalnetCard {
card_number: req_card.card_number.clone(),
card_expiry_month: req_card.card_exp_month.clone(),
card_expiry_year: req_card.card_exp_year.clone(),
card_cvc: req_card.card_cvc.clone(),
card_holder: item.get_billing_address()?.get_full_name()?,
});
let transaction = NovalnetPaymentsRequestTransaction {
test_mode,
payment_type: NovalNetPaymentTypes::CREDITCARD,
amount: NovalNetAmount::Int(0),
currency: item.request.currency,
order_no: item.connector_request_reference_id.clone(),
hook_url: Some(hook_url),
return_url: Some(return_url.clone()),
error_return_url: Some(return_url.clone()),
payment_data: Some(novalnet_card),
enforce_3d,
create_token,
};
Ok(Self {
merchant,
transaction,
customer,
custom,
})
}
PaymentMethodData::Wallet(ref wallet_data) => match wallet_data {
WalletDataPaymentMethod::GooglePay(ref req_wallet) => {
let novalnet_google_pay: NovalNetPaymentData =
NovalNetPaymentData::GooglePay(NovalnetGooglePay {
wallet_data: Secret::new(
req_wallet
.tokenization_data
.get_encrypted_google_pay_token()
.change_context(errors::ConnectorError::MissingRequiredField {
field_name: "gpay wallet_token",
})?
.clone(),
),
});
let transaction = NovalnetPaymentsRequestTransaction {
test_mode,
payment_type: NovalNetPaymentTypes::GOOGLEPAY,
amount: NovalNetAmount::Int(0),
currency: item.request.currency,
order_no: item.connector_request_reference_id.clone(),
hook_url: Some(hook_url),
return_url: None,
error_return_url: None,
payment_data: Some(novalnet_google_pay),
enforce_3d,
create_token,
};
Ok(Self {
merchant,
transaction,
customer,
custom,
})
}
WalletDataPaymentMethod::ApplePay(payment_method_data) => {
let transaction = NovalnetPaymentsRequestTransaction {
test_mode,
payment_type: NovalNetPaymentTypes::APPLEPAY,
amount: NovalNetAmount::Int(0),
currency: item.request.currency,
order_no: item.connector_request_reference_id.clone(),
hook_url: Some(hook_url),
return_url: None,
error_return_url: None,
payment_data: Some(NovalNetPaymentData::ApplePay(NovalnetApplePay {
wallet_data: payment_method_data.get_applepay_decoded_payment_data()?,
})),
enforce_3d: None,
create_token,
};
Ok(Self {
merchant,
transaction,
customer,
custom,
})
}
WalletDataPaymentMethod::AliPayQr(_)
| WalletDataPaymentMethod::AliPayRedirect(_)
| WalletDataPaymentMethod::AliPayHkRedirect(_)
| WalletDataPaymentMethod::AmazonPay(_)
| WalletDataPaymentMethod::AmazonPayRedirect(_)
| WalletDataPaymentMethod::Paysera(_)
| WalletDataPaymentMethod::Skrill(_)
| WalletDataPaymentMethod::BluecodeRedirect {}
| WalletDataPaymentMethod::MomoRedirect(_)
| WalletDataPaymentMethod::KakaoPayRedirect(_)
| WalletDataPaymentMethod::GoPayRedirect(_)
| WalletDataPaymentMethod::GcashRedirect(_)
| WalletDataPaymentMethod::ApplePayRedirect(_)
| WalletDataPaymentMethod::ApplePayThirdPartySdk(_)
| WalletDataPaymentMethod::DanaRedirect {}
| WalletDataPaymentMethod::GooglePayRedirect(_)
| WalletDataPaymentMethod::GooglePayThirdPartySdk(_)
| WalletDataPaymentMethod::MbWayRedirect(_)
| WalletDataPaymentMethod::MobilePayRedirect(_)
| WalletDataPaymentMethod::RevolutPay(_) => {
Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("novalnet"),
))?
}
WalletDataPaymentMethod::PaypalRedirect(_) => {
let transaction = NovalnetPaymentsRequestTransaction {
test_mode,
payment_type: NovalNetPaymentTypes::PAYPAL,
amount: NovalNetAmount::Int(0),
currency: item.request.currency,
order_no: item.connector_request_reference_id.clone(),
hook_url: Some(hook_url),
return_url: Some(return_url.clone()),
error_return_url: Some(return_url.clone()),
payment_data: None,
enforce_3d: None,
create_token,
};
Ok(Self {
merchant,
transaction,
customer,
custom,
})
}
WalletDataPaymentMethod::PaypalSdk(_)
| WalletDataPaymentMethod::Paze(_)
| WalletDataPaymentMethod::SamsungPay(_)
| WalletDataPaymentMethod::TwintRedirect {}
| WalletDataPaymentMethod::VippsRedirect {}
| WalletDataPaymentMethod::TouchNGoRedirect(_)
| WalletDataPaymentMethod::WeChatPayRedirect(_)
| WalletDataPaymentMethod::CashappQr(_)
| WalletDataPaymentMethod::SwishQr(_)
| WalletDataPaymentMethod::WeChatPayQr(_)
| WalletDataPaymentMethod::Mifinity(_) => {
Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("novalnet"),
))?
}
},
_ => Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("novalnet"),
))?,
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2769,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_from_1863258471422242738 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/novalnet/transformers
// Implementation of enums::RefundStatus for From<NovalnetTransactionStatus>
fn from(item: NovalnetTransactionStatus) -> Self {
match item {
NovalnetTransactionStatus::Success | NovalnetTransactionStatus::Confirmed => {
Self::Success
}
NovalnetTransactionStatus::Pending => Self::Pending,
NovalnetTransactionStatus::Failure
| NovalnetTransactionStatus::OnHold
| NovalnetTransactionStatus::Deactivated
| NovalnetTransactionStatus::Progress => Self::Failure,
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2600,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_get_error_response_1863258471422242738 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/novalnet/transformers
pub fn get_error_response(result: ResultData, status_code: u16) -> ErrorResponse {
let error_code = result.status;
let error_reason = result.status_text.clone();
ErrorResponse {
code: error_code.to_string(),
message: error_reason.clone(),
reason: Some(error_reason),
status_code,
attempt_status: None,
connector_transaction_id: None,
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
connector_metadata: None,
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 67,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_get_token_1863258471422242738 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/novalnet/transformers
// Inherent implementation for NovalnetSyncResponseTransactionData
pub fn get_token(transaction_data: Option<&Self>) -> Option<String> {
if let Some(data) = transaction_data {
match &data.payment_data {
Some(NovalnetResponsePaymentData::Card(card_data)) => {
card_data.token.clone().map(|token| token.expose())
}
Some(NovalnetResponsePaymentData::Paypal(paypal_data)) => {
paypal_data.token.clone().map(|token| token.expose())
}
None => None,
}
} else {
None
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 57,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_is_refund_event_1863258471422242738 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/novalnet/transformers
pub fn is_refund_event(event_code: &WebhookEventType) -> bool {
matches!(event_code, WebhookEventType::TransactionRefund)
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 31,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_try_from_-5743583739494442283 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/silverflow/transformers
// Implementation of RouterData<F, T, PaymentsResponseData> for TryFrom<ResponseRouterData<F, SilverflowTokenizationResponse, T, PaymentsResponseData>>
fn try_from(
item: ResponseRouterData<F, SilverflowTokenizationResponse, T, PaymentsResponseData>,
) -> Result<Self, Self::Error> {
Ok(Self {
response: Ok(PaymentsResponseData::TokenizationResponse {
token: item.response.key,
}),
..item.data
})
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2657,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_from_-5743583739494442283 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/silverflow/transformers
// Implementation of enums::RefundStatus for From<&SilverflowRefundStatus>
fn from(item: &SilverflowRefundStatus) -> Self {
match item {
SilverflowRefundStatus::Success => Self::Success,
SilverflowRefundStatus::Failure => Self::Failure,
SilverflowRefundStatus::Pending => Self::Pending,
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2600,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_try_from_-3534569339615775185 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/taxjar/transformers
// Implementation of RouterData<F, PaymentsTaxCalculationData, TaxCalculationResponseData> for TryFrom<
ResponseRouterData<
F,
TaxjarPaymentsResponse,
PaymentsTaxCalculationData,
TaxCalculationResponseData,
>,
>
fn try_from(
item: ResponseRouterData<
F,
TaxjarPaymentsResponse,
PaymentsTaxCalculationData,
TaxCalculationResponseData,
>,
) -> Result<Self, Self::Error> {
let currency = item.data.request.currency;
let amount_to_collect = item.response.tax.amount_to_collect;
let calculated_tax = utils::convert_back_amount_to_minor_units(
&FloatMajorUnitForConnector,
amount_to_collect,
currency,
)?;
Ok(Self {
response: Ok(TaxCalculationResponseData {
order_tax_amount: calculated_tax,
}),
..item.data
})
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2659,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_from_-3534569339615775185 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/taxjar/transformers
// Implementation of TaxjarRouterData<T> for From<(FloatMajorUnit, FloatMajorUnit, FloatMajorUnit, T)>
fn from(
(amount, order_amount, shipping, item): (FloatMajorUnit, FloatMajorUnit, FloatMajorUnit, T),
) -> Self {
Self {
amount,
order_amount,
shipping,
router_data: item,
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2600,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_try_from_768773736363713038 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/celero/transformers
// Implementation of RefundsRouterData<RSync> for TryFrom<RefundsResponseRouterData<RSync, CeleroRefundResponse>>
fn try_from(
item: RefundsResponseRouterData<RSync, CeleroRefundResponse>,
) -> Result<Self, Self::Error> {
match item.response.status {
CeleroResponseStatus::Success => Ok(Self {
response: Ok(RefundsResponseData {
connector_refund_id: item.data.request.refund_id.clone(),
refund_status: enums::RefundStatus::Success,
}),
..item.data
}),
CeleroResponseStatus::Error => Ok(Self {
response: Err(hyperswitch_domain_models::router_data::ErrorResponse {
code: "REFUND_SYNC_FAILED".to_string(),
message: item.response.msg.clone(),
reason: Some(item.response.msg),
status_code: item.http_code,
attempt_status: None,
connector_transaction_id: Some(
item.data.request.connector_transaction_id.clone(),
),
network_decline_code: None,
network_advice_code: None,
network_error_message: None,
connector_metadata: None,
}),
..item.data
}),
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2665,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_from_768773736363713038 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/celero/transformers
// Implementation of CeleroErrorDetails for From<CeleroErrorResponse>
fn from(error_response: CeleroErrorResponse) -> Self {
Self {
error_code: Some("API_ERROR".to_string()),
error_message: error_response.msg,
processor_response_code: None,
decline_reason: None,
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2602,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_map_processor_error_768773736363713038 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/celero/transformers
// Inherent implementation for CeleroErrorDetails
/// Map processor response codes and messages to specific Hyperswitch error codes
fn map_processor_error(processor_code: &Option<String>, message: &str) -> Option<String> {
let message_lower = message.to_lowercase();
// Check processor response codes if available
if let Some(code) = processor_code {
match code.as_str() {
"05" => Some("TRANSACTION_DECLINED".to_string()),
"14" => Some("INVALID_CARD_DATA".to_string()),
"51" => Some("INSUFFICIENT_FUNDS".to_string()),
"54" => Some("EXPIRED_CARD".to_string()),
"55" => Some("INCORRECT_CVC".to_string()),
"61" => Some("Exceeds withdrawal amount limit".to_string()),
"62" => Some("TRANSACTION_DECLINED".to_string()),
"65" => Some("Exceeds withdrawal frequency limit".to_string()),
"78" => Some("INVALID_CARD_DATA".to_string()),
"91" => Some("PROCESSING_ERROR".to_string()),
"96" => Some("PROCESSING_ERROR".to_string()),
_ => {
router_env::logger::info!(
"Celero response error code ({:?}) is not mapped to any error state ",
code
);
Some("Transaction failed".to_string())
}
}
} else {
Some(message_lower)
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 39,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_get_mandate_reference_768773736363713038 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/celero/transformers
// Inherent implementation for CeleroTransactionResponseData
pub fn get_mandate_reference(&self) -> Box<Option<MandateReference>> {
if self.payment_method_id.is_some() {
Box::new(Some(MandateReference {
connector_mandate_id: None,
payment_method_id: self.payment_method_id.clone(),
mandate_metadata: None,
connector_mandate_request_reference_id: Some(self.id.clone()),
}))
} else {
Box::new(None)
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": true,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 28,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_determine_cit_mit_fields_768773736363713038 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/celero/transformers
fn determine_cit_mit_fields(
router_data: &PaymentsAuthorizeRouterData,
) -> Result<(CeleroMandateFields, CeleroPaymentMethod), error_stack::Report<errors::ConnectorError>>
{
// Default null values
let mut mandate_fields = CeleroMandateFields::default();
// First check if there's a mandate_id in the request
match router_data
.request
.mandate_id
.clone()
.and_then(|mandate_ids| mandate_ids.mandate_reference_id)
{
// If there's a connector mandate ID, this is a MIT (Merchant Initiated Transaction)
Some(api_models::payments::MandateReferenceId::ConnectorMandateId(
connector_mandate_id,
)) => {
mandate_fields.card_on_file_indicator = Some(CardOnFileIndicator::RecurringPayment);
mandate_fields.initiated_by = Some(InitiatedBy::Merchant); // This is a MIT
mandate_fields.stored_credential_indicator = Some(StoredCredentialIndicator::Used);
mandate_fields.billing_method = Some(BillingMethod::Recurring);
mandate_fields.initial_transaction_id =
connector_mandate_id.get_connector_mandate_request_reference_id();
Ok((
mandate_fields,
CeleroPaymentMethod::Customer(CeleroCustomer {
id: Some(router_data.get_customer_id()?),
payment_method_id: connector_mandate_id.get_payment_method_id(),
}),
))
}
// For other mandate types that might not be supported
Some(api_models::payments::MandateReferenceId::NetworkMandateId(_))
| Some(api_models::payments::MandateReferenceId::NetworkTokenWithNTI(_)) => {
// These might need different handling or return an error
Err(errors::ConnectorError::NotImplemented(
get_unimplemented_payment_method_error_message("Celero"),
)
.into())
}
// If no mandate ID is present, check if it's a mandate payment
None => {
if router_data.request.is_mandate_payment() {
// This is a customer-initiated transaction for a recurring payment
mandate_fields.initiated_by = Some(InitiatedBy::Customer);
mandate_fields.card_on_file_indicator = Some(CardOnFileIndicator::RecurringPayment);
mandate_fields.billing_method = Some(BillingMethod::Recurring);
mandate_fields.stored_credential_indicator = Some(StoredCredentialIndicator::Used);
}
let is_three_ds = router_data.is_three_ds();
Ok((
mandate_fields,
CeleroPaymentMethod::try_from((
&router_data.request.payment_method_data,
is_three_ds,
))?,
))
}
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 26,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_try_from_6746975707483433314 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/adyen/transformers
// Implementation of AdyenPaymentRequest<'_> for TryFrom<(
&AdyenRouterData<&PaymentsAuthorizeRouterData>,
&NetworkTokenData,
)>
fn try_from(
value: (
&AdyenRouterData<&PaymentsAuthorizeRouterData>,
&NetworkTokenData,
),
) -> Result<Self, Self::Error> {
let (item, token_data) = value;
let amount = get_amount_data(item);
let auth_type = AdyenAuthType::try_from(&item.router_data.connector_auth_type)?;
let shopper_interaction = AdyenShopperInteraction::from(item.router_data);
let shopper_reference = build_shopper_reference(item.router_data);
let (recurring_processing_model, store_payment_method, _) =
get_recurring_processing_model(item.router_data)?;
let browser_info = get_browser_info(item.router_data)?;
let billing_address =
get_address_info(item.router_data.get_optional_billing()).transpose()?;
let country_code = get_country_code(item.router_data.get_optional_billing());
let additional_data = get_additional_data(item.router_data);
let return_url = item.router_data.request.get_router_return_url()?;
let testing_data = item
.router_data
.request
.get_connector_testing_data()
.map(AdyenTestingData::try_from)
.transpose()?;
let test_holder_name = testing_data.and_then(|test_data| test_data.holder_name);
let card_holder_name =
test_holder_name.or(item.router_data.get_optional_billing_full_name());
let payment_method = PaymentMethod::AdyenPaymentMethod(Box::new(
AdyenPaymentMethod::try_from((token_data, card_holder_name))?,
));
let shopper_email = item.router_data.request.email.clone();
let shopper_name = get_shopper_name(item.router_data.get_optional_billing());
let mpi_data = AdyenMpiData {
directory_response: "Y".to_string(),
authentication_response: "Y".to_string(),
cavv: None,
token_authentication_verification_value: Some(
token_data.get_cryptogram().clone().unwrap_or_default(),
),
eci: Some("02".to_string()),
};
let (store, splits) = match item.router_data.request.split_payments.as_ref() {
Some(common_types::payments::SplitPaymentsRequest::AdyenSplitPayment(
adyen_split_payment,
)) => get_adyen_split_request(adyen_split_payment, item.router_data.request.currency),
_ => (None, None),
};
let device_fingerprint = item
.router_data
.request
.metadata
.clone()
.and_then(get_device_fingerprint);
let delivery_address =
get_address_info(item.router_data.get_optional_shipping()).and_then(Result::ok);
let telephone_number = item.router_data.get_optional_billing_phone_number();
Ok(AdyenPaymentRequest {
amount,
merchant_account: auth_type.merchant_account,
payment_method,
reference: item.router_data.connector_request_reference_id.clone(),
return_url,
shopper_interaction,
recurring_processing_model,
browser_info,
additional_data,
telephone_number,
shopper_name,
shopper_email,
shopper_locale: item.router_data.request.locale.clone(),
social_security_number: None,
billing_address,
delivery_address,
country_code,
line_items: None,
shopper_reference,
store_payment_method,
channel: None,
shopper_statement: item.router_data.request.statement_descriptor.clone(),
shopper_ip: item.router_data.request.get_ip_address_as_optional(),
merchant_order_reference: item.router_data.request.merchant_order_reference_id.clone(),
mpi_data: Some(mpi_data),
store,
splits,
device_fingerprint,
session_validity: None,
metadata: item.router_data.request.metadata.clone(),
})
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2747,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_from_6746975707483433314 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/adyen/transformers
// Implementation of storage_enums::PayoutStatus for From<AdyenStatus>
fn from(adyen_status: AdyenStatus) -> Self {
match adyen_status {
AdyenStatus::Authorised => Self::Success,
AdyenStatus::PayoutConfirmReceived => Self::Initiated,
AdyenStatus::Cancelled | AdyenStatus::PayoutDeclineReceived => Self::Cancelled,
AdyenStatus::Error => Self::Failed,
AdyenStatus::Pending => Self::Pending,
AdyenStatus::PayoutSubmitReceived => Self::RequiresFulfillment,
_ => Self::Ineligible,
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 2600,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_from_str_6746975707483433314 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/adyen/transformers
// Implementation of AdyenRefundRequestReason for FromStr
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_uppercase().as_str() {
"FRAUD" => Ok(Self::FRAUD),
"CUSTOMER REQUEST" | "CUSTOMERREQUEST" => Ok(Self::CUSTOMERREQUEST),
"RETURN" => Ok(Self::RETURN),
"DUPLICATE" => Ok(Self::DUPLICATE),
"OTHER" => Ok(Self::OTHER),
_ => Ok(Self::OTHER),
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 783,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_foreign_try_from_6746975707483433314 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/adyen/transformers
// Implementation of DefendDisputeRouterData for ForeignTryFrom<(&Self, AdyenDisputeResponse)>
fn foreign_try_from(item: (&Self, AdyenDisputeResponse)) -> Result<Self, Self::Error> {
let (data, response) = item;
if response.success {
Ok(DefendDisputeRouterData {
response: Ok(DefendDisputeResponse {
dispute_status: storage_enums::DisputeStatus::DisputeChallenged,
connector_status: None,
}),
..data.clone()
})
} else {
Ok(DefendDisputeRouterData {
response: Err(ErrorResponse {
code: response
.error_message
.clone()
.unwrap_or_else(|| NO_ERROR_CODE.to_string()),
message: response
.error_message
.clone()
.unwrap_or_else(|| NO_ERROR_MESSAGE.to_string()),
reason: response.error_message,
status_code: data.connector_http_status_code.ok_or(
errors::ConnectorError::MissingRequiredField {
field_name: "http code",
},
)?,
attempt_status: None,
connector_transaction_id: None,
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
connector_metadata: None,
}),
..data.clone()
})
}
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 446,
"total_crates": null
} |
fn_clm_hyperswitch_connectors_get_str_6746975707483433314 | clm | function | // Repository: hyperswitch
// Crate: hyperswitch_connectors
// Purpose: Payment provider integrations (Stripe, PayPal, etc.)
// Module: crates/hyperswitch_connectors/src/connectors/adyen/transformers
fn get_str(key: &str, riskdata: &serde_json::Value) -> Option<String> {
riskdata
.get(key)
.and_then(|v| v.as_str())
.map(|s| s.to_string())
}
| {
"crate": "hyperswitch_connectors",
"file": null,
"file_size": null,
"is_async": false,
"is_pub": false,
"num_enums": null,
"num_structs": null,
"num_tables": null,
"score": 118,
"total_crates": null
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.