Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
use api_models::enums::Connector;
use error_stack::ResultExt;
use crate::{core::errors, types::domain};
pub fn generate_card_from_details(
card_number: String,
card_exp_year: String,
card_exp_month: String,
card_cvv: String,
) -> errors::RouterResult<domain::Card> {
Ok(domain::Card {
card_number: card_number
.parse::<cards::CardNumber>()
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Error while parsing card number")?,
card_issuer: None,
card_cvc: hyperswitch_masking::Secret::new(card_cvv),
card_network: None,
card_exp_year: hyperswitch_masking::Secret::new(card_exp_year),
card_exp_month: hyperswitch_masking::Secret::new(card_exp_month),
nick_name: None,
card_type: None,
card_subtype: None,
card_segment_type: None,
funding_source: None,
card_issuing_country: None,
card_issuing_country_code: None,
bank_code: None,
card_holder_name: None,
co_badged_card_data: None,
})
}
pub fn get_test_card_details(
connector_name: Connector,
) -> errors::RouterResult<Option<domain::Card>> {
match connector_name {
Connector::Stripe => Some(generate_card_from_details(
"4242424242424242".to_string(),
"2025".to_string(),
"12".to_string(),
"100".to_string(),
))
.transpose(),
Connector::Paypal => Some(generate_card_from_details(
"4111111111111111".to_string(),
"2025".to_string(),
"02".to_string(),
"123".to_string(),
))
.transpose(),
_ => Ok(None),
}
}