diff --git a/connect.yaml b/connect.yaml index a8e7d32..cb0d9e9 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: ENABLE_MOLLIE_CARD_COMPONENT + - key: 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 4ba0f38..f91a487 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= -ENABLE_MOLLIE_CARD_COMPONENT=0 ## Either 1 for enable or 0 for disable +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 89d754f..e590678 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 -ENABLE_MOLLIE_CARD_COMPONENT=0 +MOLLIE_CARD_COMPONENT=0 CONNECT_SERVICE_URL=http://localhost:3000/processor diff --git a/processor/package.json b/processor/package.json index 111cff2..8da67b8 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.19", + "version": "0.0.20", "main": "index.js", "private": true, "scripts": { diff --git a/processor/src/service/payment.service.ts b/processor/src/service/payment.service.ts index 833164b..c17fb68 100644 --- a/processor/src/service/payment.service.ts +++ b/processor/src/service/payment.service.ts @@ -69,7 +69,7 @@ export const handleListPaymentMethodsByPayment = async (ctPayment: Payment): Pro ctUpdateActions.push( setCustomFields( CustomFields.payment.profileId, - toBoolean(readConfiguration().mollie.enableCardComponent, true) ? readConfiguration().mollie.profileId : '', + toBoolean(readConfiguration().mollie.cardComponent, true) ? readConfiguration().mollie.profileId : '', ), ); } diff --git a/processor/src/types/index.types.ts b/processor/src/types/index.types.ts index 06793ae..a0a8320 100644 --- a/processor/src/types/index.types.ts +++ b/processor/src/types/index.types.ts @@ -26,6 +26,6 @@ export type ConnectorEnvVars = { apiKey: string; profileId: string; debug: string; - enableCardComponent: string; + cardComponent: string; }; }; diff --git a/processor/src/utils/config.utils.ts b/processor/src/utils/config.utils.ts index 1e6c663..08cd5f7 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.ENABLE_MOLLIE_CARD_COMPONENT as string, + cardComponent: process.env.MOLLIE_CARD_COMPONENT as string, }, }; diff --git a/processor/src/validators/env.validators.ts b/processor/src/validators/env.validators.ts index 3b0d8a1..6e6c124 100644 --- a/processor/src/validators/env.validators.ts +++ b/processor/src/validators/env.validators.ts @@ -72,7 +72,7 @@ const envValidators = [ ), standardString( - ['mollie', 'enableCardComponent'], + ['mollie', 'cardComponent'], { code: 'InvalidEnableCardComponent', message: 'Enable Mollie card component should be a valid string of either "0" or "1".', diff --git a/processor/tests/utils/config.utils.spec.ts b/processor/tests/utils/config.utils.spec.ts index b4e54f0..06f26b3 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.ENABLE_MOLLIE_CARD_COMPONENT, + cardComponent: process.env.MOLLIE_CARD_COMPONENT, }, }); }); @@ -57,8 +57,8 @@ describe('Test src/utils/config.utils.ts', () => { expect(() => readConfiguration()).toThrow(CustomError); }); - test('should throw an error when ENABLE_MOLLIE_CARD_COMPONENT is not defined', () => { - delete process.env.ENABLE_MOLLIE_CARD_COMPONENT; + test('should throw an error when MOLLIE_CARD_COMPONENT is not defined', () => { + delete process.env.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 2b681fa..444b752 100644 --- a/processor/tests/validators/env.validators.spec.ts +++ b/processor/tests/validators/env.validators.spec.ts @@ -103,7 +103,7 @@ describe('Test env.validators.ts', () => { index1: 8, index2: 0, field1: 'mollie', - field2: 'enableCardComponent', + field2: 'cardComponent', error: { code: 'InvalidEnableCardComponent', message: 'Enable Mollie card component should be a valid string of either "0" or "1".', diff --git a/processor/tests/validators/helpers.validators.spec.ts b/processor/tests/validators/helpers.validators.spec.ts index 3a295df..b33c541 100644 --- a/processor/tests/validators/helpers.validators.spec.ts +++ b/processor/tests/validators/helpers.validators.spec.ts @@ -236,7 +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, + cardComponent: (process.env.MOLLIE_CARD_COMPONENT ?? '0') as string, }, }; const error = getValidateMessages(envValidators, vars); @@ -257,7 +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, + cardComponent: (process.env.MOLLIE_CARD_COMPONENT ?? '0') as string, }, }; const error = getValidateMessages(envValidators, vars);