Skip to content

Commit

Permalink
ci(cypress): Add Checkout Connector (#6559)
Browse files Browse the repository at this point in the history
  • Loading branch information
likhinbopanna authored Nov 15, 2024
1 parent c562ceb commit 0b63efb
Show file tree
Hide file tree
Showing 5 changed files with 321 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ describe("Card - SaveCard payment flow test", () => {
globalState
);
if (should_continue) {
// Don't continue if payment status is processing during auto capture
// Payment data is tokenized only after payment is successful
let notProcessing = res_data?.body?.status != "processing";
should_continue =
notProcessing && utils.should_continue_further(res_data);
should_continue = utils.should_continue_further(res_data);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ import getConnectorDetails, * as utils from "../PaymentUtils/Utils";
let globalState;

describe("Card - ThreeDS Manual payment flow test", () => {
let should_continue = true;

beforeEach(function () {
if (!should_continue) {
this.skip();
}
});

before("seed global state", () => {
cy.task("getGlobalState").then((state) => {
globalState = new State(state);
Expand Down
298 changes: 298 additions & 0 deletions cypress-tests/cypress/e2e/PaymentUtils/Checkout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,298 @@
const successfulNo3DSCardDetails = {
card_number: "4242424242424242",
card_exp_month: "01",
card_exp_year: "25",
card_holder_name: "joseph Doe",
card_cvc: "123",
};

const successfulThreeDSTestCardDetails = {
card_number: "4242424242424242",
card_exp_month: "01",
card_exp_year: "25",
card_holder_name: "joseph Doe",
card_cvc: "123",
};

const customerAcceptance = {
acceptance_type: "offline",
accepted_at: "1963-05-03T04:07:52.723Z",
online: {
ip_address: "127.0.0.1",
user_agent: "amet irure esse",
},
};

export const connectorDetails = {
card_pm: {
PaymentIntent: {
Request: {
currency: "USD",
customer_acceptance: null,
setup_future_usage: "on_session",
},
Response: {
status: 200,
body: {
status: "requires_payment_method",
},
},
},
"3DSManualCapture": {
Request: {
payment_method: "card",
payment_method_data: {
card: successfulThreeDSTestCardDetails,
},
customer_acceptance: null,
setup_future_usage: "on_session",
},
Response: {
status: 200,
body: {
status: "requires_customer_action",
},
},
},
"3DSAutoCapture": {
Request: {
payment_method: "card",
payment_method_data: {
card: successfulThreeDSTestCardDetails,
},
customer_acceptance: null,
setup_future_usage: "on_session",
},
Response: {
status: 200,
body: {
status: "requires_customer_action",
},
},
},
No3DSManualCapture: {
Request: {
payment_method: "card",
payment_method_data: {
card: successfulNo3DSCardDetails,
},
customer_acceptance: null,
setup_future_usage: "on_session",
},
Response: {
status: 200,
body: {
status: "requires_capture",
},
},
},
No3DSAutoCapture: {
Request: {
payment_method: "card",
payment_method_data: {
card: successfulNo3DSCardDetails,
},
customer_acceptance: null,
setup_future_usage: "on_session",
},
Response: {
status: 200,
body: {
status: "processing",
},
},
},
Capture: {
Request: {
payment_method: "card",
payment_method_data: {
card: successfulNo3DSCardDetails,
},
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,
},
},
},
Void: {
Request: {},
Response: {
status: 200,
body: {
status: "cancelled",
},
},
},
Refund: {
Request: {
payment_method: "card",
payment_method_data: {
card: successfulNo3DSCardDetails,
},
customer_acceptance: null,
},
Response: {
status: 200,
body: {
status: "succeeded",
},
},
},
PartialRefund: {
Request: {
payment_method: "card",
payment_method_data: {
card: successfulNo3DSCardDetails,
},
customer_acceptance: null,
},
Response: {
status: 200,
body: {
status: "succeeded",
},
},
},
manualPaymentRefund: {
Request: {
payment_method: "card",
payment_method_data: {
card: successfulNo3DSCardDetails,
},
customer_acceptance: null,
},
Response: {
status: 200,
body: {
status: "succeeded",
},
},
},
manualPaymentPartialRefund: {
Request: {
payment_method: "card",
payment_method_data: {
card: successfulNo3DSCardDetails,
},
customer_acceptance: null,
},
Response: {
status: 200,
body: {
status: "succeeded",
},
},
},
SyncRefund: {
Request: {
payment_method: "card",
payment_method_data: {
card: successfulNo3DSCardDetails,
},
customer_acceptance: null,
},
Response: {
status: 200,
body: {
status: "succeeded",
},
},
},
ZeroAuthMandate: {
Response: {
status: 501,
body: {
error: {
type: "invalid_request",
message: "Setup Mandate flow for Checkout is not implemented",
code: "IR_00",
},
},
},
},
ZeroAuthPaymentIntent: {
Request: {
amount: 0,
setup_future_usage: "off_session",
currency: "USD",
},
Response: {
status: 200,
body: {
status: "requires_payment_method",
setup_future_usage: "off_session",
},
},
},
ZeroAuthConfirmPayment: {
Request: {
payment_type: "setup_mandate",
payment_method: "card",
payment_method_type: "credit",
payment_method_data: {
card: successfulNo3DSCardDetails,
},
},
Response: {
status: 501,
body: {
error: {
type: "invalid_request",
message: "Setup Mandate flow for Checkout is not implemented",
code: "IR_00",
},
},
},
},
SaveCardUseNo3DSAutoCapture: {
Request: {
payment_method: "card",
payment_method_data: {
card: successfulNo3DSCardDetails,
},
setup_future_usage: "on_session",
customer_acceptance: customerAcceptance,
},
Response: {
status: 200,
body: {
status: "processing",
},
},
},
SaveCardUseNo3DSManualCapture: {
Request: {
payment_method: "card",
payment_method_data: {
card: successfulNo3DSCardDetails,
},
setup_future_usage: "on_session",
customer_acceptance: customerAcceptance,
},
Response: {
status: 200,
body: {
status: "requires_capture",
},
},
},
},
};
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 @@ -20,11 +20,13 @@ import { connectorDetails as trustpayConnectorDetails } from "./Trustpay.js";
import { connectorDetails as wellsfargoConnectorDetails } from "./WellsFargo.js";
import { connectorDetails as fiuuConnectorDetails } from "./Fiuu.js";
import { connectorDetails as worldpayConnectorDetails } from "./WorldPay.js";
import { connectorDetails as checkoutConnectorDetails } from "./Checkout.js";

const connectorDetails = {
adyen: adyenConnectorDetails,
bankofamerica: bankOfAmericaConnectorDetails,
bluesnap: bluesnapConnectorDetails,
checkout: checkoutConnectorDetails,
commons: CommonConnectorDetails,
cybersource: cybersourceConnectorDetails,
fiservemea: fiservemeaConnectorDetails,
Expand Down
12 changes: 12 additions & 0 deletions cypress-tests/cypress/support/redirectionHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,18 @@ function threeDsRedirection(redirection_url, expected_url, connectorId) {
cy.get('input[type="text"]').click().type("1234");
cy.get('input[value="SUBMIT"]').click();
});
} else if (connectorId === "checkout") {
cy.get("iframe", { timeout: TIMEOUT })
.its("0.contentDocument.body")
.within((body) => {
cy.get('form[id="form"]', { timeout: WAIT_TIME })
.should("exist")
.then((form) => {
cy.get('input[id="password"]').click();
cy.get('input[id="password"]').type("Checkout1!");
cy.get("#txtButton").click();
});
});
} else if (connectorId === "nmi" || connectorId === "noon") {
cy.get("iframe", { timeout: TIMEOUT })
.its("0.contentDocument.body")
Expand Down

0 comments on commit 0b63efb

Please sign in to comment.