id stringlengths 20 153 | type stringclasses 1
value | granularity stringclasses 14
values | content stringlengths 16 84.3k | metadata dict |
|---|---|---|---|---|
connector-service_body_connector-integration_-7571287875217013577 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/razorpay.rs
// Function: get_request_body
{
let converted_amount = self
.amount_converter
.convert(req.request.minor_amount_to_capture, req.request.currency)
.change_context(errors::ConnectorError::RequestEncodingFailed)?;
let connector_router_data =
razorpay::RazorpayRouterData::try_from((converted_amount, req))?;
let connector_req = razorpay::RazorpayCaptureRequest::try_from(&connector_router_data)?;
Ok(Some(RequestContent::Json(Box::new(connector_req))))
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_request_body",
"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_7316385582725157319 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/razorpay.rs
// Function: handle_response_v2
{
let response: razorpay::RazorpayCaptureResponse = res
.response
.parse_struct("RazorpayCaptureResponse")
.map_err(|err| {
report!(errors::ConnectorError::ResponseDeserializationFailed)
.attach_printable(format!("Failed to parse RazorpayCaptureResponse: {err:?}"))
})?;
with_response_body!(event_builder, response);
RouterDataV2::foreign_try_from((response, data.clone(), res.status_code))
.change_context(errors::ConnectorError::ResponseHandlingFailed)
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "handle_response_v2",
"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_-3441543475276427313 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/razorpay.rs
// Function: get_event_type
{
let payload = transformers::get_webhook_object_from_body(request.body).map_err(|err| {
report!(errors::ConnectorError::WebhookBodyDecodingFailed)
.attach_printable(format!("error while decoing webhook body {err}"))
})?;
if payload.refund.is_some() {
Ok(EventType::RefundSuccess)
} else {
Ok(EventType::PaymentIntentSuccess)
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_event_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_2222899861964199352 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/razorpay.rs
// Function: process_payment_webhook
{
let request_body_copy = request.body.clone();
let payload = transformers::get_webhook_object_from_body(request.body).map_err(|err| {
report!(errors::ConnectorError::WebhookBodyDecodingFailed)
.attach_printable(format!("error while decoding webhook body {err}"))
})?;
let notif = payload.payment.ok_or_else(|| {
error_stack::Report::new(errors::ConnectorError::RequestEncodingFailed)
})?;
Ok(WebhookDetailsResponse {
resource_id: Some(ResponseId::ConnectorTransactionId(notif.entity.order_id)),
status: transformers::get_razorpay_payment_webhook_status(
notif.entity.entity,
notif.entity.status,
)?,
mandate_reference: None,
connector_response_reference_id: None,
error_code: notif.entity.error_code,
error_message: notif.entity.error_reason,
raw_connector_response: Some(String::from_utf8_lossy(&request_body_copy).to_string()),
status_code: 200,
response_headers: None,
transformation_status: common_enums::WebhookTransformationStatus::Complete,
minor_amount_captured: None,
amount_captured: None,
error_reason: None,
network_txn_id: None,
})
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "process_payment_webhook",
"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_-4776203926114871987 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/razorpay.rs
// Function: process_refund_webhook
{
let request_body_copy = request.body.clone();
let payload = transformers::get_webhook_object_from_body(request.body).map_err(|err| {
report!(errors::ConnectorError::WebhookBodyDecodingFailed)
.attach_printable(format!("error while decoing webhook body {err}"))
})?;
let notif = payload.refund.ok_or_else(|| {
error_stack::Report::new(errors::ConnectorError::RequestEncodingFailed)
})?;
Ok(RefundWebhookDetailsResponse {
connector_refund_id: Some(notif.entity.id),
status: transformers::get_razorpay_refund_webhook_status(
notif.entity.entity,
notif.entity.status,
)?,
connector_response_reference_id: None,
error_code: None,
error_message: None,
raw_connector_response: Some(String::from_utf8_lossy(&request_body_copy).to_string()),
status_code: 200,
response_headers: None,
})
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "process_refund_webhook",
"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_-632523813206235948 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/razorpay.rs
// Function: validate_mandate_payment
{
let mandate_supported_pmd = std::collections::HashSet::from([PaymentMethodDataType::Card]);
is_mandate_supported(pm_data, pm_type, mandate_supported_pmd, self.id())
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "validate_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_1041528722336276981 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/razorpay.rs
// Function: validate_psync_reference_id
{
if data.encoded_data.is_some() {
return Ok(());
}
Err(errors::ConnectorError::MissingRequiredField {
field_name: "encoded_data",
}
.into())
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "validate_psync_reference_id",
"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_8384678097382920721 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/worldpay.rs
// Function: get_auth_header
{
let auth = worldpay::WorldpayAuthType::try_from(auth_type)
.change_context(errors::ConnectorError::FailedToObtainAuthType)?;
Ok(vec![(
headers::AUTHORIZATION.to_string(),
auth.api_key.into_masked(),
)])
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_auth_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_189987158657173823 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/worldpay.rs
// Function: build_error_response
{
let response = if !res.response.is_empty() {
res.response
.parse_struct("WorldpayErrorResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?
} else {
WorldpayErrorResponse::default(res.status_code)
};
with_error_response_body!(event_builder, response);
Ok(ErrorResponse {
status_code: res.status_code,
code: response.error_name,
message: response.message,
reason: response.validation_errors.map(|e| e.to_string()),
attempt_status: Some(common_enums::AttemptStatus::Failure),
connector_transaction_id: None,
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
})
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "build_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_5734756975046770815 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/volt.rs
// Function: build_error_response
{
let response: volt::VoltErrorResponse = res
.response
.parse_struct("VoltErrorResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
with_error_response_body!(event_builder, response);
let reason = match &response.exception.error_list {
Some(error_list) => error_list
.iter()
.map(|error| error.message.clone())
.collect::<Vec<String>>()
.join(" & "),
None => response.exception.message.clone(),
};
Ok(ErrorResponse {
status_code: res.status_code,
code: response.exception.message.to_string(),
message: response.exception.message.clone(),
reason: Some(reason),
attempt_status: None,
connector_transaction_id: None,
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
})
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "build_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_-7552583342404676401 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/fiuu.rs
// Function: build_error_response
{
let response: fiuu::FiuuErrorResponse = res
.response
.parse_struct("fiuu::FiuuErrorResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
with_error_response_body!(event_builder, response);
Ok(ErrorResponse {
status_code: res.status_code,
code: response.error_code.clone(),
message: response.error_desc.clone(),
reason: Some(response.error_desc.clone()),
attempt_status: None,
connector_transaction_id: None,
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
})
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "build_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_-8921672900864899698 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/fiuu.rs
// Function: get_url
{
Ok(format!(
"{}RMS/API/gate-query/index.php",
self.connector_base_url_payments(req)
))
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_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_8028544984512183043 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/fiuu.rs
// Function: get_request_body
{
let bridge = self.p_sync;
let input_data = FiuuRouterData {
connector: self.to_owned(),
router_data: req.clone(),
};
let request = bridge.request_body(input_data)?;
let form_data = <FiuuPaymentSyncRequest as GetFormData>::get_form_data(&request);
Ok(Some(macro_types::RequestContent::FormData(form_data)))
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_request_body",
"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_1585140472056921292 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/fiuu.rs
// Function: handle_response_v2
{
match res.headers {
Some(headers) => {
let content_header = utils::get_http_header("Content-type", &headers)
.attach_printable("Missing content type in headers")
.change_context(errors::ConnectorError::ResponseHandlingFailed)?;
let response: fiuu::FiuuPaymentResponse = if content_header
== "text/plain;charset=UTF-8"
{
parse_response(&res.response)
} else {
Err(errors::ConnectorError::ResponseDeserializationFailed)
.attach_printable(format!("Expected content type to be text/plain;charset=UTF-8 , but received different content type as {content_header} in response"))?
}?;
with_response_body!(event_builder, response);
RouterDataV2::try_from(ResponseRouterData {
response,
router_data: data.clone(),
http_code: res.status_code,
})
.change_context(errors::ConnectorError::ResponseHandlingFailed)
}
None => {
// We don't get headers for payment webhook response handling
let response: fiuu::FiuuPaymentResponse = res
.response
.parse_struct("fiuu::FiuuPaymentResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
with_response_body!(event_builder, response);
RouterDataV2::try_from(ResponseRouterData {
response,
router_data: data.clone(),
http_code: res.status_code,
})
.change_context(errors::ConnectorError::ResponseHandlingFailed)
}
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "handle_response_v2",
"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_-6780363234530636826 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/fiuu.rs
// Function: get_webhook_source_verification_signature
{
let header = request
.headers
.get("content-type")
.ok_or(errors::ConnectorError::WebhookSourceVerificationFailed)?;
let resource: FiuuWebhooksResponse = if header == "application/x-www-form-urlencoded" {
parse_and_log_keys_in_url_encoded_response::<FiuuWebhooksResponse>(&request.body);
serde_urlencoded::from_bytes::<FiuuWebhooksResponse>(&request.body)
.change_context(errors::ConnectorError::WebhookSourceVerificationFailed)?
} else {
request
.body
.parse_struct("fiuu::FiuuWebhooksResponse")
.change_context(errors::ConnectorError::WebhookSourceVerificationFailed)?
};
let signature = match resource {
FiuuWebhooksResponse::FiuuWebhookPaymentResponse(webhooks_payment_response) => {
webhooks_payment_response.skey
}
FiuuWebhooksResponse::FiuuWebhookRefundResponse(webhooks_refunds_response) => {
webhooks_refunds_response.signature
}
};
hex::decode(signature.expose())
.change_context(errors::ConnectorError::WebhookSourceVerificationFailed)
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_webhook_source_verification_signature",
"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_-8151310081204394688 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/fiuu.rs
// Function: get_webhook_source_verification_message
{
let header = request
.headers
.get("content-type")
.ok_or(errors::ConnectorError::WebhookSourceVerificationFailed)?;
let resource: FiuuWebhooksResponse = if header == "application/x-www-form-urlencoded" {
parse_and_log_keys_in_url_encoded_response::<FiuuWebhooksResponse>(&request.body);
serde_urlencoded::from_bytes::<FiuuWebhooksResponse>(&request.body)
.change_context(errors::ConnectorError::WebhookSourceVerificationFailed)?
} else {
request
.body
.parse_struct("fiuu::FiuuWebhooksResponse")
.change_context(errors::ConnectorError::WebhookSourceVerificationFailed)?
};
let verification_message = match resource {
FiuuWebhooksResponse::FiuuWebhookPaymentResponse(webhooks_payment_response) => {
let key0 = format!(
"{}{}{}{}{}{}",
webhooks_payment_response.tran_id,
webhooks_payment_response.order_id,
webhooks_payment_response.status,
webhooks_payment_response.domain.clone().peek(),
webhooks_payment_response.amount.get_amount_as_string(),
webhooks_payment_response.currency
);
let md5_key0 = hex::encode(
crypto::Md5
.generate_digest(key0.as_bytes())
.change_context(errors::ConnectorError::WebhookSourceVerificationFailed)?,
);
let key1 = format!(
"{}{}{}{}{}",
webhooks_payment_response.paydate,
webhooks_payment_response.domain.peek(),
md5_key0,
webhooks_payment_response
.appcode
.map_or("".to_string(), |appcode| appcode.expose()),
String::from_utf8_lossy(&connector_webhook_secrets.secret)
);
key1
}
FiuuWebhooksResponse::FiuuWebhookRefundResponse(webhooks_refunds_response) => {
format!(
"{}{}{}{}{}{}{}{}",
webhooks_refunds_response.refund_type,
webhooks_refunds_response.merchant_id.peek(),
webhooks_refunds_response.ref_id,
webhooks_refunds_response.refund_id,
webhooks_refunds_response.txn_id,
webhooks_refunds_response.amount.get_amount_as_string(),
webhooks_refunds_response.status,
String::from_utf8_lossy(&connector_webhook_secrets.secret)
)
}
};
Ok(verification_message.as_bytes().to_vec())
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_webhook_source_verification_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_7999311101286408366 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/fiuu.rs
// Function: verify_webhook_source
{
let algorithm = crypto::Md5;
let connector_webhook_secrets = match connector_webhook_secret {
Some(secrets) => secrets,
None => Err(domain_types::errors::ConnectorError::WebhookSourceVerificationFailed)?,
};
let signature =
self.get_webhook_source_verification_signature(&request, &connector_webhook_secrets)?;
let message =
self.get_webhook_source_verification_message(&request, &connector_webhook_secrets)?;
algorithm
.verify_signature(&connector_webhook_secrets.secret, &signature, &message)
.change_context(errors::ConnectorError::WebhookSourceVerificationFailed)
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "verify_webhook_source",
"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_2238187406495655261 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/fiuu.rs
// Function: get_event_type
{
let header = request
.headers
.get("content-type")
.ok_or(errors::ConnectorError::WebhookSourceVerificationFailed)?;
let resource: FiuuWebhooksResponse = if header == "application/x-www-form-urlencoded" {
parse_and_log_keys_in_url_encoded_response::<FiuuWebhooksResponse>(&request.body);
serde_urlencoded::from_bytes::<FiuuWebhooksResponse>(&request.body)
.change_context(errors::ConnectorError::WebhookEventTypeNotFound)?
} else {
request
.body
.parse_struct("fiuu::FiuuWebhooksResponse")
.change_context(errors::ConnectorError::WebhookEventTypeNotFound)?
};
match resource {
FiuuWebhooksResponse::FiuuWebhookPaymentResponse(webhooks_payment_response) => {
Ok(EventType::from(webhooks_payment_response.status))
}
FiuuWebhooksResponse::FiuuWebhookRefundResponse(webhooks_refunds_response) => {
Ok(EventType::from(webhooks_refunds_response.status))
}
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_event_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_1467597268859528544 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/fiuu.rs
// Function: get_webhook_resource_object
{
let header = request
.headers
.get("content-type")
.ok_or(errors::ConnectorError::WebhookBodyDecodingFailed)?;
let payload: FiuuWebhooksResponse = if header == "application/x-www-form-urlencoded" {
parse_and_log_keys_in_url_encoded_response::<FiuuWebhooksResponse>(&request.body);
serde_urlencoded::from_bytes::<FiuuWebhooksResponse>(&request.body)
.change_context(errors::ConnectorError::WebhookResourceObjectNotFound)?
} else {
request
.body
.parse_struct("fiuu::FiuuWebhooksResponse")
.change_context(errors::ConnectorError::WebhookResourceObjectNotFound)?
};
match payload.clone() {
FiuuWebhooksResponse::FiuuWebhookPaymentResponse(webhook_payment_response) => Ok(
Box::new(fiuu::FiuuPaymentResponse::FiuuWebhooksPaymentResponse(
webhook_payment_response,
)),
),
FiuuWebhooksResponse::FiuuWebhookRefundResponse(webhook_refund_response) => {
Ok(Box::new(fiuu::FiuuRefundSyncResponse::Webhook(
webhook_refund_response,
)))
}
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_webhook_resource_object",
"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_8350515313512997096 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/fiuu.rs
// Function: process_payment_webhook
{
Ok(WebhookDetailsResponse {
resource_id: None,
status: common_enums::AttemptStatus::Unknown,
connector_response_reference_id: None,
error_code: None,
error_message: None,
raw_connector_response: None,
status_code: 200,
response_headers: None,
mandate_reference: None,
minor_amount_captured: None,
amount_captured: None,
error_reason: None,
network_txn_id: None,
transformation_status: common_enums::WebhookTransformationStatus::Incomplete,
})
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "process_payment_webhook",
"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_-7098855071164778483 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/fiuu.rs
// Function: process_refund_webhook
{
let header = request
.headers
.get("content-type")
.ok_or(errors::ConnectorError::WebhookBodyDecodingFailed)?;
let payload: FiuuWebhooksResponse = if header == "application/x-www-form-urlencoded" {
parse_and_log_keys_in_url_encoded_response::<FiuuWebhooksResponse>(&request.body);
serde_urlencoded::from_bytes::<FiuuWebhooksResponse>(&request.body)
.change_context(errors::ConnectorError::WebhookResourceObjectNotFound)?
} else {
request
.body
.parse_struct("fiuu::FiuuWebhooksResponse")
.change_context(errors::ConnectorError::WebhookResourceObjectNotFound)?
};
let notif = match payload.clone() {
FiuuWebhooksResponse::FiuuWebhookPaymentResponse(_) => {
Err(errors::ConnectorError::WebhookBodyDecodingFailed)
}
FiuuWebhooksResponse::FiuuWebhookRefundResponse(webhook_refund_response) => Ok(
fiuu::FiuuRefundSyncResponse::Webhook(webhook_refund_response),
),
}?;
let response = RefundWebhookDetailsResponse::try_from(notif)
.change_context(errors::ConnectorError::WebhookBodyDecodingFailed);
response.map(|mut response| {
response.raw_connector_response =
Some(String::from_utf8_lossy(&request.body).to_string());
response
})
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "process_refund_webhook",
"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_-8884561724767210004 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/fiuu.rs
// Function: parse_response
{
let response_str = String::from_utf8(data.to_vec()).map_err(|e| {
error!("Error in Deserializing Response Data: {:?}", e);
errors::ConnectorError::ResponseDeserializationFailed
})?;
let mut json = serde_json::Map::new();
let mut miscellaneous: HashMap<String, Secret<String>> = HashMap::new();
for line in response_str.lines() {
if let Some((key, value)) = line.split_once('=') {
if key.trim().is_empty() {
error!("Null or empty key encountered in response.");
continue;
}
if let Some(old_value) = json.insert(key.to_string(), Value::String(value.to_string()))
{
warn!("Repeated key encountered: {}", key);
miscellaneous.insert(key.to_string(), Secret::new(old_value.to_string()));
}
}
}
if !miscellaneous.is_empty() {
let misc_value = serde_json::to_value(miscellaneous).map_err(|e| {
error!("Error serializing miscellaneous data: {:?}", e);
errors::ConnectorError::ResponseDeserializationFailed
})?;
json.insert("miscellaneous".to_string(), misc_value);
}
let response: T = serde_json::from_value(Value::Object(json)).map_err(|e| {
error!("Error in Deserializing Response Data: {:?}", e);
errors::ConnectorError::ResponseDeserializationFailed
})?;
Ok(response)
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "parse_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_-215533353466898770 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/fiuu.rs
// Function: parse_and_log_keys_in_url_encoded_response
{
match std::str::from_utf8(data) {
Ok(query_str) => {
let loggable_keys = [
"status",
"orderid",
"tranID",
"nbcb",
"amount",
"currency",
"paydate",
"channel",
"error_desc",
"error_code",
"extraP",
];
let keys: Vec<(Cow<'_, str>, String)> =
url::form_urlencoded::parse(query_str.as_bytes())
.map(|(key, value)| {
if loggable_keys.contains(&key.to_string().as_str()) {
(key, value.to_string())
} else {
(key, "SECRET".to_string())
}
})
.collect();
info!("Keys in {} response\n{:?}", type_name::<T>(), keys);
}
Err(err) => {
error!("Failed to convert bytes to string: {:?}", err);
}
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "parse_and_log_keys_in_url_encoded_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_2900781375977387707 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/phonepe.rs
// Function: get_auth_header
{
let _auth = phonepe::PhonepeAuthType::try_from(auth_type)
.change_context(errors::ConnectorError::FailedToObtainAuthType)?;
Ok(vec![(
"Content-Type".to_string(),
"application/json".to_string().into(),
)])
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_auth_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_1927953236325825598 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/phonepe.rs
// Function: build_error_response
{
// Parse PhonePe error response (unified for both sync and payments)
let (error_message, error_code, attempt_status) = if let Ok(error_response) =
res.response
.parse_struct::<phonepe::PhonepeErrorResponse>("PhonePe ErrorResponse")
{
let attempt_status = phonepe::get_phonepe_error_status(&error_response.code);
(error_response.message, error_response.code, attempt_status)
} else {
let raw_response = String::from_utf8_lossy(&res.response);
(
"Unknown PhonePe error".to_string(),
raw_response.to_string(),
None,
)
};
Ok(ErrorResponse {
status_code: res.status_code,
code: error_code,
message: error_message.clone(),
reason: Some(error_message),
attempt_status,
connector_transaction_id: None,
network_decline_code: None,
network_advice_code: None,
network_error_message: None,
})
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "build_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_7547272039749893692 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/helcim.rs
// Function: get_auth_header
{
let auth = helcim::HelcimAuthType::try_from(auth_type)
.change_context(errors::ConnectorError::FailedToObtainAuthType)?;
Ok(vec![(
headers::API_TOKEN.to_string(),
auth.api_key.expose().into_masked(),
)])
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_auth_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_-1436091478754495665 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/helcim.rs
// Function: build_error_response
{
let response: helcim::HelcimErrorResponse = res
.response
.parse_struct("HelcimErrorResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
with_error_response_body!(event_builder, response);
let error_string = match response {
helcim::HelcimErrorResponse::Payment(response) => match response.errors {
helcim::HelcimErrorTypes::StringType(error) => error,
helcim::HelcimErrorTypes::JsonType(error) => error.to_string(),
},
helcim::HelcimErrorResponse::General(error_string) => error_string,
};
Ok(ErrorResponse {
status_code: res.status_code,
code: NO_ERROR_CODE.to_owned(),
message: error_string.clone(),
reason: Some(error_string),
attempt_status: None,
connector_transaction_id: None,
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
})
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "build_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_5851360822222492636 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/mifinity.rs
// Function: get_auth_header
{
let auth = MifinityAuthType::try_from(auth_type)
.change_context(errors::ConnectorError::FailedToObtainAuthType)?;
Ok(vec![("key".to_string(), auth.key.expose().into_masked())])
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_auth_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_-502111590944834684 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/mifinity.rs
// Function: build_error_response
{
if res.response.is_empty() {
Ok(ErrorResponse {
status_code: res.status_code,
code: "No error code".to_string(),
message: "No error message".to_string(),
reason: Some("Authentication Error from the connector".to_string()),
attempt_status: None,
connector_transaction_id: None,
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
})
} else {
let response: Result<
MifinityErrorResponse,
Report<common_utils::errors::ParsingError>,
> = res.response.parse_struct("MifinityErrorResponse");
match response {
Ok(response) => {
if let Some(i) = event_builder {
i.set_connector_response(&response);
}
let error_codes = response
.errors
.iter()
.map(|error| error.error_code.clone())
.collect::<Vec<String>>()
.join(" & ");
let error_messages = response
.errors
.iter()
.map(|error| error.message.clone())
.collect::<Vec<String>>()
.join(" & ");
Ok(ErrorResponse {
status_code: res.status_code,
code: error_codes,
message: error_messages.clone(),
reason: Some(error_messages),
attempt_status: None,
connector_transaction_id: None,
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
})
}
Err(_error_msg) => {
if let Some(event) = event_builder {
event.set_connector_response(&serde_json::json!({"error": "Error response parsing failed", "status_code": res.status_code}));
}
crate::utils::handle_json_response_deserialization_failure(res, "mifinity")
}
}
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "build_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_-7904421727497723039 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/bluecode.rs
// Function: verify_webhook_source
{
let connector_webhook_secrets = match connector_webhook_secret {
Some(secrets) => secrets.secret,
None => return Ok(false),
};
let security_header = request
.headers
.get("x-eorder-webhook-signature")
.ok_or(domain_types::errors::ConnectorError::WebhookSignatureNotFound)?
.clone();
let signature = hex::decode(security_header)
.change_context(errors::ConnectorError::WebhookSignatureNotFound)?;
let parsed: serde_json::Value = serde_json::from_slice(&request.body)
.change_context(errors::ConnectorError::ParsingFailed)?;
let sorted_payload = transformers::sort_and_minify_json(&parsed)?;
let key = ring::hmac::Key::new(ring::hmac::HMAC_SHA512, &connector_webhook_secrets);
let verify = ring::hmac::verify(&key, sorted_payload.as_bytes(), &signature)
.map(|_| true)
.change_context(errors::ConnectorError::WebhookSourceVerificationFailed)?;
Ok(verify)
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "verify_webhook_source",
"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_-1504575242888662960 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/bluecode.rs
// Function: process_payment_webhook
{
let request_body_copy = request.body.clone();
let webhook_body: transformers::BluecodeWebhookResponse = request
.body
.parse_struct("BluecodeWebhookResponse")
.change_context(ConnectorError::WebhookResourceObjectNotFound)
.attach_printable_lazy(|| "Failed to parse Bluecode payment webhook body structure")?;
let transaction_id = webhook_body.order_id.clone();
let status: common_enums::AttemptStatus = webhook_body.status.into();
Ok(WebhookDetailsResponse {
resource_id: Some(ResponseId::ConnectorTransactionId(transaction_id.clone())),
status,
status_code: 200,
connector_response_reference_id: Some(transaction_id),
error_code: None,
error_message: None,
raw_connector_response: Some(String::from_utf8_lossy(&request_body_copy).to_string()),
response_headers: None,
mandate_reference: 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": "process_payment_webhook",
"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_9160131929266963698 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/bluecode.rs
// Function: get_auth_header
{
let auth = BluecodeAuthType::try_from(auth_type)
.change_context(errors::ConnectorError::FailedToObtainAuthType)?;
Ok(vec![(
headers::AUTHORIZATION.to_string(),
format!("token {}", auth.api_key.expose()).into_masked(),
)])
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_auth_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_-3506774410299189820 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/bluecode.rs
// Function: build_error_response
{
let response: BluecodeErrorResponse = res
.response
.parse_struct("BluecodeErrorResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
with_error_response_body!(event_builder, response);
Ok(ErrorResponse {
status_code: res.status_code,
code: consts::NO_ERROR_CODE.to_string(),
message: response.message.clone(),
reason: Some(response.message),
attempt_status: None,
connector_transaction_id: None,
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
})
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "build_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_2690919274058171796 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/bluecode.rs
// Function: validate_mandate_payment
{
match pm_data {
PaymentMethodData::Card(_) => Err(errors::ConnectorError::NotImplemented(
"validate_mandate_payment does not support cards".to_string(),
)
.into()),
_ => Ok(()),
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "validate_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_-1648689825258421689 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/stripe.rs
// Function: get_auth_header
{
let auth = stripe::StripeAuthType::try_from(auth_type)
.change_context(errors::ConnectorError::FailedToObtainAuthType)?;
Ok(vec![
(
headers::AUTHORIZATION.to_string(),
format!("Bearer {}", auth.api_key.peek()).into_masked(),
),
(
auth_headers::STRIPE_API_VERSION.to_string(),
auth_headers::STRIPE_VERSION.to_string().into_masked(),
),
])
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_auth_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_-1213445061676583630 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/stripe.rs
// Function: build_error_response
{
let response: stripe::ErrorResponse = res
.response
.parse_struct("ErrorResponse")
.change_context(ConnectorError::ResponseDeserializationFailed)?;
with_error_response_body!(event_builder, response);
Ok(ErrorResponse {
status_code: res.status_code,
code: response
.error
.code
.clone()
.unwrap_or_else(|| NO_ERROR_CODE.to_string()),
message: response
.error
.code
.unwrap_or_else(|| NO_ERROR_MESSAGE.to_string()),
reason: response.error.message.map(|message| {
response
.error
.decline_code
.clone()
.map(|decline_code| {
format!("message - {message}, decline_code - {decline_code}")
})
.unwrap_or(message)
}),
attempt_status: None,
connector_transaction_id: response.error.payment_intent.map(|pi| pi.id),
network_advice_code: response.error.network_advice_code,
network_decline_code: response.error.network_decline_code,
network_error_message: response.error.decline_code.or(response.error.advice_code),
})
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "build_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_5262077823121277769 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/rapyd.rs
// Function: get_auth_header
{
let auth = RapydAuthType::try_from(auth_type)
.change_context(errors::ConnectorError::FailedToObtainAuthType)?;
// Return basic auth headers - signature will be added in get_headers method
Ok(vec![(
"access_key".to_string(),
auth.access_key.into_masked(),
)])
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_auth_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_-9188194821457685648 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/rapyd.rs
// Function: build_error_response
{
let response: Result<RapydPaymentsResponse, Report<common_utils::errors::ParsingError>> =
res.response.parse_struct("rapyd ErrorResponse");
match response {
Ok(response_data) => {
with_error_response_body!(event_builder, response_data);
Ok(ErrorResponse {
status_code: res.status_code,
code: response_data.status.error_code,
message: response_data.status.status.unwrap_or_default(),
reason: response_data.status.message,
attempt_status: None,
connector_transaction_id: None,
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
})
}
Err(error_msg) => {
if let Some(event) = event_builder {
event.set_connector_response(&serde_json::json!({"error": "Error response parsing failed", "status_code": res.status_code}))
};
tracing::error!(deserialization_error =? error_msg);
domain_types::utils::handle_json_response_deserialization_failure(res, "rapyd")
}
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "build_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_5915913507780613867 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/cryptopay.rs
// Function: get_auth_header
{
let auth = cryptopay::CryptopayAuthType::try_from(auth_type)
.change_context(errors::ConnectorError::FailedToObtainAuthType)?;
Ok(vec![(
headers::AUTHORIZATION.to_string(),
auth.api_key.peek().to_owned().into_masked(),
)])
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_auth_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_-2369417119541641091 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/cryptopay.rs
// Function: build_error_response
{
let response: cryptopay::CryptopayErrorResponse = res
.response
.parse_struct("CryptopayErrorResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
with_error_response_body!(event_builder, response);
Ok(ErrorResponse {
status_code: res.status_code,
code: response.error.code,
message: response.error.message,
reason: response.error.reason,
attempt_status: None,
connector_transaction_id: None,
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
})
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "build_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_1289114260966462833 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/cryptopay.rs
// Function: get_webhook_source_verification_signature
{
let base64_signature = request
.headers
.get("x-cryptopay-signature")
.ok_or(errors::ConnectorError::WebhookSourceVerificationFailed)
.attach_printable("Missing incoming webhook signature for Cryptopay")?;
hex::decode(base64_signature)
.change_context(errors::ConnectorError::WebhookSourceVerificationFailed)
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_webhook_source_verification_signature",
"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_-1237073407817626933 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/cryptopay.rs
// Function: get_webhook_source_verification_message
{
let message = std::str::from_utf8(&request.body)
.change_context(errors::ConnectorError::WebhookSourceVerificationFailed)
.attach_printable("Webhook source verification message parsing failed for Cryptopay")?;
Ok(message.to_string().into_bytes())
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_webhook_source_verification_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_-7848549749971430659 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/cryptopay.rs
// Function: verify_webhook_source
{
let algorithm = crypto::HmacSha256;
let connector_webhook_secrets = match connector_webhook_secret {
Some(secrets) => secrets,
None => Err(domain_types::errors::ConnectorError::WebhookSourceVerificationFailed)?,
};
let signature =
self.get_webhook_source_verification_signature(&request, &connector_webhook_secrets)?;
let message =
self.get_webhook_source_verification_message(&request, &connector_webhook_secrets)?;
algorithm
.verify_signature(&connector_webhook_secrets.secret, &signature, &message)
.change_context(errors::ConnectorError::WebhookSourceVerificationFailed)
.attach_printable("Webhook source verification failed for Cryptopay")
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "verify_webhook_source",
"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_-5446855348638743212 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/cryptopay.rs
// Function: get_event_type
{
let notif: cryptopay::CryptopayWebhookDetails = request
.body
.parse_struct("CryptopayWebhookDetails")
.change_context(errors::ConnectorError::WebhookEventTypeNotFound)?;
match notif.data.status {
cryptopay::CryptopayPaymentStatus::Completed => Ok(EventType::PaymentIntentSuccess),
cryptopay::CryptopayPaymentStatus::Unresolved => Ok(EventType::PaymentActionRequired),
cryptopay::CryptopayPaymentStatus::Cancelled => Ok(EventType::PaymentIntentFailure),
_ => Ok(EventType::IncomingWebhookEventUnspecified),
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_event_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_-93599485080688997 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/cryptopay.rs
// Function: process_payment_webhook
{
let notif: cryptopay::CryptopayWebhookDetails = request
.body
.parse_struct("CryptopayWebhookDetails")
.change_context(errors::ConnectorError::WebhookEventTypeNotFound)?;
let response = WebhookDetailsResponse::try_from(notif)
.change_context(errors::ConnectorError::WebhookBodyDecodingFailed);
response.map(|mut response| {
response.raw_connector_response =
Some(String::from_utf8_lossy(&request.body).to_string());
response
})
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "process_payment_webhook",
"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_5109453963539044520 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/checkout.rs
// Function: get_auth_header
{
let auth = transformers::CheckoutAuthType::try_from(auth_type)
.change_context(errors::ConnectorError::FailedToObtainAuthType)?;
Ok(vec![(
headers::AUTHORIZATION.to_string(),
format!("Bearer {}", auth.api_secret.peek()).into_masked(),
)])
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_auth_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_3696234339673166478 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/checkout.rs
// Function: build_error_response
{
let response: CheckoutErrorResponse = if res.response.is_empty() {
let (error_codes, error_type) = if res.status_code == 401 {
(
Some(vec!["Invalid api key".to_string()]),
Some("invalid_api_key".to_string()),
)
} else {
(None, None)
};
CheckoutErrorResponse {
request_id: None,
error_codes,
error_type,
}
} else {
res.response
.parse_struct("ErrorResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?
};
if let Some(i) = event_builder {
i.set_connector_response(&response);
}
Ok(ErrorResponse {
status_code: res.status_code,
code: consts::NO_ERROR_CODE.to_string(),
message: consts::NO_ERROR_MESSAGE.to_string(),
reason: response
.error_codes
.map(|errors| errors.join(" & "))
.or(response.error_type),
attempt_status: None,
connector_transaction_id: response.request_id,
network_decline_code: None,
network_advice_code: None,
network_error_message: None,
})
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "build_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_1094722381260037946 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/razorpayv2.rs
// Function: new
{
&Self {
amount_converter: &common_utils::types::MinorUnitForConnector,
_phantom: std::marker::PhantomData,
}
}
| {
"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_-299579780432541397 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/razorpayv2.rs
// Function: get_auth_header
{
let auth = razorpayv2::RazorpayV2AuthType::try_from(auth_type)
.change_context(errors::ConnectorError::FailedToObtainAuthType)?;
Ok(vec![(
headers::AUTHORIZATION.to_string(),
auth.generate_authorization_header().into(),
)])
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_auth_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_-6366760446948384412 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/razorpayv2.rs
// Function: build_error_response
{
let response: razorpayv2::RazorpayV2ErrorResponse = res
.response
.parse_struct("RazorpayV2ErrorResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
if let Some(i) = event_builder {
i.set_connector_response(&response)
}
let (code, message, attempt_status) = match response {
razorpayv2::RazorpayV2ErrorResponse::StandardError { error } => {
let attempt_status = match error.code.as_str() {
"BAD_REQUEST_ERROR" => AttemptStatus::Failure,
"GATEWAY_ERROR" => AttemptStatus::Failure,
"AUTHENTICATION_ERROR" => AttemptStatus::AuthenticationFailed,
"AUTHORIZATION_ERROR" => AttemptStatus::AuthorizationFailed,
"SERVER_ERROR" => AttemptStatus::Pending,
_ => AttemptStatus::Pending,
};
(error.code, error.description.clone(), attempt_status)
}
razorpayv2::RazorpayV2ErrorResponse::SimpleError { message } => {
// For simple error messages like "no Route matched with those values"
// Default to failure status and use a generic error code
(
"ROUTE_ERROR".to_string(),
message.clone(),
AttemptStatus::Failure,
)
}
};
Ok(domain_types::router_data::ErrorResponse {
code,
message: message.clone(),
reason: Some(message),
status_code: res.status_code,
attempt_status: Some(attempt_status),
connector_transaction_id: None,
network_decline_code: None,
network_advice_code: None,
network_error_message: None,
})
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "build_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_3996886326951440771 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/razorpayv2.rs
// Function: get_headers
{
let mut headers = vec![(
headers::CONTENT_TYPE.to_string(),
"application/json".to_string().into(),
)];
let mut auth_headers = self.get_auth_header(&req.connector_auth_type)?;
headers.append(&mut auth_headers);
Ok(headers)
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_headers",
"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_5716527772711383934 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/razorpayv2.rs
// Function: get_url
{
let base_url = &req.resource_common_data.connectors.razorpayv2.base_url;
let connector_payment_id = &req.request.connector_transaction_id;
Ok(format!(
"{base_url}v1/payments/{connector_payment_id}/refund"
))
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_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_-6119063708497718768 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/razorpayv2.rs
// Function: get_request_body
{
let converted_amount = self
.amount_converter
.convert(req.request.minor_refund_amount, req.request.currency)
.change_context(errors::ConnectorError::RequestEncodingFailed)?;
let connector_router_data = razorpayv2::RazorpayV2RouterData::<
&RefundsData,
DefaultPCIHolder,
>::try_from((converted_amount, &req.request, None))?;
let connector_req = razorpayv2::RazorpayV2RefundRequest::try_from(&connector_router_data)?;
Ok(Some(RequestContent::Json(Box::new(connector_req))))
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_request_body",
"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_8008120248975303706 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/razorpayv2.rs
// Function: handle_response_v2
{
let response: razorpayv2::RazorpayV2RefundResponse = res
.response
.parse_struct("RazorpayV2RefundResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
if let Some(i) = event_builder {
i.set_connector_response(&response)
}
RouterDataV2::foreign_try_from((
response,
data.clone(),
res.status_code,
res.response.to_vec(),
))
.change_context(errors::ConnectorError::ResponseHandlingFailed)
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "handle_response_v2",
"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_-4304612732005902899 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/macros.rs
// Function: response
{
if bytes.is_empty() {
serde_json::from_str("{}")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)
} else {
bytes
.parse_struct(std::any::type_name::<Self::ResponseBody>())
.change_context(errors::ConnectorError::ResponseDeserializationFailed)
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "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_-3255286691494576199 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/aci.rs
// Function: get_auth_header
{
let auth = aci::AciAuthType::try_from(auth_type)
.change_context(errors::ConnectorError::FailedToObtainAuthType)?;
Ok(vec![(
headers::AUTHORIZATION.to_string(),
format!("Bearer {}", auth.api_key.peek()).into_masked(),
)])
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_auth_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_641024712665909102 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/aci.rs
// Function: build_error_response
{
let response: aci::AciErrorResponse = res
.response
.parse_struct("AciErrorResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
with_error_response_body!(event_builder, response);
Ok(ErrorResponse {
status_code: res.status_code,
code: response.result.code,
message: response.result.description,
reason: response.result.parameter_errors.map(|errors| {
errors
.into_iter()
.map(|error_description| {
format!(
"Field is {} and the message is {}",
error_description.name, error_description.message
)
})
.collect::<Vec<String>>()
.join("; ")
}),
attempt_status: None,
connector_transaction_id: None,
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
})
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "build_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_-1860421272076504246 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/elavon.rs
// Function: build_error_response
{
match res
.response
.parse_struct::<elavon::ElavonPaymentsResponse>("ElavonPaymentsResponse")
.map_err(|_| errors::ConnectorError::ResponseDeserializationFailed)
{
Ok(elavon_response) => {
with_error_response_body!(event_builder, elavon_response);
match elavon_response.result {
elavon::ElavonResult::Error(error_payload) => Ok(ErrorResponse {
status_code: res.status_code,
code: error_payload.error_code.unwrap_or_else(|| "".to_string()),
message: error_payload.error_message,
reason: error_payload.error_name,
attempt_status: Some(common_enums::AttemptStatus::Failure),
connector_transaction_id: error_payload.ssl_txn_id,
network_decline_code: None,
network_advice_code: None,
network_error_message: None,
}),
elavon::ElavonResult::Success(success_payload) => Ok(ErrorResponse {
status_code: res.status_code,
code: "".to_string(),
message: "Received success response in error flow".to_string(),
reason: Some(format!(
"Unexpected success: {:?}",
success_payload.ssl_result_message
)),
attempt_status: Some(common_enums::AttemptStatus::Failure),
connector_transaction_id: Some(success_payload.ssl_txn_id),
network_decline_code: None,
network_advice_code: None,
network_error_message: None,
}),
}
}
Err(_parsing_error) => {
let (message, reason) = match res.status_code {
500..=599 => (
"Elavon server error".to_string(),
Some(String::from_utf8_lossy(&res.response).into_owned()),
),
_ => (
"Elavon error response".to_string(),
Some(String::from_utf8_lossy(&res.response).into_owned()),
),
};
Ok(ErrorResponse {
status_code: res.status_code,
code: "".to_string(),
message,
reason,
attempt_status: Some(common_enums::AttemptStatus::Failure),
connector_transaction_id: None,
network_decline_code: None,
network_advice_code: None,
network_error_message: None,
})
}
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "build_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_-1019376945297712761 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/authorizedotnet.rs
// Function: verify_webhook_source
{
// If no webhook secret is provided, cannot verify
let webhook_secret = match connector_webhook_secret {
Some(secrets) => secrets.secret,
None => return Ok(false),
};
// Extract X-ANET-Signature header (case-insensitive)
let signature_header = match request
.headers
.get("X-ANET-Signature")
.or_else(|| request.headers.get("x-anet-signature"))
{
Some(header) => header,
None => {
tracing::warn!(
target: "authorizedotnet_webhook",
"Missing X-ANET-Signature header in webhook request from Authorize.Net - verification failed but continuing processing"
);
return Ok(false); // Missing signature -> verification fails but continue processing
}
};
// Parse "sha512=<hex>" format
let signature_hex = match signature_header.strip_prefix("sha512=") {
Some(hex) => hex,
None => {
tracing::warn!(
target: "authorizedotnet_webhook",
"Invalid signature format in X-ANET-Signature header, expected 'sha512=<hex>' but got: '{}' - verification failed but continuing processing",
signature_header
);
return Ok(false); // Invalid format -> verification fails but continue processing
}
};
// Decode hex signature
let expected_signature = match hex::decode(signature_hex) {
Ok(sig) => sig,
Err(hex_error) => {
tracing::warn!(
target: "authorizedotnet_webhook",
"Failed to decode hex signature from X-ANET-Signature header: '{}', error: {} - verification failed but continuing processing",
signature_hex,
hex_error
);
return Ok(false); // Invalid hex -> verification fails but continue processing
}
};
// Compute HMAC-SHA512 of request body
use common_utils::crypto::{HmacSha512, SignMessage};
let crypto_algorithm = HmacSha512;
let computed_signature = match crypto_algorithm.sign_message(&webhook_secret, &request.body)
{
Ok(sig) => sig,
Err(crypto_error) => {
tracing::error!(
target: "authorizedotnet_webhook",
"Failed to compute HMAC-SHA512 signature for webhook verification, error: {:?} - verification failed but continuing processing",
crypto_error
);
return Ok(false); // Crypto error -> verification fails but continue processing
}
};
// Constant-time comparison to prevent timing attacks
Ok(computed_signature == expected_signature)
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "verify_webhook_source",
"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_-6429782132288584706 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/authorizedotnet.rs
// Function: get_event_type
{
let webhook_body: AuthorizedotnetWebhookEventType = request
.body
.parse_struct("AuthorizedotnetWebhookEventType")
.change_context(ConnectorError::WebhookEventTypeNotFound)
.attach_printable_lazy(|| {
"Failed to parse webhook event type from Authorize.Net webhook body"
})?;
Ok(match webhook_body.event_type {
transformers::AuthorizedotnetIncomingWebhookEventType::AuthorizationCreated => {
EventType::PaymentIntentAuthorizationSuccess
}
transformers::AuthorizedotnetIncomingWebhookEventType::PriorAuthCapture
| transformers::AuthorizedotnetIncomingWebhookEventType::CaptureCreated => {
EventType::PaymentIntentCaptureSuccess
}
transformers::AuthorizedotnetIncomingWebhookEventType::AuthCapCreated => {
EventType::PaymentIntentSuccess // Combined auth+capture
}
transformers::AuthorizedotnetIncomingWebhookEventType::VoidCreated => {
EventType::PaymentIntentCancelled
}
transformers::AuthorizedotnetIncomingWebhookEventType::RefundCreated => {
EventType::RefundSuccess
}
transformers::AuthorizedotnetIncomingWebhookEventType::CustomerCreated
| transformers::AuthorizedotnetIncomingWebhookEventType::CustomerPaymentProfileCreated => {
EventType::MandateActive
}
transformers::AuthorizedotnetIncomingWebhookEventType::Unknown => {
tracing::warn!(
target: "authorizedotnet_webhook",
"Received unknown webhook event type from Authorize.Net - rejecting webhook"
);
return Err(
error_stack::report!(ConnectorError::WebhookEventTypeNotFound)
.attach_printable("Unknown webhook event type"),
)
}
})
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_event_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_-2219996987668904238 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/authorizedotnet.rs
// Function: process_payment_webhook
{
let request_body_copy = request.body.clone();
let webhook_body: AuthorizedotnetWebhookObjectId = request
.body
.parse_struct("AuthorizedotnetWebhookObjectId")
.change_context(ConnectorError::WebhookResourceObjectNotFound)
.attach_printable_lazy(|| {
"Failed to parse Authorize.Net payment webhook body structure"
})?;
let transaction_id = get_trans_id(&webhook_body).attach_printable_lazy(|| {
format!(
"Failed to extract transaction ID from payment webhook for event: {:?}",
webhook_body.event_type
)
})?;
let status = transformers::SyncStatus::from(webhook_body.event_type.clone());
Ok(WebhookDetailsResponse {
resource_id: Some(ResponseId::ConnectorTransactionId(transaction_id.clone())),
status: common_enums::AttemptStatus::from(status),
status_code: 200,
mandate_reference: None,
connector_response_reference_id: Some(transaction_id),
error_code: None,
error_message: None,
raw_connector_response: Some(String::from_utf8_lossy(&request_body_copy).to_string()),
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": "process_payment_webhook",
"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_-2292690856165331702 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/authorizedotnet.rs
// Function: process_refund_webhook
{
let request_body_copy = request.body.clone();
let webhook_body: AuthorizedotnetWebhookObjectId = request
.body
.parse_struct("AuthorizedotnetWebhookObjectId")
.change_context(ConnectorError::WebhookResourceObjectNotFound)
.attach_printable_lazy(|| {
"Failed to parse Authorize.Net refund webhook body structure"
})?;
let transaction_id = get_trans_id(&webhook_body).attach_printable_lazy(|| {
format!(
"Failed to extract transaction ID from refund webhook for event: {:?}",
webhook_body.event_type
)
})?;
Ok(RefundWebhookDetailsResponse {
connector_refund_id: Some(transaction_id.clone()),
status: common_enums::RefundStatus::Success, // Authorize.Net only sends successful refund webhooks
status_code: 200,
connector_response_reference_id: Some(transaction_id),
error_code: None,
error_message: None,
raw_connector_response: Some(String::from_utf8_lossy(&request_body_copy).to_string()),
response_headers: None,
})
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "process_refund_webhook",
"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_4332481879722836047 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/authorizedotnet.rs
// Function: build_error_response
{
let response: transformers::ResponseMessages = res
.response
.parse_struct("ResponseMessages")
.map_err(|_| ConnectorError::ResponseDeserializationFailed)?;
with_response_body!(event_builder, response);
Ok(ErrorResponse {
status_code: res.status_code,
code: response
.message
.first()
.map(|m| m.code.clone())
.unwrap_or_else(|| consts::NO_ERROR_CODE.to_string()),
message: response
.message
.first()
.map(|m| m.text.clone())
.unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()),
reason: None,
attempt_status: None,
connector_transaction_id: None,
network_decline_code: None,
network_advice_code: None,
network_error_message: None,
})
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "build_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_3297076432563105908 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/authorizedotnet.rs
// Function: get_request_body
{
// This is a placeholder implementation
// The actual refund logic should be handled by specific implementations
Err(ConnectorError::NotImplemented("Refund not implemented for generic type".into()).into())
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_request_body",
"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_1149203201784082838 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/payload.rs
// Function: get_auth_header
{
let auth = payload::PayloadAuthType::try_from(auth_type)
.change_context(errors::ConnectorError::FailedToObtainAuthType)?;
// The API key is the same for all currencies, so we can take any.
let api_key = auth
.auths
.values()
.next()
.ok_or(errors::ConnectorError::FailedToObtainAuthType)?
.api_key
.clone();
let encoded_api_key = BASE64_ENGINE.encode(format!("{}:", api_key.expose()));
Ok(vec![(
headers::AUTHORIZATION.to_string(),
format!("Basic {encoded_api_key}").into_masked(),
)])
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_auth_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_4305318005823475314 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/payload.rs
// Function: build_error_response
{
let response: PayloadErrorResponse = res
.response
.parse_struct("PayloadErrorResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
with_error_response_body!(event_builder, response);
Ok(ErrorResponse {
status_code: res.status_code,
code: response.error_type,
message: response.error_description,
reason: response
.details
.as_ref()
.map(|details_value| details_value.to_string()),
attempt_status: None,
connector_transaction_id: None,
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
})
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "build_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_-7458802218834735305 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/payload.rs
// Function: get_webhook_source_verification_signature
{
let signature = request
.headers
.get(headers::X_PAYLOAD_SIGNATURE)
.map(|header_value| header_value.as_bytes().to_vec())
.ok_or(errors::ConnectorError::WebhookSourceVerificationFailed)?;
Ok(signature)
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_webhook_source_verification_signature",
"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_-3825368285375067169 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/payload.rs
// Function: verify_webhook_source
{
let algorithm = common_utils::crypto::Sha256;
let connector_webhook_secrets = match connector_webhook_secret {
Some(secrets) => secrets,
None => {
return Ok(false);
}
};
let signature = self
.get_webhook_source_verification_signature(&request, &connector_webhook_secrets)
.change_context(errors::ConnectorError::WebhookSourceVerificationFailed)?;
let message = self
.get_webhook_source_verification_message(&request, &connector_webhook_secrets)
.change_context(errors::ConnectorError::WebhookSourceVerificationFailed)?;
algorithm
.verify_signature(&connector_webhook_secrets.secret, &signature, &message)
.change_context(errors::ConnectorError::WebhookSourceVerificationFailed)
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "verify_webhook_source",
"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_-6117839938170545747 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/payload.rs
// Function: get_event_type
{
let webhook_body: transformers::PayloadWebhookEvent = request
.body
.parse_struct("PayloadWebhookEvent")
.change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?;
Ok(transformers::get_event_type_from_trigger(
webhook_body.trigger,
))
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_event_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_3679372211755775360 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/payload.rs
// Function: get_webhook_resource_object
{
let webhook_body: transformers::PayloadWebhookEvent = request
.body
.parse_struct("PayloadWebhookEvent")
.change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?;
Ok(Box::new(webhook_body))
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_webhook_resource_object",
"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_-8584907116032210648 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/trustpay.rs
// Function: build_error_response
{
let response: Result<TrustpayErrorResponse, Report<common_utils::errors::ParsingError>> =
res.response.parse_struct("trustpay ErrorResponse");
match response {
Ok(response_data) => {
if let Some(i) = event_builder {
i.set_connector_response(&response_data);
}
let reason = response_data.errors.map(|errors| {
errors
.iter()
.map(|error| error.description.clone())
.collect::<Vec<String>>()
.join(" & ")
});
Ok(ErrorResponse {
status_code: res.status_code,
code: consts::NO_ERROR_CODE.to_string(),
message: consts::NO_ERROR_CODE.to_string(),
reason: reason
.or(response_data.description)
.or(response_data.payment_description),
attempt_status: None,
connector_transaction_id: response_data.instance_id,
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
})
}
Err(error_msg) => {
if let Some(event) = event_builder {
event.set_connector_response(&serde_json::json!({"error": "Error response parsing failed", "status_code": res.status_code}))
};
tracing::error!(deserialization_error =? error_msg);
domain_types::utils::handle_json_response_deserialization_failure(res, "trustpay")
}
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "build_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_8439462769836917282 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/placetopay.rs
// Function: build_error_response
{
let response: placetopay::PlacetopayErrorResponse = res
.response
.parse_struct("PlacetopayErrorResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
with_error_response_body!(event_builder, response);
Ok(ErrorResponse {
status_code: res.status_code,
code: response
.status
.reason
.unwrap_or_else(|| NO_ERROR_CODE.to_string()),
message: response
.status
.message
.clone()
.unwrap_or_else(|| NO_ERROR_MESSAGE.to_string()),
reason: response.status.message,
attempt_status: None,
connector_transaction_id: None,
network_decline_code: None,
network_advice_code: None,
network_error_message: None,
})
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "build_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_-4538026060445534962 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/helcim/transformers.rs
// Function: check_currency
{
if currency == common_enums::Currency::USD {
Ok(currency)
} else {
Err(errors::ConnectorError::NotSupported {
message: format!("currency {currency} is not supported for this merchant account"),
connector: "Helcim",
})?
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "check_currency",
"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_-6984681284988699009 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/helcim/transformers.rs
// Function: try_from
{
Ok(Self {
response: Ok(RefundsResponseData {
connector_refund_id: item.response.transaction_id.to_string(),
refund_status: common_enums::RefundStatus::from(item.response),
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_3422008630065729510 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/helcim/transformers.rs
// Function: from
{
match item.transaction_type {
HelcimRefundTransactionType::Refund => match item.status {
HelcimPaymentStatus::Approved => Self::Success,
HelcimPaymentStatus::Declined => Self::Failure,
},
}
}
| {
"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_-4321416530944177081 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/braintree/transformers.rs
// Function: try_from
{
let reference_id = Some(
item.router_data
.resource_common_data
.connector_request_reference_id
.clone(),
);
let order_id = reference_id.ok_or(
errors::ConnectorError::MissingConnectorRelatedTransactionID {
id: "order_id".to_string(),
},
)?;
let amount = item
.connector
.amount_converter
.convert(
item.router_data.request.minor_amount,
item.router_data.request.currency,
)
.change_context(ConnectorError::AmountConversionFailed)?;
let (query, transaction_body) = if item.router_data.request.is_mandate_payment() {
(
if item.router_data.request.is_auto_capture()? {
constants::CHARGE_AND_VAULT_TRANSACTION_MUTATION.to_string()
} else {
constants::AUTHORIZE_AND_VAULT_CREDIT_CARD_MUTATION.to_string()
},
TransactionBody::Vault(VaultTransactionBody {
amount,
merchant_account_id: metadata.merchant_account_id,
vault_payment_method_after_transacting: TransactionTiming {
when: "ALWAYS".to_string(),
},
customer_details: item
.router_data
.resource_common_data
.get_billing_email()
.ok()
.map(|email| CustomerBody { email }),
order_id,
}),
)
} else {
(
if item.router_data.request.is_auto_capture()? {
constants::CHARGE_CREDIT_CARD_MUTATION.to_string()
} else {
constants::AUTHORIZE_CREDIT_CARD_MUTATION.to_string()
},
TransactionBody::Regular(RegularTransactionBody {
amount,
merchant_account_id: metadata.merchant_account_id,
channel: constants::CHANNEL_CODE.to_string(),
customer_details: item
.router_data
.resource_common_data
.get_billing_email()
.ok()
.map(|email| CustomerBody { email }),
order_id,
}),
)
};
Ok(Self {
query,
variables: VariablePaymentInput {
input: PaymentInput {
payment_method_id: match item
.router_data
.resource_common_data
.get_payment_method_token()?
{
PaymentMethodTokenFlow::Token(token) => token,
PaymentMethodTokenFlow::ApplePayDecrypt(_) => Err(
unimplemented_payment_method!("Apple Pay", "Simplified", "Braintree"),
)?,
PaymentMethodTokenFlow::PazeDecrypt(_) => {
Err(unimplemented_payment_method!("Paze", "Braintree"))?
}
PaymentMethodTokenFlow::GooglePayDecrypt(_) => {
Err(unimplemented_payment_method!("Google Pay", "Braintree"))?
}
},
transaction: transaction_body,
},
},
})
}
| {
"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_1904185500043067894 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/braintree/transformers.rs
// Function: build_error_response
{
let error_messages = response
.iter()
.map(|error| error.message.to_string())
.collect::<Vec<String>>();
let reason = match !error_messages.is_empty() {
true => Some(error_messages.join(" ")),
false => None,
};
get_error_response(
response
.first()
.and_then(|err_details| err_details.extensions.as_ref())
.and_then(|extensions| extensions.legacy_code.clone()),
response
.first()
.map(|err_details| err_details.message.clone()),
reason,
http_code,
)
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "build_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_-6761038712963536350 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/braintree/transformers.rs
// Function: get_error_response
{
Err(Box::new(domain_types::router_data::ErrorResponse {
code: error_code.unwrap_or_else(|| NO_ERROR_CODE.to_string()),
message: error_msg.unwrap_or_else(|| NO_ERROR_MESSAGE.to_string()),
reason: error_reason,
status_code: http_code,
attempt_status: None,
connector_transaction_id: None,
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
}))
}
| {
"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_-7817174023340429534 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/braintree/transformers.rs
// Function: create_failure_error_response
{
let status_string = status.to_string();
domain_types::router_data::ErrorResponse {
code: status_string.clone(),
message: status_string.clone(),
reason: Some(status_string),
attempt_status: None,
connector_transaction_id: connector_id,
status_code: http_code,
network_advice_code: None,
network_decline_code: None,
network_error_message: None,
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_failure_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_-8268771788428002779 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/braintree/transformers.rs
// Function: from
{
match item {
BraintreeRefundStatus::Settled
| BraintreeRefundStatus::Settling
| BraintreeRefundStatus::SubmittedForSettlement
| BraintreeRefundStatus::SettlementPending => Self::Success,
BraintreeRefundStatus::Failed => Self::Failure,
}
}
| {
"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_483564631913249337 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/braintree/transformers.rs
// Function: extract_metadata_field
{
metadata
.as_ref()
.and_then(|metadata| {
let exposed = metadata.clone().expose();
exposed
.get(field_name)
.and_then(|v| v.as_str())
.and_then(|s| s.parse().ok())
})
.ok_or_else(|| errors::ConnectorError::MissingRequiredField { field_name }.into())
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "extract_metadata_field",
"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_3195557981787106941 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/braintree/transformers.rs
// Function: extract_metadata_string_field
{
metadata
.as_ref()
.and_then(|metadata| {
let exposed = metadata.clone().expose();
exposed
.get(field_name)
.and_then(|v| v.as_str())
.map(|s| Secret::new(s.to_string()))
})
.ok_or_else(|| errors::ConnectorError::MissingRequiredField { field_name }.into())
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "extract_metadata_string_field",
"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_8831325716289253065 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/braintree/transformers.rs
// Function: get_card_isin_from_payment_method_data
{
match card_details {
PaymentMethodData::Card(card_data) => {
let card_number_str = format!("{:?}", card_data.card_number.0);
let cleaned_number = card_number_str
.chars()
.filter(|c| c.is_ascii_digit())
.take(6)
.collect::<String>();
Ok(cleaned_number)
}
_ => Err(errors::ConnectorError::NotImplemented("given payment method".to_owned()).into()),
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_card_isin_from_payment_method_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_660694642381827870 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/braintree/transformers.rs
// Function: get_braintree_redirect_form
{
Ok(RedirectForm::Braintree {
client_token: client_token_data
.data
.create_client_token
.client_token
.expose(),
card_token: match payment_method_token {
PaymentMethodTokenFlow::Token(token) => token.expose(),
PaymentMethodTokenFlow::ApplePayDecrypt(_) => Err(unimplemented_payment_method!(
"Apple Pay",
"Simplified",
"Braintree"
))?,
PaymentMethodTokenFlow::PazeDecrypt(_) => {
Err(unimplemented_payment_method!("Paze", "Braintree"))?
}
PaymentMethodTokenFlow::GooglePayDecrypt(_) => {
Err(unimplemented_payment_method!("Google Pay", "Braintree"))?
}
},
bin: match card_details {
PaymentMethodData::Card(_) => get_card_isin_from_payment_method_data(&card_details)?,
PaymentMethodData::CardRedirect(_)
| PaymentMethodData::Wallet(_)
| PaymentMethodData::PayLater(_)
| PaymentMethodData::BankRedirect(_)
| PaymentMethodData::BankDebit(_)
| PaymentMethodData::BankTransfer(_)
| PaymentMethodData::Crypto(_)
| PaymentMethodData::MandatePayment
| PaymentMethodData::OpenBanking(_)
| PaymentMethodData::Reward
| PaymentMethodData::RealTimePayment(_)
| PaymentMethodData::MobilePayment(_)
| PaymentMethodData::Upi(_)
| PaymentMethodData::Voucher(_)
| PaymentMethodData::GiftCard(_)
| PaymentMethodData::CardToken(_)
| PaymentMethodData::NetworkToken(_)
| PaymentMethodData::CardDetailsForNetworkTransactionId(_) => Err(
errors::ConnectorError::NotImplemented("given payment method".to_owned()),
)?,
},
acs_url: complete_authorize_url,
})
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_braintree_redirect_form",
"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_-4509922505890427308 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/braintree/transformers.rs
// Function: validate_currency
{
let merchant_config_currency =
merchant_config_currency.ok_or(errors::ConnectorError::NoConnectorMetaData)?;
if request_currency != merchant_config_currency {
Err(errors::ConnectorError::NotSupported {
message: format!(
"currency {request_currency} is not supported for this merchant account",
),
connector: "Braintree",
})?
}
Ok(())
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "validate_currency",
"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_-3077146323451367751 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/worldpay/response.rs
// Function: fmt
{
match self {
Self::Authorized => write!(f, "authorized"),
Self::Refused => write!(f, "refused"),
Self::SentForSettlement => write!(f, "sentForSettlement"),
Self::SentForRefund => write!(f, "sentForRefund"),
Self::FraudHighRisk => write!(f, "fraudHighRisk"),
Self::ThreeDsDeviceDataRequired => write!(f, "3dsDeviceDataRequired"),
Self::SentForCancellation => write!(f, "sentForCancellation"),
Self::ThreeDsAuthenticationFailed => write!(f, "3dsAuthenticationFailed"),
Self::SentForPartialRefund => write!(f, "sentForPartialRefund"),
Self::ThreeDsChallenged => write!(f, "3dsChallenged"),
Self::ThreeDsUnavailable => write!(f, "3dsUnavailable"),
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "fmt",
"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_-3524783540640719383 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/worldpay/response.rs
// Function: get_resource_id
{
// First check top-level _links (for capture, authorize, etc.)
let optional_reference_id = response
.links
.as_ref()
.and_then(|link| link.self_link.href.rsplit_once('/').map(|(_, h)| h))
.or_else(|| {
// Fallback to variant-specific logic for DDC and 3DS challenges
response
.other_fields
.as_ref()
.and_then(|other_fields| match other_fields {
WorldpayPaymentResponseFields::DDCResponse(res) => {
res.actions.supply_ddc_data.href.split('/').nth_back(1)
}
WorldpayPaymentResponseFields::ThreeDsChallenged(res) => res
.actions
.complete_three_ds_challenge
.href
.split('/')
.nth_back(1),
_ => None,
})
})
.map(|href| {
urlencoding::decode(href)
.map(|s| transform_fn(s.into_owned()))
.change_context(errors::ConnectorError::ResponseHandlingFailed)
})
.transpose()?;
optional_reference_id
.or_else(|| response.transaction_reference.map(&transform_fn))
.or_else(|| connector_transaction_id.map(&transform_fn))
.ok_or_else(|| {
errors::ConnectorError::MissingRequiredField {
field_name: "_links.self.href or transactionReference",
}
.into()
})
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_resource_id",
"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_-8949055349067764251 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/worldpay/response.rs
// Function: default
{
match status_code {
code @ 404 => Self {
error_name: format!("{code} Not found"),
message: "Resource not found".to_string(),
validation_errors: None,
},
code => Self {
error_name: code.to_string(),
message: "Unknown error".to_string(),
validation_errors: None,
},
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "default",
"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_-6870044579557088761 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/worldpay/transformers.rs
// Function: try_from
{
let status = enums::AttemptStatus::from(item.response.outcome.clone());
let (_redirection_data, connector_response_reference_id) =
extract_redirection_data(&item.response)?;
let _connector_metadata = extract_three_ds_metadata(&item.response);
let response = Ok(PaymentsResponseData::PostAuthenticateResponse {
authentication_data: None,
connector_response_reference_id,
status_code: item.http_code,
});
Ok(Self {
resource_common_data: PaymentFlowData {
status,
..item.router_data.resource_common_data
},
response,
..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_5057857530063268768 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/worldpay/transformers.rs
// Function: fetch_payment_instrument
{
match payment_method {
PaymentMethodData::Card(card) => {
// Extract expiry month and year using helper functions
let expiry_month_i8 = card.get_expiry_month_as_i8()?;
let expiry_year_4_digit = card.get_expiry_year_4_digit();
let expiry_year: i32 = expiry_year_4_digit
.peek()
.parse::<i32>()
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
Ok(PaymentInstrument::Card(CardPayment {
raw_card_details: RawCardDetails {
payment_type: PaymentType::Plain,
expiry_date: ExpiryDate {
month: expiry_month_i8,
year: Secret::new(expiry_year),
},
card_number: card.card_number,
},
cvc: card.card_cvc,
card_holder_name: billing_address
.and_then(|address| address.get_optional_full_name()),
billing_address: billing_address
.and_then(|addr| addr.address.clone())
.and_then(|address| {
match (address.line1, address.city, address.zip, address.country) {
(Some(address1), Some(city), Some(postal_code), Some(country_code)) => {
Some(BillingAddress {
address1,
address2: address.line2,
address3: address.line3,
city,
state: address.state,
postal_code,
country_code,
})
}
_ => None,
}
}),
}))
}
PaymentMethodData::CardDetailsForNetworkTransactionId(raw_card_details) => {
// Extract expiry month and year using helper functions
let expiry_month_i8 = raw_card_details.get_expiry_month_as_i8()?;
let expiry_year_4_digit = raw_card_details.get_expiry_year_4_digit();
let expiry_year: i32 = expiry_year_4_digit
.peek()
.parse::<i32>()
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
Ok(PaymentInstrument::RawCardForNTI(RawCardDetails {
payment_type: PaymentType::Plain,
expiry_date: ExpiryDate {
month: expiry_month_i8,
year: Secret::new(expiry_year),
},
card_number: RawCardNumber(raw_card_details.card_number),
}))
}
PaymentMethodData::MandatePayment => {
Err(errors::ConnectorError::NotImplemented(
"MandatePayment should not be used in Authorize flow - use RepeatPayment flow for MIT transactions".to_string()
).into())
}
PaymentMethodData::Wallet(wallet) => match wallet {
WalletDataPaymentMethod::GooglePay(data) => {
Ok(PaymentInstrument::Googlepay(WalletPayment {
payment_type: PaymentType::Encrypted,
wallet_token: Secret::new(
data.tokenization_data
.get_encrypted_google_pay_token()
.change_context(errors::ConnectorError::MissingRequiredField {
field_name: "gpay wallet_token",
})?,
),
..WalletPayment::default()
}))
}
WalletDataPaymentMethod::ApplePay(data) => {
Ok(PaymentInstrument::Applepay(WalletPayment {
payment_type: PaymentType::Encrypted,
wallet_token: data.get_applepay_decoded_payment_data()?,
..WalletPayment::default()
}))
}
WalletDataPaymentMethod::AliPayQr(_)
| WalletDataPaymentMethod::AliPayRedirect(_)
| WalletDataPaymentMethod::AliPayHkRedirect(_)
| WalletDataPaymentMethod::AmazonPayRedirect(_)
| WalletDataPaymentMethod::MomoRedirect(_)
| WalletDataPaymentMethod::KakaoPayRedirect(_)
| WalletDataPaymentMethod::GoPayRedirect(_)
| WalletDataPaymentMethod::GcashRedirect(_)
| WalletDataPaymentMethod::ApplePayRedirect(_)
| WalletDataPaymentMethod::ApplePayThirdPartySdk(_)
| WalletDataPaymentMethod::DanaRedirect {}
| WalletDataPaymentMethod::GooglePayRedirect(_)
| WalletDataPaymentMethod::GooglePayThirdPartySdk(_)
| WalletDataPaymentMethod::MbWayRedirect(_)
| WalletDataPaymentMethod::MobilePayRedirect(_)
| WalletDataPaymentMethod::PaypalRedirect(_)
| WalletDataPaymentMethod::PaypalSdk(_)
| WalletDataPaymentMethod::Paze(_)
| WalletDataPaymentMethod::SamsungPay(_)
| WalletDataPaymentMethod::TwintRedirect {}
| WalletDataPaymentMethod::VippsRedirect {}
| WalletDataPaymentMethod::TouchNGoRedirect(_)
| WalletDataPaymentMethod::WeChatPayRedirect(_)
| WalletDataPaymentMethod::CashappQr(_)
| WalletDataPaymentMethod::SwishQr(_)
| WalletDataPaymentMethod::WeChatPayQr(_)
| WalletDataPaymentMethod::Mifinity(_)
| WalletDataPaymentMethod::RevolutPay(_)
| WalletDataPaymentMethod::BluecodeRedirect {} => {
Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("worldpay"),
)
.into())
}
},
PaymentMethodData::PayLater(_)
| PaymentMethodData::BankRedirect(_)
| PaymentMethodData::BankDebit(_)
| PaymentMethodData::BankTransfer(_)
| PaymentMethodData::Crypto(_)
| PaymentMethodData::Reward
| PaymentMethodData::RealTimePayment(_)
| PaymentMethodData::MobilePayment(_)
| PaymentMethodData::Upi(_)
| PaymentMethodData::Voucher(_)
| PaymentMethodData::CardRedirect(_)
| PaymentMethodData::GiftCard(_)
| PaymentMethodData::OpenBanking(_)
| PaymentMethodData::CardToken(_)
| PaymentMethodData::NetworkToken(_) => Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("worldpay"),
)
.into()),
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "fetch_payment_instrument",
"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_2092038884879643199 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/worldpay/transformers.rs
// Function: create_three_ds_request
{
match (
&router_data.resource_common_data.auth_type,
&router_data.request.payment_method_data,
) {
// 3DS for NTI flow
(_, PaymentMethodData::CardDetailsForNetworkTransactionId(_)) => Ok(None),
// 3DS for regular payments
(enums::AuthenticationType::ThreeDs, _) => {
let browser_info = router_data.request.browser_info.as_ref().ok_or(
errors::ConnectorError::MissingRequiredField {
field_name: "browser_info",
},
)?;
let accept_header = browser_info
.accept_header
.clone()
.get_required_value("accept_header")
.change_context(errors::ConnectorError::MissingRequiredField {
field_name: "accept_header",
})?;
let user_agent_header = browser_info
.user_agent
.clone()
.get_required_value("user_agent")
.change_context(errors::ConnectorError::MissingRequiredField {
field_name: "user_agent",
})?;
let channel = Some(ThreeDSRequestChannel::Browser);
Ok(Some(ThreeDSRequest {
three_ds_type: super::requests::THREE_DS_TYPE.to_string(),
mode: super::requests::THREE_DS_MODE.to_string(),
device_data: ThreeDSRequestDeviceData {
accept_header,
user_agent_header,
browser_language: browser_info.language.clone(),
browser_screen_width: browser_info.screen_width,
browser_screen_height: browser_info.screen_height,
browser_color_depth: browser_info.color_depth.map(|depth| depth.to_string()),
time_zone: browser_info.time_zone.map(|tz| tz.to_string()),
browser_java_enabled: browser_info.java_enabled,
browser_javascript_enabled: browser_info.java_script_enabled,
channel,
},
challenge: ThreeDSRequestChallenge {
return_url: router_data.request.get_complete_authorize_url()?,
preference: if is_mandate_payment {
Some(super::requests::THREE_DS_CHALLENGE_PREFERENCE.to_string())
} else {
None
},
},
}))
}
// Non 3DS
_ => Ok(None),
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "create_three_ds_request",
"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_-7406223009684672156 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/worldpay/transformers.rs
// Function: get_settlement_info
{
match router_data.request.capture_method.unwrap_or_default() {
_ if amount == MinorUnit::zero() => None,
enums::CaptureMethod::Automatic | enums::CaptureMethod::SequentialAutomatic => {
Some(AutoSettlement { auto: true })
}
enums::CaptureMethod::Manual | enums::CaptureMethod::ManualMultiple => {
Some(AutoSettlement { auto: false })
}
_ => None,
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_settlement_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_-6268339382331430753 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/worldpay/transformers.rs
// Function: get_token_and_agreement
{
match (payment_method_data, setup_future_usage, off_session) {
// CIT - Setup for future usage (creates token for future MIT via RepeatPayment)
(PaymentMethodData::Card(_), Some(enums::FutureUsage::OffSession), _) => (
Some(TokenCreation {
token_type: TokenCreationType::Worldpay,
}),
Some(CustomerAgreement {
agreement_type: CustomerAgreementType::Subscription,
stored_card_usage: Some(StoredCardUsageType::First),
scheme_reference: None,
}),
),
// NTI with raw card data
(PaymentMethodData::CardDetailsForNetworkTransactionId(_), _, _) => (
None,
mandate_ids.and_then(|mandate_ids| {
mandate_ids
.mandate_reference_id
.and_then(|mandate_id| match mandate_id {
MandateReferenceId::NetworkMandateId(network_transaction_id) => {
Some(CustomerAgreement {
agreement_type: CustomerAgreementType::Unscheduled,
scheme_reference: Some(network_transaction_id.into()),
stored_card_usage: None,
})
}
_ => None,
})
}),
),
_ => (None, None),
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_token_and_agreement",
"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_4046033018174556701 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/worldpay/transformers.rs
// Function: from
{
match value {
EventType::Refunded | EventType::SentForRefund => Self::Success,
EventType::RefundFailed => Self::Failure,
EventType::Authorized
| EventType::Cancelled
| EventType::Settled
| EventType::Refused
| EventType::Error
| EventType::SentForSettlement
| EventType::SentForAuthorization
| EventType::SettlementFailed
| EventType::Expired
| EventType::Unknown => Self::Pending,
}
}
| {
"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_4513066018639816036 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/worldpay/transformers.rs
// Function: extract_redirection_data
{
match &response.other_fields {
Some(WorldpayPaymentResponseFields::ThreeDsChallenged(challenged)) => {
let redirect_form = RedirectForm::Form {
endpoint: challenged.challenge.url.to_string(),
method: common_utils::request::Method::Post,
form_fields: std::collections::HashMap::from([(
"JWT".to_string(),
challenged.challenge.jwt.clone().expose(),
)]),
};
Ok((
Some(redirect_form),
Some(challenged.challenge.reference.clone()),
))
}
Some(WorldpayPaymentResponseFields::DDCResponse(ddc)) => {
let link_data = ddc
.actions
.supply_ddc_data
.href
.split('/')
.nth_back(1)
.map(|s| s.to_string());
let redirect_form = RedirectForm::WorldpayDDCForm {
endpoint: ddc.device_data_collection.url.clone(),
method: common_utils::request::Method::Post,
collection_id: link_data,
form_fields: std::collections::HashMap::from([
(
FORM_FIELD_BIN.to_string(),
ddc.device_data_collection.bin.clone().expose(),
),
(
FORM_FIELD_JWT.to_string(),
ddc.device_data_collection.jwt.clone().expose(),
),
]),
};
Ok((
Some(redirect_form),
Some(METADATA_DDC_REFERENCE.to_string()),
))
}
_ => Ok((None, None)),
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "extract_redirection_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_5018237074213886487 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/worldpay/transformers.rs
// Function: extract_three_ds_metadata
{
match &response.other_fields {
Some(WorldpayPaymentResponseFields::RefusedResponse(refused)) => {
// Check for 3DS data in refused response
if let Some(three_ds) = &refused.three_ds {
let mut metadata = serde_json::Map::new();
if let Some(version) = &three_ds.version {
metadata.insert(
METADATA_3DS_VERSION.to_string(),
serde_json::Value::String(version.clone()),
);
}
if let Some(eci) = &three_ds.eci {
metadata.insert(
METADATA_ECI.to_string(),
serde_json::Value::String(eci.clone()),
);
}
if let Some(applied) = &three_ds.applied {
metadata.insert(
METADATA_AUTH_APPLIED.to_string(),
serde_json::Value::String(applied.clone()),
);
}
if !metadata.is_empty() {
return Some(serde_json::Value::Object(metadata));
}
}
None
}
Some(WorldpayPaymentResponseFields::ThreeDsChallenged(challenged)) => {
let mut metadata = serde_json::Map::new();
metadata.insert(
METADATA_3DS_VERSION.to_string(),
serde_json::Value::String(challenged.authentication.version.clone()),
);
if let Some(eci) = &challenged.authentication.eci {
metadata.insert(
METADATA_ECI.to_string(),
serde_json::Value::String(eci.clone()),
);
}
// Extract linkData and stage for Authenticate response with 3DS challenge
if let Some(link_data) = challenged
.actions
.complete_three_ds_challenge
.href
.split('/')
.nth_back(1)
{
metadata.insert(
"link_data".to_string(),
serde_json::Value::String(link_data.to_string()),
);
metadata.insert(
"3ds_stage".to_string(),
serde_json::Value::String("challenge".to_string()),
);
}
Some(serde_json::Value::Object(metadata))
}
Some(WorldpayPaymentResponseFields::DDCResponse(ddc)) => {
// Extract linkData and stage for Authenticate response with DDC
let mut metadata = serde_json::Map::new();
if let Some(link_data) = ddc.actions.supply_ddc_data.href.split('/').nth_back(1) {
metadata.insert(
"link_data".to_string(),
serde_json::Value::String(link_data.to_string()),
);
metadata.insert(
"3ds_stage".to_string(),
serde_json::Value::String("ddc".to_string()),
);
}
if !metadata.is_empty() {
Some(serde_json::Value::Object(metadata))
} else {
None
}
}
_ => None,
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "extract_three_ds_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_-2123970909380419765 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/payu/transformers.rs
// Function: deserialize_payu_status
{
use serde_json::Value;
let value: Option<Value> = Option::deserialize(deserializer)?;
match value {
Some(Value::Number(n)) => {
if let Some(i) = n.as_i64() {
Ok(Some(PayuStatusValue::IntStatus(i as i32)))
} else {
Ok(None)
}
}
Some(Value::String(s)) => Ok(Some(PayuStatusValue::StringStatus(s))),
_ => Ok(None),
}
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "deserialize_payu_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_2420171303857288176 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/payu/transformers.rs
// Function: try_from
{
let response = item.response;
let error_message = response
.msg
.unwrap_or_else(|| "PayU PSync error".to_string());
// Check PayU status field - 0 means error, 1 means success response structure
match (response.status, response.transaction_details) {
(Some(1), Some(transaction_details)) => {
// PayU returned success status, check transaction_details
// Try to find the transaction in the response by iterating through all transactions
// Since PayU returns transaction details as a map with txnid as key
let txn_detail = transaction_details.values().next();
let connector_transaction_id = txn_detail.and_then(|detail| detail.txnid.clone());
match (txn_detail, connector_transaction_id) {
(Some(txn_detail), Some(connector_transaction_id)) => {
// Found transaction details, map status
let attempt_status = map_payu_sync_status(&txn_detail.status, txn_detail);
let payment_response_data = PaymentsResponseData::TransactionResponse {
resource_id: ResponseId::ConnectorTransactionId(
connector_transaction_id.clone(),
),
redirection_data: None,
mandate_reference: None,
connector_metadata: None,
network_txn_id: txn_detail.field1.clone(), // UPI transaction ID
connector_response_reference_id: txn_detail.mihpayid.clone(),
incremental_authorization_allowed: None,
status_code: item.http_code,
};
Ok(Self {
response: Ok(payment_response_data),
resource_common_data: PaymentFlowData {
status: attempt_status,
..item.router_data.resource_common_data
},
..item.router_data
})
}
_ => {
// Transaction not found in PayU response
let error_response = ErrorResponse {
status_code: item.http_code,
code: "TRANSACTION_NOT_FOUND".to_string(),
message: error_message,
reason: None,
attempt_status: Some(AttemptStatus::Failure),
connector_transaction_id: None,
network_error_message: None,
network_advice_code: None,
network_decline_code: None,
};
Ok(Self {
response: Err(error_response),
resource_common_data: PaymentFlowData {
status: AttemptStatus::Failure,
..item.router_data.resource_common_data
},
..item.router_data
})
}
}
}
_ => {
// PayU returned error status
let error_response = ErrorResponse {
status_code: item.http_code,
code: "PAYU_SYNC_ERROR".to_string(),
message: error_message,
reason: None,
attempt_status: Some(AttemptStatus::Failure),
connector_transaction_id: None,
network_error_message: None,
network_advice_code: None,
network_decline_code: None,
};
Ok(Self {
response: Err(error_response),
resource_common_data: PaymentFlowData {
status: AttemptStatus::Failure,
..item.router_data.resource_common_data
},
..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_4643251440628525040 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/payu/transformers.rs
// Function: generate_payu_verify_hash
{
use sha2::{Digest, Sha512};
// PayU verify hash format: key|command|var1|salt
let hash_fields = [
request.key.clone(),
request.command.clone(),
request.var1.clone(),
merchant_salt.peek().to_string(),
];
// Join with pipe separator
let hash_string = hash_fields.join("|");
// Log hash string for debugging (remove in production)
#[cfg(debug_assertions)]
{
let masked_hash = format!(
"{}|***MASKED***",
hash_fields[..hash_fields.len() - 1].join("|")
);
tracing::debug!("PayU verify hash string (salt masked): {}", masked_hash);
tracing::debug!("PayU verify expected format: key|command|var1|salt");
}
// Generate SHA-512 hash
let mut hasher = Sha512::new();
hasher.update(hash_string.as_bytes());
let result = hasher.finalize();
Ok(hex::encode(result))
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "generate_payu_verify_hash",
"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_6892969105233692280 | clm | function_body | // connector-service/backend/connector-integration/src/connectors/payu/transformers.rs
// Function: generate_udf_fields
{
// Based on Haskell implementation:
// udf1-udf5 come from PayuMetaData (if available) or default values
// udf6-udf9 come from orderReference fields
// udf10 is always empty string
// Extract metadata from request
let metadata = router_data.request.metadata.as_ref();
// Helper function to get string value from metadata
let get_metadata_field = |field: &str| -> Option<String> {
metadata
.and_then(|m| m.get(field))
.and_then(|v| v.as_str())
.map(|s| s.to_string())
};
[
// udf1: From metadata "udf1" or default to transaction ID
get_metadata_field("udf1").or(Some(payment_id.to_string())),
// udf2: From metadata "udf2" or default to merchant ID
get_metadata_field("udf2").or(Some(merchant_id.to_string())),
// udf3: From metadata "udf3" or empty
get_metadata_field("udf3"),
// udf4: From metadata "udf4" or empty
get_metadata_field("udf4"),
// udf5: From metadata "udf5" or empty
get_metadata_field("udf5"),
// udf6: From metadata "udf6" or empty
get_metadata_field("udf6"),
// udf7: From metadata "udf7" or empty
get_metadata_field("udf7"),
// udf8: From metadata "udf8" or empty
get_metadata_field("udf8"),
// udf9: From metadata "udf9" or empty
get_metadata_field("udf9"),
// udf9: From metadata "udf10" or empty
get_metadata_field("udf10"),
]
}
| {
"chunk": null,
"crate": "connector-integration",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "generate_udf_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
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.