Skip to content

Commit

Permalink
feat: support connect
Browse files Browse the repository at this point in the history
  • Loading branch information
luispinto-commercetools committed Jun 19, 2023
1 parent bc2c28f commit d2a544e
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 14 deletions.
21 changes: 21 additions & 0 deletions connect.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
deployAs:
- name: extension
applicationType: service
endpoint: /
scripts:
postDeploy: npm install && npm run setup-resources
configuration:
securedConfiguration:
- key: ADYEN_INTEGRATION_CONFIG
description: Escaped JSON object, for more details visit (https://github.com/commercetools/commercetools-adyen-integration/blob/master/extension/docs/HowToRun.md#environment-variable)
- name: notification
applicationType: service
endpoint: /
scripts:
postDeploy: npm install && npm run setup-resources
configuration:
securedConfiguration:
- key: ADYEN_INTEGRATION_CONFIG
description: Escaped JSON object, for more details visit (https://github.com/commercetools/commercetools-adyen-integration/blob/master/notification/docs/HowToRun.md#environment-variable)


4 changes: 3 additions & 1 deletion extension/src/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ function getModuleConfig() {
),
port: config.port,
logLevel: config.logLevel,
apiExtensionBaseUrl: config.apiExtensionBaseUrl, // used for development purpose and for setup-resources command
// If used for development purpose and for setup-resources command
apiExtensionBaseUrl:
process.env.CONNECT_SERVICE_URL ?? config.apiExtensionBaseUrl,
basicAuth: config.basicAuth || false,
keepAliveTimeout: !Number.isNaN(config.keepAliveTimeout)
? parseFloat(config.keepAliveTimeout, 10)
Expand Down
24 changes: 12 additions & 12 deletions notification/docs/HowToRun.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,17 @@ is `ADYEN_INTEGRATION_CONFIG` and it must contain settings as attributes in a JS

### Optional attributes

| Group | Name | Content | Default value |
| --------------- | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
| `adyen` | `enableHmacSignature` | Verify the integrity of notifications using [Adyen HMAC signatures](https://docs.adyen.com/development-resources/webhooks/verify-hmac-signatures). | true |
| `adyen` | `secretHmacKey` | The generated secret HMAC key that is linked to a Adyen **Standard Notification** endpoint | |
| `commercetools` | `apiUrl` | The commercetools HTTP API is hosted at that URL. | `https://api.europe-west1.gcp.commercetools.com` |
| `commercetools` | `authUrl` | The commercetools’ OAuth 2.0 service is hosted at that URL. | `https://auth.europe-west1.gcp.commercetools.com` |
| `other` | `adyenPaymentMethodsToNames` | Key-value object where key is `paymentMethod` returned in the notification and value is the custom localized name that will be saved in CTP `payment.paymentMethodInfo.method`. | `{scheme: {en: 'Credit Card'}, pp: {en: 'PayPal'}, klarna: {en: 'Klarna'}, gpay: {en: 'Google Pay'}}` |
| `other` | `removeSensitiveData` | Boolean attribute. When set to "false", Adyen fields with additional information about the payment will be saved in the interface interaction and in the custom fields. | true |
| `other` | `port` | The port number on which the application will run. | 443 |
| `other` | `logLevel` | The log level (`trace`, `debug`, `info`, `warn`, `error`, `fatal`). | `info` |
| `other` | `keepAliveTimeout` | Milliseconds to keep a socket alive after the last response ([Node.js docs](https://nodejs.org/dist/latest/docs/api/http.html#http_server_keepalivetimeout)). | Node.js default (5 seconds) |
| Group | Name | Content | Default value |
| --------------- | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
| `adyen` | `enableHmacSignature` | Verify the integrity of notifications using [Adyen HMAC signatures](https://docs.adyen.com/development-resources/webhooks/verify-hmac-signatures). (⚠️ If deploying in Connect, it is required to set the field to false) | true |
| `adyen` | `secretHmacKey` | The generated secret HMAC key that is linked to a Adyen **Standard Notification** endpoint | |
| `commercetools` | `apiUrl` | The commercetools HTTP API is hosted at that URL. | `https://api.europe-west1.gcp.commercetools.com` |
| `commercetools` | `authUrl` | The commercetools’ OAuth 2.0 service is hosted at that URL. | `https://auth.europe-west1.gcp.commercetools.com` |
| `other` | `adyenPaymentMethodsToNames` | Key-value object where key is `paymentMethod` returned in the notification and value is the custom localized name that will be saved in CTP `payment.paymentMethodInfo.method`. | `{scheme: {en: 'Credit Card'}, pp: {en: 'PayPal'}, klarna: {en: 'Klarna'}, gpay: {en: 'Google Pay'}}` |
| `other` | `removeSensitiveData` | Boolean attribute. When set to "false", Adyen fields with additional information about the payment will be saved in the interface interaction and in the custom fields. | true |
| `other` | `port` | The port number on which the application will run. (⚠️ If deploying in Connect, it is required to set the field to 8080) | 443 |
| `other` | `logLevel` | The log level (`trace`, `debug`, `info`, `warn`, `error`, `fatal`). | `info` |
| `other` | `keepAliveTimeout` | Milliseconds to keep a socket alive after the last response ([Node.js docs](https://nodejs.org/dist/latest/docs/api/http.html#http_server_keepalivetimeout)). | Node.js default (5 seconds) |

### Other Configurations

Expand All @@ -102,7 +102,7 @@ Other configurations can be set as direct child attributes in `ADYEN_INTEGRATION
| Name | Content | Default value |
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------- |
| `adyenPaymentMethodsToNames` | Key-value object where key is `paymentMethod` returned in the notification and value is the custom localized name that will be saved in CTP `payment.paymentMethodInfo.method`. | `{scheme: {en: 'Credit Card'}, pp: {en: 'PayPal'}, klarna: {en: 'Klarna'}, gpay: {en: 'Google Pay'}}` |
| `port` | The port number on which the application will run. | 443 |
| `port` | The port number on which the application will run. (⚠️ If deploying in Connect, it is required to set the field to 8080) | 443 |
| `logLevel` | The log level (`trace`, `debug`, `info`, `warn`, `error`, `fatal`). | `info` |
| `keepAliveTimeout` | Milliseconds to keep a socket alive after the last response ([Node.js docs](https://nodejs.org/dist/latest/docs/api/http.html#http_server_keepalivetimeout)). | Node.js default (5 seconds) |
| `removeSensitiveData` | Boolean attribute. When set to "false", Adyen fields with additional information about the payment will be saved in the interface interaction and in the custom fields. | true |
Expand Down
2 changes: 2 additions & 0 deletions notification/docs/IntegrationGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ To protect your server from unauthorized notifications, we strongly recommend th

You can set up the webhooks and generate HMAC by running the command `npm run setup-resources` as below, the command requires the `ADYEN_INTEGRATION_CONFIG` to be set as an environment variable. For every project you want to generate HMAC key set the attribute `enableHmacSignature: true` and do not have the attribute `secretHmacKey`. The new HMAC key will be generated and the updated `ADYEN_INTEGRATION_CONFIG` will be printed to you. Use this updated `ADYEN_INTEGRATION_CONFIG` to replace the existing one in environment variable and run the notification module. Be aware that this command also sets up [the commercetools resources required for the notification module](./HowToRun.md#commercetools-project-requirements).

(⚠️ When deploying in Connect, it is mandatory for the user to set the `enableHmacSignature` to false, as currently does not support it.)

```bash
export ADYEN_INTEGRATION_CONFIG=xxxx
npm run setup-resources
Expand Down
3 changes: 2 additions & 1 deletion notification/src/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ function getAdyenConfig(adyenMerchantAccount) {
if (adyenConfig.enableHmacSignature === false) enableHmacSignature = false
return {
secretHmacKey: adyenConfig.secretHmacKey,
notificationBaseUrl: adyenConfig.notificationBaseUrl,
notificationBaseUrl:
process.env.CONNECT_SERVICE_URL ?? adyenConfig.notificationBaseUrl,
enableHmacSignature,
apiKey: adyenConfig.apiKey,
}
Expand Down

0 comments on commit d2a544e

Please sign in to comment.