Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

fix(connector): [datatrans] fix void flow (#13432)

likhinbopanna1ec203baab36
diff --git a/crates/hyperswitch_connectors/src/connectors/datatrans.rs b/crates/hyperswitch_connectors/src/connectors/datatrans.rs
index f3a932b7cc..be17a17a8b 100644
--- a/crates/hyperswitch_connectors/src/connectors/datatrans.rs
+++ b/crates/hyperswitch_connectors/src/connectors/datatrans.rs
@@ -560,6 +560,18 @@ impl ConnectorIntegration<Void, PaymentsCancelData, PaymentsResponseData> for Da
Ok(format!("{base_url}v1/transactions/{transaction_id}/cancel"))
}
+ fn get_request_body(
+ &self,
+ _req: &PaymentsCancelRouterData,
+ _connectors: &Connectors,
+ ) -> CustomResult<RequestContent, errors::ConnectorError> {
+ // Datatrans cancel takes no fields; send an empty JSON object `{}` so the
+ // application/json body is valid and avoids `INVALID_JSON_PAYLOAD`.
+ Ok(RequestContent::Json(Box::new(
+ datatrans::DatatransCancelRequest {},
+ )))
+ }
+
fn build_request(
&self,
req: &PaymentsCancelRouterData,
diff --git a/crates/hyperswitch_connectors/src/connectors/datatrans/transformers.rs b/crates/hyperswitch_connectors/src/connectors/datatrans/transformers.rs
index 8cfe642d19..6f26648554 100644
--- a/crates/hyperswitch_connectors/src/connectors/datatrans/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/datatrans/transformers.rs
@@ -263,6 +263,12 @@ pub struct DataPaymentCaptureRequest {
pub refno: String,
}
+// Datatrans cancel expects an empty JSON object `{}` as the body when
+// Content-Type is application/json. Sending anything else (e.g. a bare JSON
+// string) triggers `INVALID_JSON_PAYLOAD`.
+#[derive(Debug, Serialize, Clone)]
+pub struct DatatransCancelRequest {}
+
impl<T> TryFrom<(MinorUnit, T)> for DatatransRouterData<T> {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from((amount, item): (MinorUnit, T)) -> Result<Self, Self::Error> {
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Datatrans.js b/cypress-tests/cypress/e2e/configs/Payment/Datatrans.js
index 9b562522e9..a6167c843f 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Datatrans.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Datatrans.js
@@ -46,10 +46,10 @@ const multiUseMandateData = {
const paymentMethodData3Ds = {
card: {
last4: "1111",
- card_type: "CREDIT",
+ card_type: "DEBIT",
card_network: "Visa",
- card_issuer: "JP Morgan",
- card_issuing_country: "INDIA",
+ card_issuer: "CONOTOXIA SP Z OO",
+ card_issuing_country: "POLAND",
card_isin: "411111",
card_extended_bin: null,
card_exp_month: "06",
@@ -57,6 +57,7 @@ const paymentMethodData3Ds = {
card_holder_name: "joseph Doe",
payment_checks: null,
authentication_data: null,
+ auth_code: null,
},
billing: null,
};
@@ -66,7 +67,7 @@ const paymentMethodDataNo3Ds = {
last4: "0018",
card_type: "CREDIT",
card_network: "Visa",
- card_issuer: "Intl Hdqtrs Center Owned",
+ card_issuer: "INTL HDQTRS CENTER OWNED",
card_issuing_country: "UNITED STATES OF AMERICA",
card_isin: "400000",
card_extended_bin: null,
@@ -312,6 +313,9 @@ export const connectorDetails = {
},
},
MandateMultiUseNo3DSAutoCapture: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
Request: {
payment_method: "card",
payment_method_data: {
@@ -493,6 +497,7 @@ export const connectorDetails = {
currency: "USD",
setup_future_usage: "on_session",
customer_acceptance: customerAcceptance,
+ billing: billingWithNewline,
},
Response: {
status: 200,
@@ -501,7 +506,23 @@ export const connectorDetails = {
},
},
},
-
+ SaveCardUse3DSAutoCaptureOffSession: {
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ setup_future_usage: "off_session",
+ customer_acceptance: customerAcceptance,
+ billing: billingWithNewline,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_customer_action",
+ },
+ },
+ },
SaveCardUseNo3DSManualCapture: {
Request: {
payment_method: "card",
@@ -511,6 +532,7 @@ export const connectorDetails = {
currency: "USD",
setup_future_usage: "on_session",
customer_acceptance: customerAcceptance,
+ billing: billingWithNewline,
},
Response: {
status: 200,
@@ -532,6 +554,7 @@ export const connectorDetails = {
},
setup_future_usage: "off_session",
customer_acceptance: customerAcceptance,
+ billing: billingWithNewline,
},
Response: {
status: 200,
@@ -554,6 +577,7 @@ export const connectorDetails = {
},
setup_future_usage: "off_session",
customer_acceptance: customerAcceptance,
+ billing: billingWithNewline,
},
Response: {
status: 200,
@@ -738,5 +762,19 @@ export const connectorDetails = {
},
},
},
+ PaymentWithBilling: {
+ Request: {
+ currency: "USD",
+ setup_future_usage: "on_session",
+ billing: billingWithNewline,
+ email: "[email protected]",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ },
+ },
+ },
},
};