-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9def2e6
commit 08bfd71
Showing
83 changed files
with
555 additions
and
494 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...s-tests/cypress/e2e/PaymentUtils/Adyen.js → ...ests/cypress/e2e/configs/Payment/Adyen.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 2 additions & 4 deletions
6
...s/cypress/e2e/PaymentUtils/Cybersource.js → ...ypress/e2e/configs/Payment/Cybersource.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...-tests/cypress/e2e/PaymentUtils/Paypal.js → ...sts/cypress/e2e/configs/Payment/Paypal.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...-tests/cypress/e2e/PaymentUtils/Stripe.js → ...sts/cypress/e2e/configs/Payment/Stripe.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ests/cypress/e2e/PaymentUtils/Trustpay.js → ...s/cypress/e2e/configs/Payment/Trustpay.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...s-tests/cypress/e2e/PaymentUtils/Utils.js → ...ests/cypress/e2e/configs/Payment/Utils.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...ests/cypress/e2e/PaymentUtils/WorldPay.js → ...s/cypress/e2e/configs/Payment/WorldPay.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ss-tests/cypress/e2e/PayoutUtils/Utils.js → ...tests/cypress/e2e/configs/Payout/Utils.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.