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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
import * as fixtures from "../../../fixtures/imports";
import State from "../../../utils/State";
import getConnectorDetails, * as utils from "../../configs/Payment/Utils";
let globalState;
let originalCustomerId;
describe("Card - SingleUse Mandates flow test", () => {
before(function () {
// Changed to regular function instead of arrow function
let skip = false;
cy.task("getGlobalState")
.then((state) => {
globalState = new State(state);
originalCustomerId = globalState.get("customerId");
// Skip running test against a connector that is added in the exclude list
if (
utils.shouldExcludeConnector(
globalState.get("connectorId"),
utils.CONNECTOR_LISTS.EXCLUDE.MANDATE_ID_TEST
)
) {
skip = true;
}
})
.then(() => {
if (skip) {
this.skip();
}
});
});
after("flush global state", () => {
// This spec's contexts create their own customers for local mandate
// testing, overwriting globalState.customerId. Restore the original
// customer before flushing so later specs don't inherit one scoped to
// this spec's own mandate tests.
globalState.set("customerId", originalCustomerId);
cy.task("setGlobalState", globalState.data);
});
context(
"Card - NoThreeDS Create + Confirm Automatic CIT and MIT payment flow test",
() => {
let shouldContinue = true; // variable that will be used to skip tests if a previous test fails
beforeEach(function () {
if (!shouldContinue) {
this.skip();
}
});
it("Confirm No 3DS CIT", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["MandateSingleUseNo3DSAutoCapture"];
cy.citForMandatesCallTest(
fixtures.citConfirmBody,
data,
true,
"automatic",
"new_mandate",
globalState
);
if (shouldContinue)
shouldContinue = utils.should_continue_further(data);
});
it("Confirm No 3DS MIT", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["MITAutoCapture"];
cy.mitForMandatesCallTest(
fixtures.mitConfirmBody,
data,
true,
"automatic",
globalState
);
});
}
);
context(
"Card - NoThreeDS Create + Confirm Manual CIT and MIT payment flow test",
() => {
let shouldContinue = true; // variable that will be used to skip tests if a previous test fails
beforeEach(function () {
if (!shouldContinue) {
this.skip();
}
});
it("Confirm No 3DS CIT", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["MandateSingleUseNo3DSManualCapture"];
cy.citForMandatesCallTest(
fixtures.citConfirmBody,
data,
true,
"manual",
"new_mandate",
globalState
);
if (shouldContinue)
shouldContinue = utils.should_continue_further(data);
});
it("cit-capture-call-test", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["Capture"];
cy.captureCallTest(fixtures.captureBody, data, globalState);
if (shouldContinue)
shouldContinue = utils.should_continue_further(data);
});
it("Confirm No 3DS MIT", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["MITManualCapture"];
cy.mitForMandatesCallTest(
fixtures.mitConfirmBody,
data,
true,
"manual",
globalState
);
if (shouldContinue)
shouldContinue = utils.should_continue_further(data);
});
it("mit-capture-call-test", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["Capture"];
cy.captureCallTest(fixtures.captureBody, data, globalState);
if (shouldContinue)
shouldContinue = utils.should_continue_further(data);
});
it("list-mandate-call-test", () => {
cy.listMandateCallTest(globalState);
});
}
);
context(
"Card - No threeDS Create + Confirm Manual CIT and MIT payment flow test",
() => {
let shouldContinue = true; // variable that will be used to skip tests if a previous test fails
beforeEach(function () {
if (!shouldContinue) {
this.skip();
}
});
it("Create No 3DS CIT", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["MandateSingleUseNo3DSManualCapture"];
cy.citForMandatesCallTest(
fixtures.citConfirmBody,
data,
true,
"manual",
"new_mandate",
globalState
);
if (shouldContinue)
shouldContinue = utils.should_continue_further(data);
});
it("cit-capture-call-test", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["Capture"];
cy.captureCallTest(fixtures.captureBody, data, globalState);
if (shouldContinue)
shouldContinue = utils.should_continue_further(data);
});
it("Confirm No 3DS MIT", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["MITAutoCapture"];
cy.mitForMandatesCallTest(
fixtures.mitConfirmBody,
data,
true,
"automatic",
globalState
);
});
it("list-mandate-call-test", () => {
cy.listMandateCallTest(globalState);
});
}
);
context(
"Card - Recurring mandate with greater mandate amount flow test",
() => {
let shouldContinue = true; // variable that will be used to skip tests if a previous test fails
beforeEach(function () {
if (!shouldContinue) {
this.skip();
}
});
it("No 3DS CIT", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["MandateSingleUseNo3DSManualCapture"];
cy.citForMandatesCallTest(
fixtures.citConfirmBody,
data,
true,
"manual",
"new_mandate",
globalState
);
if (shouldContinue)
shouldContinue = utils.should_continue_further(data);
});
it("cit-capture-call-test", () => {
if (!shouldContinue) {
this.skip();
}
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["Capture"];
cy.captureCallTest(fixtures.captureBody, data, globalState);
if (shouldContinue)
shouldContinue = utils.should_continue_further(data);
});
it("Retrieve payment", () => {
if (!shouldContinue) {
this.skip();
}
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["Capture"];
cy.retrievePaymentCallTest({ globalState, data });
});
it("Confirm No 3DS MIT", () => {
if (!shouldContinue) {
this.skip();
}
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["MITExceedingMandateAmount"];
cy.mitForMandatesCallTest(
fixtures.mitConfirmBody,
data,
true,
"manual",
globalState
);
});
}
);
context(
"Card - NoThreeDS Zero Auth Mandate Create + Confirm Automatic CIT and Single use MIT payment flow test",
() => {
let shouldContinue = true; // variable that will be used to skip tests if a previous test fails
beforeEach(function () {
if (!shouldContinue) {
this.skip();
}
});
it("customer-create-call-test", () => {
cy.createCustomerCallTest(fixtures.customerCreateBody, globalState);
});
it("Confirm No 3DS CIT", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["ZeroAuthMandate"];
cy.citForMandatesCallTest(
fixtures.citConfirmBody,
data,
true,
"automatic",
"setup_mandate",
globalState
);
if (shouldContinue)
shouldContinue = utils.should_continue_further(data);
});
it("retrieve-payment-call-test", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["ZeroAuthMandate"];
cy.retrievePaymentCallTest({ globalState, data });
});
it("Confirm No 3DS MIT", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["MITAutoCapture"];
cy.mitForMandatesCallTest(
fixtures.mitConfirmBody,
data,
true,
"automatic",
globalState
);
});
it("retrieve-payment-call-test", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["MITAutoCapture"];
cy.retrievePaymentCallTest({ globalState, data });
});
}
);
});