diff --git a/extension/extension-trigger/index.azureFunction.js b/extension/extension-trigger/index.azureFunction.js index 1b28207ef..0cc3b384b 100644 --- a/extension/extension-trigger/index.azureFunction.js +++ b/extension/extension-trigger/index.azureFunction.js @@ -42,7 +42,7 @@ export const azureExtensionTrigger = async function (context, req) { try { const paymentResult = await paymentHandler.handlePayment( paymentObj, - authToken + authToken, ) if (paymentResult.actions) diff --git a/extension/index.googleFunction.js b/extension/index.googleFunction.js index c3cb8bac9..39dde8afc 100644 --- a/extension/index.googleFunction.js +++ b/extension/index.googleFunction.js @@ -20,7 +20,7 @@ export const extensionTrigger = async (request, response) => { const authToken = getAuthorizationRequestHeader(request) const paymentResult = await paymentHandler.handlePayment( paymentObj, - authToken + authToken, ) if (paymentResult.actions) { return response.status(200).send({ diff --git a/extension/index.lambda.js b/extension/index.lambda.js index c480ae17d..20e27bf43 100644 --- a/extension/index.lambda.js +++ b/extension/index.lambda.js @@ -21,7 +21,7 @@ let handler = async (event) => { const authToken = getAuthorizationRequestHeader(event) const paymentResult = await paymentHandler.handlePayment( paymentObj, - authToken + authToken, ) return { responseType: paymentResult.actions diff --git a/extension/src/api/payment/payment.controller.js b/extension/src/api/payment/payment.controller.js index 6774ff0ca..0fe9d4375 100644 --- a/extension/src/api/payment/payment.controller.js +++ b/extension/src/api/payment/payment.controller.js @@ -10,7 +10,7 @@ async function processRequest(request, response) { // API extensions always calls this endpoint with POST, so if we got GET, we don't process further // https://docs.commercetools.com/api/projects/api-extensions#input logger.debug( - `Received non-POST request: ${request.method}. The request will not be processed...` + `Received non-POST request: ${request.method}. The request will not be processed...`, ) return httpUtils.sendResponse({ response, @@ -33,7 +33,7 @@ async function processRequest(request, response) { logger.debug('Received payment object', JSON.stringify(paymentObject)) const paymentResult = await paymentHandler.handlePayment( paymentObject, - authToken + authToken, ) const result = { response, diff --git a/extension/src/config/config-loader.js b/extension/src/config/config-loader.js index 7107e1cc7..a50c1f0e2 100644 --- a/extension/src/config/config-loader.js +++ b/extension/src/config/config-loader.js @@ -13,7 +13,7 @@ function loadFromAdyenIntegrationEnvVar() { return JSON.parse(process.env.ADYEN_INTEGRATION_CONFIG) } catch (e) { throw new Error( - 'Adyen integration configuration is not provided in the JSON format' + 'Adyen integration configuration is not provided in the JSON format', ) } } diff --git a/extension/src/config/config.js b/extension/src/config/config.js index 5d089a0cd..e5f32503b 100644 --- a/extension/src/config/config.js +++ b/extension/src/config/config.js @@ -6,7 +6,7 @@ function getModuleConfig() { return { removeSensitiveData: _getValueOfBooleanFlag( config.removeSensitiveData, - true + true, ), port: config.port, logLevel: config.logLevel, @@ -19,11 +19,11 @@ function getModuleConfig() { : undefined, addCommercetoolsLineItems: _getValueOfBooleanFlag( config.addCommercetoolsLineItems, - false + false, ), generateIdempotencyKey: _getValueOfBooleanFlag( config.generateIdempotencyKey, - false + false, ), } } @@ -67,7 +67,7 @@ function getCtpConfig(ctpProjectKey) { const ctpConfig = config.commercetools[ctpProjectKey] if (!ctpConfig) throw new Error( - `Configuration is not provided. Please update the configuration. ctpProjectKey: [${ctpProjectKey}]` + `Configuration is not provided. Please update the configuration. ctpProjectKey: [${ctpProjectKey}]`, ) const result = { clientId: ctpConfig.clientId, @@ -93,8 +93,8 @@ function getAdyenConfig(adyenMerchantAccount) { if (!adyenConfig) throw new Error( `Configuration for adyenMerchantAccount is not provided. Please update the configuration: ${JSON.stringify( - adyenMerchantAccount - )}` + adyenMerchantAccount, + )}`, ) return { apiKey: adyenConfig.apiKey, @@ -132,26 +132,26 @@ function loadAndValidateConfig() { const numberOfAdyenConfigs = Object.keys(config.adyen).length if (numberOfCtpConfigs === 0) throw new Error( - 'Please add at least one commercetools project to the config' + 'Please add at least one commercetools project to the config', ) if (numberOfAdyenConfigs === 0) throw new Error( - 'Please add at least one Adyen merchant account to the config' + 'Please add at least one Adyen merchant account to the config', ) for (const [ctpProjectKey, ctpConfig] of Object.entries( - config.commercetools + config.commercetools, )) { if (!ctpConfig.clientId || !ctpConfig.clientSecret) throw new Error( `[${ctpProjectKey}]: CTP project credentials are missing. ` + - 'Please verify that all projects have projectKey, clientId and clientSecret' + 'Please verify that all projects have projectKey, clientId and clientSecret', ) const errorMessage = _validateAuthenticationConfig(ctpConfig) if (errorMessage) { throw new Error( `Authentication is not properly configured. Please update the configuration. error : [${errorMessage}] - ctpProjectKey: [${ctpProjectKey}]` + ctpProjectKey: [${ctpProjectKey}]`, ) } } diff --git a/extension/src/config/init/ensure-api-extensions.js b/extension/src/config/init/ensure-api-extensions.js index ddf38b1de..2a8a37135 100644 --- a/extension/src/config/init/ensure-api-extensions.js +++ b/extension/src/config/init/ensure-api-extensions.js @@ -8,10 +8,10 @@ async function ensureApiExtensions( ctpClient, ctpProjectKey, ctpAdyenIntegrationBaseUrl, - ctpAuthHeaderValue + ctpAuthHeaderValue, ) { const apiExtensionTemplate = await utils.readAndParseJsonFile( - 'resources/api-extension.json' + 'resources/api-extension.json', ) try { const logger = mainLogger.child({ @@ -20,25 +20,25 @@ async function ensureApiExtensions( const extensionDraft = JSON.parse( _.template(JSON.stringify(apiExtensionTemplate))({ ctpAdyenIntegrationBaseUrl, - }) + }), ) if (ctpAuthHeaderValue) { extensionDraft.destination.authentication = JSON.parse( `{` + ` "type": "AuthorizationHeader",` + ` "headerValue": "${ctpAuthHeaderValue}"` + - ` }` + ` }`, ) } const existingExtension = await fetchExtensionByKey( ctpClient, - apiExtensionTemplate.key + apiExtensionTemplate.key, ) if (existingExtension === null) { await ctpClient.create(ctpClient.builder.extensions, extensionDraft) logger.info( 'Successfully created an API extension for payment resource type ' + - `(key=${apiExtensionTemplate.key})` + `(key=${apiExtensionTemplate.key})`, ) } else { const actions = buildUpdateActions(existingExtension, extensionDraft) @@ -47,18 +47,18 @@ async function ensureApiExtensions( ctpClient.builder.extensions, existingExtension.id, existingExtension.version, - actions + actions, ) logger.info( 'Successfully updated the API extension for payment resource type ' + - `(key=${apiExtensionTemplate.key})` + `(key=${apiExtensionTemplate.key})`, ) } } } catch (err) { throw Error( `Failed to sync API extension (key=${apiExtensionTemplate.key}). ` + - `Error: ${JSON.stringify(serializeError(err))}` + `Error: ${JSON.stringify(serializeError(err))}`, ) } } @@ -84,7 +84,7 @@ async function fetchExtensionByKey(ctpClient, key) { try { const { body } = await ctpClient.fetchByKey( ctpClient.builder.extensions, - key + key, ) return body } catch (err) { diff --git a/extension/src/config/init/ensure-custom-type.js b/extension/src/config/init/ensure-custom-type.js index 3038b151e..612e5893f 100644 --- a/extension/src/config/init/ensure-custom-type.js +++ b/extension/src/config/init/ensure-custom-type.js @@ -6,34 +6,34 @@ const mainLogger = utils.getLogger() async function ensurePaymentCustomType(ctpClient, ctpProjectKey) { const paymentCustomType = await utils.readAndParseJsonFile( - 'resources/web-components-payment-type.json' + 'resources/web-components-payment-type.json', ) return syncCustomType( ctpClient, createChildLogger(ctpProjectKey), - paymentCustomType + paymentCustomType, ) } async function ensureInterfaceInteractionCustomType(ctpClient, ctpProjectKey) { const interfaceInteractionType = await utils.readAndParseJsonFile( - 'resources/payment-interface-interaction-type.json' + 'resources/payment-interface-interaction-type.json', ) return syncCustomType( ctpClient, createChildLogger(ctpProjectKey), - interfaceInteractionType + interfaceInteractionType, ) } async function ensureTransactionCustomType(ctpClient, ctpProjectKey) { const interfaceInteractionType = await utils.readAndParseJsonFile( - 'resources/payment-transaction-type.json' + 'resources/payment-transaction-type.json', ) return syncCustomType( ctpClient, createChildLogger(ctpProjectKey), - interfaceInteractionType + interfaceInteractionType, ) } @@ -59,7 +59,7 @@ async function syncCustomType(ctpClient, logger, typeDraft) { ctpClient.builder.types, existingType.id, existingType.version, - updateActions + updateActions, ) logger.info(`Successfully updated the type (key=${typeDraft.key})`) } @@ -67,7 +67,7 @@ async function syncCustomType(ctpClient, logger, typeDraft) { } catch (err) { throw Error( `Failed to sync payment type (key=${typeDraft.key}). ` + - `Error: ${JSON.stringify(serializeError(err))}` + `Error: ${JSON.stringify(serializeError(err))}`, ) } } diff --git a/extension/src/config/init/ensure-resources.js b/extension/src/config/init/ensure-resources.js index 5bcd6c757..1568dedb3 100644 --- a/extension/src/config/init/ensure-resources.js +++ b/extension/src/config/init/ensure-resources.js @@ -17,7 +17,7 @@ function ensureResources( ctpClient, ctpProjectKey, apiExtensionBaseUrl, - authHeaderValue + authHeaderValue, ) { return Promise.all([ ensureCustomTypes(ctpClient, ctpProjectKey), @@ -25,7 +25,7 @@ function ensureResources( ctpClient, ctpProjectKey, apiExtensionBaseUrl, - authHeaderValue + authHeaderValue, ), ]) } diff --git a/extension/src/ctp.js b/extension/src/ctp.js index 3f26f2a53..9ed4e33fa 100644 --- a/extension/src/ctp.js +++ b/extension/src/ctp.js @@ -97,14 +97,14 @@ async function setUpClient(config) { return ctpClient.execute( this.buildRequestOptions( uri.byId(id).withVersion(version).build(), - 'DELETE' - ) + 'DELETE', + ), ) }, create(uri, body) { return ctpClient.execute( - this.buildRequestOptions(uri.build(), 'POST', body) + this.buildRequestOptions(uri.build(), 'POST', body), ) }, @@ -114,7 +114,7 @@ async function setUpClient(config) { actions, } return ctpClient.execute( - this.buildRequestOptions(uri.byId(id).build(), 'POST', body) + this.buildRequestOptions(uri.byId(id).build(), 'POST', body), ) }, @@ -134,7 +134,7 @@ async function setUpClient(config) { return this.process( this.buildRequestOptions(uri.build()), (data) => Promise.resolve(callback(data.body.results)), - opts + opts, ) }, diff --git a/extension/src/paymentHandler/amount-updates.handler.js b/extension/src/paymentHandler/amount-updates.handler.js index 2a8de6144..66aa2ce24 100644 --- a/extension/src/paymentHandler/amount-updates.handler.js +++ b/extension/src/paymentHandler/amount-updates.handler.js @@ -7,7 +7,7 @@ import c from '../config/constants.js' async function execute(paymentObject) { const amountUpdatesRequestObj = JSON.parse( - paymentObject.custom.fields.amountUpdatesRequest + paymentObject.custom.fields.amountUpdatesRequest, ) const adyenMerchantAccount = paymentObject.custom.fields.adyenMerchantAccount const commercetoolsProjectKey = @@ -15,7 +15,7 @@ async function execute(paymentObject) { const { request, response } = await updateAmount( adyenMerchantAccount, commercetoolsProjectKey, - amountUpdatesRequestObj + amountUpdatesRequestObj, ) return { actions: [ @@ -26,7 +26,7 @@ async function execute(paymentObject) { }), createSetCustomFieldAction( c.CTP_CUSTOM_FIELD_AMOUNT_UPDATES_RESPONSE, - response + response, ), ], } diff --git a/extension/src/paymentHandler/cancel-payment.handler.js b/extension/src/paymentHandler/cancel-payment.handler.js index 99a7b9335..8ed85458b 100644 --- a/extension/src/paymentHandler/cancel-payment.handler.js +++ b/extension/src/paymentHandler/cancel-payment.handler.js @@ -26,7 +26,7 @@ async function execute(paymentObject) { const { request, response } = await cancelPayment( adyenMerchantAccount, commercetoolsProjectKey, - cancelRequestObj + cancelRequestObj, ) const addInterfaceInteractionAction = createAddInterfaceInteractionAction({ @@ -38,7 +38,7 @@ async function execute(paymentObject) { const actions = [addInterfaceInteractionAction] if (!response.errorCode && response.pspReference) actions.push( - ..._createTransactionActions(paymentObject, response.pspReference) + ..._createTransactionActions(paymentObject, response.pspReference), ) return { actions } diff --git a/extension/src/paymentHandler/disable-stored-payment.handler.js b/extension/src/paymentHandler/disable-stored-payment.handler.js index cde854b68..e05072051 100644 --- a/extension/src/paymentHandler/disable-stored-payment.handler.js +++ b/extension/src/paymentHandler/disable-stored-payment.handler.js @@ -7,12 +7,12 @@ import c from '../config/constants.js' async function execute(paymentObject) { const disableStoredPaymentRequestObj = JSON.parse( - paymentObject.custom.fields.disableStoredPaymentRequest + paymentObject.custom.fields.disableStoredPaymentRequest, ) const adyenMerchantAccount = paymentObject.custom.fields.adyenMerchantAccount const { request, response } = await disableStoredPayment( adyenMerchantAccount, - disableStoredPaymentRequestObj + disableStoredPaymentRequestObj, ) return { @@ -24,7 +24,7 @@ async function execute(paymentObject) { }), createSetCustomFieldAction( c.CTP_DISABLE_STORED_PAYMENT_RESPONSE, - response + response, ), ], } diff --git a/extension/src/paymentHandler/get-carbon-offset-costs.handler.js b/extension/src/paymentHandler/get-carbon-offset-costs.handler.js index 8c31f4ab8..820c48b36 100644 --- a/extension/src/paymentHandler/get-carbon-offset-costs.handler.js +++ b/extension/src/paymentHandler/get-carbon-offset-costs.handler.js @@ -7,12 +7,12 @@ import { getCarbonOffsetCosts } from '../service/web-component-service.js' async function execute(paymentObject) { const getCarbonOffsetCostsRequestObj = JSON.parse( - paymentObject.custom.fields.getCarbonOffsetCostsRequest + paymentObject.custom.fields.getCarbonOffsetCostsRequest, ) const adyenMerchantAccount = paymentObject.custom.fields.adyenMerchantAccount const { request, response } = await getCarbonOffsetCosts( adyenMerchantAccount, - getCarbonOffsetCostsRequestObj + getCarbonOffsetCostsRequestObj, ) return { actions: [ diff --git a/extension/src/paymentHandler/get-payment-methods.handler.js b/extension/src/paymentHandler/get-payment-methods.handler.js index 41c977d7c..202533627 100644 --- a/extension/src/paymentHandler/get-payment-methods.handler.js +++ b/extension/src/paymentHandler/get-payment-methods.handler.js @@ -7,12 +7,12 @@ import { getPaymentMethods } from '../service/web-component-service.js' async function execute(paymentObject) { const getPaymentMethodsRequestObj = JSON.parse( - paymentObject.custom.fields.getPaymentMethodsRequest + paymentObject.custom.fields.getPaymentMethodsRequest, ) const adyenMerchantAccount = paymentObject.custom.fields.adyenMerchantAccount const { request, response } = await getPaymentMethods( adyenMerchantAccount, - getPaymentMethodsRequestObj + getPaymentMethodsRequestObj, ) return { actions: [ @@ -23,7 +23,7 @@ async function execute(paymentObject) { }), createSetCustomFieldAction( c.CTP_CUSTOM_FIELD_GET_PAYMENT_METHODS_RESPONSE, - response + response, ), ], } diff --git a/extension/src/paymentHandler/line-items-utils.js b/extension/src/paymentHandler/line-items-utils.js index e756b0dae..4e7466948 100644 --- a/extension/src/paymentHandler/line-items-utils.js +++ b/extension/src/paymentHandler/line-items-utils.js @@ -12,7 +12,7 @@ async function fetchMatchingCart(paymentObject, ctpProjectKey) { const { body } = await ctpClient.fetch( ctpClient.builder.carts .where(`paymentInfo(payments(id="${paymentObject.id}"))`) - .expand('shippingInfo.shippingMethod') + .expand('shippingInfo.shippingMethod'), ) return body.results[0] } @@ -53,7 +53,7 @@ function _createAdyenLineItemFromLineItem(ctpLineItem, locales) { description: _localizeOrFallback( ctpLineItem.name, locales, - KLARNA_DEFAULT_LINE_ITEM_NAME + KLARNA_DEFAULT_LINE_ITEM_NAME, ), amountIncludingTax: ctpLineItem.price.value.centAmount, taxPercentage: ctpLineItem.taxRate.amount * ADYEN_PERCENTAGE_MINOR_UNIT, @@ -67,7 +67,7 @@ function _createAdyenLineItemFromCustomLineItem(ctpLineItem, locales) { description: _localizeOrFallback( ctpLineItem.name, locales, - KLARNA_DEFAULT_LINE_ITEM_NAME + KLARNA_DEFAULT_LINE_ITEM_NAME, ), amountIncludingTax: ctpLineItem.money.centAmount, taxPercentage: ctpLineItem.taxRate.amount * ADYEN_PERCENTAGE_MINOR_UNIT, @@ -92,7 +92,7 @@ function _getShippingMethodDescription(shippingInfo, locales) { return _localizeOrFallback( shippingMethod.localizedDescription, locales, - shippingMethod.description + shippingMethod.description, ) } return shippingInfo.shippingMethodName diff --git a/extension/src/paymentHandler/make-lineitems-payment.handler.js b/extension/src/paymentHandler/make-lineitems-payment.handler.js index 2aad9cc7a..19a818615 100644 --- a/extension/src/paymentHandler/make-lineitems-payment.handler.js +++ b/extension/src/paymentHandler/make-lineitems-payment.handler.js @@ -3,22 +3,22 @@ import lineItemsUtils from './line-items-utils.js' async function execute(paymentObject) { const makePaymentRequestObj = JSON.parse( - paymentObject.custom.fields.makePaymentRequest + paymentObject.custom.fields.makePaymentRequest, ) const commercetoolsProjectKey = paymentObject.custom.fields.commercetoolsProjectKey if (!makePaymentRequestObj.lineItems) { const ctpCart = await lineItemsUtils.fetchMatchingCart( paymentObject, - commercetoolsProjectKey + commercetoolsProjectKey, ) if (ctpCart) { makePaymentRequestObj.lineItems = lineItemsUtils.createLineItems( paymentObject, - ctpCart + ctpCart, ) paymentObject.custom.fields.makePaymentRequest = JSON.stringify( - makePaymentRequestObj + makePaymentRequestObj, ) } } diff --git a/extension/src/paymentHandler/make-payment.handler.js b/extension/src/paymentHandler/make-payment.handler.js index 6752028c4..332dd2ee1 100644 --- a/extension/src/paymentHandler/make-payment.handler.js +++ b/extension/src/paymentHandler/make-payment.handler.js @@ -11,7 +11,7 @@ import { makePayment } from '../service/web-component-service.js' async function execute(paymentObject) { const makePaymentRequestObj = JSON.parse( - paymentObject.custom.fields.makePaymentRequest + paymentObject.custom.fields.makePaymentRequest, ) const adyenMerchantAccount = paymentObject.custom.fields.adyenMerchantAccount const commercetoolsProjectKey = @@ -19,7 +19,7 @@ async function execute(paymentObject) { const { request, response } = await makePayment( adyenMerchantAccount, commercetoolsProjectKey, - makePaymentRequestObj + makePaymentRequestObj, ) const actions = [ createAddInterfaceInteractionAction({ @@ -29,7 +29,7 @@ async function execute(paymentObject) { }), createSetCustomFieldAction( c.CTP_CUSTOM_FIELD_MAKE_PAYMENT_RESPONSE, - response + response, ), ] @@ -44,14 +44,14 @@ async function execute(paymentObject) { const updatePaymentAction = getPaymentKeyUpdateAction( paymentObject.key, request, - response + response, ) if (updatePaymentAction) actions.push(updatePaymentAction) const addTransactionAction = createAddTransactionActionByResponse( paymentObject.amountPlanned.centAmount, paymentObject.amountPlanned.currencyCode, - response + response, ) if (addTransactionAction) actions.push(addTransactionAction) diff --git a/extension/src/paymentHandler/manual-capture.handler.js b/extension/src/paymentHandler/manual-capture.handler.js index fb09c44be..7978463ed 100644 --- a/extension/src/paymentHandler/manual-capture.handler.js +++ b/extension/src/paymentHandler/manual-capture.handler.js @@ -31,7 +31,7 @@ async function execute(paymentObject) { adyenMerchantAccount, commercetoolsProjectKey, idempotencyKey, - manualCaptureRequestObj + manualCaptureRequestObj, ) const actions = [ @@ -43,13 +43,16 @@ async function execute(paymentObject) { ] if (!response.errorCode && response.pspReference) { actions.push( - createChangeTransactionStateAction(chargeInitialTransaction.id, 'Pending') + createChangeTransactionStateAction( + chargeInitialTransaction.id, + 'Pending', + ), ) actions.push( createChangeTransactionInteractionId( chargeInitialTransaction.id, - response.pspReference - ) + response.pspReference, + ), ) } diff --git a/extension/src/paymentHandler/payment-handler.js b/extension/src/paymentHandler/payment-handler.js index 64e3fdc9a..680f9ab0c 100644 --- a/extension/src/paymentHandler/payment-handler.js +++ b/extension/src/paymentHandler/payment-handler.js @@ -35,7 +35,7 @@ async function handlePayment(paymentObject, authToken) { const validatePaymentErrors = _validatePaymentRequest( paymentObject, - authToken + authToken, ) if (validatePaymentErrors) return { @@ -44,7 +44,7 @@ async function handlePayment(paymentObject, authToken) { const handlers = _getPaymentHandlers(paymentObject) const handlerResponses = await Promise.all( - handlers.map((handler) => handler.execute(paymentObject)) + handlers.map((handler) => handler.execute(paymentObject)), ) const handlerResponse = { actions: handlerResponses.flatMap((result) => result.actions), @@ -96,7 +96,7 @@ function _getPaymentHandlers(paymentObject) { !customFields.createSessionResponse ) { const createSessionRequestHandler = _getCreateSessionRequestHandler( - customFields.createSessionRequest + customFields.createSessionRequest, ) handlers.push(createSessionRequestHandler) } diff --git a/extension/src/paymentHandler/payment-utils.js b/extension/src/paymentHandler/payment-utils.js index fb6bd7d5c..d1181216e 100644 --- a/extension/src/paymentHandler/payment-utils.js +++ b/extension/src/paymentHandler/payment-utils.js @@ -8,7 +8,7 @@ function getAuthorizationTransactionSuccess(paymentObject) { return getTransactionWithTypesAndStates( paymentObject, ['Authorization'], - ['Success'] + ['Success'], ) } @@ -16,7 +16,7 @@ function getCancelAuthorizationTransactionInit(paymentObject) { return getTransactionWithTypesAndStates( paymentObject, ['CancelAuthorization'], - ['Initial'] + ['Initial'], ) } @@ -24,19 +24,19 @@ function listRefundTransactionsInit(paymentObject) { return listTransactionsWithTypesAndStates( paymentObject, ['Refund'], - ['Initial'] + ['Initial'], ) } function getTransactionWithTypesAndStates(paymentObject, types, states) { return paymentObject.transactions.find( - (t) => types.includes(t.type) && states.includes(t.state) + (t) => types.includes(t.type) && states.includes(t.state), ) } function listTransactionsWithTypesAndStates(paymentObject, types, states) { return paymentObject.transactions.filter( - (t) => types.includes(t.type) && states.includes(t.state) + (t) => types.includes(t.type) && states.includes(t.state), ) } @@ -147,7 +147,7 @@ function getChargeTransactionInitial(paymentObject) { return getTransactionWithTypesAndStates( paymentObject, ['Charge'], - ['Initial'] + ['Initial'], ) } @@ -155,7 +155,7 @@ function getChargeTransactionPending(paymentObject) { return getTransactionWithTypesAndStates( paymentObject, ['Charge'], - ['Pending'] + ['Pending'], ) } @@ -163,7 +163,7 @@ function getChargeTransactionSuccess(paymentObject) { return getTransactionWithTypesAndStates( paymentObject, ['Charge'], - ['Success'] + ['Success'], ) } diff --git a/extension/src/paymentHandler/refund-payment.handler.js b/extension/src/paymentHandler/refund-payment.handler.js index ed04e18c7..fbee6a72e 100644 --- a/extension/src/paymentHandler/refund-payment.handler.js +++ b/extension/src/paymentHandler/refund-payment.handler.js @@ -38,28 +38,28 @@ async function execute(paymentObject) { adyenMerchantAccount, commercetoolsProjectKey, idempotencyKey, - refundRequestObjects + refundRequestObjects, ) const addInterfaceInteractionAction = createAddInterfaceInteractionAction( { request, response, type: CTP_INTERACTION_TYPE_REFUND, - } + }, ) actions.push(addInterfaceInteractionAction) if (!response.errorCode && response.pspReference) { actions.push( - createChangeTransactionStateAction(refundTransaction.id, 'Pending') + createChangeTransactionStateAction(refundTransaction.id, 'Pending'), ) actions.push( createChangeTransactionInteractionId( refundTransaction.id, - response.pspReference - ) + response.pspReference, + ), ) } - }) + }), ) return { diff --git a/extension/src/paymentHandler/sessions-line-items-request.handler.js b/extension/src/paymentHandler/sessions-line-items-request.handler.js index ca2e9ee9e..ce5df5a00 100644 --- a/extension/src/paymentHandler/sessions-line-items-request.handler.js +++ b/extension/src/paymentHandler/sessions-line-items-request.handler.js @@ -3,22 +3,22 @@ import lineItemsUtils from './line-items-utils.js' async function execute(paymentObject) { const createSessionRequestObj = JSON.parse( - paymentObject.custom.fields.createSessionRequest + paymentObject.custom.fields.createSessionRequest, ) const commercetoolsProjectKey = paymentObject.custom.fields.commercetoolsProjectKey if (!createSessionRequestObj.lineItems) { const ctpCart = await lineItemsUtils.fetchMatchingCart( paymentObject, - commercetoolsProjectKey + commercetoolsProjectKey, ) if (ctpCart) { createSessionRequestObj.lineItems = lineItemsUtils.createLineItems( paymentObject, - ctpCart + ctpCart, ) paymentObject.custom.fields.createSessionRequest = JSON.stringify( - createSessionRequestObj + createSessionRequestObj, ) } } diff --git a/extension/src/paymentHandler/sessions-request.handler.js b/extension/src/paymentHandler/sessions-request.handler.js index eafbf22ee..d6bb95c4b 100644 --- a/extension/src/paymentHandler/sessions-request.handler.js +++ b/extension/src/paymentHandler/sessions-request.handler.js @@ -7,7 +7,7 @@ import { createSessionRequest } from '../service/web-component-service.js' async function execute(paymentObject) { const createSessionRequestObj = JSON.parse( - paymentObject.custom.fields.createSessionRequest + paymentObject.custom.fields.createSessionRequest, ) const adyenMerchantAccount = paymentObject.custom.fields.adyenMerchantAccount const commercetoolsProjectKey = @@ -15,7 +15,7 @@ async function execute(paymentObject) { const { request, response } = await createSessionRequest( adyenMerchantAccount, commercetoolsProjectKey, - createSessionRequestObj + createSessionRequestObj, ) const actions = [ @@ -26,7 +26,7 @@ async function execute(paymentObject) { }), createSetCustomFieldAction( c.CTP_INTERACTION_TYPE_CREATE_SESSION_RESPONSE, - response + response, ), ] diff --git a/extension/src/paymentHandler/submit-payment-details.handler.js b/extension/src/paymentHandler/submit-payment-details.handler.js index 3882f4225..ecf6ab4b8 100644 --- a/extension/src/paymentHandler/submit-payment-details.handler.js +++ b/extension/src/paymentHandler/submit-payment-details.handler.js @@ -13,14 +13,14 @@ const { CTP_INTERACTION_TYPE_SUBMIT_ADDITIONAL_PAYMENT_DETAILS } = c async function execute(paymentObject) { const actions = [] const submitAdditionalDetailsRequestObj = JSON.parse( - paymentObject.custom.fields.submitAdditionalPaymentDetailsRequest + paymentObject.custom.fields.submitAdditionalPaymentDetailsRequest, ) const adyenMerchantAccount = paymentObject.custom.fields.adyenMerchantAccount const commercetoolsProjectKey = paymentObject.custom.fields.commercetoolsProjectKey if (!submitAdditionalDetailsRequestObj.paymentData) { const makePaymentResponseObj = JSON.parse( - paymentObject.custom.fields.makePaymentResponse + paymentObject.custom.fields.makePaymentResponse, ) submitAdditionalDetailsRequestObj.paymentData = makePaymentResponseObj.paymentData @@ -29,7 +29,7 @@ async function execute(paymentObject) { const { request, response } = await submitAdditionalPaymentDetails( adyenMerchantAccount, commercetoolsProjectKey, - submitAdditionalDetailsRequestObj + submitAdditionalDetailsRequestObj, ) actions.push( createAddInterfaceInteractionAction({ @@ -39,8 +39,8 @@ async function execute(paymentObject) { }), createSetCustomFieldAction( c.CTP_CUSTOM_FIELD_SUBMIT_ADDITIONAL_PAYMENT_DETAILS_RESPONSE, - response - ) + response, + ), ) if ( @@ -49,7 +49,7 @@ async function execute(paymentObject) { const addTransactionAction = createAddTransactionActionByResponse( paymentObject.amountPlanned.centAmount, paymentObject.amountPlanned.currencyCode, - response + response, ) if (addTransactionAction) actions.push(addTransactionAction) @@ -57,7 +57,7 @@ async function execute(paymentObject) { const updatePaymentAction = getPaymentKeyUpdateAction( paymentObject.key, request, - response + response, ) if (updatePaymentAction) actions.push(updatePaymentAction) } @@ -68,12 +68,12 @@ async function execute(paymentObject) { function _isNewRequest( submitAdditionalPaymentDetailsRequestObj, - paymentObject + paymentObject, ) { const interfaceInteraction = paymentObject.interfaceInteractions.find( (interaction) => interaction.fields.type === - CTP_INTERACTION_TYPE_SUBMIT_ADDITIONAL_PAYMENT_DETAILS + CTP_INTERACTION_TYPE_SUBMIT_ADDITIONAL_PAYMENT_DETAILS, ) if (!interfaceInteraction) // request is new if there are no requests yet @@ -82,7 +82,7 @@ function _isNewRequest( if (oldSubmitDetailsRequest) { const oldSubmitDetailsRequestObj = JSON.parse(oldSubmitDetailsRequest) const newSubmitDetailsRequestObj = _.cloneDeep( - submitAdditionalPaymentDetailsRequestObj + submitAdditionalPaymentDetailsRequestObj, ) delete newSubmitDetailsRequestObj.merchantAccount if (!_.isEqual(oldSubmitDetailsRequestObj, newSubmitDetailsRequestObj)) @@ -95,7 +95,7 @@ function _isNewRequest( function _hasTransactionWithPspReference(pspReference, paymentObject) { return paymentObject.transactions.some( - (transaction) => transaction.interactionId === pspReference + (transaction) => transaction.interactionId === pspReference, ) } diff --git a/extension/src/server.js b/extension/src/server.js index e1b1e36ba..8fa7632f4 100644 --- a/extension/src/server.js +++ b/extension/src/server.js @@ -16,7 +16,7 @@ function setupServer() { } catch (e) { logger.error( e, - `Unexpected error when processing URL ${JSON.stringify(parts)}` + `Unexpected error when processing URL ${JSON.stringify(parts)}`, ) utils.sendResponse({ response, statusCode: 500 }) } diff --git a/extension/src/service/web-component-service.js b/extension/src/service/web-component-service.js index 81710be6b..f3d2d0833 100644 --- a/extension/src/service/web-component-service.js +++ b/extension/src/service/web-component-service.js @@ -10,14 +10,14 @@ async function getPaymentMethods(merchantAccount, getPaymentMethodsRequestObj) { `${adyenCredentials.apiBaseUrl}/paymentMethods`, merchantAccount, adyenCredentials.apiKey, - await extendRequestObjWithApplicationInfo(getPaymentMethodsRequestObj) + await extendRequestObjWithApplicationInfo(getPaymentMethodsRequestObj), ) } async function makePayment( merchantAccount, commercetoolsProjectKey, - makePaymentRequestObj + makePaymentRequestObj, ) { const adyenCredentials = config.getAdyenConfig(merchantAccount) extendRequestObjWithMetadata(makePaymentRequestObj, commercetoolsProjectKey) @@ -27,25 +27,25 @@ async function makePayment( `${adyenCredentials.apiBaseUrl}/payments`, merchantAccount, adyenCredentials.apiKey, - makePaymentRequestObj + makePaymentRequestObj, ) } function submitAdditionalPaymentDetails( merchantAccount, commercetoolsProjectKey, - submitAdditionalPaymentDetailsRequestObj + submitAdditionalPaymentDetailsRequestObj, ) { const adyenCredentials = config.getAdyenConfig(merchantAccount) extendRequestObjWithMetadata( submitAdditionalPaymentDetailsRequestObj, - commercetoolsProjectKey + commercetoolsProjectKey, ) return callAdyen( `${adyenCredentials.apiBaseUrl}/payments/details`, merchantAccount, adyenCredentials.apiKey, - submitAdditionalPaymentDetailsRequestObj + submitAdditionalPaymentDetailsRequestObj, ) } @@ -59,7 +59,7 @@ function manualCapture( merchantAccount, commercetoolsProjectKey, idempotencyKey, - manualCaptureRequestObj + manualCaptureRequestObj, ) { const adyenCredentials = config.getAdyenConfig(merchantAccount) return callAdyen( @@ -70,14 +70,14 @@ function manualCapture( amount: manualCaptureRequestObj.modificationAmount, reference: manualCaptureRequestObj?.reference, }, - idempotencyKey && { 'Idempotency-Key': idempotencyKey } + idempotencyKey && { 'Idempotency-Key': idempotencyKey }, ) } function cancelPayment( merchantAccount, commercetoolsProjectKey, - cancelPaymentRequestObj + cancelPaymentRequestObj, ) { const adyenCredentials = config.getAdyenConfig(merchantAccount) return callAdyen( @@ -86,7 +86,7 @@ function cancelPayment( adyenCredentials.apiKey, { reference: cancelPaymentRequestObj?.reference, - } + }, ) } @@ -94,7 +94,7 @@ function refund( merchantAccount, commercetoolsProjectKey, idempotencyKey, - refundRequestObj + refundRequestObj, ) { const adyenCredentials = config.getAdyenConfig(merchantAccount) return callAdyen( @@ -105,7 +105,7 @@ function refund( amount: refundRequestObj.modificationAmount, reference: refundRequestObj?.reference, }, - idempotencyKey && { 'Idempotency-Key': idempotencyKey } + idempotencyKey && { 'Idempotency-Key': idempotencyKey }, ) } @@ -115,14 +115,14 @@ function getCarbonOffsetCosts(merchantAccount, getCarbonOffsetCostsRequestObj) { `${adyenCredentials.apiBaseUrl}/carbonOffsetCosts`, merchantAccount, adyenCredentials.apiKey, - getCarbonOffsetCostsRequestObj + getCarbonOffsetCostsRequestObj, ) } function updateAmount( merchantAccount, commercetoolsProjectKey, - amountUpdatesRequestObj + amountUpdatesRequestObj, ) { const adyenCredentials = config.getAdyenConfig(merchantAccount) const paymentPspReference = amountUpdatesRequestObj.paymentPspReference @@ -130,14 +130,14 @@ function updateAmount( `${adyenCredentials.apiBaseUrl}/payments/${paymentPspReference}/amountUpdates`, merchantAccount, adyenCredentials.apiKey, - amountUpdatesRequestObj + amountUpdatesRequestObj, ) } async function createSessionRequest( merchantAccount, commercetoolsProjectKey, - requestObject + requestObject, ) { extendRequestObjWithMetadata(requestObject, commercetoolsProjectKey) await extendRequestObjWithApplicationInfo(requestObject) @@ -147,7 +147,7 @@ async function createSessionRequest( `${adyenCredentials.apiBaseUrl}/sessions`, merchantAccount, adyenCredentials.apiKey, - requestObject + requestObject, ) } @@ -160,7 +160,7 @@ function disableStoredPayment(merchantAccount, disableStoredPaymentRequestObj) { url, merchantAccount, adyenCredentials.apiKey, - disableStoredPaymentRequestObj + disableStoredPaymentRequestObj, ) } @@ -199,7 +199,7 @@ async function callAdyen( adyenMerchantAccount, adyenApiKey, requestArg, - headers + headers, ) { let returnedRequest let returnedResponse @@ -209,7 +209,7 @@ async function callAdyen( adyenMerchantAccount, adyenApiKey, requestArg, - headers + headers, ) returnedRequest = request returnedResponse = response @@ -226,7 +226,7 @@ async function fetchAsync( adyenMerchantAccount, adyenApiKey, requestObj, - headers + headers, ) { const moduleConfig = config.getModuleConfig() const removeSensitiveData = @@ -239,7 +239,7 @@ async function fetchAsync( adyenMerchantAccount, adyenApiKey, requestObj, - headers + headers, ) try { @@ -251,7 +251,7 @@ async function fetchAsync( if (response) // Handle non-JSON format response throw new Error( - `Unable to receive non-JSON format resposne from Adyen API : ${responseBodyInText}` + `Unable to receive non-JSON format resposne from Adyen API : ${responseBodyInText}`, ) // Error in fetching URL else throw err diff --git a/extension/src/setup.js b/extension/src/setup.js index 69b9f2d2a..ed3ea09b3 100644 --- a/extension/src/setup.js +++ b/extension/src/setup.js @@ -19,18 +19,18 @@ async function setupExtensionResources(apiExtensionBaseUrl) { ctpClient, ctpConfig.projectKey, apiExtensionBaseUrl || moduleConfig.apiExtensionBaseUrl, - generateBasicAuthorizationHeaderValue(ctpConfig.projectKey) + generateBasicAuthorizationHeaderValue(ctpConfig.projectKey), ) - }) + }), ) logger.info( `Configured commercetools project keys are: ${JSON.stringify( - ctpProjectKeys + ctpProjectKeys, )}. ` + `Configured adyen merchant accounts are: ${JSON.stringify( - adyenMerchantAccounts - )}` + adyenMerchantAccounts, + )}`, ) } diff --git a/extension/src/validator/validator-builder.js b/extension/src/validator/validator-builder.js index 89a670fa1..286dcb48c 100644 --- a/extension/src/validator/validator-builder.js +++ b/extension/src/validator/validator-builder.js @@ -48,7 +48,7 @@ function withPayment(paymentObject) { errorMessages.MAKE_PAYMENT_REQUEST_INVALID_JSON if ( !isValidJSON( - paymentObject.custom.fields.submitAdditionalPaymentDetailsRequest + paymentObject.custom.fields.submitAdditionalPaymentDetailsRequest, ) ) errors.submitAdditionalPaymentDetailsRequest = @@ -75,7 +75,7 @@ function withPayment(paymentObject) { !paymentObject.custom.fields.createSessionResponse ) { const createSessionRequestObj = JSON.parse( - paymentObject.custom.fields.createSessionRequest + paymentObject.custom.fields.createSessionRequest, ) if (!createSessionRequestObj.reference) errors.missingReference = @@ -87,7 +87,7 @@ function withPayment(paymentObject) { !paymentObject.custom.fields.makePaymentResponse ) { const makePaymentRequestObj = JSON.parse( - paymentObject.custom.fields.makePaymentRequest + paymentObject.custom.fields.makePaymentRequest, ) if (!makePaymentRequestObj.reference) errors.missingReference = @@ -102,17 +102,17 @@ function withPayment(paymentObject) { const createSessionRequestInterfaceInteraction = getLatestInterfaceInteraction( paymentObject.interfaceInteractions, - c.CTP_INTERACTION_TYPE_CREATE_SESSION + c.CTP_INTERACTION_TYPE_CREATE_SESSION, ) const makePaymentRequestInterfaceInteraction = getLatestInterfaceInteraction( paymentObject.interfaceInteractions, - c.CTP_INTERACTION_TYPE_MAKE_PAYMENT + c.CTP_INTERACTION_TYPE_MAKE_PAYMENT, ) if (createSessionRequestInterfaceInteraction) createSessionAmount = JSON.parse( - createSessionRequestInterfaceInteraction.fields.request + createSessionRequestInterfaceInteraction.fields.request, ).amount else { const createSessionRequestString = @@ -125,7 +125,7 @@ function withPayment(paymentObject) { if (makePaymentRequestInterfaceInteraction) makePaymentAmount = JSON.parse( - makePaymentRequestInterfaceInteraction.fields.request + makePaymentRequestInterfaceInteraction.fields.request, ).amount else { const makePaymentRequestString = @@ -171,7 +171,7 @@ function withPayment(paymentObject) { !paymentObject.custom.fields.amountUpdatesResponse ) { const amountUpdatesRequestObj = JSON.parse( - paymentObject.custom.fields.amountUpdatesRequest + paymentObject.custom.fields.amountUpdatesRequest, ) if (!amountUpdatesRequestObj.paymentPspReference) errors.missingPspReference = diff --git a/extension/test/e2e/affirm.spec.js b/extension/test/e2e/affirm.spec.js index 2aa2fa1a0..32cce7428 100644 --- a/extension/test/e2e/affirm.spec.js +++ b/extension/test/e2e/affirm.spec.js @@ -28,14 +28,14 @@ describe.skip('::affirmPayment::', () => { serveFile( './test/e2e/fixtures/affirm-init-session-form.html', request, - response + response, ) } routes['/redirect-payment-form'] = async (request, response) => { serveFile( './test/e2e/fixtures/redirect-payment-form.html', request, - response + response, ) } routes['/return-url'] = async (request, response) => { @@ -77,7 +77,7 @@ describe.skip('::affirmPayment::', () => { let createSessionRequest = await getCreateSessionRequest( baseUrl, clientKey, - 'USD' + 'USD', ) createSessionRequest = buildAffirmCreateSessionRequest(createSessionRequest) @@ -86,11 +86,11 @@ describe.skip('::affirmPayment::', () => { adyenMerchantAccount, ctpProjectKey, createSessionRequest, - 'USD' + 'USD', ) logger.debug( 'affirm::paymentAfterCreateSession:', - JSON.stringify(paymentAfterCreateSession) + JSON.stringify(paymentAfterCreateSession), ) // Step #2 - Setup Component @@ -109,16 +109,16 @@ describe.skip('::affirmPayment::', () => { }) logger.debug( 'affirm::redirectPaymentResult:', - JSON.stringify(redirectPaymentResult) + JSON.stringify(redirectPaymentResult), ) } catch (err) { logger.error('affirm::errors', err) } assertCreatePaymentSession( paymentAfterCreateSession, - redirectPaymentResult + redirectPaymentResult, ) - } + }, ) async function initPaymentSession({ @@ -129,7 +129,7 @@ describe.skip('::affirmPayment::', () => { }) { const initPaymentSessionFormPage = new AffirmInitSessionFormPage( browserTab, - baseUrl + baseUrl, ) await initPaymentSessionFormPage.goToThisPage() @@ -148,14 +148,14 @@ describe.skip('::affirmPayment::', () => { const redirectPaymentFormPage = new RedirectPaymentFormPage( browserTab, - baseUrl + baseUrl, ) await redirectPaymentFormPage.goToThisPage() const submittedRedirectResult = await redirectPaymentFormPage.redirectToAdyenPaymentPage( clientKey, sessionId, - redirectResult + redirectResult, ) return submittedRedirectResult } diff --git a/extension/test/e2e/credit-card-3ds-native.spec.js b/extension/test/e2e/credit-card-3ds-native.spec.js index 14a61f82c..77c99c073 100644 --- a/extension/test/e2e/credit-card-3ds-native.spec.js +++ b/extension/test/e2e/credit-card-3ds-native.spec.js @@ -27,14 +27,14 @@ describe.skip('::creditCardPayment3dsNative::', () => { serveFile( './test/e2e/fixtures/3ds-v2-init-session-form.html', request, - response + response, ) } routes['/redirect-payment-form'] = async (request, response) => { serveFile( './test/e2e/fixtures/redirect-payment-form.html', request, - response + response, ) } routes['/return-url'] = async (request, response) => { @@ -80,18 +80,18 @@ describe.skip('::creditCardPayment3dsNative::', () => { // https://docs.adyen.com/online-payments/web-components#create-payment-session const createSessionRequest = await getCreateSessionRequest( baseUrl, - clientKey + clientKey, ) paymentAfterCreateSession = await createPaymentSession( ctpClient, adyenMerchantAccount, ctpProjectKey, - createSessionRequest + createSessionRequest, ) logger.debug( 'credit-card-3ds-native::paymentAfterCreateSession:', - JSON.stringify(paymentAfterCreateSession) + JSON.stringify(paymentAfterCreateSession), ) // Step #2 - Setup Component @@ -115,13 +115,13 @@ describe.skip('::creditCardPayment3dsNative::', () => { }) logger.debug( 'credit-card-3ds-native::initPaymentResult:', - JSON.stringify(initPaymentResult) + JSON.stringify(initPaymentResult), ) } catch (err) { logger.error('credit-card-3ds-native::errors', JSON.stringify(err)) } assertCreatePaymentSession(paymentAfterCreateSession, initPaymentResult) - } + }, ) async function initPaymentSession({ @@ -135,7 +135,7 @@ describe.skip('::creditCardPayment3dsNative::', () => { }) { const initSessionFormPage = new CreditCardInitSessionFormPage( browserTab, - baseUrl + baseUrl, ) await initSessionFormPage.goToThisPage() return await initSessionFormPage.initPaymentSession({ @@ -151,14 +151,14 @@ describe.skip('::creditCardPayment3dsNative::', () => { await browserTab.waitForTimeout(5_000) const creditCardAuthenticationPage = new CreditCardNativeAuthenticationPage( - browserTab + browserTab, ) await creditCardAuthenticationPage.doPaymentAuthentication() const initSessionFormPage = new CreditCardInitSessionFormPage( browserTab, - baseUrl + baseUrl, ) return await initSessionFormPage.getPaymentAuthResult() } diff --git a/extension/test/e2e/credit-card-3ds-redirect.spec.js b/extension/test/e2e/credit-card-3ds-redirect.spec.js index df7154e13..84b8a0c5d 100644 --- a/extension/test/e2e/credit-card-3ds-redirect.spec.js +++ b/extension/test/e2e/credit-card-3ds-redirect.spec.js @@ -21,14 +21,14 @@ function setRoute() { serveFile( './test/e2e/fixtures/credit-card-init-session-form.html', request, - response + response, ) } routes['/redirect-payment-form'] = async (request, response) => { serveFile( './test/e2e/fixtures/redirect-payment-form.html', request, - response + response, ) } routes['/return-url'] = async (request, response) => { @@ -105,18 +105,18 @@ describe.skip('::creditCardPayment3dsRedirect::', () => { // https://docs.adyen.com/online-payments/web-components#create-payment-session const createSessionRequest = await getCreateSessionRequest( baseUrl, - clientKey + clientKey, ) paymentAfterCreateSession = await createPaymentSession( ctpClient, adyenMerchantAccount, ctpProjectKey, - createSessionRequest + createSessionRequest, ) logger.debug( 'credit-card-3ds-redirect::paymentAfterCreateSession:', - JSON.stringify(paymentAfterCreateSession) + JSON.stringify(paymentAfterCreateSession), ) // Step #2 - Setup Component @@ -140,21 +140,21 @@ describe.skip('::creditCardPayment3dsRedirect::', () => { }) logger.debug( 'credit-card-3ds-redirect::redirectPaymentResult:', - JSON.stringify(redirectPaymentResult) + JSON.stringify(redirectPaymentResult), ) } catch (err) { logger.error( 'credit-card-3ds-redirect::errors', - JSON.stringify(err) + JSON.stringify(err), ) } assertCreatePaymentSession( paymentAfterCreateSession, - redirectPaymentResult + redirectPaymentResult, ) - } + }, ) - } + }, ) async function initPaymentSession({ @@ -168,7 +168,7 @@ describe.skip('::creditCardPayment3dsRedirect::', () => { }) { const initSessionFormPage = new CreditCardInitSessionFormPage( browserTab, - baseUrl + baseUrl, ) await initSessionFormPage.goToThisPage() return await initSessionFormPage.initPaymentSession({ @@ -188,7 +188,7 @@ describe.skip('::creditCardPayment3dsRedirect::', () => { const redirectPaymentFormPage = new RedirectPaymentFormPage( browserTab, - baseUrl + baseUrl, ) await redirectPaymentFormPage.goToThisPage() @@ -197,7 +197,7 @@ describe.skip('::creditCardPayment3dsRedirect::', () => { await redirectPaymentFormPage.redirectToAdyenPaymentPage( clientKey, sessionId, - redirectResult + redirectResult, ) return submittedRedirectResult diff --git a/extension/test/e2e/credit-card-advanced-flow.spec.js b/extension/test/e2e/credit-card-advanced-flow.spec.js index 02b18d1db..63d2309d3 100644 --- a/extension/test/e2e/credit-card-advanced-flow.spec.js +++ b/extension/test/e2e/credit-card-advanced-flow.spec.js @@ -26,14 +26,14 @@ describe('::creditCardAdvancedFlow::', () => { serveFile( './test/e2e/fixtures/3ds-v2-make-payment-form.html', request, - response + response, ) } routes['/redirect-payment-form'] = async (request, response) => { serveFile( './test/e2e/fixtures/redirect-payment-form-advanced-flow.html', request, - response + response, ) } routes['/return-url'] = async (request, response) => { @@ -82,7 +82,7 @@ describe('::creditCardAdvancedFlow::', () => { }) logger.debug( 'creditCardAdvancedFlow::paymentAfterMakePayment:', - JSON.stringify(paymentAfterMakePayment) + JSON.stringify(paymentAfterMakePayment), ) paymentAfterAuthentication = await performChallengeFlow({ payment: paymentAfterMakePayment, @@ -92,13 +92,13 @@ describe('::creditCardAdvancedFlow::', () => { }) logger.debug( 'creditCardAdvancedFlow::paymentAfterAuthentication:', - JSON.stringify(paymentAfterAuthentication) + JSON.stringify(paymentAfterAuthentication), ) } catch (err) { logger.error('creditCardAdvancedFlow::errors', JSON.stringify(err)) } assertPayment(paymentAfterAuthentication) - } + }, ) async function makePayment({ @@ -124,7 +124,7 @@ describe('::creditCardAdvancedFlow::', () => { ctpClient, adyenMerchantAccount, ctpProjectKey, - makePaymentRequest + makePaymentRequest, ) } finally { const endTime = new Date().getTime() @@ -145,12 +145,12 @@ describe('::creditCardAdvancedFlow::', () => { const makePaymentResponse = await JSON.parse(makePaymentResponseString) const redirectPaymentFormPage = new RedirectPaymentFormPage( browserTab, - baseUrl + baseUrl, ) await redirectPaymentFormPage.goToThisPage() await redirectPaymentFormPage.redirectToAdyenPaymentPage( makePaymentResponse, - clientKey + clientKey, ) await browserTab.waitForTimeout(5_000) @@ -162,7 +162,7 @@ describe('::creditCardAdvancedFlow::', () => { logger.debug( 'additionalPaymentDetailsString', - additionalPaymentDetailsString + additionalPaymentDetailsString, ) let result = null const startTime = new Date().getTime() @@ -177,19 +177,19 @@ describe('::creditCardAdvancedFlow::', () => { name: 'submitAdditionalPaymentDetailsRequest', value: additionalPaymentDetailsString, }, - ] + ], ) } catch (err) { logger.error( 'creditCardAdvancedFlow::performChallengeFlow::errors:', - JSON.stringify(err) + JSON.stringify(err), ) throw err } finally { const endTime = new Date().getTime() logger.debug( 'creditCardAdvancedFlow::performChallengeFlow:', - endTime - startTime + endTime - startTime, ) } return result.body diff --git a/extension/test/e2e/credit-card-amount-update.spec.js b/extension/test/e2e/credit-card-amount-update.spec.js index 24a52c108..13e379a27 100644 --- a/extension/test/e2e/credit-card-amount-update.spec.js +++ b/extension/test/e2e/credit-card-amount-update.spec.js @@ -24,7 +24,7 @@ function setRoute() { serveFile( './test/e2e/fixtures/credit-card-init-session-form.html', request, - response + response, ) } } @@ -71,7 +71,7 @@ describe('::creditCardPayment::amount-update::', () => { paymentAfterCreateSession = await createSession(clientKey) logger.debug( 'credit-card-amount-update::paymentAfterCreateSession:', - JSON.stringify(paymentAfterCreateSession) + JSON.stringify(paymentAfterCreateSession), ) // Step #2 - Setup Component @@ -91,8 +91,8 @@ describe('::creditCardPayment::amount-update::', () => { async () => await fetchNotificationInterfaceInteraction( ctpClient, - paymentAfterCreateSession.id - ) + paymentAfterCreateSession.id, + ), ) // Step #3 - Update Amount @@ -101,26 +101,26 @@ describe('::creditCardPayment::amount-update::', () => { try { return await updateAmount( notificationInteraction, - paymentAfterCreateSession + paymentAfterCreateSession, ) } catch (err) { logger.error( 'credit-card-amount-update::errors:', - JSON.stringify(err) + JSON.stringify(err), ) return Promise.resolve() } }, 10, - 1_000 + 1_000, ) amountUpdatesResponse = JSON.parse( - updatedPayment.custom.fields.amountUpdatesResponse + updatedPayment.custom.fields.amountUpdatesResponse, ) amountUpdatesInterfaceInteractions = updatedPayment.interfaceInteractions.filter( - (ii) => ii.fields.type === 'amountUpdates' + (ii) => ii.fields.type === 'amountUpdates', ) updatedAmountStatusCode = statusCode } catch (err) { @@ -132,15 +132,15 @@ describe('::creditCardPayment::amount-update::', () => { await fetchNotificationInterfaceInteraction( ctpClient, paymentAfterCreateSession.id, - 'authorisation_adjustment' - ) + 'authorisation_adjustment', + ), ) logger.debug(JSON.stringify(notificationInteractionForAmountUpdates)) assertCreatePaymentSession( paymentAfterCreateSession, - initPaymentSessionResult + initPaymentSessionResult, ) expect(updatedAmountStatusCode).to.equal(200) expect(amountUpdatesResponse.status).to.equal('received') @@ -151,14 +151,14 @@ describe('::creditCardPayment::amount-update::', () => { notificationInteractionForAmountUpdates.fields.notification const notificationJson = JSON.parse(notificationStr) expect(notificationJson.NotificationRequestItem.eventCode).to.equal( - 'AUTHORISATION_ADJUSTMENT' + 'AUTHORISATION_ADJUSTMENT', ) expect(notificationJson.NotificationRequestItem.success).to.equal('true') }) async function updateAmount( notificationInteraction, - paymentAfterCreateSession + paymentAfterCreateSession, ) { const notificationStr = notificationInteraction.fields.notification const notificationJson = JSON.parse(notificationStr) @@ -176,7 +176,7 @@ describe('::creditCardPayment::amount-update::', () => { const { body: paymentAfterReceivingNotification } = await ctpClient.fetchById( ctpClient.builder.payments, - paymentAfterCreateSession.id + paymentAfterCreateSession.id, ) const { statusCode, body: updatedPayment } = await ctpClient.update( ctpClient.builder.payments, @@ -188,7 +188,7 @@ describe('::creditCardPayment::amount-update::', () => { name: 'amountUpdatesRequest', value: JSON.stringify(amountUpdatesRequestDraft), }, - ] + ], ) return { statusCode, updatedPayment } } @@ -201,7 +201,7 @@ describe('::creditCardPayment::amount-update::', () => { ctpClient, adyenMerchantAccount, ctpProjectKey, - createSessionRequest + createSessionRequest, ) } catch (err) { logger.error('credit-card::createSession::errors', JSON.stringify(err)) @@ -224,7 +224,7 @@ describe('::creditCardPayment::amount-update::', () => { }) { const initSessionFormPage = new CreditCardInitSessionFormPage( browserTab, - baseUrl + baseUrl, ) await initSessionFormPage.goToThisPage() await initSessionFormPage.initPaymentSession({ diff --git a/extension/test/e2e/credit-card-cancel-payment.spec.js b/extension/test/e2e/credit-card-cancel-payment.spec.js index bfbe711d8..886eedea2 100644 --- a/extension/test/e2e/credit-card-cancel-payment.spec.js +++ b/extension/test/e2e/credit-card-cancel-payment.spec.js @@ -25,7 +25,7 @@ function setRoute() { serveFile( './test/e2e/fixtures/credit-card-init-session-form.html', request, - response + response, ) } } @@ -72,7 +72,7 @@ describe('::creditCardPayment::cancel-payment::', () => { paymentAfterCreateSession = await createSession(clientKey) logger.debug( 'credit-card-cancel-payment::paymentAfterCreateSession:', - JSON.stringify(paymentAfterCreateSession) + JSON.stringify(paymentAfterCreateSession), ) // Step #2 - Setup Component @@ -92,8 +92,8 @@ describe('::creditCardPayment::cancel-payment::', () => { async () => await fetchNotificationInterfaceInteraction( ctpClient, - paymentAfterCreateSession.id - ) + paymentAfterCreateSession.id, + ), ) // Step #3 - Cancel payment @@ -103,7 +103,7 @@ describe('::creditCardPayment::cancel-payment::', () => { const { body: paymentAfterReceivingNotification } = await ctpClient.fetchById( ctpClient.builder.payments, - paymentAfterCreateSession.id + paymentAfterCreateSession.id, ) return await ctpClient.update( @@ -117,18 +117,18 @@ describe('::creditCardPayment::cancel-payment::', () => { currency: 'EUR', amount: 500, }), - ] + ], ) } catch (err) { logger.error( 'credit-card-cancel-payment::errors:', - JSON.stringify(err) + JSON.stringify(err), ) return Promise.resolve() } }, 10, - 1_000 + 1_000, ) cancelledPaymentStatusCode = statusCode @@ -143,19 +143,19 @@ describe('::creditCardPayment::cancel-payment::', () => { await fetchNotificationInterfaceInteraction( ctpClient, paymentAfterCreateSession.id, - `cancellation` - ) + `cancellation`, + ), ) const { body: paymentAfterReceivingNotification } = await ctpClient.fetchById( ctpClient.builder.payments, - paymentAfterCreateSession.id + paymentAfterCreateSession.id, ) assertCreatePaymentSession( paymentAfterCreateSession, - initPaymentSessionResult + initPaymentSessionResult, ) expect(cancelledPaymentStatusCode).to.be.equal(200) @@ -170,7 +170,7 @@ describe('::creditCardPayment::cancel-payment::', () => { notificationInteractionForCancelPayment.fields.notification const notificationJson = JSON.parse(notificationStr) expect(notificationJson.NotificationRequestItem.eventCode).to.equal( - 'CANCELLATION' + 'CANCELLATION', ) expect(notificationJson.NotificationRequestItem.success).to.equal('true') }) @@ -184,7 +184,7 @@ describe('::creditCardPayment::cancel-payment::', () => { ctpClient, adyenMerchantAccount, ctpProjectKey, - createSessionRequest + createSessionRequest, ) } catch (err) { logger.error('credit-card::createSession::errors', JSON.stringify(err)) @@ -207,7 +207,7 @@ describe('::creditCardPayment::cancel-payment::', () => { }) { const initSessionFormPage = new CreditCardInitSessionFormPage( browserTab, - baseUrl + baseUrl, ) await initSessionFormPage.goToThisPage() await initSessionFormPage.initPaymentSession({ diff --git a/extension/test/e2e/credit-card-disable-stored-payment.spec.js b/extension/test/e2e/credit-card-disable-stored-payment.spec.js index 73d4493a0..fa2a7c500 100644 --- a/extension/test/e2e/credit-card-disable-stored-payment.spec.js +++ b/extension/test/e2e/credit-card-disable-stored-payment.spec.js @@ -24,7 +24,7 @@ function setRoute() { serveFile( './test/e2e/fixtures/credit-card-init-session-form.html', request, - response + response, ) } } @@ -66,7 +66,7 @@ describe('::creditCardPayment::disable-stored-payment::', () => { paymentAfterCreateSession = await creatSession(clientKey, 'CardOnFile') logger.debug( 'credit-card-disable-stored-payment::paymentAfterCreateSession:', - JSON.stringify(paymentAfterCreateSession) + JSON.stringify(paymentAfterCreateSession), ) // Step #2 - Setup Component @@ -86,14 +86,14 @@ describe('::creditCardPayment::disable-stored-payment::', () => { async () => await fetchNotificationInterfaceInteraction( ctpClient, - paymentAfterCreateSession.id - ) + paymentAfterCreateSession.id, + ), ) // Step #3 - Disable stored payment const notificationRequestItem = JSON.parse( - notificationInteraction.fields.notification + notificationInteraction.fields.notification, ).NotificationRequestItem const recurringDetailReference = @@ -106,12 +106,12 @@ describe('::creditCardPayment::disable-stored-payment::', () => { } catch (err) { logger.error( 'credit-card-disable-stored-payment::errors:', - JSON.stringify(err) + JSON.stringify(err), ) } expect( - disabledPayment?.custom?.fields?.disableStoredPaymentResponse + disabledPayment?.custom?.fields?.disableStoredPaymentResponse, ).to.be.equal('{"response":"[detail-successfully-disabled]"}') }) @@ -133,7 +133,7 @@ describe('::creditCardPayment::disable-stored-payment::', () => { paymentAfterCreateSession = await creatSession(clientKey, 'Subscription') logger.debug( 'credit-card-disable-stored-payment::paymentAfterCreateSession:', - JSON.stringify(paymentAfterCreateSession) + JSON.stringify(paymentAfterCreateSession), ) // Step #2 - Setup Component @@ -153,13 +153,13 @@ describe('::creditCardPayment::disable-stored-payment::', () => { async () => await fetchNotificationInterfaceInteraction( ctpClient, - paymentAfterCreateSession.id - ) + paymentAfterCreateSession.id, + ), ) // Step #3 - Disable stored payment const notificationRequestItem = JSON.parse( - notificationInteraction.fields.notification + notificationInteraction.fields.notification, ).NotificationRequestItem const recurringDetailReference = @@ -172,12 +172,12 @@ describe('::creditCardPayment::disable-stored-payment::', () => { } catch (err) { logger.error( 'credit-card-disable-stored-payment::errors:', - JSON.stringify(err) + JSON.stringify(err), ) } expect( - disabledPayment?.custom?.fields?.disableStoredPaymentResponse + disabledPayment?.custom?.fields?.disableStoredPaymentResponse, ).to.be.equal('{"response":"[detail-successfully-disabled]"}') }) @@ -198,11 +198,11 @@ describe('::creditCardPayment::disable-stored-payment::', () => { // https://docs.adyen.com/online-payments/web-components#create-payment-session paymentAfterCreateSession = await creatSession( clientKey, - 'UnscheduledCardOnFile' + 'UnscheduledCardOnFile', ) logger.debug( 'credit-card-disable-stored-payment::paymentAfterCreateSession:', - JSON.stringify(paymentAfterCreateSession) + JSON.stringify(paymentAfterCreateSession), ) // Step #2 - Setup Component @@ -222,13 +222,13 @@ describe('::creditCardPayment::disable-stored-payment::', () => { async () => await fetchNotificationInterfaceInteraction( ctpClient, - paymentAfterCreateSession.id - ) + paymentAfterCreateSession.id, + ), ) // Step #3 - Disable stored payment const notificationRequestItem = JSON.parse( - notificationInteraction.fields.notification + notificationInteraction.fields.notification, ).NotificationRequestItem const recurringDetailReference = @@ -241,12 +241,12 @@ describe('::creditCardPayment::disable-stored-payment::', () => { } catch (err) { logger.error( 'credit-card-disable-stored-payment::errors:', - JSON.stringify(err) + JSON.stringify(err), ) } expect( - disabledPayment?.custom?.fields?.disableStoredPaymentResponse + disabledPayment?.custom?.fields?.disableStoredPaymentResponse, ).to.be.equal('{"response":"[detail-successfully-disabled]"}') }) @@ -263,7 +263,7 @@ describe('::creditCardPayment::disable-stored-payment::', () => { ctpClient, adyenMerchantAccount, commercetoolsProjectKey, - createSessionRequest + createSessionRequest, ) return payment @@ -280,7 +280,7 @@ describe('::creditCardPayment::disable-stored-payment::', () => { }) { const initSessionFormPage = new CreditCardInitSessionFormPage( browserTab, - baseUrl + baseUrl, ) await initSessionFormPage.goToThisPage() await initSessionFormPage.initPaymentSession({ @@ -317,7 +317,7 @@ describe('::creditCardPayment::disable-stored-payment::', () => { }, fields: { disableStoredPaymentRequest: JSON.stringify( - disableStoredPaymentRequestDraft + disableStoredPaymentRequestDraft, ), adyenMerchantAccount, commercetoolsProjectKey, @@ -327,7 +327,7 @@ describe('::creditCardPayment::disable-stored-payment::', () => { const { body: payment } = await ctpClient.create( ctpClient.builder.payments, - paymentDraft + paymentDraft, ) return payment diff --git a/extension/test/e2e/credit-card.spec.js b/extension/test/e2e/credit-card.spec.js index d36eacdd2..493c6b2c4 100644 --- a/extension/test/e2e/credit-card.spec.js +++ b/extension/test/e2e/credit-card.spec.js @@ -19,7 +19,7 @@ function setRoute() { serveFile( './test/e2e/fixtures/credit-card-init-session-form.html', request, - response + response, ) } } @@ -72,18 +72,18 @@ describe('::creditCardPayment::', () => { // https://docs.adyen.com/online-payments/web-components#create-payment-session const createSessionRequest = await getCreateSessionRequest( baseUrl, - clientKey + clientKey, ) paymentAfterCreateSession = await createPaymentSession( ctpClient, adyenMerchantAccount, ctpProjectKey, - createSessionRequest + createSessionRequest, ) logger.debug( 'credit-card::paymentAfterCreateSession:', - JSON.stringify(paymentAfterCreateSession) + JSON.stringify(paymentAfterCreateSession), ) // Step #2 - Setup Component @@ -104,11 +104,11 @@ describe('::creditCardPayment::', () => { assertCreatePaymentSession( paymentAfterCreateSession, - initPaymentSessionResult + initPaymentSessionResult, ) - } + }, ) - } + }, ) async function initPaymentSession({ @@ -122,7 +122,7 @@ describe('::creditCardPayment::', () => { }) { const initSessionFormPage = new CreditCardInitSessionFormPage( browserTab, - baseUrl + baseUrl, ) await initSessionFormPage.goToThisPage() await initSessionFormPage.initPaymentSession({ diff --git a/extension/test/e2e/e2e-test-utils.js b/extension/test/e2e/e2e-test-utils.js index a29fd602a..931572fc7 100644 --- a/extension/test/e2e/e2e-test-utils.js +++ b/extension/test/e2e/e2e-test-utils.js @@ -13,7 +13,7 @@ async function pasteValue(page, selector, value) { // eslint-disable-next-line no-undef document.querySelector(data.selector).value = data.value }, - { selector, value } + { selector, value }, ) } @@ -56,18 +56,18 @@ async function getCreateSessionRequest(baseUrl, clientKey, currency = 'EUR') { function assertCreatePaymentSession( paymentAfterCreateSession, - initPaymentSessionResult + initPaymentSessionResult, ) { const { createSessionResponse } = paymentAfterCreateSession.custom.fields const initPaymentSessionResultJson = JSON.parse(initPaymentSessionResult) const finalAdyenPaymentInteraction = getLatestInterfaceInteraction( paymentAfterCreateSession.interfaceInteractions, - c.CTP_INTERACTION_TYPE_CREATE_SESSION + c.CTP_INTERACTION_TYPE_CREATE_SESSION, ) expect(finalAdyenPaymentInteraction.fields.response).to.equal( - createSessionResponse + createSessionResponse, ) expect(initPaymentSessionResultJson.resultCode).to.equal('Authorised') expect(initPaymentSessionResultJson.sessionData).to.not.equal('undefined') @@ -78,7 +78,7 @@ async function createPaymentSession( adyenMerchantAccount, commercetoolsProjectKey, createSessionRequest, - currency = 'EUR' + currency = 'EUR', ) { const paymentDraft = { amountPlanned: { @@ -103,14 +103,14 @@ async function createPaymentSession( const { body: payment } = await ctpClient.create( ctpClient.builder.payments, - paymentDraft + paymentDraft, ) return payment } function assertPayment( payment, - finalAdyenPaymentInteractionName = 'submitAdditionalPaymentDetails' + finalAdyenPaymentInteractionName = 'submitAdditionalPaymentDetails', ) { const { [`${finalAdyenPaymentInteractionName}Response`]: @@ -119,19 +119,19 @@ function assertPayment( const finalAdyenPaymentResponse = JSON.parse(finalAdyenPaymentResponseString) expect(finalAdyenPaymentResponse.resultCode).to.equal( 'Authorised', - `resultCode is not Authorised: ${finalAdyenPaymentResponseString}` + `resultCode is not Authorised: ${finalAdyenPaymentResponseString}`, ) expect(finalAdyenPaymentResponse.pspReference).to.match( /[A-Z0-9]+/, - `pspReference does not match '/[A-Z0-9]+/': ${finalAdyenPaymentResponseString}` + `pspReference does not match '/[A-Z0-9]+/': ${finalAdyenPaymentResponseString}`, ) const finalAdyenPaymentInteraction = getLatestInterfaceInteraction( payment.interfaceInteractions, - finalAdyenPaymentInteractionName + finalAdyenPaymentInteractionName, ) expect(finalAdyenPaymentInteraction.fields.response).to.equal( - finalAdyenPaymentResponseString + finalAdyenPaymentResponseString, ) expect(payment.transactions).to.have.lengthOf(1) @@ -139,13 +139,13 @@ function assertPayment( expect(transaction.state).to.equal('Success') expect(transaction.type).to.equal('Authorization') expect(transaction.interactionId).to.equal( - finalAdyenPaymentResponse.pspReference + finalAdyenPaymentResponse.pspReference, ) expect(transaction.amount.centAmount).to.equal( - payment.amountPlanned.centAmount + payment.amountPlanned.centAmount, ) expect(transaction.amount.currencyCode).to.equal( - payment.amountPlanned.currencyCode + payment.amountPlanned.currencyCode, ) } @@ -154,7 +154,7 @@ async function createPayment( adyenMerchantAccount, commercetoolsProjectKey, makePaymentRequest, - currency = 'EUR' + currency = 'EUR', ) { const paymentDraft = { amountPlanned: { @@ -179,7 +179,7 @@ async function createPayment( const { body: payment } = await ctpClient.create( ctpClient.builder.payments, - paymentDraft + paymentDraft, ) return payment } diff --git a/extension/test/e2e/fixtures/3ds-v2-init-session-form.html b/extension/test/e2e/fixtures/3ds-v2-init-session-form.html index 8ab25549f..f1374c91b 100644 --- a/extension/test/e2e/fixtures/3ds-v2-init-session-form.html +++ b/extension/test/e2e/fixtures/3ds-v2-init-session-form.html @@ -1,4 +1,4 @@ - + diff --git a/extension/test/e2e/fixtures/3ds-v2-make-payment-form.html b/extension/test/e2e/fixtures/3ds-v2-make-payment-form.html index 7ad1c5045..c8aba48ca 100644 --- a/extension/test/e2e/fixtures/3ds-v2-make-payment-form.html +++ b/extension/test/e2e/fixtures/3ds-v2-make-payment-form.html @@ -1,4 +1,4 @@ - + diff --git a/extension/test/e2e/fixtures/affirm-init-session-form.html b/extension/test/e2e/fixtures/affirm-init-session-form.html index f78c838cd..b43d700c7 100644 --- a/extension/test/e2e/fixtures/affirm-init-session-form.html +++ b/extension/test/e2e/fixtures/affirm-init-session-form.html @@ -1,4 +1,4 @@ - + diff --git a/extension/test/e2e/fixtures/credit-card-init-session-form.html b/extension/test/e2e/fixtures/credit-card-init-session-form.html index af9dccda5..94efca6ac 100644 --- a/extension/test/e2e/fixtures/credit-card-init-session-form.html +++ b/extension/test/e2e/fixtures/credit-card-init-session-form.html @@ -1,4 +1,4 @@ - + diff --git a/extension/test/e2e/fixtures/klarna-init-session-form.html b/extension/test/e2e/fixtures/klarna-init-session-form.html index 933e8f38e..d770cd0cd 100644 --- a/extension/test/e2e/fixtures/klarna-init-session-form.html +++ b/extension/test/e2e/fixtures/klarna-init-session-form.html @@ -1,4 +1,4 @@ - + diff --git a/extension/test/e2e/fixtures/paypal-init-session-form.html b/extension/test/e2e/fixtures/paypal-init-session-form.html index adca58145..c42fbe1a9 100644 --- a/extension/test/e2e/fixtures/paypal-init-session-form.html +++ b/extension/test/e2e/fixtures/paypal-init-session-form.html @@ -1,4 +1,4 @@ - + diff --git a/extension/test/e2e/fixtures/redirect-payment-form-advanced-flow.html b/extension/test/e2e/fixtures/redirect-payment-form-advanced-flow.html index c783e1e65..835d4e868 100644 --- a/extension/test/e2e/fixtures/redirect-payment-form-advanced-flow.html +++ b/extension/test/e2e/fixtures/redirect-payment-form-advanced-flow.html @@ -48,13 +48,13 @@ } const actionFieldElemenet = document.getElementById( - 'redirect-payment-button' + 'redirect-payment-button', ) actionFieldElemenet.addEventListener('click', async () => { const clientKeyElement = document.getElementById('adyen-client-key') configuration.clientKey = clientKeyElement.value const actionFieldElemenet = document.getElementById( - 'adyen-make-payment-response-action-field' + 'adyen-make-payment-response-action-field', ) const action = JSON.parse(actionFieldElemenet.value) const checkout = await AdyenCheckout(configuration) @@ -63,7 +63,7 @@ function handleOnAdditionalDetails(state) { const additionalPaymentDetailsInput = document.getElementById( - 'adyen-additional-payment-details' + 'adyen-additional-payment-details', ) additionalPaymentDetailsInput.value = JSON.stringify(state.data) } diff --git a/extension/test/e2e/fixtures/redirect-payment-form.html b/extension/test/e2e/fixtures/redirect-payment-form.html index 55d883dde..b0cf74175 100644 --- a/extension/test/e2e/fixtures/redirect-payment-form.html +++ b/extension/test/e2e/fixtures/redirect-payment-form.html @@ -1,4 +1,4 @@ - + @@ -62,13 +62,13 @@ // 1. Instantiate AdyenCheckout object // 2. Create FormAction const actionFieldElemenet = document.getElementById( - 'redirect-payment-button' + 'redirect-payment-button', ) const sessionIdElement = document.getElementById( - 'adyen-redirect-session-id' + 'adyen-redirect-session-id', ) const redirectResultElement = document.getElementById( - 'adyen-redirect-result' + 'adyen-redirect-result', ) actionFieldElemenet.addEventListener('click', async () => { const clientKeyElement = document.getElementById('adyen-client-key') diff --git a/extension/test/e2e/klarna-capture-and-refund.spec.js b/extension/test/e2e/klarna-capture-and-refund.spec.js index f04fc1e43..caa6b17d4 100644 --- a/extension/test/e2e/klarna-capture-and-refund.spec.js +++ b/extension/test/e2e/klarna-capture-and-refund.spec.js @@ -42,14 +42,14 @@ describe('::klarnaPayment::', () => { serveFile( './test/e2e/fixtures/klarna-init-session-form.html', request, - response + response, ) } routes['/redirect-payment-form'] = async (request, response) => { serveFile( './test/e2e/fixtures/redirect-payment-form.html', request, - response + response, ) } routes['/return-url'] = async (request, response) => { @@ -104,7 +104,7 @@ describe('::klarnaPayment::', () => { // https://docs.adyen.com/online-payments/web-components#create-payment-session let createSessionRequest = await getCreateSessionRequest( baseUrl, - clientKey + clientKey, ) createSessionRequest = buildKlarnaCreateSessionRequest(createSessionRequest) @@ -112,11 +112,11 @@ describe('::klarnaPayment::', () => { ctpClient, adyenMerchantAccount, ctpProjectKey, - createSessionRequest + createSessionRequest, ) logger.debug( 'klarna::paymentAfterCreateSession:', - JSON.stringify(paymentAfterCreateSession) + JSON.stringify(paymentAfterCreateSession), ) // Step #2 - Setup Component @@ -135,19 +135,19 @@ describe('::klarnaPayment::', () => { }) logger.debug( 'klarna::redirectPaymentResult:', - JSON.stringify(redirectPaymentResult) + JSON.stringify(redirectPaymentResult), ) assertCreatePaymentSession( paymentAfterCreateSession, - redirectPaymentResult + redirectPaymentResult, ) const notificationInteraction = await waitUntil( async () => await fetchNotificationInterfaceInteraction( ctpClient, - paymentAfterCreateSession.id - ) + paymentAfterCreateSession.id, + ), ) // #3 - Capture the payment @@ -162,8 +162,8 @@ describe('::klarnaPayment::', () => { await fetchNotificationInterfaceInteraction( ctpClient, paymentAfterCreateSession.id, - 'capture' - ) + 'capture', + ), ) const captureNotification = captureNotificationInteraction.fields.notification @@ -180,7 +180,7 @@ describe('::klarnaPayment::', () => { logger.debug( 'klarna::paymentAfterCapture:', - JSON.stringify(paymentAfterCapture) + JSON.stringify(paymentAfterCapture), ) // #4 - Refund the payment @@ -190,22 +190,22 @@ describe('::klarnaPayment::', () => { const { body: paymentAfterReceivingCaptureNotification } = await ctpClient.fetchById( ctpClient.builder.payments, - paymentAfterCapture.id + paymentAfterCapture.id, ) return await refundPaymentTransactions( - paymentAfterReceivingCaptureNotification + paymentAfterReceivingCaptureNotification, ) } catch (err) { logger.error( 'credit-card-cancel-payment::errors:', - JSON.stringify(err) + JSON.stringify(err), ) return Promise.resolve() } }, 10, - 1_000 + 1_000, ) const refundPaymentStatusCode = statusCode @@ -215,14 +215,14 @@ describe('::klarnaPayment::', () => { await fetchNotificationInterfaceInteraction( ctpClient, paymentAfterCreateSession.id, - `refund` + `refund`, ), - 30 + 30, ) paymentAfterReceivingRefundNotification = await ctpClient.fetchById( ctpClient.builder.payments, - paymentAfterCreateSession.id + paymentAfterCreateSession.id, ) paymentAfterReceivingRefundNotification = @@ -243,7 +243,7 @@ describe('::klarnaPayment::', () => { logger.debug( 'klarna::paymentAfterRefund:', - JSON.stringify(paymentAfterRefund) + JSON.stringify(paymentAfterRefund), ) } catch (err) { logger.error('klarna::errors', err) @@ -257,10 +257,10 @@ describe('::klarnaPayment::', () => { expect(refundEventCode).to.equal('REFUND') expect(refundSuccess).to.equal('true') expect(refundPspReference).to.not.equal( - paymentAfterReceivingRefundNotification.key + paymentAfterReceivingRefundNotification.key, ) expect(refundOriginalPspReference).to.be.equal( - paymentAfterReceivingRefundNotification.key + paymentAfterReceivingRefundNotification.key, ) }) @@ -272,7 +272,7 @@ describe('::klarnaPayment::', () => { }) { const initPaymentSessionFormPage = new KlarnaInitSessionFormPage( browserTab, - baseUrl + baseUrl, ) await initPaymentSessionFormPage.goToThisPage() @@ -291,14 +291,14 @@ describe('::klarnaPayment::', () => { const redirectPaymentFormPage = new RedirectPaymentFormPage( browserTab, - baseUrl + baseUrl, ) await redirectPaymentFormPage.goToThisPage() const submittedRedirectResult = await redirectPaymentFormPage.redirectToAdyenPaymentPage( clientKey, sessionId, - redirectResult + redirectResult, ) return submittedRedirectResult @@ -320,7 +320,7 @@ describe('::klarnaPayment::', () => { currency: transaction.amount.currencyCode, amount: transaction.amount.centAmount, }), - ] + ], ) return result.body @@ -329,24 +329,24 @@ describe('::klarnaPayment::', () => { function assertManualCaptureResponse(paymentAfterCapture) { const interfaceInteraction = getLatestInterfaceInteraction( paymentAfterCapture.interfaceInteractions, - constants.CTP_INTERACTION_TYPE_MANUAL_CAPTURE + constants.CTP_INTERACTION_TYPE_MANUAL_CAPTURE, ) const manualCaptureResponse = JSON.parse( - interfaceInteraction.fields.response + interfaceInteraction.fields.response, ) expect(manualCaptureResponse.status).to.equal( 'received', - `response status is not "received": ${manualCaptureResponse}` + `response status is not "received": ${manualCaptureResponse}`, ) expect(manualCaptureResponse.pspReference).to.match( /[A-Z0-9]+/, - `pspReference does not match '/[A-Z0-9]+/': ${manualCaptureResponse}` + `pspReference does not match '/[A-Z0-9]+/': ${manualCaptureResponse}`, ) const chargePendingTransaction = getChargeTransactionPending(paymentAfterCapture) expect(chargePendingTransaction.interactionId).to.equal( - manualCaptureResponse.pspReference + manualCaptureResponse.pspReference, ) } @@ -399,7 +399,7 @@ describe('::klarnaPayment::', () => { return JSON.stringify(createSessionRequestJson) } async function refundPaymentTransactions( - paymentAfterReceivingCaptureNotification + paymentAfterReceivingCaptureNotification, ) { const { statusCode, body: refundPayment } = await ctpClient.update( ctpClient.builder.payments, @@ -442,7 +442,7 @@ describe('::klarnaPayment::', () => { currency: 'EUR', amount: 100, }), - ] + ], ) return { statusCode, refundPayment } } diff --git a/extension/test/e2e/pageObjects/AffirmInitSessionFormPage.js b/extension/test/e2e/pageObjects/AffirmInitSessionFormPage.js index d0eede3e1..608be0074 100644 --- a/extension/test/e2e/pageObjects/AffirmInitSessionFormPage.js +++ b/extension/test/e2e/pageObjects/AffirmInitSessionFormPage.js @@ -11,66 +11,66 @@ export default class AffirmInitSessionFormPage extends InitSessionFormPage { await this.page.waitForSelector('.adyen-checkout__button--pay') // wait for rendering of web component const adyenCheckoutInputFormElement = await this.page.$( - '#adyen-payment-form-input' + '#adyen-payment-form-input', ) const adyenCheckoutInputForm = await ( await adyenCheckoutInputFormElement.getProperty('innerHTML') ).jsonValue() const adyenCheckoutInputFormJSON = JSON.parse( - adyenCheckoutInputForm.toString() + adyenCheckoutInputForm.toString(), ) await this.page.type( '.adyen-checkout__input--firstName', - adyenCheckoutInputFormJSON?.shopperName?.firstName + adyenCheckoutInputFormJSON?.shopperName?.firstName, ) await this.page.type( '.adyen-checkout__input--lastName', - adyenCheckoutInputFormJSON?.shopperName?.lastName + adyenCheckoutInputFormJSON?.shopperName?.lastName, ) await this.page.type( '.adyen-checkout__input--shopperEmail', - adyenCheckoutInputFormJSON?.shopperEmail + adyenCheckoutInputFormJSON?.shopperEmail, ) await this.page.type( '.adyen-checkout__input--telephoneNumber', - adyenCheckoutInputFormJSON?.telephoneNumber + adyenCheckoutInputFormJSON?.telephoneNumber, ) await this.page.type( '.adyen-checkout__input--street', - adyenCheckoutInputFormJSON?.billingAddress?.street + adyenCheckoutInputFormJSON?.billingAddress?.street, ) await this.page.type( '.adyen-checkout__input--houseNumberOrName', - adyenCheckoutInputFormJSON?.billingAddress?.houseNumberOrName + adyenCheckoutInputFormJSON?.billingAddress?.houseNumberOrName, ) await this.page.type( '.adyen-checkout__input--city', - adyenCheckoutInputFormJSON?.billingAddress?.city + adyenCheckoutInputFormJSON?.billingAddress?.city, ) await this.page.type( '.adyen-checkout__input--postalCode', - adyenCheckoutInputFormJSON?.billingAddress?.postalCode + adyenCheckoutInputFormJSON?.billingAddress?.postalCode, ) await this.fillDeliveryAddressStateDDL( - adyenCheckoutInputFormJSON?.billingAddress?.stateCode + adyenCheckoutInputFormJSON?.billingAddress?.stateCode, ) } async fillDeliveryAddressStateDDL(stateCodeInput) { const deliveryAddressStateElemList = await this.page.$$( - '.adyen-checkout__dropdown__list' + '.adyen-checkout__dropdown__list', ) const deliveryAddressStateElem = deliveryAddressStateElemList[1] const deliveryAddressStateOptions = await deliveryAddressStateElem.$$( - '.adyen-checkout__dropdown__element' + '.adyen-checkout__dropdown__element', ) deliveryAddressStateOptions.map(async (el) => { // const elem = e1 diff --git a/extension/test/e2e/pageObjects/AffirmRedirectAuthenticationPage.js b/extension/test/e2e/pageObjects/AffirmRedirectAuthenticationPage.js index 30c2d51ec..bfdf64a63 100644 --- a/extension/test/e2e/pageObjects/AffirmRedirectAuthenticationPage.js +++ b/extension/test/e2e/pageObjects/AffirmRedirectAuthenticationPage.js @@ -41,7 +41,7 @@ export default class AffirmRedirectAuthenticationPage { await this.page.evaluate((cb) => cb.click(), autoPayToggle) await this.page.waitForTimeout(1_000) // Wait for the page refreshes after toggling the autopay const confirmCheckbox = await this.page.$( - '[data-testid="disclosure-checkbox-indicator"]' + '[data-testid="disclosure-checkbox-indicator"]', ) await this.page.evaluate((cb) => cb.click(), confirmCheckbox) await Promise.all([ @@ -55,11 +55,11 @@ export default class AffirmRedirectAuthenticationPage { const redirectResultEle = await this.page.$('#redirectResult') const sessionId = await this.page.evaluate( (el) => el.textContent, - sessionIdEle + sessionIdEle, ) const redirectResult = await this.page.evaluate( (el) => el.textContent, - redirectResultEle + redirectResultEle, ) return { sessionId, redirectResult } } diff --git a/extension/test/e2e/pageObjects/CreditCard3dsNativePage.js b/extension/test/e2e/pageObjects/CreditCard3dsNativePage.js index 05a99d6d3..e8451cc58 100644 --- a/extension/test/e2e/pageObjects/CreditCard3dsNativePage.js +++ b/extension/test/e2e/pageObjects/CreditCard3dsNativePage.js @@ -8,18 +8,18 @@ export default class CreditCard3dsNativePage { async finish3dsNativePayment() { await executeInAdyenIframe(this.page, '[name=answer]', (el) => - el.type('password') + el.type('password'), ) await executeInAdyenIframe(this.page, 'button[type=submit]', (el, frame) => frame.$eval('#buttonSubmit', async (button) => { await button.click() - }) + }), ) await this.page.waitForTimeout(1_000) const additionalPaymentDetailsInput2 = await this.page.$( - '#adyen-additional-payment-details' + '#adyen-additional-payment-details', ) return this.page.evaluate((el) => el.value, additionalPaymentDetailsInput2) } diff --git a/extension/test/e2e/pageObjects/CreditCardInitSessionFormPage.js b/extension/test/e2e/pageObjects/CreditCardInitSessionFormPage.js index 7d94157d9..0683975d2 100644 --- a/extension/test/e2e/pageObjects/CreditCardInitSessionFormPage.js +++ b/extension/test/e2e/pageObjects/CreditCardInitSessionFormPage.js @@ -13,7 +13,7 @@ export default class CreditCardInitSessionFormPage extends InitSessionFormPage { await this.pasteValuesInCreditCardWebComponent( creditCardNumber, creditCardDate, - creditCardCvc + creditCardCvc, ) await this.confirmCreditCardWebComopnent() } @@ -21,26 +21,26 @@ export default class CreditCardInitSessionFormPage extends InitSessionFormPage { async pasteValuesInCreditCardWebComponent( creditCardNumber, creditCardDate, - creditCardCvc + creditCardCvc, ) { await this.page.waitForTimeout(2_000) // wait for web component rendering await executeInAdyenIframe( this.page, '[data-fieldtype=encryptedCardNumber]', - (el) => el.type(creditCardNumber) + (el) => el.type(creditCardNumber), ) await executeInAdyenIframe( this.page, 'input[data-fieldtype^=encryptedExpiry]', - (el) => el.type(creditCardDate) + (el) => el.type(creditCardDate), ) await executeInAdyenIframe( this.page, 'input[data-fieldtype^=encryptedSecurity]', - (el) => el.type(creditCardCvc) + (el) => el.type(creditCardCvc), ) } diff --git a/extension/test/e2e/pageObjects/CreditCardMakePaymentFormPage.js b/extension/test/e2e/pageObjects/CreditCardMakePaymentFormPage.js index fe47b9f6f..6f3c07a80 100644 --- a/extension/test/e2e/pageObjects/CreditCardMakePaymentFormPage.js +++ b/extension/test/e2e/pageObjects/CreditCardMakePaymentFormPage.js @@ -15,17 +15,17 @@ export default class CreditCardMakePaymentFormPage extends MakePaymentFormPage { await executeInAdyenIframe( this.page, '[data-fieldtype=encryptedCardNumber]', - (el) => el.type(creditCardNumber) + (el) => el.type(creditCardNumber), ) await executeInAdyenIframe( this.page, 'input[data-fieldtype^=encryptedExpiry]', - (el) => el.type(creditCardDate) + (el) => el.type(creditCardDate), ) await executeInAdyenIframe( this.page, 'input[data-fieldtype^=encryptedSecurity]', - (el) => el.type(creditCardCvc) + (el) => el.type(creditCardCvc), ) return this.getMakePaymentRequestTextAreaValue() diff --git a/extension/test/e2e/pageObjects/CreditCardNativeAuthenticationPage.js b/extension/test/e2e/pageObjects/CreditCardNativeAuthenticationPage.js index d88176da7..a64897786 100644 --- a/extension/test/e2e/pageObjects/CreditCardNativeAuthenticationPage.js +++ b/extension/test/e2e/pageObjects/CreditCardNativeAuthenticationPage.js @@ -19,7 +19,7 @@ export default class CreditCardNativeAuthenticationPage { await passwordInputEle.type('password') } const submitButtonEle = await frameWithPasswordInput.$( - 'button[type=submit]' + 'button[type=submit]', ) if (submitButtonEle) { await submitButtonEle.click() diff --git a/extension/test/e2e/pageObjects/CreditCardRedirectAuthenticationPage.js b/extension/test/e2e/pageObjects/CreditCardRedirectAuthenticationPage.js index 115925673..c7c731dee 100644 --- a/extension/test/e2e/pageObjects/CreditCardRedirectAuthenticationPage.js +++ b/extension/test/e2e/pageObjects/CreditCardRedirectAuthenticationPage.js @@ -18,11 +18,11 @@ export default class CreditCardRedirectAuthenticationPage { const redirectResultEle = await this.page.$('#redirectResult') const sessionId = await this.page.evaluate( (el) => el.textContent, - sessionIdEle + sessionIdEle, ) const redirectResult = await this.page.evaluate( (el) => el.textContent, - redirectResultEle + redirectResultEle, ) return { sessionId, redirectResult } } diff --git a/extension/test/e2e/pageObjects/InitSessionFormPage.js b/extension/test/e2e/pageObjects/InitSessionFormPage.js index dbcb28879..9cc129762 100644 --- a/extension/test/e2e/pageObjects/InitSessionFormPage.js +++ b/extension/test/e2e/pageObjects/InitSessionFormPage.js @@ -29,7 +29,7 @@ export default class InitSessionFormPage { await this.page.type( '#adyen-session-data', - createSessionResponse.sessionData + createSessionResponse.sessionData, ) await this.page.$eval('#adyen-session-data', (e) => e.blur()) } diff --git a/extension/test/e2e/pageObjects/KlarnaAuthenticationPage.js b/extension/test/e2e/pageObjects/KlarnaAuthenticationPage.js index 6dfb341d0..08b8227f9 100644 --- a/extension/test/e2e/pageObjects/KlarnaAuthenticationPage.js +++ b/extension/test/e2e/pageObjects/KlarnaAuthenticationPage.js @@ -14,11 +14,11 @@ export default class KlarnaAuthenticationPage { const redirectResultEle = await this.page.$('#redirectResult') const sessionId = await this.page.evaluate( (el) => el.textContent, - sessionIdEle + sessionIdEle, ) const redirectResult = await this.page.evaluate( (el) => el.textContent, - redirectResultEle + redirectResultEle, ) return { sessionId, redirectResult } } @@ -41,7 +41,7 @@ export default class KlarnaAuthenticationPage { // Use focus and keyboard instead of click method (see https://github.com/puppeteer/puppeteer/issues/4754) await klarnaIframe.waitForSelector( '#newCollectPhone [data-testid="kaf-button"]', - { visible: true } + { visible: true }, ) await klarnaIframe.focus('#newCollectPhone [data-testid="kaf-button"]') await this.page.keyboard.press('Enter') @@ -77,19 +77,19 @@ export default class KlarnaAuthenticationPage { }) const dialogButtons = await klarnaIframe.$$( '#directdebit\\.0-mandate-review button', - { visible: true } + { visible: true }, ) const confirmButton = dialogButtons[dialogButtons.length - 1] await confirmButton.click() await klarnaIframe.waitForSelector( '[data-testid="summary"] [data-testid="confirm-and-pay"]', - { visible: true } + { visible: true }, ) await klarnaIframe.click('[data-testid="confirm-and-pay"]') } else { const finalSubmitButton = await klarnaIframe.$( - '[data-testid="summary"] [data-testid="confirm-and-pay"]' + '[data-testid="summary"] [data-testid="confirm-and-pay"]', ) // Sleep before final click because klarna uses some internal state to disable button directly with its style. diff --git a/extension/test/e2e/pageObjects/MakePaymentFormPage.js b/extension/test/e2e/pageObjects/MakePaymentFormPage.js index c2515fd20..ce48f2fb9 100644 --- a/extension/test/e2e/pageObjects/MakePaymentFormPage.js +++ b/extension/test/e2e/pageObjects/MakePaymentFormPage.js @@ -22,7 +22,7 @@ export default class MakePaymentFormPage { await this.page.click('.adyen-checkout__button--pay') const makePaymentRequestTextArea = await this.page.$( - '#adyen-make-payment-request' + '#adyen-make-payment-request', ) return ( await makePaymentRequestTextArea.getProperty('innerHTML') diff --git a/extension/test/e2e/pageObjects/RedirectPaymentFormPage.js b/extension/test/e2e/pageObjects/RedirectPaymentFormPage.js index 0874bab0d..f2565bf8b 100644 --- a/extension/test/e2e/pageObjects/RedirectPaymentFormPage.js +++ b/extension/test/e2e/pageObjects/RedirectPaymentFormPage.js @@ -19,7 +19,7 @@ export default class RedirectPaymentFormPage { await this.page.click('#redirect-payment-button') await this.page.waitForTimeout(3_000) const redirectResultCodeEle = await this.page.$( - '#adyen-payment-auth-result' + '#adyen-payment-auth-result', ) return await this.page.evaluate((el) => el.value, redirectResultCodeEle) } diff --git a/extension/test/e2e/pageObjects/RedirectPaymentFormPageAdvancedFlow.js b/extension/test/e2e/pageObjects/RedirectPaymentFormPageAdvancedFlow.js index 4258c502c..c4455bb74 100644 --- a/extension/test/e2e/pageObjects/RedirectPaymentFormPageAdvancedFlow.js +++ b/extension/test/e2e/pageObjects/RedirectPaymentFormPageAdvancedFlow.js @@ -16,12 +16,12 @@ export default class RedirectPaymentFormPageAdvancedFlow { async redirectToAdyenPaymentPage(paymentDetailsResponse, clientKey) { logger.debug( 'redirectToAdyenPaymentPage::paymentDetailsResponse::', - paymentDetailsResponse + paymentDetailsResponse, ) await pasteValue( this.page, '#adyen-make-payment-response-action-field', - JSON.stringify(paymentDetailsResponse.action) + JSON.stringify(paymentDetailsResponse.action), ) await pasteValue(this.page, '#adyen-client-key', clientKey) diff --git a/extension/test/e2e/paypal.spec.js b/extension/test/e2e/paypal.spec.js index e46e14a7f..4a567d390 100644 --- a/extension/test/e2e/paypal.spec.js +++ b/extension/test/e2e/paypal.spec.js @@ -25,7 +25,7 @@ describe.skip('::paypalPayment::', () => { serveFile( './test/e2e/fixtures/paypal-init-session-form.html', request, - response + response, ) } @@ -52,7 +52,7 @@ describe.skip('::paypalPayment::', () => { const paymentAfterCreateSession = await createSession(clientKey) logger.debug( 'credit-card::paymentAfterCreateSession:', - JSON.stringify(paymentAfterCreateSession) + JSON.stringify(paymentAfterCreateSession), ) await initPaymentSession({ @@ -72,9 +72,9 @@ describe.skip('::paypalPayment::', () => { assertCreatePaymentSession( paymentAfterCreateSession, - initPaymentSessionResult + initPaymentSessionResult, ) - } + }, ) async function createSession(clientKey) { @@ -86,7 +86,7 @@ describe.skip('::paypalPayment::', () => { ctpClient, adyenMerchantAccount, ctpProjectKey, - createSessionRequest + createSessionRequest, ) } catch (err) { logger.error('paypal::createSession::errors', JSON.stringify(err)) @@ -107,7 +107,7 @@ describe.skip('::paypalPayment::', () => { }) { initPaymentSessionFormPage = new PaypalInitSessionFormPage( browserTab, - baseUrl + baseUrl, ) await initPaymentSessionFormPage.goToThisPage() diff --git a/extension/test/integration/ensure-resources.spec.js b/extension/test/integration/ensure-resources.spec.js index 984fe2356..53ce75e6f 100644 --- a/extension/test/integration/ensure-resources.spec.js +++ b/extension/test/integration/ensure-resources.spec.js @@ -15,7 +15,7 @@ describe('::ensure-resources::', () => { it('should ensure types', async () => { const apiExtensionTemplate = await utils.readAndParseJsonFile( - 'resources/api-extension.json' + 'resources/api-extension.json', ) const { body: { @@ -23,7 +23,7 @@ describe('::ensure-resources::', () => { }, } = await ctpClient.fetchByKey( ctpClient.builder.extensions, - apiExtensionTemplate.key + apiExtensionTemplate.key, ) // create resources @@ -70,7 +70,7 @@ describe('::ensure-resources::', () => { required: false, }, }, - ] + ], ), ctpClient.update( ctpClient.builder.types, @@ -95,33 +95,33 @@ describe('::ensure-resources::', () => { required: false, }, }, - ] + ], ), ]) } async function fetchTypes() { const interfaceInteractionType = await utils.readAndParseJsonFile( - 'resources/payment-interface-interaction-type.json' + 'resources/payment-interface-interaction-type.json', ) const paymentCustomType = await utils.readAndParseJsonFile( - 'resources/web-components-payment-type.json' + 'resources/web-components-payment-type.json', ) const { body: { results }, } = await ctpClient.fetch( ctpClient.builder.types.where( - `key in ("${paymentCustomType.key}", "${interfaceInteractionType.key}")` - ) + `key in ("${paymentCustomType.key}", "${interfaceInteractionType.key}")`, + ), ) expect(results).to.have.lengthOf(2) const existingPaymentType = results.filter( - (type) => type.key === paymentCustomType.key + (type) => type.key === paymentCustomType.key, )[0] const existingInterfaceType = results.filter( - (type) => type.key === interfaceInteractionType.key + (type) => type.key === interfaceInteractionType.key, )[0] return { existingPaymentType, existingInterfaceType } @@ -131,17 +131,17 @@ describe('::ensure-resources::', () => { const { existingPaymentType, existingInterfaceType } = await fetchTypes() expect( - existingPaymentType.fieldDefinitions.map((def) => def.name) + existingPaymentType.fieldDefinitions.map((def) => def.name), ).to.include.members(['commercetoolsProjectKey', 'adyenMerchantAccount']) expect( - existingPaymentType.fieldDefinitions.map((def) => def.name) + existingPaymentType.fieldDefinitions.map((def) => def.name), ).to.not.have.members(['customFieldOfUser']) expect( - existingInterfaceType.fieldDefinitions.map((def) => def.name) + existingInterfaceType.fieldDefinitions.map((def) => def.name), ).to.include.members(['type']) expect( - existingInterfaceType.fieldDefinitions.map((def) => def.name) + existingInterfaceType.fieldDefinitions.map((def) => def.name), ).to.not.have.members(['customFieldOfUser']) } }) diff --git a/extension/test/integration/get-carbon-offset-costs.handler.spec.js b/extension/test/integration/get-carbon-offset-costs.handler.spec.js index 2a8763460..f3266c784 100644 --- a/extension/test/integration/get-carbon-offset-costs.handler.spec.js +++ b/extension/test/integration/get-carbon-offset-costs.handler.spec.js @@ -23,7 +23,7 @@ describe('get-carbon-offset-costs', () => { }, } const interfaceInteractionResponse = await getCarbonOffsetCosts( - getCarbonOffsetCostsRequestDraft + getCarbonOffsetCostsRequestDraft, ) expect(interfaceInteractionResponse.deliveryOffset).to.exist expect(interfaceInteractionResponse.deliveryOffset.value).to.exist @@ -57,7 +57,7 @@ describe('get-carbon-offset-costs', () => { ], } const interfaceInteractionResponse = await getCarbonOffsetCosts( - getCarbonOffsetCostsRequestDraft + getCarbonOffsetCostsRequestDraft, ) expect(interfaceInteractionResponse.deliveryOffset).to.exist expect(interfaceInteractionResponse.deliveryOffset.value).to.exist @@ -82,7 +82,7 @@ describe('get-carbon-offset-costs', () => { }, fields: { getCarbonOffsetCostsRequest: JSON.stringify( - getCarbonOffsetCostsRequestDraft + getCarbonOffsetCostsRequestDraft, ), commercetoolsProjectKey, adyenMerchantAccount, @@ -92,24 +92,24 @@ describe('get-carbon-offset-costs', () => { const { statusCode, body: payment } = await ctpClient.create( ctpClient.builder.payments, - paymentDraft + paymentDraft, ) expect(statusCode).to.equal(201) const { getCarbonOffsetCostsRequest, getCarbonOffsetCostsResponse } = payment.custom.fields expect(getCarbonOffsetCostsRequest).to.be.deep.equal( - JSON.stringify(getCarbonOffsetCostsRequestDraft) + JSON.stringify(getCarbonOffsetCostsRequestDraft), ) const interfaceInteraction = payment.interfaceInteractions.find( (interaction) => interaction.fields.type === - c.CTP_INTERACTION_TYPE_GET_CARBON_OFFSET_COSTS + c.CTP_INTERACTION_TYPE_GET_CARBON_OFFSET_COSTS, ) expect(interfaceInteraction).to.not.undefined expect(getCarbonOffsetCostsResponse).to.be.deep.equal( - interfaceInteraction.fields.response + interfaceInteraction.fields.response, ) const request = JSON.parse(interfaceInteraction.fields.request) diff --git a/extension/test/integration/get-payment-methods.handler.spec.js b/extension/test/integration/get-payment-methods.handler.spec.js index 9ee9f6e17..15a9c4412 100644 --- a/extension/test/integration/get-payment-methods.handler.spec.js +++ b/extension/test/integration/get-payment-methods.handler.spec.js @@ -46,7 +46,7 @@ describe('::getPaymentMethods::', () => { }, fields: { getPaymentMethodsRequest: JSON.stringify( - getPaymentMethodsRequestDraft + getPaymentMethodsRequestDraft, ), commercetoolsProjectKey, adyenMerchantAccount, @@ -56,11 +56,11 @@ describe('::getPaymentMethods::', () => { const { statusCode, body: payment } = await ctpClient.create( ctpClient.builder.payments, - paymentDraft + paymentDraft, ) const getPaymentMethodsRequestExtended = _.cloneDeep( - getPaymentMethodsRequestDraft + getPaymentMethodsRequestDraft, ) getPaymentMethodsRequestExtended.applicationInfo = { merchantApplication: { @@ -77,23 +77,24 @@ describe('::getPaymentMethods::', () => { const { getPaymentMethodsRequest, getPaymentMethodsResponse } = payment.custom.fields expect(getPaymentMethodsRequest).to.be.deep.equal( - JSON.stringify(getPaymentMethodsRequestDraft) + JSON.stringify(getPaymentMethodsRequestDraft), ) const interfaceInteraction = payment.interfaceInteractions.find( (interaction) => - interaction.fields.type === c.CTP_INTERACTION_TYPE_GET_PAYMENT_METHODS + interaction.fields.type === + c.CTP_INTERACTION_TYPE_GET_PAYMENT_METHODS, ) expect(interfaceInteraction).to.not.undefined expect(getPaymentMethodsResponse).to.be.deep.equal( - interfaceInteraction.fields.response + interfaceInteraction.fields.response, ) const getPaymentMethodsRequestInteraction = JSON.parse( - interfaceInteraction.fields.request + interfaceInteraction.fields.request, ) const getPaymentMethodsRequestBody = JSON.parse( - getPaymentMethodsRequestInteraction.body + getPaymentMethodsRequestInteraction.body, ) expect(getPaymentMethodsRequestBody).to.be.deep.equal({ merchantAccount: adyenMerchantAccount, @@ -101,13 +102,13 @@ describe('::getPaymentMethods::', () => { }) const interfaceInteractionResponse = JSON.parse( - interfaceInteraction.fields.response + interfaceInteraction.fields.response, ) expect(interfaceInteractionResponse.paymentMethods).to.be.an.instanceof( - Array + Array, ) expect(interfaceInteractionResponse.additionalData).to.not.exist - } + }, ) it( @@ -139,7 +140,7 @@ describe('::getPaymentMethods::', () => { }, fields: { getPaymentMethodsRequest: JSON.stringify( - getPaymentMethodsRequestDraft + getPaymentMethodsRequestDraft, ), adyenMerchantAccount, commercetoolsProjectKey, @@ -149,11 +150,11 @@ describe('::getPaymentMethods::', () => { const { statusCode, body: payment } = await ctpClient.create( ctpClient.builder.payments, - paymentDraft + paymentDraft, ) const getPaymentMethodsRequestExtended = _.cloneDeep( - getPaymentMethodsRequestDraft + getPaymentMethodsRequestDraft, ) getPaymentMethodsRequestExtended.applicationInfo = { merchantApplication: { @@ -170,23 +171,24 @@ describe('::getPaymentMethods::', () => { const { getPaymentMethodsRequest, getPaymentMethodsResponse } = payment.custom.fields expect(getPaymentMethodsRequest).to.be.deep.equal( - JSON.stringify(getPaymentMethodsRequestDraft) + JSON.stringify(getPaymentMethodsRequestDraft), ) const paymentMethodsInteraction = payment.interfaceInteractions.find( (interaction) => - interaction.fields.type === c.CTP_INTERACTION_TYPE_GET_PAYMENT_METHODS + interaction.fields.type === + c.CTP_INTERACTION_TYPE_GET_PAYMENT_METHODS, ) expect(paymentMethodsInteraction).to.not.undefined expect(getPaymentMethodsResponse).to.be.deep.equal( - paymentMethodsInteraction.fields.response + paymentMethodsInteraction.fields.response, ) const getPaymentMethodsRequestInteraction = JSON.parse( - paymentMethodsInteraction.fields.request + paymentMethodsInteraction.fields.request, ) const getPaymentMethodsRequestBody = JSON.parse( - getPaymentMethodsRequestInteraction.body + getPaymentMethodsRequestInteraction.body, ) expect(getPaymentMethodsRequestBody).to.be.deep.equal({ merchantAccount: adyenMerchantAccount, @@ -194,12 +196,12 @@ describe('::getPaymentMethods::', () => { }) const paymentMethodsInteractionResponse = JSON.parse( - paymentMethodsInteraction.fields.response + paymentMethodsInteraction.fields.response, ) expect( - paymentMethodsInteractionResponse.paymentMethods + paymentMethodsInteractionResponse.paymentMethods, ).to.be.an.instanceof(Array) expect(paymentMethodsInteractionResponse.additionalData).to.not.exist - } + }, ) }) diff --git a/extension/test/integration/integration-test-set-up.js b/extension/test/integration/integration-test-set-up.js index 72b52c26d..39cbafdfe 100644 --- a/extension/test/integration/integration-test-set-up.js +++ b/extension/test/integration/integration-test-set-up.js @@ -61,10 +61,10 @@ async function _ensureCtpResources({ async function _ensureZones(ctpClient) { const ctpZone = await utils.readAndParseJsonFile( - 'test/integration/fixtures/ctp-zone.json' + 'test/integration/fixtures/ctp-zone.json', ) const { body } = await ctpClient.fetch( - ctpClient.builder.zones.where(`key="${ctpZone.key}"`) + ctpClient.builder.zones.where(`key="${ctpZone.key}"`), ) if (body.results.length === 0) return ctpClient.create(ctpClient.builder.zones, ctpZone) @@ -73,10 +73,10 @@ async function _ensureZones(ctpClient) { async function _ensureTaxCategories(ctpClient) { const ctpTaxCategory = await utils.readAndParseJsonFile( - 'test/integration/fixtures/ctp-tax-category.json' + 'test/integration/fixtures/ctp-tax-category.json', ) const { body } = await ctpClient.fetch( - ctpClient.builder.taxCategories.where(`key="${ctpTaxCategory.key}"`) + ctpClient.builder.taxCategories.where(`key="${ctpTaxCategory.key}"`), ) if (body.results.length === 0) return ctpClient.create(ctpClient.builder.taxCategories, ctpTaxCategory) @@ -85,10 +85,10 @@ async function _ensureTaxCategories(ctpClient) { async function _ensureShippingMethods(ctpClient, taxCategoryId, zoneId) { const ctpShippingMethod = await utils.readAndParseJsonFile( - 'test/integration/fixtures/ctp-shipping-method.json' + 'test/integration/fixtures/ctp-shipping-method.json', ) const { body } = await ctpClient.fetch( - ctpClient.builder.shippingMethods.where(`key="${ctpShippingMethod.key}"`) + ctpClient.builder.shippingMethods.where(`key="${ctpShippingMethod.key}"`), ) if (body.results.length === 0) { const ctpShippingMethodClone = _.cloneDeep(ctpShippingMethod) @@ -96,7 +96,7 @@ async function _ensureShippingMethods(ctpClient, taxCategoryId, zoneId) { ctpShippingMethodClone.zoneRates[0].zone.id = zoneId return ctpClient.create( ctpClient.builder.shippingMethods, - ctpShippingMethodClone + ctpShippingMethodClone, ) } return { body: body.results[0] } @@ -104,10 +104,10 @@ async function _ensureShippingMethods(ctpClient, taxCategoryId, zoneId) { async function _ensureProductTypes(ctpClient) { const ctpProductType = await utils.readAndParseJsonFile( - 'test/integration/fixtures/ctp-product-type.json' + 'test/integration/fixtures/ctp-product-type.json', ) const { body } = await ctpClient.fetch( - ctpClient.builder.productTypes.where(`key="${ctpProductType.key}"`) + ctpClient.builder.productTypes.where(`key="${ctpProductType.key}"`), ) if (body.results.length === 0) return ctpClient.create(ctpClient.builder.productTypes, ctpProductType) @@ -116,10 +116,10 @@ async function _ensureProductTypes(ctpClient) { async function _ensureCartDiscount(ctpClient) { const ctpCartDiscount = await utils.readAndParseJsonFile( - 'test/integration/fixtures/ctp-cart-discount.json' + 'test/integration/fixtures/ctp-cart-discount.json', ) const { body } = await ctpClient.fetch( - ctpClient.builder.cartDiscounts.where(`key="${ctpCartDiscount.key}"`) + ctpClient.builder.cartDiscounts.where(`key="${ctpCartDiscount.key}"`), ) if (body.results.length === 0) return ctpClient.create(ctpClient.builder.cartDiscounts, ctpCartDiscount) @@ -128,51 +128,51 @@ async function _ensureCartDiscount(ctpClient) { async function _ensureCartDiscountMultiBuy(ctpClient) { const ctpCartDiscountMultiBuy = await utils.readAndParseJsonFile( - 'test/integration/fixtures/ctp-cart-discount-multi-buy.json' + 'test/integration/fixtures/ctp-cart-discount-multi-buy.json', ) const { body } = await ctpClient.fetch( ctpClient.builder.cartDiscounts.where( - `key="${ctpCartDiscountMultiBuy.key}"` - ) + `key="${ctpCartDiscountMultiBuy.key}"`, + ), ) if (body.results.length === 0) return ctpClient.create( ctpClient.builder.cartDiscounts, - ctpCartDiscountMultiBuy + ctpCartDiscountMultiBuy, ) return { body: body.results[0] } } async function _ensureCartDiscountShipping(ctpClient) { const ctpCartDiscountShipping = await utils.readAndParseJsonFile( - 'test/integration/fixtures/ctp-cart-discount-shipping.json' + 'test/integration/fixtures/ctp-cart-discount-shipping.json', ) const { body } = await ctpClient.fetch( ctpClient.builder.cartDiscounts.where( - `key="${ctpCartDiscountShipping.key}"` - ) + `key="${ctpCartDiscountShipping.key}"`, + ), ) if (body.results.length === 0) return ctpClient.create( ctpClient.builder.cartDiscounts, - ctpCartDiscountShipping + ctpCartDiscountShipping, ) return { body: body.results[0] } } async function _ensureDiscountCode(ctpClient, cartDiscountId) { const ctpDiscountCode = await utils.readAndParseJsonFile( - 'test/integration/fixtures/ctp-discount-code.json' + 'test/integration/fixtures/ctp-discount-code.json', ) const { body } = await ctpClient.fetch( - ctpClient.builder.discountCodes.where(`code="${ctpDiscountCode.code}"`) + ctpClient.builder.discountCodes.where(`code="${ctpDiscountCode.code}"`), ) if (body.results.length === 0) { const ctpDiscountCodeClone = _.cloneDeep(ctpDiscountCode) ctpDiscountCodeClone.cartDiscounts[0].id = cartDiscountId return ctpClient.create( ctpClient.builder.discountCodes, - ctpDiscountCodeClone + ctpDiscountCodeClone, ) } return { body: body.results[0] } @@ -180,19 +180,19 @@ async function _ensureDiscountCode(ctpClient, cartDiscountId) { async function _ensureDiscountCodeMultiBuy(ctpClient, cartDiscountId) { const ctpDiscountCodeMultiBuy = await utils.readAndParseJsonFile( - 'test/integration/fixtures/ctp-discount-code-multi-buy.json' + 'test/integration/fixtures/ctp-discount-code-multi-buy.json', ) const { body } = await ctpClient.fetch( ctpClient.builder.discountCodes.where( - `code="${ctpDiscountCodeMultiBuy.code}"` - ) + `code="${ctpDiscountCodeMultiBuy.code}"`, + ), ) if (body.results.length === 0) { const ctpDiscountCodeMultiBuyClone = _.cloneDeep(ctpDiscountCodeMultiBuy) ctpDiscountCodeMultiBuyClone.cartDiscounts[0].id = cartDiscountId return ctpClient.create( ctpClient.builder.discountCodes, - ctpDiscountCodeMultiBuyClone + ctpDiscountCodeMultiBuyClone, ) } return { body: body.results[0] } @@ -200,19 +200,19 @@ async function _ensureDiscountCodeMultiBuy(ctpClient, cartDiscountId) { async function _ensureDiscountCodeShipping(ctpClient, cartDiscountId) { const ctpDiscountCodeShipping = await utils.readAndParseJsonFile( - 'test/integration/fixtures/ctp-discount-code-shipping.json' + 'test/integration/fixtures/ctp-discount-code-shipping.json', ) const { body } = await ctpClient.fetch( ctpClient.builder.discountCodes.where( - `code="${ctpDiscountCodeShipping.code}"` - ) + `code="${ctpDiscountCodeShipping.code}"`, + ), ) if (body.results.length === 0) { const ctpDiscountCodeShippingClone = _.cloneDeep(ctpDiscountCodeShipping) ctpDiscountCodeShippingClone.cartDiscounts[0].id = cartDiscountId return ctpClient.create( ctpClient.builder.discountCodes, - ctpDiscountCodeShippingClone + ctpDiscountCodeShippingClone, ) } return { body: body.results[0] } @@ -220,15 +220,15 @@ async function _ensureDiscountCodeShipping(ctpClient, cartDiscountId) { async function _ensureProducts(ctpClient, productTypeId, taxCategoryId) { const ctpProductUsd = await utils.readAndParseJsonFile( - 'test/integration/fixtures/usd/ctp-product.json' + 'test/integration/fixtures/usd/ctp-product.json', ) const ctpProduct = await utils.readAndParseJsonFile( - 'test/integration/fixtures/ctp-product.json' + 'test/integration/fixtures/ctp-product.json', ) const productKey = currency === 'USD' ? ctpProductUsd.key : ctpProduct.key const { body } = await ctpClient.fetch( - ctpClient.builder.products.where(`key="${productKey}"`) + ctpClient.builder.products.where(`key="${productKey}"`), ) if (body.results.length === 0) { let ctpProductClone @@ -238,7 +238,7 @@ async function _ensureProducts(ctpClient, productTypeId, taxCategoryId) { ctpProductClone.taxCategory.id = taxCategoryId const { body: product } = await ctpClient.create( ctpClient.builder.products, - ctpProductClone + ctpProductClone, ) return _publish(ctpClient, product) } @@ -261,10 +261,10 @@ async function _ensurePayment({ commercetoolsProjectKey, }) { const ctpPayment = await utils.readAndParseJsonFile( - 'test/integration/fixtures/ctp-payment.json' + 'test/integration/fixtures/ctp-payment.json', ) const ctpPaymentUsd = await utils.readAndParseJsonFile( - 'test/integration/fixtures/usd/ctp-payment.json' + 'test/integration/fixtures/usd/ctp-payment.json', ) if (currency === 'USD') { ctpPaymentUsd.custom.fields.adyenMerchantAccount = adyenMerchantAccount @@ -282,13 +282,13 @@ async function _createCart( productId, paymentId, shippingMethodId, - discountCodes + discountCodes, ) { const ctpCartUsd = await utils.readAndParseJsonFile( - 'test/integration/fixtures/usd/ctp-cart.json' + 'test/integration/fixtures/usd/ctp-cart.json', ) const ctpCart = await utils.readAndParseJsonFile( - 'test/integration/fixtures/ctp-cart.json' + 'test/integration/fixtures/ctp-cart.json', ) let ctpCartClone if (currency === 'USD') ctpCartClone = _.cloneDeep(ctpCartUsd) @@ -297,7 +297,7 @@ async function _createCart( ctpCartClone.shippingMethod.id = shippingMethodId const { body: cartResponse } = await ctpClient.create( ctpClient.builder.carts, - ctpCartClone + ctpCartClone, ) return ctpClient.update( ctpClient.builder.carts, @@ -317,7 +317,7 @@ async function _createCart( }, taxCategory: { typeId: 'tax-category', key: 'standard' }, }, - ] + ], ) } diff --git a/extension/test/integration/make-payment.handler.spec.js b/extension/test/integration/make-payment.handler.spec.js index 1ad14592d..9c391ad7d 100644 --- a/extension/test/integration/make-payment.handler.spec.js +++ b/extension/test/integration/make-payment.handler.spec.js @@ -37,7 +37,7 @@ describe('::make-payment with multiple adyen accounts use case::', () => { adyenMerchantAccount: adyenMerchantAccount2 || adyenMerchantAccount1, }), ]) - } + }, ) it( @@ -82,7 +82,7 @@ describe('::make-payment with multiple adyen accounts use case::', () => { name: 'makePaymentRequest', value: JSON.stringify(makePaymentRequestDraft), }, - ] + ], ) const makePaymentResponse = @@ -98,12 +98,12 @@ describe('::make-payment with multiple adyen accounts use case::', () => { const interfaceInteraction = updatedPayment.interfaceInteractions.find( (interaction) => interaction.fields.type === - constants.CTP_INTERACTION_TYPE_MAKE_PAYMENT + constants.CTP_INTERACTION_TYPE_MAKE_PAYMENT, ) const makePaymentRequest = JSON.parse(interfaceInteraction.fields.request) const makePaymentRequestBody = JSON.parse(makePaymentRequest.body) expect(makePaymentRequestBody.lineItems).to.have.lengthOf(3) - } + }, ) async function makePayment({ reference, adyenMerchantAccount, metadata }) { @@ -146,7 +146,7 @@ describe('::make-payment with multiple adyen accounts use case::', () => { const { statusCode, body: payment } = await ctpClient.create( ctpClient.builder.payments, - paymentDraft + paymentDraft, ) expect(statusCode).to.equal(201) @@ -158,7 +158,7 @@ describe('::make-payment with multiple adyen accounts use case::', () => { const interfaceInteraction = payment.interfaceInteractions.find( (interaction) => - interaction.fields.type === constants.CTP_INTERACTION_TYPE_MAKE_PAYMENT + interaction.fields.type === constants.CTP_INTERACTION_TYPE_MAKE_PAYMENT, ) const makePaymentRequest = JSON.parse(interfaceInteraction.fields.request) const makePaymentRequestBody = JSON.parse(makePaymentRequest.body) @@ -174,11 +174,11 @@ describe('::make-payment with multiple adyen accounts use case::', () => { } expect(makePaymentRequestBody.merchantAccount).to.be.equal( - adyenMerchantAccount + adyenMerchantAccount, ) expect(makePaymentResponse).to.be.deep.equal( - interfaceInteraction.fields.response + interfaceInteraction.fields.response, ) expect(JSON.parse(makePaymentResponse).resultCode).to.be.equal('Authorised') @@ -188,7 +188,7 @@ describe('::make-payment with multiple adyen accounts use case::', () => { expect(transaction.type).to.be.equal('Authorization') expect(transaction.amount.currencyCode).to.be.equal('EUR') expect(transaction.amount.centAmount).to.be.equal( - paymentDraft.amountPlanned.centAmount + paymentDraft.amountPlanned.centAmount, ) expect(transaction.interactionId).to.be.a('string') } diff --git a/extension/test/integration/manual-capture.spec.js b/extension/test/integration/manual-capture.spec.js index 759b7bcba..28e64ad16 100644 --- a/extension/test/integration/manual-capture.spec.js +++ b/extension/test/integration/manual-capture.spec.js @@ -55,7 +55,7 @@ describe('::manualCapture::', () => { const result = await ctpClient.create( ctpClient.builder.payments, - paymentDraft + paymentDraft, ) payment = result.body }) @@ -78,13 +78,13 @@ describe('::manualCapture::', () => { }, }, }), - ] + ], ) const transaction1 = chargedPayment1.transactions[2] const interfaceInteraction1 = chargedPayment1.interfaceInteractions.filter( (interaction) => - interaction.fields.type === CTP_INTERACTION_TYPE_MANUAL_CAPTURE + interaction.fields.type === CTP_INTERACTION_TYPE_MANUAL_CAPTURE, )[1] const adyenRequest1 = JSON.parse(interfaceInteraction1.fields.request) expect(adyenRequest1.headers['Idempotency-Key']).to.equal(transaction1.id) @@ -121,7 +121,7 @@ describe('::manualCapture::', () => { }, }, }), - ] + ], ) expect(statusCode).to.be.equal(200) @@ -133,7 +133,7 @@ describe('::manualCapture::', () => { const interfaceInteraction = chargedPayment.interfaceInteractions.find( (interaction) => - interaction.fields.type === CTP_INTERACTION_TYPE_MANUAL_CAPTURE + interaction.fields.type === CTP_INTERACTION_TYPE_MANUAL_CAPTURE, ) const adyenRequest = JSON.parse(interfaceInteraction.fields.request) @@ -143,6 +143,6 @@ describe('::manualCapture::', () => { expect(transaction.interactionId).to.equal(adyenResponse.pspReference) await testGenerateIdempotencyKey(chargedPayment) - } + }, ) }) diff --git a/extension/test/integration/sessions-request.handler.spec.js b/extension/test/integration/sessions-request.handler.spec.js index 2757920ca..c91f01f84 100644 --- a/extension/test/integration/sessions-request.handler.spec.js +++ b/extension/test/integration/sessions-request.handler.spec.js @@ -57,11 +57,11 @@ describe('::create-session-request::', () => { const { statusCode, body: payment } = await ctpClient.create( ctpClient.builder.payments, - paymentDraft + paymentDraft, ) const createSessionRequestExtended = _.cloneDeep( - createSessionRequestDraft + createSessionRequestDraft, ) createSessionRequestExtended.metadata = { @@ -83,24 +83,24 @@ describe('::create-session-request::', () => { const { createSessionRequest, createSessionResponse } = payment.custom.fields expect(createSessionRequest).to.be.deep.equal( - JSON.stringify(createSessionRequestDraft) + JSON.stringify(createSessionRequestDraft), ) const interfaceInteraction = payment.interfaceInteractions.find( (interaction) => interaction.fields.type === - constants.CTP_INTERACTION_TYPE_CREATE_SESSION + constants.CTP_INTERACTION_TYPE_CREATE_SESSION, ) expect(interfaceInteraction).to.not.undefined expect(createSessionResponse).to.be.deep.equal( - interfaceInteraction.fields.response + interfaceInteraction.fields.response, ) const createSessionRequestInteraction = JSON.parse( - interfaceInteraction.fields.request + interfaceInteraction.fields.request, ) const createSessionRequestBody = JSON.parse( - createSessionRequestInteraction.body + createSessionRequestInteraction.body, ) expect(createSessionRequestBody).to.be.deep.equal({ @@ -109,11 +109,11 @@ describe('::create-session-request::', () => { }) const interfaceInteractionResponse = JSON.parse( - interfaceInteraction.fields.response + interfaceInteraction.fields.response, ) expect(interfaceInteractionResponse.additionalData).to.not.exist expect(interfaceInteractionResponse.sessionData).to.not.undefined - } + }, ) it( @@ -149,7 +149,7 @@ describe('::create-session-request::', () => { name: 'createSessionRequest', value: JSON.stringify(createSessionRequestDraft), }, - ] + ], ) expect(statusCode).to.equal(200) expect(updatedPayment.key).to.equal(createSessionRequestDraft.reference) @@ -157,13 +157,13 @@ describe('::create-session-request::', () => { const interfaceInteraction = updatedPayment.interfaceInteractions.find( (interaction) => interaction.fields.type === - constants.CTP_INTERACTION_TYPE_CREATE_SESSION + constants.CTP_INTERACTION_TYPE_CREATE_SESSION, ) const createSessionRequest = JSON.parse( - interfaceInteraction.fields.request + interfaceInteraction.fields.request, ) const createSessionRequestBody = JSON.parse(createSessionRequest.body) expect(createSessionRequestBody.lineItems).to.have.lengthOf(3) - } + }, ) }) diff --git a/extension/test/test-utils.js b/extension/test/test-utils.js index 4bd088bab..46b7d772b 100644 --- a/extension/test/test-utils.js +++ b/extension/test/test-utils.js @@ -127,7 +127,7 @@ async function updatePaymentWithRetry(ctpClient, actions, payment) { ctpClient.builder.payments, payment.id, version, - actions + actions, ) statusCode = response.statusCode updatedPayment = response.body @@ -136,7 +136,7 @@ async function updatePaymentWithRetry(ctpClient, actions, payment) { if (e.statusCode === 409) { const { body } = await ctpClient.fetchById( ctpClient.builder.payments, - payment.id + payment.id, ) version = body.version } else { @@ -158,7 +158,7 @@ async function ensureAdyenWebhookForAllAdyenAccounts(webhookUrl) { const webhookId = await ensureAdyenWebhook( adyenConfig.apiKey, webhookUrlWithProjectKey, - adyenMerchantId + adyenMerchantId, ) merchantIdToWebhookIdMap.set(adyenMerchantId, webhookId) } @@ -183,7 +183,7 @@ async function setUpWebhooksAndNotificationModule() { await ensureAdyenWebhookForAllAdyenAccounts(webhookUrl) notificationTunnel = await initTunnel( notificationTunnelDomain, - notificationPort + notificationPort, ) } @@ -200,7 +200,7 @@ async function deleteWebhooks() { 'Content-Type': 'application/json', 'X-Api-Key': adyenConfig.apiKey, }, - } + }, ) } } @@ -208,7 +208,7 @@ async function deleteWebhooks() { async function waitUntil( waitCondition, maxRetry = 15, - maxWaitingTimePerRetryInMs = 32000 + maxWaitingTimePerRetryInMs = 32000, ) { let counter = 0 while (true) { @@ -249,13 +249,14 @@ async function ensureAdyenWebhook(adyenApiKey, webhookUrl, merchantId) { 'Content-Type': 'application/json', 'X-Api-Key': adyenApiKey, }, - } + }, ) const getWebhookResponseJson = await getWebhookResponse.json() const existingWebhook = getWebhookResponseJson.data?.find( (webhook) => - webhook.url === webhookConfig.url && webhook.type === webhookConfig.type + webhook.url === webhookConfig.url && + webhook.type === webhookConfig.type, ) if (existingWebhook) { @@ -271,7 +272,7 @@ async function ensureAdyenWebhook(adyenApiKey, webhookUrl, merchantId) { 'Content-Type': 'application/json', 'X-Api-Key': adyenApiKey, }, - } + }, ) return existingWebhook.id } @@ -285,7 +286,7 @@ async function ensureAdyenWebhook(adyenApiKey, webhookUrl, merchantId) { 'Content-Type': 'application/json', 'X-Api-Key': adyenApiKey, }, - } + }, ) const createWebhookResponseJson = await createWebhookResponse.json() @@ -294,7 +295,7 @@ async function ensureAdyenWebhook(adyenApiKey, webhookUrl, merchantId) { } catch (err) { throw Error( `Failed to ensure adyen webhook for project ${merchantId}.` + - `Error: ${JSON.stringify(serializeError(err))}` + `Error: ${JSON.stringify(serializeError(err))}`, ) } } @@ -302,16 +303,16 @@ async function ensureAdyenWebhook(adyenApiKey, webhookUrl, merchantId) { async function fetchNotificationInterfaceInteraction( ctpClient, paymentId, - status = 'authorisation' + status = 'authorisation', ) { const { body } = await ctpClient.fetchById( ctpClient.builder.payments, - paymentId + paymentId, ) return body.interfaceInteractions.find( (interaction) => interaction.fields.type === 'notification' && - interaction.fields.status === status + interaction.fields.status === status, ) } diff --git a/extension/test/unit/amount-updates.handler.spec.js b/extension/test/unit/amount-updates.handler.spec.js index 755732403..136e14d65 100644 --- a/extension/test/unit/amount-updates.handler.spec.js +++ b/extension/test/unit/amount-updates.handler.spec.js @@ -95,7 +95,7 @@ describe('amount-updates.handler::execute::', () => { const paymentObject = cloneDeep(authorisedPayment) paymentObject.custom.fields.amountUpdatesRequest = JSON.stringify( - amountUpdatesRequestDraft + amountUpdatesRequestDraft, ) const { actions } = await amountUpdatesHandler.execute(paymentObject) @@ -103,15 +103,15 @@ describe('amount-updates.handler::execute::', () => { expect(actions).to.have.lengthOf(2) const addInterfaceInteraction = actions.find( - (a) => a.action === 'addInterfaceInteraction' + (a) => a.action === 'addInterfaceInteraction', ) expect(addInterfaceInteraction.fields.type).to.equal( - constants.CTP_INTERACTION_TYPE_AMOUNT_UPDATES + constants.CTP_INTERACTION_TYPE_AMOUNT_UPDATES, ) expect(addInterfaceInteraction.fields.request).to.be.a('string') expect(addInterfaceInteraction.fields.response).to.equal( - JSON.stringify(amountUpdatesResponse) + JSON.stringify(amountUpdatesResponse), ) expect(addInterfaceInteraction.fields.createdAt).to.be.a('string') @@ -121,6 +121,6 @@ describe('amount-updates.handler::execute::', () => { action: 'setCustomField', value: JSON.stringify(amountUpdatesResponse), }) - } + }, ) }) diff --git a/extension/test/unit/authentication.spec.js b/extension/test/unit/authentication.spec.js index 09f1d7ca7..03b42f8cc 100644 --- a/extension/test/unit/authentication.spec.js +++ b/extension/test/unit/authentication.spec.js @@ -20,7 +20,7 @@ describe('Authentication unit test', () => { const sandbox = sinon.createSandbox() sandbox.stub(config, 'getCtpConfig').returns(ctpDummyConfig) const result = generateBasicAuthorizationHeaderValue( - ctpDummyConfig.projectKey + ctpDummyConfig.projectKey, ) expect(result).to.equal('Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==') sandbox.restore() @@ -31,7 +31,7 @@ describe('Authentication unit test', () => { const sandbox = sinon.createSandbox() sandbox.stub(config, 'getCtpConfig').returns(ctpDummyConfig) const result = generateBasicAuthorizationHeaderValue( - ctpDummyConfig.projectKey + ctpDummyConfig.projectKey, ) expect(result).to.not.exist sandbox.restore() diff --git a/extension/test/unit/cancel-payment.handler.spec.js b/extension/test/unit/cancel-payment.handler.spec.js index bd655da7a..8ce259c22 100644 --- a/extension/test/unit/cancel-payment.handler.spec.js +++ b/extension/test/unit/cancel-payment.handler.spec.js @@ -34,7 +34,7 @@ describe('cancel-payment::execute', () => { before(async () => { ctpPayment = await utils.readAndParseJsonFile( - 'test/unit/fixtures/ctp-payment.json' + 'test/unit/fixtures/ctp-payment.json', ) }) @@ -64,19 +64,19 @@ describe('cancel-payment::execute', () => { expect(actions).to.have.lengthOf(3) const addInterfaceInteraction = actions.find( - (a) => a.action === 'addInterfaceInteraction' + (a) => a.action === 'addInterfaceInteraction', ) expect(addInterfaceInteraction.fields.type).to.equal( - CTP_INTERACTION_TYPE_CANCEL_PAYMENT + CTP_INTERACTION_TYPE_CANCEL_PAYMENT, ) expect(addInterfaceInteraction.fields.request).to.be.a('string') expect(addInterfaceInteraction.fields.response).to.equal( - JSON.stringify(cancelPaymentResponse) + JSON.stringify(cancelPaymentResponse), ) expect(addInterfaceInteraction.fields.createdAt).to.be.a('string') const changeTransactionState = actions.find( - (a) => a.action === 'changeTransactionState' + (a) => a.action === 'changeTransactionState', ) expect(changeTransactionState).to.be.deep.equal({ transactionId: 'cancelTransactionId', @@ -85,13 +85,13 @@ describe('cancel-payment::execute', () => { }) const changeTransactionInteractionId = actions.find( - (a) => a.action === 'changeTransactionInteractionId' + (a) => a.action === 'changeTransactionInteractionId', ) expect(changeTransactionInteractionId).to.be.deep.equal({ transactionId: 'cancelTransactionId', action: 'changeTransactionInteractionId', interactionId: '8825408195409505', }) - } + }, ) }) diff --git a/extension/test/unit/config/config.spec.js b/extension/test/unit/config/config.spec.js index f29cfe24b..96aa52948 100644 --- a/extension/test/unit/config/config.spec.js +++ b/extension/test/unit/config/config.spec.js @@ -188,7 +188,7 @@ describe('::config::', () => { expect.fail('This test should throw an error, but it did not') } catch (e) { expect(e.message).to.contain( - 'Authentication is not properly configured. Please update the configuration' + 'Authentication is not properly configured. Please update the configuration', ) } }) @@ -223,7 +223,7 @@ describe('::config::', () => { expect.fail('This test should throw an error, but it did not') } catch (e) { expect(e.message).to.contain( - 'Authentication is not properly configured. Please update the configuration' + 'Authentication is not properly configured. Please update the configuration', ) } }) @@ -259,7 +259,7 @@ describe('::config::', () => { expect.fail('This test should throw an error, but it did not') } catch (e) { expect(e.message).to.contain( - 'Authentication is not properly configured. Please update the configuration' + 'Authentication is not properly configured. Please update the configuration', ) } }) @@ -292,7 +292,7 @@ describe('::config::', () => { gpay: { en: 'Google Pay' }, affirm: { en: 'Affirm' }, }) - } + }, ) it( @@ -327,7 +327,7 @@ describe('::config::', () => { affirm: { en: 'Affirm' }, gpay: { en: 'Google pay' }, }) - } + }, ) describe('removeSentitiveData', () => { @@ -362,9 +362,9 @@ describe('::config::', () => { }) const config = await reloadModule('../../../src/config/config.js') expect(config.default.getModuleConfig().removeSensitiveData).to.eql( - false + false, ) - } + }, ) it( @@ -398,9 +398,9 @@ describe('::config::', () => { }) const config = await reloadModule('../../../src/config/config.js') expect(config.default.getModuleConfig().removeSensitiveData).to.eql( - true + true, ) - } + }, ) it( @@ -426,9 +426,9 @@ describe('::config::', () => { }) const config = await reloadModule('../../../src/config/config.js') expect(config.default.getModuleConfig().removeSensitiveData).to.eql( - false + false, ) - } + }, ) it( @@ -454,9 +454,9 @@ describe('::config::', () => { }) const config = await reloadModule('../../../src/config/config.js') expect(config.default.getModuleConfig().removeSensitiveData).to.eql( - true + true, ) - } + }, ) }) @@ -492,9 +492,9 @@ describe('::config::', () => { }) const config = await reloadModule('../../../src/config/config.js') expect( - config.default.getModuleConfig().addCommercetoolsLineItems + config.default.getModuleConfig().addCommercetoolsLineItems, ).to.eql(false) - } + }, ) it( @@ -528,9 +528,9 @@ describe('::config::', () => { }) const config = await reloadModule('../../../src/config/config.js') expect( - config.default.getModuleConfig().addCommercetoolsLineItems + config.default.getModuleConfig().addCommercetoolsLineItems, ).to.eql(true) - } + }, ) it( @@ -556,9 +556,9 @@ describe('::config::', () => { }) const config = await reloadModule('../../../src/config/config.js') expect( - config.default.getModuleConfig().addCommercetoolsLineItems + config.default.getModuleConfig().addCommercetoolsLineItems, ).to.eql(false) - } + }, ) it( @@ -584,9 +584,9 @@ describe('::config::', () => { }) const config = await reloadModule('../../../src/config/config.js') expect( - config.default.getModuleConfig().addCommercetoolsLineItems + config.default.getModuleConfig().addCommercetoolsLineItems, ).to.eql(true) - } + }, ) }) @@ -622,9 +622,9 @@ describe('::config::', () => { }) const config = await reloadModule('../../../src/config/config.js') expect(config.default.getModuleConfig().generateIdempotencyKey).to.eql( - false + false, ) - } + }, ) it( @@ -658,9 +658,9 @@ describe('::config::', () => { }) const config = await reloadModule('../../../src/config/config.js') expect(config.default.getModuleConfig().generateIdempotencyKey).to.eql( - true + true, ) - } + }, ) it( @@ -686,9 +686,9 @@ describe('::config::', () => { }) const config = await reloadModule('../../../src/config/config.js') expect(config.default.getModuleConfig().generateIdempotencyKey).to.eql( - false + false, ) - } + }, ) it( @@ -714,9 +714,9 @@ describe('::config::', () => { }) const config = await reloadModule('../../../src/config/config.js') expect(config.default.getModuleConfig().generateIdempotencyKey).to.eql( - true + true, ) - } + }, ) }) @@ -727,7 +727,7 @@ describe('::config::', () => { expect.fail('This test should throw an error, but it did not') } catch (e) { expect(e.message).to.contain( - 'configuration is not provided in the JSON format' + 'configuration is not provided in the JSON format', ) } }) @@ -768,7 +768,7 @@ describe('::config::', () => { const loadedConfig = await reloadModule('../../../src/config/config.js') expect( - loadedConfig.default.getCtpConfig('ctpProjectKey1') + loadedConfig.default.getCtpConfig('ctpProjectKey1'), ).to.deep.equal({ clientId: 'clientId', clientSecret: 'clientSecret', @@ -782,7 +782,7 @@ describe('::config::', () => { }, }) expect( - loadedConfig.default.getAdyenConfig('adyenMerchantAccount1') + loadedConfig.default.getAdyenConfig('adyenMerchantAccount1'), ).to.deep.equal({ apiBaseUrl: 'apiBaseUrl', apiKey: 'apiKey', @@ -794,7 +794,7 @@ describe('::config::', () => { fs.unlinkSync(filePath) renameExtensionrcFile(tempFileName, extensionConfigFileName) } - } + }, ) function renameExtensionrcFile(fileName, fileNameToRename) { diff --git a/extension/test/unit/config/init/ensure-resources.spec.js b/extension/test/unit/config/init/ensure-resources.spec.js index 12cb300c9..1f8935489 100644 --- a/extension/test/unit/config/init/ensure-resources.spec.js +++ b/extension/test/unit/config/init/ensure-resources.spec.js @@ -25,13 +25,13 @@ describe('Ensure resources', () => { before(async () => { webComponentsPaymentType = await utils.readAndParseJsonFile( - 'resources/web-components-payment-type.json' + 'resources/web-components-payment-type.json', ) apiExtension = await utils.readAndParseJsonFile( - 'resources/api-extension.json' + 'resources/api-extension.json', ) interfaceInteractionType = await utils.readAndParseJsonFile( - 'resources/payment-interface-interaction-type.json' + 'resources/payment-interface-interaction-type.json', ) }) @@ -51,12 +51,12 @@ describe('Ensure resources', () => { const callArgs = _.flattenDeep(createStub.args) const createdPaymentType = callArgs.find( - (arg) => arg.key === webComponentsPaymentType.key + (arg) => arg.key === webComponentsPaymentType.key, ) expect(createdPaymentType).to.deep.equal(webComponentsPaymentType) const createdApiExtension = callArgs.find( - (arg) => arg.key === apiExtension.key + (arg) => arg.key === apiExtension.key, ) // set the url variable in the template to the correctly evaluated value const apiExtensionCloned = _.cloneDeep(apiExtension) @@ -64,10 +64,10 @@ describe('Ensure resources', () => { expect(createdApiExtension).to.deep.equal(apiExtensionCloned) const createdInterfaceInteractionType = callArgs.find( - (arg) => arg.key === interfaceInteractionType.key + (arg) => arg.key === interfaceInteractionType.key, ) expect(createdInterfaceInteractionType).to.deep.equal( - interfaceInteractionType + interfaceInteractionType, ) }) diff --git a/extension/test/unit/create-lineitems-session-request.handler.spec.js b/extension/test/unit/create-lineitems-session-request.handler.spec.js index 694b5886a..3ae01b80c 100644 --- a/extension/test/unit/create-lineitems-session-request.handler.spec.js +++ b/extension/test/unit/create-lineitems-session-request.handler.spec.js @@ -18,13 +18,13 @@ describe('create-lineitems-session-request::execute', () => { before(async () => { ctpPayment = await utils.readAndParseJsonFile( - 'test/unit/fixtures/ctp-payment.json' + 'test/unit/fixtures/ctp-payment.json', ) ctpCart = await utils.readAndParseJsonFile( - 'test/unit/fixtures/ctp-cart.json' + 'test/unit/fixtures/ctp-cart.json', ) ctpCartWithCustomShippingMethod = await utils.readAndParseJsonFile( - 'test/unit/fixtures/ctp-cart-custom-shipping-method.json' + 'test/unit/fixtures/ctp-cart-custom-shipping-method.json', ) }) @@ -56,40 +56,39 @@ describe('create-lineitems-session-request::execute', () => { ctpPaymentClone.custom.fields.commercetoolsProjectKey = commercetoolsProjectKey - const response = await createLineItemsSessionPaymentHandler.execute( - ctpPaymentClone - ) + const response = + await createLineItemsSessionPaymentHandler.execute(ctpPaymentClone) expect(response.actions).to.have.lengthOf(3) const createSessionRequestInteraction = JSON.parse( response.actions.find((a) => a.action === 'addInterfaceInteraction') - .fields.request + .fields.request, ) const createSessionRequestJson = JSON.parse( - createSessionRequestInteraction.body + createSessionRequestInteraction.body, ) const ctpLineItem = ctpCart.lineItems[0] const adyenLineItem = createSessionRequestJson.lineItems.find( - (item) => item.id === 'test-product-sku-1' + (item) => item.id === 'test-product-sku-1', ) expect(ctpLineItem.price.value.centAmount).to.equal( - adyenLineItem.amountIncludingTax + adyenLineItem.amountIncludingTax, ) expect(ctpLineItem.taxRate.amount * ADYEN_PERCENTAGE_MINOR_UNIT).to.equal( - adyenLineItem.taxPercentage + adyenLineItem.taxPercentage, ) const ctpShippingInfo = ctpCart.shippingInfo const adyenShippingInfo = createSessionRequestJson.lineItems.find( - (item) => item.id === ctpShippingInfo.shippingMethodName + (item) => item.id === ctpShippingInfo.shippingMethodName, ) expect(ctpShippingInfo.price.centAmount).to.equal( - adyenShippingInfo.amountIncludingTax + adyenShippingInfo.amountIncludingTax, ) expect( - ctpShippingInfo.taxRate.amount * ADYEN_PERCENTAGE_MINOR_UNIT + ctpShippingInfo.taxRate.amount * ADYEN_PERCENTAGE_MINOR_UNIT, ).to.equal(adyenShippingInfo.taxPercentage) - } + }, ) it( @@ -110,21 +109,20 @@ describe('create-lineitems-session-request::execute', () => { JSON.stringify(createSessionRequest) ctpPaymentClone.custom.fields.adyenMerchantAccount = adyenMerchantAccount - const response = await createLineItemsSessionPaymentHandler.execute( - ctpPaymentClone - ) + const response = + await createLineItemsSessionPaymentHandler.execute(ctpPaymentClone) expect(response.actions).to.have.lengthOf(3) const createSessionRequestInteraction = JSON.parse( response.actions.find((a) => a.action === 'addInterfaceInteraction') - .fields.request + .fields.request, ) const createSessionRequestJson = JSON.parse( - createSessionRequestInteraction.body + createSessionRequestInteraction.body, ) expect(createSessionRequestJson.lineItems).to.deep.equal( - createSessionRequest.lineItems + createSessionRequest.lineItems, ) - } + }, ) it( @@ -147,25 +145,24 @@ describe('create-lineitems-session-request::execute', () => { }, }, } - const response = await createLineItemsSessionPaymentHandler.execute( - ctpPaymentToTest - ) + const response = + await createLineItemsSessionPaymentHandler.execute(ctpPaymentToTest) const createSessionRequestInteraction = JSON.parse( response.actions.find((a) => a.action === 'addInterfaceInteraction') - .fields.request + .fields.request, ) const { lineItems } = JSON.parse(createSessionRequestInteraction.body) expect(lineItems).to.have.lengthOf(3) expect(lineItems[0].description).to.equal( - Object.values(ctpCart.lineItems[0].name)[0] + Object.values(ctpCart.lineItems[0].name)[0], ) expect(lineItems[1].description).to.equal( - ctpCart.customLineItems[0].name[DEFAULT_PAYMENT_LANGUAGE] + ctpCart.customLineItems[0].name[DEFAULT_PAYMENT_LANGUAGE], ) expect(lineItems[2].description).to.equal( - ctpCart.shippingInfo.shippingMethod.obj.description + ctpCart.shippingInfo.shippingMethod.obj.description, ) - } + }, ) it( @@ -191,18 +188,17 @@ describe('create-lineitems-session-request::execute', () => { }, } - const response = await createLineItemsSessionPaymentHandler.execute( - ctpPaymentToTest - ) + const response = + await createLineItemsSessionPaymentHandler.execute(ctpPaymentToTest) const createSessionRequestInteraction = JSON.parse( response.actions.find((a) => a.action === 'addInterfaceInteraction') - .fields.request + .fields.request, ) const { lineItems } = JSON.parse(createSessionRequestInteraction.body) expect(lineItems[2].description).to.equal( - ctpCart.shippingInfo.shippingMethodName + ctpCart.shippingInfo.shippingMethodName, ) - } + }, ) it( @@ -222,32 +218,31 @@ describe('create-lineitems-session-request::execute', () => { const ctpPaymentClone = _.cloneDeep(ctpPayment) ctpPaymentClone.custom.fields.createSessionRequest = JSON.stringify( - klarnacreateSessionRequest + klarnacreateSessionRequest, ) ctpPaymentClone.custom.fields.adyenMerchantAccount = adyenMerchantAccount ctpPaymentClone.custom.fields.commercetoolsProjectKey = commercetoolsProjectKey - const response = await createLineItemsSessionPaymentHandler.execute( - ctpPaymentClone - ) + const response = + await createLineItemsSessionPaymentHandler.execute(ctpPaymentClone) expect(response.actions).to.have.lengthOf(3) const createSessionRequestInteraction = JSON.parse( response.actions.find((a) => a.action === 'addInterfaceInteraction') - .fields.request + .fields.request, ) const { lineItems } = JSON.parse(createSessionRequestInteraction.body) const shippingMethodItem = lineItems[lineItems.length - 1] expect(shippingMethodItem.id).to.equal( - ctpCartWithCustomShippingMethod.shippingInfo.shippingMethodName + ctpCartWithCustomShippingMethod.shippingInfo.shippingMethodName, ) expect(shippingMethodItem.description).to.equal( - ctpCartWithCustomShippingMethod.shippingInfo.shippingMethodName + ctpCartWithCustomShippingMethod.shippingInfo.shippingMethodName, ) expect(shippingMethodItem.taxPercentage).to.equal( - ctpCartWithCustomShippingMethod.shippingInfo.taxRate.amount * 10000 + ctpCartWithCustomShippingMethod.shippingInfo.taxRate.amount * 10000, ) - } + }, ) it( @@ -267,32 +262,31 @@ describe('create-lineitems-session-request::execute', () => { const ctpPaymentClone = _.cloneDeep(ctpPayment) ctpPaymentClone.custom.fields.createSessionRequest = JSON.stringify( - affirmcreateSessionRequest + affirmcreateSessionRequest, ) ctpPaymentClone.custom.fields.adyenMerchantAccount = adyenMerchantAccount ctpPaymentClone.custom.fields.commercetoolsProjectKey = commercetoolsProjectKey - const response = await createLineItemsSessionPaymentHandler.execute( - ctpPaymentClone - ) + const response = + await createLineItemsSessionPaymentHandler.execute(ctpPaymentClone) expect(response.actions).to.have.lengthOf(3) const createSessionRequestInteraction = JSON.parse( response.actions.find((a) => a.action === 'addInterfaceInteraction') - .fields.request + .fields.request, ) const { lineItems } = JSON.parse(createSessionRequestInteraction.body) const shippingMethodItem = lineItems[lineItems.length - 1] expect(shippingMethodItem.id).to.equal( - ctpCartWithCustomShippingMethod.shippingInfo.shippingMethodName + ctpCartWithCustomShippingMethod.shippingInfo.shippingMethodName, ) expect(shippingMethodItem.description).to.equal( - ctpCartWithCustomShippingMethod.shippingInfo.shippingMethodName + ctpCartWithCustomShippingMethod.shippingInfo.shippingMethodName, ) expect(shippingMethodItem.taxPercentage).to.equal( - ctpCartWithCustomShippingMethod.shippingInfo.taxRate.amount * 10000 + ctpCartWithCustomShippingMethod.shippingInfo.taxRate.amount * 10000, ) - } + }, ) it('when payment has languageCode, it should take precedence', async () => { @@ -317,12 +311,11 @@ describe('create-lineitems-session-request::execute', () => { }, }, } - const response = await createLineItemsSessionPaymentHandler.execute( - ctpPaymentToTest - ) + const response = + await createLineItemsSessionPaymentHandler.execute(ctpPaymentToTest) const createSessionRequestInteraction = JSON.parse( response.actions.find((a) => a.action === 'addInterfaceInteraction') - .fields.request + .fields.request, ) const { lineItems } = JSON.parse(createSessionRequestInteraction.body) expect(lineItems[0].description).to.equal('test-de') @@ -355,16 +348,15 @@ describe('create-lineitems-session-request::execute', () => { }, }, } - const response = await createLineItemsSessionPaymentHandler.execute( - ctpPaymentToTest - ) + const response = + await createLineItemsSessionPaymentHandler.execute(ctpPaymentToTest) const createSessionRequestInteraction = JSON.parse( response.actions.find((a) => a.action === 'addInterfaceInteraction') - .fields.request + .fields.request, ) const { lineItems } = JSON.parse(createSessionRequestInteraction.body) expect(lineItems[0].description).to.equal('test-fr') - } + }, ) it( @@ -393,16 +385,15 @@ describe('create-lineitems-session-request::execute', () => { }, }, } - const response = await createLineItemsSessionPaymentHandler.execute( - ctpPaymentToTest - ) + const response = + await createLineItemsSessionPaymentHandler.execute(ctpPaymentToTest) const createSessionRequestInteraction = JSON.parse( response.actions.find((a) => a.action === 'addInterfaceInteraction') - .fields.request + .fields.request, ) const { lineItems } = JSON.parse(createSessionRequestInteraction.body) expect(lineItems[0].description).to.equal('test-de') - } + }, ) function _mockCtpCartsEndpoint(mockCart = ctpCart) { diff --git a/extension/test/unit/create-session-request.handler.spec.js b/extension/test/unit/create-session-request.handler.spec.js index 378a1e5a8..6273d5f85 100644 --- a/extension/test/unit/create-session-request.handler.spec.js +++ b/extension/test/unit/create-session-request.handler.spec.js @@ -37,7 +37,7 @@ describe('create-session-request::execute::', () => { } const adyenCredentials = config.getAdyenConfig( - paymentObject.custom.fields.adyenMerchantAccount + paymentObject.custom.fields.adyenMerchantAccount, ) afterEach(() => { @@ -70,16 +70,16 @@ describe('create-session-request::execute::', () => { const request = JSON.parse(result.actions[0].fields.request) expect(JSON.parse(request.body)).to.be.deep.includes(getSessionRequest) expect(result.actions[0].fields.response).to.be.deep.equal( - JSON.stringify(adyenGetSessionResponse) + JSON.stringify(adyenGetSessionResponse), ) expect(result.actions[0].fields.response).to.be.deep.equal( - result.actions[1].value + result.actions[1].value, ) expect(result.actions[0].fields.type).to.equal( - c.CTP_INTERACTION_TYPE_CREATE_SESSION + c.CTP_INTERACTION_TYPE_CREATE_SESSION, ) expect(result.actions[1].name).to.equal( - c.CTP_INTERACTION_TYPE_CREATE_SESSION_RESPONSE + c.CTP_INTERACTION_TYPE_CREATE_SESSION_RESPONSE, ) }) @@ -103,11 +103,11 @@ describe('create-session-request::execute::', () => { expect(JSON.parse(request.body)).to.be.deep.includes(getSessionRequest) expect(result.actions[0].fields.response).to.be.includes(errorMsg) expect(result.actions[0].fields.type).to.equal( - c.CTP_INTERACTION_TYPE_CREATE_SESSION + c.CTP_INTERACTION_TYPE_CREATE_SESSION, ) expect(result.actions[1].name).to.equal( - c.CTP_INTERACTION_TYPE_CREATE_SESSION_RESPONSE + c.CTP_INTERACTION_TYPE_CREATE_SESSION_RESPONSE, ) - } + }, ) }) diff --git a/extension/test/unit/create-session-with-splits.handler.spec.js b/extension/test/unit/create-session-with-splits.handler.spec.js index 959b7b55f..9bec62ae4 100644 --- a/extension/test/unit/create-session-with-splits.handler.spec.js +++ b/extension/test/unit/create-session-with-splits.handler.spec.js @@ -83,7 +83,7 @@ describe('create-session-with-splits::execute', () => { expect(response.actions).to.have.lengthOf(3) const addInterfaceInteraction = response.actions.find( - (a) => a.action === 'addInterfaceInteraction' + (a) => a.action === 'addInterfaceInteraction', ) expect(addInterfaceInteraction.fields.type).to.equal('createSession') expect(addInterfaceInteraction.fields.request).to.be.a('string') @@ -93,33 +93,33 @@ describe('create-session-with-splits::execute', () => { const request = JSON.parse(addInterfaceInteraction.fields.request) const requestBody = JSON.parse(request.body) expect(requestBody.reference).to.deep.equal( - createSessiontWithSplitsRequest.reference + createSessiontWithSplitsRequest.reference, ) expect(requestBody.riskData).to.deep.equal( - createSessiontWithSplitsRequest.riskData + createSessiontWithSplitsRequest.riskData, ) expect(requestBody.browserInfo).to.deep.equal( - createSessiontWithSplitsRequest.browserInfo + createSessiontWithSplitsRequest.browserInfo, ) expect(requestBody.amount).to.deep.equal( - createSessiontWithSplitsRequest.amount + createSessiontWithSplitsRequest.amount, ) expect(requestBody.merchantAccount).to.equal(adyenMerchantAccount) const setCustomFieldAction = response.actions.find( - (a) => a.action === 'setCustomField' + (a) => a.action === 'setCustomField', ) expect(setCustomFieldAction.name).to.equal('createSessionResponse') expect(setCustomFieldAction.value).to.be.a('string') expect(setCustomFieldAction.value).to.equal( - addInterfaceInteraction.fields.response + addInterfaceInteraction.fields.response, ) const setKeyAction = response.actions.find((a) => a.action === 'setKey') expect(setKeyAction.key).to.equal( - createSessiontWithSplitsRequest.reference + createSessiontWithSplitsRequest.reference, ) - } + }, ) }) diff --git a/extension/test/unit/get-carbon-offset-costs.handler.spec.js b/extension/test/unit/get-carbon-offset-costs.handler.spec.js index 0b7cdf1c7..f8280a5f1 100644 --- a/extension/test/unit/get-carbon-offset-costs.handler.spec.js +++ b/extension/test/unit/get-carbon-offset-costs.handler.spec.js @@ -32,7 +32,7 @@ describe('get-carbon-offset-costs::execute::', () => { fields: { commercetoolsProjectKey: 'commercetoolsProjectKey', getCarbonOffsetCostsRequest: JSON.stringify( - getCarbonOffsetCostsRequest + getCarbonOffsetCostsRequest, ), adyenMerchantAccount, }, @@ -66,16 +66,16 @@ describe('get-carbon-offset-costs::execute::', () => { expect(result.actions[1].action).to.equal('setCustomField') const request = JSON.parse(result.actions[0].fields.request) expect(JSON.parse(request.body)).to.be.deep.includes( - getCarbonOffsetCostsRequest + getCarbonOffsetCostsRequest, ) expect(result.actions[0].fields.response).to.be.deep.equal( - getCarbonOffsetCostsResponse + getCarbonOffsetCostsResponse, ) expect(result.actions[0].fields.response).to.be.deep.equal( - result.actions[1].value + result.actions[1].value, ) expect(result.actions[0].fields.type).to.equal( - c.CTP_INTERACTION_TYPE_GET_CARBON_OFFSET_COSTS + c.CTP_INTERACTION_TYPE_GET_CARBON_OFFSET_COSTS, ) expect(result.actions[1].name).to.equal(c.CTP_CARBON_OFFSET_COSTS_RESPONSE) }) @@ -101,17 +101,17 @@ describe('get-carbon-offset-costs::execute::', () => { expect(result.actions[1].action).to.equal('setCustomField') const request = JSON.parse(result.actions[0].fields.request) expect(JSON.parse(request.body)).to.be.deep.includes( - getCarbonOffsetCostsRequest + getCarbonOffsetCostsRequest, ) expect(result.actions[0].fields.response).to.equal( - getCarbonOffsetCostsFailedResponse + getCarbonOffsetCostsFailedResponse, ) expect(result.actions[0].fields.type).to.equal( - c.CTP_INTERACTION_TYPE_GET_CARBON_OFFSET_COSTS + c.CTP_INTERACTION_TYPE_GET_CARBON_OFFSET_COSTS, ) expect(result.actions[1].name).to.equal( - c.CTP_CARBON_OFFSET_COSTS_RESPONSE + c.CTP_CARBON_OFFSET_COSTS_RESPONSE, ) - } + }, ) }) diff --git a/extension/test/unit/get-payment-methods.handler.spec.js b/extension/test/unit/get-payment-methods.handler.spec.js index d9ccae7cc..fcc089ced 100644 --- a/extension/test/unit/get-payment-methods.handler.spec.js +++ b/extension/test/unit/get-payment-methods.handler.spec.js @@ -37,7 +37,7 @@ describe('get-payment-methods::execute::', () => { } const adyenCredentials = config.getAdyenConfig( - paymentObject.custom.fields.adyenMerchantAccount + paymentObject.custom.fields.adyenMerchantAccount, ) afterEach(() => { @@ -69,19 +69,19 @@ describe('get-payment-methods::execute::', () => { expect(result.actions[1].action).to.equal('setCustomField') const request = JSON.parse(result.actions[0].fields.request) expect(JSON.parse(request.body)).to.be.deep.includes( - getPaymentMethodsRequest + getPaymentMethodsRequest, ) expect(result.actions[0].fields.response).to.be.deep.equal( - JSON.stringify(adyenGetPaymentResponse) + JSON.stringify(adyenGetPaymentResponse), ) expect(result.actions[0].fields.response).to.be.deep.equal( - result.actions[1].value + result.actions[1].value, ) expect(result.actions[0].fields.type).to.equal( - c.CTP_INTERACTION_TYPE_GET_PAYMENT_METHODS + c.CTP_INTERACTION_TYPE_GET_PAYMENT_METHODS, ) expect(result.actions[1].name).to.equal( - c.CTP_CUSTOM_FIELD_GET_PAYMENT_METHODS_RESPONSE + c.CTP_CUSTOM_FIELD_GET_PAYMENT_METHODS_RESPONSE, ) }) @@ -103,15 +103,15 @@ describe('get-payment-methods::execute::', () => { expect(result.actions[1].action).to.equal('setCustomField') const request = JSON.parse(result.actions[0].fields.request) expect(JSON.parse(request.body)).to.be.deep.includes( - getPaymentMethodsRequest + getPaymentMethodsRequest, ) expect(result.actions[0].fields.response).to.be.includes(errorMsg) expect(result.actions[0].fields.type).to.equal( - c.CTP_INTERACTION_TYPE_GET_PAYMENT_METHODS + c.CTP_INTERACTION_TYPE_GET_PAYMENT_METHODS, ) expect(result.actions[1].name).to.equal( - c.CTP_CUSTOM_FIELD_GET_PAYMENT_METHODS_RESPONSE + c.CTP_CUSTOM_FIELD_GET_PAYMENT_METHODS_RESPONSE, ) - } + }, ) }) diff --git a/extension/test/unit/make-payment.handler.spec.js b/extension/test/unit/make-payment.handler.spec.js index 4ea7415c7..03ebcefaf 100644 --- a/extension/test/unit/make-payment.handler.spec.js +++ b/extension/test/unit/make-payment.handler.spec.js @@ -55,7 +55,7 @@ describe('make-payment::execute', () => { before(async () => { ctpPayment = await utils.readAndParseJsonFile( - 'test/unit/fixtures/ctp-payment-make-payment.json' + 'test/unit/fixtures/ctp-payment-make-payment.json', ) }) @@ -84,17 +84,17 @@ describe('make-payment::execute', () => { expect(response.actions).to.have.lengthOf(6) const setMethodInfoMethod = response.actions.find( - (a) => a.action === 'setMethodInfoMethod' + (a) => a.action === 'setMethodInfoMethod', ) expect(setMethodInfoMethod.method).to.equal('scheme') const setMethodInfoName = response.actions.find( - (a) => a.action === 'setMethodInfoName' + (a) => a.action === 'setMethodInfoName', ) expect(setMethodInfoName.name).to.eql({ en: 'Credit Card' }) const addInterfaceInteraction = response.actions.find( - (a) => a.action === 'addInterfaceInteraction' + (a) => a.action === 'addInterfaceInteraction', ) expect(addInterfaceInteraction.fields.type).to.equal('makePayment') expect(addInterfaceInteraction.fields.request).to.be.a('string') @@ -106,38 +106,38 @@ describe('make-payment::execute', () => { expect(requestBody.reference).to.deep.equal(makePaymentRequest.reference) expect(requestBody.riskData).to.deep.equal(makePaymentRequest.riskData) expect(requestBody.paymentMethod).to.deep.equal( - makePaymentRequest.paymentMethod + makePaymentRequest.paymentMethod, ) expect(requestBody.browserInfo).to.deep.equal( - makePaymentRequest.browserInfo + makePaymentRequest.browserInfo, ) expect(requestBody.amount).to.deep.equal(makePaymentRequest.amount) expect(requestBody.merchantAccount).to.equal(adyenMerchantAccount) const setCustomFieldAction = response.actions.find( - (a) => a.action === 'setCustomField' + (a) => a.action === 'setCustomField', ) expect(setCustomFieldAction.name).to.equal('makePaymentResponse') expect(setCustomFieldAction.value).to.be.a('string') expect(setCustomFieldAction.value).to.equal( - addInterfaceInteraction.fields.response + addInterfaceInteraction.fields.response, ) const setKeyAction = response.actions.find((a) => a.action === 'setKey') expect(setKeyAction.key).to.equal( - JSON.parse(paymentSuccessResponse).pspReference + JSON.parse(paymentSuccessResponse).pspReference, ) const addTransaction = response.actions.find( - (a) => a.action === 'addTransaction' + (a) => a.action === 'addTransaction', ) expect(addTransaction.transaction).to.be.a('object') expect(addTransaction.transaction.type).to.equal('Authorization') expect(addTransaction.transaction.state).to.equal('Success') expect(addTransaction.transaction.interactionId).to.equal( - JSON.parse(paymentSuccessResponse).pspReference + JSON.parse(paymentSuccessResponse).pspReference, ) - } + }, ) it( @@ -156,7 +156,7 @@ describe('make-payment::execute', () => { expect(response.actions).to.have.lengthOf(5) const addInterfaceInteraction = response.actions.find( - (a) => a.action === 'addInterfaceInteraction' + (a) => a.action === 'addInterfaceInteraction', ) expect(addInterfaceInteraction.fields.type).to.equal('makePayment') expect(addInterfaceInteraction.fields.request).to.be.a('string') @@ -168,26 +168,26 @@ describe('make-payment::execute', () => { expect(requestBody.reference).to.deep.equal(makePaymentRequest.reference) expect(requestBody.riskData).to.deep.equal(makePaymentRequest.riskData) expect(requestBody.paymentMethod).to.deep.equal( - makePaymentRequest.paymentMethod + makePaymentRequest.paymentMethod, ) expect(requestBody.browserInfo).to.deep.equal( - makePaymentRequest.browserInfo + makePaymentRequest.browserInfo, ) expect(requestBody.amount).to.deep.equal(makePaymentRequest.amount) expect(requestBody.merchantAccount).to.equal(adyenMerchantAccount) const setCustomFieldAction = response.actions.find( - (a) => a.action === 'setCustomField' + (a) => a.action === 'setCustomField', ) expect(setCustomFieldAction.name).to.equal('makePaymentResponse') expect(setCustomFieldAction.value).to.be.a('string') expect(setCustomFieldAction.value).to.equal( - addInterfaceInteraction.fields.response + addInterfaceInteraction.fields.response, ) const setKeyAction = response.actions.find((a) => a.action === 'setKey') expect(setKeyAction.key).to.equal(makePaymentRequest.reference) // no pspReference until submitting additional details in redirect flow - } + }, ) it( @@ -206,7 +206,7 @@ describe('make-payment::execute', () => { expect(response.actions).to.have.lengthOf(5) const addInterfaceInteraction = response.actions.find( - (a) => a.action === 'addInterfaceInteraction' + (a) => a.action === 'addInterfaceInteraction', ) expect(addInterfaceInteraction.fields.type).to.equal('makePayment') expect(addInterfaceInteraction.fields.request).to.be.a('string') @@ -218,26 +218,26 @@ describe('make-payment::execute', () => { expect(requestBody.reference).to.deep.equal(makePaymentRequest.reference) expect(requestBody.riskData).to.deep.equal(makePaymentRequest.riskData) expect(requestBody.paymentMethod).to.deep.equal( - makePaymentRequest.paymentMethod + makePaymentRequest.paymentMethod, ) expect(requestBody.browserInfo).to.deep.equal( - makePaymentRequest.browserInfo + makePaymentRequest.browserInfo, ) expect(requestBody.amount).to.deep.equal(makePaymentRequest.amount) expect(requestBody.merchantAccount).to.equal(adyenMerchantAccount) const setCustomFieldAction = response.actions.find( - (a) => a.action === 'setCustomField' + (a) => a.action === 'setCustomField', ) expect(setCustomFieldAction.name).to.equal('makePaymentResponse') expect(setCustomFieldAction.value).to.be.a('string') expect(setCustomFieldAction.value).to.equal( - addInterfaceInteraction.fields.response + addInterfaceInteraction.fields.response, ) const setKeyAction = response.actions.find((a) => a.action === 'setKey') expect(setKeyAction.key).to.equal(makePaymentRequest.reference) - } + }, ) it( @@ -257,7 +257,7 @@ describe('make-payment::execute', () => { expect(response.actions).to.have.lengthOf(6) const addInterfaceInteraction = response.actions.find( - (a) => a.action === 'addInterfaceInteraction' + (a) => a.action === 'addInterfaceInteraction', ) expect(addInterfaceInteraction.fields.type).to.equal('makePayment') expect(addInterfaceInteraction.fields.request).to.be.a('string') @@ -269,38 +269,38 @@ describe('make-payment::execute', () => { expect(requestBody.reference).to.deep.equal(makePaymentRequest.reference) expect(requestBody.riskData).to.deep.equal(makePaymentRequest.riskData) expect(requestBody.paymentMethod).to.deep.equal( - makePaymentRequest.paymentMethod + makePaymentRequest.paymentMethod, ) expect(requestBody.browserInfo).to.deep.equal( - makePaymentRequest.browserInfo + makePaymentRequest.browserInfo, ) expect(requestBody.amount).to.deep.equal(makePaymentRequest.amount) expect(requestBody.merchantAccount).to.equal(adyenMerchantAccount) const setCustomFieldAction = response.actions.find( - (a) => a.action === 'setCustomField' + (a) => a.action === 'setCustomField', ) expect(setCustomFieldAction.name).to.equal('makePaymentResponse') expect(setCustomFieldAction.value).to.be.a('string') expect(setCustomFieldAction.value).to.equal( - addInterfaceInteraction.fields.response + addInterfaceInteraction.fields.response, ) const setKeyAction = response.actions.find((a) => a.action === 'setKey') expect(setKeyAction.key).to.equal( - JSON.parse(paymentRefusedResponse).pspReference + JSON.parse(paymentRefusedResponse).pspReference, ) const addTransaction = response.actions.find( - (a) => a.action === 'addTransaction' + (a) => a.action === 'addTransaction', ) expect(addTransaction.transaction).to.be.a('object') expect(addTransaction.transaction.type).to.equal('Authorization') expect(addTransaction.transaction.state).to.equal('Failure') expect(addTransaction.transaction.interactionId).to.equal( - JSON.parse(paymentRefusedResponse).pspReference + JSON.parse(paymentRefusedResponse).pspReference, ) - } + }, ) it( @@ -320,7 +320,7 @@ describe('make-payment::execute', () => { expect(response.actions).to.have.lengthOf(6) const addInterfaceInteraction = response.actions.find( - (a) => a.action === 'addInterfaceInteraction' + (a) => a.action === 'addInterfaceInteraction', ) expect(addInterfaceInteraction.fields.type).to.equal('makePayment') expect(addInterfaceInteraction.fields.request).to.be.a('string') @@ -332,38 +332,38 @@ describe('make-payment::execute', () => { expect(requestBody.reference).to.deep.equal(makePaymentRequest.reference) expect(requestBody.riskData).to.deep.equal(makePaymentRequest.riskData) expect(requestBody.paymentMethod).to.deep.equal( - makePaymentRequest.paymentMethod + makePaymentRequest.paymentMethod, ) expect(requestBody.browserInfo).to.deep.equal( - makePaymentRequest.browserInfo + makePaymentRequest.browserInfo, ) expect(requestBody.amount).to.deep.equal(makePaymentRequest.amount) expect(requestBody.merchantAccount).to.equal(adyenMerchantAccount) const setCustomFieldAction = response.actions.find( - (a) => a.action === 'setCustomField' + (a) => a.action === 'setCustomField', ) expect(setCustomFieldAction.name).to.equal('makePaymentResponse') expect(setCustomFieldAction.value).to.be.a('string') expect(setCustomFieldAction.value).to.equal( - addInterfaceInteraction.fields.response + addInterfaceInteraction.fields.response, ) const setKeyAction = response.actions.find((a) => a.action === 'setKey') expect(setKeyAction.key).to.equal( - JSON.parse(paymentErrorResponse).pspReference + JSON.parse(paymentErrorResponse).pspReference, ) const addTransaction = response.actions.find( - (a) => a.action === 'addTransaction' + (a) => a.action === 'addTransaction', ) expect(addTransaction.transaction).to.be.a('object') expect(addTransaction.transaction.type).to.equal('Authorization') expect(addTransaction.transaction.state).to.equal('Failure') expect(addTransaction.transaction.interactionId).to.equal( - JSON.parse(paymentErrorResponse).pspReference + JSON.parse(paymentErrorResponse).pspReference, ) - } + }, ) it( @@ -376,22 +376,22 @@ describe('make-payment::execute', () => { const makePaymentRequestClone = _.cloneDeep(makePaymentRequest) makePaymentRequestClone.paymentMethod.type = 'new payment method' ctpPaymentClone.custom.fields.makePaymentRequest = JSON.stringify( - makePaymentRequestClone + makePaymentRequestClone, ) ctpPaymentClone.custom.fields.adyenMerchantAccount = adyenMerchantAccount const response = await execute(ctpPaymentClone) const setMethodInfoMethod = response.actions.find( - (a) => a.action === 'setMethodInfoMethod' + (a) => a.action === 'setMethodInfoMethod', ) expect(setMethodInfoMethod.method).to.equal('new payment method') const setMethodInfoName = response.actions.find( - (a) => a.action === 'setMethodInfoName' + (a) => a.action === 'setMethodInfoName', ) expect(setMethodInfoName).to.be.undefined - } + }, ) it( @@ -404,16 +404,16 @@ describe('make-payment::execute', () => { const makePaymentRequestClone = _.cloneDeep(makePaymentRequest) delete makePaymentRequestClone.paymentMethod.type ctpPaymentClone.custom.fields.makePaymentRequest = JSON.stringify( - makePaymentRequestClone + makePaymentRequestClone, ) ctpPaymentClone.custom.fields.adyenMerchantAccount = adyenMerchantAccount const response = await execute(ctpPaymentClone) const setMethodInfoMethod = response.actions.find( - (a) => a.action === 'setMethodInfoMethod' + (a) => a.action === 'setMethodInfoMethod', ) expect(setMethodInfoMethod).to.be.undefined - } + }, ) }) diff --git a/extension/test/unit/manual-capture.handler.spec.js b/extension/test/unit/manual-capture.handler.spec.js index bcfde4148..10cbfba5c 100644 --- a/extension/test/unit/manual-capture.handler.spec.js +++ b/extension/test/unit/manual-capture.handler.spec.js @@ -91,19 +91,19 @@ describe('manual-capture.handler::execute::', () => { expect(actions).to.have.lengthOf(3) const addInterfaceInteraction = actions.find( - (a) => a.action === 'addInterfaceInteraction' + (a) => a.action === 'addInterfaceInteraction', ) expect(addInterfaceInteraction.fields.type).to.equal( - CTP_INTERACTION_TYPE_MANUAL_CAPTURE + CTP_INTERACTION_TYPE_MANUAL_CAPTURE, ) expect(addInterfaceInteraction.fields.request).to.be.a('string') expect(addInterfaceInteraction.fields.response).to.equal( - JSON.stringify(manualCaptureResponse) + JSON.stringify(manualCaptureResponse), ) expect(addInterfaceInteraction.fields.createdAt).to.be.a('string') const changeTransactionState = actions.find( - (a) => a.action === 'changeTransactionState' + (a) => a.action === 'changeTransactionState', ) expect(changeTransactionState).to.be.deep.equal({ transactionId: 'chargeInitialTransactionId', @@ -112,14 +112,14 @@ describe('manual-capture.handler::execute::', () => { }) const changeTransactionInteractionId = actions.find( - (a) => a.action === 'changeTransactionInteractionId' + (a) => a.action === 'changeTransactionInteractionId', ) expect(changeTransactionInteractionId).to.be.deep.equal({ transactionId: 'chargeInitialTransactionId', action: 'changeTransactionInteractionId', interactionId: '8825408195409505', }) - } + }, ) it( @@ -143,20 +143,20 @@ describe('manual-capture.handler::execute::', () => { expect(actions).to.have.lengthOf(1) const addInterfaceInteraction = actions.find( - (a) => a.action === 'addInterfaceInteraction' + (a) => a.action === 'addInterfaceInteraction', ) expect(addInterfaceInteraction.fields.type).to.equal( - CTP_INTERACTION_TYPE_MANUAL_CAPTURE + CTP_INTERACTION_TYPE_MANUAL_CAPTURE, ) expect(addInterfaceInteraction.fields.request).to.be.a('string') expect(addInterfaceInteraction.fields.response).to.equal( - JSON.stringify(validationError) + JSON.stringify(validationError), ) expect(addInterfaceInteraction.fields.createdAt).to.be.a('string') const addTransaction = actions.find((a) => a.action === 'addTransaction') expect(addTransaction).to.equal(undefined) - } + }, ) it( @@ -172,15 +172,15 @@ describe('manual-capture.handler::execute::', () => { const { actions } = await manualCaptureHandler.execute(paymentObject) const adyenRequest = actions.find( - (action) => action.action === 'addInterfaceInteraction' + (action) => action.action === 'addInterfaceInteraction', ).fields.request const adyenRequestJson = JSON.parse(adyenRequest) const requestBody = JSON.parse(adyenRequestJson.body) expect(requestBody.reference).to.equal( - chargeInitialTransaction.custom.fields.reference + chargeInitialTransaction.custom.fields.reference, ) - } + }, ) it( @@ -199,12 +199,12 @@ describe('manual-capture.handler::execute::', () => { const { actions } = await manualCaptureHandler.execute(paymentObject) const addInterfaceInteraction = actions.find( - (a) => a.action === 'addInterfaceInteraction' + (a) => a.action === 'addInterfaceInteraction', ) const requestJson = JSON.parse(addInterfaceInteraction.fields.request) expect(requestJson.headers['Idempotency-Key']).to.equal( - chargeInitialTransaction.id + chargeInitialTransaction.id, ) - } + }, ) }) diff --git a/extension/test/unit/multitenancy.spec.js b/extension/test/unit/multitenancy.spec.js index 847181c74..da63d13c9 100644 --- a/extension/test/unit/multitenancy.spec.js +++ b/extension/test/unit/multitenancy.spec.js @@ -17,10 +17,10 @@ describe('::Multitenancy::', () => { before(async () => { ctpPayment = await utils.readAndParseJsonFile( - 'test/unit/fixtures/ctp-payment.json' + 'test/unit/fixtures/ctp-payment.json', ) ctpCart = await utils.readAndParseJsonFile( - 'test/unit/fixtures/ctp-cart.json' + 'test/unit/fixtures/ctp-cart.json', ) }) @@ -46,17 +46,16 @@ describe('::Multitenancy::', () => { ctpPaymentClone.custom.fields.adyenMerchantAccount = adyenMerchantAccount ctpPaymentClone.custom.fields.commercetoolsProjectKey = ctpProjectKey - const response = await lineItemsSessionRequestHandler.execute( - ctpPaymentClone - ) + const response = + await lineItemsSessionRequestHandler.execute(ctpPaymentClone) const adyenRequest = JSON.parse( response.actions.find((a) => a.action === 'addInterfaceInteraction') - .fields.request + .fields.request, ) const adyenRequestBody = JSON.parse(adyenRequest.body) expect(adyenRequestBody.merchantAccount).to.equal(adyenMerchantAccount) expect(ctpApiScope.isDone()).to.be.true - } + }, ) function _mockCtpCartsEndpoint(mockCart = ctpCart) { diff --git a/extension/test/unit/payment-handler-authorization.spec.js b/extension/test/unit/payment-handler-authorization.spec.js index 469bcf145..b90a8d477 100644 --- a/extension/test/unit/payment-handler-authorization.spec.js +++ b/extension/test/unit/payment-handler-authorization.spec.js @@ -54,7 +54,7 @@ describe('payment-handler-authorization::execute', () => { } before(async () => { ctpPayment = await utils.readAndParseJsonFile( - 'test/unit/fixtures/ctp-payment.json' + 'test/unit/fixtures/ctp-payment.json', ) }) @@ -83,11 +83,11 @@ describe('payment-handler-authorization::execute', () => { sandbox.stub(config, 'getCtpConfig').returns(dummyCtpConfig) const response = await handlePayment( ctpPaymentClone, - 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==' + 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==', ) expect(response.actions).to.have.lengthOf.above(0) sandbox.restore() - } + }, ) it( @@ -109,10 +109,10 @@ describe('payment-handler-authorization::execute', () => { expect(response.errors).to.have.lengthOf(1) expect(response.errors[0].message).to.equal( - errorMessage.UNAUTHORIZED_REQUEST + errorMessage.UNAUTHORIZED_REQUEST, ) sandbox.restore() - } + }, ) it( @@ -134,10 +134,10 @@ describe('payment-handler-authorization::execute', () => { expect(response.errors).to.have.lengthOf(1) expect(response.errors[0].message).to.equal( - errorMessage.UNAUTHORIZED_REQUEST + errorMessage.UNAUTHORIZED_REQUEST, ) sandbox.restore() - } + }, ) it( @@ -157,7 +157,7 @@ describe('payment-handler-authorization::execute', () => { await handlePayment(ctpPaymentClone, 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==') sandbox.restore() - } + }, ) it( @@ -174,6 +174,6 @@ describe('payment-handler-authorization::execute', () => { const response = await handlePayment(ctpPaymentClone, 'Basic xxxyyyzzz') expect(response.actions).to.have.lengthOf.above(0) - } + }, ) }) diff --git a/extension/test/unit/payment-handler-lineItems.spec.js b/extension/test/unit/payment-handler-lineItems.spec.js index d9cd2130d..811b12d8d 100644 --- a/extension/test/unit/payment-handler-lineItems.spec.js +++ b/extension/test/unit/payment-handler-lineItems.spec.js @@ -21,10 +21,10 @@ describe('payment-handler-lineItems::execute', () => { before(async () => { ctpPayment = await utils.readAndParseJsonFile( - 'test/unit/fixtures/ctp-payment.json' + 'test/unit/fixtures/ctp-payment.json', ) ctpCart = await utils.readAndParseJsonFile( - 'test/unit/fixtures/ctp-cart.json' + 'test/unit/fixtures/ctp-cart.json', ) }) @@ -69,13 +69,13 @@ describe('payment-handler-lineItems::execute', () => { const response = await handlePayment(ctpPaymentClone) const createSessionRequestInteraction = JSON.parse( response.actions.find((a) => a.action === 'addInterfaceInteraction') - .fields.request + .fields.request, ) const createSessionRequestJson = JSON.parse( - createSessionRequestInteraction.body + createSessionRequestInteraction.body, ) expect(createSessionRequestJson.lineItems).to.have.lengthOf(3) - } + }, ) it( @@ -106,13 +106,13 @@ describe('payment-handler-lineItems::execute', () => { const createSessionRequestInteraction = JSON.parse( response.actions.find((a) => a.action === 'addInterfaceInteraction') - .fields.request + .fields.request, ) const createSessionRequestJson = JSON.parse( - createSessionRequestInteraction.body + createSessionRequestInteraction.body, ) expect(createSessionRequestJson.lineItems).to.have.lengthOf(3) - } + }, ) it( @@ -142,13 +142,13 @@ describe('payment-handler-lineItems::execute', () => { const response = await paymentHandler.handlePayment(ctpPaymentClone) const createSessionRequestInteraction = JSON.parse( response.actions.find((a) => a.action === 'addInterfaceInteraction') - .fields.request + .fields.request, ) const createSessionRequestJson = JSON.parse( - createSessionRequestInteraction.body + createSessionRequestInteraction.body, ) expect(createSessionRequestJson.lineItems).to.undefined - } + }, ) it( @@ -177,13 +177,13 @@ describe('payment-handler-lineItems::execute', () => { const response = await handlePayment(ctpPaymentClone) const createSessionRequestInteraction = JSON.parse( response.actions.find((a) => a.action === 'addInterfaceInteraction') - .fields.request + .fields.request, ) const createSessionRequestJson = JSON.parse( - createSessionRequestInteraction.body + createSessionRequestInteraction.body, ) expect(createSessionRequestJson.lineItems).to.have.lengthOf(3) - } + }, ) function _mockCtpCartsEndpoint(mockCart = ctpCart) { diff --git a/extension/test/unit/payment-handler.spec.js b/extension/test/unit/payment-handler.spec.js index 29f950cda..af862b48b 100644 --- a/extension/test/unit/payment-handler.spec.js +++ b/extension/test/unit/payment-handler.spec.js @@ -15,7 +15,7 @@ describe('payment-handler::execute', () => { before(async () => { ctpPayment = await utils.readAndParseJsonFile( - 'test/unit/fixtures/ctp-payment.json' + 'test/unit/fixtures/ctp-payment.json', ) }) @@ -33,12 +33,12 @@ describe('payment-handler::execute', () => { expect(response.errors).to.have.lengthOf(2) expect(response.errors[0].message).to.equal( - errorMessage.MISSING_REQUIRED_FIELDS_CTP_PROJECT_KEY + errorMessage.MISSING_REQUIRED_FIELDS_CTP_PROJECT_KEY, ) expect(response.errors[1].message).to.equal( - errorMessage.MISSING_REQUIRED_FIELDS_ADYEN_MERCHANT_ACCOUNT + errorMessage.MISSING_REQUIRED_FIELDS_ADYEN_MERCHANT_ACCOUNT, ) - } + }, ) describe('amountPlanned', () => { @@ -64,9 +64,9 @@ describe('payment-handler::execute', () => { expect(response.errors).to.have.lengthOf.above(0) expect(response.errors[0].message).to.equal( - errorMessage.CREATE_SESSION_AMOUNT_PLANNED_NOT_SAME + errorMessage.CREATE_SESSION_AMOUNT_PLANNED_NOT_SAME, ) - } + }, ) it( @@ -84,7 +84,7 @@ describe('payment-handler::execute', () => { const response = await paymentHandler.handlePayment(ctpPaymentClone) expect(response.actions).to.deep.equal([]) - } + }, ) it('is different than create session interface interaction, then it should return errors', async () => { @@ -119,7 +119,7 @@ describe('payment-handler::execute', () => { const response = await paymentHandler.handlePayment(ctpPaymentClone) expect(response.errors[0].message).to.equal( - errorMessage.CREATE_SESSION_AMOUNT_PLANNED_NOT_SAME + errorMessage.CREATE_SESSION_AMOUNT_PLANNED_NOT_SAME, ) }) }) diff --git a/extension/test/unit/payment.controller.spec.js b/extension/test/unit/payment.controller.spec.js index 45de882b0..577958a49 100644 --- a/extension/test/unit/payment.controller.spec.js +++ b/extension/test/unit/payment.controller.spec.js @@ -10,7 +10,7 @@ describe('Payment controller', () => { beforeEach(async () => { ctpPayment = await utils.readAndParseJsonFile( - 'test/unit/fixtures/ctp-payment.json' + 'test/unit/fixtures/ctp-payment.json', ) }) @@ -84,7 +84,7 @@ describe('Payment controller', () => { expect(data.errors[0].code).to.equal('General') expect(data.errors[0].message).to.equal( '[commercetools-adyen-integration-extension] ' + - 'Unexpected error (Payment ID: undefined): request.on is not a function.' + 'Unexpected error (Payment ID: undefined): request.on is not a function.', ) } diff --git a/extension/test/unit/refund-payment.handler.spec.js b/extension/test/unit/refund-payment.handler.spec.js index 6b907a7b5..25b5335a5 100644 --- a/extension/test/unit/refund-payment.handler.spec.js +++ b/extension/test/unit/refund-payment.handler.spec.js @@ -38,7 +38,7 @@ describe('refund-payment::execute', () => { before(async () => { ctpPayment = await utils.readAndParseJsonFile( - 'test/unit/fixtures/ctp-payment.json' + 'test/unit/fixtures/ctp-payment.json', ) }) @@ -60,13 +60,13 @@ describe('refund-payment::execute', () => { const response = await execute(ctpPaymentClone) const adyenRequest = response.actions.find( - (action) => action.action === 'addInterfaceInteraction' + (action) => action.action === 'addInterfaceInteraction', ).fields.request const adyenRequestJson = JSON.parse(adyenRequest) const requestBody = JSON.parse(adyenRequestJson.body) expect(requestBody.reference).to.equal( - refundPaymentTransaction.custom.fields.reference + refundPaymentTransaction.custom.fields.reference, ) }) @@ -85,13 +85,13 @@ describe('refund-payment::execute', () => { const { actions } = await execute(ctpPaymentClone) const addInterfaceInteraction = actions.find( - (a) => a.action === 'addInterfaceInteraction' + (a) => a.action === 'addInterfaceInteraction', ) const requestJson = JSON.parse(addInterfaceInteraction.fields.request) expect(requestJson.headers['Idempotency-Key']).to.equal( - refundPaymentTransaction.id + refundPaymentTransaction.id, ) - } + }, ) it( @@ -108,19 +108,19 @@ describe('refund-payment::execute', () => { const response = await execute(ctpPaymentClone) const adyenRequest = response.actions.find( - (action) => action.action === 'addInterfaceInteraction' + (action) => action.action === 'addInterfaceInteraction', ).fields.request const adyenResponse = response.actions.find( - (action) => action.action === 'addInterfaceInteraction' + (action) => action.action === 'addInterfaceInteraction', ).fields.response const adyenRequestJson = JSON.parse(adyenRequest) const requestBody = JSON.parse(adyenRequestJson.body) expect(requestBody.reference).to.equal( - refundPaymentTransaction.custom.fields.reference + refundPaymentTransaction.custom.fields.reference, ) expect(adyenResponse).to.contains('non-json-response') - } + }, ) }) diff --git a/extension/test/unit/submit-payment-details.handler.spec.js b/extension/test/unit/submit-payment-details.handler.spec.js index 233e3c958..1a12cc8b1 100644 --- a/extension/test/unit/submit-payment-details.handler.spec.js +++ b/extension/test/unit/submit-payment-details.handler.spec.js @@ -28,7 +28,7 @@ describe('submit-additional-payment-details::execute', () => { before(async () => { ctpPayment = await utils.readAndParseJsonFile( - 'test/unit/fixtures/ctp-payment-make-payment.json' + 'test/unit/fixtures/ctp-payment-make-payment.json', ) }) @@ -53,7 +53,7 @@ describe('submit-additional-payment-details::execute', () => { ctpPaymentClone.custom.fields.submitAdditionalPaymentDetailsRequest = JSON.stringify(submitPaymentDetailsRequest) ctpPaymentClone.custom.fields.makePaymentResponse = JSON.stringify( - makePaymentRedirectResponse + makePaymentRedirectResponse, ) ctpPaymentClone.custom.fields.adyenMerchantAccount = adyenMerchantAccount @@ -61,10 +61,10 @@ describe('submit-additional-payment-details::execute', () => { expect(response.actions).to.have.lengthOf(4) const addInterfaceInteraction = response.actions.find( - (a) => a.action === 'addInterfaceInteraction' + (a) => a.action === 'addInterfaceInteraction', ) expect(addInterfaceInteraction.fields.type).to.equal( - c.CTP_INTERACTION_TYPE_SUBMIT_ADDITIONAL_PAYMENT_DETAILS + c.CTP_INTERACTION_TYPE_SUBMIT_ADDITIONAL_PAYMENT_DETAILS, ) expect(addInterfaceInteraction.fields.request).to.be.a('string') expect(addInterfaceInteraction.fields.response).to.be.a('string') @@ -73,54 +73,54 @@ describe('submit-additional-payment-details::execute', () => { const request = JSON.parse(addInterfaceInteraction.fields.request) const requestBody = JSON.parse(request.body) expect(requestBody.reference).to.deep.equal( - submitPaymentDetailsRequest.reference + submitPaymentDetailsRequest.reference, ) expect(requestBody.riskData).to.deep.equal( - submitPaymentDetailsRequest.riskData + submitPaymentDetailsRequest.riskData, ) expect(requestBody.paymentMethod).to.deep.equal( - submitPaymentDetailsRequest.paymentMethod + submitPaymentDetailsRequest.paymentMethod, ) expect(requestBody.browserInfo).to.deep.equal( - submitPaymentDetailsRequest.browserInfo + submitPaymentDetailsRequest.browserInfo, ) expect(requestBody.amount).to.deep.equal( - submitPaymentDetailsRequest.amount + submitPaymentDetailsRequest.amount, ) expect(requestBody.merchantAccount).to.equal(adyenMerchantAccount) const setCustomFieldAction = response.actions.find( - (a) => a.action === 'setCustomField' + (a) => a.action === 'setCustomField', ) expect(setCustomFieldAction.name).to.equal( - c.CTP_CUSTOM_FIELD_SUBMIT_ADDITIONAL_PAYMENT_DETAILS_RESPONSE + c.CTP_CUSTOM_FIELD_SUBMIT_ADDITIONAL_PAYMENT_DETAILS_RESPONSE, ) expect(setCustomFieldAction.value).to.be.a('string') const expectedCustomFieldValue = JSON.parse( - _.cloneDeep(submitPaymentDetailsSuccessResponse) + _.cloneDeep(submitPaymentDetailsSuccessResponse), ) delete expectedCustomFieldValue.additionalData expect(setCustomFieldAction.value).to.equal( - JSON.stringify(expectedCustomFieldValue) + JSON.stringify(expectedCustomFieldValue), ) expect(setCustomFieldAction.value).to.equal( - addInterfaceInteraction.fields.response + addInterfaceInteraction.fields.response, ) const addTransaction = response.actions.find( - (a) => a.action === 'addTransaction' + (a) => a.action === 'addTransaction', ) expect(addTransaction.transaction).to.be.a('object') expect(addTransaction.transaction.type).to.equal('Authorization') expect(addTransaction.transaction.state).to.equal('Success') expect(addTransaction.transaction.interactionId).to.equal( - JSON.parse(submitPaymentDetailsSuccessResponse).pspReference + JSON.parse(submitPaymentDetailsSuccessResponse).pspReference, ) const setKeyAction = response.actions.find((a) => a.action === 'setKey') expect(setKeyAction.key).to.equal( - JSON.parse(submitPaymentDetailsSuccessResponse).pspReference + JSON.parse(submitPaymentDetailsSuccessResponse).pspReference, ) - } + }, ) it( @@ -135,7 +135,7 @@ describe('submit-additional-payment-details::execute', () => { ctpPaymentClone.custom.fields.submitAdditionalPaymentDetailsRequest = JSON.stringify(submitPaymentDetailsRequest) ctpPaymentClone.custom.fields.makePaymentResponse = JSON.stringify( - makePaymentRedirectResponse + makePaymentRedirectResponse, ) ctpPaymentClone.custom.fields.adyenMerchantAccount = adyenMerchantAccount @@ -144,10 +144,10 @@ describe('submit-additional-payment-details::execute', () => { expect(response.actions).to.have.lengthOf(2) const addInterfaceInteraction = response.actions.find( - (a) => a.action === 'addInterfaceInteraction' + (a) => a.action === 'addInterfaceInteraction', ) expect(addInterfaceInteraction.fields.type).to.equal( - c.CTP_INTERACTION_TYPE_SUBMIT_ADDITIONAL_PAYMENT_DETAILS + c.CTP_INTERACTION_TYPE_SUBMIT_ADDITIONAL_PAYMENT_DETAILS, ) expect(addInterfaceInteraction.fields.request).to.be.a('string') expect(addInterfaceInteraction.fields.response).to.be.a('string') @@ -156,36 +156,36 @@ describe('submit-additional-payment-details::execute', () => { const request = JSON.parse(addInterfaceInteraction.fields.request) const requestBody = JSON.parse(request.body) expect(requestBody.reference).to.deep.equal( - submitPaymentDetailsRequest.reference + submitPaymentDetailsRequest.reference, ) expect(requestBody.riskData).to.deep.equal( - submitPaymentDetailsRequest.riskData + submitPaymentDetailsRequest.riskData, ) expect(requestBody.paymentMethod).to.deep.equal( - submitPaymentDetailsRequest.paymentMethod + submitPaymentDetailsRequest.paymentMethod, ) expect(requestBody.browserInfo).to.deep.equal( - submitPaymentDetailsRequest.browserInfo + submitPaymentDetailsRequest.browserInfo, ) expect(requestBody.amount).to.deep.equal( - submitPaymentDetailsRequest.amount + submitPaymentDetailsRequest.amount, ) expect(requestBody.merchantAccount).to.equal(adyenMerchantAccount) const setCustomFieldAction = response.actions.find( - (a) => a.action === 'setCustomField' + (a) => a.action === 'setCustomField', ) expect(setCustomFieldAction.name).to.equal( - c.CTP_CUSTOM_FIELD_SUBMIT_ADDITIONAL_PAYMENT_DETAILS_RESPONSE + c.CTP_CUSTOM_FIELD_SUBMIT_ADDITIONAL_PAYMENT_DETAILS_RESPONSE, ) expect(setCustomFieldAction.value).to.be.a('string') expect(setCustomFieldAction.value).to.equal( - submitPaymentDetailsChallengeRes + submitPaymentDetailsChallengeRes, ) expect(setCustomFieldAction.value).to.equal( - addInterfaceInteraction.fields.response + addInterfaceInteraction.fields.response, ) - } + }, ) it( @@ -209,14 +209,14 @@ describe('submit-additional-payment-details::execute', () => { const response = await execute(ctpPaymentClone) const addInterfaceInteraction = response.actions.find( - (a) => a.action === 'addInterfaceInteraction' + (a) => a.action === 'addInterfaceInteraction', ) const request = JSON.parse(addInterfaceInteraction.fields.request) const requestBody = JSON.parse(request.body) expect(requestBody.paymentData).to.equal( - JSON.parse(makePaymentRedirectResponse).paymentData + JSON.parse(makePaymentRedirectResponse).paymentData, ) - } + }, ) it( @@ -241,12 +241,12 @@ describe('submit-additional-payment-details::execute', () => { const response = await execute(ctpPaymentClone) const addInterfaceInteraction = response.actions.find( - (a) => a.action === 'addInterfaceInteraction' + (a) => a.action === 'addInterfaceInteraction', ) const request = JSON.parse(addInterfaceInteraction.fields.request) const requestBody = JSON.parse(request.body) expect(requestBody.paymentData).to.equal(testPaymentData) - } + }, ) it( @@ -273,7 +273,7 @@ describe('submit-additional-payment-details::execute', () => { ctpPaymentClone.custom.fields.submitAdditionalPaymentDetailsRequest = JSON.stringify(submitPaymentDetailsRequest) ctpPaymentClone.custom.fields.makePaymentResponse = JSON.stringify( - makePaymentRedirectResponse + makePaymentRedirectResponse, ) ctpPaymentClone.custom.fields.adyenMerchantAccount = adyenMerchantAccount @@ -281,21 +281,21 @@ describe('submit-additional-payment-details::execute', () => { expect(response.actions).to.have.lengthOf(4) const addInterfaceInteractionAction = response.actions.find( - (a) => a.action === 'addInterfaceInteraction' + (a) => a.action === 'addInterfaceInteraction', ) expect(addInterfaceInteractionAction.fields.response).to.include( - 'additionalData' + 'additionalData', ) const setCustomFieldAction = response.actions.find( - (a) => a.action === 'setCustomField' + (a) => a.action === 'setCustomField', ) expect(setCustomFieldAction.value).to.include('additionalData') const setKeyAction = response.actions.find((a) => a.action === 'setKey') expect(setKeyAction.key).to.equal( - JSON.parse(submitPaymentDetailsSuccessResponse).pspReference + JSON.parse(submitPaymentDetailsSuccessResponse).pspReference, ) sandbox.restore() - } + }, ) it( @@ -322,7 +322,7 @@ describe('submit-additional-payment-details::execute', () => { ctpPaymentClone.custom.fields.submitAdditionalPaymentDetailsRequest = JSON.stringify(submitPaymentDetailsRequest) ctpPaymentClone.custom.fields.makePaymentResponse = JSON.stringify( - makePaymentRedirectResponse + makePaymentRedirectResponse, ) ctpPaymentClone.custom.fields.adyenMerchantAccount = adyenMerchantAccount @@ -330,21 +330,21 @@ describe('submit-additional-payment-details::execute', () => { expect(response.actions).to.have.lengthOf(4) const addInterfaceInteractionAction = response.actions.find( - (a) => a.action === 'addInterfaceInteraction' + (a) => a.action === 'addInterfaceInteraction', ) expect(addInterfaceInteractionAction.fields.response).to.not.include( - 'additionalData' + 'additionalData', ) const setCustomFieldAction = response.actions.find( - (a) => a.action === 'setCustomField' + (a) => a.action === 'setCustomField', ) expect(setCustomFieldAction.value).to.not.include('additionalData') const setKeyAction = response.actions.find((a) => a.action === 'setKey') expect(setKeyAction.key).to.equal( - JSON.parse(submitPaymentDetailsSuccessResponse).pspReference + JSON.parse(submitPaymentDetailsSuccessResponse).pspReference, ) sandbox.restore() - } + }, ) it( @@ -359,7 +359,7 @@ describe('submit-additional-payment-details::execute', () => { ctpPaymentClone.custom.fields.submitAdditionalPaymentDetailsRequest = JSON.stringify(submitPaymentDetailsRequest) ctpPaymentClone.custom.fields.makePaymentResponse = JSON.stringify( - makePaymentRedirectResponse + makePaymentRedirectResponse, ) ctpPaymentClone.custom.fields.adyenMerchantAccount = adyenMerchantAccount ctpPaymentClone.transactions.push({ @@ -379,13 +379,13 @@ describe('submit-additional-payment-details::execute', () => { expect(response.actions).to.have.lengthOf(3) const addTransaction = response.actions.find( - (a) => a.action === 'addTransaction' + (a) => a.action === 'addTransaction', ) expect(addTransaction).to.be.undefined const setKeyAction = response.actions.find((a) => a.action === 'setKey') expect(setKeyAction.key).to.equal( - JSON.parse(submitPaymentDetailsSuccessResponse).pspReference + JSON.parse(submitPaymentDetailsSuccessResponse).pspReference, ) - } + }, ) }) diff --git a/extension/test/unit/validator-builder.spec.js b/extension/test/unit/validator-builder.spec.js index 9fed75e83..45e5939b0 100644 --- a/extension/test/unit/validator-builder.spec.js +++ b/extension/test/unit/validator-builder.spec.js @@ -28,7 +28,7 @@ describe('Validator builder', () => { .getErrors() expect(errorObject[0].message).to.equal(CREATE_SESSION_REQUEST_INVALID_JSON) expect(errorObject[1].message).to.equal( - GET_CARBON_OFFSET_COSTS_REQUEST_INVALID_JSON + GET_CARBON_OFFSET_COSTS_REQUEST_INVALID_JSON, ) }) @@ -60,9 +60,9 @@ describe('Validator builder', () => { .validateAmountPlanned() .getErrors() expect(errorObject[0].message).to.equal( - CREATE_SESSION_AMOUNT_PLANNED_NOT_SAME + CREATE_SESSION_AMOUNT_PLANNED_NOT_SAME, ) - } + }, ) it( @@ -130,9 +130,9 @@ describe('Validator builder', () => { .validateAmountPlanned() .getErrors() expect(errorObject[0].message).to.equal( - CREATE_SESSION_AMOUNT_PLANNED_NOT_SAME + CREATE_SESSION_AMOUNT_PLANNED_NOT_SAME, ) - } + }, ) it('on missing reference in createSessionRequest should return error object', () => { @@ -159,7 +159,7 @@ describe('Validator builder', () => { .getErrors() expect(errorObject[0].message).to.equal( - CREATE_SESSION_REQUEST_MISSING_REFERENCE + CREATE_SESSION_REQUEST_MISSING_REFERENCE, ) }) @@ -176,7 +176,7 @@ describe('Validator builder', () => { .getErrors() expect(errorObject[0].message).to.equal( - MISSING_REQUIRED_FIELDS_CTP_PROJECT_KEY + MISSING_REQUIRED_FIELDS_CTP_PROJECT_KEY, ) }) @@ -193,7 +193,7 @@ describe('Validator builder', () => { .getErrors() expect(errorObject[0].message).to.equal( - MISSING_REQUIRED_FIELDS_ADYEN_MERCHANT_ACCOUNT + MISSING_REQUIRED_FIELDS_ADYEN_MERCHANT_ACCOUNT, ) }) @@ -211,10 +211,10 @@ describe('Validator builder', () => { .getErrors() expect(errorObject[0].message).to.equal( - MISSING_REQUIRED_FIELDS_CTP_PROJECT_KEY + MISSING_REQUIRED_FIELDS_CTP_PROJECT_KEY, ) expect(errorObject[1].message).to.equal( - MISSING_REQUIRED_FIELDS_ADYEN_MERCHANT_ACCOUNT + MISSING_REQUIRED_FIELDS_ADYEN_MERCHANT_ACCOUNT, ) }) @@ -242,7 +242,7 @@ describe('Validator builder', () => { .getErrors() expect(errorObject[0].message).to.equal( - AMOUNT_UPDATES_REQUEST_MISSING_PSP_REFERENCE + AMOUNT_UPDATES_REQUEST_MISSING_PSP_REFERENCE, ) }) }) diff --git a/notification/index.googleFunction.js b/notification/index.googleFunction.js index 2f7a1b36b..809075082 100644 --- a/notification/index.googleFunction.js +++ b/notification/index.googleFunction.js @@ -21,7 +21,7 @@ export const notificationTrigger = async (request, response) => { await handler.processNotification( notification, adyenConfig.enableHmacSignature, - ctpProjectConfig + ctpProjectConfig, ) } } catch (err) { @@ -31,7 +31,7 @@ export const notificationTrigger = async (request, response) => { notification: utils.getNotificationForTracking(notificationItems), cause, }, - 'Unexpected exception occurred.' + 'Unexpected exception occurred.', ) if (isRecoverableError(err)) { return response.status(500).send(cause.message) diff --git a/notification/index.lambda.js b/notification/index.lambda.js index 1458ec988..5da320b92 100644 --- a/notification/index.lambda.js +++ b/notification/index.lambda.js @@ -17,7 +17,7 @@ export const handler = async (event) => { notification: undefined, err: error, }, - 'Unexpected error when processing event' + 'Unexpected error when processing event', ) throw error } @@ -29,7 +29,7 @@ export const handler = async (event) => { await notificationHandler.processNotification( notification, adyenConfig.enableHmacSignature, - ctpProjectConfig + ctpProjectConfig, ) } } catch (err) { @@ -39,7 +39,7 @@ export const handler = async (event) => { notification: utils.getNotificationForTracking(notificationItems), cause, }, - 'Unexpected exception occurred.' + 'Unexpected exception occurred.', ) if (isRecoverableError(err)) { throw err diff --git a/notification/notification-trigger/index.azureFunction.js b/notification/notification-trigger/index.azureFunction.js index 7dc9ffc5f..5bdcd9ccf 100644 --- a/notification/notification-trigger/index.azureFunction.js +++ b/notification/notification-trigger/index.azureFunction.js @@ -39,7 +39,7 @@ export const azureNotificationTrigger = async function (context, req) { await notificationHandler.processNotification( notification, adyenConfig.enableHmacSignature, - ctpProjectConfig + ctpProjectConfig, ) } } catch (err) { @@ -49,7 +49,7 @@ export const azureNotificationTrigger = async function (context, req) { notification: utils.getNotificationForTracking(notificationItems), cause, }, - 'Unexpected exception occurred.' + 'Unexpected exception occurred.', ) if (isRecoverableError(err)) { diff --git a/notification/src/api/notification/notification.controller.js b/notification/src/api/notification/notification.controller.js index d1dbfaf8e..9c45b1776 100644 --- a/notification/src/api/notification/notification.controller.js +++ b/notification/src/api/notification/notification.controller.js @@ -11,7 +11,7 @@ const logger = getLogger() async function handleNotification(request, response) { if (request.method !== 'POST') { logger.debug( - `Received non-POST request: ${request.method}. The request will not be processed...` + `Received non-POST request: ${request.method}. The request will not be processed...`, ) return utils.sendResponse(response) } @@ -27,7 +27,7 @@ async function handleNotification(request, response) { await notificationHandler.processNotification( notification, adyenConfig.enableHmacSignature, - ctpProjectConfig + ctpProjectConfig, ) } return sendAcceptedResponse(response) @@ -39,7 +39,7 @@ async function handleNotification(request, response) { notification: utils.getNotificationForTracking(notification), cause, }, - 'Unexpected exception occurred.' + 'Unexpected exception occurred.', ) if (isRecoverableError(err)) { return utils.sendResponse(response, 500) @@ -57,7 +57,7 @@ function sendAcceptedResponse(response) { response, 200, { 'Content-Type': 'application/json' }, - JSON.stringify({ notificationResponse: '[accepted]' }) + JSON.stringify({ notificationResponse: '[accepted]' }), ) } diff --git a/notification/src/config/config-loader.js b/notification/src/config/config-loader.js index c7abd053e..0775e6988 100644 --- a/notification/src/config/config-loader.js +++ b/notification/src/config/config-loader.js @@ -13,7 +13,7 @@ function loadFromAdyenIntegrationEnvVar() { return JSON.parse(process.env.ADYEN_INTEGRATION_CONFIG) } catch (e) { throw new Error( - 'Adyen integration configuration is not provided in the JSON format' + 'Adyen integration configuration is not provided in the JSON format', ) } } diff --git a/notification/src/config/config.js b/notification/src/config/config.js index ba71c0313..d325b95c0 100644 --- a/notification/src/config/config.js +++ b/notification/src/config/config.js @@ -22,8 +22,8 @@ function getCtpConfig(ctpProjectKey) { if (!ctpConfig) throw new Error( `Configuration is not provided. Please update the configuration. ctpProjectKey: [${JSON.stringify( - ctpProjectKey - )}]` + ctpProjectKey, + )}]`, ) return { clientId: ctpConfig.clientId, @@ -41,8 +41,8 @@ function getAdyenConfig(adyenMerchantAccount) { if (!adyenConfig) throw new Error( `Configuration for adyenMerchantAccount is not provided. Please update the configuration: ${JSON.stringify( - adyenMerchantAccount - )}` + adyenMerchantAccount, + )}`, ) let enableHmacSignature = adyenConfig.enableHmacSignature !== 'false' @@ -81,20 +81,20 @@ function loadAndValidateConfig() { const numberOfAdyenConfigs = Object.keys(config.adyen).length if (numberOfCtpConfigs === 0) throw new Error( - 'Please add at least one commercetools project to the config' + 'Please add at least one commercetools project to the config', ) if (numberOfAdyenConfigs === 0) throw new Error( - 'Please add at least one Adyen merchant account to the config' + 'Please add at least one Adyen merchant account to the config', ) for (const [ctpProjectKey, ctpConfig] of Object.entries( - config.commercetools + config.commercetools, )) { if (!ctpConfig.clientId || !ctpConfig.clientSecret) throw new Error( `[${ctpProjectKey}]: CTP project credentials are missing. ` + - 'Please verify that all projects have projectKey, clientId and clientSecret' + 'Please verify that all projects have projectKey, clientId and clientSecret', ) } @@ -106,7 +106,7 @@ function loadAndValidateConfig() { return for (const [adyenMerchantAccount, adyenConfig] of Object.entries( - config.adyen + config.adyen, )) { if ( adyenConfig.enableHmacSignature !== 'false' && @@ -115,7 +115,7 @@ function loadAndValidateConfig() { throw new Error( `[${adyenMerchantAccount}]: The "secretHmacKey" config variable is missing to be able to verify ` + `notifications, please generate a secret HMAC key in Adyen Customer Area ` + - `or set "enableHmacSignature=false" to disable the verification feature.` + `or set "enableHmacSignature=false" to disable the verification feature.`, ) } } diff --git a/notification/src/config/init/ensure-adyen-webhook.js b/notification/src/config/init/ensure-adyen-webhook.js index a9fb709f5..610780167 100644 --- a/notification/src/config/init/ensure-adyen-webhook.js +++ b/notification/src/config/init/ensure-adyen-webhook.js @@ -28,19 +28,20 @@ async function ensureAdyenWebhook(adyenApiKey, webhookUrl, merchantId) { 'Content-Type': 'application/json', 'X-Api-Key': adyenApiKey, }, - } + }, ) const getWebhookResponseJson = await getWebhookResponse.json() const existingWebhook = getWebhookResponseJson.data?.find( (webhook) => - webhook.url === webhookConfig.url && webhook.type === webhookConfig.type + webhook.url === webhookConfig.url && + webhook.type === webhookConfig.type, ) if (existingWebhook) { logger.info( `Webhook already existed with ID ${existingWebhook.id}. ` + - 'Skipping webhook creation and ensuring the webhook is active' + 'Skipping webhook creation and ensuring the webhook is active', ) if (!existingWebhook.active) await fetch( @@ -54,7 +55,7 @@ async function ensureAdyenWebhook(adyenApiKey, webhookUrl, merchantId) { 'Content-Type': 'application/json', 'X-Api-Key': adyenApiKey, }, - } + }, ) return existingWebhook.id } @@ -68,7 +69,7 @@ async function ensureAdyenWebhook(adyenApiKey, webhookUrl, merchantId) { 'Content-Type': 'application/json', 'X-Api-Key': adyenApiKey, }, - } + }, ) const createWebhookResponseJson = await createWebhookResponse.json() @@ -79,7 +80,7 @@ async function ensureAdyenWebhook(adyenApiKey, webhookUrl, merchantId) { } catch (err) { throw Error( `Failed to ensure adyen webhook for project ${merchantId}.` + - `Error: ${JSON.stringify(serializeError(err))}` + `Error: ${JSON.stringify(serializeError(err))}`, ) } } @@ -97,7 +98,7 @@ async function ensureAdyenHmac(adyenApiKey, merchantId, webhookId) { 'Content-Type': 'application/json', 'X-Api-Key': adyenApiKey, }, - } + }, ) const generateHmacResponseJson = await generateHmacResponse.json() @@ -119,13 +120,13 @@ async function ensureAdyenWebhooksForAllProjects() { const webhookId = await ensureAdyenWebhook( adyenConfig.apiKey, adyenConfig.notificationBaseUrl, - adyenMerchantId + adyenMerchantId, ) if (adyenConfig.enableHmacSignature && !adyenConfig.secretHmacKey) { const hmacKey = await ensureAdyenHmac( adyenConfig.apiKey, adyenMerchantId, - webhookId + webhookId, ) jsonConfig.adyen[adyenMerchantId].secretHmacKey = hmacKey } diff --git a/notification/src/config/init/ensure-interface-interaction-custom-type.js b/notification/src/config/init/ensure-interface-interaction-custom-type.js index e46a107af..ce1a249fa 100644 --- a/notification/src/config/init/ensure-interface-interaction-custom-type.js +++ b/notification/src/config/init/ensure-interface-interaction-custom-type.js @@ -18,12 +18,12 @@ async function ensureInterfaceInteractionCustomTypeForAllProjects() { async function ensureInterfaceInteractionCustomType(ctpClient, ctpProjectKey) { const interfaceInteractionType = await utils.readAndParseJsonFile( - 'resources/payment-interface-interaction-type.json' + 'resources/payment-interface-interaction-type.json', ) return syncCustomType( ctpClient, createChildLogger(ctpProjectKey), - interfaceInteractionType + interfaceInteractionType, ) } @@ -49,7 +49,7 @@ async function syncCustomType(ctpClient, logger, typeDraft) { ctpClient.builder.types, existingType.id, existingType.version, - updateActions + updateActions, ) logger.info(`Successfully updated the type (key=${typeDraft.key})`) } @@ -57,7 +57,7 @@ async function syncCustomType(ctpClient, logger, typeDraft) { } catch (err) { throw Error( `Failed to sync payment type (key=${typeDraft.key}). ` + - `Error: ${JSON.stringify(serializeError(err))}` + `Error: ${JSON.stringify(serializeError(err))}`, ) } } diff --git a/notification/src/handler/notification/notification.handler.js b/notification/src/handler/notification/notification.handler.js index 96d5b423f..20d1d1c88 100644 --- a/notification/src/handler/notification/notification.handler.js +++ b/notification/src/handler/notification/notification.handler.js @@ -12,7 +12,7 @@ const mainLogger = getLogger() async function processNotification( notification, enableHmacSignature, - ctpProjectConfig + ctpProjectConfig, ) { const logger = mainLogger.child({ commercetools_project_key: ctpProjectConfig.projectKey, @@ -23,7 +23,7 @@ async function processNotification( if (errorMessage) { logger.error( { notification: utils.getNotificationForTracking(notification) }, - `HMAC validation failed. Reason: "${errorMessage}"` + `HMAC validation failed. Reason: "${errorMessage}"`, ) return } @@ -32,19 +32,19 @@ async function processNotification( const merchantReference = _.get( notification, 'NotificationRequestItem.merchantReference', - null + null, ) const pspReference = _.get( notification, 'NotificationRequestItem.pspReference', - null + null, ) const originalReference = _.get( notification, 'NotificationRequestItem.originalReference', - null + null, ) const ctpClient = await ctp.get(ctpProjectConfig) @@ -52,13 +52,13 @@ async function processNotification( const payment = await getPaymentByMerchantReference( merchantReference, originalReference || pspReference, - ctpClient + ctpClient, ) if (payment) await updatePaymentWithRepeater(payment, notification, ctpClient, logger) else logger.error( - `Payment with merchantReference: ${merchantReference} was not found` + `Payment with merchantReference: ${merchantReference} was not found`, ) } @@ -66,7 +66,7 @@ async function updatePaymentWithRepeater( payment, notification, ctpClient, - logger + logger, ) { const maxRetry = 20 let currentPayment = payment @@ -78,7 +78,7 @@ async function updatePaymentWithRepeater( updateActions = await calculateUpdateActionsForPayment( currentPayment, notification, - logger + logger, ) if (updateActions.length === 0) { break @@ -86,7 +86,7 @@ async function updatePaymentWithRepeater( logger.debug( `Update payment with key ${ currentPayment.key - } with update actions [${JSON.stringify(updateActions)}]` + } with update actions [${JSON.stringify(updateActions)}]`, ) try { /* eslint-disable-next-line no-await-in-loop */ @@ -94,10 +94,10 @@ async function updatePaymentWithRepeater( ctpClient.builder.payments, currentPayment.id, currentVersion, - updateActions + updateActions, ) logger.debug( - `Payment with key ${currentPayment.key} was successfully updated` + `Payment with key ${currentPayment.key} was successfully updated`, ) break } catch (err) { @@ -126,14 +126,14 @@ async function updatePaymentWithRepeater( `${retryMessage} Won't retry again` + ` because of a reached limit ${maxRetry}` + ` max retries. Failed actions: ${JSON.stringify( - updateActionsToLog - )}` + updateActionsToLog, + )}`, ) } /* eslint-disable-next-line no-await-in-loop */ const response = await ctpClient.fetchById( ctpClient.builder.payments, - currentPayment.id + currentPayment.id, ) currentPayment = response.body // eslint-disable-line prefer-destructuring currentVersion = currentPayment.version @@ -148,7 +148,7 @@ function _obfuscateNotificationInfoFromActionFields(updateActions) { .filter((value) => value?.fields?.notification) .forEach((value) => { value.fields.notification = utils.getNotificationForTracking( - JSON.parse(value.fields.notification) + JSON.parse(value.fields.notification), ) }) return copyOfUpdateActions @@ -162,7 +162,7 @@ async function calculateUpdateActionsForPayment(payment, notification, logger) { const isNotificationInInterfaceInteraction = payment.interfaceInteractions.some( (interaction) => - interaction.fields.notification === stringifiedNotification + interaction.fields.notification === stringifiedNotification, ) if (isNotificationInInterfaceInteraction === false) updateActions.push(getAddInterfaceInteractionUpdateAction(notification)) @@ -176,7 +176,7 @@ async function calculateUpdateActionsForPayment(payment, notification, logger) { const { eventDate } = notificationRequestItem const oldTransaction = _.find( payment.transactions, - (transaction) => transaction.interactionId === pspReference + (transaction) => transaction.interactionId === pspReference, ) if (_.isEmpty(oldTransaction)) updateActions.push( @@ -187,7 +187,7 @@ async function calculateUpdateActionsForPayment(payment, notification, logger) { amount: notificationRequestItem.amount.value, currency: notificationRequestItem.amount.currency, interactionId: pspReference, - }) + }), ) else if ( compareTransactionStates(oldTransaction.state, transactionState) > 0 @@ -195,15 +195,15 @@ async function calculateUpdateActionsForPayment(payment, notification, logger) { updateActions.push( getChangeTransactionStateUpdateAction( oldTransaction.id, - transactionState - ) + transactionState, + ), ) updateActions.push( getChangeTransactionTimestampUpdateAction( oldTransaction.id, notificationRequestItem.eventDate, - logger - ) + logger, + ), ) } const paymentKey = payment.key @@ -224,7 +224,7 @@ async function calculateUpdateActionsForPayment(payment, notification, logger) { paymentMethodFromPayment !== paymentMethodFromNotification ) { updateActions.push( - getSetMethodInfoMethodAction(paymentMethodFromNotification) + getSetMethodInfoMethodAction(paymentMethodFromNotification), ) const action = getSetMethodInfoNameAction(paymentMethodFromNotification) if (action) updateActions.push(action) @@ -334,7 +334,7 @@ function getAddInterfaceInteractionUpdateAction(notification) { function getChangeTransactionStateUpdateAction( transactionId, - newTransactionState + newTransactionState, ) { return { action: 'changeTransactionState', @@ -353,7 +353,7 @@ function convertDateToUTCFormat(transactionEventDate, logger) { // if transactionEventDate is incorrect in format logger.error( err, - `Fail to convert notification event date "${transactionEventDate}" to UTC format` + `Fail to convert notification event date "${transactionEventDate}" to UTC format`, ) return new Date().toISOString() } @@ -362,7 +362,7 @@ function convertDateToUTCFormat(transactionEventDate, logger) { function getChangeTransactionTimestampUpdateAction( transactionId, transactionEventDate, - logger + logger, ) { return { action: 'changeTransactionTimestamp', @@ -373,7 +373,7 @@ function getChangeTransactionTimestampUpdateAction( async function getTransactionTypeAndStateOrNull(notificationRequestItem) { const adyenEvents = await utils.readAndParseJsonFile( - 'resources/adyen-events.json' + 'resources/adyen-events.json', ) const adyenEventCode = notificationRequestItem.eventCode const adyenEventSuccess = notificationRequestItem.success @@ -381,7 +381,7 @@ async function getTransactionTypeAndStateOrNull(notificationRequestItem) { // eslint-disable-next-line max-len const adyenEvent = _.find( adyenEvents, - (e) => e.eventCode === adyenEventCode && e.success === adyenEventSuccess + (e) => e.eventCode === adyenEventCode && e.success === adyenEventSuccess, ) if (adyenEvent && adyenEventCode === 'CANCEL_OR_REFUND') { /* we need to get correct action from the additional data, for example: @@ -454,7 +454,7 @@ function getSetMethodInfoNameAction(paymentMethod) { async function getPaymentByMerchantReference( merchantReference, pspReference, - ctpClient + ctpClient, ) { try { const keys = [merchantReference, pspReference] diff --git a/notification/src/server.js b/notification/src/server.js index d08488df0..66a6e45fc 100644 --- a/notification/src/server.js +++ b/notification/src/server.js @@ -21,7 +21,7 @@ function setupServer() { } catch (err) { logger.error( err, - `Unexpected error when processing URL ${JSON.stringify(parts)}` + `Unexpected error when processing URL ${JSON.stringify(parts)}`, ) utils.sendResponse(response, 500) } diff --git a/notification/src/setup.js b/notification/src/setup.js index 380d3fcd1..5accb02ed 100644 --- a/notification/src/setup.js +++ b/notification/src/setup.js @@ -15,11 +15,11 @@ async function setupNotificationResources() { logger.info( `Configured commercetools project keys are: ${JSON.stringify( - ctpProjectKeys + ctpProjectKeys, )}. ` + `Configured adyen merchant accounts are: ${JSON.stringify( - adyenMerchantAccounts - )}` + adyenMerchantAccounts, + )}`, ) } diff --git a/notification/src/utils/commons.js b/notification/src/utils/commons.js index 801f1ecc6..17c2f57fc 100644 --- a/notification/src/utils/commons.js +++ b/notification/src/utils/commons.js @@ -40,7 +40,7 @@ function getNotificationForTracking(notification) { const notificationListForTracking = [] notification.forEach((notificationElement) => { notificationListForTracking.push( - convertNotificationForTracking(notificationElement) + convertNotificationForTracking(notificationElement), ) }) return notificationListForTracking diff --git a/notification/src/utils/ctp.js b/notification/src/utils/ctp.js index bc231115b..8e864ece0 100644 --- a/notification/src/utils/ctp.js +++ b/notification/src/utils/ctp.js @@ -80,14 +80,14 @@ async function setUpClient(config) { return ctpClient.execute( this.buildRequestOptions( uri.byId(id).withVersion(version).build(), - 'DELETE' - ) + 'DELETE', + ), ) }, create(uri, body) { return ctpClient.execute( - this.buildRequestOptions(uri.build(), 'POST', body) + this.buildRequestOptions(uri.build(), 'POST', body), ) }, @@ -97,7 +97,7 @@ async function setUpClient(config) { actions, } return ctpClient.execute( - this.buildRequestOptions(uri.byId(id).build(), 'POST', body) + this.buildRequestOptions(uri.byId(id).build(), 'POST', body), ) }, @@ -118,7 +118,7 @@ async function setUpClient(config) { const keyConditions = `key in (${keyList.join(',')})` return ctpClient.execute( - this.buildRequestOptions(uri.where(keyConditions).build()) + this.buildRequestOptions(uri.where(keyConditions).build()), ) }, @@ -126,7 +126,7 @@ async function setUpClient(config) { return this.process( this.buildRequestOptions(uri.build()), (data) => callback(data.body.results), - opts + opts, ) }, diff --git a/notification/src/utils/hmacValidator.js b/notification/src/utils/hmacValidator.js index e7e9e94a4..fa59519d7 100644 --- a/notification/src/utils/hmacValidator.js +++ b/notification/src/utils/hmacValidator.js @@ -34,7 +34,7 @@ function validateHmacSignature(notification) { const adyenConfig = config.getAdyenConfig(adyenMerchantAccount) const validationResult = validator.validateHMAC( notificationRequestItem, - adyenConfig.secretHmacKey + adyenConfig.secretHmacKey, ) if (!validationResult) return ( diff --git a/notification/src/utils/parser.js b/notification/src/utils/parser.js index 2ac7febd2..0ad858915 100644 --- a/notification/src/utils/parser.js +++ b/notification/src/utils/parser.js @@ -13,7 +13,7 @@ function getCtpProjectConfig(notification, path) { if (_.isEmpty(commercetoolsProjectKey)) { throw new Error( 'Notification can not be processed as "metadata.ctProjectKey" was not found on the notification ' + - 'nor the path is containing the commercetools project key.' + 'nor the path is containing the commercetools project key.', ) } diff --git a/notification/test/integration/multitenancy.spec.js b/notification/test/integration/multitenancy.spec.js index f5bdd948e..5d14cae8d 100644 --- a/notification/test/integration/multitenancy.spec.js +++ b/notification/test/integration/multitenancy.spec.js @@ -9,21 +9,24 @@ import { } from '../test-utils.js' describe('::multitenancy::', () => { - const [commercetoolsProjectKey1, commercetoolsProjectKey2] = + let [commercetoolsProjectKey1, commercetoolsProjectKey2] = config.getAllCtpProjectKeys() - const [adyenMerchantAccount1, adyenMerchantAccount2] = + let [adyenMerchantAccount1, adyenMerchantAccount2] = config.getAllAdyenMerchantAccounts() let ctpClient1 let ctpClient2 let notificationURL + commercetoolsProjectKey2 = commercetoolsProjectKey2 || commercetoolsProjectKey1; + adyenMerchantAccount2 = adyenMerchantAccount2 || adyenMerchantAccount1; + before(async () => { ctpClient1 = await ctpClientBuilder.get( - config.getCtpConfig(commercetoolsProjectKey1) + config.getCtpConfig(commercetoolsProjectKey1), ) ctpClient2 = await ctpClientBuilder.get( - config.getCtpConfig(commercetoolsProjectKey2) + config.getCtpConfig(commercetoolsProjectKey2), ) notificationURL = getNotificationURL() }) @@ -39,14 +42,14 @@ describe('::multitenancy::', () => { merchantReference1, pspReference1, commercetoolsProjectKey1, - adyenMerchantAccount1 + adyenMerchantAccount1, ), ensurePayment( ctpClient2, merchantReference2, pspReference2, commercetoolsProjectKey2, - adyenMerchantAccount2 + adyenMerchantAccount2, ), ]) @@ -54,14 +57,14 @@ describe('::multitenancy::', () => { commercetoolsProjectKey1, adyenMerchantAccount1, merchantReference1, - pspReference1 + pspReference1, ) const notificationPayload2 = createNotificationPayload( commercetoolsProjectKey2, adyenMerchantAccount2, merchantReference2, - pspReference2 + pspReference2, ) const [response1, response2] = await Promise.all([ @@ -84,12 +87,12 @@ describe('::multitenancy::', () => { const { body: paymentAfter1 } = await ctpClient1.fetchByKey( ctpClient1.builder.payments, - pspReference1 // pspReference is the key of authorized payment + pspReference1, // pspReference is the key of authorized payment ) const { body: paymentAfter2 } = await ctpClient2.fetchByKey( ctpClient2.builder.payments, - pspReference2 // pspReference is the key of authorized payment + pspReference2, // pspReference is the key of authorized payment ) expect(paymentAfter1.transactions).to.have.lengthOf(1) @@ -101,7 +104,7 @@ describe('::multitenancy::', () => { .additionalData } expect(paymentAfter1.interfaceInteractions[0].fields.notification).to.equal( - JSON.stringify(notificationPayload1.notificationItems[0]) + JSON.stringify(notificationPayload1.notificationItems[0]), ) expect(paymentAfter2.transactions).to.have.lengthOf(1) @@ -113,7 +116,7 @@ describe('::multitenancy::', () => { .additionalData } expect(paymentAfter2.interfaceInteractions[0].fields.notification).to.equal( - JSON.stringify(notificationPayload2.notificationItems[0]) + JSON.stringify(notificationPayload2.notificationItems[0]), ) }) }) diff --git a/notification/test/integration/notification.handler.spec.js b/notification/test/integration/notification.handler.spec.js index 62ef35422..932c910ca 100644 --- a/notification/test/integration/notification.handler.spec.js +++ b/notification/test/integration/notification.handler.spec.js @@ -17,7 +17,7 @@ describe('notification module', () => { let ctpClient before(async () => { ctpClient = await ctpClientBuilder.get( - config.getCtpConfig(commercetoolsProjectKey) + config.getCtpConfig(commercetoolsProjectKey), ) notificationURL = getNotificationURL() }) @@ -34,7 +34,7 @@ describe('notification module', () => { merchantReference, pspReference, commercetoolsProjectKey, - adyenMerchantAccount + adyenMerchantAccount, ) expect(paymentBefore.transactions).to.have.lengthOf(1) expect(paymentBefore.transactions[0].type).to.equal('Authorization') @@ -45,7 +45,7 @@ describe('notification module', () => { commercetoolsProjectKey, adyenMerchantAccount, merchantReference, - pspReference + pspReference, ) // Simulating a notification from Adyen @@ -62,7 +62,7 @@ describe('notification module', () => { const { body: paymentAfter } = await ctpClient.fetchByKey( ctpClient.builder.payments, - pspReference // pspReference is the key of authorized payment + pspReference, // pspReference is the key of authorized payment ) expect(paymentAfter.transactions).to.have.lengthOf(1) @@ -75,9 +75,9 @@ describe('notification module', () => { .additionalData } expect( - paymentAfter.interfaceInteractions[0].fields.notification + paymentAfter.interfaceInteractions[0].fields.notification, ).to.equal(JSON.stringify(notificationPayload.notificationItems[0])) - } + }, ) it('should add a charge transaction when receives a successful manual CAPTURE notification', async () => { @@ -90,7 +90,7 @@ describe('notification module', () => { merchantReference, pspReference, commercetoolsProjectKey, - adyenMerchantAccount + adyenMerchantAccount, ) expect(paymentBefore.transactions).to.have.lengthOf(1) expect(paymentBefore.transactions[0].type).to.equal('Authorization') @@ -114,7 +114,7 @@ describe('notification module', () => { ctpClient.builder.payments, paymentBefore.id, paymentBefore.version, - actions + actions, ) expect(updatedPayment.transactions).to.have.lengthOf(1) @@ -128,7 +128,7 @@ describe('notification module', () => { chargeInteractionId, 'CAPTURE', 'true', - pspReference + pspReference, ) // Simulating a notification from Adyen @@ -145,7 +145,7 @@ describe('notification module', () => { const { body: paymentAfter } = await ctpClient.fetchByKey( ctpClient.builder.payments, - pspReference // pspReference is the key of authorized payment + pspReference, // pspReference is the key of authorized payment ) expect(paymentAfter.transactions).to.have.lengthOf(2) expect(paymentAfter.transactions[0].type).to.equal('Authorization') @@ -159,7 +159,7 @@ describe('notification module', () => { .additionalData } expect(paymentAfter.interfaceInteractions[0].fields.notification).to.equal( - JSON.stringify(notificationPayload.notificationItems[0]) + JSON.stringify(notificationPayload.notificationItems[0]), ) }) @@ -175,7 +175,7 @@ describe('notification module', () => { merchantReference, pspReference, commercetoolsProjectKey, - adyenMerchantAccount + adyenMerchantAccount, ) expect(paymentBefore.transactions).to.have.lengthOf(1) expect(paymentBefore.transactions[0].type).to.equal('Authorization') @@ -187,7 +187,7 @@ describe('notification module', () => { adyenMerchantAccount, merchantReference, pspReference, - 'UNKNOWN_EVENT_CODE' + 'UNKNOWN_EVENT_CODE', ) // Simulating a notification from Adyen @@ -204,7 +204,7 @@ describe('notification module', () => { const { body: paymentAfter } = await ctpClient.fetchByKey( ctpClient.builder.payments, - merchantReference // merchantReference is the key of unauthorized payment + merchantReference, // merchantReference is the key of unauthorized payment ) expect(paymentAfter.transactions).to.have.lengthOf(1) expect(paymentAfter.transactions[0].type).to.equal('Authorization') @@ -215,9 +215,9 @@ describe('notification module', () => { .additionalData } expect( - paymentAfter.interfaceInteractions[0].fields.notification + paymentAfter.interfaceInteractions[0].fields.notification, ).to.equal(JSON.stringify(notificationPayload.notificationItems[0])) - } + }, ) it('should response with success when payment does not exist on the platform', async () => { @@ -229,7 +229,7 @@ describe('notification module', () => { merchantReference, pspReference, commercetoolsProjectKey, - adyenMerchantAccount + adyenMerchantAccount, ) expect(paymentBefore.transactions).to.have.lengthOf(1) expect(paymentBefore.transactions[0].type).to.equal('Authorization') @@ -241,7 +241,7 @@ describe('notification module', () => { adyenMerchantAccount, merchantReference, pspReference, - 'NOT_EXISTING_PAYMENT' + 'NOT_EXISTING_PAYMENT', ) // Simulating a notification from Adyen @@ -258,7 +258,7 @@ describe('notification module', () => { const { body: paymentAfter } = await ctpClient.fetchByKey( ctpClient.builder.payments, - merchantReference // merchantReference is the key of unauthorized payment + merchantReference, // merchantReference is the key of unauthorized payment ) expect(paymentAfter.transactions).to.have.lengthOf(1) expect(paymentAfter.transactions[0].type).to.equal('Authorization') @@ -279,7 +279,7 @@ describe('notification module', () => { merchantReference, pspReference, commercetoolsProjectKey, - adyenMerchantAccount + adyenMerchantAccount, ) expect(paymentBefore.transactions).to.have.lengthOf(1) expect(paymentBefore.transactions[0].type).to.equal('Authorization') @@ -316,7 +316,7 @@ describe('notification module', () => { ctpClient.builder.payments, paymentBefore.id, paymentBefore.version, - actions + actions, ) expect(updatedPayment.transactions).to.have.lengthOf(2) @@ -332,7 +332,7 @@ describe('notification module', () => { refundInteractionId, 'REFUND', 'true', - pspReference + pspReference, ) // Simulating a notification from Adyen @@ -349,7 +349,7 @@ describe('notification module', () => { const { body: paymentAfter } = await ctpClient.fetchByKey( ctpClient.builder.payments, - pspReference // pspReference is the key of authorized payment + pspReference, // pspReference is the key of authorized payment ) expect(paymentAfter.transactions).to.have.lengthOf(2) expect(paymentAfter.transactions[0].type).to.equal('Authorization') @@ -363,9 +363,9 @@ describe('notification module', () => { .additionalData } expect( - paymentAfter.interfaceInteractions[0].fields.notification + paymentAfter.interfaceInteractions[0].fields.notification, ).to.equal(JSON.stringify(notificationPayload.notificationItems[0])) - } + }, ) it( @@ -380,7 +380,7 @@ describe('notification module', () => { merchantReference, pspReference, commercetoolsProjectKey, - adyenMerchantAccount + adyenMerchantAccount, ) const refundInteractionId1 = _generateRandomNumber() const refundInteractionId2 = _generateRandomNumber() @@ -432,7 +432,7 @@ describe('notification module', () => { ctpClient.builder.payments, paymentBefore.id, paymentBefore.version, - actions + actions, ) const notificationPayload1 = createNotificationPayload( @@ -442,7 +442,7 @@ describe('notification module', () => { refundInteractionId1, 'REFUND', 'true', - pspReference + pspReference, ) const notificationPayload2 = createNotificationPayload( @@ -452,7 +452,7 @@ describe('notification module', () => { refundInteractionId2, 'REFUND', 'true', - pspReference + pspReference, ) const notificationPayload3 = createNotificationPayload( @@ -462,7 +462,7 @@ describe('notification module', () => { refundInteractionId3, 'REFUND', 'false', - pspReference + pspReference, ) // Simulating notifications from Adyen @@ -496,7 +496,7 @@ describe('notification module', () => { const { body: paymentAfter } = await ctpClient.fetchByKey( ctpClient.builder.payments, - pspReference // pspReference is the key of authorized payment + pspReference, // pspReference is the key of authorized payment ) expect(paymentAfter.transactions).to.have.lengthOf(4) expect(paymentAfter.transactions[1].type).to.equal('Refund') @@ -505,7 +505,7 @@ describe('notification module', () => { expect(paymentAfter.transactions[2].state).to.equal('Success') expect(paymentAfter.transactions[3].type).to.equal('Refund') expect(paymentAfter.transactions[3].state).to.equal('Failure') - } + }, ) it( @@ -520,7 +520,7 @@ describe('notification module', () => { merchantReference, pspReference, commercetoolsProjectKey, - adyenMerchantAccount + adyenMerchantAccount, ) expect(paymentBefore.transactions).to.have.lengthOf(1) expect(paymentBefore.transactions[0].type).to.equal('Authorization') @@ -558,14 +558,14 @@ describe('notification module', () => { ctpClient.builder.payments, paymentBefore.id, paymentBefore.version, - actions + actions, ) expect(updatedPayment.transactions).to.have.lengthOf(2) expect(updatedPayment.transactions[0].type).to.equal('Authorization') expect(updatedPayment.transactions[0].state).to.equal('Success') expect(updatedPayment.transactions[1].type).to.equal( - 'CancelAuthorization' + 'CancelAuthorization', ) expect(updatedPayment.transactions[1].state).to.equal('Pending') @@ -576,7 +576,7 @@ describe('notification module', () => { cancellationInteractionId, 'CANCEL_OR_REFUND', 'true', - pspReference + pspReference, ) // Simulating a notification from Adyen @@ -593,7 +593,7 @@ describe('notification module', () => { const { body: paymentAfter } = await ctpClient.fetchByKey( ctpClient.builder.payments, - pspReference // pspReference is the key of authorized payment + pspReference, // pspReference is the key of authorized payment ) expect(paymentAfter.transactions).to.have.lengthOf(2) expect(paymentAfter.transactions[0].type).to.equal('Authorization') @@ -607,9 +607,9 @@ describe('notification module', () => { .additionalData } expect( - paymentAfter.interfaceInteractions[0].fields.notification + paymentAfter.interfaceInteractions[0].fields.notification, ).to.equal(JSON.stringify(notificationPayload.notificationItems[0])) - } + }, ) it('should not update payment when the notification is unauthorised', async () => { @@ -621,7 +621,7 @@ describe('notification module', () => { merchantReference, pspReference, commercetoolsProjectKey, - adyenMerchantAccount + adyenMerchantAccount, ) expect(paymentBefore.transactions).to.have.lengthOf(1) expect(paymentBefore.transactions[0].type).to.equal('Authorization') @@ -639,7 +639,7 @@ describe('notification module', () => { commercetoolsProjectKey, adyenMerchantAccount, merchantReference, - pspReference + pspReference, ) // Simulating a modification by a middle man during transmission @@ -659,7 +659,7 @@ describe('notification module', () => { const { body: paymentAfter } = await ctpClient.fetchByKey( ctpClient.builder.payments, - merchantReference // merchantReference is the key of unauthorized payment + merchantReference, // merchantReference is the key of unauthorized payment ) expect(paymentAfter.transactions).to.have.lengthOf(1) expect(paymentAfter.transactions[0].type).to.equal('Authorization') @@ -678,7 +678,7 @@ describe('notification module', () => { merchantReference, pspReference, commercetoolsProjectKey, - adyenMerchantAccount + adyenMerchantAccount, ) expect(paymentBefore.transactions).to.have.lengthOf(1) expect(paymentBefore.transactions[0].type).to.equal('Authorization') @@ -689,7 +689,7 @@ describe('notification module', () => { null, adyenMerchantAccount, merchantReference, - pspReference + pspReference, ) // Simulating a notification from Adyen @@ -699,7 +699,7 @@ describe('notification module', () => { method: 'post', body: JSON.stringify(notificationPayload), headers: { 'Content-Type': 'application/json' }, - } + }, ) const { status } = response @@ -710,7 +710,7 @@ describe('notification module', () => { const { body: paymentAfter } = await ctpClient.fetchByKey( ctpClient.builder.payments, - pspReference // pspReference is the key of authorized payment + pspReference, // pspReference is the key of authorized payment ) expect(paymentAfter.transactions).to.have.lengthOf(1) expect(paymentAfter.transactions[0].type).to.equal('Authorization') diff --git a/notification/test/test-utils.js b/notification/test/test-utils.js index dc601a3fa..814dc9112 100644 --- a/notification/test/test-utils.js +++ b/notification/test/test-utils.js @@ -31,7 +31,7 @@ function restoreAdyenConfig() { async function buildMockErrorFromConcurrentModificationException() { const concurrentModificationError = await utils.readAndParseJsonFile( - 'test/resources/concurrent-modification-exception.json' + 'test/resources/concurrent-modification-exception.json', ) const error = new Error(concurrentModificationError.message) error.body = concurrentModificationError.body @@ -91,7 +91,7 @@ function createNotificationPayload( pspReference, eventCode = 'AUTHORISATION', success = 'true', - originalReference + originalReference, ) { const notification = { live: 'false', @@ -130,7 +130,7 @@ function createNotificationPayload( notificationRequestItem.additionalData.hmacSignature = validator.calculateHmac( notificationRequestItem, - adyenConfig.secretHmacKey + adyenConfig.secretHmacKey, ) } @@ -142,10 +142,10 @@ async function ensurePayment( paymentKey, pspReference, commercetoolsProjectKey, - adyenMerchantAccount + adyenMerchantAccount, ) { const payment = await utils.readAndParseJsonFile( - 'test/resources/payment-draft.json' + 'test/resources/payment-draft.json', ) const paymentDraft = _.cloneDeep(payment) paymentDraft.key = paymentKey diff --git a/notification/test/unit/azure-function.spec.js b/notification/test/unit/azure-function.spec.js index c601e8560..751e36ab1 100644 --- a/notification/test/unit/azure-function.spec.js +++ b/notification/test/unit/azure-function.spec.js @@ -75,7 +75,7 @@ describe('Google Function handler', () => { await azureNotificationTrigger(context, mockRequest) expect(context.res.status).to.equal(500) expect(context.res.body.error).to.equal( - 'Object 62f05181-4789-47ce-84f8-d27c895ee23c has a different version than expected. Expected: 1 - Actual: 2.' + 'Object 62f05181-4789-47ce-84f8-d27c895ee23c has a different version than expected. Expected: 1 - Actual: 2.', ) const notificationItem = mockRequest.body.notificationItems.pop() @@ -84,7 +84,7 @@ describe('Google Function handler', () => { notification: utils.getNotificationForTracking(notificationItem), err: errorWrapper, }, - 'Unexpected exception occurred.' + 'Unexpected exception occurred.', ) } finally { getLogger().child = originalChildFn @@ -113,7 +113,7 @@ describe('Google Function handler', () => { notification: utils.getNotificationForTracking(notificationItem), err: error, }, - 'Unexpected exception occurred.' + 'Unexpected exception occurred.', ) } finally { getLogger().child = originalChildFn diff --git a/notification/test/unit/commons.spec.js b/notification/test/unit/commons.spec.js index 334768f61..e29bec5c5 100644 --- a/notification/test/unit/commons.spec.js +++ b/notification/test/unit/commons.spec.js @@ -40,9 +40,8 @@ describe('notification module common utility', () => { }, }, ] - const actualNotificationResult = await utils.getNotificationForTracking( - notifications - ) + const actualNotificationResult = + await utils.getNotificationForTracking(notifications) const expectedNotificationResult = [ { eventCode: 'AUTHORISATION', @@ -81,9 +80,8 @@ describe('notification module common utility', () => { }, } - const actualNotificationResult = await utils.getNotificationForTracking( - notifications - ) + const actualNotificationResult = + await utils.getNotificationForTracking(notifications) const expectedNotificationResult = { eventCode: 'AUTHORISATION', eventDate: '2019-01-30T18:16:22+01:00', diff --git a/notification/test/unit/config.spec.js b/notification/test/unit/config.spec.js index eb69d37ae..4ef5fd3d7 100644 --- a/notification/test/unit/config.spec.js +++ b/notification/test/unit/config.spec.js @@ -30,7 +30,7 @@ describe('::config::', () => { expect.fail('This test should throw an error, but it did not') } catch (e) { expect(e.message).to.contain( - 'The "secretHmacKey" config variable is missing to be able to verify notifications' + 'The "secretHmacKey" config variable is missing to be able to verify notifications', ) } }) @@ -62,7 +62,7 @@ describe('::config::', () => { }) const config = await reloadModule('../../src/config/config.js') expect(config.default.getModuleConfig().removeSensitiveData).to.eql(false) - } + }, ) it( @@ -88,7 +88,7 @@ describe('::config::', () => { }) const config = await reloadModule('../../src/config/config.js') expect(config.default.getModuleConfig().removeSensitiveData).to.eql(true) - } + }, ) it( @@ -114,7 +114,7 @@ describe('::config::', () => { }) const config = await reloadModule('../../src/config/config.js') expect(config.default.getModuleConfig().removeSensitiveData).to.eql(false) - } + }, ) it( @@ -140,7 +140,7 @@ describe('::config::', () => { }) const config = await reloadModule('../../src/config/config.js') expect(config.default.getModuleConfig().removeSensitiveData).to.eql(true) - } + }, ) it('when ADYEN_INTEGRATION_CONFIG is not valid JSON, it should throw error', async () => { @@ -151,7 +151,7 @@ describe('::config::', () => { expect.fail('This test should throw an error, but it did not') } catch (e) { expect(e.message).to.contain( - 'configuration is not provided in the JSON format' + 'configuration is not provided in the JSON format', ) } finally { process.env.ADYEN_INTEGRATION_CONFIG = originalAdyenConfig @@ -191,7 +191,7 @@ describe('::config::', () => { const loadedConfig = await reloadModule('../../src/config/config.js') expect( - loadedConfig.default.getCtpConfig('ctpProjectKey1') + loadedConfig.default.getCtpConfig('ctpProjectKey1'), ).to.deep.equal({ clientId: 'clientId', clientSecret: 'clientSecret', @@ -200,7 +200,7 @@ describe('::config::', () => { projectKey: 'ctpProjectKey1', }) expect( - loadedConfig.default.getAdyenConfig('adyenMerchantAccount1') + loadedConfig.default.getAdyenConfig('adyenMerchantAccount1'), ).to.deep.equal({ enableHmacSignature: false, secretHmacKey: undefined, @@ -212,7 +212,7 @@ describe('::config::', () => { renameNotificationrcFile(tempFileName, notificationConfigFileName) process.env.ADYEN_INTEGRATION_CONFIG = originalAdyenConfig } - } + }, ) function renameNotificationrcFile(fileName, fileNameToRename) { diff --git a/notification/test/unit/ctp-client-mock.js b/notification/test/unit/ctp-client-mock.js index 2b7d4ed2e..259b160cf 100644 --- a/notification/test/unit/ctp-client-mock.js +++ b/notification/test/unit/ctp-client-mock.js @@ -86,7 +86,7 @@ function compareTransactionStates(currentState, newState) { ) throw Error( 'Wrong transaction state passed. ' + - `currentState: ${currentState}, newState: ${newState}` + `currentState: ${currentState}, newState: ${newState}`, ) if (transactionStateFlow[currentState] < transactionStateFlow[newState]) return 1 diff --git a/notification/test/unit/ensure-adyen-webhook.spec.js b/notification/test/unit/ensure-adyen-webhook.spec.js index e9fb1668c..bb34e633a 100644 --- a/notification/test/unit/ensure-adyen-webhook.spec.js +++ b/notification/test/unit/ensure-adyen-webhook.spec.js @@ -36,7 +36,7 @@ describe('verify ensure-adyen-webhook', () => { } nock( - `https://management-test.adyen.com/v1/merchants/${adyenMerchantAccount0}` + `https://management-test.adyen.com/v1/merchants/${adyenMerchantAccount0}`, ) .get('/webhooks') .reply(200, fetchWebhookResponse) diff --git a/notification/test/unit/google-function.spec.js b/notification/test/unit/google-function.spec.js index fbef0cff2..18ba2474a 100644 --- a/notification/test/unit/google-function.spec.js +++ b/notification/test/unit/google-function.spec.js @@ -86,7 +86,7 @@ describe('Google Function handler', () => { const result = await notificationTrigger(mockRequest, mockResponse) expect(result.responseStatus).to.equal(500) expect(result.responseBody).to.equal( - 'Object 62f05181-4789-47ce-84f8-d27c895ee23c has a different version than expected. Expected: 1 - Actual: 2.' + 'Object 62f05181-4789-47ce-84f8-d27c895ee23c has a different version than expected. Expected: 1 - Actual: 2.', ) const notificationItem = mockRequest.body.notificationItems.pop() @@ -95,7 +95,7 @@ describe('Google Function handler', () => { notification: utils.getNotificationForTracking(notificationItem), err: errorWrapper, }, - 'Unexpected exception occurred.' + 'Unexpected exception occurred.', ) } finally { getLogger().child = originalChildFn @@ -124,7 +124,7 @@ describe('Google Function handler', () => { notification: utils.getNotificationForTracking(notificationItem), err: error, }, - 'Unexpected exception occurred.' + 'Unexpected exception occurred.', ) } finally { getLogger().child = originalChildFn diff --git a/notification/test/unit/hmac-verification.spec.js b/notification/test/unit/hmac-verification.spec.js index fb6a7d0ba..1b8d38a5a 100644 --- a/notification/test/unit/hmac-verification.spec.js +++ b/notification/test/unit/hmac-verification.spec.js @@ -27,13 +27,13 @@ describe('verify hmac signatures', () => { const notification = createNotificationPayload( 'YOUR_PROJECT_KEY', 'YOUR_ADYEN_ACCOUNT', - `payment_${new Date().getTime()}` + `payment_${new Date().getTime()}`, ) const errorMessage = validateHmacSignature( - notification.notificationItems[0] + notification.notificationItems[0], ) expect(errorMessage).to.equal(null) - } + }, ) it( @@ -44,16 +44,16 @@ describe('verify hmac signatures', () => { const modifiedNotification = createNotificationPayload( 'YOUR_PROJECT_KEY', 'YOUR_ADYEN_ACCOUNT', - `payment_${new Date().getTime()}` + `payment_${new Date().getTime()}`, ).notificationItems[0] modifiedNotification.NotificationRequestItem.amount.value = 0 const errorMessage = validateHmacSignature(modifiedNotification) expect(errorMessage).to.equal( 'Notification does not have a valid HMAC signature, ' + - 'please confirm that the notification was sent by Adyen, and was not modified during transmission.' + 'please confirm that the notification was sent by Adyen, and was not modified during transmission.', ) - } + }, ) it( @@ -64,16 +64,16 @@ describe('verify hmac signatures', () => { const modifiedNotification = createNotificationPayload( 'YOUR_PROJECT_KEY', 'YOUR_ADYEN_ACCOUNT', - `payment_${new Date().getTime()}` + `payment_${new Date().getTime()}`, ).notificationItems[0] modifiedNotification.NotificationRequestItem.additionalData = null const errorMessage = validateHmacSignature(modifiedNotification) expect(errorMessage).to.equal( 'Notification does not contain the required field ' + - '"NotificationRequestItem.additionalData". Please check if HMAC is configured correctly or contact Adyen.' + '"NotificationRequestItem.additionalData". Please check if HMAC is configured correctly or contact Adyen.', ) - } + }, ) it( @@ -84,7 +84,7 @@ describe('verify hmac signatures', () => { const modifiedNotification = createNotificationPayload( 'YOUR_PROJECT_KEY', 'YOUR_ADYEN_ACCOUNT', - `payment_${new Date().getTime()}` + `payment_${new Date().getTime()}`, ).notificationItems[0] modifiedNotification.NotificationRequestItem.additionalData.hmacSignature = null @@ -93,8 +93,8 @@ describe('verify hmac signatures', () => { expect(errorMessage).to.equal( 'Notification does not contain the required field ' + '"NotificationRequestItem.additionalData.hmacSignature". ' + - 'Please check if HMAC is configured correctly or contact Adyen.' + 'Please check if HMAC is configured correctly or contact Adyen.', ) - } + }, ) }) diff --git a/notification/test/unit/lambda.spec.js b/notification/test/unit/lambda.spec.js index 070f262e3..41dc52208 100644 --- a/notification/test/unit/lambda.spec.js +++ b/notification/test/unit/lambda.spec.js @@ -89,7 +89,7 @@ describe('Lambda handler', () => { notification: utils.getNotificationForTracking(notificationItem), err: errorWrapper, }, - 'Unexpected error when processing event' + 'Unexpected error when processing event', ) } finally { logger.child = originalChildFn @@ -117,7 +117,7 @@ describe('Lambda handler', () => { notification: utils.getNotificationForTracking(notificationItem), err: error, }, - 'Unexpected error when processing event' + 'Unexpected error when processing event', ) } finally { logger.child = originalChildFn @@ -143,8 +143,8 @@ describe('Lambda handler', () => { .instanceOf(Error) .and(sinon.match.has('message', error.message)), }), - `Unexpected error when processing event` - ) + `Unexpected error when processing event`, + ), ) }) }) diff --git a/notification/test/unit/notification.controller.spec.js b/notification/test/unit/notification.controller.spec.js index 65a9a7792..edc8c669f 100644 --- a/notification/test/unit/notification.controller.spec.js +++ b/notification/test/unit/notification.controller.spec.js @@ -84,13 +84,13 @@ describe('notification controller', () => { expect(responseWriteHeadSpy.firstCall.firstArg).to.equal(200) expect(logSpy.calledOnce).to.be.true expect(responseEndSpy.firstCall.firstArg).to.equal( - JSON.stringify({ notificationResponse: '[accepted]' }) + JSON.stringify({ notificationResponse: '[accepted]' }), ) expect(cause.message).to.equal( 'Notification can not be processed as "metadata.ctProjectKey" was not found on the notification ' + - 'nor the path is containing the commercetools project key.' + 'nor the path is containing the commercetools project key.', ) - } + }, ) it('when adyenMerchantAccount is not configured, it should log error and return "accepted" status', async () => { @@ -130,11 +130,11 @@ describe('notification controller', () => { expect(responseWriteHeadSpy.firstCall.firstArg).to.equal(200) expect(logSpy.calledOnce).to.be.true expect(responseEndSpy.firstCall.firstArg).to.equal( - JSON.stringify({ notificationResponse: '[accepted]' }) + JSON.stringify({ notificationResponse: '[accepted]' }), ) expect(cause.message).to.equal( // eslint-disable-next-line max-len - 'Configuration for adyenMerchantAccount is not provided. Please update the configuration: "nonExistingMerchantAccount"' + 'Configuration for adyenMerchantAccount is not provided. Please update the configuration: "nonExistingMerchantAccount"', ) }) @@ -168,11 +168,11 @@ describe('notification controller', () => { expect(responseWriteHeadSpy.firstCall.firstArg).to.equal(200) expect(logSpy.calledOnce).to.be.true expect(responseEndSpy.firstCall.firstArg).to.equal( - JSON.stringify({ notificationResponse: '[accepted]' }) + JSON.stringify({ notificationResponse: '[accepted]' }), ) expect(cause.message).to.equal( - 'Configuration is not provided. Please update the configuration. ctpProjectKey: ["nonExistingCtpProjectKey"]' + 'Configuration is not provided. Please update the configuration. ctpProjectKey: ["nonExistingCtpProjectKey"]', ) }) @@ -182,7 +182,7 @@ describe('notification controller', () => { async () => { // prepare: const paymentMock = await utils.readAndParseJsonFile( - 'test/resources/payment-credit-card.json' + 'test/resources/payment-credit-card.json', ) const requestMock = { method: 'POST', @@ -234,10 +234,10 @@ describe('notification controller', () => { expect(logSpy.calledOnce).to.be.true expect(cause.body.message).to.equal( - 'Object 62f05181-4789-47ce-84f8-d27c895ee23c has a different version than expected. Expected: 1 - Actual: 2.' + 'Object 62f05181-4789-47ce-84f8-d27c895ee23c has a different version than expected. Expected: 1 - Actual: 2.', ) expect(responseWriteHeadSpy.firstCall.firstArg).to.equal(500) expect(responseEndSpy.firstCall.firstArg).to.equal(undefined) - } + }, ) }) diff --git a/notification/test/unit/notification.handler.spec.js b/notification/test/unit/notification.handler.spec.js index e5a31a496..1b12a9cad 100644 --- a/notification/test/unit/notification.handler.spec.js +++ b/notification/test/unit/notification.handler.spec.js @@ -26,10 +26,10 @@ describe('notification module', () => { before(async () => { paymentMock = await utils.readAndParseJsonFile( - 'test/resources/payment-credit-card.json' + 'test/resources/payment-credit-card.json', ) notification = await utils.readAndParseJsonFile( - 'test/resources/notification.json' + 'test/resources/notification.json', ) notificationsMock = notification.notificationItems overrideAdyenConfig({ @@ -101,7 +101,7 @@ describe('notification module', () => { await notificationHandler.processNotification( notifications[0], false, - config + config, ) if (config.getModuleConfig().removeSensitiveData) { delete notifications[0].NotificationRequestItem.additionalData @@ -150,7 +150,7 @@ describe('notification module', () => { expect(actualTransactionTimestamp).to.not.equal(undefined) expectedUpdateActions[2].timestamp = actualTransactionTimestamp expect(actualUpdateActionsWithoutCreatedAt).to.deep.equal( - expectedUpdateActions + expectedUpdateActions, ) }) @@ -204,7 +204,7 @@ describe('notification module', () => { await notificationHandler.processNotification( notifications[0], false, - config + config, ) if (config.getModuleConfig().removeSensitiveData) { delete notifications[0].NotificationRequestItem.additionalData @@ -235,7 +235,7 @@ describe('notification module', () => { const actualUpdateActionsWithoutCreatedAt = ctpClientUpdateSpy.args[0][3] delete actualUpdateActionsWithoutCreatedAt[0].fields.createdAt expect(actualUpdateActionsWithoutCreatedAt).to.deep.equal( - expectedUpdateActions + expectedUpdateActions, ) }) @@ -306,7 +306,7 @@ describe('notification module', () => { await notificationHandler.processNotification( notifications[0], false, - config + config, ) // assert expect(ctpClientUpdateSpy.callCount).to.equal(1) @@ -314,7 +314,7 @@ describe('notification module', () => { const actualUpdateActionsWithoutCreatedAt = ctpClientUpdateSpy.args[0][3] expect(actualUpdateActionsWithoutCreatedAt).to.deep.equal( - expectedUpdateActions + expectedUpdateActions, ) }) @@ -367,7 +367,7 @@ describe('notification module', () => { await notificationHandler.processNotification( notifications[0], false, - config + config, ) if (config.getModuleConfig().removeSensitiveData) { delete notifications[0].NotificationRequestItem.additionalData @@ -414,7 +414,7 @@ describe('notification module', () => { expect(actualTransactionTimestamp).to.not.equal(undefined) expectedUpdateActions[1].transaction.timestamp = actualTransactionTimestamp expect(actualUpdateActionsWithoutCreatedAt).to.deep.equal( - expectedUpdateActions + expectedUpdateActions, ) }) @@ -467,7 +467,7 @@ describe('notification module', () => { await notificationHandler.processNotification( notifications[0], false, - config + config, ) if (config.getModuleConfig().removeSensitiveData) { delete notifications[0].NotificationRequestItem.additionalData @@ -514,7 +514,7 @@ describe('notification module', () => { expect(actualTransactionTimestamp).to.not.equal(undefined) expectedUpdateActions[1].transaction.timestamp = actualTransactionTimestamp expect(actualUpdateActionsWithoutCreatedAt).to.deep.equal( - expectedUpdateActions + expectedUpdateActions, ) }) @@ -567,7 +567,7 @@ describe('notification module', () => { await notificationHandler.processNotification( notifications[0], false, - config + config, ) if (config.getModuleConfig().removeSensitiveData) { delete notifications[0].NotificationRequestItem.additionalData @@ -615,7 +615,7 @@ describe('notification module', () => { expect(actualTransactionTimestamp).to.not.equal(undefined) expectedUpdateActions[1].transaction.timestamp = actualTransactionTimestamp expect(actualUpdateActionsWithoutCreatedAt).to.deep.equal( - expectedUpdateActions + expectedUpdateActions, ) }) @@ -677,7 +677,7 @@ describe('notification module', () => { await notificationHandler.processNotification( notifications[0], false, - config + config, ) if (config.getModuleConfig().removeSensitiveData) { delete notifications[0].NotificationRequestItem.additionalData @@ -753,7 +753,7 @@ describe('notification module', () => { await notificationHandler.processNotification( notificationsMock[0], false, - config + config, ) } catch (e) { // we check retry logic here and it should throw after certain amount @@ -821,16 +821,16 @@ describe('notification module', () => { await notificationHandler.processNotification( notifications[0], false, - config + config, ) expect(ctpClientUpdateSpy.args[0][3][0].fields.notification).to.include( - 'additionalData' + 'additionalData', ) expect(ctpClientUpdateSpy.args[0][3][0].fields.notification).to.include( - 'reason' + 'reason', ) - } + }, ) it( @@ -889,16 +889,16 @@ describe('notification module', () => { await notificationHandler.processNotification( notifications[0], false, - config + config, ) expect( - ctpClientUpdateSpy.args[0][3][0].fields.notification + ctpClientUpdateSpy.args[0][3][0].fields.notification, ).to.not.include('additionalData') expect( - ctpClientUpdateSpy.args[0][3][0].fields.notification + ctpClientUpdateSpy.args[0][3][0].fields.notification, ).to.not.include('reason') - } + }, ) it(`given that unexpected error occurs when get payment By merchant reference @@ -950,14 +950,14 @@ describe('notification module', () => { await notificationHandler.processNotification( notifications[0], false, - config + config, ) } catch (e) { error = e } expect(error instanceof VError).to.equal(true) expect(error.message).to.contains( - 'Failed to fetch a payment with merchantReference' + 'Failed to fetch a payment with merchantReference', ) }) })