diff --git a/crates/hyperswitch_connectors/src/connectors/deutschebank/transformers.rs b/crates/hyperswitch_connectors/src/connectors/deutschebank/transformers.rs index 3d52249634f1..d4c0a23aef68 100644 --- a/crates/hyperswitch_connectors/src/connectors/deutschebank/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/deutschebank/transformers.rs @@ -366,37 +366,64 @@ impl PaymentsResponseData, >, ) -> Result { - Ok(Self { - status: if item.response.outcome - == DeutschebankThreeDSInitializeResponseOutcome::Processed - { - match item.data.request.is_auto_capture()? { + match item.response.outcome { + DeutschebankThreeDSInitializeResponseOutcome::Processed => Ok(Self { + status: match item.data.request.is_auto_capture()? { true => common_enums::AttemptStatus::Charged, false => common_enums::AttemptStatus::Authorized, - } - } else { - common_enums::AttemptStatus::AuthenticationPending - }, - response: Ok(PaymentsResponseData::TransactionResponse { - resource_id: ResponseId::NoResponseId, - redirection_data: match item.response.challenge_required { - Some(challenge) => { - Box::new(Some(RedirectForm::DeutschebankThreeDSChallengeFlow { - acs_url: challenge.clone().acs_url.clone(), - creq: challenge.clone().creq.clone(), - })) - } - None => Box::new(None), }, - mandate_reference: Box::new(None), - connector_metadata: None, - network_txn_id: None, - connector_response_reference_id: None, - incremental_authorization_allowed: None, - charge_id: None, + response: Ok(PaymentsResponseData::TransactionResponse { + resource_id: ResponseId::NoResponseId, + redirection_data: Box::new(None), + mandate_reference: Box::new(None), + connector_metadata: None, + network_txn_id: None, + connector_response_reference_id: None, + incremental_authorization_allowed: None, + charge_id: None, + }), + ..item.data }), - ..item.data - }) + DeutschebankThreeDSInitializeResponseOutcome::ChallengeRequired => { + match item.response.challenge_required { + Some(challenge) => Ok(Self { + status: common_enums::AttemptStatus::AuthenticationPending, + response: Ok(PaymentsResponseData::TransactionResponse { + resource_id: ResponseId::NoResponseId, + redirection_data: Box::new(Some( + RedirectForm::DeutschebankThreeDSChallengeFlow { + acs_url: challenge.acs_url, + creq: challenge.creq, + }, + )), + mandate_reference: Box::new(None), + connector_metadata: None, + network_txn_id: None, + connector_response_reference_id: None, + incremental_authorization_allowed: None, + charge_id: None, + }), + ..item.data + }), + None => Err(errors::ConnectorError::MissingRequiredField { + field_name: "challenge_required", + } + .into()), + } + } + DeutschebankThreeDSInitializeResponseOutcome::MethodRequired => Ok(Self { + status: common_enums::AttemptStatus::Failure, + response: Err(ErrorResponse { + code: "500".to_owned(), + message: "Method_Required Flow not supported".to_owned(), + reason: None, + status_code: 500, + attempt_status: None, + connector_transaction_id: None, + }), + ..item.data + }), + } } } diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Deutschebank.js b/cypress-tests/cypress/e2e/PaymentUtils/Deutschebank.js new file mode 100644 index 000000000000..fbfb7d9b894d --- /dev/null +++ b/cypress-tests/cypress/e2e/PaymentUtils/Deutschebank.js @@ -0,0 +1,218 @@ +const successful3DSCardDetails = { + card_number: "4761739090000088", + card_exp_month: "12", + card_exp_year: "2034", + card_holder_name: "John Doe", + card_cvc: "123", + }; + + export const connectorDetails = { + card_pm: { + PaymentIntent: { + Request: { + currency: "USD", + customer_acceptance: null, + }, + Response: { + status: 200, + body: { + status: "requires_payment_method", + }, + }, + }, + "3DSManualCapture": { + Request: { + payment_method: "card", + payment_method_data: { + card: successful3DSCardDetails, + }, + currency: "USD", + customer_acceptance: { + acceptance_type: "online" + }, + setup_future_usage: "on_session", + }, + Response: { + status: 200, + body: { + status: "requires_customer_action", + }, + }, + }, + + "3DSAutoCapture": { + Request: { + payment_method: "card", + payment_method_data: { + card: successful3DSCardDetails, + }, + currency: "USD", + customer_acceptance: { + acceptance_type: "online" + }, + setup_future_usage: "on_session", + }, + Response: { + status: 200, + body: { + status: "requires_customer_action", + }, + }, + }, + No3DSManualCapture: { + Request: { + currency: "USD", + payment_method: "card", + payment_method_data: { + card: successful3DSCardDetails, + }, + customer_acceptance: null, + setup_future_usage: "on_session", + }, + Response: { + status: 400, + body: { + error: { + type: "invalid_request", + message: "Payment method type not supported", + code: "IR_19", + } + }, + }, + }, + No3DSAutoCapture: { + Request: { + currency: "USD", + payment_method: "card", + payment_method_data: { + card: successful3DSCardDetails, + }, + customer_acceptance: null, + setup_future_usage: "on_session", + }, + Response: { + status: 400, + body: { + error: { + type: "invalid_request", + message: "Payment method type not supported", + code: "IR_19", + } + }, + }, + }, + Capture: { + Request: { + payment_method: "card", + payment_method_data: { + card: successful3DSCardDetails, + }, + customer_acceptance: null, + }, + Response: { + status: 200, + body: { + status: "succeeded", + amount: 6500, + amount_capturable: 0, + amount_received: 6500, + }, + }, + }, + PartialCapture: { + Request: {}, + Response: { + status: 200, + body: { + status: "partially_captured", + amount: 6500, + amount_capturable: 0, + amount_received: 100, + }, + }, + }, + Refund: { + Configs: { + TRIGGER_SKIP: true, + }, + Request: { + payment_method: "card", + payment_method_data: { + card: successful3DSCardDetails, + }, + customer_acceptance: null, + }, + Response: { + status: 200, + body: { + status: "succeeded", + }, + }, + }, + manualPaymentRefund: { + Configs: { + TRIGGER_SKIP: true, + }, + Request: { + payment_method: "card", + payment_method_data: { + card: successful3DSCardDetails, + }, + customer_acceptance: null, + }, + Response: { + status: 200, + body: { + status: "succeeded", + }, + }, + }, + manualPaymentPartialRefund: { + Configs: { + TRIGGER_SKIP: true, + }, + Request: { + payment_method: "card", + payment_method_data: { + card: successful3DSCardDetails, + }, + customer_acceptance: null, + }, + Response: { + status: 200, + body: { + status: "succeeded", + }, + }, + }, + PartialRefund: { + Configs: { + TRIGGER_SKIP: true, + }, + Request: { + payment_method: "card", + payment_method_data: { + card: successful3DSCardDetails, + }, + customer_acceptance: null, + }, + Response: { + status: 200, + body: { + status: "succeeded", + }, + }, + }, + SyncRefund: { + Configs: { + TRIGGER_SKIP: true, + }, + Response: { + status: 200, + body: { + status: "succeeded", + }, + }, + }, + }, + }; \ No newline at end of file diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Utils.js b/cypress-tests/cypress/e2e/PaymentUtils/Utils.js index e432c37717bf..884f7bccf1c2 100644 --- a/cypress-tests/cypress/e2e/PaymentUtils/Utils.js +++ b/cypress-tests/cypress/e2e/PaymentUtils/Utils.js @@ -25,6 +25,7 @@ import { connectorDetails as stripeConnectorDetails } from "./Stripe.js"; import { connectorDetails as trustpayConnectorDetails } from "./Trustpay.js"; import { connectorDetails as wellsfargoConnectorDetails } from "./WellsFargo.js"; import { connectorDetails as worldpayConnectorDetails } from "./WorldPay.js"; +import { connectorDetails as deutschebankConnectorDetails } from "./Deutschebank.js"; const connectorDetails = { adyen: adyenConnectorDetails, @@ -33,6 +34,7 @@ const connectorDetails = { checkout: checkoutConnectorDetails, commons: CommonConnectorDetails, cybersource: cybersourceConnectorDetails, + deutschebank: deutschebankConnectorDetails, fiservemea: fiservemeaConnectorDetails, iatapay: iatapayConnectorDetails, itaubank: itaubankConnectorDetails,