Skip to content

Commit

Permalink
Rename debug
Browse files Browse the repository at this point in the history
Add uuid
  • Loading branch information
Tung-Huynh-Shopmacher committed Jul 18, 2024
1 parent 776df25 commit 751d7cf
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 19 deletions.
4 changes: 2 additions & 2 deletions connect.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ deployAs:
description: Commercetools Composable Commerce API region
required: true
default: "europe-west1.gcp"
- key: MOLLIE_DEBUG
description: Mollie PSP debug mode
- key: DEBUG
description: Debug mode (0 or 1)
required: false
default: "0"
securedConfiguration:
Expand Down
2 changes: 1 addition & 1 deletion processor/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ CTP_AUTH_URL=https://auth.<YOUR_CTP_REGION>.commercetools.com
CTP_API_URL=https://api.<YOUR_CTP_REGION>.commercetools.com

## Mollie PSP credentials
MOLLIE_DEBUG=<INTEGER_VALUE> ## Either 1 for enable or 0 for disable
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>

Expand Down
2 changes: 1 addition & 1 deletion processor/.env.jest
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ CTP_REGION=europe-west1.gcp
## MOLLIE vars
MOLLIE_API_KEY=12345678901234567890123456789012
MOLLIE_PROFILE_ID=pfl_12345
MOLLIE_DEBUG=1
DEBUG=0
25 changes: 19 additions & 6 deletions processor/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 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.10",
"version": "0.0.11",
"main": "index.js",
"private": true,
"scripts": {
Expand Down Expand Up @@ -70,6 +70,7 @@
"dotenv": "^16.4.5",
"express": "^4.19.2",
"proxy-from-env": "^1.1.0",
"uuid": "^10.0.0",
"validator": "^13.12.0"
}
}
2 changes: 1 addition & 1 deletion processor/src/utils/config.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const readConfiguration = () => {
},
mollie: {
apiKey: process.env.MOLLIE_API_KEY as string,
debug: process.env.MOLLIE_DEBUG as string,
debug: process.env.DEBUG as string,
profileId: process.env.MOLLIE_PROFILE_ID as string,
},
};
Expand Down
4 changes: 2 additions & 2 deletions processor/src/validators/payment.validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ export const hasValidPaymentMethod: (method: string | undefined) => boolean = (m
/**
* Checks the payment method input of a Commercetools Payment object.
*
* @param {CTPayment} CTPayment - The Commercetools Payment object to check.
* @return {true | CustomError} An object containing the validation result.
* The `isInvalid` property indicates if the payment method input is invalid.
* The `errorMessage` property contains the error message if the input is invalid.
* @param ctPayment
*/
export const checkPaymentMethodInput = (ctPayment: CTPayment): true | CustomError => {
const CTPaymentMethod = ctPayment.paymentMethodInfo?.method ?? '';
Expand Down Expand Up @@ -137,7 +137,7 @@ export const validateCommerceToolsPaymentPayload = (action: string, ctPayment: C

checkPaymentInterface(ctPayment);

checkPaymentMethodInput(ctPayment);
// checkPaymentMethodInput(ctPayment);

checkAmountPlanned(ctPayment);
};
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 @@ -15,7 +15,7 @@ describe('Test src/utils/config.utils.ts', () => {
},
mollie: {
apiKey: process.env.MOLLIE_API_KEY,
debug: process.env.MOLLIE_DEBUG,
debug: process.env.DEBUG,
profileId: process.env.MOLLIE_PROFILE_ID,
},
});
Expand Down Expand Up @@ -51,8 +51,8 @@ describe('Test src/utils/config.utils.ts', () => {
expect(() => readConfiguration()).toThrow(CustomError);
});

test('should throw an error when MOLLIE_DEBUG is not defined', () => {
delete process.env.MOLLIE_DEBUG;
test('should throw an error when DEBUG is not defined', () => {
delete process.env.DEBUG;
expect(() => readConfiguration()).toThrow(CustomError);
});
});
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 @@ -234,7 +234,7 @@ describe('Test helpers.validators.ts', () => {
},
mollie: {
apiKey: process.env.MOLLIE_API_KEY as string,
debug: (process.env.MOLLIE_DEBUG ?? '0') as string,
debug: (process.env.DEBUG ?? '0') as string,
profileId: process.env.MOLLIE_PROFILE_ID as string,
},
};
Expand All @@ -254,7 +254,7 @@ describe('Test helpers.validators.ts', () => {
},
mollie: {
apiKey: process.env.MOLLIE_API_KEY as string,
debug: (process.env.MOLLIE_DEBUG ?? '0') as string,
debug: (process.env.DEBUG ?? '0') as string,
profileId: process.env.MOLLIE_PROFILE_ID as string,
},
};
Expand Down

0 comments on commit 751d7cf

Please sign in to comment.