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 { isMockServer } from "../../../support/mitmProxy";
import State from "../../../utils/State";
import getConnectorDetails, * as utils from "../../configs/Payment/Utils";
let globalState;
describe("Card - Refund flow - No 3DS", () => {
before("seed global state", () => {
cy.task("getGlobalState").then((state) => {
globalState = new State(state);
});
});
afterEach("flush global state", () => {
cy.task("setGlobalState", globalState.data);
});
context("Bluesnap - warm up account balance", () => {
it("Create and Confirm 5 payments of 100000 so the sandbox account has enough settled balance for refunds", () => {
if (globalState.get("connectorId") !== "bluesnap") {
return;
}
const baseData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["No3DSAutoCapture"];
const warmupData = {
...baseData,
Request: { ...baseData.Request, amount: 100000 },
Response: {
...baseData.Response,
body: { ...baseData.Response.body, amount: 100000 },
},
};
cy.step("Warm up transaction 1", () => {
cy.createConfirmPaymentTest(
fixtures.createConfirmPaymentBody,
warmupData,
"no_three_ds",
"automatic",
globalState
);
});
cy.step("Warm up transaction 2", () => {
cy.createConfirmPaymentTest(
fixtures.createConfirmPaymentBody,
warmupData,
"no_three_ds",
"automatic",
globalState
);
});
cy.step("Warm up transaction 3", () => {
cy.createConfirmPaymentTest(
fixtures.createConfirmPaymentBody,
warmupData,
"no_three_ds",
"automatic",
globalState
);
});
cy.step("Warm up transaction 4", () => {
cy.createConfirmPaymentTest(
fixtures.createConfirmPaymentBody,
warmupData,
"no_three_ds",
"automatic",
globalState
);
});
cy.step("Warm up transaction 5", () => {
cy.createConfirmPaymentTest(
fixtures.createConfirmPaymentBody,
warmupData,
"no_three_ds",
"automatic",
globalState
);
});
});
});
context("Card - Full Refund flow test for No-3DS", () => {
it("Create Payment Intent -> Payment Methods Call -> Confirm Payment Intent -> Retrieve Payment after Confirmation -> Refund Payment -> Sync Refund Payment", () => {
let shouldContinue = true;
cy.step("Create Payment Intent", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["PaymentIntent"];
cy.createPaymentIntentTest(
fixtures.createPaymentBody,
data,
"no_three_ds",
"automatic",
globalState
);
if (!utils.should_continue_further(data)) {
shouldContinue = false;
}
});
cy.step("Payment Methods Call", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Payment Methods Call");
return;
}
cy.paymentMethodsCallTest(globalState);
});
cy.step("Confirm Payment Intent", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Confirm Payment Intent");
return;
}
const confirmData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["No3DSAutoCapture"];
cy.confirmCallTest(
fixtures.confirmBody,
confirmData,
true,
globalState
);
if (!utils.should_continue_further(confirmData)) {
shouldContinue = false;
}
});
cy.step("Retrieve Payment after Confirmation", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Retrieve Payment after Confirmation"
);
return;
}
const confirmData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["No3DSAutoCapture"];
cy.retrievePaymentCallTest({ globalState, data: confirmData });
if (!utils.should_continue_further(confirmData)) {
shouldContinue = false;
}
});
cy.step("Refund Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Refund Payment");
return;
}
const refundData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["Refund"];
cy.refundCallTest(fixtures.refundBody, refundData, globalState);
if (!utils.should_continue_further(refundData)) {
shouldContinue = false;
}
});
cy.step("Sync Refund Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Sync Refund Payment");
return;
}
const syncRefundData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["SyncRefund"];
cy.syncRefundCallTest(syncRefundData, globalState);
});
});
});
context("Card - Partial Refund flow test for No-3DS", () => {
it("Create Payment Intent -> Payment Methods Call -> Confirm Payment Intent -> Retrieve Payment after Confirmation -> Partial Refund Payment -> Partial Refund Payment - 2nd Attempt -> Sync Refund Payment", () => {
let shouldContinue = true;
cy.step("Create Payment Intent", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["PaymentIntent"];
cy.createPaymentIntentTest(
fixtures.createPaymentBody,
data,
"no_three_ds",
"automatic",
globalState
);
if (!utils.should_continue_further(data)) {
shouldContinue = false;
}
});
cy.step("Payment Methods Call", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Payment Methods Call");
return;
}
cy.paymentMethodsCallTest(globalState);
});
cy.step("Confirm Payment Intent", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Confirm Payment Intent");
return;
}
const confirmData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["No3DSAutoCapture"];
cy.confirmCallTest(
fixtures.confirmBody,
confirmData,
true,
globalState
);
if (!utils.should_continue_further(confirmData)) {
shouldContinue = false;
}
});
cy.step("Retrieve Payment after Confirmation", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Retrieve Payment after Confirmation"
);
return;
}
const confirmData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["No3DSAutoCapture"];
cy.retrievePaymentCallTest({ globalState, data: confirmData });
if (!utils.should_continue_further(confirmData)) {
shouldContinue = false;
}
});
cy.step("Partial Refund Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Partial Refund Payment");
return;
}
const partialRefundData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["PartialRefund"];
cy.refundCallTest(fixtures.refundBody, partialRefundData, globalState);
if (!utils.should_continue_further(partialRefundData)) {
shouldContinue = false;
}
});
cy.step("Partial Refund Payment - 2nd Attempt", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Partial Refund Payment - 2nd Attempt"
);
return;
}
const partialRefundData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["PartialRefund"];
cy.refundCallTest(fixtures.refundBody, partialRefundData, globalState);
if (!utils.should_continue_further(partialRefundData)) {
shouldContinue = false;
}
});
cy.step("Sync Refund Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Sync Refund Payment");
return;
}
const syncRefundData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["SyncRefund"];
cy.syncRefundCallTest(syncRefundData, globalState);
});
});
});
context(
"Fully Refund Card-NoThreeDS payment flow test Create+Confirm",
() => {
it("Create and Confirm Payment -> Retrieve Payment after Confirmation -> Refund Payment -> Sync Refund Payment", () => {
let shouldContinue = true;
cy.step("Create and Confirm Payment", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["No3DSAutoCapture"];
cy.createConfirmPaymentTest(
fixtures.createConfirmPaymentBody,
data,
"no_three_ds",
"automatic",
globalState
);
if (!utils.should_continue_further(data)) {
shouldContinue = false;
}
});
cy.step("Retrieve Payment after Confirmation", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Retrieve Payment after Confirmation"
);
return;
}
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["No3DSAutoCapture"];
cy.retrievePaymentCallTest({ globalState, data });
if (!utils.should_continue_further(data)) {
shouldContinue = false;
}
});
cy.step("Refund Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Refund Payment");
return;
}
const refundData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["Refund"];
cy.refundCallTest(fixtures.refundBody, refundData, globalState);
if (!utils.should_continue_further(refundData)) {
shouldContinue = false;
}
});
cy.step("Sync Refund Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Sync Refund Payment");
return;
}
const syncRefundData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["SyncRefund"];
cy.syncRefundCallTest(syncRefundData, globalState);
});
});
}
);
context(
"Partially Refund Card-NoThreeDS payment flow test Create+Confirm",
() => {
it("Create and Confirm Payment -> Retrieve Payment after Confirmation -> Partial Refund Payment -> Partial Refund Payment - 2nd Attempt -> Sync Refund Payment", () => {
let shouldContinue = true;
cy.step("Create and Confirm Payment", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["No3DSAutoCapture"];
cy.createConfirmPaymentTest(
fixtures.createConfirmPaymentBody,
data,
"no_three_ds",
"automatic",
globalState
);
if (!utils.should_continue_further(data)) {
shouldContinue = false;
}
});
cy.step("Retrieve Payment after Confirmation", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Retrieve Payment after Confirmation"
);
return;
}
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["No3DSAutoCapture"];
cy.retrievePaymentCallTest({ globalState, data });
if (!utils.should_continue_further(data)) {
shouldContinue = false;
}
});
cy.step("Partial Refund Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Partial Refund Payment");
return;
}
const partialRefundData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["PartialRefund"];
cy.refundCallTest(
fixtures.refundBody,
partialRefundData,
globalState
);
if (!utils.should_continue_further(partialRefundData)) {
shouldContinue = false;
}
});
cy.step("Partial Refund Payment - 2nd Attempt", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Partial Refund Payment - 2nd Attempt"
);
return;
}
const partialRefundData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["PartialRefund"];
cy.refundCallTest(
fixtures.refundBody,
partialRefundData,
globalState
);
if (!utils.should_continue_further(partialRefundData)) {
shouldContinue = false;
}
});
cy.step("Sync Refund Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Sync Refund Payment");
return;
}
const syncRefundData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["SyncRefund"];
cy.syncRefundCallTest(syncRefundData, globalState);
});
});
}
);
context("Card - Full Refund for fully captured No-3DS payment", () => {
it("Create Payment Intent -> Payment Methods Call -> Confirm Payment Intent -> Retrieve Payment after Confirmation -> Capture Payment -> Retrieve Payment after Capture -> Refund Payment -> Sync Refund Payment", () => {
let shouldContinue = true;
cy.step("Create Payment Intent", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["PaymentIntent"];
cy.createPaymentIntentTest(
fixtures.createPaymentBody,
data,
"no_three_ds",
"manual",
globalState
);
if (!utils.should_continue_further(data)) {
shouldContinue = false;
}
});
cy.step("Payment Methods Call", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Payment Methods Call");
return;
}
cy.paymentMethodsCallTest(globalState);
});
cy.step("Confirm Payment Intent", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Confirm Payment Intent");
return;
}
const confirmData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["No3DSManualCapture"];
cy.confirmCallTest(
fixtures.confirmBody,
confirmData,
true,
globalState
);
if (!utils.should_continue_further(confirmData)) {
shouldContinue = false;
}
});
cy.step("Retrieve Payment after Confirmation", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Retrieve Payment after Confirmation"
);
return;
}
const confirmData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["No3DSManualCapture"];
cy.retrievePaymentCallTest({ globalState, data: confirmData });
if (!utils.should_continue_further(confirmData)) {
shouldContinue = false;
}
});
cy.step("Capture Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Capture Payment");
return;
}
const captureData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["Capture"];
cy.captureCallTest(fixtures.captureBody, captureData, globalState);
if (!utils.should_continue_further(captureData)) {
shouldContinue = false;
}
});
cy.step("Retrieve Payment after Capture", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Retrieve Payment after Capture");
return;
}
const captureData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["Capture"];
cy.retrievePaymentCallTest({ globalState, data: captureData });
if (!utils.should_continue_further(captureData)) {
shouldContinue = false;
}
});
cy.step("Refund Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Refund Payment");
return;
}
const refundData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["manualPaymentRefund"];
const newRefundData = {
...refundData,
Response: refundData.ResponseCustom || refundData.Response,
};
cy.refundCallTest(fixtures.refundBody, newRefundData, globalState);
if (!utils.should_continue_further(refundData)) {
shouldContinue = false;
}
});
cy.step("Sync Refund Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Sync Refund Payment");
return;
}
const syncRefundData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["SyncRefund"];
cy.syncRefundCallTest(syncRefundData, globalState);
});
});
});
context("Card - Partial Refund for fully captured No-3DS payment", () => {
it("Create Payment Intent -> Payment Methods Call -> Confirm Payment Intent -> Retrieve Payment after Confirmation -> Capture Payment -> Retrieve Payment after Capture -> Partial Refund Payment -> Partial Refund Payment - 2nd Attempt -> Sync Refund Payment -> List Refunds", () => {
let shouldContinue = true;
cy.step("Create Payment Intent", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["PaymentIntent"];
cy.createPaymentIntentTest(
fixtures.createPaymentBody,
data,
"no_three_ds",
"manual",
globalState
);
if (!utils.should_continue_further(data)) {
shouldContinue = false;
}
});
cy.step("Payment Methods Call", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Payment Methods Call");
return;
}
cy.paymentMethodsCallTest(globalState);
});
cy.step("Confirm Payment Intent", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Confirm Payment Intent");
return;
}
const confirmData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["No3DSManualCapture"];
cy.confirmCallTest(
fixtures.confirmBody,
confirmData,
true,
globalState
);
if (!utils.should_continue_further(confirmData)) {
shouldContinue = false;
}
});
cy.step("Retrieve Payment after Confirmation", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Retrieve Payment after Confirmation"
);
return;
}
const confirmData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["No3DSManualCapture"];
cy.retrievePaymentCallTest({ globalState, data: confirmData });
if (!utils.should_continue_further(confirmData)) {
shouldContinue = false;
}
});
cy.step("Capture Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Capture Payment");
return;
}
const captureData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["Capture"];
cy.captureCallTest(fixtures.captureBody, captureData, globalState);
if (!utils.should_continue_further(captureData)) {
shouldContinue = false;
}
});
cy.step("Retrieve Payment after Capture", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Retrieve Payment after Capture");
return;
}
const captureData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["Capture"];
cy.retrievePaymentCallTest({ globalState, data: captureData });
if (!utils.should_continue_further(captureData)) {
shouldContinue = false;
}
});
cy.step("Partial Refund Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Partial Refund Payment");
return;
}
const partialRefundData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["manualPaymentPartialRefund"];
const newPartialRefundData = {
...partialRefundData,
Response:
partialRefundData.ResponseCustom || partialRefundData.Response,
};
cy.refundCallTest(
fixtures.refundBody,
newPartialRefundData,
globalState
);
if (!utils.should_continue_further(partialRefundData)) {
shouldContinue = false;
}
});
cy.step("Partial Refund Payment - 2nd Attempt", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Partial Refund Payment - 2nd Attempt"
);
return;
}
const partialRefundData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["manualPaymentPartialRefund"];
const newPartialRefundData = {
...partialRefundData,
Response:
partialRefundData.ResponseCustom || partialRefundData.Response,
};
cy.refundCallTest(
fixtures.refundBody,
newPartialRefundData,
globalState
);
if (!utils.should_continue_further(partialRefundData)) {
shouldContinue = false;
}
});
cy.step("Sync Refund Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Sync Refund Payment");
return;
}
const syncRefundData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["SyncRefund"];
cy.syncRefundCallTest(syncRefundData, globalState);
if (!utils.should_continue_further(syncRefundData)) {
shouldContinue = false;
}
});
cy.step("List Refunds", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: List Refunds");
return;
}
cy.listRefundCallTest(fixtures.listRefundCall, globalState);
});
});
});
context("Card - Full Refund for partially captured No-3DS payment", () => {
it("Create Payment Intent -> Payment Methods Call -> Confirm Payment Intent -> Retrieve Payment after Confirmation -> Partial Capture Payment -> Retrieve Payment after Partial Capture -> Refund Payment -> Sync Refund Payment", () => {
let shouldContinue = true;
cy.step("Create Payment Intent", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["PaymentIntent"];
cy.createPaymentIntentTest(
fixtures.createPaymentBody,
data,
"no_three_ds",
"manual",
globalState
);
if (!utils.should_continue_further(data)) {
shouldContinue = false;
}
});
cy.step("Payment Methods Call", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Payment Methods Call");
return;
}
cy.paymentMethodsCallTest(globalState);
});
cy.step("Confirm Payment Intent", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Confirm Payment Intent");
return;
}
const confirmData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["No3DSManualCapture"];
cy.confirmCallTest(
fixtures.confirmBody,
confirmData,
true,
globalState
);
if (!utils.should_continue_further(confirmData)) {
shouldContinue = false;
}
});
cy.step("Retrieve Payment after Confirmation", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Retrieve Payment after Confirmation"
);
return;
}
const confirmData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["No3DSManualCapture"];
cy.retrievePaymentCallTest({ globalState, data: confirmData });
if (!utils.should_continue_further(confirmData)) {
shouldContinue = false;
}
});
cy.step("Partial Capture Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Partial Capture Payment");
return;
}
const partialCaptureData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["PartialCapture"];
cy.captureCallTest(
fixtures.captureBody,
partialCaptureData,
globalState
);
if (!utils.should_continue_further(partialCaptureData)) {
shouldContinue = false;
}
});
cy.step("Retrieve Payment after Partial Capture", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Retrieve Payment after Partial Capture"
);
return;
}
const partialCaptureData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["PartialCapture"];
cy.retrievePaymentCallTest({ globalState, data: partialCaptureData });
if (!utils.should_continue_further(partialCaptureData)) {
shouldContinue = false;
}
});
cy.step("Refund Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Refund Payment");
return;
}
const partialRefundData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["manualPaymentPartialRefund"];
const newPartialRefundData = {
...partialRefundData,
Response:
partialRefundData.ResponseCustom || partialRefundData.Response,
};
cy.refundCallTest(
fixtures.refundBody,
newPartialRefundData,
globalState
);
if (!utils.should_continue_further(partialRefundData)) {
shouldContinue = false;
}
});
cy.step("Sync Refund Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Sync Refund Payment");
return;
}
const syncRefundData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["SyncRefund"];
cy.syncRefundCallTest(syncRefundData, globalState);
});
});
});
context("Card - Partial Refund for partially captured No-3DS payment", () => {
it("Create Payment Intent -> Payment Methods Call -> Confirm Payment Intent -> Retrieve Payment after Confirmation -> Partial Capture Payment -> Retrieve Payment after Partial Capture -> Refund Payment -> Sync Refund Payment", () => {
let shouldContinue = true;
cy.step("Create Payment Intent", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["PaymentIntent"];
cy.createPaymentIntentTest(
fixtures.createPaymentBody,
data,
"no_three_ds",
"manual",
globalState
);
if (!utils.should_continue_further(data)) {
shouldContinue = false;
}
});
cy.step("Payment Methods Call", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Payment Methods Call");
return;
}
cy.paymentMethodsCallTest(globalState);
});
cy.step("Confirm Payment Intent", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Confirm Payment Intent");
return;
}
const confirmData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["No3DSManualCapture"];
cy.confirmCallTest(
fixtures.confirmBody,
confirmData,
true,
globalState
);
if (!utils.should_continue_further(confirmData)) {
shouldContinue = false;
}
});
cy.step("Retrieve Payment after Confirmation", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Retrieve Payment after Confirmation"
);
return;
}
const confirmData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["No3DSManualCapture"];
cy.retrievePaymentCallTest({ globalState, data: confirmData });
if (!utils.should_continue_further(confirmData)) {
shouldContinue = false;
}
});
cy.step("Partial Capture Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Partial Capture Payment");
return;
}
const partialCaptureData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["PartialCapture"];
cy.captureCallTest(
fixtures.captureBody,
partialCaptureData,
globalState
);
if (!utils.should_continue_further(partialCaptureData)) {
shouldContinue = false;
}
});
cy.step("Retrieve Payment after Partial Capture", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Retrieve Payment after Partial Capture"
);
return;
}
const partialCaptureData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["PartialCapture"];
cy.retrievePaymentCallTest({ globalState, data: partialCaptureData });
if (!utils.should_continue_further(partialCaptureData)) {
shouldContinue = false;
}
});
cy.step("Refund Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Refund Payment");
return;
}
const partialRefundData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["manualPaymentPartialRefund"];
const newPartialRefundData = {
...partialRefundData,
Response:
partialRefundData.ResponseCustom || partialRefundData.Response,
};
cy.refundCallTest(
fixtures.refundBody,
newPartialRefundData,
globalState
);
if (!utils.should_continue_further(partialRefundData)) {
shouldContinue = false;
}
});
cy.step("Sync Refund Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Sync Refund Payment");
return;
}
const syncRefundData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["SyncRefund"];
cy.syncRefundCallTest(syncRefundData, globalState);
});
});
});
});
describe("Card - Refund flow - 3DS", () => {
before("seed global state", () => {
cy.task("getGlobalState").then((state) => {
globalState = new State(state);
});
});
afterEach("flush global state", () => {
cy.task("setGlobalState", globalState.data);
});
context("Card - Full Refund flow test for 3DS", () => {
it("Create Payment Intent -> Payment Methods Call -> Confirm Payment Intent -> Handle Redirection -> Retrieve Payment after Confirmation -> Refund Payment -> Sync Refund Payment", () => {
let shouldContinue = true;
cy.step("Create Payment Intent", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["PaymentIntent"];
cy.createPaymentIntentTest(
fixtures.createPaymentBody,
data,
"three_ds",
"automatic",
globalState
);
if (!utils.should_continue_further(data)) {
shouldContinue = false;
}
});
cy.step("Payment Methods Call", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Payment Methods Call");
return;
}
cy.paymentMethodsCallTest(globalState);
});
cy.step("Confirm Payment Intent", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Confirm Payment Intent");
return;
}
const confirmData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["3DSAutoCapture"];
cy.confirmCallTest(
fixtures.confirmBody,
confirmData,
true,
globalState
);
if (!utils.should_continue_further(confirmData)) {
shouldContinue = false;
}
});
cy.step("Handle Redirection", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Handle Redirection");
return;
}
const expected_redirection = fixtures.confirmBody["return_url"];
cy.handleRedirection(globalState, expected_redirection);
});
cy.step("Retrieve Payment after Confirmation", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Retrieve Payment after Confirmation"
);
return;
}
const confirmData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["3DSAutoCapture"];
cy.retrievePaymentCallTest({ globalState, data: confirmData });
if (!utils.should_continue_further(confirmData)) {
shouldContinue = false;
}
});
cy.step("Refund Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Refund Payment");
return;
}
const refundData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["Refund"];
cy.refundCallTest(fixtures.refundBody, refundData, globalState);
if (!utils.should_continue_further(refundData)) {
shouldContinue = false;
}
});
cy.step("Sync Refund Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Sync Refund Payment");
return;
}
const syncRefundData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["SyncRefund"];
cy.syncRefundCallTest(syncRefundData, globalState);
});
});
});
context("Card - Partial Refund flow test for 3DS", () => {
it("Create Payment Intent -> Payment Methods Call -> Confirm Payment Intent -> Handle Redirection -> Retrieve Payment after Confirmation -> Partial Refund Payment -> Partial Refund Payment - 2nd Attempt -> Sync Refund Payment", () => {
let shouldContinue = true;
cy.step("Create Payment Intent", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["PaymentIntent"];
cy.createPaymentIntentTest(
fixtures.createPaymentBody,
data,
"three_ds",
"automatic",
globalState
);
if (!utils.should_continue_further(data)) {
shouldContinue = false;
}
});
cy.step("Payment Methods Call", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Payment Methods Call");
return;
}
cy.paymentMethodsCallTest(globalState);
});
cy.step("Confirm Payment Intent", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Confirm Payment Intent");
return;
}
const confirmData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["3DSAutoCapture"];
cy.confirmCallTest(
fixtures.confirmBody,
confirmData,
true,
globalState
);
if (!utils.should_continue_further(confirmData)) {
shouldContinue = false;
}
});
cy.step("Handle Redirection", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Handle Redirection");
return;
}
const expected_redirection = fixtures.confirmBody["return_url"];
cy.handleRedirection(globalState, expected_redirection);
});
cy.step("Retrieve Payment after Confirmation", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Retrieve Payment after Confirmation"
);
return;
}
const confirmData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["3DSAutoCapture"];
cy.retrievePaymentCallTest({ globalState, data: confirmData });
if (!utils.should_continue_further(confirmData)) {
shouldContinue = false;
}
});
cy.step("Partial Refund Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Partial Refund Payment");
return;
}
const partialRefundData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["PartialRefund"];
cy.refundCallTest(fixtures.refundBody, partialRefundData, globalState);
if (!utils.should_continue_further(partialRefundData)) {
shouldContinue = false;
}
});
cy.step("Partial Refund Payment - 2nd Attempt", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Partial Refund Payment - 2nd Attempt"
);
return;
}
const partialRefundData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["PartialRefund"];
cy.refundCallTest(fixtures.refundBody, partialRefundData, globalState);
if (!utils.should_continue_further(partialRefundData)) {
shouldContinue = false;
}
});
cy.step("Sync Refund Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Sync Refund Payment");
return;
}
const syncRefundData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["SyncRefund"];
cy.syncRefundCallTest(syncRefundData, globalState);
});
});
});
context("Fully Refund Card-ThreeDS payment flow test Create+Confirm", () => {
it("Create and Confirm Payment -> Handle Redirection -> Retrieve Payment after Confirmation -> Refund Payment -> Sync Refund Payment", () => {
let shouldContinue = true;
cy.step("Create and Confirm Payment", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["3DSAutoCapture"];
cy.createConfirmPaymentTest(
fixtures.createConfirmPaymentBody,
data,
"three_ds",
"automatic",
globalState
);
if (!utils.should_continue_further(data)) {
shouldContinue = false;
}
});
cy.step("Handle Redirection", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Handle Redirection");
return;
}
const expected_redirection = fixtures.confirmBody["return_url"];
cy.handleRedirection(globalState, expected_redirection);
});
cy.step("Retrieve Payment after Confirmation", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Retrieve Payment after Confirmation"
);
return;
}
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["3DSAutoCapture"];
cy.retrievePaymentCallTest({ globalState, data });
if (!utils.should_continue_further(data)) {
shouldContinue = false;
}
});
cy.step("Refund Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Refund Payment");
return;
}
const refundData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["Refund"];
cy.refundCallTest(fixtures.refundBody, refundData, globalState);
if (!utils.should_continue_further(refundData)) {
shouldContinue = false;
}
});
cy.step("Sync Refund Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Sync Refund Payment");
return;
}
const syncRefundData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["SyncRefund"];
cy.syncRefundCallTest(syncRefundData, globalState);
});
});
});
context(
"Partially Refund Card-ThreeDS payment flow test Create+Confirm",
() => {
it("Create and Confirm Payment -> Handle Redirection -> Retrieve Payment after Confirmation -> Partial Refund Payment -> Partial Refund Payment - 2nd Attempt -> Sync Refund Payment", () => {
let shouldContinue = true;
cy.step("Create and Confirm Payment", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["3DSAutoCapture"];
cy.createConfirmPaymentTest(
fixtures.createConfirmPaymentBody,
data,
"three_ds",
"automatic",
globalState
);
if (!utils.should_continue_further(data)) {
shouldContinue = false;
}
});
cy.step("Handle Redirection", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Handle Redirection");
return;
}
const expected_redirection = fixtures.confirmBody["return_url"];
cy.handleRedirection(globalState, expected_redirection);
});
cy.step("Retrieve Payment after Confirmation", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Retrieve Payment after Confirmation"
);
return;
}
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["3DSAutoCapture"];
cy.retrievePaymentCallTest({ globalState, data });
if (!utils.should_continue_further(data)) {
shouldContinue = false;
}
});
cy.step("Partial Refund Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Partial Refund Payment");
return;
}
const partialRefundData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["PartialRefund"];
cy.refundCallTest(
fixtures.refundBody,
partialRefundData,
globalState
);
if (!utils.should_continue_further(partialRefundData)) {
shouldContinue = false;
}
});
cy.step("Partial Refund Payment - 2nd Attempt", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Partial Refund Payment - 2nd Attempt"
);
return;
}
const partialRefundData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["PartialRefund"];
cy.refundCallTest(
fixtures.refundBody,
partialRefundData,
globalState
);
if (!utils.should_continue_further(partialRefundData)) {
shouldContinue = false;
}
});
cy.step("Sync Refund Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Sync Refund Payment");
return;
}
const syncRefundData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["SyncRefund"];
cy.syncRefundCallTest(syncRefundData, globalState);
});
});
}
);
context("Card - Full Refund for fully captured 3DS payment", () => {
it("Create Payment Intent -> Payment Methods Call -> Confirm Payment Intent -> Handle Redirection -> Retrieve Payment after Confirmation -> Capture Payment -> Retrieve Payment after Capture -> Refund Payment -> Sync Refund Payment", () => {
let shouldContinue = true;
cy.step("Create Payment Intent", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["PaymentIntent"];
cy.createPaymentIntentTest(
fixtures.createPaymentBody,
data,
"three_ds",
"manual",
globalState
);
if (!utils.should_continue_further(data)) {
shouldContinue = false;
}
});
cy.step("Payment Methods Call", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Payment Methods Call");
return;
}
cy.paymentMethodsCallTest(globalState);
});
cy.step("Confirm Payment Intent", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Confirm Payment Intent");
return;
}
const confirmData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["3DSManualCapture"];
cy.confirmCallTest(
fixtures.confirmBody,
confirmData,
true,
globalState
);
if (!utils.should_continue_further(confirmData)) {
shouldContinue = false;
}
});
cy.step("Handle Redirection", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Handle Redirection");
return;
}
const expected_redirection = fixtures.confirmBody["return_url"];
cy.handleRedirection(globalState, expected_redirection);
});
cy.step("Retrieve Payment after Confirmation", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Retrieve Payment after Confirmation"
);
return;
}
const confirmData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["3DSManualCapture"];
cy.retrievePaymentCallTest({ globalState, data: confirmData });
if (!utils.should_continue_further(confirmData)) {
shouldContinue = false;
}
});
cy.step("Capture Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Capture Payment");
return;
}
const captureData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["Capture"];
cy.captureCallTest(fixtures.captureBody, captureData, globalState);
if (!utils.should_continue_further(captureData)) {
shouldContinue = false;
}
});
cy.step("Retrieve Payment after Capture", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Retrieve Payment after Capture");
return;
}
const captureData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["Capture"];
cy.retrievePaymentCallTest({ globalState, data: captureData });
if (!utils.should_continue_further(captureData)) {
shouldContinue = false;
}
});
cy.step("Refund Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Refund Payment");
return;
}
const refundData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["manualPaymentRefund"];
cy.refundCallTest(fixtures.refundBody, refundData, globalState);
if (!utils.should_continue_further(refundData)) {
shouldContinue = false;
}
});
cy.step("Sync Refund Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Sync Refund Payment");
return;
}
const syncRefundData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["SyncRefund"];
cy.syncRefundCallTest(syncRefundData, globalState);
});
});
});
context("Card - Partial Refund for fully captured 3DS payment", () => {
it("Create Payment Intent -> Payment Methods Call -> Confirm Payment Intent -> Handle Redirection -> Retrieve Payment after Confirmation -> Capture Payment -> Retrieve Payment after Capture -> Partial Refund Payment -> Partial Refund Payment - 2nd Attempt -> Sync Refund Payment", () => {
let shouldContinue = true;
cy.step("Create Payment Intent", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["PaymentIntent"];
cy.createPaymentIntentTest(
fixtures.createPaymentBody,
data,
"three_ds",
"manual",
globalState
);
if (!utils.should_continue_further(data)) {
shouldContinue = false;
}
});
cy.step("Payment Methods Call", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Payment Methods Call");
return;
}
cy.paymentMethodsCallTest(globalState);
});
cy.step("Confirm Payment Intent", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Confirm Payment Intent");
return;
}
const confirmData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["3DSManualCapture"];
cy.confirmCallTest(
fixtures.confirmBody,
confirmData,
true,
globalState
);
if (!utils.should_continue_further(confirmData)) {
shouldContinue = false;
}
});
cy.step("Handle Redirection", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Handle Redirection");
return;
}
const expected_redirection = fixtures.confirmBody["return_url"];
cy.handleRedirection(globalState, expected_redirection);
});
cy.step("Retrieve Payment after Confirmation", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Retrieve Payment after Confirmation"
);
return;
}
const confirmData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["3DSManualCapture"];
cy.retrievePaymentCallTest({ globalState, data: confirmData });
if (!utils.should_continue_further(confirmData)) {
shouldContinue = false;
}
});
cy.step("Capture Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Capture Payment");
return;
}
const captureData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["Capture"];
cy.captureCallTest(fixtures.captureBody, captureData, globalState);
if (!utils.should_continue_further(captureData)) {
shouldContinue = false;
}
});
cy.step("Retrieve Payment after Capture", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Retrieve Payment after Capture");
return;
}
const captureData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["Capture"];
cy.retrievePaymentCallTest({ globalState, data: captureData });
if (!utils.should_continue_further(captureData)) {
shouldContinue = false;
}
});
cy.step("Partial Refund Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Partial Refund Payment");
return;
}
const partialRefundData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["manualPaymentPartialRefund"];
cy.refundCallTest(fixtures.refundBody, partialRefundData, globalState);
if (!utils.should_continue_further(partialRefundData)) {
shouldContinue = false;
}
});
cy.step("Partial Refund Payment - 2nd Attempt", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Partial Refund Payment - 2nd Attempt"
);
return;
}
const partialRefundData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["manualPaymentPartialRefund"];
cy.refundCallTest(fixtures.refundBody, partialRefundData, globalState);
if (!utils.should_continue_further(partialRefundData)) {
shouldContinue = false;
}
});
cy.step("Sync Refund Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Sync Refund Payment");
return;
}
const syncRefundData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["SyncRefund"];
cy.syncRefundCallTest(syncRefundData, globalState);
});
});
});
context("Card - Full Refund for partially captured 3DS payment", () => {
it("Create Payment Intent -> Payment Methods Call -> Confirm Payment Intent -> Handle Redirection -> Retrieve Payment after Confirmation -> Partial Capture Payment -> Retrieve Payment after Partial Capture -> Refund Payment -> Sync Refund Payment", () => {
let shouldContinue = true;
cy.step("Create Payment Intent", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["PaymentIntent"];
cy.createPaymentIntentTest(
fixtures.createPaymentBody,
data,
"three_ds",
"manual",
globalState
);
if (!utils.should_continue_further(data)) {
shouldContinue = false;
}
});
cy.step("Payment Methods Call", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Payment Methods Call");
return;
}
cy.paymentMethodsCallTest(globalState);
});
cy.step("Confirm Payment Intent", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Confirm Payment Intent");
return;
}
const confirmData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["3DSManualCapture"];
cy.confirmCallTest(
fixtures.confirmBody,
confirmData,
true,
globalState
);
if (!utils.should_continue_further(confirmData)) {
shouldContinue = false;
}
});
cy.step("Handle Redirection", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Handle Redirection");
return;
}
const expected_redirection = fixtures.confirmBody["return_url"];
cy.handleRedirection(globalState, expected_redirection);
});
cy.step("Retrieve Payment after Confirmation", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Retrieve Payment after Confirmation"
);
return;
}
const confirmData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["3DSManualCapture"];
cy.retrievePaymentCallTest({ globalState, data: confirmData });
if (!utils.should_continue_further(confirmData)) {
shouldContinue = false;
}
});
cy.step("Partial Capture Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Partial Capture Payment");
return;
}
const partialCaptureData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["PartialCapture"];
cy.captureCallTest(
fixtures.captureBody,
partialCaptureData,
globalState
);
if (!utils.should_continue_further(partialCaptureData)) {
shouldContinue = false;
}
});
cy.step("Retrieve Payment after Partial Capture", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Retrieve Payment after Partial Capture"
);
return;
}
const partialCaptureData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["PartialCapture"];
cy.retrievePaymentCallTest({ globalState, data: partialCaptureData });
if (!utils.should_continue_further(partialCaptureData)) {
shouldContinue = false;
}
});
cy.step("Refund Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Refund Payment");
return;
}
const partialRefundData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["manualPaymentPartialRefund"];
cy.refundCallTest(fixtures.refundBody, partialRefundData, globalState);
if (!utils.should_continue_further(partialRefundData)) {
shouldContinue = false;
}
});
cy.step("Sync Refund Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Sync Refund Payment");
return;
}
const syncRefundData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["SyncRefund"];
cy.syncRefundCallTest(syncRefundData, globalState);
});
});
});
context("Card - Partial Refund for partially captured 3DS payment", () => {
it("Create Payment Intent -> Payment Methods Call -> Confirm Payment Intent -> Handle Redirection -> Retrieve Payment after Confirmation -> Partial Capture Payment -> Retrieve Payment after Partial Capture -> Partial Refund Payment -> Sync Refund Payment", () => {
let shouldContinue = true;
cy.step("Create Payment Intent", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["PaymentIntent"];
cy.createPaymentIntentTest(
fixtures.createPaymentBody,
data,
"three_ds",
"manual",
globalState
);
if (!utils.should_continue_further(data)) {
shouldContinue = false;
}
});
cy.step("Payment Methods Call", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Payment Methods Call");
return;
}
cy.paymentMethodsCallTest(globalState);
});
cy.step("Confirm Payment Intent", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Confirm Payment Intent");
return;
}
const confirmData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["3DSManualCapture"];
cy.confirmCallTest(
fixtures.confirmBody,
confirmData,
true,
globalState
);
if (!utils.should_continue_further(confirmData)) {
shouldContinue = false;
}
});
cy.step("Handle Redirection", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Handle Redirection");
return;
}
const expected_redirection = fixtures.confirmBody["return_url"];
cy.handleRedirection(globalState, expected_redirection);
});
cy.step("Retrieve Payment after Confirmation", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Retrieve Payment after Confirmation"
);
return;
}
const confirmData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["3DSManualCapture"];
cy.retrievePaymentCallTest({ globalState, data: confirmData });
if (!utils.should_continue_further(confirmData)) {
shouldContinue = false;
}
});
cy.step("Partial Capture Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Partial Capture Payment");
return;
}
const partialCaptureData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["PartialCapture"];
cy.captureCallTest(
fixtures.captureBody,
partialCaptureData,
globalState
);
if (!utils.should_continue_further(partialCaptureData)) {
shouldContinue = false;
}
});
cy.step("Retrieve Payment after Partial Capture", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Retrieve Payment after Partial Capture"
);
return;
}
const partialCaptureData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["PartialCapture"];
cy.retrievePaymentCallTest({ globalState, data: partialCaptureData });
if (!utils.should_continue_further(partialCaptureData)) {
shouldContinue = false;
}
});
cy.step("Partial Refund Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Partial Refund Payment");
return;
}
const partialRefundData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["manualPaymentPartialRefund"];
const newPartialRefundData = {
...partialRefundData,
Request: { amount: partialRefundData.Request.amount / 2 },
};
cy.refundCallTest(
fixtures.refundBody,
newPartialRefundData,
globalState
);
if (!utils.should_continue_further(partialRefundData)) {
shouldContinue = false;
}
});
cy.step("Sync Refund Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Sync Refund Payment");
return;
}
const syncRefundData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["SyncRefund"];
cy.syncRefundCallTest(syncRefundData, globalState);
});
});
});
});
describe("Card - Refund Manual Update - No 3DS", () => {
before(function () {
let skip = false;
cy.task("getGlobalState")
.then((state) => {
globalState = new State(state);
const connector = globalState.get("connectorId");
if (
utils.shouldIncludeConnector(
connector,
utils.CONNECTOR_LISTS.INCLUDE.REFUND_MANUAL_UPDATE
)
) {
skip = true;
}
})
.then(() => {
if (skip) {
this.skip();
}
});
});
beforeEach(function () {
if (isMockServer()) {
this.skip();
}
});
afterEach("flush global state", () => {
cy.task("setGlobalState", globalState.data);
});
context("Manual Update - Status Change (succeeded -> succeeded)", () => {
it("Create Payment Intent -> Confirm Payment -> Create Refund -> Manual Update Status -> Retrieve Refund to Verify", () => {
let shouldContinue = true;
cy.step("Create Payment Intent", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["PaymentIntent"];
cy.createPaymentIntentTest(
fixtures.createPaymentBody,
data,
"no_three_ds",
"automatic",
globalState
);
if (!utils.should_continue_further(data)) {
shouldContinue = false;
}
});
cy.step("Payment Methods Call", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Payment Methods Call");
return;
}
cy.paymentMethodsCallTest(globalState);
});
cy.step("Confirm Payment Intent", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Confirm Payment Intent");
return;
}
const confirmData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["No3DSAutoCapture"];
cy.confirmCallTest(
fixtures.confirmBody,
confirmData,
true,
globalState
);
if (!utils.should_continue_further(confirmData)) {
shouldContinue = false;
}
});
cy.step("Create Refund", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Create Refund");
return;
}
const refundData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["Refund"];
cy.refundCallTest(fixtures.refundBody, refundData, globalState);
if (!utils.should_continue_further(refundData)) {
shouldContinue = false;
}
});
cy.step("Manual Update Refund Status to Succeeded", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Manual Update Refund Status to Succeeded"
);
return;
}
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["ManualRefundUpdate"];
cy.manualRefundStatusUpdateTest(globalState, data);
if (!utils.should_continue_further(data)) {
shouldContinue = false;
}
});
cy.step("Retrieve Refund to Verify Status Update", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Retrieve Refund to Verify Status Update"
);
return;
}
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["SyncRefundManualUpdateSucceeded"];
cy.syncRefundCallTest(data, globalState);
});
});
});
context("Manual Update - Set Error Code and Error Message", () => {
it("Create Payment Intent -> Confirm Payment -> Create Refund -> Manual Update Error Code/Message -> Retrieve Refund to Verify", () => {
let shouldContinue = true;
cy.step("Create Payment Intent", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["PaymentIntent"];
cy.createPaymentIntentTest(
fixtures.createPaymentBody,
data,
"no_three_ds",
"automatic",
globalState
);
if (!utils.should_continue_further(data)) {
shouldContinue = false;
}
});
cy.step("Payment Methods Call", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Payment Methods Call");
return;
}
cy.paymentMethodsCallTest(globalState);
});
cy.step("Confirm Payment Intent", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Confirm Payment Intent");
return;
}
const confirmData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["No3DSAutoCapture"];
cy.confirmCallTest(
fixtures.confirmBody,
confirmData,
true,
globalState
);
if (!utils.should_continue_further(confirmData)) {
shouldContinue = false;
}
});
cy.step("Create Refund", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Create Refund");
return;
}
const refundData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["Refund"];
cy.refundCallTest(fixtures.refundBody, refundData, globalState);
if (!utils.should_continue_further(refundData)) {
shouldContinue = false;
}
});
cy.step("Manual Update Error Code and Error Message", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Manual Update Error Code and Error Message"
);
return;
}
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["ManualRefundUpdateErrorCode"];
cy.manualRefundStatusUpdateTest(globalState, data);
if (!utils.should_continue_further(data)) {
shouldContinue = false;
}
});
cy.step("Retrieve Refund to Verify Error Code and Message", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Retrieve Refund to Verify Error Code and Message"
);
return;
}
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["SyncRefundManualUpdateErrorCode"];
cy.syncRefundCallTest(data, globalState);
});
});
});
context("Manual Update - Partial Refund Status Update", () => {
it("Create Payment Intent -> Confirm Payment -> Create Partial Refund -> Manual Update Status -> Retrieve Refund to Verify", () => {
let shouldContinue = true;
cy.step("Create Payment Intent", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["PaymentIntent"];
cy.createPaymentIntentTest(
fixtures.createPaymentBody,
data,
"no_three_ds",
"automatic",
globalState
);
if (!utils.should_continue_further(data)) {
shouldContinue = false;
}
});
cy.step("Payment Methods Call", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Payment Methods Call");
return;
}
cy.paymentMethodsCallTest(globalState);
});
cy.step("Confirm Payment Intent", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Confirm Payment Intent");
return;
}
const confirmData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["No3DSAutoCapture"];
cy.confirmCallTest(
fixtures.confirmBody,
confirmData,
true,
globalState
);
if (!utils.should_continue_further(confirmData)) {
shouldContinue = false;
}
});
cy.step("Create Partial Refund", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Create Partial Refund");
return;
}
const partialRefundData = getConnectorDetails(
globalState.get("connectorId")
)["card_pm"]["PartialRefund"];
cy.refundCallTest(fixtures.refundBody, partialRefundData, globalState);
if (!utils.should_continue_further(partialRefundData)) {
shouldContinue = false;
}
});
cy.step("Manual Update Partial Refund Status to Succeeded", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Manual Update Partial Refund Status to Succeeded"
);
return;
}
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["ManualRefundUpdatePartialRefund"];
cy.manualRefundStatusUpdateTest(globalState, data);
if (!utils.should_continue_further(data)) {
shouldContinue = false;
}
});
cy.step("Retrieve Partial Refund to Verify Status Update", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Retrieve Partial Refund to Verify Status Update"
);
return;
}
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["SyncRefundManualUpdatePartialRefund"];
cy.syncRefundCallTest(data, globalState);
});
});
});
context("Manual Update - Idempotency Test (Multiple Updates)", () => {
it("Create Payment Intent -> Confirm Payment -> Create Refund -> Manual Update 1 -> Manual Update 2 (Same Data) -> Retrieve to Verify Idempotency", () => {
let shouldContinue = true;
cy.step("Create Payment Intent", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["PaymentIntent"];
cy.createPaymentIntentTest(
fixtures.createPaymentBody,
data,
"no_three_ds",
"automatic",
globalState
);
if (!utils.should_continue_further(data)) {
shouldContinue = false;
}
});
cy.step("Payment Methods Call", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Payment Methods Call");
return;
}
cy.paymentMethodsCallTest(globalState);
});
cy.step("Confirm Payment Intent", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Confirm Payment Intent");
return;
}
const confirmData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["No3DSAutoCapture"];
cy.confirmCallTest(
fixtures.confirmBody,
confirmData,
true,
globalState
);
if (!utils.should_continue_further(confirmData)) {
shouldContinue = false;
}
});
cy.step("Create Refund", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Create Refund");
return;
}
const refundData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["Refund"];
cy.refundCallTest(fixtures.refundBody, refundData, globalState);
if (!utils.should_continue_further(refundData)) {
shouldContinue = false;
}
});
cy.step("Manual Update 1 - Set Error Code and Message", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Manual Update 1 - Set Error Code and Message"
);
return;
}
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["ManualRefundUpdateIdempotency"];
cy.manualRefundStatusUpdateTest(globalState, data);
if (!utils.should_continue_further(data)) {
shouldContinue = false;
}
});
cy.step("Manual Update 2 - Same Data (Idempotency Check)", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Manual Update 2 - Same Data (Idempotency Check)"
);
return;
}
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["ManualRefundUpdateIdempotency"];
cy.manualRefundStatusUpdateTest(globalState, data);
if (!utils.should_continue_further(data)) {
shouldContinue = false;
}
});
cy.step("Retrieve Refund to Verify Idempotency", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Retrieve Refund to Verify Idempotency"
);
return;
}
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["SyncRefundManualUpdateIdempotency"];
cy.syncRefundCallTest(data, globalState);
});
});
});
context("Manual Update - Unset Error Code and Error Message", () => {
it("Create Payment Intent -> Confirm Payment -> Create Refund -> Manual Update with Error -> Unset Error Fields -> Retrieve to Verify", () => {
let shouldContinue = true;
cy.step("Create Payment Intent", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["PaymentIntent"];
cy.createPaymentIntentTest(
fixtures.createPaymentBody,
data,
"no_three_ds",
"automatic",
globalState
);
if (!utils.should_continue_further(data)) {
shouldContinue = false;
}
});
cy.step("Payment Methods Call", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Payment Methods Call");
return;
}
cy.paymentMethodsCallTest(globalState);
});
cy.step("Confirm Payment Intent", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Confirm Payment Intent");
return;
}
const confirmData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["No3DSAutoCapture"];
cy.confirmCallTest(
fixtures.confirmBody,
confirmData,
true,
globalState
);
if (!utils.should_continue_further(confirmData)) {
shouldContinue = false;
}
});
cy.step("Create Refund", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Create Refund");
return;
}
const refundData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["Refund"];
cy.refundCallTest(fixtures.refundBody, refundData, globalState);
if (!utils.should_continue_further(refundData)) {
shouldContinue = false;
}
});
cy.step("Manual Update with Error Code and Message", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Manual Update with Error Code and Message"
);
return;
}
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["ManualRefundUpdateErrorCode"];
cy.manualRefundStatusUpdateTest(globalState, data);
if (!utils.should_continue_further(data)) {
shouldContinue = false;
}
});
cy.step("Unset Error Code and Error Message", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Unset Error Code and Error Message"
);
return;
}
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["ManualRefundUpdateUnset"];
cy.manualRefundStatusUpdateTest(globalState, data);
if (!utils.should_continue_further(data)) {
shouldContinue = false;
}
});
cy.step("Retrieve Refund to Verify Unset Fields", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Retrieve Refund to Verify Unset Fields"
);
return;
}
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["SyncRefundManualUpdateUnset"];
cy.syncRefundCallTest(data, globalState);
});
});
});
context("Manual Update - Connector Refund ID", () => {
it("Create Payment Intent -> Confirm Payment -> Create Refund -> Manual Update Connector Refund ID -> Retrieve Refund to Verify", () => {
let shouldContinue = true;
cy.step("Create Payment Intent", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["PaymentIntent"];
cy.createPaymentIntentTest(
fixtures.createPaymentBody,
data,
"no_three_ds",
"automatic",
globalState
);
if (!utils.should_continue_further(data)) {
shouldContinue = false;
}
});
cy.step("Payment Methods Call", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Payment Methods Call");
return;
}
cy.paymentMethodsCallTest(globalState);
});
cy.step("Confirm Payment Intent", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Confirm Payment Intent");
return;
}
const confirmData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["No3DSAutoCapture"];
cy.confirmCallTest(
fixtures.confirmBody,
confirmData,
true,
globalState
);
if (!utils.should_continue_further(confirmData)) {
shouldContinue = false;
}
});
cy.step("Create Refund", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Create Refund");
return;
}
const refundData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["Refund"];
cy.refundCallTest(fixtures.refundBody, refundData, globalState);
if (!utils.should_continue_further(refundData)) {
shouldContinue = false;
}
});
cy.step("Manual Update Connector Refund ID", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Manual Update Connector Refund ID"
);
return;
}
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["ManualRefundUpdateConnectorRefundId"];
cy.manualRefundStatusUpdateTest(globalState, data);
if (!utils.should_continue_further(data)) {
shouldContinue = false;
}
});
cy.step("Retrieve Refund to Verify Connector Refund ID", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Retrieve Refund to Verify Connector Refund ID"
);
return;
}
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["SyncRefundManualUpdateConnectorRefundId"];
cy.syncRefundCallTest(data, globalState);
});
});
});
context("Manual Update - Connector Refund ID with Status", () => {
it("Create Payment Intent -> Confirm Payment -> Create Refund -> Manual Update Connector Refund ID and Status -> Retrieve Refund to Verify", () => {
let shouldContinue = true;
cy.step("Create Payment Intent", () => {
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["PaymentIntent"];
cy.createPaymentIntentTest(
fixtures.createPaymentBody,
data,
"no_three_ds",
"automatic",
globalState
);
if (!utils.should_continue_further(data)) {
shouldContinue = false;
}
});
cy.step("Payment Methods Call", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Payment Methods Call");
return;
}
cy.paymentMethodsCallTest(globalState);
});
cy.step("Confirm Payment Intent", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Confirm Payment Intent");
return;
}
const confirmData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["No3DSAutoCapture"];
cy.confirmCallTest(
fixtures.confirmBody,
confirmData,
true,
globalState
);
if (!utils.should_continue_further(confirmData)) {
shouldContinue = false;
}
});
cy.step("Create Refund", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Create Refund");
return;
}
const refundData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["Refund"];
cy.refundCallTest(fixtures.refundBody, refundData, globalState);
if (!utils.should_continue_further(refundData)) {
shouldContinue = false;
}
});
cy.step("Manual Update Connector Refund ID and Status", () => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Manual Update Connector Refund ID and Status"
);
return;
}
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["ManualRefundUpdateConnectorRefundIdWithStatus"];
cy.manualRefundStatusUpdateTest(globalState, data);
if (!utils.should_continue_further(data)) {
shouldContinue = false;
}
});
cy.step(
"Retrieve Refund to Verify Connector Refund ID and Status",
() => {
if (!shouldContinue) {
cy.task(
"cli_log",
"Skipping step: Retrieve Refund to Verify Connector Refund ID and Status"
);
return;
}
const data = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["SyncRefundManualUpdateConnectorRefundIdWithStatus"];
cy.syncRefundCallTest(data, globalState);
}
);
});
});
});