Skip to content

Commit

Permalink
refactor: rename mollie card component flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Tung-Huynh-Shopmacher committed Jul 30, 2024
1 parent f01a6de commit 5231592
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion connect.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion processor/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ CTP_API_URL=https://api.<YOUR_CTP_REGION>.commercetools.com
DEBUG=<INTEGER_VALUE> ## Either 1 for enable or 0 for disable
MOLLIE_API_KEY=<YOUR_MOLLIE_API_KEY>
MOLLIE_PROFILE_ID=<YOUR_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=<YOUR_NGROK_AUTH_TOKEN>
2 changes: 1 addition & 1 deletion processor/.env.jest
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion processor/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion processor/src/service/payment.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 : '',
),
);
}
Expand Down
2 changes: 1 addition & 1 deletion processor/src/types/index.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ export type ConnectorEnvVars = {
apiKey: string;
profileId: string;
debug: string;
enableCardComponent: string;
cardComponent: string;
};
};
2 changes: 1 addition & 1 deletion processor/src/utils/config.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
};

Expand Down
2 changes: 1 addition & 1 deletion processor/src/validators/env.validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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".',
Expand Down
6 changes: 3 additions & 3 deletions processor/tests/utils/config.utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
});
});
Expand Down Expand Up @@ -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);
});
});
2 changes: 1 addition & 1 deletion processor/tests/validators/env.validators.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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".',
Expand Down
4 changes: 2 additions & 2 deletions processor/tests/validators/helpers.validators.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 5231592

Please sign in to comment.