Skip to content

Commit

Permalink
redo: resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
pixincreate committed Jan 7, 2025
1 parent 9def2e6 commit 08bfd71
Show file tree
Hide file tree
Showing 83 changed files with 555 additions and 494 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getCustomExchange } from "./Commons";
import { getCustomExchange } from "./_Reusable";

const successfulNo3DSCardDetails = {
card_number: "4111111111111111",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,45 +1,5 @@
// This file is the default. To override, add to connector.js
import State from "../../utils/State";

const globalState = new State({
connectorId: Cypress.env("CONNECTOR"),
baseUrl: Cypress.env("BASEURL"),
adminApiKey: Cypress.env("ADMINAPIKEY"),
connectorAuthFilePath: Cypress.env("CONNECTOR_AUTH_FILE_PATH"),
});

const connectorName = normalize(globalState.get("connectorId"));

function normalize(input) {
const exceptions = {
bankofamerica: "Bank of America",
cybersource: "Cybersource",
paybox: "Paybox",
paypal: "Paypal",
wellsfargo: "Wellsfargo",
fiuu: "Fiuu",
noon: "Noon",
// Add more known exceptions here
};

if (typeof input !== "string") {
const specName = Cypress.spec.name;

if (specName.includes("-")) {
const parts = specName.split("-");

if (parts.length > 1 && parts[1].includes(".")) {
return parts[1].split(".")[0];
}
}

// Fallback
return `${specName}`;
}

const lowerCaseInput = input.toLowerCase();
return exceptions[lowerCaseInput] || input;
}
import { getCustomExchange } from "./_Reusable";

const successfulNo3DSCardDetails = {
card_number: "4111111111111111",
Expand Down Expand Up @@ -141,68 +101,6 @@ export const fullNameRequiredField = {
};

export const billingRequiredField = {};
/*
`getDefaultExchange` contains the default Request and Response to be considered if none provided.
`getCustomExchange` takes in 2 optional fields named as Request and Response.
with `getCustomExchange`, if 501 response is expected, there is no need to pass Response as it considers default values.
*/

// Const to get default PaymentExchange object
const getDefaultExchange = () => ({
Request: {},
Response: {
status: 501,
body: {
error: {
type: "invalid_request",
message: `Selected payment method through ${connectorName} is not implemented`,
code: "IR_00",
},
},
},
});

const getUnsupportedExchange = () => ({
Request: {
currency: "EUR",
},
Response: {
status: 400,
body: {
error: {
type: "invalid_request",
message: `Payment method type not supported`,
code: "IR_19",
},
},
},
});

// Const to get PaymentExchange with overridden properties
export const getCustomExchange = (overrides) => {
const defaultExchange = getDefaultExchange();

return {
...defaultExchange,
...(overrides.Configs ? { Configs: overrides.Configs } : {}),
Request: {
...defaultExchange.Request,
...(overrides.Request || {}),
},
Response: {
...defaultExchange.Response,
...(overrides.Response || {}),
},
...(overrides.ResponseCustom
? { ResponseCustom: overrides.ResponseCustom }
: {}),
};
};

// Function to update the default status code
export const updateDefaultStatusCode = () => {
return getUnsupportedExchange().Response;
};

export const payment_methods_enabled = [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import {
connectorDetails as commonConnectorDetails,
getCustomExchange,
} from "./Commons";
import { getCustomExchange } from "./_Reusable";
import { connectorDetails as commonConnectorDetails } from "./Commons";

const successfulNo3DSCardDetails = {
card_number: "4242424242424242",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getCustomExchange } from "./Commons";
import { getCustomExchange } from "./_Reusable";

const successfulNo3DSCardDetails = {
card_number: "4012000033330026",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
cardRequiredField,
connectorDetails as commonConnectorDetails,
getCustomExchange,
} from "./Commons";
import { getCustomExchange } from "./_Reusable";

const successfulNo3DSCardDetails = {
card_number: "4242424242424242",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getCustomExchange } from "./Commons";
import { getCustomExchange } from "./_Reusable";

const successfulNo3DSCardDetails = {
card_number: "4200000000000000",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { execConfig, validateConfig } from "../../utils/featureFlags.js";
import { execConfig, validateConfig } from "../../../utils/featureFlags.js";

import { connectorDetails as adyenConnectorDetails } from "./Adyen.js";
import { connectorDetails as bankOfAmericaConnectorDetails } from "./BankOfAmerica.js";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getCustomExchange } from "./Commons";
import { getCustomExchange } from "./_Reusable";

const billing = {
address: {
Expand Down
104 changes: 104 additions & 0 deletions cypress-tests/cypress/e2e/configs/Payment/_Reusable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import State from "../../../utils/State";

const globalState = new State({
connectorId: Cypress.env("CONNECTOR"),
baseUrl: Cypress.env("BASEURL"),
adminApiKey: Cypress.env("ADMINAPIKEY"),
connectorAuthFilePath: Cypress.env("CONNECTOR_AUTH_FILE_PATH"),
});

const connectorName = normalize(globalState.get("connectorId"));

function normalize(input) {
const exceptions = {
bankofamerica: "Bank of America",
cybersource: "Cybersource",
paybox: "Paybox",
paypal: "Paypal",
wellsfargo: "Wellsfargo",
fiuu: "Fiuu",
noon: "Noon",
// Add more known exceptions here
};

if (typeof input !== "string") {
const specName = Cypress.spec.name;

if (specName.includes("-")) {
const parts = specName.split("-");

if (parts.length > 1 && parts[1].includes(".")) {
return parts[1].split(".")[0];
}
}

// Fallback
return `${specName}`;
}

const lowerCaseInput = input.toLowerCase();
return exceptions[lowerCaseInput] || input;
}

/*
`getDefaultExchange` contains the default Request and Response to be considered if none provided.
`getCustomExchange` takes in 2 optional fields named as Request and Response.
with `getCustomExchange`, if 501 response is expected, there is no need to pass Response as it considers default values.
*/

// Const to get default PaymentExchange object
const getDefaultExchange = () => ({
Request: {},
Response: {
status: 501,
body: {
error: {
type: "invalid_request",
message: `Selected payment method through ${connectorName} is not implemented`,
code: "IR_00",
},
},
},
});

const getUnsupportedExchange = () => ({
Request: {
currency: "EUR",
},
Response: {
status: 400,
body: {
error: {
type: "invalid_request",
message: `Payment method type not supported`,
code: "IR_19",
},
},
},
});

// Const to get PaymentExchange with overridden properties
export const getCustomExchange = (overrides) => {
const defaultExchange = getDefaultExchange();

return {
...defaultExchange,
...(overrides.Configs ? { Configs: overrides.Configs } : {}),
Request: {
...defaultExchange.Request,
...(overrides.Request || {}),
},
Response: {
...defaultExchange.Response,
...(overrides.Response || {}),
},
...(overrides.ResponseCustom
? { ResponseCustom: overrides.ResponseCustom }
: {}),
};
};

// Function to update the default status code
export const updateDefaultStatusCode = () => {
return getUnsupportedExchange().Response;
};
Original file line number Diff line number Diff line change
@@ -1,44 +1,5 @@
// This file is the default. To override, add to connector.js
import State from "../../utils/State";

const globalState = new State({
connectorId: Cypress.env("CONNECTOR"),
baseUrl: Cypress.env("BASEURL"),
adminApiKey: Cypress.env("ADMINAPIKEY"),
connectorAuthFilePath: Cypress.env("CONNECTOR_AUTH_FILE_PATH"),
});

const connectorName = normalise(globalState.get("connectorId"));

function normalise(input) {
const exceptions = {
adyenplatform: "Adyenplatform",
wise: "Wise",
wellsfargo: "Wellsfargo",
// Add more known exceptions here
};

if (typeof input !== "string") {
const specName = Cypress.spec.name;

if (specName.includes("-")) {
const parts = specName.split("-");

if (parts.length > 1 && parts[1].includes(".")) {
return parts[1].split(".")[0];
}
}

// Fallback
return `${specName}`;
}

if (exceptions[input.toLowerCase()]) {
return exceptions[input.toLowerCase()];
} else {
return input;
}
}
import { getCustomExchange } from "./_Reusable";

const card_data = {
card_number: "4111111111111111",
Expand Down Expand Up @@ -71,44 +32,6 @@ const billing = {
},
};

/*
`getDefaultExchange` contains the default Request and Response to be considered if none provided.
`getCustomExchange` takes in 2 optional fields named as Request and Response.
with `getCustomExchange`, if 501 response is expected, there is no need to pass Response as it considers default values.
*/

// Const to get default PaymentExchange object
const getDefaultExchange = () => ({
Request: {},
Response: {
status: 501,
body: {
error: {
type: "invalid_request",
message: `Selected payment method through ${connectorName} is not implemented`,
code: "IR_00",
},
},
},
});

// Const to get PaymentExchange with overridden properties
export const getCustomExchange = (overrides) => {
const defaultExchange = getDefaultExchange();

return {
...defaultExchange,
Request: {
...defaultExchange.Request,
...(overrides.Request || {}),
},
Response: {
...defaultExchange.Response,
...(overrides.Response || {}),
},
};
};

export const connectorDetails = {
card_pm: {
Create: getCustomExchange({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { validateConfig } from "../../utils/featureFlags.js";
import { validateConfig } from "../../../utils/featureFlags.js";

import { connectorDetails as adyenConnectorDetails } from "./Adyen.js";
import { connectorDetails as adyenPlatformConnectorDetails } from "./AdyenPlatform.js";
Expand Down
Loading

0 comments on commit 08bfd71

Please sign in to comment.