From a03a9f859a13b1d5ffc5cc0b62744f3c92536d39 Mon Sep 17 00:00:00 2001 From: Win Date: Thu, 25 Jul 2024 18:08:08 +0700 Subject: [PATCH 1/5] MOL-134/PICT-214: implement setting for enabling Mollie card component --- connect.yaml | 4 + processor/.env.example | 1 + processor/.env.jest | 1 + processor/bin/ngrok.sh | 2 +- processor/package-lock.json | 76 +------------------ processor/src/service/payment.service.ts | 12 ++- processor/src/types/index.types.ts | 3 +- processor/src/utils/config.utils.ts | 3 +- processor/src/validators/env.validators.ts | 19 ++++- processor/tests/utils/config.utils.spec.ts | 8 +- .../tests/validators/env.validators.spec.ts | 16 +++- .../validators/helpers.validators.spec.ts | 2 + 12 files changed, 61 insertions(+), 86 deletions(-) diff --git a/connect.yaml b/connect.yaml index 94a1286..621248c 100644 --- a/connect.yaml +++ b/connect.yaml @@ -11,6 +11,10 @@ deployAs: description: Commercetools Composable Commerce API region required: true default: "europe-west1.gcp" + - key: ENBALE_MOLLIE_CARD_COMPONENT + description: Enable Mollie cart component (0 or 1) + required: true + default: "0" - key: DEBUG description: Debug mode (0 or 1) required: false diff --git a/processor/.env.example b/processor/.env.example index 631be2e..2f1a26a 100644 --- a/processor/.env.example +++ b/processor/.env.example @@ -13,6 +13,7 @@ CTP_API_URL=https://api..commercetools.com DEBUG= ## Either 1 for enable or 0 for disable MOLLIE_API_KEY= MOLLIE_PROFILE_ID= +ENBALE_MOLLIE_CARD_COMPONENT=0 ## Either 1 for enable or 0 for disable ## NGROK CONNECTOR_EXTENSION_TOKEN= diff --git a/processor/.env.jest b/processor/.env.jest index b8d116f..8199a0a 100644 --- a/processor/.env.jest +++ b/processor/.env.jest @@ -9,5 +9,6 @@ CTP_REGION=europe-west1.gcp MOLLIE_API_KEY=12345678901234567890123456789012 MOLLIE_PROFILE_ID=pfl_12345 DEBUG=0 +ENBALE_MOLLIE_CARD_COMPONENT=0 CONNECT_SERVICE_URL=http://localhost:3000/processor diff --git a/processor/bin/ngrok.sh b/processor/bin/ngrok.sh index fb5857b..48b9057 100755 --- a/processor/bin/ngrok.sh +++ b/processor/bin/ngrok.sh @@ -12,7 +12,7 @@ fi # Start NGROK in background echo "⚡️ Starting ngrok" -ngrok http 8889 --authtoken ${CONNECTOR_EXTENSION_TOKEN} > /dev/null & +ngrok http 8080 --authtoken ${CONNECTOR_EXTENSION_TOKEN} > /dev/null & # Wait for ngrok to be available while ! nc -z localhost 4040; do diff --git a/processor/package-lock.json b/processor/package-lock.json index de27807..c665cf9 100644 --- a/processor/package-lock.json +++ b/processor/package-lock.json @@ -1,12 +1,12 @@ { "name": "shopmacher-mollie-processor", - "version": "0.0.13", + "version": "0.0.16", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "shopmacher-mollie-processor", - "version": "0.0.13", + "version": "0.0.16", "hasInstallScript": true, "license": "MIT", "dependencies": { @@ -2037,11 +2037,6 @@ "node": ">=0.10.0" } }, - "node_modules/color/node_modules/color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==" - }, "node_modules/jest-validate": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/jest-validate/-/jest-validate-29.7.0.tgz", @@ -2098,18 +2093,6 @@ "integrity": "sha512-xiNMgCuoy4mCL4JTywk9XFs5xpRUcKxtWEcMR6FNMtsgewYTIgIR+nvlP4A4iRCAzRsHMnPhvTRrzp4AGcRTEA==", "dev": true }, - "node_modules/pkg-dir/node_modules/locate-path": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", - "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", - "dev": true, - "dependencies": { - "p-locate": "^4.1.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/update-browserslist-db": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.0.tgz", @@ -2235,15 +2218,6 @@ "node": ">=10" } }, - "node_modules/@istanbuljs/load-nyc-config/node_modules/argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "dev": true, - "dependencies": { - "sprintf-js": "~1.0.2" - } - }, "node_modules/jest-cli": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/jest-cli/-/jest-cli-29.7.0.tgz", @@ -3205,14 +3179,6 @@ "semver": "bin/semver.js" } }, - "node_modules/winston-transport/node_modules/@colors/colors": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.6.0.tgz", - "integrity": "sha512-Ir+AOibqzrIsL6ajt3Rz3LskB7OiMVHqltZmspbW/TJuTVuyOMirVqAkjfY6JISiLHgyNqicAC8AyHHGzNd/dA==", - "engines": { - "node": ">=0.1.90" - } - }, "node_modules/eastasianwidth": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", @@ -4594,11 +4560,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/express/node_modules/ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" - }, "node_modules/define-properties": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.1.tgz", @@ -4902,18 +4863,6 @@ "@babel/core": "^7.0.0-0" } }, - "node_modules/pkg-dir/node_modules/p-locate": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", - "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", - "dev": true, - "dependencies": { - "p-limit": "^2.2.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", @@ -6579,21 +6528,6 @@ "node": ">= 0.6" } }, - "node_modules/pkg-dir/node_modules/p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", - "dev": true, - "dependencies": { - "p-try": "^2.0.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/ngrok": { "version": "5.0.0-beta.2", "resolved": "https://registry.npmjs.org/ngrok/-/ngrok-5.0.0-beta.2.tgz", @@ -7754,12 +7688,6 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", - "dev": true - }, "node_modules/supports-color": { "version": "8.1.1", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", diff --git a/processor/src/service/payment.service.ts b/processor/src/service/payment.service.ts index 7963d9c..49506eb 100644 --- a/processor/src/service/payment.service.ts +++ b/processor/src/service/payment.service.ts @@ -35,6 +35,7 @@ import { setTransactionCustomField, } from '../commercetools/action.commercetools'; import { readConfiguration } from '../utils/config.utils'; +import { toBoolean } from 'validator'; import { CancelParameters, CreateParameters, @@ -59,10 +60,15 @@ export const handleListPaymentMethodsByPayment = async (ctPayment: Payment): Pro const ctUpdateActions: UpdateAction[] = [setCustomFields(CustomFields.payment.response, availableMethods)]; - const hasCardPayment = methods.find((method: Method) => method.id === PaymentMethod.creditcard); + const hasCardPayment = methods.findIndex((method: Method) => method.id === PaymentMethod.creditcard); - if (hasCardPayment) { - ctUpdateActions.push(setCustomFields(CustomFields.payment.profileId, readConfiguration().mollie.profileId)); + if (hasCardPayment >= 0) { + ctUpdateActions.push( + setCustomFields( + CustomFields.payment.profileId, + toBoolean(readConfiguration().mollie.enableCardComponent, true) ? readConfiguration().mollie.profileId : '', + ), + ); } return { diff --git a/processor/src/types/index.types.ts b/processor/src/types/index.types.ts index 7571879..06793ae 100644 --- a/processor/src/types/index.types.ts +++ b/processor/src/types/index.types.ts @@ -25,6 +25,7 @@ export type ConnectorEnvVars = { mollie: { apiKey: string; profileId: string; - debug?: string; + debug: string; + enableCardComponent: string; }; }; diff --git a/processor/src/utils/config.utils.ts b/processor/src/utils/config.utils.ts index 6414c64..da02a68 100644 --- a/processor/src/utils/config.utils.ts +++ b/processor/src/utils/config.utils.ts @@ -21,6 +21,7 @@ export const readConfiguration = () => { apiKey: process.env.MOLLIE_API_KEY as string, debug: process.env.DEBUG as string, profileId: process.env.MOLLIE_PROFILE_ID as string, + enableCardComponent: process.env.ENBALE_MOLLIE_CARD_COMPONENT as string, }, }; @@ -29,7 +30,7 @@ export const readConfiguration = () => { if (validationErrors.length) { throw new CustomError( 'InvalidEnvironmentVariablesError', - 'Invalid Environment Variables please check your .env file', + 'Invalid Environment Variables please check your .env file. Details: ' + JSON.stringify(validationErrors), ); } diff --git a/processor/src/validators/env.validators.ts b/processor/src/validators/env.validators.ts index 3f6451e..3b0d8a1 100644 --- a/processor/src/validators/env.validators.ts +++ b/processor/src/validators/env.validators.ts @@ -58,16 +58,29 @@ const envValidators = [ referencedBy: 'environmentVariables', }), - optional(standardString)( + standardString( ['mollie', 'debug'], { code: 'InvalidDebug', - message: 'Mollie debug should be a valid string.', + message: 'Mollie debug should be a valid string of either "0" or "1".', + referencedBy: 'environmentVariables', + }, + { + min: 1, + max: 1, + }, + ), + + standardString( + ['mollie', 'enableCardComponent'], + { + code: 'InvalidEnableCardComponent', + message: 'Enable Mollie card component should be a valid string of either "0" or "1".', referencedBy: 'environmentVariables', }, { min: 1, - max: undefined, + max: 1, }, ), ]; diff --git a/processor/tests/utils/config.utils.spec.ts b/processor/tests/utils/config.utils.spec.ts index 1e9fc90..42c24f8 100644 --- a/processor/tests/utils/config.utils.spec.ts +++ b/processor/tests/utils/config.utils.spec.ts @@ -3,7 +3,7 @@ import CustomError from '../../src/errors/custom.error'; import { describe, expect, test } from '@jest/globals'; describe('Test src/utils/config.utils.ts', () => { - it('should return the correct configuration when all env vars are valid', () => { + test('should return the correct configuration when all env vars are valid', () => { const config = readConfiguration(); expect(config).toEqual({ commerceTools: { @@ -17,6 +17,7 @@ describe('Test src/utils/config.utils.ts', () => { apiKey: process.env.MOLLIE_API_KEY, debug: process.env.DEBUG, profileId: process.env.MOLLIE_PROFILE_ID, + enableCardComponent: process.env.ENBALE_MOLLIE_CARD_COMPONENT, }, }); }); @@ -55,4 +56,9 @@ describe('Test src/utils/config.utils.ts', () => { delete process.env.DEBUG; expect(() => readConfiguration()).toThrow(CustomError); }); + + test('should throw an error when ENBALE_MOLLIE_CARD_COMPONENT is not defined', () => { + delete process.env.ENBALE_MOLLIE_CARD_COMPONENT; + expect(() => readConfiguration()).toThrow(CustomError); + }); }); diff --git a/processor/tests/validators/env.validators.spec.ts b/processor/tests/validators/env.validators.spec.ts index ed4ed34..2b681fa 100644 --- a/processor/tests/validators/env.validators.spec.ts +++ b/processor/tests/validators/env.validators.spec.ts @@ -94,10 +94,22 @@ describe('Test env.validators.ts', () => { field2: 'debug', error: { code: 'InvalidDebug', - message: 'Mollie debug should be a valid string.', + message: 'Mollie debug should be a valid string of either "0" or "1".', referencedBy: 'environmentVariables', }, - condition: { min: 1, max: undefined }, + condition: { min: 1, max: 1 }, + }, + { + index1: 8, + index2: 0, + field1: 'mollie', + field2: 'enableCardComponent', + error: { + code: 'InvalidEnableCardComponent', + message: 'Enable Mollie card component should be a valid string of either "0" or "1".', + referencedBy: 'environmentVariables', + }, + condition: { min: 1, max: 1 }, }, ])( 'should return the correct validation array contains [%s, %s]', diff --git a/processor/tests/validators/helpers.validators.spec.ts b/processor/tests/validators/helpers.validators.spec.ts index 2fe7299..3a295df 100644 --- a/processor/tests/validators/helpers.validators.spec.ts +++ b/processor/tests/validators/helpers.validators.spec.ts @@ -236,6 +236,7 @@ describe('Test helpers.validators.ts', () => { apiKey: process.env.MOLLIE_API_KEY as string, debug: (process.env.DEBUG ?? '0') as string, profileId: process.env.MOLLIE_PROFILE_ID as string, + enableCardComponent: (process.env.ENABLE_CARD_COMPONENT ?? '0') as string, }, }; const error = getValidateMessages(envValidators, vars); @@ -256,6 +257,7 @@ describe('Test helpers.validators.ts', () => { apiKey: process.env.MOLLIE_API_KEY as string, debug: (process.env.DEBUG ?? '0') as string, profileId: process.env.MOLLIE_PROFILE_ID as string, + enableCardComponent: (process.env.ENABLE_CARD_COMPONENT ?? '0') as string, }, }; const error = getValidateMessages(envValidators, vars); From 5d7c092bbfd716d6b2ee38cdd6c1b9fd35eb20d0 Mon Sep 17 00:00:00 2001 From: Win Date: Fri, 26 Jul 2024 10:37:17 +0700 Subject: [PATCH 2/5] MOL-134/PICT-214: add version --- processor/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/processor/package.json b/processor/package.json index b3e675e..7c842bb 100644 --- a/processor/package.json +++ b/processor/package.json @@ -1,7 +1,7 @@ { "name": "shopmacher-mollie-processor", "description": "Integration between commercetools and mollie payment service provider", - "version": "0.0.16", + "version": "0.0.18", "main": "index.js", "private": true, "scripts": { From 34bb3f0882a1afe66a525c6200d8c13622e0fe59 Mon Sep 17 00:00:00 2001 From: Win Date: Mon, 29 Jul 2024 13:38:08 +0700 Subject: [PATCH 3/5] [Update] package version --- processor/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/processor/package.json b/processor/package.json index 7c842bb..111cff2 100644 --- a/processor/package.json +++ b/processor/package.json @@ -1,7 +1,7 @@ { "name": "shopmacher-mollie-processor", "description": "Integration between commercetools and mollie payment service provider", - "version": "0.0.18", + "version": "0.0.19", "main": "index.js", "private": true, "scripts": { From a1ae457ead2d88787ef8b1c8d5f432fb8467a75f Mon Sep 17 00:00:00 2001 From: Win Date: Mon, 29 Jul 2024 13:48:02 +0700 Subject: [PATCH 4/5] [Update] package version --- processor/package-lock.json | 76 ++++++++++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 2 deletions(-) diff --git a/processor/package-lock.json b/processor/package-lock.json index c665cf9..84c10dc 100644 --- a/processor/package-lock.json +++ b/processor/package-lock.json @@ -1,12 +1,12 @@ { "name": "shopmacher-mollie-processor", - "version": "0.0.16", + "version": "0.0.19", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "shopmacher-mollie-processor", - "version": "0.0.16", + "version": "0.0.19", "hasInstallScript": true, "license": "MIT", "dependencies": { @@ -2037,6 +2037,11 @@ "node": ">=0.10.0" } }, + "node_modules/color/node_modules/color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==" + }, "node_modules/jest-validate": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/jest-validate/-/jest-validate-29.7.0.tgz", @@ -2093,6 +2098,18 @@ "integrity": "sha512-xiNMgCuoy4mCL4JTywk9XFs5xpRUcKxtWEcMR6FNMtsgewYTIgIR+nvlP4A4iRCAzRsHMnPhvTRrzp4AGcRTEA==", "dev": true }, + "node_modules/pkg-dir/node_modules/locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "dependencies": { + "p-locate": "^4.1.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/update-browserslist-db": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.0.tgz", @@ -2218,6 +2235,15 @@ "node": ">=10" } }, + "node_modules/@istanbuljs/load-nyc-config/node_modules/argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "dependencies": { + "sprintf-js": "~1.0.2" + } + }, "node_modules/jest-cli": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/jest-cli/-/jest-cli-29.7.0.tgz", @@ -3179,6 +3205,14 @@ "semver": "bin/semver.js" } }, + "node_modules/winston-transport/node_modules/@colors/colors": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.6.0.tgz", + "integrity": "sha512-Ir+AOibqzrIsL6ajt3Rz3LskB7OiMVHqltZmspbW/TJuTVuyOMirVqAkjfY6JISiLHgyNqicAC8AyHHGzNd/dA==", + "engines": { + "node": ">=0.1.90" + } + }, "node_modules/eastasianwidth": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", @@ -4560,6 +4594,11 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/express/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" + }, "node_modules/define-properties": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.1.tgz", @@ -4863,6 +4902,18 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/pkg-dir/node_modules/p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "dependencies": { + "p-limit": "^2.2.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", @@ -6528,6 +6579,21 @@ "node": ">= 0.6" } }, + "node_modules/pkg-dir/node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/ngrok": { "version": "5.0.0-beta.2", "resolved": "https://registry.npmjs.org/ngrok/-/ngrok-5.0.0-beta.2.tgz", @@ -7688,6 +7754,12 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", + "dev": true + }, "node_modules/supports-color": { "version": "8.1.1", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", From 5bdcf4d8344ada754d8b9a58a40796b1e22706bf Mon Sep 17 00:00:00 2001 From: Win Date: Mon, 29 Jul 2024 14:47:05 +0700 Subject: [PATCH 5/5] MOL-134/PICT-214: fix wrong wording --- connect.yaml | 2 +- processor/.env.example | 2 +- processor/.env.jest | 2 +- processor/src/utils/config.utils.ts | 2 +- processor/tests/utils/config.utils.spec.ts | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/connect.yaml b/connect.yaml index 621248c..a8e7d32 100644 --- a/connect.yaml +++ b/connect.yaml @@ -11,7 +11,7 @@ deployAs: description: Commercetools Composable Commerce API region required: true default: "europe-west1.gcp" - - key: ENBALE_MOLLIE_CARD_COMPONENT + - key: ENABLE_MOLLIE_CARD_COMPONENT description: Enable Mollie cart component (0 or 1) required: true default: "0" diff --git a/processor/.env.example b/processor/.env.example index 2f1a26a..4ba0f38 100644 --- a/processor/.env.example +++ b/processor/.env.example @@ -13,7 +13,7 @@ CTP_API_URL=https://api..commercetools.com DEBUG= ## Either 1 for enable or 0 for disable MOLLIE_API_KEY= MOLLIE_PROFILE_ID= -ENBALE_MOLLIE_CARD_COMPONENT=0 ## Either 1 for enable or 0 for disable +ENABLE_MOLLIE_CARD_COMPONENT=0 ## Either 1 for enable or 0 for disable ## NGROK CONNECTOR_EXTENSION_TOKEN= diff --git a/processor/.env.jest b/processor/.env.jest index 8199a0a..89d754f 100644 --- a/processor/.env.jest +++ b/processor/.env.jest @@ -9,6 +9,6 @@ CTP_REGION=europe-west1.gcp MOLLIE_API_KEY=12345678901234567890123456789012 MOLLIE_PROFILE_ID=pfl_12345 DEBUG=0 -ENBALE_MOLLIE_CARD_COMPONENT=0 +ENABLE_MOLLIE_CARD_COMPONENT=0 CONNECT_SERVICE_URL=http://localhost:3000/processor diff --git a/processor/src/utils/config.utils.ts b/processor/src/utils/config.utils.ts index da02a68..1e6c663 100644 --- a/processor/src/utils/config.utils.ts +++ b/processor/src/utils/config.utils.ts @@ -21,7 +21,7 @@ export const readConfiguration = () => { apiKey: process.env.MOLLIE_API_KEY as string, debug: process.env.DEBUG as string, profileId: process.env.MOLLIE_PROFILE_ID as string, - enableCardComponent: process.env.ENBALE_MOLLIE_CARD_COMPONENT as string, + enableCardComponent: process.env.ENABLE_MOLLIE_CARD_COMPONENT as string, }, }; diff --git a/processor/tests/utils/config.utils.spec.ts b/processor/tests/utils/config.utils.spec.ts index 42c24f8..b4e54f0 100644 --- a/processor/tests/utils/config.utils.spec.ts +++ b/processor/tests/utils/config.utils.spec.ts @@ -17,7 +17,7 @@ describe('Test src/utils/config.utils.ts', () => { apiKey: process.env.MOLLIE_API_KEY, debug: process.env.DEBUG, profileId: process.env.MOLLIE_PROFILE_ID, - enableCardComponent: process.env.ENBALE_MOLLIE_CARD_COMPONENT, + enableCardComponent: process.env.ENABLE_MOLLIE_CARD_COMPONENT, }, }); }); @@ -57,8 +57,8 @@ describe('Test src/utils/config.utils.ts', () => { expect(() => readConfiguration()).toThrow(CustomError); }); - test('should throw an error when ENBALE_MOLLIE_CARD_COMPONENT is not defined', () => { - delete process.env.ENBALE_MOLLIE_CARD_COMPONENT; + test('should throw an error when ENABLE_MOLLIE_CARD_COMPONENT is not defined', () => { + delete process.env.ENABLE_MOLLIE_CARD_COMPONENT; expect(() => readConfiguration()).toThrow(CustomError); }); });