id stringlengths 20 153 | type stringclasses 1
value | granularity stringclasses 14
values | content stringlengths 16 84.3k | metadata dict |
|---|---|---|---|---|
connector-service_body_connector-integration_8988377329679646038 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/fiuu/transformers.rs
// Function: from
{
match value {
FiuuRefundsWebhookStatus::RefundSuccess => Self::RefundSuccess,
FiuuRefundsWebhookStatus::RefundFailure => Self::RefundFailure,
FiuuRefundsWebhookStatus::RefundPending => Self::IncomingWebhookEventUnspecified,
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "from",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_7436998386497302050 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/fiuu/transformers.rs
// Function: capture_status_codes
{
[
("00", "Capture successful"),
("11", "Capture failed"),
("12", "Invalid or unmatched security hash string"),
("13", "Not a credit card transaction"),
("15", "Requested day is on settlement day"),
("16", "Forbidden transaction"),
("17", "Transaction not found"),
("18", "Missing required parameter"),
("19", "Domain not found"),
("20", "Temporary out of service"),
("21", "Authorization expired"),
("23", "Partial capture not allowed"),
("24", "Transaction already captured"),
("25", "Requested amount exceeds available capture amount"),
("99", "General error (contact payment gateway support)"),
]
.into_iter()
.collect()
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "capture_status_codes",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-8534463597789796036 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/fiuu/transformers.rs
// Function: void_status_codes
{
[
("00", "Success (will proceed the request)"),
("11", "Failure"),
("12", "Invalid or unmatched security hash string"),
("13", "Not a refundable transaction"),
("14", "Transaction date more than 180 days"),
("15", "Requested day is on settlement day"),
("16", "Forbidden transaction"),
("17", "Transaction not found"),
("18", "Duplicate partial refund request"),
("19", "Merchant not found"),
("20", "Missing required parameter"),
(
"21",
"Transaction must be in authorized/captured/settled status",
),
]
.into_iter()
.collect()
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "void_status_codes",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_764780647771770914 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/fiuu/transformers.rs
// Function: get_qr_metadata
{
let image_data = QrImage::new_colored_from_data(
response.txn_data.request_data.qr_data.peek().clone(),
DUIT_NOW_BRAND_COLOR,
)
.change_context(errors::ConnectorError::ResponseHandlingFailed)?;
let image_data_url = Url::parse(image_data.data.clone().as_str()).ok();
let display_to_timestamp = None;
if let Some(color_image_data_url) = image_data_url {
let qr_code_info = QrCodeInformation::QrColorDataUrl {
color_image_data_url,
display_to_timestamp,
display_text: Some(DUIT_NOW_BRAND_TEXT.to_string()),
border_color: Some(DUIT_NOW_BRAND_COLOR.to_string()),
};
Some(qr_code_info.encode_to_value())
.transpose()
.change_context(errors::ConnectorError::ResponseHandlingFailed)
} else {
Ok(None)
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_qr_metadata",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-4757302051768782463 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/fiuu/transformers.rs
// Function: build_form_from_struct
{
let mut form = reqwest::multipart::Form::new();
let serialized =
serde_json::to_value(&data).map_err(|_| errors::ParsingError::EncodeError("json-value"))?;
let serialized_object = serialized
.as_object()
.ok_or(errors::ParsingError::EncodeError("Expected object"))?;
for (key, values) in serialized_object {
let value = match values {
Value::String(s) => s.clone(),
Value::Number(n) => n.to_string(),
Value::Bool(b) => b.to_string(),
Value::Array(_) | Value::Object(_) | Value::Null => "".to_string(),
};
form = form.text(key.clone(), value.clone());
}
Ok(form)
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "build_form_from_struct",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_5459057106939751601 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/fiuu/transformers.rs
// Function: new_from_data
{
let qr_code = qrcode::QrCode::new(data.as_bytes())
.change_context(QrCodeError::FailedToCreateQrCode)?;
let qrcode_image_buffer = qr_code.render::<Luma<u8>>().build();
let qrcode_dynamic_image = DynamicImage::ImageLuma8(qrcode_image_buffer);
let mut image_bytes = std::io::BufWriter::new(std::io::Cursor::new(Vec::new()));
// Encodes qrcode_dynamic_image and write it to image_bytes
let _ = qrcode_dynamic_image.write_to(&mut image_bytes, ImageFormat::Png);
let image_data_source = format!(
"{},{}",
QR_IMAGE_DATA_SOURCE_STRING,
BASE64_ENGINE.encode(image_bytes.buffer())
);
Ok(Self {
data: image_data_source,
})
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "new_from_data",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-313731343863386829 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/fiuu/transformers.rs
// Function: new_colored_from_data
{
let qr_code = qrcode::QrCode::new(data.as_bytes())
.change_context(QrCodeError::FailedToCreateQrCode)?;
let qrcode_image_buffer = qr_code.render::<Luma<u8>>().build();
let (width, height) = qrcode_image_buffer.dimensions();
let mut colored_image = ImageBuffer::new(width, height);
let rgb = Self::parse_hex_color(hex_color)?;
for (x, y, pixel) in qrcode_image_buffer.enumerate_pixels() {
let luminance = pixel.0[0];
let color = if luminance == 0 {
Rgba([rgb.0, rgb.1, rgb.2, 255])
} else {
Rgba([255, 255, 255, 255])
};
colored_image.put_pixel(x, y, color);
}
let qrcode_dynamic_image = DynamicImage::ImageRgba8(colored_image);
let mut image_bytes = std::io::Cursor::new(Vec::new());
qrcode_dynamic_image
.write_to(&mut image_bytes, ImageFormat::Png)
.change_context(QrCodeError::FailedToCreateQrCode)?;
let image_data_source = format!(
"{},{}",
QR_IMAGE_DATA_SOURCE_STRING,
BASE64_ENGINE.encode(image_bytes.get_ref())
);
Ok(Self {
data: image_data_source,
})
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "new_colored_from_data",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_1626286669194681363 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/fiuu/transformers.rs
// Function: parse_hex_color
{
let hex = hex.trim_start_matches('#');
if hex.len() == 6 {
let r = u8::from_str_radix(&hex[0..2], 16).ok();
let g = u8::from_str_radix(&hex[2..4], 16).ok();
let b = u8::from_str_radix(&hex[4..6], 16).ok();
if let (Some(r), Some(g), Some(b)) = (r, g, b) {
return Ok((r, g, b));
}
}
Err(QrCodeError::InvalidHexColor)
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "parse_hex_color",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-2475670696279178684 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/aci/transformers.rs
// Function: try_from
{
let auth = AciAuthType::try_from(&item.router_data.connector_auth_type)?;
let amount = item
.connector
.amount_converter
.convert(
item.router_data.request.minor_amount,
item.router_data.request.currency,
)
.change_context(ConnectorError::AmountConversionFailed)?;
let payment_type = if item.router_data.request.is_auto_capture()? {
AciPaymentType::Debit
} else {
AciPaymentType::Preauthorization
};
let instruction = Some(Instruction {
mode: InstructionMode::Repeated,
transaction_type: InstructionType::Unscheduled,
source: InstructionSource::MerchantInitiatedTransaction,
create_registration: None,
});
let txn_details = TransactionDetails {
entity_id: auth.entity_id,
amount,
currency: item.router_data.request.currency.to_string(),
payment_type,
};
let recurring_type = Some(AciRecurringType::Repeated);
Ok(Self {
txn_details,
payment_method: PaymentDetails::Mandate,
instruction,
shopper_result_url: item.router_data.resource_common_data.return_url.clone(),
three_ds_two_enrolled: None,
recurring_type,
})
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "try_from",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_5868182820372981165 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/aci/transformers.rs
// Function: get_aci_payment_brand
{
match card_network {
Some(common_enums::CardNetwork::Visa) => Ok(PaymentBrand::Visa),
Some(common_enums::CardNetwork::Mastercard) => Ok(PaymentBrand::Mastercard),
Some(common_enums::CardNetwork::AmericanExpress) => Ok(PaymentBrand::AmericanExpress),
Some(common_enums::CardNetwork::JCB) => Ok(PaymentBrand::Jcb),
Some(common_enums::CardNetwork::DinersClub) => Ok(PaymentBrand::DinersClub),
Some(common_enums::CardNetwork::Discover) => Ok(PaymentBrand::Discover),
Some(common_enums::CardNetwork::UnionPay) => Ok(PaymentBrand::UnionPay),
Some(common_enums::CardNetwork::Maestro) => Ok(PaymentBrand::Maestro),
Some(unsupported_network) => Err(errors::ConnectorError::NotSupported {
message: format!("Card network {unsupported_network} is not supported by ACI"),
connector: "ACI",
})?,
None => {
if is_network_token_flow {
Ok(PaymentBrand::Visa)
} else {
Err(errors::ConnectorError::MissingRequiredField {
field_name: "card.card_network",
}
.into())
}
}
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_aci_payment_brand",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_5993362075725529143 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/aci/transformers.rs
// Function: get_transaction_details
{
let auth = AciAuthType::try_from(&item.router_data.connector_auth_type)?;
let amount = item
.connector
.amount_converter
.convert(
item.router_data.request.minor_amount,
item.router_data.request.currency,
)
.change_context(ConnectorError::AmountConversionFailed)?;
let payment_type = if item.router_data.request.is_auto_capture()? {
AciPaymentType::Debit
} else {
AciPaymentType::Preauthorization
};
Ok(TransactionDetails {
entity_id: auth.entity_id,
amount,
currency: item.router_data.request.currency.to_string(),
payment_type,
})
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_transaction_details",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-6818782463916748221 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/aci/transformers.rs
// Function: get_instruction_details
{
if item.router_data.request.customer_acceptance.is_some()
&& item.router_data.request.setup_future_usage
== Some(common_enums::FutureUsage::OffSession)
{
return Some(Instruction {
mode: InstructionMode::Initial,
transaction_type: InstructionType::Unscheduled,
source: InstructionSource::CardholderInitiatedTransaction,
create_registration: Some(true),
});
} else if item.router_data.request.mandate_id.is_some() {
return Some(Instruction {
mode: InstructionMode::Repeated,
transaction_type: InstructionType::Unscheduled,
source: InstructionSource::MerchantInitiatedTransaction,
create_registration: None,
});
}
None
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_instruction_details",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-5309365021088424429 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/aci/transformers.rs
// Function: get_recurring_type
{
if item.router_data.request.customer_acceptance.is_some()
&& item.router_data.request.setup_future_usage
== Some(common_enums::FutureUsage::OffSession)
{
Some(AciRecurringType::Initial)
} else {
None
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_recurring_type",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-6266609253027953232 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/aci/transformers.rs
// Function: map_aci_attempt_status
{
match item {
AciPaymentStatus::Succeeded => {
if auto_capture {
common_enums::AttemptStatus::Charged
} else {
common_enums::AttemptStatus::Authorized
}
}
AciPaymentStatus::Failed => common_enums::AttemptStatus::Failure,
AciPaymentStatus::Pending => common_enums::AttemptStatus::Authorizing,
AciPaymentStatus::RedirectShopper => common_enums::AttemptStatus::AuthenticationPending,
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "map_aci_attempt_status",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-2349756336930730154 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/aci/transformers.rs
// Function: from_str
{
if FAILURE_CODES.contains(&s) {
Ok(Self::Failed)
} else if PENDING_CODES.contains(&s) {
Ok(Self::Pending)
} else if SUCCESSFUL_CODES.contains(&s) {
Ok(Self::Succeeded)
} else {
Err(report!(errors::ConnectorError::UnexpectedResponseError(
bytes::Bytes::from(s.to_owned())
)))
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "from_str",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-324582186595130169 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/aci/transformers.rs
// Function: map_aci_capture_status
{
match item {
AciStatus::Succeeded => common_enums::AttemptStatus::Charged,
AciStatus::Failed => common_enums::AttemptStatus::Failure,
AciStatus::Pending => common_enums::AttemptStatus::Pending,
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "map_aci_capture_status",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_4759838529303483321 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/aci/transformers.rs
// Function: map_aci_void_status
{
match item {
AciStatus::Succeeded => common_enums::AttemptStatus::Voided,
AciStatus::Failed => common_enums::AttemptStatus::VoidFailed,
AciStatus::Pending => common_enums::AttemptStatus::VoidInitiated,
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "map_aci_void_status",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_5967455669209128865 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/aci/transformers.rs
// Function: from
{
match item {
AciRefundStatus::Succeeded => Self::Success,
AciRefundStatus::Failed => Self::Failure,
AciRefundStatus::Pending => Self::Pending,
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "from",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_6772711868557895414 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/fiserv/transformers.rs
// Function: get_card_expiry_year_4_digit_placeholder
{
let year_str = year_yy.peek();
if year_str.len() == 2 && year_str.chars().all(char::is_numeric) {
Ok(Secret::new(format!("20{year_str}")))
} else if year_str.len() == 4 && year_str.chars().all(char::is_numeric) {
Ok(year_yy.clone())
} else {
Err(report!(ConnectorError::RequestEncodingFailed))
.attach_printable("Invalid card expiry year format: expected YY or YYYY")
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_card_expiry_year_4_digit_placeholder",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_2816155212846388580 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/fiserv/transformers.rs
// Function: try_from
{
let ResponseRouterData {
response,
router_data,
http_code,
} = item;
let error_details = response
.error
.as_ref()
.or(response.details.as_ref())
.and_then(|e| e.first());
let message = error_details.map_or(NO_ERROR_MESSAGE.to_string(), |e| e.message.clone());
let code = error_details
.and_then(|e| e.code.clone())
.unwrap_or_else(|| NO_ERROR_CODE.to_string());
let reason = error_details.and_then(|e| e.field.clone());
let mut router_data_out = router_data;
router_data_out.response = Err(ErrorResponse {
code,
message,
reason,
status_code: http_code,
attempt_status: None,
connector_transaction_id: None,
network_decline_code: None,
network_advice_code: None,
network_error_message: None,
});
Ok(router_data_out)
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "try_from",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_4136552758440614962 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/fiserv/transformers.rs
// Function: from
{
match item {
FiservPaymentStatus::Captured
| FiservPaymentStatus::Succeeded
| FiservPaymentStatus::Authorized => Self::Success,
FiservPaymentStatus::Declined | FiservPaymentStatus::Failed => Self::Failure,
FiservPaymentStatus::Voided | FiservPaymentStatus::Processing => Self::Pending,
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "from",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-3758289943798318162 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/checkout/transformers.rs
// Function: to_connector_meta
{
connector_meta
.map(|meta| {
serde_json::from_value::<CheckoutMeta>(meta)
.map_err(|_| report!(errors::ConnectorError::ResponseDeserializationFailed))
})
.unwrap_or(Ok(CheckoutMeta {
psync_flow: CheckoutPaymentIntent::Capture,
}))
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "to_connector_meta",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-6306299953775902384 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/checkout/transformers.rs
// Function: get_connector_meta
{
match capture_method {
enums::CaptureMethod::Automatic | enums::CaptureMethod::SequentialAutomatic => {
Ok(serde_json::json!(CheckoutMeta {
psync_flow: CheckoutPaymentIntent::Capture,
}))
}
enums::CaptureMethod::Manual | enums::CaptureMethod::ManualMultiple => {
Ok(serde_json::json!(CheckoutMeta {
psync_flow: CheckoutPaymentIntent::Authorize,
}))
}
enums::CaptureMethod::Scheduled => {
Err(errors::ConnectorError::CaptureMethodNotSupported.into())
}
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_connector_meta",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_5289544423721072476 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/checkout/transformers.rs
// Function: get_attempt_status_cap
{
let (status, capture_method) = item;
match status {
CheckoutPaymentStatus::Authorized => {
if capture_method == Some(enums::CaptureMethod::Automatic) || capture_method.is_none() {
enums::AttemptStatus::Pending
} else {
enums::AttemptStatus::Authorized
}
}
CheckoutPaymentStatus::Captured
| CheckoutPaymentStatus::PartiallyRefunded
| CheckoutPaymentStatus::Refunded => enums::AttemptStatus::Charged,
CheckoutPaymentStatus::PartiallyCaptured => enums::AttemptStatus::PartialCharged,
CheckoutPaymentStatus::Declined
| CheckoutPaymentStatus::Expired
| CheckoutPaymentStatus::Canceled => enums::AttemptStatus::Failure,
CheckoutPaymentStatus::Pending => enums::AttemptStatus::AuthenticationPending,
CheckoutPaymentStatus::CardVerified | CheckoutPaymentStatus::RetryScheduled => {
enums::AttemptStatus::Pending
}
CheckoutPaymentStatus::Voided => enums::AttemptStatus::Voided,
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_attempt_status_cap",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_5008216598957983708 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/checkout/transformers.rs
// Function: get_attempt_status_intent
{
let (status, psync_flow) = item;
match status {
CheckoutPaymentStatus::Authorized => {
if psync_flow == CheckoutPaymentIntent::Capture {
enums::AttemptStatus::Pending
} else {
enums::AttemptStatus::Authorized
}
}
CheckoutPaymentStatus::Captured
| CheckoutPaymentStatus::PartiallyRefunded
| CheckoutPaymentStatus::Refunded => enums::AttemptStatus::Charged,
CheckoutPaymentStatus::PartiallyCaptured => enums::AttemptStatus::PartialCharged,
CheckoutPaymentStatus::Declined
| CheckoutPaymentStatus::Expired
| CheckoutPaymentStatus::Canceled => enums::AttemptStatus::Failure,
CheckoutPaymentStatus::Pending => enums::AttemptStatus::AuthenticationPending,
CheckoutPaymentStatus::CardVerified | CheckoutPaymentStatus::RetryScheduled => {
enums::AttemptStatus::Pending
}
CheckoutPaymentStatus::Voided => enums::AttemptStatus::Voided,
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_attempt_status_intent",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_5133014760509552792 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/checkout/transformers.rs
// Function: get_attempt_status_bal
{
let (status, balances) = item;
match status {
CheckoutPaymentStatus::Authorized => {
if let Some(Balances {
available_to_capture: 0,
}) = balances
{
enums::AttemptStatus::Charged
} else {
enums::AttemptStatus::Authorized
}
}
CheckoutPaymentStatus::Captured
| CheckoutPaymentStatus::PartiallyRefunded
| CheckoutPaymentStatus::Refunded => enums::AttemptStatus::Charged,
CheckoutPaymentStatus::PartiallyCaptured => enums::AttemptStatus::PartialCharged,
CheckoutPaymentStatus::Declined
| CheckoutPaymentStatus::Expired
| CheckoutPaymentStatus::Canceled => enums::AttemptStatus::Failure,
CheckoutPaymentStatus::Pending => enums::AttemptStatus::AuthenticationPending,
CheckoutPaymentStatus::CardVerified | CheckoutPaymentStatus::RetryScheduled => {
enums::AttemptStatus::Pending
}
CheckoutPaymentStatus::Voided => enums::AttemptStatus::Voided,
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_attempt_status_bal",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-3841855297523034765 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/checkout/transformers.rs
// Function: try_from
{
let ResponseRouterData {
response,
router_data,
http_code,
} = item;
// Get the refund status using the From implementation
let refund_status = enums::RefundStatus::from(response);
let mut router_data = router_data;
router_data.response = Ok(RefundsResponseData {
connector_refund_id: response.action_id.clone(),
refund_status,
status_code: http_code,
});
Ok(router_data)
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "try_from",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-2434093513669160601 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/cashtocode/transformers.rs
// Function: get_mid
{
match CashtocodeAuth::try_from((connector_auth_type, ¤cy)) {
Ok(cashtocode_auth) => match payment_method_type {
Some(common_enums::PaymentMethodType::ClassicReward) => Ok(cashtocode_auth
.merchant_id_classic
.ok_or(errors::ConnectorError::FailedToObtainAuthType)?),
Some(common_enums::PaymentMethodType::Evoucher) => Ok(cashtocode_auth
.merchant_id_evoucher
.ok_or(errors::ConnectorError::FailedToObtainAuthType)?),
_ => Err(errors::ConnectorError::FailedToObtainAuthType),
},
Err(_) => Err(errors::ConnectorError::FailedToObtainAuthType)?,
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_mid",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_1867878338672038562 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/cashtocode/transformers.rs
// Function: try_from
{
let ResponseRouterData {
response,
router_data,
http_code,
} = item;
let (status, response) = match response {
CashtocodePaymentsResponse::CashtoCodeError(error_data) => (
common_enums::AttemptStatus::Failure,
Err(ErrorResponse {
code: error_data.error.to_string(),
status_code: item.http_code,
message: error_data.error_description.clone(),
reason: Some(error_data.error_description),
attempt_status: None,
connector_transaction_id: None,
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
}),
),
CashtocodePaymentsResponse::CashtoCodeData(response_data) => {
let payment_method_type = router_data
.request
.payment_method_type
.ok_or(errors::ConnectorError::MissingPaymentMethodType)?;
let redirection_data = get_redirect_form_data(payment_method_type, response_data)?;
(
common_enums::AttemptStatus::AuthenticationPending,
Ok(PaymentsResponseData::TransactionResponse {
resource_id: ResponseId::ConnectorTransactionId(
router_data
.resource_common_data
.connector_request_reference_id
.clone(),
),
redirection_data: Some(Box::new(redirection_data)),
mandate_reference: None,
connector_metadata: None,
network_txn_id: None,
connector_response_reference_id: None,
incremental_authorization_allowed: None,
status_code: http_code,
}),
)
}
};
Ok(Self {
resource_common_data: PaymentFlowData {
status,
..router_data.resource_common_data
},
response,
..router_data
})
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "try_from",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-5154119684211301797 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/cashtocode/transformers.rs
// Function: from
{
match item {
CashtocodePaymentStatus::Succeeded => Self::Charged,
CashtocodePaymentStatus::Processing => Self::AuthenticationPending,
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "from",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_6883614331911483996 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/cashtocode/transformers.rs
// Function: get_redirect_form_data
{
match payment_method_type {
common_enums::PaymentMethodType::ClassicReward => Ok(RedirectForm::Form {
//redirect form is manually constructed because the connector for this pm type expects query params in the url
endpoint: response_data.pay_url.to_string(),
method: Method::Post,
form_fields: Default::default(),
}),
common_enums::PaymentMethodType::Evoucher => Ok(RedirectForm::Form {
//here the pay url gets parsed, and query params are sent as formfields as the connector expects
endpoint: response_data.pay_url.to_string(),
method: Method::Get,
form_fields: Default::default(),
}),
_ => Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("CashToCode"),
))?,
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_redirect_form_data",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_8339934356743527216 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/cybersource/transformers.rs
// Function: card_issuer_to_string
{
let card_type = match card_issuer {
CardIssuer::AmericanExpress => "003",
CardIssuer::Master => "002",
//"042" is the type code for Masetro Cards(International). For Maestro Cards(UK-Domestic) the mapping should be "024"
CardIssuer::Maestro => "042",
CardIssuer::Visa => "001",
CardIssuer::Discover => "004",
CardIssuer::DinersClub => "005",
CardIssuer::CarteBlanche => "006",
CardIssuer::JCB => "007",
CardIssuer::CartesBancaires => "036",
};
card_type.to_string()
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "card_issuer_to_string",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_7619619377881359831 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/cybersource/transformers.rs
// Function: try_from
{
let commerce_indicator = solution
.as_ref()
.map(|pm_solution| match pm_solution {
PaymentSolution::ApplePay | PaymentSolution::SamsungPay => network
.as_ref()
.map(|card_network| match card_network.to_lowercase().as_str() {
"mastercard" => "spa",
_ => "internet",
})
.unwrap_or("internet"),
PaymentSolution::GooglePay => "internet",
})
.unwrap_or("internet")
.to_string();
let connector_merchant_config = CybersourceConnectorMetadataObject::try_from(
&item.router_data.request.merchant_account_metadata,
)?;
// Extract connector mandate ID from mandate_reference
let connector_mandate_id = match &item.router_data.request.mandate_reference {
MandateReferenceId::ConnectorMandateId(connector_mandate_data) => {
connector_mandate_data
.get_connector_mandate_id()
.ok_or_else(|| errors::ConnectorError::MissingRequiredField {
field_name: "connector_mandate_id",
})?
}
MandateReferenceId::NetworkMandateId(_)
| MandateReferenceId::NetworkTokenWithNTI(_) => {
return Err(error_stack::report!(errors::ConnectorError::NotSupported {
message: "Network mandate ID not supported for Cybersource repeat payments"
.to_string(),
connector: "cybersource",
}));
}
};
let (action_list, action_token_types, authorization_options) = if !connector_mandate_id
.is_empty()
{
match item.router_data.request.mandate_reference.clone() {
MandateReferenceId::ConnectorMandateId(_) => {
let original_amount = item
.router_data
.request
.recurring_mandate_payment_data
.as_ref()
.and_then(|recurring_mandate_payment_data| {
recurring_mandate_payment_data.original_payment_authorized_amount
});
let original_currency = item
.router_data
.request
.recurring_mandate_payment_data
.as_ref()
.and_then(|recurring_mandate_payment_data| {
recurring_mandate_payment_data.original_payment_authorized_currency
});
let original_authorized_amount = match original_amount.zip(original_currency) {
Some((original_amount, original_currency)) => {
Some(domain_types::utils::get_amount_as_string(
&common_enums::CurrencyUnit::Base,
original_amount,
original_currency,
)?)
}
None => None,
};
(
None,
None,
Some(CybersourceAuthorizationOptions {
initiator: None,
merchant_initiated_transaction: Some(MerchantInitiatedTransaction {
reason: None,
original_authorized_amount,
previous_transaction_id: None,
}),
ignore_avs_result: connector_merchant_config.disable_avs,
ignore_cv_result: connector_merchant_config.disable_cvn,
}),
)
}
MandateReferenceId::NetworkMandateId(_)
| MandateReferenceId::NetworkTokenWithNTI(_) => {
return Err(error_stack::report!(errors::ConnectorError::NotSupported {
message: "Network mandate ID not supported for Cybersource repeat payments"
.to_string(),
connector: "cybersource",
}));
}
}
} else {
(
None,
None,
Some(CybersourceAuthorizationOptions {
initiator: None,
merchant_initiated_transaction: None,
ignore_avs_result: connector_merchant_config.disable_avs,
ignore_cv_result: connector_merchant_config.disable_cvn,
}),
)
};
Ok(Self {
capture: Some(matches!(
item.router_data.request.capture_method,
Some(common_enums::CaptureMethod::Automatic) | None
)),
payment_solution: solution.map(String::from),
action_list,
action_token_types,
authorization_options,
capture_options: None,
commerce_indicator,
})
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "try_from",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-4165971609938476048 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/cybersource/transformers.rs
// Function: from
{
match item {
CybersourceRefundStatus::Succeeded | CybersourceRefundStatus::Transmitted => {
Self::Success
}
CybersourceRefundStatus::Cancelled
| CybersourceRefundStatus::Failed
| CybersourceRefundStatus::Voided => Self::Failure,
CybersourceRefundStatus::Pending => Self::Pending,
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "from",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-8019715245686394547 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/cybersource/transformers.rs
// Function: get_authentication_data_for_check_enrollment_response
{
let trans_status = response
.validate_response
.pares_status
.map(common_enums::TransactionStatus::from);
// CAVV is populated from UCAF data if available(for mastercard), else from CAVV field
let cavv = response
.validate_response
.ucaf_authentication_data
.or(response.validate_response.cavv);
let eci = response.validate_response.ecommerce_indicator;
let ucaf_collection_indicator = response.validate_response.ucaf_collection_indicator.clone();
let ds_trans_id = response
.validate_response
.directory_server_transaction_id
.map(|id| id.expose());
router_request_types::AuthenticationData {
ucaf_collection_indicator,
eci,
cavv,
threeds_server_transaction_id: response.validate_response.three_d_s_server_transaction_id,
message_version: response.validate_response.specification_version,
trans_status,
ds_trans_id,
acs_transaction_id: response.validate_response.acs_transaction_id,
transaction_id: response.validate_response.xid,
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_authentication_data_for_check_enrollment_response",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_305558305954841632 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/cybersource/transformers.rs
// Function: get_authentication_data_for_validation_response
{
let trans_status = response
.validate_response
.pares_status
.map(common_enums::TransactionStatus::from);
// CAVV is populated from UCAF data if available(for mastercard), else from CAVV field
let cavv = response
.validate_response
.ucaf_authentication_data
.or(response.validate_response.cavv);
let eci = response.validate_response.indicator;
let ucaf_collection_indicator = response.validate_response.ucaf_collection_indicator.clone();
let ds_trans_id = response
.validate_response
.directory_server_transaction_id
.map(|id| id.expose());
router_request_types::AuthenticationData {
ucaf_collection_indicator,
eci,
cavv,
threeds_server_transaction_id: response.validate_response.three_d_s_server_transaction_id,
message_version: response.validate_response.specification_version,
trans_status,
ds_trans_id,
acs_transaction_id: response.validate_response.acs_transaction_id,
transaction_id: response.validate_response.xid,
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_authentication_data_for_validation_response",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_7498401018909472574 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/cybersource/transformers.rs
// Function: truncate_string
{
let exposed = state.clone().expose();
let truncated = exposed.get(..max_len).unwrap_or(&exposed);
Secret::new(truncated.to_string())
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "truncate_string",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_8046806024228547471 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/cybersource/transformers.rs
// Function: build_bill_to
{
let default_address = BillTo {
first_name: None,
last_name: None,
address1: None,
locality: None,
administrative_area: None,
postal_code: None,
country: None,
email: email.clone(),
};
Ok(address_details
.and_then(|addr| {
addr.address.as_ref().map(|addr| BillTo {
first_name: addr.first_name.remove_new_line(),
last_name: addr.last_name.remove_new_line(),
address1: addr.line1.remove_new_line(),
locality: addr.city.remove_new_line(),
administrative_area: addr.to_state_code_as_optional().unwrap_or_else(|_| {
addr.state
.remove_new_line()
.as_ref()
.map(|state| truncate_string(state, 20)) //NOTE: Cybersource connector throws error if billing state exceeds 20 characters, so truncation is done to avoid payment failure
}),
postal_code: addr.zip.remove_new_line(),
country: addr.country,
email,
})
})
.unwrap_or(default_address))
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "build_bill_to",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-8939643827257498663 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/cybersource/transformers.rs
// Function: convert_metadata_to_merchant_defined_info
{
let hashmap: std::collections::BTreeMap<String, Value> =
serde_json::from_str(&metadata.to_string()).unwrap_or(std::collections::BTreeMap::new());
let mut vector = Vec::new();
let mut iter = 1;
for (key, value) in hashmap {
vector.push(MerchantDefinedInformation {
key: iter,
value: format!("{key}={value}"),
});
iter += 1;
}
vector
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "convert_metadata_to_merchant_defined_info",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-8248328403727091815 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/cybersource/transformers.rs
// Function: get_samsung_pay_payment_information
{
let samsung_pay_fluid_data_value =
get_samsung_pay_fluid_data_value(&samsung_pay_data.payment_credential.token_data)?;
let samsung_pay_fluid_data_str = serde_json::to_string(&samsung_pay_fluid_data_value)
.change_context(errors::ConnectorError::RequestEncodingFailed)
.attach_printable("Failed to serialize samsung pay fluid data")?;
let payment_information =
PaymentInformation::SamsungPay(Box::new(SamsungPayPaymentInformation {
fluid_data: FluidData {
value: Secret::new(BASE64_ENGINE.encode(samsung_pay_fluid_data_str)),
descriptor: Some(BASE64_ENGINE.encode(FLUID_DATA_DESCRIPTOR_FOR_SAMSUNG_PAY)),
},
tokenized_card: SamsungPayTokenizedCard {
transaction_type: TransactionType::InApp,
},
}));
Ok(payment_information)
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_samsung_pay_payment_information",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_5532048770562631172 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/cybersource/transformers.rs
// Function: get_samsung_pay_fluid_data_value
{
let samsung_pay_header = jwt::decode_header(samsung_pay_token_data.data.clone().peek())
.change_context(errors::ConnectorError::RequestEncodingFailed)
.attach_printable("Failed to decode samsung pay header")?;
let samsung_pay_kid_optional = samsung_pay_header.kid;
let samsung_pay_fluid_data_value = SamsungPayFluidDataValue {
public_key_hash: Secret::new(
samsung_pay_kid_optional
.get_required_value("samsung pay public_key_hash")
.change_context(errors::ConnectorError::RequestEncodingFailed)?
.to_string(),
),
version: samsung_pay_token_data.version.clone(),
data: Secret::new(BASE64_ENGINE.encode(samsung_pay_token_data.data.peek())),
};
Ok(samsung_pay_fluid_data_value)
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_samsung_pay_fluid_data_value",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_8082865412243660934 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/cybersource/transformers.rs
// Function: map_cybersource_attempt_status
{
match status {
CybersourcePaymentStatus::Authorized => {
if capture {
// Because Cybersource will return Payment Status as Authorized even in AutoCapture Payment
common_enums::AttemptStatus::Charged
} else {
common_enums::AttemptStatus::Authorized
}
}
CybersourcePaymentStatus::Succeeded | CybersourcePaymentStatus::Transmitted => {
common_enums::AttemptStatus::Charged
}
CybersourcePaymentStatus::Voided
| CybersourcePaymentStatus::Reversed
| CybersourcePaymentStatus::Cancelled => common_enums::AttemptStatus::Voided,
CybersourcePaymentStatus::Failed
| CybersourcePaymentStatus::Declined
| CybersourcePaymentStatus::AuthorizedRiskDeclined
| CybersourcePaymentStatus::Rejected
| CybersourcePaymentStatus::InvalidRequest
| CybersourcePaymentStatus::ServerError => common_enums::AttemptStatus::Failure,
CybersourcePaymentStatus::PendingAuthentication => {
common_enums::AttemptStatus::AuthenticationPending
}
CybersourcePaymentStatus::PendingReview
| CybersourcePaymentStatus::StatusNotReceived
| CybersourcePaymentStatus::Challenge
| CybersourcePaymentStatus::Accepted
| CybersourcePaymentStatus::Pending
| CybersourcePaymentStatus::AuthorizedPendingReview => common_enums::AttemptStatus::Pending,
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "map_cybersource_attempt_status",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-4136628398086485022 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/cybersource/transformers.rs
// Function: get_error_response_if_failure
{
if domain_types::utils::is_payment_failure(status) {
Some(get_error_response(
&info_response.error_information,
&info_response.processor_information,
&info_response.risk_information,
Some(status),
http_code,
info_response.id.clone(),
))
} else {
None
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_error_response_if_failure",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-2599135435502679244 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/cybersource/transformers.rs
// Function: get_payment_response
{
let error_response = get_error_response_if_failure((info_response, status, http_code));
match error_response {
Some(error) => Err(Box::new(error)),
None => {
let incremental_authorization_allowed =
Some(status == common_enums::AttemptStatus::Authorized);
let mandate_reference =
info_response
.token_information
.clone()
.map(|token_info| MandateReference {
connector_mandate_id: token_info
.payment_instrument
.map(|payment_instrument| payment_instrument.id.expose()),
payment_method_id: None,
});
Ok(PaymentsResponseData::TransactionResponse {
resource_id: ResponseId::ConnectorTransactionId(info_response.id.clone()),
redirection_data: None,
mandate_reference: mandate_reference.map(Box::new),
connector_metadata: None,
network_txn_id: info_response.processor_information.as_ref().and_then(
|processor_information| processor_information.network_transaction_id.clone(),
),
connector_response_reference_id: Some(
info_response
.client_reference_information
.clone()
.and_then(|client_reference_information| client_reference_information.code)
.unwrap_or(info_response.id.clone()),
),
incremental_authorization_allowed,
status_code: http_code,
})
}
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_payment_response",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-1078727645221439739 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/cybersource/transformers.rs
// Function: get_error_response
{
let avs_message = risk_information
.clone()
.map(|client_risk_information| {
client_risk_information.rules.map(|rules| {
rules
.iter()
.map(|risk_info| {
risk_info.name.clone().map_or("".to_string(), |name| {
format!(" , {}", name.clone().expose())
})
})
.collect::<Vec<String>>()
.join("")
})
})
.unwrap_or(Some("".to_string()));
let detailed_error_info = error_data.as_ref().and_then(|error_data| {
error_data.details.as_ref().map(|details| {
details
.iter()
.map(|detail| format!("{} : {}", detail.field, detail.reason))
.collect::<Vec<_>>()
.join(", ")
})
});
let network_decline_code = processor_information
.as_ref()
.and_then(|info| info.response_code.clone());
let network_advice_code = processor_information.as_ref().and_then(|info| {
info.merchant_advice
.as_ref()
.and_then(|merchant_advice| merchant_advice.code_raw.clone())
});
let reason = get_error_reason(
error_data
.as_ref()
.and_then(|error_info| error_info.message.clone()),
detailed_error_info,
avs_message,
);
let error_message = error_data
.as_ref()
.and_then(|error_info| error_info.reason.clone());
ErrorResponse {
code: error_message
.clone()
.unwrap_or_else(|| NO_ERROR_CODE.to_string()),
message: error_message.unwrap_or_else(|| NO_ERROR_MESSAGE.to_string()),
reason,
status_code,
attempt_status,
connector_transaction_id: Some(transaction_id),
network_advice_code,
network_decline_code,
network_error_message: None,
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_error_response",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-439592443807537185 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/cybersource/transformers.rs
// Function: get_error_reason
{
match (error_info, detailed_error_info, avs_error_info) {
(Some(message), Some(details), Some(avs_message)) => Some(format!(
"{message}, detailed_error_information: {details}, avs_message: {avs_message}",
)),
(Some(message), Some(details), None) => {
Some(format!("{message}, detailed_error_information: {details}"))
}
(Some(message), None, Some(avs_message)) => {
Some(format!("{message}, avs_message: {avs_message}"))
}
(None, Some(details), Some(avs_message)) => {
Some(format!("{details}, avs_message: {avs_message}"))
}
(Some(message), None, None) => Some(message),
(None, Some(details), None) => Some(details),
(None, None, Some(avs_message)) => Some(avs_message),
(None, None, None) => None,
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_error_reason",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_7012713584769309075 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/cybersource/transformers.rs
// Function: get_cybersource_card_type
{
match card_network {
common_enums::CardNetwork::Visa => Some("001"),
common_enums::CardNetwork::Mastercard => Some("002"),
common_enums::CardNetwork::AmericanExpress => Some("003"),
common_enums::CardNetwork::JCB => Some("007"),
common_enums::CardNetwork::DinersClub => Some("005"),
common_enums::CardNetwork::Discover => Some("004"),
common_enums::CardNetwork::CartesBancaires => Some("036"),
common_enums::CardNetwork::UnionPay => Some("062"),
//"042" is the type code for Masetro Cards(International). For Maestro Cards(UK-Domestic) the mapping should be "024"
common_enums::CardNetwork::Maestro => Some("042"),
common_enums::CardNetwork::Interac
| common_enums::CardNetwork::RuPay
| common_enums::CardNetwork::Star
| common_enums::CardNetwork::Accel
| common_enums::CardNetwork::Pulse
| common_enums::CardNetwork::Nyce => None,
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_cybersource_card_type",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-445441321632269646 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/cryptopay/transformers.rs
// Function: try_from
{
let status = common_enums::AttemptStatus::from(notif.data.status.clone());
if is_payment_failure(status) {
Ok(Self {
error_code: Some(
notif
.data
.name
.clone()
.unwrap_or(consts::NO_ERROR_CODE.to_string()),
),
error_message: Some(
notif
.data
.status_context
.clone()
.unwrap_or(consts::NO_ERROR_MESSAGE.to_string()),
),
error_reason: notif.data.status_context.clone(),
status_code: 200,
status: common_enums::AttemptStatus::Unknown,
resource_id: Some(ResponseId::ConnectorTransactionId(notif.data.id.clone())),
connector_response_reference_id: None,
mandate_reference: None,
raw_connector_response: None,
response_headers: None,
transformation_status: common_enums::WebhookTransformationStatus::Complete,
minor_amount_captured: None,
amount_captured: None,
network_txn_id: None,
})
} else {
let amount_captured_in_minor_units =
match (notif.data.price_amount, notif.data.price_currency) {
(Some(amount), Some(currency)) => {
Some(CryptopayAmountConvertor::convert_back(amount, currency)?)
}
_ => None,
};
match (amount_captured_in_minor_units, status) {
(Some(minor_amount), common_enums::AttemptStatus::Charged) => {
let amount_captured = Some(minor_amount.get_amount_as_i64());
Ok(Self {
amount_captured,
minor_amount_captured: amount_captured_in_minor_units,
status,
resource_id: Some(ResponseId::ConnectorTransactionId(
notif.data.id.clone(),
)),
error_reason: None,
mandate_reference: None,
status_code: 200,
connector_response_reference_id: notif
.data
.custom_id
.or(Some(notif.data.id)),
error_code: None,
error_message: None,
raw_connector_response: None,
response_headers: None,
network_txn_id: None,
transformation_status: common_enums::WebhookTransformationStatus::Complete,
})
}
_ => Ok(Self {
status,
resource_id: Some(ResponseId::ConnectorTransactionId(notif.data.id.clone())),
mandate_reference: None,
status_code: 200,
connector_response_reference_id: notif.data.custom_id.or(Some(notif.data.id)),
error_code: None,
error_message: None,
raw_connector_response: None,
response_headers: None,
minor_amount_captured: None,
amount_captured: None,
error_reason: None,
network_txn_id: None,
transformation_status: common_enums::WebhookTransformationStatus::Complete,
}),
}
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "try_from",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-5655207447427497326 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/cryptopay/transformers.rs
// Function: from
{
match item {
CryptopayPaymentStatus::New => Self::AuthenticationPending,
CryptopayPaymentStatus::Completed => Self::Charged,
CryptopayPaymentStatus::Cancelled => Self::Failure,
CryptopayPaymentStatus::Unresolved | CryptopayPaymentStatus::Refunded => {
Self::Unresolved
} //mapped refunded to Unresolved because refund api is not available, also merchant has done the action on the connector dashboard.
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "from",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_6584227525461909224 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/razorpayv2/test.rs
// Function: test_upi_flow_determination
{
// Add tests for UPI flow determination logic
// TODO: Implement comprehensive tests
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_upi_flow_determination",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_1558662536331175589 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/razorpayv2/test.rs
// Function: test_create_order_request_building
{
// Add tests for create order request building
// TODO: Implement comprehensive tests
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_create_order_request_building",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_7335008701231297933 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/razorpayv2/test.rs
// Function: test_payments_request_building
{
// Add tests for payments request building
// TODO: Implement comprehensive tests
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_payments_request_building",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_1676547017282257746 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/razorpayv2/transformers.rs
// Function: generate_authorization_header
{
match self {
RazorpayV2AuthType::AuthToken(token) => format!("Bearer {}", token.peek()),
RazorpayV2AuthType::ApiKeySecret {
api_key,
api_secret,
} => {
let credentials = format!("{}:{}", api_key.peek(), api_secret.peek());
let encoded = STANDARD.encode(credentials);
format!("Basic {encoded}")
}
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "generate_authorization_header",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-4026817227612703553 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/razorpayv2/transformers.rs
// Function: try_from
{
let amount_in_minor_units = item.amount.get_amount_as_i64();
Ok(Self {
amount: amount_in_minor_units,
})
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "try_from",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_593002213147923887 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/razorpayv2/transformers.rs
// Function: get_psync_razorpay_payment_status
{
match razorpay_status {
RazorpayStatus::Created => AttemptStatus::Pending,
RazorpayStatus::Authorized => AttemptStatus::Authorized,
RazorpayStatus::Captured => AttemptStatus::Charged,
RazorpayStatus::Refunded => AttemptStatus::AutoRefunded,
RazorpayStatus::Failed => AttemptStatus::Failure,
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_psync_razorpay_payment_status",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-2965787975485232033 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/razorpayv2/transformers.rs
// Function: foreign_try_from
{
let payments_response_data = PaymentsResponseData::TransactionResponse {
resource_id: ResponseId::ConnectorTransactionId(response.id),
redirection_data: None,
connector_metadata: None,
mandate_reference: None,
network_txn_id: None,
connector_response_reference_id: data.resource_common_data.reference_id.clone(),
incremental_authorization_allowed: None,
status_code: _status_code,
};
Ok(RouterDataV2 {
response: Ok(payments_response_data),
resource_common_data: PaymentFlowData {
status: AttemptStatus::AuthenticationPending,
..data.resource_common_data
},
..data
})
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "foreign_try_from",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-1285128844360666749 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/trustpay/transformers.rs
// Function: try_from
{
match (item.response.access_token, item.response.expires_in) {
(Some(access_token), Some(expires_in)) => Ok(Self {
response: Ok(AccessTokenResponseData {
access_token: access_token.expose(),
expires_in: Some(expires_in),
token_type: Some(item.router_data.request.grant_type.clone()),
}),
..item.router_data
}),
_ => Ok(Self {
response: Err(ErrorResponse {
code: item.response.result_info.result_code.to_string(),
// message vary for the same code, so relying on code alone as it is unique
message: item.response.result_info.result_code.to_string(),
reason: item.response.result_info.additional_info,
status_code: item.http_code,
attempt_status: None,
connector_transaction_id: None,
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
}),
..item.router_data
}),
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "try_from",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_7812994628977182480 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/trustpay/transformers.rs
// Function: error_message
{
match self {
Self::EmptyCvvNotAllowed => "Empty CVV for VISA, MASTER not allowed",
Self::SessionRejected => "Referenced session is rejected (no action possible)",
Self::UserAuthenticationFailed => "User authentication failed",
Self::RiskManagementTimeout => "Risk management transaction timeout",
Self::PaResValidationFailed => "PARes validation failed - problem with signature",
Self::ThreeDSecureSystemError => "Transaction rejected because of technical error in 3DSecure system",
Self::DirectoryServerError => "Communication error to VISA/Mastercard Directory Server",
Self::ThreeDSystemError => "Technical error in 3D system",
Self::AuthenticationInvalidFormat => "Authentication failed due to invalid message format",
Self::AuthenticationSuspectedFraud => "Authentication failed due to suspected fraud",
Self::InvalidInputData => "Invalid input data",
Self::AmountOutsideBoundaries => "Amount is outside allowed ticket size boundaries",
Self::InvalidOrMissingParameter => "Invalid or missing parameter",
Self::AdditionalAuthRequired => "Transaction declined (additional customer authentication required)",
Self::CardNotEnrolledIn3DS => "Card not enrolled in 3DS",
Self::AuthenticationError => "Authentication error",
Self::TransactionDeclinedAuth => "Transaction declined (auth. declined)",
Self::InvalidTransaction1 => "Invalid transaction",
Self::InvalidTransaction2 => "Invalid transaction",
Self::NoDescription => "No description available.",
Self::CannotRefund => "Cannot refund (refund volume exceeded or tx reversed or invalid workflow)",
Self::TooManyTransactions => "Referenced session contains too many transactions",
Self::TestAccountsNotAllowed => "Test accounts not allowed in production",
Self::DeclinedUnknownReason => "Transaction declined for unknown reason",
Self::DeclinedInvalidCard => "Transaction declined (invalid card)",
Self::DeclinedByAuthSystem => "Transaction declined by authorization system",
Self::DeclinedInvalidCvv => "Transaction declined (invalid CVV)",
Self::DeclinedExceedsCredit => "Transaction declined (amount exceeds credit)",
Self::DeclinedWrongExpiry => "Transaction declined (wrong expiry date)",
Self::DeclinedSuspectingManipulation => "transaction declined (suspecting manipulation)",
Self::DeclinedCardBlocked => "transaction declined (card blocked)",
Self::DeclinedLimitExceeded => "Transaction declined (limit exceeded)",
Self::DeclinedFrequencyExceeded => "Transaction declined (maximum transaction frequency exceeded)",
Self::DeclinedCardLost => "Transaction declined (card lost)",
Self::DeclinedRestrictedCard => "Transaction declined (restricted card)",
Self::DeclinedNotPermitted => "Transaction declined (transaction not permitted)",
Self::DeclinedPickUpCard => "transaction declined (pick up card)",
Self::DeclinedAccountBlocked => "Transaction declined (account blocked)",
Self::DeclinedInvalidConfig => "Transaction declined (invalid configuration data)",
Self::AccountClosed => "Account Closed",
Self::InsufficientFunds => "Insufficient Funds",
Self::RejectedByThrottling => "Rejected by throttling",
Self::CountryBlacklisted => "Country blacklisted",
Self::BinBlacklisted => "Bin blacklisted",
Self::SessionBeingProcessed => "Transaction for the same session is currently being processed, please try again later",
Self::CommunicationError => "Unexpected communication error with connector/acquirer",
Self::TimeoutUncertainResult => "Timeout, uncertain result",
Self::Unknown => "",
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "error_message",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_1583704845102738579 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/trustpay/transformers.rs
// Function: from
{
match item {
TrustpayBankRedirectPaymentStatus::Paid => Self::Success,
TrustpayBankRedirectPaymentStatus::Rejected => Self::Failure,
_ => Self::Pending,
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "from",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-5912870118739466683 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/trustpay/transformers.rs
// Function: is_payment_failed
{
let status_code = TrustpayPaymentStatusCode::from(payment_status);
(status_code.is_failure(), status_code.error_message())
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "is_payment_failed",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_6622341884730005451 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/trustpay/transformers.rs
// Function: is_payment_successful
{
match payment_status {
"000.400.100" => Ok(true),
_ => {
let allowed_prefixes = [
"000.000.",
"000.100.1",
"000.3",
"000.6",
"000.400.01",
"000.400.02",
"000.400.04",
"000.400.05",
"000.400.06",
"000.400.07",
"000.400.08",
"000.400.09",
];
let is_valid = allowed_prefixes
.iter()
.any(|&prefix| payment_status.starts_with(prefix));
Ok(is_valid)
}
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "is_payment_successful",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_2952569615443560748 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/trustpay/transformers.rs
// Function: get_pending_status_based_on_redirect_url
{
match redirect_url {
Some(_url) => enums::AttemptStatus::AuthenticationPending,
None => enums::AttemptStatus::Pending,
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_pending_status_based_on_redirect_url",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-5915264256727995919 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/trustpay/transformers.rs
// Function: get_transaction_status
{
// We don't get payment_status only in case, when the user doesn't complete the authentication step.
// If we receive status, then return the proper status based on the connector response
if let Some(payment_status) = payment_status {
let (is_failed, failure_message) = is_payment_failed(&payment_status);
if is_failed {
Ok((
enums::AttemptStatus::Failure,
Some(failure_message.to_string()),
))
} else if is_payment_successful(&payment_status)? {
Ok((enums::AttemptStatus::Charged, None))
} else {
let pending_status = get_pending_status_based_on_redirect_url(redirect_url);
Ok((pending_status, None))
}
} else {
Ok((enums::AttemptStatus::AuthenticationPending, None))
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_transaction_status",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_1583055968923952888 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/trustpay/transformers.rs
// Function: handle_cards_response
{
let (status, message) = get_transaction_status(
response.payment_status.to_owned(),
response.redirect_url.to_owned(),
)?;
let form_fields = response.redirect_params.unwrap_or_default();
let redirection_data = response.redirect_url.map(|url| RedirectForm::Form {
endpoint: url.to_string(),
method: Method::Post,
form_fields,
});
let error = if message.is_some() {
Some(ErrorResponse {
code: response
.payment_status
.unwrap_or_else(|| NO_ERROR_CODE.to_string()),
message: message
.clone()
.unwrap_or_else(|| NO_ERROR_MESSAGE.to_string()),
reason: message,
status_code,
attempt_status: None,
connector_transaction_id: Some(response.instance_id.clone()),
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
})
} else {
None
};
let payment_response_data = PaymentsResponseData::TransactionResponse {
resource_id: ResponseId::ConnectorTransactionId(response.instance_id.clone()),
redirection_data: redirection_data.map(Box::new),
mandate_reference: None,
connector_metadata: None,
network_txn_id: None,
connector_response_reference_id: None,
incremental_authorization_allowed: None,
status_code,
};
Ok((status, error, payment_response_data))
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "handle_cards_response",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-3517347824656025567 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/trustpay/transformers.rs
// Function: handle_bank_redirects_response
{
let status = enums::AttemptStatus::AuthenticationPending;
let error = None;
let payment_response_data = PaymentsResponseData::TransactionResponse {
resource_id: ResponseId::ConnectorTransactionId(response.payment_request_id.to_string()),
redirection_data: Some(Box::new(RedirectForm::from((
response.gateway_url,
Method::Get,
)))),
mandate_reference: None,
connector_metadata: None,
network_txn_id: None,
connector_response_reference_id: None,
incremental_authorization_allowed: None,
status_code,
};
Ok((status, error, payment_response_data))
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "handle_bank_redirects_response",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-4374479314201853124 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/trustpay/transformers.rs
// Function: handle_bank_redirects_error_response
{
let status = if matches!(response.payment_result_info.result_code, 1132014 | 1132005) {
previous_attempt_status
} else {
enums::AttemptStatus::AuthorizationFailed
};
let error = Some(ErrorResponse {
code: response.payment_result_info.result_code.to_string(),
// message vary for the same code, so relying on code alone as it is unique
message: response.payment_result_info.result_code.to_string(),
reason: response.payment_result_info.additional_info,
status_code,
attempt_status: Some(status),
connector_transaction_id: None,
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
});
let payment_response_data = PaymentsResponseData::TransactionResponse {
resource_id: ResponseId::NoResponseId,
redirection_data: None,
mandate_reference: None,
connector_metadata: None,
network_txn_id: None,
connector_response_reference_id: None,
incremental_authorization_allowed: None,
status_code,
};
Ok((status, error, payment_response_data))
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "handle_bank_redirects_error_response",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-1347416815255535494 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/trustpay/transformers.rs
// Function: handle_bank_redirects_sync_response
{
let status = enums::AttemptStatus::from(response.payment_information.status);
let error = if domain_types::utils::is_payment_failure(status) {
let reason_info = response
.payment_information
.status_reason_information
.unwrap_or_default();
Some(ErrorResponse {
code: reason_info
.reason
.code
.clone()
.unwrap_or(NO_ERROR_CODE.to_string()),
// message vary for the same code, so relying on code alone as it is unique
message: reason_info
.reason
.code
.unwrap_or(NO_ERROR_MESSAGE.to_string()),
reason: reason_info.reason.reject_reason,
status_code,
attempt_status: None,
connector_transaction_id: Some(
response
.payment_information
.references
.payment_request_id
.clone(),
),
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
})
} else {
None
};
let payment_response_data = PaymentsResponseData::TransactionResponse {
resource_id: ResponseId::ConnectorTransactionId(
response
.payment_information
.references
.payment_request_id
.clone(),
),
redirection_data: None,
mandate_reference: None,
connector_metadata: None,
network_txn_id: None,
connector_response_reference_id: None,
incremental_authorization_allowed: None,
status_code,
};
Ok((status, error, payment_response_data))
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "handle_bank_redirects_sync_response",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-2715685907814403815 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/trustpay/transformers.rs
// Function: handle_webhook_response
{
let status = enums::AttemptStatus::try_from(payment_information.status)?;
let error = if domain_types::utils::is_payment_failure(status) {
let reason_info = payment_information
.status_reason_information
.unwrap_or_default();
Some(ErrorResponse {
code: reason_info
.reason
.code
.clone()
.unwrap_or(NO_ERROR_CODE.to_string()),
// message vary for the same code, so relying on code alone as it is unique
message: reason_info
.reason
.code
.unwrap_or(NO_ERROR_MESSAGE.to_string()),
reason: reason_info.reason.reject_reason,
status_code,
attempt_status: None,
connector_transaction_id: payment_information.references.payment_request_id.clone(),
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
})
} else {
None
};
let payment_response_data = PaymentsResponseData::TransactionResponse {
resource_id: ResponseId::NoResponseId,
redirection_data: None,
mandate_reference: None,
connector_metadata: None,
network_txn_id: None,
connector_response_reference_id: None,
incremental_authorization_allowed: None,
status_code,
};
Ok((status, error, payment_response_data))
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "handle_webhook_response",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_1129761068507008509 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/trustpay/transformers.rs
// Function: get_trustpay_response
{
match response {
TrustpayPaymentsResponse::CardsPayments(response) => {
handle_cards_response(*response, status_code)
}
TrustpayPaymentsResponse::BankRedirectPayments(response) => {
handle_bank_redirects_response(*response, status_code)
}
TrustpayPaymentsResponse::BankRedirectSync(response) => {
handle_bank_redirects_sync_response(*response, status_code)
}
TrustpayPaymentsResponse::BankRedirectError(response) => {
handle_bank_redirects_error_response(*response, status_code, previous_attempt_status)
}
TrustpayPaymentsResponse::WebhookResponse(response) => {
handle_webhook_response(*response, status_code)
}
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_trustpay_response",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-6845142066205286710 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/xendit/transformers.rs
// Function: try_from
{
let ResponseRouterData {
response,
router_data,
http_code,
} = item;
Ok(Self {
response: Ok(RefundsResponseData {
connector_refund_id: response.id,
refund_status: common_enums::RefundStatus::from(response.status),
status_code: http_code,
}),
..router_data
})
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "try_from",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-7764359483446056564 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/xendit/transformers.rs
// Function: is_auto_capture
{
match data.capture_method {
Some(common_enums::CaptureMethod::Automatic) | None => Ok(true),
Some(common_enums::CaptureMethod::Manual) => Ok(false),
Some(_) => Err(ConnectorError::CaptureMethodNotSupported),
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "is_auto_capture",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_2957072239002240268 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/xendit/transformers.rs
// Function: is_auto_capture_psync
{
match data.capture_method {
Some(common_enums::CaptureMethod::Automatic) | None => Ok(true),
Some(common_enums::CaptureMethod::Manual) => Ok(false),
Some(_) => Err(ConnectorError::CaptureMethodNotSupported),
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "is_auto_capture_psync",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_1220201645857116306 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/xendit/transformers.rs
// Function: map_payment_response_to_attempt_status
{
match response.status {
PaymentStatus::Failed => common_enums::AttemptStatus::Failure,
PaymentStatus::Succeeded | PaymentStatus::Verified => {
if is_auto_capture {
common_enums::AttemptStatus::Charged
} else {
common_enums::AttemptStatus::Authorized
}
}
PaymentStatus::Pending => common_enums::AttemptStatus::Pending,
PaymentStatus::RequiresAction => common_enums::AttemptStatus::AuthenticationPending,
PaymentStatus::AwaitingCapture => common_enums::AttemptStatus::Authorized,
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "map_payment_response_to_attempt_status",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_4328141175566158444 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/xendit/transformers.rs
// Function: from
{
match item {
RefundStatus::Succeeded => Self::Success,
RefundStatus::Failed | RefundStatus::Cancelled => Self::Failure,
RefundStatus::Pending | RefundStatus::RequiresAction => Self::Pending,
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "from",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-7080870094687339040 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/xendit/transformers.rs
// Function: is_mandate_payment
{
(item.setup_future_usage == Some(common_enums::enums::FutureUsage::OffSession))
|| item
.mandate_id
.as_ref()
.and_then(|mandate_ids| mandate_ids.mandate_reference_id.as_ref())
.is_some()
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "is_mandate_payment",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-5499501572199064837 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/volt/transformers.rs
// Function: try_from
{
Ok(Self {
response: Ok(RefundsResponseData {
connector_refund_id: item.response.id.to_string(),
refund_status: common_enums::RefundStatus::Pending, //We get Refund Status only by Webhooks
status_code: item.http_code,
}),
..item.router_data
})
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "try_from",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-4471542057309744522 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/volt/transformers.rs
// Function: get_attempt_status
{
match item {
VoltPaymentStatus::Received | VoltPaymentStatus::Settled => AttemptStatus::Charged,
VoltPaymentStatus::Completed | VoltPaymentStatus::DelayedAtBank => AttemptStatus::Pending,
VoltPaymentStatus::NewPayment
| VoltPaymentStatus::BankRedirect
| VoltPaymentStatus::AwaitingCheckoutAuthorisation => AttemptStatus::AuthenticationPending,
VoltPaymentStatus::RefusedByBank
| VoltPaymentStatus::RefusedByRisk
| VoltPaymentStatus::NotReceived
| VoltPaymentStatus::ErrorAtBank
| VoltPaymentStatus::CancelledByUser
| VoltPaymentStatus::AbandonedByUser
| VoltPaymentStatus::Failed => AttemptStatus::Failure,
VoltPaymentStatus::Unknown => current_status,
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_attempt_status",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-8121934653120202201 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/volt/transformers.rs
// Function: from
{
match status {
VoltWebhookBodyEventType::Payment(payment_data) => match payment_data.status {
VoltWebhookPaymentStatus::Received => Self::PaymentIntentSuccess,
VoltWebhookPaymentStatus::Failed | VoltWebhookPaymentStatus::NotReceived => {
Self::PaymentIntentFailure
}
VoltWebhookPaymentStatus::Completed | VoltWebhookPaymentStatus::Pending => {
Self::PaymentIntentProcessing
}
},
VoltWebhookBodyEventType::Refund(refund_data) => match refund_data.status {
VoltWebhookRefundsStatus::RefundConfirmed => Self::RefundSuccess,
VoltWebhookRefundsStatus::RefundFailed => Self::RefundFailure,
},
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "from",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_4840959861993344353 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/noon/transformers.rs
// Function: get_value_as_string
{
match value {
serde_json::Value::String(string) => string.to_owned(),
serde_json::Value::Null
| serde_json::Value::Bool(_)
| serde_json::Value::Number(_)
| serde_json::Value::Array(_)
| serde_json::Value::Object(_) => value.to_string(),
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_value_as_string",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_3000270290517726204 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/noon/transformers.rs
// Function: new
{
let metadata_as_string = metadata.to_string();
let hash_map: std::collections::BTreeMap<String, serde_json::Value> =
serde_json::from_str(&metadata_as_string).unwrap_or(std::collections::BTreeMap::new());
let inner = hash_map
.into_iter()
.enumerate()
.map(|(index, (hs_key, hs_value))| {
let noon_key = format!("{}", index + 1);
// to_string() function on serde_json::Value returns a string with "" quotes. Noon doesn't allow this. Hence get_value_as_string function
let noon_value = format!("{hs_key}={}", get_value_as_string(&hs_value));
(noon_key, Secret::new(noon_value))
})
.collect();
Self { inner }
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "new",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_4862076425151944515 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/noon/transformers.rs
// Function: try_from
{
let order = item.response.result.order;
let current_attempt_status = item.router_data.resource_common_data.status;
let status = get_payment_status((order.status, current_attempt_status));
let redirection_data = item.response.result.checkout_data.map(|redirection_data| {
Box::new(RedirectForm::Form {
endpoint: redirection_data.post_url.to_string(),
method: Method::Post,
form_fields: std::collections::HashMap::new(),
})
});
let mandate_reference = item.response.result.subscription.map(|subscription_data| {
Box::new(MandateReference {
connector_mandate_id: Some(subscription_data.identifier.expose()),
payment_method_id: None,
})
});
Ok(Self {
resource_common_data: PaymentFlowData {
status,
..item.router_data.resource_common_data
},
response: match order.error_message {
Some(error_message) => Err(ErrorResponse {
code: order.error_code.to_string(),
message: error_message.clone(),
reason: Some(error_message),
status_code: item.http_code,
attempt_status: Some(status),
connector_transaction_id: Some(order.id.to_string()),
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
}),
_ => {
let connector_response_reference_id =
order.reference.or(Some(order.id.to_string()));
Ok(PaymentsResponseData::TransactionResponse {
resource_id: ResponseId::ConnectorTransactionId(order.id.to_string()),
redirection_data,
mandate_reference,
connector_metadata: None,
network_txn_id: None,
connector_response_reference_id,
incremental_authorization_allowed: None,
status_code: item.http_code,
})
}
},
..item.router_data
})
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "try_from",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_6624040959457726474 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/noon/transformers.rs
// Function: get_payment_status
{
let (item, current_status) = data;
match item {
NoonPaymentStatus::Authorized => AttemptStatus::Authorized,
NoonPaymentStatus::Captured
| NoonPaymentStatus::PartiallyCaptured
| NoonPaymentStatus::PartiallyRefunded
| NoonPaymentStatus::Refunded => AttemptStatus::Charged,
NoonPaymentStatus::Reversed | NoonPaymentStatus::PartiallyReversed => AttemptStatus::Voided,
NoonPaymentStatus::Cancelled | NoonPaymentStatus::Expired => {
AttemptStatus::AuthenticationFailed
}
NoonPaymentStatus::ThreeDsEnrollInitiated | NoonPaymentStatus::ThreeDsEnrollChecked => {
AttemptStatus::AuthenticationPending
}
NoonPaymentStatus::ThreeDsResultVerified => AttemptStatus::AuthenticationSuccessful,
NoonPaymentStatus::Failed | NoonPaymentStatus::Rejected => AttemptStatus::Failure,
NoonPaymentStatus::Pending | NoonPaymentStatus::MarkedForReview => AttemptStatus::Pending,
NoonPaymentStatus::Initiated
| NoonPaymentStatus::PaymentInfoAdded
| NoonPaymentStatus::Authenticated => AttemptStatus::Started,
NoonPaymentStatus::Locked => current_status,
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_payment_status",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_253263964257174660 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/noon/transformers.rs
// Function: from
{
Self {
result: NoonPaymentsResponseResult {
order: NoonPaymentsOrderResponse {
status: value.order_status,
id: value.order_id,
//For successful payments Noon Always populates error_code as 0.
error_code: 0,
error_message: None,
reference: None,
},
checkout_data: None,
subscription: None,
},
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "from",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-8659267270991720171 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/placetopay/transformers.rs
// Function: try_from
{
Ok(Self {
response: Ok(RefundsResponseData {
connector_refund_id: item.response.internal_reference.to_string(),
refund_status: common_enums::RefundStatus::from(item.response.status.status),
status_code: item.http_code,
}),
..item.router_data
})
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "try_from",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-6218284339970308393 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/placetopay/transformers.rs
// Function: from
{
match item {
PlacetopayRefundStatus::Ok
| PlacetopayRefundStatus::Approved
| PlacetopayRefundStatus::Refunded => Self::Success,
PlacetopayRefundStatus::Failed
| PlacetopayRefundStatus::Rejected
| PlacetopayRefundStatus::Error => Self::Failure,
PlacetopayRefundStatus::Pending
| PlacetopayRefundStatus::PendingProcess
| PlacetopayRefundStatus::PendingValidation => Self::Pending,
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "from",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_3152717781405429979 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/razorpay/test.rs
// Function: test_build_request_valid
{
let email = Email::try_from("testuser@gmail.com".to_string()).unwrap();
let test_router_data = RouterDataV2 {
flow: std::marker::PhantomData,
resource_common_data: PaymentFlowData {
merchant_id: MerchantId::default(),
customer_id: None,
connector_customer: None,
payment_id: "IRRELEVANT_PAYMENT_ID".to_string(),
attempt_id: "IRRELEVANT_ATTEMPT_ID".to_string(),
status: AttemptStatus::Pending,
payment_method: PaymentMethod::Card,
description: None,
return_url: None,
address: PaymentAddress::new(
None,
Some(Address {
address: None,
phone: Some(PhoneDetails {
number: Some("1234567890".to_string().into()),
country_code: Some("+1".to_string()),
}),
email: Some(email.clone()),
}),
None,
None,
),
auth_type: AuthenticationType::NoThreeDs,
connector_meta_data: None,
amount_captured: None,
minor_amount_captured: None,
access_token: None,
session_token: None,
reference_id: Some("order_QMSVrXxHS9sBmu".to_string()),
payment_method_token: None,
preprocessing_id: None,
connector_api_version: None,
connector_request_reference_id: "ref_12345".to_string(),
test_mode: None,
connector_http_status_code: None,
external_latency: None,
raw_connector_response: None,
connectors: Connectors {
razorpay: ConnectorParams {
base_url: "https://api.razorpay.com/".to_string(),
dispute_base_url: None,
..Default::default()
},
..Default::default()
},
vault_headers: None,
connector_response_headers: None,
raw_connector_request: None,
minor_amount_capturable: None,
connector_response: None,
recurring_mandate_payment_data: None,
},
connector_auth_type: ConnectorAuthType::BodyKey {
api_key: "dummy_api_key".to_string().into(),
key1: "dummy_key1".to_string().into(),
},
request: PaymentsAuthorizeData {
authentication_data: None,
payment_method_data: PaymentMethodData::Card(Card {
card_number: RawCardNumber(
CardNumber::from_str("5123456789012346").unwrap(),
),
card_exp_month: "12".to_string().into(),
card_exp_year: "2026".to_string().into(),
card_cvc: "123".to_string().into(),
card_issuer: None,
card_network: None,
card_type: None,
card_issuing_country: None,
bank_code: None,
nick_name: None,
card_holder_name: Some("Test User".to_string().into()),
co_badged_card_data: None,
}),
amount: 1000,
order_tax_amount: None,
email: Some(email.clone()),
customer_name: None,
currency: Currency::USD,
confirm: true,
statement_descriptor_suffix: None,
statement_descriptor: None,
capture_method: None,
router_return_url: None,
webhook_url: None,
integrity_object: None,
complete_authorize_url: None,
mandate_id: None,
setup_future_usage: None,
off_session: None,
browser_info: Some(BrowserInformation {
color_depth: None,
java_enabled: Some(false),
java_script_enabled: None,
language: Some("en-US".to_string()),
screen_height: Some(1080),
screen_width: Some(1920),
time_zone: None,
ip_address: None,
accept_header: Some(
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
.to_string(),
),
user_agent: Some(
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)".to_string(),
),
referer: None,
os_type: None,
os_version: None,
device_model: None,
accept_language: None,
}),
order_category: None,
session_token: None,
enrolled_for_3ds: false,
related_transaction_id: None,
payment_experience: None,
payment_method_type: Some(PaymentMethodType::Credit),
customer_id: None,
request_incremental_authorization: false,
metadata: None,
minor_amount: MinorUnit::new(1000),
merchant_order_reference_id: None,
shipping_cost: None,
merchant_account_id: None,
merchant_config_currency: None,
all_keys_required: None,
access_token: None,
customer_acceptance: None,
split_payments: None,
request_extended_authorization: None,
setup_mandate_details: None,
enable_overcapture: None,
merchant_account_metadata: None,
},
response: Err(ErrorResponse {
code: "HE_00".to_string(),
message: "Something went wrong".to_string(),
reason: None,
status_code: 500,
attempt_status: None,
connector_transaction_id: None,
network_decline_code: None,
network_advice_code: None,
network_error_message: None,
}),
};
let connector: BoxedConnector<DefaultPCIHolder> = Box::new(Razorpay::new());
let result = connector.get_request_body(&test_router_data);
let request_content = result.unwrap();
let actual_json: Value = match request_content {
Some(RequestContent::Json(payload)) => {
to_value(&payload).expect("Failed to serialize payload to JSON")
}
_ => panic!("Expected JSON payload"),
};
let expected_json: Value = json!({
"amount": 1000,
"currency": "USD",
"contact": "1234567890",
"email": "testuser@gmail.com",
"order_id": "order_QMSVrXxHS9sBmu",
"method": "card",
"card": {
"number": "5123456789012346",
"expiry_month": "12",
"expiry_year": "2026",
"cvv": "123"
},
"authentication": {
"authentication_channel": "browser"
},
"browser": {
"java_enabled": false,
"language": "en-US",
"screen_height": 1080,
"screen_width": 1920
},
"ip": "127.0.0.1",
"referer": "https://example.com",
"user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)"
});
assert_eq!(actual_json, expected_json);
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_build_request_valid",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-6108357518927124253 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/razorpay/test.rs
// Function: test_build_request_missing
{
use common_enums::Currency;
use common_utils::{id_type::MerchantId, types::MinorUnit};
use domain_types::{
connector_types::PaymentCreateOrderData,
payment_address::PaymentAddress,
router_data::{ConnectorAuthType, ErrorResponse},
router_data_v2::RouterDataV2,
};
use crate::connectors::Razorpay;
let test_router_data = RouterDataV2 {
flow: std::marker::PhantomData,
resource_common_data: domain_types::connector_types::PaymentFlowData {
merchant_id: MerchantId::default(),
customer_id: None,
connector_customer: None,
payment_id: "".to_string(),
attempt_id: "".to_string(),
status: common_enums::AttemptStatus::Pending,
payment_method: common_enums::PaymentMethod::Card,
description: None,
return_url: None,
address: PaymentAddress::default(),
auth_type: common_enums::AuthenticationType::NoThreeDs,
connector_meta_data: None,
amount_captured: None,
minor_amount_captured: None,
access_token: None,
session_token: None,
reference_id: None,
payment_method_token: None,
preprocessing_id: None,
connector_api_version: None,
connector_request_reference_id: "".to_string(),
test_mode: None,
connector_http_status_code: None,
external_latency: None,
raw_connector_response: None,
connectors: Connectors {
razorpay: ConnectorParams {
base_url: "https://api.razorpay.com/".to_string(),
dispute_base_url: None,
..Default::default()
},
..Default::default()
},
vault_headers: None,
connector_response_headers: None,
raw_connector_request: None,
minor_amount_capturable: None,
connector_response: None,
recurring_mandate_payment_data: None,
},
connector_auth_type: ConnectorAuthType::BodyKey {
api_key: "dummy_api_key".to_string().into(),
key1: "dummy_key1".to_string().into(),
},
request: PaymentCreateOrderData {
amount: MinorUnit::new(0),
currency: Currency::default(),
integrity_object: None,
metadata: None,
webhook_url: None,
},
response: Err(ErrorResponse {
code: "HE_01".to_string(),
message: "Missing required fields".to_string(),
reason: None,
status_code: 400,
attempt_status: None,
connector_transaction_id: None,
network_decline_code: None,
network_advice_code: None,
network_error_message: None,
}),
};
let connector: BoxedConnector<DefaultPCIHolder> = Box::new(Razorpay::new());
let result = connector.get_request_body(&test_router_data);
let req = result.unwrap();
let actual_json: Value = match req {
Some(RequestContent::Json(payload)) => {
to_value(&payload).expect("Failed to serialize payload")
}
None => {
return;
}
Some(RequestContent::RawBytes(bytes)) => {
let json_str =
String::from_utf8(bytes).expect("Failed to convert bytes to string");
serde_json::from_str(&json_str).expect("Failed to parse bytes as JSON")
}
Some(RequestContent::FormUrlEncoded(form_data)) => {
to_value(&form_data).expect("Failed to serialize form data")
}
Some(other) => panic!("Unexpected RequestContent type: {other:?}"),
};
assert_eq!(actual_json["amount"], 0);
assert_eq!(actual_json["currency"], "USD");
let receipt_value = &actual_json["receipt"];
assert!(
receipt_value.is_string(),
"Expected receipt to be a string, got: {receipt_value:?}"
);
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_build_request_missing",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-4559112145041872844 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/razorpay/test.rs
// Function: test_build_request_invalid
{
use common_enums::{
AttemptStatus, AuthenticationType, Currency, PaymentMethod, PaymentMethodType,
};
use common_utils::{id_type::MerchantId, types::MinorUnit};
use domain_types::{
connector_types::{PaymentFlowData, PaymentsAuthorizeData},
payment_address::PaymentAddress,
payment_method_data::{Card, PaymentMethodData},
router_data::ErrorResponse,
router_data_v2::RouterDataV2,
types::{ConnectorParams, Connectors},
};
use crate::connectors::Razorpay;
let test_router_data = RouterDataV2 {
flow: std::marker::PhantomData,
resource_common_data: PaymentFlowData {
merchant_id: MerchantId::default(),
customer_id: None,
connector_customer: None,
payment_id: "invalid_payment_id".to_string(),
attempt_id: "invalid_attempt_id".to_string(),
status: AttemptStatus::Pending,
payment_method: PaymentMethod::Card,
description: None,
return_url: None,
address: PaymentAddress::new(None, None, None, None),
auth_type: AuthenticationType::NoThreeDs,
connector_meta_data: None,
amount_captured: None,
minor_amount_captured: None,
access_token: None,
session_token: None,
reference_id: Some("order_invalid".to_string()),
payment_method_token: None,
preprocessing_id: None,
connector_api_version: None,
connector_request_reference_id: "ref_invalid".to_string(),
test_mode: None,
connector_http_status_code: None,
external_latency: None,
raw_connector_response: None,
connectors: Connectors {
razorpay: ConnectorParams {
base_url: "https://api.razorpay.com/".to_string(),
dispute_base_url: None,
..Default::default()
},
..Default::default()
},
vault_headers: None,
connector_response_headers: None,
raw_connector_request: None,
minor_amount_capturable: None,
connector_response: None,
recurring_mandate_payment_data: None,
},
connector_auth_type: ConnectorAuthType::BodyKey {
api_key: "invalid_key".to_string().into(),
key1: "invalid_key1".to_string().into(),
},
request: PaymentsAuthorizeData {
authentication_data: None,
payment_method_data: PaymentMethodData::Card(Card {
card_number: Default::default(),
card_exp_month: "".to_string().into(),
card_exp_year: "".to_string().into(),
card_cvc: "".to_string().into(),
card_issuer: None,
card_network: None,
card_type: None,
card_issuing_country: None,
bank_code: None,
nick_name: None,
card_holder_name: Some("Test User".to_string().into()),
co_badged_card_data: None,
}),
amount: 1000,
order_tax_amount: None,
email: None,
customer_name: None,
currency: Currency::USD,
confirm: true,
statement_descriptor_suffix: None,
statement_descriptor: None,
capture_method: None,
router_return_url: None,
webhook_url: None,
complete_authorize_url: None,
mandate_id: None,
setup_future_usage: None,
off_session: None,
browser_info: None,
order_category: None,
session_token: None,
enrolled_for_3ds: false,
related_transaction_id: None,
payment_experience: None,
payment_method_type: Some(PaymentMethodType::Credit),
customer_id: None,
request_incremental_authorization: false,
metadata: None,
integrity_object: None,
minor_amount: MinorUnit::new(1000),
merchant_order_reference_id: None,
shipping_cost: None,
merchant_account_id: None,
merchant_config_currency: None,
all_keys_required: None,
access_token: None,
customer_acceptance: None,
split_payments: None,
request_extended_authorization: None,
setup_mandate_details: None,
enable_overcapture: None,
merchant_account_metadata: None,
},
response: Err(ErrorResponse {
code: "HE_INVALID".to_string(),
message: "Invalid request body".to_string(),
reason: None,
status_code: 422,
attempt_status: None,
connector_transaction_id: None,
network_decline_code: None,
network_advice_code: None,
network_error_message: None,
}),
};
let connector: BoxedConnector<DefaultPCIHolder> = Box::new(Razorpay::new());
let result = connector.get_request_body(&test_router_data);
assert!(
result.is_err(),
"Expected error for invalid request data, but got: {result:?}"
);
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_build_request_invalid",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-3871210758204669158 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/razorpay/test.rs
// Function: test_handle_response_v2_valid_authorize_response
{
use std::str::FromStr;
use common_enums::Currency;
use common_utils::{id_type::MerchantId, pii::Email, types::MinorUnit};
use domain_types::{
connector_types::PaymentFlowData,
payment_address::PaymentAddress,
router_data::{ConnectorAuthType, ErrorResponse},
router_data_v2::RouterDataV2,
types::{ConnectorParams, Connectors},
};
let connector: BoxedConnector<DefaultPCIHolder> = Box::new(Razorpay::new());
let email = Email::try_from("testuser@gmail.com".to_string()).unwrap();
let data = RouterDataV2 {
flow: std::marker::PhantomData,
resource_common_data: PaymentFlowData {
merchant_id: MerchantId::default(),
customer_id: None,
connector_customer: None,
payment_id: "IRRELEVANT_PAYMENT_ID".to_string(),
attempt_id: "IRRELEVANT_ATTEMPT_ID".to_string(),
status: AttemptStatus::Pending,
payment_method: PaymentMethod::Card,
description: None,
return_url: None,
address: PaymentAddress::new(
None,
Some(Address {
address: None,
phone: Some(PhoneDetails {
number: Some("1234567890".to_string().into()),
country_code: Some("+1".to_string()),
}),
email: Some(email.clone()),
}),
None,
None,
),
auth_type: AuthenticationType::NoThreeDs,
connector_meta_data: None,
amount_captured: None,
minor_amount_captured: None,
access_token: None,
session_token: None,
reference_id: Some("order_QMsUrrLPdwNxPG".to_string()),
payment_method_token: None,
preprocessing_id: None,
connector_api_version: None,
connector_request_reference_id: "ref_12345".to_string(),
test_mode: None,
connector_http_status_code: None,
external_latency: None,
raw_connector_response: None,
connectors: Connectors {
razorpay: ConnectorParams {
base_url: "https://api.razorpay.com/".to_string(),
dispute_base_url: None,
..Default::default()
},
..Default::default()
},
vault_headers: None,
connector_response_headers: None,
raw_connector_request: None,
minor_amount_capturable: None,
connector_response: None,
recurring_mandate_payment_data: None,
},
connector_auth_type: ConnectorAuthType::BodyKey {
api_key: "dummy_api_key".to_string().into(),
key1: "dummy_key1".to_string().into(),
},
request: PaymentsAuthorizeData {
authentication_data: None,
payment_method_data: PaymentMethodData::Card(Card {
card_number: RawCardNumber(
CardNumber::from_str("5123450000000008").unwrap(),
),
card_exp_month: "12".to_string().into(),
card_exp_year: "2025".to_string().into(),
card_cvc: "123".to_string().into(),
card_issuer: None,
card_network: None,
card_type: None,
card_issuing_country: None,
bank_code: None,
nick_name: None,
card_holder_name: Some("Test User".to_string().into()),
co_badged_card_data: None,
}),
amount: 1000,
order_tax_amount: None,
email: Some(email),
customer_name: None,
currency: Currency::USD,
confirm: true,
statement_descriptor_suffix: None,
statement_descriptor: None,
capture_method: None,
router_return_url: None,
webhook_url: None,
integrity_object: None,
complete_authorize_url: None,
mandate_id: None,
setup_future_usage: None,
off_session: None,
browser_info: Some(BrowserInformation {
color_depth: None,
java_enabled: Some(false),
java_script_enabled: None,
language: Some("en-US".to_string()),
screen_height: Some(1080),
screen_width: Some(1920),
time_zone: None,
ip_address: None,
accept_header: Some(
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
.to_string(),
),
user_agent: Some(
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)".to_string(),
),
referer: None,
os_type: None,
os_version: None,
device_model: None,
accept_language: None,
}),
order_category: None,
session_token: None,
enrolled_for_3ds: false,
related_transaction_id: None,
payment_experience: None,
payment_method_type: Some(common_enums::PaymentMethodType::Credit),
customer_id: None,
request_incremental_authorization: false,
metadata: None,
minor_amount: MinorUnit::new(1000),
merchant_order_reference_id: None,
shipping_cost: None,
merchant_account_id: None,
merchant_config_currency: None,
all_keys_required: None,
access_token: None,
customer_acceptance: None,
split_payments: None,
request_extended_authorization: None,
setup_mandate_details: None,
enable_overcapture: None,
merchant_account_metadata: None,
},
response: Err(ErrorResponse {
code: "HE_00".to_string(),
message: "Something went wrong".to_string(),
reason: None,
status_code: 500,
attempt_status: None,
connector_transaction_id: None,
network_decline_code: None,
network_advice_code: None,
network_error_message: None,
}),
};
let http_response = Response {
headers: None,
response: br#"{
"razorpay_payment_id":"pay_QMsUsXCDy9sX3b",
"next":[
{
"action":"redirect",
"url":"https://api.razorpay.com/v1/payments/QMsUsXCDy9sX3b/authenticate"
}
]
}"#
.to_vec()
.into(),
status_code: 200,
};
let result = connector
.handle_response_v2(&data, None, http_response)
.unwrap();
assert!(matches!(
result.resource_common_data.status,
AttemptStatus::AuthenticationPending
));
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_handle_response_v2_valid_authorize_response",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-8922597920826393306 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/razorpay/test.rs
// Function: test_handle_authorize_error_response
{
use domain_types::{
connector_flow::Authorize,
connector_types::{PaymentFlowData, PaymentsAuthorizeData, PaymentsResponseData},
};
let http_response = Response {
headers: None,
response: br#"{
"error": {
"code": "BAD_REQUEST_ERROR",
"description": "The id provided does not exist",
"source": "internal",
"step": "payment_initiation",
"reason": "input_validation_failed",
"metadata": {}
}
}"#
.to_vec()
.into(),
status_code: 400,
};
let connector: BoxedConnector<DefaultPCIHolder> = Box::new(Razorpay::new());
let result =
<dyn ConnectorServiceTrait<DefaultPCIHolder> + Sync as ConnectorIntegrationV2<
Authorize,
PaymentFlowData,
PaymentsAuthorizeData<DefaultPCIHolder>,
PaymentsResponseData,
>>::get_error_response_v2(&**connector, http_response, None)
.unwrap();
let actual_json = to_value(&result).unwrap();
let expected_json = json!({
"code": "BAD_REQUEST_ERROR",
"message": "The id provided does not exist",
"reason": "input_validation_failed",
"status_code": 400,
"attempt_status": "failure",
"connector_transaction_id": null,
"network_advice_code": null,
"network_decline_code": null,
"network_error_message": null
});
assert_eq!(actual_json, expected_json);
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_handle_authorize_error_response",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_901397538912186964 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/razorpay/test.rs
// Function: test_handle_authorize_missing_required_fields
{
use domain_types::{
connector_flow::Authorize,
connector_types::{PaymentFlowData, PaymentsAuthorizeData, PaymentsResponseData},
};
let http_response = Response {
headers: None,
response: br#"{
"error": {
"description": "Missing required fields",
"step": "payment_initiation",
"reason": "input_validation_failed"
}
}"#
.to_vec()
.into(),
status_code: 400,
};
let connector: BoxedConnector<DefaultPCIHolder> = Box::new(Razorpay::new());
let result =
<dyn ConnectorServiceTrait<DefaultPCIHolder> + Sync as ConnectorIntegrationV2<
Authorize,
PaymentFlowData,
PaymentsAuthorizeData<DefaultPCIHolder>,
PaymentsResponseData,
>>::get_error_response_v2(&**connector, http_response, None);
assert!(
result.is_err(),
"Expected panic due to missing required fields",
);
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_handle_authorize_missing_required_fields",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-4972240173322938778 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/razorpay/test.rs
// Function: test_handle_authorize_invalid_error_fields
{
use domain_types::{
connector_flow::Authorize,
connector_types::{PaymentFlowData, PaymentsAuthorizeData, PaymentsResponseData},
};
let http_response = Response {
headers: None,
response: br#"{
"error": {
"code": 500,
"description": "Card number is invalid.",
"step": "payment_authorization",
"reason": "input_validation_failed",
"source": "business",
"metadata": {}
}
}"#
.to_vec()
.into(),
status_code: 400,
};
let connector: BoxedConnector<DefaultPCIHolder> = Box::new(Razorpay::new());
let result =
<dyn ConnectorServiceTrait<DefaultPCIHolder> + Sync as ConnectorIntegrationV2<
Authorize,
PaymentFlowData,
PaymentsAuthorizeData<DefaultPCIHolder>,
PaymentsResponseData,
>>::get_error_response_v2(&**connector, http_response, None);
assert!(
result.is_err(),
"Expected panic due to missing required fields"
);
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_handle_authorize_invalid_error_fields",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_8878164691626727343 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/razorpay/test.rs
// Function: test_handle_response_v2_missing_fields_authorize_response
{
use std::str::FromStr;
use common_enums::Currency;
use common_utils::{id_type::MerchantId, pii::Email, types::MinorUnit};
use domain_types::{
connector_types::PaymentFlowData,
payment_address::PaymentAddress,
router_data::{ConnectorAuthType, ErrorResponse},
router_data_v2::RouterDataV2,
types::{ConnectorParams, Connectors},
};
let connector: BoxedConnector<DefaultPCIHolder> = Box::new(Razorpay::new());
let email = Email::try_from("testuser@gmail.com".to_string()).unwrap();
let data = RouterDataV2 {
flow: std::marker::PhantomData,
resource_common_data: PaymentFlowData {
merchant_id: MerchantId::default(),
customer_id: None,
connector_customer: None,
payment_id: "IRRELEVANT_PAYMENT_ID".to_string(),
attempt_id: "IRRELEVANT_ATTEMPT_ID".to_string(),
status: AttemptStatus::Pending,
payment_method: PaymentMethod::Card,
description: None,
return_url: None,
address: PaymentAddress::new(
None,
Some(Address {
address: None,
phone: Some(PhoneDetails {
number: Some("1234567890".to_string().into()),
country_code: Some("+1".to_string()),
}),
email: Some(email.clone()),
}),
None,
None,
),
auth_type: AuthenticationType::NoThreeDs,
connector_meta_data: None,
amount_captured: None,
minor_amount_captured: None,
access_token: None,
session_token: None,
reference_id: Some("order_QMsUrrLPdwNxPG".to_string()),
payment_method_token: None,
preprocessing_id: None,
connector_api_version: None,
connector_request_reference_id: "ref_12345".to_string(),
test_mode: None,
connector_http_status_code: None,
external_latency: None,
raw_connector_response: None,
connectors: Connectors {
razorpay: ConnectorParams {
base_url: "https://api.razorpay.com/".to_string(),
dispute_base_url: None,
..Default::default()
},
..Default::default()
},
vault_headers: None,
connector_response_headers: None,
raw_connector_request: None,
minor_amount_capturable: None,
connector_response: None,
recurring_mandate_payment_data: None,
},
connector_auth_type: ConnectorAuthType::BodyKey {
api_key: "dummy_api_key".to_string().into(),
key1: "dummy_key1".to_string().into(),
},
request: PaymentsAuthorizeData {
authentication_data: None,
payment_method_data: PaymentMethodData::Card(Card {
card_number: RawCardNumber(CardNumber::from_str("5123450000000008").unwrap()),
card_exp_month: "12".to_string().into(),
card_exp_year: "2025".to_string().into(),
card_cvc: "123".to_string().into(),
card_issuer: None,
card_network: None,
card_type: None,
card_issuing_country: None,
bank_code: None,
nick_name: None,
card_holder_name: Some("Test User".to_string().into()),
co_badged_card_data: None,
}),
amount: 1000,
order_tax_amount: None,
email: Some(email),
customer_name: None,
currency: Currency::USD,
confirm: true,
statement_descriptor_suffix: None,
statement_descriptor: None,
capture_method: None,
router_return_url: None,
webhook_url: None,
complete_authorize_url: None,
mandate_id: None,
setup_future_usage: None,
off_session: None,
browser_info: Some(BrowserInformation {
color_depth: None,
java_enabled: Some(false),
java_script_enabled: None,
language: Some("en-US".to_string()),
screen_height: Some(1080),
screen_width: Some(1920),
time_zone: None,
ip_address: None,
accept_header: Some(
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
.to_string(),
),
user_agent: Some("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)".to_string()),
referer: None,
os_type: None,
os_version: None,
device_model: None,
accept_language: None,
}),
order_category: None,
session_token: None,
enrolled_for_3ds: false,
related_transaction_id: None,
payment_experience: None,
payment_method_type: Some(common_enums::PaymentMethodType::Credit),
customer_id: None,
request_incremental_authorization: false,
metadata: None,
minor_amount: MinorUnit::new(1000),
merchant_order_reference_id: None,
shipping_cost: None,
integrity_object: None,
merchant_account_id: None,
merchant_config_currency: None,
all_keys_required: None,
access_token: None,
customer_acceptance: None,
split_payments: None,
request_extended_authorization: None,
setup_mandate_details: None,
enable_overcapture: None,
merchant_account_metadata: None,
},
response: Err(ErrorResponse {
code: "HE_00".to_string(),
message: "Something went wrong".to_string(),
reason: None,
status_code: 500,
attempt_status: None,
connector_transaction_id: None,
network_decline_code: None,
network_advice_code: None,
network_error_message: None,
}),
};
let http_response = Response {
headers: None,
response: br#"{
"next":[
{
"action":"redirect",
"url":"https://api.razorpay.com/v1/payments/QMsUsXCDy9sX3b/authenticate"
}
]
}"#
.to_vec()
.into(),
status_code: 200,
};
let result = connector.handle_response_v2(&data, None, http_response);
assert!(
result.is_err(),
"Expected error due to missing razorpay_payment_id, but got success."
);
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_handle_response_v2_missing_fields_authorize_response",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-1262477012638053872 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/razorpay/test.rs
// Function: test_handle_response_v2_invalid_json_authorize_response
{
use std::str::FromStr;
use common_enums::Currency;
use common_utils::{id_type::MerchantId, pii::Email, types::MinorUnit};
use domain_types::{
connector_types::PaymentFlowData,
payment_address::PaymentAddress,
router_data::{ConnectorAuthType, ErrorResponse},
router_data_v2::RouterDataV2,
types::{ConnectorParams, Connectors},
};
let connector: BoxedConnector<DefaultPCIHolder> = Box::new(Razorpay::new());
let email = Email::try_from("testuser@gmail.com".to_string()).unwrap();
let data = RouterDataV2 {
flow: std::marker::PhantomData,
resource_common_data: PaymentFlowData {
merchant_id: MerchantId::default(),
customer_id: None,
connector_customer: None,
payment_id: "IRRELEVANT_PAYMENT_ID".to_string(),
attempt_id: "IRRELEVANT_ATTEMPT_ID".to_string(),
status: AttemptStatus::Pending,
payment_method: PaymentMethod::Card,
description: None,
return_url: None,
address: PaymentAddress::new(
None,
Some(Address {
address: None,
phone: Some(PhoneDetails {
number: Some("1234567890".to_string().into()),
country_code: Some("+1".to_string()),
}),
email: Some(email.clone()),
}),
None,
None,
),
auth_type: AuthenticationType::NoThreeDs,
connector_meta_data: None,
amount_captured: None,
minor_amount_captured: None,
access_token: None,
session_token: None,
reference_id: Some("order_QMsUrrLPdwNxPG".to_string()),
payment_method_token: None,
preprocessing_id: None,
connector_api_version: None,
connector_request_reference_id: "ref_12345".to_string(),
test_mode: None,
connector_http_status_code: None,
external_latency: None,
raw_connector_response: None,
connectors: Connectors {
razorpay: ConnectorParams {
base_url: "https://api.razorpay.com/".to_string(),
dispute_base_url: None,
..Default::default()
},
..Default::default()
},
vault_headers: None,
connector_response_headers: None,
raw_connector_request: None,
minor_amount_capturable: None,
connector_response: None,
recurring_mandate_payment_data: None,
},
connector_auth_type: ConnectorAuthType::BodyKey {
api_key: "dummy_api_key".to_string().into(),
key1: "dummy_key1".to_string().into(),
},
request: PaymentsAuthorizeData {
authentication_data: None,
payment_method_data: PaymentMethodData::Card(Card {
card_number: RawCardNumber(CardNumber::from_str("5123450000000008").unwrap()),
card_exp_month: "12".to_string().into(),
card_exp_year: "2025".to_string().into(),
card_cvc: "123".to_string().into(),
card_issuer: None,
card_network: None,
card_type: None,
card_issuing_country: None,
bank_code: None,
nick_name: None,
card_holder_name: Some("Test User".to_string().into()),
co_badged_card_data: None,
}),
amount: 1000,
order_tax_amount: None,
email: Some(email),
customer_name: None,
currency: Currency::USD,
confirm: true,
statement_descriptor_suffix: None,
statement_descriptor: None,
capture_method: None,
router_return_url: None,
webhook_url: None,
complete_authorize_url: None,
mandate_id: None,
setup_future_usage: None,
off_session: None,
browser_info: Some(BrowserInformation {
color_depth: None,
java_enabled: Some(false),
java_script_enabled: None,
language: Some("en-US".to_string()),
screen_height: Some(1080),
screen_width: Some(1920),
time_zone: None,
ip_address: None,
accept_header: Some(
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
.to_string(),
),
user_agent: Some("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)".to_string()),
referer: None,
os_type: None,
os_version: None,
device_model: None,
accept_language: None,
}),
order_category: None,
session_token: None,
enrolled_for_3ds: false,
related_transaction_id: None,
payment_experience: None,
payment_method_type: Some(common_enums::PaymentMethodType::Credit),
customer_id: None,
request_incremental_authorization: false,
metadata: None,
minor_amount: MinorUnit::new(1000),
merchant_order_reference_id: None,
shipping_cost: None,
integrity_object: None,
merchant_account_id: None,
merchant_config_currency: None,
all_keys_required: None,
access_token: None,
customer_acceptance: None,
split_payments: None,
request_extended_authorization: None,
setup_mandate_details: None,
enable_overcapture: None,
merchant_account_metadata: None,
},
response: Err(ErrorResponse {
code: "HE_00".to_string(),
message: "Something went wrong".to_string(),
reason: None,
status_code: 500,
attempt_status: None,
connector_transaction_id: None,
network_decline_code: None,
network_advice_code: None,
network_error_message: None,
}),
};
let http_response = Response {
headers: None,
response: br#"{"razorpay_payment_id": "pay_xyz", "next": [ { "action": "redirect" "url": "https://api.razorpay.com/v1/payments/xyz/authenticate" } ]"#.to_vec().into(),
status_code: 200,
};
let result = connector.handle_response_v2(&data, None, http_response);
assert!(
result.is_err(),
"Expected error due to missing razorpay_payment_id, but got success."
);
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_handle_response_v2_invalid_json_authorize_response",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-7908791156729419999 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/razorpay/test.rs
// Function: test_build_request_valid_order
{
use common_enums::Currency;
use common_utils::{id_type::MerchantId, request::RequestContent, types::MinorUnit};
use domain_types::{
connector_types::PaymentCreateOrderData,
payment_address::PaymentAddress,
router_data::{ConnectorAuthType, ErrorResponse},
router_data_v2::RouterDataV2,
};
use serde_json::{to_value, Value};
let email = Email::try_from("testuser@gmail.com".to_string()).unwrap();
let test_router_data = RouterDataV2 {
flow: std::marker::PhantomData,
resource_common_data: domain_types::connector_types::PaymentFlowData {
merchant_id: MerchantId::default(),
customer_id: None,
connector_customer: None,
payment_id: "IRRELEVANT_PAYMENT_ID".to_string(),
attempt_id: "IRRELEVANT_ATTEMPT_ID".to_string(),
status: common_enums::AttemptStatus::Pending,
payment_method: common_enums::PaymentMethod::Card,
description: None,
return_url: None,
address: PaymentAddress::new(
None,
Some(Address {
address: None,
phone: Some(PhoneDetails {
number: Some("1234567890".to_string().into()),
country_code: Some("+1".to_string()),
}),
email: Some(email.clone()),
}),
None,
None,
),
auth_type: common_enums::AuthenticationType::NoThreeDs,
connector_meta_data: None,
amount_captured: None,
minor_amount_captured: None,
access_token: None,
session_token: None,
reference_id: None,
payment_method_token: None,
preprocessing_id: None,
connector_api_version: None,
connector_request_reference_id: "ref_12345".to_string(),
test_mode: None,
connector_http_status_code: None,
external_latency: None,
raw_connector_response: None,
connectors: domain_types::types::Connectors {
razorpay: ConnectorParams {
base_url: "https://api.razorpay.com/".to_string(),
dispute_base_url: None,
..Default::default()
},
..Default::default()
},
vault_headers: None,
connector_response_headers: None,
raw_connector_request: None,
minor_amount_capturable: None,
connector_response: None,
recurring_mandate_payment_data: None,
},
connector_auth_type: ConnectorAuthType::BodyKey {
api_key: "dummy_api_key".to_string().into(),
key1: "dummy_key1".to_string().into(),
},
request: PaymentCreateOrderData {
amount: MinorUnit::new(1000),
currency: Currency::USD,
integrity_object: None,
metadata: None,
webhook_url: None,
},
response: Err(ErrorResponse {
code: "HE_00".to_string(),
message: "Something went wrong".to_string(),
reason: None,
status_code: 500,
attempt_status: None,
connector_transaction_id: None,
network_decline_code: None,
network_advice_code: None,
network_error_message: None,
}),
};
let connector: BoxedConnector<DefaultPCIHolder> = Box::new(Razorpay::new());
let result = connector.get_request_body(&test_router_data).unwrap();
let actual_json: Value = match result {
Some(RequestContent::Json(payload)) => {
to_value(&payload).expect("Failed to serialize payload")
}
Some(RequestContent::RawBytes(bytes)) => {
// Handle raw bytes - try to parse as JSON
let json_str =
String::from_utf8(bytes).expect("Failed to convert bytes to string");
serde_json::from_str(&json_str).expect("Failed to parse bytes as JSON")
}
Some(RequestContent::FormUrlEncoded(form_data)) => {
// Convert form data to JSON for comparison
to_value(&form_data).expect("Failed to serialize form data")
}
None => panic!("Expected some request content"),
Some(other) => panic!("Unexpected RequestContent type: {other:?}"),
};
assert_eq!(actual_json["amount"], 1000);
assert_eq!(actual_json["currency"], "USD");
let receipt_value = &actual_json["receipt"];
assert!(
receipt_value.is_string(),
"Expected receipt to be a string, got: {receipt_value:?}"
);
let receipt_str = receipt_value.as_str().unwrap();
assert!(!receipt_str.is_empty(), "Expected non-empty receipt string");
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_build_request_valid_order",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_-2250098341918712889 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/razorpay/test.rs
// Function: test_handle_response_v2_valid_order_response
{
use common_enums::Currency;
use common_utils::{id_type::MerchantId, pii::Email, types::MinorUnit};
use domain_types::{
connector_types::{PaymentCreateOrderData, PaymentFlowData},
payment_address::PaymentAddress,
router_data::{ConnectorAuthType, ErrorResponse},
router_data_v2::RouterDataV2,
types::{ConnectorParams, Connectors},
};
let email = Email::try_from("testuser@gmail.com".to_string()).unwrap();
let connector: BoxedConnector<DefaultPCIHolder> = Box::new(Razorpay::new());
let data = RouterDataV2 {
flow: std::marker::PhantomData,
resource_common_data: PaymentFlowData {
merchant_id: MerchantId::default(),
customer_id: None,
connector_customer: None,
payment_id: "IRRELEVANT_PAYMENT_ID".to_string(),
attempt_id: "IRRELEVANT_ATTEMPT_ID".to_string(),
status: common_enums::AttemptStatus::Pending,
payment_method: common_enums::PaymentMethod::Card,
description: None,
return_url: None,
address: PaymentAddress::new(
None,
Some(Address {
address: None,
phone: Some(PhoneDetails {
number: Some("1234567890".to_string().into()),
country_code: Some("+1".to_string()),
}),
email: Some(email.clone()),
}),
None,
None,
),
auth_type: common_enums::AuthenticationType::NoThreeDs,
connector_meta_data: None,
amount_captured: None,
minor_amount_captured: None,
access_token: None,
session_token: None,
reference_id: None,
payment_method_token: None,
preprocessing_id: None,
connector_api_version: None,
connector_request_reference_id: "ref_12345".to_string(),
test_mode: None,
connector_http_status_code: None,
external_latency: None,
raw_connector_response: None,
connectors: Connectors {
razorpay: ConnectorParams {
base_url: "https://api.razorpay.com/".to_string(),
dispute_base_url: None,
..Default::default()
},
..Default::default()
},
vault_headers: None,
connector_response_headers: None,
raw_connector_request: None,
minor_amount_capturable: None,
connector_response: None,
recurring_mandate_payment_data: None,
},
connector_auth_type: ConnectorAuthType::BodyKey {
api_key: "dummy_api_key".to_string().into(),
key1: "dummy_key1".to_string().into(),
},
request: PaymentCreateOrderData {
amount: MinorUnit::new(1000),
currency: Currency::USD,
integrity_object: None,
metadata: None,
webhook_url: None,
},
response: Err(ErrorResponse {
code: "HE_00".to_string(),
message: "Something went wrong".to_string(),
reason: None,
status_code: 500,
attempt_status: None,
connector_transaction_id: None,
network_decline_code: None,
network_advice_code: None,
network_error_message: None,
}),
};
let http_response = Response {
headers: None,
response: br#"{
"amount":1000,
"amount_due":1000,
"amount_paid":0,
"attempts":0,
"created_at":1745490447,
"currency":"USD",
"entity":"order",
"id":"order_QMrTOdLWvEHsXz",
"notes":[],
"offer_id":null,
"receipt":"141674f6-30d3-4a17-b904-27fe6ca085c7",
"status":"created"
}"#
.to_vec()
.into(),
status_code: 200,
};
let result = connector
.handle_response_v2(&data, None, http_response)
.unwrap();
assert_eq!(
result.response.unwrap().order_id,
"order_QMrTOdLWvEHsXz".to_string()
);
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_handle_response_v2_valid_order_response",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_6941333131051758840 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/razorpay/test.rs
// Function: test_handle_response_missing
{
use common_enums::Currency;
use common_utils::{id_type::MerchantId, pii::Email, types::MinorUnit};
use domain_types::{
connector_types::PaymentCreateOrderData,
payment_address::PaymentAddress,
router_data::{ConnectorAuthType, ErrorResponse},
router_data_v2::RouterDataV2,
types::{ConnectorParams, Connectors},
};
let email = Email::try_from("testuser@gmail.com".to_string()).unwrap();
let connector: BoxedConnector<DefaultPCIHolder> = Box::new(Razorpay::new());
let data = RouterDataV2 {
flow: std::marker::PhantomData,
resource_common_data: PaymentFlowData {
merchant_id: MerchantId::default(),
customer_id: None,
connector_customer: None,
payment_id: "IRRELEVANT_PAYMENT_ID".to_string(),
attempt_id: "IRRELEVANT_ATTEMPT_ID".to_string(),
status: common_enums::AttemptStatus::Pending,
payment_method: common_enums::PaymentMethod::Card,
description: None,
return_url: None,
address: PaymentAddress::new(
None,
Some(Address {
address: None,
phone: Some(PhoneDetails {
number: Some("1234567890".to_string().into()),
country_code: Some("+1".to_string()),
}),
email: Some(email.clone()),
}),
None,
None,
),
auth_type: common_enums::AuthenticationType::NoThreeDs,
connector_meta_data: None,
amount_captured: None,
minor_amount_captured: None,
access_token: None,
session_token: None,
reference_id: None,
payment_method_token: None,
preprocessing_id: None,
connector_api_version: None,
connector_request_reference_id: "ref_12345".to_string(),
test_mode: None,
connector_http_status_code: None,
external_latency: None,
raw_connector_response: None,
connectors: Connectors {
razorpay: ConnectorParams {
base_url: "https://api.razorpay.com/".to_string(),
dispute_base_url: None,
..Default::default()
},
..Default::default()
},
vault_headers: None,
connector_response_headers: None,
raw_connector_request: None,
minor_amount_capturable: None,
connector_response: None,
recurring_mandate_payment_data: None,
},
connector_auth_type: ConnectorAuthType::BodyKey {
api_key: "dummy_api_key".to_string().into(),
key1: "dummy_key1".to_string().into(),
},
request: PaymentCreateOrderData {
amount: MinorUnit::new(1000),
currency: Currency::USD,
integrity_object: None,
metadata: None,
webhook_url: None,
},
response: Err(ErrorResponse {
code: "HE_00".to_string(),
message: "Something went wrong".to_string(),
reason: None,
status_code: 500,
attempt_status: None,
connector_transaction_id: None,
network_decline_code: None,
network_advice_code: None,
network_error_message: None,
}),
};
let http_response = Response {
headers: None,
response: br#"{
"amount":1000,
"currency":"USD",
"status":"created"
}"#
.to_vec()
.into(),
status_code: 200,
};
let result = connector.handle_response_v2(&data, None, http_response);
assert!(
result.is_err(),
"Expected error due to missing order_id or receipt"
);
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_handle_response_missing",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_989211878059782093 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/razorpay/test.rs
// Function: test_handle_response_invalid
{
use common_enums::Currency;
use common_utils::{id_type::MerchantId, pii::Email, types::MinorUnit};
use domain_types::{
connector_types::PaymentCreateOrderData,
payment_address::PaymentAddress,
router_data::{ConnectorAuthType, ErrorResponse},
router_data_v2::RouterDataV2,
types::{ConnectorParams, Connectors},
};
let email = Email::try_from("testuser@gmail.com".to_string()).unwrap();
let connector: BoxedConnector<DefaultPCIHolder> = Box::new(Razorpay::new());
let data = RouterDataV2 {
flow: std::marker::PhantomData,
resource_common_data: PaymentFlowData {
merchant_id: MerchantId::default(),
customer_id: None,
connector_customer: None,
payment_id: "IRRELEVANT_PAYMENT_ID".to_string(),
attempt_id: "IRRELEVANT_ATTEMPT_ID".to_string(),
status: common_enums::AttemptStatus::Pending,
payment_method: common_enums::PaymentMethod::Card,
description: None,
return_url: None,
address: PaymentAddress::new(
None,
Some(Address {
address: None,
phone: Some(PhoneDetails {
number: Some("1234567890".to_string().into()),
country_code: Some("+1".to_string()),
}),
email: Some(email.clone()),
}),
None,
None,
),
auth_type: common_enums::AuthenticationType::NoThreeDs,
connector_meta_data: None,
amount_captured: None,
minor_amount_captured: None,
access_token: None,
session_token: None,
reference_id: None,
payment_method_token: None,
preprocessing_id: None,
connector_api_version: None,
connector_request_reference_id: "ref_12345".to_string(),
test_mode: None,
connector_http_status_code: None,
external_latency: None,
raw_connector_response: None,
connectors: Connectors {
razorpay: ConnectorParams {
base_url: "https://api.razorpay.com/".to_string(),
dispute_base_url: None,
..Default::default()
},
..Default::default()
},
vault_headers: None,
connector_response_headers: None,
raw_connector_request: None,
minor_amount_capturable: None,
connector_response: None,
recurring_mandate_payment_data: None,
},
connector_auth_type: ConnectorAuthType::BodyKey {
api_key: "dummy_api_key".to_string().into(),
key1: "dummy_key1".to_string().into(),
},
request: PaymentCreateOrderData {
amount: MinorUnit::new(1000),
currency: Currency::USD,
integrity_object: None,
metadata: None,
webhook_url: None,
},
response: Err(ErrorResponse {
code: "HE_00".to_string(),
message: "Something went wrong".to_string(),
reason: None,
status_code: 500,
attempt_status: None,
connector_transaction_id: None,
network_decline_code: None,
network_advice_code: None,
network_error_message: None,
}),
};
let http_response = Response {
headers: None,
response: br#"{
"amount":1000,
"currency":"USD",
"status":"created"
}"#
.to_vec()
.into(),
status_code: 500,
};
let result = connector.handle_response_v2(&data, None, http_response);
assert!(
result.is_err(),
"Expected error due to invalid response format"
);
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_handle_response_invalid",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_3435598897392635562 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/razorpay/test.rs
// Function: test_handle_error_response_valid
{
let http_response = Response {
headers: None,
response: br#"{
"error": {
"code": "BAD_REQUEST_ERROR",
"description": "Order receipt should be unique.",
"step": "payment_initiation",
"reason": "input_validation_failed",
"source": "business",
"metadata": {
"order_id": "order_OL0t841dI8F9NV"
}
}
}"#
.to_vec()
.into(),
status_code: 400,
};
let connector: BoxedConnector<DefaultPCIHolder> = Box::new(Razorpay::new());
let result =
<dyn ConnectorServiceTrait<DefaultPCIHolder> + Sync as ConnectorIntegrationV2<
domain_types::connector_flow::CreateOrder,
domain_types::connector_types::PaymentFlowData,
domain_types::connector_types::PaymentCreateOrderData,
domain_types::connector_types::PaymentCreateOrderResponse,
>>::get_error_response_v2(&**connector, http_response, None)
.unwrap();
let actual_json = to_value(&result).unwrap();
let expected_json = json!({
"code": "BAD_REQUEST_ERROR",
"message": "Order receipt should be unique.",
"reason": "input_validation_failed",
"status_code": 400,
"attempt_status": "failure",
"connector_transaction_id": null,
"network_advice_code": null,
"network_decline_code": null,
"network_error_message": null
});
assert_eq!(actual_json, expected_json);
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_handle_error_response_valid",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_body_connector-integration_8132296736493886026 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/razorpay/test.rs
// Function: test_handle_error_response_invalid_json
{
let http_response = Response {
headers: None,
response: br#"{ "error": { "code": "BAD_REQUEST_ERROR" "#.to_vec().into(),
status_code: 400,
};
let connector: BoxedConnector<DefaultPCIHolder> = Box::new(Razorpay::new());
let result =
<dyn ConnectorServiceTrait<DefaultPCIHolder> + Sync as ConnectorIntegrationV2<
domain_types::connector_flow::CreateOrder,
domain_types::connector_types::PaymentFlowData,
domain_types::connector_types::PaymentCreateOrderData,
domain_types::connector_types::PaymentCreateOrderResponse,
>>::get_error_response_v2(&**connector, http_response, None);
assert!(result.is_err(), "Expected error for invalid JSON");
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_handle_error_response_invalid_json",
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.