The notifications module works in tandem with the API Extension. It assumes this commercetools project is set up with the correct custom types, as described in API Extension's installation guide.
Commercetools Mollie integration requires one environment variable to start. This environment variable name is CT_MOLLIE_CONFIG
and it must have its keys as a JSON structure.
Here is a table to show which environment variables are necessary, and which are optional:
Env variable name | Required | Notes |
---|---|---|
mollie |
YES | Contains Mollie-specific project variables |
apiKey |
YES | API key for interacting with mollie |
commercetools |
YES | Contains commercetools-specific project variables |
projectKey |
YES | Commercetools project key |
clientId |
YES | Commercetools client id, unique to the client |
clientSecret |
YES | Commercetools client secret, unique to the client |
authUrl |
YES | Commercetools authentication URL, something like https://auth.{LOCATION}.{CLOUD_PLATFORM}.commercetools.com |
host |
YES | Commercetools host, something like https://api.{LOCATION}.{CLOUD_PLATFORM}.commercetools.com |
scopes |
YES | Constrains endpoints the client has access to in commercetools. There MUST be a perfect match between the list of scopes provided to the user and those listed in the configurations. |
service |
NO | Contains service-specific project variables |
port |
NO | Which port notifications should run on |
logLevel |
NO | Specifies how verbose logs should be. Options are listed below. |
logTransports |
NO | Specifies where the logs are written to/stored. Options listed below |
Below is an example of how these should be formatted:
"CT_MOLLIE_CONFIG": {
"mollie": {
"apiKey": "mollieApiKey"
},
"commercetools": {
"projectKey": "example_project_key",
"clientId": "example_client_id",
"clientSecret": "example_client_secret",
"authUrl": "example_auth_url",
"host": "example_host",
"scopes": ["example_scope:example_projectKey"]
},
"service": {
"port": 3050,
"logLevel": "info",
"logTransports": "terminal"
}
}
The mollie API key is accessible from the developer tools section of your mollie Dashboard. You will need an account to get an API key.
You will need a commercetools project, with an API client. This API client will have the necessary environment variables (e.g. clientSecret
) which should be populated in CT_MOLLIE_CONFIG
to allow the notification module to access commercetools.
These allow you to overwrite the settings for logging and port. If not specified here, they will default to:
port: 3001
logLevel: "info"
logTransports: "terminal"
This project offers different deployment options. There is a dockerfile as well as different cloud provider handlers. Due to functionality of webhooks, notification module is expected to not have incoming authentication set up. You can read more info on webhooks from mollie documentation
- Run
npm run zip-aws-lambda
from the repository root directory, to zip the contents in preparation for uploading to AWS - An AWS lambda function should be created (Guide to creating lambda functions). The runtime should be Node.js 18.x.
- Upload the generated zip file to the lambda function (in the code section, select upload from zip file)
- Add the environment variable
CT_MOLLIE_CONFIG
into environment variables (Guide to adding environment variables)
Setting up the extension as a google cloud function requires an existing function, setting up entry point and secrets and uploading the source code.
- Run
npm run zip-gcp-function
from the repository root directory - Upload the generated zip file to your google cloud function (Guide to creating cloud functions)
- Add the
CT_MOLLIE_CONFIG
to the function asRuntime environment variables
as JSON object. - Set Runtime to
Node.js 18
and change entry point tohandler
- Create function named
notifications
based on HTTP trigger template. Setruntime node
,runtime-version 18
andfunctions-version 4
. (Guide to creating Azure functions) - Add the
CT_MOLLIE_CONFIG
to the functionApplication settings
as JSON object. - Add the
WEBSITE_RUN_FROM_PACKAGE
to the functionApplication settings
and assign it value1
- Run
npm run zip-azure-function
from the repository root directory - Deploy the generated zip file to your azure cloud function
There are 6 different levels of logging available - if this isn't provided in the environment, the level will default to 'info':
- error (only errors will display)
- warn
- info
- http
- verbose
- debug (the most explicit type of logging, should be used only for testing and not for production)
The application looks for the process.env.LOG_LEVEL
for the first source of logging configuration.
If this variable is not present, it looks for logLevel
as part of the CT_MOLLIE_CONFIG
environment variable.
If this is also not present, it will default to "info" level.
Log transports are where the logs are written to. If this isn't provided in the environment, it will default to 'terminal':
- file (written to a file inside logs/ directory)
- terminal (written to STDOUT)
- all (written to both file and terminal)