Skip to content

Commit

Permalink
feat(connector): [deutschebank] Implement Cards 3ds Flow
Browse files Browse the repository at this point in the history
  • Loading branch information
Debarshi Gupta authored and Debarshi Gupta committed Dec 18, 2024
1 parent 70da2d0 commit 7bcd4a5
Show file tree
Hide file tree
Showing 3 changed files with 274 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -366,37 +366,64 @@ impl
PaymentsResponseData,
>,
) -> Result<Self, Self::Error> {
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
}),
}
}
}

Expand Down
218 changes: 218 additions & 0 deletions cypress-tests/cypress/e2e/PaymentUtils/Deutschebank.js
Original file line number Diff line number Diff line change
@@ -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",
},
},
},
},
};
2 changes: 2 additions & 0 deletions cypress-tests/cypress/e2e/PaymentUtils/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -33,6 +34,7 @@ const connectorDetails = {
checkout: checkoutConnectorDetails,
commons: CommonConnectorDetails,
cybersource: cybersourceConnectorDetails,
deutschebank: deutschebankConnectorDetails,
fiservemea: fiservemeaConnectorDetails,
iatapay: iatapayConnectorDetails,
itaubank: itaubankConnectorDetails,
Expand Down

0 comments on commit 7bcd4a5

Please sign in to comment.