diff --git a/CHANGELOG.md b/CHANGELOG.md index aede09e..1512cff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,67 +4,18 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). -## v1.2.0-alpha - -Added - -- Mollie custom application initialization - -Updated - -- [getPaymentMethods](/docs/GetPaymentMethods.md) response has new returned format as follow - - ```Typescript - { - id: string, - name: Record - description: Record - image: string; - order: number; - } - - // e.g. - { - id: 'paypal', - name: { - 'en-GB': 'PayPal', - 'de-DE': 'PayPal', - }, - description: { - 'en-GB': '', - 'de-DE': '', - }, - image: 'https://example.img/paypal.svg', - order: 1 - } - ``` - -## v1.1.2 +## v1.0.4 Added - Add configuration to enable authorization mode - OAuth middleware for securing connector endpoint -## v1.1.1 - -Fixes - -- Type converting issue in payment method listing endpoint - -## v1.1.0 - -Added - -- DockerImage for self hosting on AWS -- Installation endpoint for required configurations - ## v1.0.3 Added - Add docs for status checking endpoint -- Endpoints for checking connector statuses ## v1.0.2 diff --git a/connect.yaml b/connect.yaml index 2d99ef6..d8b5790 100644 --- a/connect.yaml +++ b/connect.yaml @@ -11,8 +11,12 @@ deployAs: description: Commercetools Composable Commerce API region required: true default: "europe-west1.gcp" + - key: CTP_AUTH_URL + description: Commercetools Auth URL + default: https://auth.europe-west1.gcp.commercetools.com + required: true - key: MOLLIE_CARD_COMPONENT - description: Enable Mollie card component (0 or 1) + description: Enable Mollie cart component (0 or 1) required: false default: "0" - key: CONNECTOR_MODE @@ -52,26 +56,3 @@ deployAs: - key: CTP_SCOPE description: Commercetools Composable Commerce client scope required: true - - key: CTP_SESSION_AUDIENCE - description: Commercetools Composable Commerce client session audience. The value should only contain the origin URL (protocol, hostname, port). - required: true - - key: CTP_SESSION_ISSUER - description: Commercetools Composable Commerce client session issuer. The cloud identifier that maps to the MC API URL of the related cloud region or the MC API URL. - required: true - - - name: application - applicationType: merchant-center-custom-application - scripts: - postDeploy: yarn install && yarn build - preUndeploy: yarn install && yarn build - configuration: - standardConfiguration: - - key: CUSTOM_APPLICATION_ID - description: The Custom Application ID - required: true - - key: CLOUD_IDENTIFIER - description: The cloud identifier - default: 'gcp-eu' - - key: ENTRY_POINT_URI_PATH - description: The Application entry point URI path - required: true \ No newline at end of file diff --git a/docs/Authorization.md b/docs/Authorization.md index 2a4c330..7ccecd6 100644 --- a/docs/Authorization.md +++ b/docs/Authorization.md @@ -17,7 +17,7 @@ CREAT/UPDATE Extension "url": "https://efd6-115-74-115-119.ngrok-free.app/processor", "authorization": { "type": "AuthorizationHeader", - "headerValue": "_token_" + "headerValue": "***tAjsIR2!srt" } } ... diff --git a/docs/GetPaymentMethods.md b/docs/GetPaymentMethods.md index 337e986..2db071c 100644 --- a/docs/GetPaymentMethods.md +++ b/docs/GetPaymentMethods.md @@ -69,21 +69,17 @@ _Body:_ ```json { - "actions": [ - { - "actions": [ - { - "action": "setCustomField", - "name": "sctm_mollie_profile_id", - "value": "pfl_SPkYGi***" - }, - { - "action": "setCustomField", - "name": "sctm_payment_methods_response", - "value": "{\"count\":7,\"methods\":[{\"id\":\"przelewy24\",\"name\":{\"en-GB\":\"Przelewy24\",\"de-DE\":\"Przelewy24\",\"pl-PL\":\"Przelewy24\"},\"description\":{\"en-GB\":\"\",\"de-DE\":\"Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of \",\"pl-PL\":\"\"},\"image\":\"https://www.mollie.com/external/icons/payment-methods/przelewy24.svg\",\"order\":4},{\"id\":\"banktransfer\",\"name\":{\"en-GB\":\"Bank transfer\",\"de-DE\":\"Bank transfer\",\"pl-PL\":\"Bank transfer\"},\"description\":{\"en-GB\":\"\",\"de-DE\":\"\",\"pl-PL\":\"\"},\"image\":\"https://www.mollie.com/external/icons/payment-methods/banktransfer.svg\",\"order\":3},{\"id\":\"applepay\",\"name\":{\"en-GB\":\"Apple Pay\",\"de-DE\":\"Apple Pay\",\"pl-PL\":\"Apple Pay\"},\"description\":{\"en-GB\":\"Apple Pay description\",\"de-DE\":\"Apple Pay description\",\"pl-PL\":\"\"},\"image\":\"https://www.mollie.com/external/icons/payment-methods/applepay.svg\",\"order\":2},{\"id\":\"paypal\",\"name\":{\"en-GB\":\"PayPal\",\"de-DE\":\"PayPal\",\"pl-PL\":\"PayPal\"},\"description\":{\"en-GB\":\"\",\"de-DE\":\"\",\"pl-PL\":\"\"},\"image\":\"https://www.mollie.com/external/icons/payment-methods/paypal.svg\",\"order\":0},{\"id\":\"ideal\",\"name\":{\"en-GB\":\"iDEAL\",\"de-DE\":\"iDEAL\",\"pl-PL\":\"iDEAL\"},\"description\":{\"en-GB\":\"\",\"de-DE\":\"\",\"pl-PL\":\"\"},\"image\":\"https://www.mollie.com/external/icons/payment-methods/ideal.svg\",\"order\":0},{\"id\":\"bancontact\",\"name\":{\"en-GB\":\"Bancontact\",\"de-DE\":\"Bancontact\",\"pl-PL\":\"Bancontact\"},\"description\":{\"en-GB\":\"\",\"de-DE\":\"\",\"pl-PL\":\"\"},\"image\":\"https://www.mollie.com/external/icons/payment-methods/bancontact.svg\",\"order\":0},{\"id\":\"kbc\",\"name\":{\"en-GB\":\"KBC/CBC Payment Button\",\"de-DE\":\"KBC/CBC Payment Button\",\"pl-PL\":\"KBC/CBC Payment Button\"},\"description\":{\"en-GB\":\"\",\"de-DE\":\"\",\"pl-PL\":\"\"},\"image\":\"https://www.mollie.com/external/icons/payment-methods/kbc.svg\",\"order\":0}]}" - } - ] - } - ] + "actions": [ + { + "action": "setCustomField", + "name": "sctm_payment_methods_response", + "value": "{\"count\":11,\"methods\":[{\"resource\":\"method\",\"id\":\"applepay\",\"description\":\"Apple Pay\",\"minimumAmount\":{\"value\":\"0.01\",\"currency\":\"EUR\"},\"maximumAmount\":{\"value\":\"10000.00\",\"currency\":\"EUR\"},\"image\":{\"size1x\":\"https://www.mollie.com/external/icons/payment-methods/applepay.png\",\"size2x\":\"https://www.mollie.com/external/icons/payment-methods/applepay%402x.png\",\"svg\":\"https://www.mollie.com/external/icons/payment-methods/applepay.svg\"},\"status\":\"activated\",\"_links\":{\"self\":{\"href\":\"https://api.mollie.com/v2/methods/applepay\",\"type\":\"application/hal+json\"}}},{\"resource\":\"method\",\"id\":\"creditcard\",\"description\":\"Karte\",\"minimumAmount\":{\"value\":\"0.01\",\"currency\":\"EUR\"},\"maximumAmount\":{\"value\":\"10000.00\",\"currency\":\"EUR\"},\"image\":{\"size1x\":\"https://www.mollie.com/external/icons/payment-methods/creditcard.png\",\"size2x\":\"https://www.mollie.com/external/icons/payment-methods/creditcard%402x.png\",\"svg\":\"https://www.mollie.com/external/icons/payment-methods/creditcard.svg\"},\"status\":\"activated\",\"_links\":{\"self\":{\"href\":\"https://api.mollie.com/v2/methods/creditcard\",\"type\":\"application/hal+json\"}}},{\"resource\":\"method\",\"id\":\"paypal\",\"description\":\"PayPal\",\"minimumAmount\":{\"value\":\"0.01\",\"currency\":\"EUR\"},\"maximumAmount\":null,\"image\":{\"size1x\":\"https://www.mollie.com/external/icons/payment-methods/paypal.png\",\"size2x\":\"https://www.mollie.com/external/icons/payment-methods/paypal%402x.png\",\"svg\":\"https://www.mollie.com/external/icons/payment-methods/paypal.svg\"},\"status\":\"activated\",\"_links\":{\"self\":{\"href\":\"https://api.mollie.com/v2/methods/paypal\",\"type\":\"application/hal+json\"}}},{\"resource\":\"method\",\"id\":\"banktransfer\",\"description\":\"Überweisung\",\"minimumAmount\":{\"value\":\"0.01\",\"currency\":\"EUR\"},\"maximumAmount\":{\"value\":\"1000000.00\",\"currency\":\"EUR\"},\"image\":{\"size1x\":\"https://www.mollie.com/external/icons/payment-methods/banktransfer.png\",\"size2x\":\"https://www.mollie.com/external/icons/payment-methods/banktransfer%402x.png\",\"svg\":\"https://www.mollie.com/external/icons/payment-methods/banktransfer.svg\"},\"status\":\"activated\",\"_links\":{\"self\":{\"href\":\"https://api.mollie.com/v2/methods/banktransfer\",\"type\":\"application/hal+json\"}}},{\"resource\":\"method\",\"id\":\"ideal\",\"description\":\"iDEAL\",\"minimumAmount\":{\"value\":\"0.01\",\"currency\":\"EUR\"},\"maximumAmount\":{\"value\":\"50000.00\",\"currency\":\"EUR\"},\"image\":{\"size1x\":\"https://www.mollie.com/external/icons/payment-methods/ideal.png\",\"size2x\":\"https://www.mollie.com/external/icons/payment-methods/ideal%402x.png\",\"svg\":\"https://www.mollie.com/external/icons/payment-methods/ideal.svg\"},\"status\":\"activated\",\"_links\":{\"self\":{\"href\":\"https://api.mollie.com/v2/methods/ideal\",\"type\":\"application/hal+json\"}}},{\"resource\":\"method\",\"id\":\"bancontact\",\"description\":\"Bancontact\",\"minimumAmount\":{\"value\":\"0.02\",\"currency\":\"EUR\"},\"maximumAmount\":{\"value\":\"50000.00\",\"currency\":\"EUR\"},\"image\":{\"size1x\":\"https://www.mollie.com/external/icons/payment-methods/bancontact.png\",\"size2x\":\"https://www.mollie.com/external/icons/payment-methods/bancontact%402x.png\",\"svg\":\"https://www.mollie.com/external/icons/payment-methods/bancontact.svg\"},\"status\":\"activated\",\"_links\":{\"self\":{\"href\":\"https://api.mollie.com/v2/methods/bancontact\",\"type\":\"application/hal+json\"}}},{\"resource\":\"method\",\"id\":\"eps\",\"description\":\"eps\",\"minimumAmount\":{\"value\":\"1.00\",\"currency\":\"EUR\"},\"maximumAmount\":{\"value\":\"50000.00\",\"currency\":\"EUR\"},\"image\":{\"size1x\":\"https://www.mollie.com/external/icons/payment-methods/eps.png\",\"size2x\":\"https://www.mollie.com/external/icons/payment-methods/eps%402x.png\",\"svg\":\"https://www.mollie.com/external/icons/payment-methods/eps.svg\"},\"status\":\"activated\",\"_links\":{\"self\":{\"href\":\"https://api.mollie.com/v2/methods/eps\",\"type\":\"application/hal+json\"}}},{\"resource\":\"method\",\"id\":\"przelewy24\",\"description\":\"Przelewy24\",\"minimumAmount\":{\"value\":\"0.01\",\"currency\":\"EUR\"},\"maximumAmount\":{\"value\":\"12815.00\",\"currency\":\"EUR\"},\"image\":{\"size1x\":\"https://www.mollie.com/external/icons/payment-methods/przelewy24.png\",\"size2x\":\"https://www.mollie.com/external/icons/payment-methods/przelewy24%402x.png\",\"svg\":\"https://www.mollie.com/external/icons/payment-methods/przelewy24.svg\"},\"status\":\"activated\",\"_links\":{\"self\":{\"href\":\"https://api.mollie.com/v2/methods/przelewy24\",\"type\":\"application/hal+json\"}}},{\"resource\":\"method\",\"id\":\"kbc\",\"description\":\"KBC/CBC Zahlungsbutton\",\"minimumAmount\":{\"value\":\"0.01\",\"currency\":\"EUR\"},\"maximumAmount\":{\"value\":\"50000.00\",\"currency\":\"EUR\"},\"image\":{\"size1x\":\"https://www.mollie.com/external/icons/payment-methods/kbc.png\",\"size2x\":\"https://www.mollie.com/external/icons/payment-methods/kbc%402x.png\",\"svg\":\"https://www.mollie.com/external/icons/payment-methods/kbc.svg\"},\"status\":\"activated\",\"_links\":{\"self\":{\"href\":\"https://api.mollie.com/v2/methods/kbc\",\"type\":\"application/hal+json\"}}},{\"resource\":\"method\",\"id\":\"belfius\",\"description\":\"Belfius Pay Button\",\"minimumAmount\":{\"value\":\"0.01\",\"currency\":\"EUR\"},\"maximumAmount\":{\"value\":\"50000.00\",\"currency\":\"EUR\"},\"image\":{\"size1x\":\"https://www.mollie.com/external/icons/payment-methods/belfius.png\",\"size2x\":\"https://www.mollie.com/external/icons/payment-methods/belfius%402x.png\",\"svg\":\"https://www.mollie.com/external/icons/payment-methods/belfius.svg\"},\"status\":\"activated\",\"_links\":{\"self\":{\"href\":\"https://api.mollie.com/v2/methods/belfius\",\"type\":\"application/hal+json\"}}},{\"resource\":\"method\",\"id\":\"bancomatpay\",\"description\":\"Bancomat Pay\",\"minimumAmount\":{\"value\":\"0.01\",\"currency\":\"EUR\"},\"maximumAmount\":{\"value\":\"50000.00\",\"currency\":\"EUR\"},\"image\":{\"size1x\":\"https://www.mollie.com/external/icons/payment-methods/bancomatpay.png\",\"size2x\":\"https://www.mollie.com/external/icons/payment-methods/bancomatpay%402x.png\",\"svg\":\"https://www.mollie.com/external/icons/payment-methods/bancomatpay.svg\"},\"status\":\"activated\",\"_links\":{\"self\":{\"href\":\"https://api.mollie.com/v2/methods/bancomatpay\",\"type\":\"application/hal+json\"}}}]}" + }, + { + "action": "setCustomField", + "name": "sctm_mollie_profile_id", + "value": "pfl_SPkYGiEQjf" + } + ] } ``` diff --git a/docs/contribution/ContributionGuidelines.md b/docs/contribution/ContributionGuidelines.md new file mode 100644 index 0000000..414ccaf --- /dev/null +++ b/docs/contribution/ContributionGuidelines.md @@ -0,0 +1,35 @@ +# Contribution Guide + +* [Prerequisites](#prerequisites) +* [Development](#development) + +## Prerequisites + +To merge your changes, your commits must be [signed](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits). + +Minimum requirements are: +- **Node.js** version 18 +- **Npm** npm v10.7.0 +- **Bash** shell +- **Signed** git commits + +You can install all dependencies using `npm` with following command: + +``` +npm install +``` + +## Development +While developing project you can use some predefined commands for running tests, running linter or generating coverage. + +- Execute `npm run test` to run all tests. +- Execute `npm run lint` to show lint errors in the code. + +## Release procedure +At the moment there is no automated release scripts, which means we do releases manually. We use [gitflow workflow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow) for releases. Please **squash commits when finishing the feature branch**, this way we can keep relatively clean history on develop and main. + +Contributing by following these steps: + +1. Create and check out a new branch off main and make your necessary change here. The branch name should have a specific prefix depends on the purpose, e.g: `bugfix/`, `feat/` +2. Bump [version](https://semver.org/) on npm package (in /processor). Commit changes on the above branch. +3. Create PR and wait for the approval from the development team. \ No newline at end of file diff --git a/docs/contribution/IssueTemplate.md b/docs/contribution/IssueTemplate.md new file mode 100644 index 0000000..3673bf9 --- /dev/null +++ b/docs/contribution/IssueTemplate.md @@ -0,0 +1,26 @@ +# Issue Template + +**Deployment** +_My deployment is on:_ + +- [ ] Docker +- [ ] AWS Lambda +- [ ] GCP +- [ ] Azure +- [ ] Other _Please specify:_ + +**Expected behaviour** + +_Please explain what should happen._ + +**Actual behaviour** + +_Please explain what is happening instead. Provide a log message if relevant._ + +**Attempted fixes** + +_Please explain what you've done so far to try and fix the problem._ + +**Please provide more information about how this can be reproduced. Please include jsfiddle links, code snippets or any other necessary information** + +_Include extra info here._ \ No newline at end of file diff --git a/processor/.env.example b/processor/.env.example index 7c2688e..576da7b 100644 --- a/processor/.env.example +++ b/processor/.env.example @@ -10,16 +10,6 @@ AUTHENTICATION_MODE= CTP_AUTH_URL=https://auth..commercetools.com CTP_API_URL=https://api..commercetools.com -## CT Session Middleware options -### The public-facing URL used to connect to the server / serverless function. -### The value should only contain the origin URL (protocol, hostname, port), -### the request path is inferred from the incoming request. -CTP_SESSION_AUDIENCE=https://mc..commercetools.com -### The cloud identifier (see `CLOUD_IDENTIFIERS`) that maps to the MC API URL -### of the related cloud region or the MC API URL -### e.g. gcp-eu -CTP_SESSION_ISSUER=gcp-eu - ## Mollie PSP credentials DEBUG= ## Either 1 for enable or 0 for disable CONNECTOR_MODE= ## Either test or live diff --git a/processor/.env.jest b/processor/.env.jest index 7674d6d..c11c7a9 100644 --- a/processor/.env.jest +++ b/processor/.env.jest @@ -5,9 +5,8 @@ CTP_CLIENT_SECRET=12345678901234567890123456789012 CTP_PROJECT_KEY=TEST CTP_SCOPE=TEST CTP_REGION=europe-west1.gcp +CTP_AUTH_URL=https://auth.europe-west1.gcp.commercetools.com AUTHENTICATION_MODE=0 -CTP_SESSION_AUDIENCE=https://mc.europe-west1.gcp.commercetools.com -CTP_SESSION_ISSUER=gcp-eu ## MOLLIE vars MOLLIE_PROFILE_ID=pfl_12345 DEBUG=0 diff --git a/processor/jest.config.cjs b/processor/jest.config.cjs index c6143f6..108d1c2 100644 --- a/processor/jest.config.cjs +++ b/processor/jest.config.cjs @@ -7,5 +7,5 @@ module.exports = { setupFiles: ['/src/jest.setup.ts'], setupFilesAfterEnv: ['/src/jest.setupAfterEnv.ts'], modulePathIgnorePatterns: ['/src/jest.setup.ts'], - reporters: ['default', 'jest-junit'], + reporters: ['default', 'jest-junit'] }; diff --git a/processor/package-lock.json b/processor/package-lock.json index fdb27c8..94ea7af 100644 --- a/processor/package-lock.json +++ b/processor/package-lock.json @@ -1,17 +1,24 @@ { "name": "shopmacher-mollie-processor", +<<<<<<< HEAD "version": "1.2.0", +======= + "version": "1.0.3", +>>>>>>> main "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "shopmacher-mollie-processor", +<<<<<<< HEAD "version": "1.2.0", +======= + "version": "1.0.3", +>>>>>>> main "hasInstallScript": true, "license": "MIT", "dependencies": { - "@commercetools-backend/express": "^22.32.2", - "@commercetools-backend/loggers": "^21.25.2", + "@commercetools-backend/loggers": "^22.35.0", "@commercetools/connect-payments-sdk": "^0.10.0", "@commercetools/platform-sdk": "^4.11.0", "@commercetools/sdk-client-v2": "^2.5.0", @@ -63,9 +70,9 @@ "dev": true }, "node_modules/@colors/colors": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz", - "integrity": "sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.6.0.tgz", + "integrity": "sha512-Ir+AOibqzrIsL6ajt3Rz3LskB7OiMVHqltZmspbW/TJuTVuyOMirVqAkjfY6JISiLHgyNqicAC8AyHHGzNd/dA==", "engines": { "node": ">=0.1.90" } @@ -129,19 +136,6 @@ "resolved": "https://registry.npmjs.org/kuler/-/kuler-2.0.0.tgz", "integrity": "sha512-Xq9nH7KlWZmXAtodXDDRE7vs6DU1gTU8zYDHDiWLSip45Egwq3plLHzPn27NgvzL2r1LMPC1vdqh98sQxtqj4A==" }, - "node_modules/@sentry/core": { - "version": "7.43.0", - "resolved": "https://registry.npmjs.org/@sentry/core/-/core-7.43.0.tgz", - "integrity": "sha512-zvMZgEi7ptLBwDnd+xR/u4zdSe5UzS4S3ZhoemdQrn1PxsaVySD/ptyzLoGSZEABqlRxGHnQrZ78MU1hUDvKuQ==", - "dependencies": { - "@sentry/types": "7.43.0", - "@sentry/utils": "7.43.0", - "tslib": "^1.9.3" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/tr46": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", @@ -386,14 +380,6 @@ "node": ">=4" } }, - "node_modules/@commercetools-backend/express/node_modules/cookie": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", - "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", - "engines": { - "node": ">= 0.6" - } - }, "node_modules/istanbul-reports": { "version": "3.1.7", "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.7.tgz", @@ -555,34 +541,20 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/@sentry/node": { - "version": "7.43.0", - "resolved": "https://registry.npmjs.org/@sentry/node/-/node-7.43.0.tgz", - "integrity": "sha512-oXaTBq6Bk8Qwsd46hhRU2MLEnjYqWI41nPJmXyAWkDSYQTP7sUe1qM8bCUdsRpPwQh955Vq9qCRfgMbN4lEoAQ==", - "dependencies": { - "@sentry/core": "7.43.0", - "@sentry/types": "7.43.0", - "@sentry/utils": "7.43.0", - "cookie": "^0.4.1", - "https-proxy-agent": "^5.0.0", - "lru_map": "^0.3.3", - "tslib": "^1.9.3" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/logform": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/logform/-/logform-2.5.1.tgz", - "integrity": "sha512-9FyqAm9o9NKKfiAKfZoYo9bGXXuwMkxQiQttkT4YjjVtQVIQtK6LmVtlxmCaFswo6N4AfEkHqZTV0taDtPotNg==", + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/logform/-/logform-2.6.0.tgz", + "integrity": "sha512-1ulHeNPp6k/LD8H91o7VYFBng5i1BDE7HoKxVbZiGFidS1Rj65qcywLxX+pVfAPoQJEjRdvKcusKwOupHCVOVQ==", "dependencies": { - "@colors/colors": "1.5.0", + "@colors/colors": "1.6.0", "@types/triple-beam": "^1.3.2", "fecha": "^4.2.0", "ms": "^2.1.1", "safe-stable-stringify": "^2.3.1", "triple-beam": "^1.3.0" + }, + "engines": { + "node": ">= 12.0.0" } }, "node_modules/rxjs": { @@ -612,9 +584,9 @@ } }, "node_modules/@types/triple-beam": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/@types/triple-beam/-/triple-beam-1.3.2.tgz", - "integrity": "sha512-txGIh+0eDFzKGC25zORnswy+br1Ha7hj5cMVwKIU7+s0U2AxxJru/jZSMU6OC9MJWP6+pc/hc6ZjyZShpsyY2g==" + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/@types/triple-beam/-/triple-beam-1.3.5.tgz", + "integrity": "sha512-6WaYesThRMCl19iryMYP7/x2OVgCtbIVflDGFpWnb9irXI3UjYE4AzmYuiUKY1AJstGijoY+MgUszMgRxIYTYw==" }, "node_modules/touch": { "version": "3.1.1", @@ -944,27 +916,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/@commercetools/connect-payments-sdk/node_modules/winston": { - "version": "3.13.0", - "resolved": "https://registry.npmjs.org/winston/-/winston-3.13.0.tgz", - "integrity": "sha512-rwidmA1w3SE4j0E5MuIufFhyJPBDG7Nu71RkZor1p2+qHvJSZ9GYDA81AyleQcZbh/+V6HjeBdfnTZJm9rSeQQ==", - "dependencies": { - "@colors/colors": "^1.6.0", - "@dabh/diagnostics": "^2.0.2", - "async": "^3.2.3", - "is-stream": "^2.0.0", - "logform": "^2.4.0", - "one-time": "^1.0.0", - "readable-stream": "^3.4.0", - "safe-stable-stringify": "^2.3.1", - "stack-trace": "0.0.x", - "triple-beam": "^1.3.0", - "winston-transport": "^4.7.0" - }, - "engines": { - "node": ">= 12.0.0" - } - }, "node_modules/one-time": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/one-time/-/one-time-1.0.0.tgz", @@ -1074,18 +1025,6 @@ } } }, - "node_modules/@sentry/utils": { - "version": "7.43.0", - "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.43.0.tgz", - "integrity": "sha512-f78YfMLcgNU7+suyWFCuQhQlneXXMS+egb0EFZh7iU7kANUPRX5T4b+0C+fwaPm5gA6XfGYskr4ZnzQJLOlSqg==", - "dependencies": { - "@sentry/types": "7.43.0", - "tslib": "^1.9.3" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/on-finished": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", @@ -1279,14 +1218,6 @@ "node": ">= 0.4" } }, - "node_modules/jwks-rsa/node_modules/@types/jsonwebtoken": { - "version": "8.5.9", - "resolved": "https://registry.npmjs.org/@types/jsonwebtoken/-/jsonwebtoken-8.5.9.tgz", - "integrity": "sha512-272FMnFGzAVMGtu9tkr29hRL6bZj4Zs1KZNeHLnKqAvp06tAIcarTMwOh8/8bz4FmKRcMxZhZNeUAQsNLoiPhg==", - "dependencies": { - "@types/node": "*" - } - }, "node_modules/lodash.isboolean": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz", @@ -1776,22 +1707,6 @@ "node": ">=4" } }, - "node_modules/@commercetools/connect-payments-sdk/node_modules/jwks-rsa": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/jwks-rsa/-/jwks-rsa-3.1.0.tgz", - "integrity": "sha512-v7nqlfezb9YfHHzYII3ef2a2j1XnGeSE/bK3WfumaYCqONAIstJbrEGapz4kadScZzEt7zYCN7bucj8C0Mv/Rg==", - "dependencies": { - "@types/express": "^4.17.17", - "@types/jsonwebtoken": "^9.0.2", - "debug": "^4.3.4", - "jose": "^4.14.6", - "limiter": "^1.1.5", - "lru-memoizer": "^2.2.0" - }, - "engines": { - "node": ">=14" - } - }, "node_modules/synckit/node_modules/tslib": { "version": "2.6.3", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", @@ -2598,9 +2513,9 @@ } }, "node_modules/@commercetools/connect-payments-sdk/node_modules/@commercetools-backend/loggers": { - "version": "22.34.0", - "resolved": "https://registry.npmjs.org/@commercetools-backend/loggers/-/loggers-22.34.0.tgz", - "integrity": "sha512-UdXXDdBVK+S8LW3AGAjCJoNkFo53w38itRR2NNPTT7rawfgQPEMPrzwLj6BAfhGKuF3ycEQToRCNOxSbJFJwSA==", + "version": "22.32.2", + "resolved": "https://registry.npmjs.org/@commercetools-backend/loggers/-/loggers-22.32.2.tgz", + "integrity": "sha512-z2AwV1PStfAUGnYNfJHIkV2NekSSHjIDWEVj44x2yDFIJDjgj7l3E094QKA95aZmDb6zEGEFdfJO3n+24iMHtg==", "dependencies": { "@babel/runtime": "^7.22.15", "@babel/runtime-corejs3": "^7.22.15", @@ -2734,19 +2649,19 @@ "optional": true }, "node_modules/jwks-rsa": { - "version": "2.1.5", - "resolved": "https://registry.npmjs.org/jwks-rsa/-/jwks-rsa-2.1.5.tgz", - "integrity": "sha512-IODtn1SwEm7n6GQZnQLY0oxKDrMh7n/jRH1MzE8mlxWMrh2NnMyOsXTebu8vJ1qCpmuTJcL4DdiE0E4h8jnwsA==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/jwks-rsa/-/jwks-rsa-3.1.0.tgz", + "integrity": "sha512-v7nqlfezb9YfHHzYII3ef2a2j1XnGeSE/bK3WfumaYCqONAIstJbrEGapz4kadScZzEt7zYCN7bucj8C0Mv/Rg==", "dependencies": { - "@types/express": "^4.17.14", - "@types/jsonwebtoken": "^8.5.9", + "@types/express": "^4.17.17", + "@types/jsonwebtoken": "^9.0.2", "debug": "^4.3.4", - "jose": "^2.0.6", + "jose": "^4.14.6", "limiter": "^1.1.5", - "lru-memoizer": "^2.1.4" + "lru-memoizer": "^2.2.0" }, "engines": { - "node": ">=10 < 13 || >=14" + "node": ">=14" } }, "node_modules/express-winston/node_modules/escape-string-regexp": { @@ -2813,14 +2728,6 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/@commercetools/connect-payments-sdk/node_modules/jose": { - "version": "4.15.9", - "resolved": "https://registry.npmjs.org/jose/-/jose-4.15.9.tgz", - "integrity": "sha512-1vUQX+IdDMVPj4k8kOxgUqlcK518yluMuGZwqlr44FS1ppZB/5GWh4rZG89erpOBOJjU/OBsnCVFfapsRz6nEA==", - "funding": { - "url": "https://github.com/sponsors/panva" - } - }, "node_modules/p-try": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", @@ -2872,11 +2779,6 @@ "js-yaml": "bin/js-yaml.js" } }, - "node_modules/lru_map": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/lru_map/-/lru_map-0.3.3.tgz", - "integrity": "sha512-Pn9cox5CsMYngeDbmChANltQl+5pi6XmTrraMSzhPmMBbmgcxmqWry0U3PGapCU1yB4/LqCcom7qhHZiF/jGfQ==" - }, "node_modules/locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", @@ -3154,20 +3056,6 @@ "node": ">=8" } }, - "node_modules/@commercetools-backend/express/node_modules/serve-static": { - "version": "1.16.0", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.0.tgz", - "integrity": "sha512-pDLK8zwl2eKaYrs8mrPZBJua4hMplRWJ1tIFksVC3FtBEBnl8dxgeHtsaMS8DhS9i4fLObaon6ABoc4/hQGdPA==", - "dependencies": { - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "parseurl": "~1.3.3", - "send": "0.18.0" - }, - "engines": { - "node": ">= 0.8.0" - } - }, "node_modules/@isaacs/cliui": { "version": "8.0.2", "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", @@ -3313,14 +3201,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/@commercetools-backend/express/node_modules/finalhandler/node_modules/encodeurl": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", - "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", - "engines": { - "node": ">= 0.8" - } - }, "node_modules/object.fromentries": { "version": "2.0.8", "resolved": "https://registry.npmjs.org/object.fromentries/-/object.fromentries-2.0.8.tgz", @@ -3339,14 +3219,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/@commercetools/connect-payments-sdk/node_modules/@colors/colors": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.6.0.tgz", - "integrity": "sha512-Ir+AOibqzrIsL6ajt3Rz3LskB7OiMVHqltZmspbW/TJuTVuyOMirVqAkjfY6JISiLHgyNqicAC8AyHHGzNd/dA==", - "engines": { - "node": ">=0.1.90" - } - }, "node_modules/gopd": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", @@ -3379,14 +3251,6 @@ "semver": "bin/semver.js" } }, - "node_modules/winston-transport/node_modules/@colors/colors": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.6.0.tgz", - "integrity": "sha512-Ir+AOibqzrIsL6ajt3Rz3LskB7OiMVHqltZmspbW/TJuTVuyOMirVqAkjfY6JISiLHgyNqicAC8AyHHGzNd/dA==", - "engines": { - "node": ">=0.1.90" - } - }, "node_modules/eastasianwidth": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", @@ -3803,14 +3667,6 @@ "@jridgewell/sourcemap-codec": "^1.4.10" } }, - "node_modules/@commercetools-backend/express/node_modules/debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dependencies": { - "ms": "2.0.0" - } - }, "node_modules/@istanbuljs/load-nyc-config": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", @@ -3882,11 +3738,6 @@ "node": ">=0.6" } }, - "node_modules/@commercetools-backend/express/node_modules/serve-static/node_modules/ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" - }, "node_modules/levn": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", @@ -4046,11 +3897,6 @@ "node": ">=0.10.0" } }, - "node_modules/express-unless": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/express-unless/-/express-unless-2.1.3.tgz", - "integrity": "sha512-wj4tLMyCVYuIIKHGt0FhCtIViBcwzWejX0EjNxveAa6dG+0XBCQhMbx+PnkLkFCxLC69qoFrxds4pIyL88inaQ==" - }, "node_modules/json-buffer": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", @@ -4090,9 +3936,9 @@ "dev": true }, "node_modules/@mollie/api-client/node_modules/axios": { - "version": "1.6.8", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.8.tgz", - "integrity": "sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ==", + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.4.tgz", + "integrity": "sha512-DukmaFRnY6AzAALSH4J2M3k6PkaC+MfaAGdEERRWcC9q3/TWQwLpHR8ZRLKTdQ3aBDL64EdluRDjJqKw+BPZEw==", "dependencies": { "follow-redirects": "^1.14.9", "form-data": "^4.0.0" @@ -4275,9 +4121,9 @@ } }, "node_modules/cookie": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", - "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==", + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.1.tgz", + "integrity": "sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==", "engines": { "node": ">= 0.6" } @@ -4493,18 +4339,6 @@ "node": ">=0.10.0" } }, - "node_modules/https-proxy-agent": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", - "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", - "dependencies": { - "agent-base": "6", - "debug": "4" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/lodash.clonedeep": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", @@ -4541,19 +4375,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/@commercetools-backend/express/node_modules/serve-static/node_modules/encodeurl": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", - "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/@commercetools/connect-payments-sdk/node_modules/@types/triple-beam": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/@types/triple-beam/-/triple-beam-1.3.5.tgz", - "integrity": "sha512-6WaYesThRMCl19iryMYP7/x2OVgCtbIVflDGFpWnb9irXI3UjYE4AzmYuiUKY1AJstGijoY+MgUszMgRxIYTYw==" - }, "node_modules/shell-quote": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.1.tgz", @@ -5521,12 +5342,15 @@ } }, "node_modules/@commercetools/ts-client": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@commercetools/ts-client/-/ts-client-2.1.0.tgz", - "integrity": "sha512-xsZRMxSik24CcWuUclE4bjIArSkepGGcWkHbkp4HgORxstLPROeMo+1+vSSTigShQAm9CZeJvXe8cQc5zUtGhw==", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@commercetools/ts-client/-/ts-client-2.0.5.tgz", + "integrity": "sha512-v1hdwMdyGV/ja+pdgTvnA/qLiZ67Zepbaj1WzucHa/ub9V78ZuezZTExTFKhSMFm5c+mMzLwq0UpacAYlu4nmA==", "dependencies": { "abort-controller": "3.0.0", - "node-fetch": "^2.6.1" + "async-mutex": "^0.5.0", + "buffer": "^6.0.3", + "node-fetch": "^2.6.1", + "uuid": "10.0.0" }, "engines": { "node": ">=14" @@ -5597,9 +5421,12 @@ } }, "node_modules/triple-beam": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/triple-beam/-/triple-beam-1.3.0.tgz", - "integrity": "sha512-XrHUvV5HpdLmIj4uVMxHggLbFSZYIn7HEWsqePZcI50pco+MPqJ50wMGY794X7AOOhxOBAjbkqfAbEe/QMp2Lw==" + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/triple-beam/-/triple-beam-1.4.1.tgz", + "integrity": "sha512-aZbgViZrg1QNcG+LULa7nhZpJTZSLm/mXnHXnbAbjmN5aSa0y7V+wvv6+4WaBtpISJzThKy+PIPxc1Nq1EJ9mg==", + "engines": { + "node": ">= 14.0.0" + } }, "node_modules/lru-memoizer": { "version": "2.3.0", @@ -5783,14 +5610,6 @@ "node": ">=6.5" } }, - "node_modules/express/node_modules/cookie": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", - "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", - "engines": { - "node": ">= 0.6" - } - }, "node_modules/uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", @@ -5951,20 +5770,20 @@ } }, "node_modules/@commercetools-backend/loggers": { - "version": "21.25.2", - "resolved": "https://registry.npmjs.org/@commercetools-backend/loggers/-/loggers-21.25.2.tgz", - "integrity": "sha512-+aw9ai7bNzgBBRn9bgCAKCApNavsZCpKqhuOC5KWBngaN/eao8kvuLs8Rs17MGlqkZWD+Smtt67K44LV5nZDpA==", - "dependencies": { - "@babel/runtime": "^7.20.13", - "@babel/runtime-corejs3": "^7.20.13", - "@sentry/node": "7.43.0", - "@types/triple-beam": "1.3.2", + "version": "22.35.0", + "resolved": "https://registry.npmjs.org/@commercetools-backend/loggers/-/loggers-22.35.0.tgz", + "integrity": "sha512-J+3f3m3ORJ2i0pFc7KxJfYNrjUZT3EV9YqEhsTNNg0LEUxoTF3H8+HisRprC9PeIRlbJRFtLiT3/XnbFUufHEQ==", + "dependencies": { + "@babel/runtime": "^7.22.15", + "@babel/runtime-corejs3": "^7.22.15", + "@types/lodash": "^4.14.198", + "@types/triple-beam": "1.3.5", "express-winston": "4.2.0", "fast-safe-stringify": "2.1.1", "lodash": "4.17.21", - "logform": "2.5.1", - "triple-beam": "1.3.0", - "winston": "3.8.2" + "logform": "2.6.0", + "triple-beam": "1.4.1", + "winston": "3.13.0" } }, "node_modules/react-is": { @@ -6386,6 +6205,11 @@ "integrity": "sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==", "dev": true }, + "node_modules/async-mutex/node_modules/tslib": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz", + "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==" + }, "node_modules/@babel/runtime": { "version": "7.24.8", "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.8.tgz", @@ -6451,17 +6275,6 @@ "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", "dev": true }, - "node_modules/agent-base": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", - "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", - "dependencies": { - "debug": "4" - }, - "engines": { - "node": ">= 6.0.0" - } - }, "node_modules/jsesc": { "version": "2.5.2", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", @@ -6982,15 +6795,9 @@ } }, "node_modules/jose": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/jose/-/jose-2.0.7.tgz", - "integrity": "sha512-5hFWIigKqC+e/lRyQhfnirrAqUdIPMB7SJRqflJaO29dW7q5DFvH1XCSTmv6PQ6pb++0k6MJlLRoS0Wv4s38Wg==", - "dependencies": { - "@panva/asn1.js": "^1.0.0" - }, - "engines": { - "node": ">=10.13.0 < 13 || >=13.7.0" - }, + "version": "4.15.9", + "resolved": "https://registry.npmjs.org/jose/-/jose-4.15.9.tgz", + "integrity": "sha512-1vUQX+IdDMVPj4k8kOxgUqlcK518yluMuGZwqlr44FS1ppZB/5GWh4rZG89erpOBOJjU/OBsnCVFfapsRz6nEA==", "funding": { "url": "https://github.com/sponsors/panva" } @@ -7056,14 +6863,6 @@ "node": ">=14" } }, - "node_modules/@sentry/types": { - "version": "7.43.0", - "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.43.0.tgz", - "integrity": "sha512-5XxCWqYWJNoS+P6Ie2ZpUDxLRCt7FTEzmlQkCdjW6MFWOX26hAbF/wEuOTYAFKZXMIXOz0Egofik1e8v1Cg6/A==", - "engines": { - "node": ">=8" - } - }, "node_modules/@types/babel__core": { "version": "7.20.5", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz", @@ -7157,11 +6956,11 @@ } }, "node_modules/winston": { - "version": "3.8.2", - "resolved": "https://registry.npmjs.org/winston/-/winston-3.8.2.tgz", - "integrity": "sha512-MsE1gRx1m5jdTTO9Ld/vND4krP2To+lgDoMEHGGa4HIlAUyXJtfc7CxQcGXVyz2IBpw5hbFkj2b/AtUdQwyRew==", + "version": "3.13.0", + "resolved": "https://registry.npmjs.org/winston/-/winston-3.13.0.tgz", + "integrity": "sha512-rwidmA1w3SE4j0E5MuIufFhyJPBDG7Nu71RkZor1p2+qHvJSZ9GYDA81AyleQcZbh/+V6HjeBdfnTZJm9rSeQQ==", "dependencies": { - "@colors/colors": "1.5.0", + "@colors/colors": "^1.6.0", "@dabh/diagnostics": "^2.0.2", "async": "^3.2.3", "is-stream": "^2.0.0", @@ -7171,20 +6970,12 @@ "safe-stable-stringify": "^2.3.1", "stack-trace": "0.0.x", "triple-beam": "^1.3.0", - "winston-transport": "^4.5.0" + "winston-transport": "^4.7.0" }, "engines": { "node": ">= 12.0.0" } }, - "node_modules/@commercetools/connect-payments-sdk/node_modules/triple-beam": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/triple-beam/-/triple-beam-1.4.1.tgz", - "integrity": "sha512-aZbgViZrg1QNcG+LULa7nhZpJTZSLm/mXnHXnbAbjmN5aSa0y7V+wvv6+4WaBtpISJzThKy+PIPxc1Nq1EJ9mg==", - "engines": { - "node": ">= 14.0.0" - } - }, "node_modules/minimist": { "version": "1.2.8", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", @@ -7295,12 +7086,12 @@ } }, "node_modules/@commercetools/connect-payments-sdk": { - "version": "0.10.1", - "resolved": "https://registry.npmjs.org/@commercetools/connect-payments-sdk/-/connect-payments-sdk-0.10.1.tgz", - "integrity": "sha512-xhHr+zNwaS4LM6vWyJz5Q1206Et8j1EKUrC3VCO2ve5R03m8byPeT3KOgCfE8DexURuQTaPUo1+qf1y2K8EV9Q==", + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/@commercetools/connect-payments-sdk/-/connect-payments-sdk-0.10.0.tgz", + "integrity": "sha512-WLOF3nK1ppipiYkNXdKOAL8eS5WHMkgVBrEocKpZR4JlQyTkXXApVUb1La/evB7MlDuba1tt/YBhQwwRhyJSQw==", "dependencies": { - "@commercetools-backend/loggers": "22.34.0", - "@commercetools/platform-sdk": "7.17.0", + "@commercetools-backend/loggers": "22.32.2", + "@commercetools/platform-sdk": "7.14.0", "@commercetools/sdk-client-v2": "2.5.0", "jsonwebtoken": "9.0.2", "jwks-rsa": "3.1.0", @@ -7338,47 +7129,6 @@ "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", "dev": true }, - "node_modules/@commercetools-backend/express/node_modules/express": { - "version": "4.20.0", - "resolved": "https://registry.npmjs.org/express/-/express-4.20.0.tgz", - "integrity": "sha512-pLdae7I6QqShF5PnNTCVn4hI91Dx0Grkn2+IAsMTgMIKuQVte2dN9PeGSSAME2FR8anOhVA62QDIUaWVfEXVLw==", - "dependencies": { - "type-is": "~1.6.18", - "safe-buffer": "5.2.1", - "finalhandler": "1.2.0", - "fresh": "0.5.2", - "body-parser": "1.20.3", - "content-type": "~1.0.4", - "send": "0.19.0", - "cookie": "0.6.0", - "methods": "~1.1.2", - "proxy-addr": "~2.0.7", - "accepts": "~1.3.8", - "range-parser": "~1.2.1", - "on-finished": "2.4.1", - "debug": "2.6.9", - "encodeurl": "~2.0.0", - "etag": "~1.8.1", - "path-to-regexp": "0.1.10", - "statuses": "2.0.1", - "parseurl": "~1.3.3", - "setprototypeof": "1.2.0", - "merge-descriptors": "1.0.3", - "vary": "~1.1.2", - "serve-static": "1.16.0", - "content-disposition": "0.5.4", - "escape-html": "~1.0.3", - "http-errors": "2.0.0", - "cookie-signature": "1.0.6", - "utils-merge": "1.0.1", - "array-flatten": "1.1.1", - "depd": "2.0.0", - "qs": "6.11.0" - }, - "engines": { - "node": ">= 0.10.0" - } - }, "node_modules/fast-json-stable-stringify": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", @@ -7579,9 +7329,9 @@ } }, "node_modules/express": { - "version": "4.21.0", - "resolved": "https://registry.npmjs.org/express/-/express-4.21.0.tgz", - "integrity": "sha512-VqcNGcj/Id5ZT1LZ/cfihi3ttTn+NJmkli2eZADigjq29qTlWi/hAQ43t/VLPq8+UX06FCEx3ByOYet6ZFblng==", + "version": "4.21.1", + "resolved": "https://registry.npmjs.org/express/-/express-4.21.1.tgz", + "integrity": "sha512-YSFlK1Ee0/GC8QaO91tHcDxJiE/X4FbpAyQWkxAvG6AXCuR65YzK8ua6D9hvi/TzUfZMpc+BwuM1IPw8fmQBiQ==", "dependencies": { "type-is": "~1.6.18", "safe-buffer": "5.2.1", @@ -7590,7 +7340,7 @@ "body-parser": "1.20.3", "content-type": "~1.0.4", "send": "0.19.0", - "cookie": "0.6.0", + "cookie": "0.7.1", "methods": "~1.1.2", "proxy-addr": "~2.0.7", "accepts": "~1.3.8", @@ -7762,29 +7512,6 @@ "balanced-match": "^1.0.0" } }, - "node_modules/@commercetools-backend/express/node_modules/serve-static/node_modules/send": { - "version": "0.18.0", - "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", - "integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==", - "dependencies": { - "debug": "2.6.9", - "depd": "2.0.0", - "destroy": "1.2.0", - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "etag": "~1.8.1", - "fresh": "0.5.2", - "http-errors": "2.0.0", - "mime": "1.6.0", - "ms": "2.1.3", - "on-finished": "2.4.1", - "range-parser": "~1.2.1", - "statuses": "2.0.1" - }, - "engines": { - "node": ">= 0.8.0" - } - }, "node_modules/array.prototype.flat": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.3.2.tgz", @@ -7844,20 +7571,6 @@ "node": ">=6.9.0" } }, - "node_modules/@commercetools-backend/express/node_modules/qs": { - "version": "6.11.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", - "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", - "dependencies": { - "side-channel": "^1.0.4" - }, - "engines": { - "node": ">=0.6" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", @@ -8297,19 +8010,6 @@ "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", "dev": true }, - "node_modules/express-jwt": { - "version": "8.4.1", - "resolved": "https://registry.npmjs.org/express-jwt/-/express-jwt-8.4.1.tgz", - "integrity": "sha512-IZoZiDv2yZJAb3QrbaSATVtTCYT11OcqgFGoTN4iKVyN6NBkBkhtVIixww5fmakF0Upt5HfOxJuS6ZmJVeOtTQ==", - "dependencies": { - "@types/jsonwebtoken": "^9", - "express-unless": "^2.1.3", - "jsonwebtoken": "^9.0.0" - }, - "engines": { - "node": ">= 8.0.0" - } - }, "node_modules/has-property-descriptors": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", @@ -8628,37 +8328,6 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" }, - "node_modules/@commercetools-backend/express": { - "version": "22.32.2", - "resolved": "https://registry.npmjs.org/@commercetools-backend/express/-/express-22.32.2.tgz", - "integrity": "sha512-+N2gY19BLdGSFraDjtXkzIJp6jE9W1qMR2KgOsXw9Mt1idOZI2Ed4o9rDuuWDZodvR35q2yPlgbHKiHZUwn+jw==", - "dependencies": { - "@babel/runtime": "^7.22.15", - "@babel/runtime-corejs3": "^7.22.15", - "@types/express": "^4.17.17", - "@types/node": "^18.17.14", - "express": "4.20.0", - "express-jwt": "8.4.1", - "jwks-rsa": "2.1.5" - } - }, - "node_modules/@commercetools-backend/express/node_modules/finalhandler": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", - "integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==", - "dependencies": { - "debug": "2.6.9", - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "on-finished": "2.4.1", - "parseurl": "~1.3.3", - "statuses": "2.0.1", - "unpipe": "~1.0.0" - }, - "engines": { - "node": ">= 0.8" - } - }, "node_modules/es-object-atoms": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.0.0.tgz", @@ -8713,15 +8382,15 @@ } }, "node_modules/@commercetools/connect-payments-sdk/node_modules/@commercetools/platform-sdk": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@commercetools/platform-sdk/-/platform-sdk-7.17.0.tgz", - "integrity": "sha512-8W7STCwn1z+sJM0xraaRxA6SeQnHbfxOsVwBpKfQfWTEw1mK92WST+vVbLuZmRvsXNgvjuR8VwiI2n5wb/x7jw==", + "version": "7.14.0", + "resolved": "https://registry.npmjs.org/@commercetools/platform-sdk/-/platform-sdk-7.14.0.tgz", + "integrity": "sha512-08/7yAxZFa6s5iKWw+67x17wa4pqiG8WHAW3dECWhkMpTME65qTHz5eyDfcCq8Tayo1rp46g67/2mWxrqapRAA==", "dependencies": { "@commercetools/sdk-client-v2": "^2.5.0", "@commercetools/sdk-middleware-auth": "^7.0.0", "@commercetools/sdk-middleware-http": "^7.0.0", "@commercetools/sdk-middleware-logger": "^3.0.0", - "@commercetools/ts-client": "^2.1.0" + "@commercetools/ts-client": "^2.0.5" }, "engines": { "node": ">=14" @@ -8973,11 +8642,6 @@ "url": "https://opencollective.com/typescript-eslint" } }, - "node_modules/tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" - }, "node_modules/form-data": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", @@ -9087,14 +8751,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/@panva/asn1.js": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@panva/asn1.js/-/asn1.js-1.0.0.tgz", - "integrity": "sha512-UdkG3mLEqXgnlKsWanWcgb6dOjUzJ+XC5f+aWw30qrtjxeNUSfKX1cd5FBzOaXQumoe9nIqeZUvrRJS03HCCtw==", - "engines": { - "node": ">=10.13.0" - } - }, "node_modules/@babel/core": { "version": "7.24.9", "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.24.9.tgz", @@ -9125,11 +8781,6 @@ "url": "https://opencollective.com/babel" } }, - "node_modules/@commercetools-backend/express/node_modules/ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" - }, "node_modules/@sinonjs/fake-timers": { "version": "10.3.0", "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-10.3.0.tgz", @@ -9294,6 +8945,14 @@ } } }, + "node_modules/async-mutex": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/async-mutex/-/async-mutex-0.5.0.tgz", + "integrity": "sha512-1A94B18jkJ3DYq284ohPxoXbfTA5HsQ7/Mf4DEhcyLx3Bz27Rh59iScbB6EPiP+B+joue6YCxcMXSbFC1tZKwA==", + "dependencies": { + "tslib": "^2.4.0" + } + }, "node_modules/string-length": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/string-length/-/string-length-4.0.2.tgz", diff --git a/processor/package.json b/processor/package.json index c0c0c2d..4189fb9 100644 --- a/processor/package.json +++ b/processor/package.json @@ -1,7 +1,11 @@ { "name": "shopmacher-mollie-processor", "description": "Integration between commercetools and mollie payment service provider", +<<<<<<< HEAD "version": "1.2.0", +======= + "version": "1.0.3", +>>>>>>> main "main": "index.js", "private": true, "scripts": { @@ -32,6 +36,9 @@ "engines": { "node": ">=18.0.0 <=20.9.0" }, + "resolutions": { + "axios": "1.7.4" + }, "devDependencies": { "@tsconfig/recommended": "^1.0.7", "@types/express": "^4.17.21", @@ -60,10 +67,9 @@ "typescript": "^5.5.3" }, "dependencies": { - "@commercetools-backend/express": "^22.32.2", - "@commercetools-backend/loggers": "^21.25.2", - "@commercetools/platform-sdk": "^4.11.0", + "@commercetools-backend/loggers": "^22.35.0", "@commercetools/connect-payments-sdk": "^0.10.0", + "@commercetools/platform-sdk": "^4.11.0", "@commercetools/sdk-client-v2": "^2.5.0", "@mollie/api-client": "^3.7.0", "@types/uuid": "^10.0.0", diff --git a/processor/src/commercetools/auth.commercetools.ts b/processor/src/commercetools/auth.commercetools.ts new file mode 100644 index 0000000..473ea13 --- /dev/null +++ b/processor/src/commercetools/auth.commercetools.ts @@ -0,0 +1,22 @@ +import { readConfiguration } from '../utils/config.utils'; +import fetch from 'node-fetch'; + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export const getAccessToken = async (): Promise => { + const config = readConfiguration(); + + const credentials = btoa(config.commerceTools.clientId + ':' + config.commerceTools.clientSecret); + + const headers = { + Authorization: `Basic ${credentials}`, + 'Content-Type': 'application/json', + }; + + const response = await fetch(`${config.commerceTools.authUrl}/oauth/token?grant_type=client_credentials`, { + headers: headers, + method: 'POST', + redirect: 'follow', + }); + + return await response.json(); +}; diff --git a/processor/src/commercetools/extensions.commercetools.ts b/processor/src/commercetools/extensions.commercetools.ts index 6331d47..62f5a46 100644 --- a/processor/src/commercetools/extensions.commercetools.ts +++ b/processor/src/commercetools/extensions.commercetools.ts @@ -3,7 +3,7 @@ import { Extension } from '@commercetools/platform-sdk'; export const PAYMENT_EXTENSION_KEY = 'sctm-payment-create-update-extension'; -export async function createPaymentExtension(applicationUrl: string): Promise { +export async function createPaymentExtension(applicationUrl: string, accessToken: string): Promise { const apiRoot = createApiRoot(); const extension = await getPaymentExtension(); @@ -22,7 +22,7 @@ export async function createPaymentExtension(applicationUrl: string): Promise { - try { - logger.debug('getMethods - Prepare payment methods for the custom application.'); - const data: List = await getAllPaymentMethods({ - locale: Locale.en_US, - include: MethodInclude.pricing, - }); - - return response.status(200).json(data); - } catch (error) { - logger.error( - `getMethods - Unexpected error occurred when preparing payment methods for the custom application`, - error, - ); - return apiError(response, formatErrorResponse(error).errors); - } -}; diff --git a/processor/src/index.ts b/processor/src/index.ts index 161d246..aca96d1 100644 --- a/processor/src/index.ts +++ b/processor/src/index.ts @@ -7,14 +7,12 @@ import bodyParser from 'body-parser'; // Import routes import ProcessorRoutes from './routes/processor.route'; import WebhookRoutes from './routes/webhook.route'; -import ApplicationRoutes from './routes/application.route'; // Import logger import { logger } from './utils/logger.utils'; import { readConfiguration } from './utils/config.utils'; import { errorMiddleware } from './middleware/error.middleware'; -import { createSessionMiddleware } from '@commercetools-backend/express'; // Read env variables readConfiguration(); @@ -32,17 +30,9 @@ app.use(bodyParser.urlencoded({ extended: true })); // Define routes app.use('/processor', ProcessorRoutes); app.use('/webhook', WebhookRoutes); -app.use('/application', ApplicationRoutes); // Global error handler app.use(errorMiddleware); -app.use( - ['/application/*'], - createSessionMiddleware({ - audience: readConfiguration().commerceTools.sessionAudience, - issuer: readConfiguration().commerceTools.sessionIssuer, - }), -); // Listen the application const server = app.listen(PORT, () => { diff --git a/processor/src/middleware/oauth2.middleware.ts b/processor/src/middleware/oauth.middleware.ts similarity index 100% rename from processor/src/middleware/oauth2.middleware.ts rename to processor/src/middleware/oauth.middleware.ts diff --git a/processor/src/mollie/payment.mollie.ts b/processor/src/mollie/payment.mollie.ts index 10289a4..3beea2f 100644 --- a/processor/src/mollie/payment.mollie.ts +++ b/processor/src/mollie/payment.mollie.ts @@ -16,12 +16,6 @@ import { getApiKey } from '../utils/config.utils'; import { MOLLIE_VERSION_STRINGS } from '../utils/constant.utils'; import fetch from 'node-fetch'; -const HEADER = { - 'Content-Type': 'application/json', - Authorization: `Bearer ${getApiKey()}`, - versionStrings: MOLLIE_VERSION_STRINGS, -}; - /** * Creates a Mollie payment using the provided payment parameters. * @@ -114,9 +108,15 @@ export const createPaymentWithCustomMethod = async (paymentParams: PaymentCreate let errorMessage; try { + const headers = { + 'Content-Type': 'application/json', + Authorization: `Bearer ${getApiKey()}`, + versionStrings: MOLLIE_VERSION_STRINGS, + }; + const response = await fetch('https://api.mollie.com/v2/payments', { method: 'POST', - headers: HEADER, + headers, body: JSON.stringify(paymentParams), }); @@ -149,32 +149,6 @@ export const createPaymentWithCustomMethod = async (paymentParams: PaymentCreate } }; -export const getAllPaymentMethods = async (options: MethodsListParams): Promise> => { - let errorMessage; - - try { - const queryParams = new URLSearchParams(options as any).toString(); - const url = `https://api.mollie.com/v2/methods/all?${queryParams}`; - - const response = await fetch(url, { - method: 'GET', - headers: HEADER, - }); - - const data = await response.json(); - return data; - } catch (error: unknown) { - if (!errorMessage) { - errorMessage = 'SCTM - getAllPaymentMethods - Failed to get all payment methods with unknown errors'; - logger.error(errorMessage, { - error, - }); - } - - throw new CustomError(400, errorMessage); - } -}; - export const getApplePaySession = async (options: ApplePaySessionRequest): Promise => { try { return await initMollieClientForApplePaySession().applePay.requestPaymentSession(options); diff --git a/processor/src/routes/application.route.ts b/processor/src/routes/application.route.ts deleted file mode 100644 index d973b45..0000000 --- a/processor/src/routes/application.route.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { Router } from 'express'; -import { getMethods } from '../controllers/application.controller'; - -const serviceRouter = Router(); - -serviceRouter.get('/methods', getMethods); - -export default serviceRouter; diff --git a/processor/src/routes/processor.route.ts b/processor/src/routes/processor.route.ts index 720c714..912e32a 100644 --- a/processor/src/routes/processor.route.ts +++ b/processor/src/routes/processor.route.ts @@ -2,7 +2,7 @@ import { Router } from 'express'; import { post } from '../controllers/processor.controller'; import { install, healthCheck, uninstall, mollieStatus } from '../controllers/connector.controller'; import { readConfiguration } from '../utils/config.utils'; -import { oauthMiddleware } from '../middleware/oauth2.middleware'; +import { oauthMiddleware } from '../middleware/oauth.middleware'; const serviceRouter = Router(); const AUTH_MODE = readConfiguration().commerceTools.authMode === '1'; diff --git a/processor/src/service/connector.service.ts b/processor/src/service/connector.service.ts index 9e9fd8d..ad68651 100644 --- a/processor/src/service/connector.service.ts +++ b/processor/src/service/connector.service.ts @@ -4,8 +4,11 @@ import { createCustomPaymentInterfaceInteractionType, createCustomPaymentTransactionCancelReasonType, } from '../commercetools/customFields.commercetools'; +import { getAccessToken } from '../commercetools/auth.commercetools'; + export const createExtensionAndCustomFields = async (extensionUrl: string): Promise => { - await createPaymentExtension(extensionUrl); + const response = await getAccessToken(); + await createPaymentExtension(extensionUrl, response?.access_token as string); await createCustomPaymentType(); await createCustomPaymentInterfaceInteractionType(); await createCustomPaymentTransactionCancelReasonType(); diff --git a/processor/src/types/index.types.ts b/processor/src/types/index.types.ts index e86712b..fe615b3 100644 --- a/processor/src/types/index.types.ts +++ b/processor/src/types/index.types.ts @@ -21,9 +21,8 @@ export type ConnectorEnvVars = { projectKey: string; scope: string; region: string; + authUrl: string; authMode: string; - sessionAudience: string; - sessionIssuer: string; }; mollie: { testApiKey: string; diff --git a/processor/src/utils/config.utils.ts b/processor/src/utils/config.utils.ts index 65d0e76..1d2b6d0 100644 --- a/processor/src/utils/config.utils.ts +++ b/processor/src/utils/config.utils.ts @@ -16,9 +16,8 @@ export const readConfiguration = () => { projectKey: process.env.CTP_PROJECT_KEY as string, scope: process.env.CTP_SCOPE as string, region: process.env.CTP_REGION as string, + authUrl: process.env.CTP_AUTH_URL as string, authMode: process.env.AUTHENTICATION_MODE as string, - sessionAudience: (process.env.CTP_SESSION_AUDIENCE as string) || 'https://mc.europe-west1.gcp.commercetools.com', - sessionIssuer: (process.env.CTP_SESSION_ISSUER as string) || 'gcp-eu', }, mollie: { testApiKey: process.env.MOLLIE_API_TEST_KEY as string, diff --git a/processor/src/utils/constant.utils.ts b/processor/src/utils/constant.utils.ts index 3e39cee..14e8264 100644 --- a/processor/src/utils/constant.utils.ts +++ b/processor/src/utils/constant.utils.ts @@ -62,6 +62,7 @@ export const CancelStatusText = 'Cancelled from shop side'; export const DUE_DATE_PATTERN = /^(\d+)d$/; export const DEFAULT_DUE_DATE = 14; +<<<<<<< HEAD export const CUSTOM_OBJECT_CONTAINER_NAME = 'sctm-app-methods'; @@ -70,3 +71,5 @@ export const MOLLIE_SURCHARGE_CUSTOM_LINE_ITEM = 'mollie-surcharge-line-item'; export const MOLLIE_SURCHARGE_LINE_DESCRIPTION = 'Total surcharge amount'; export const MOLLIE_SHIPPING_LINE_DESCRIPTION = 'Shipping amount'; +======= +>>>>>>> main diff --git a/processor/src/validators/env.validators.ts b/processor/src/validators/env.validators.ts index fba7ebe..243bfab 100644 --- a/processor/src/validators/env.validators.ts +++ b/processor/src/validators/env.validators.ts @@ -1,4 +1,4 @@ -import { optional, standardKey, standardString, region, standardDueDate } from './helpers.validators'; +import { optional, standardKey, standardString, region, standardDueDate, standardUrl } from './helpers.validators'; /** * Create here your own validators @@ -46,25 +46,11 @@ const envValidators = [ referencedBy: 'environmentVariables', }), - standardString( - ['commerceTools', 'sessionAudience'], - { - code: 'InvalidSessionAudience', - message: 'Not a valid sessionAudience.', - referencedBy: 'environmentVariables', - }, - { min: 1, max: undefined }, - ), - - standardString( - ['commerceTools', 'sessionIssuer'], - { - code: 'InvalidSessionIssuer', - message: 'Not a valid sessionIssuer.', - referencedBy: 'environmentVariables', - }, - { min: 1, max: undefined }, - ), + standardUrl(['commerceTools', 'authUrl'], { + code: 'InvalidAuthUrl', + message: 'Not a valid url.', + referencedBy: 'environmentVariables', + }), standardKey(['mollie', 'testApiKey'], { code: 'InvalidMollieTestApiKey', diff --git a/processor/tests/commercetools/auth.commercetools.spec.ts b/processor/tests/commercetools/auth.commercetools.spec.ts new file mode 100644 index 0000000..abaf9a3 --- /dev/null +++ b/processor/tests/commercetools/auth.commercetools.spec.ts @@ -0,0 +1,42 @@ +import { getAccessToken } from './../../src/commercetools/auth.commercetools'; +import { afterEach, describe, expect, jest, it } from '@jest/globals'; +import fetch from 'node-fetch'; + +// @ts-expect-error: Mock fetch globally +fetch = jest.fn() as jest.Mock; + +describe('test getAccessToken', () => { + afterEach(() => { + jest.clearAllMocks(); // Clear all mocks after each test + }); + + it('should call fetch with the correct parameters', async () => { + const expectedHeaders = { + Authorization: `Basic ${btoa(`${process.env.CTP_CLIENT_ID}:${process.env.CTP_CLIENT_SECRET}`)}`, + 'Content-Type': 'application/json', + }; + + const expectedUrl = `${process.env.CTP_AUTH_URL}/oauth/token?grant_type=client_credentials`; + + (fetch as unknown as jest.Mock).mockImplementation(async () => + Promise.resolve({ + json: () => Promise.resolve({ data: [] }), + headers: new Headers(), + ok: true, + redirected: false, + status: 201, + statusText: 'OK', + url: '', + }), + ); + + await getAccessToken(); + + expect(fetch).toHaveBeenCalledTimes(1); + expect(fetch).toHaveBeenCalledWith(expectedUrl, { + method: 'POST', + headers: expectedHeaders, + redirect: 'follow', + }); + }); +}); diff --git a/processor/tests/commercetools/extension.commercetools.spec.ts b/processor/tests/commercetools/extension.commercetools.spec.ts index 09ee528..b851b95 100644 --- a/processor/tests/commercetools/extension.commercetools.spec.ts +++ b/processor/tests/commercetools/extension.commercetools.spec.ts @@ -170,7 +170,9 @@ describe('Test extension.commercetools', () => { }), ); - await createPaymentExtension(mockUrl); + const accessToken = 'token123'; + + await createPaymentExtension(mockUrl, accessToken); expect(getExtensions).toHaveBeenCalledTimes(1); expect(withKey).toHaveBeenCalledTimes(1); @@ -190,7 +192,7 @@ describe('Test extension.commercetools', () => { url: mockUrl, authentication: { type: 'AuthorizationHeader', - headerValue: 'Bearer _token_', + headerValue: `Bearer ${accessToken}`, }, }, triggers: [ @@ -213,7 +215,9 @@ describe('Test extension.commercetools', () => { }), ); - await createPaymentExtension(mockUrl); + const accessToken = 'token123'; + + await createPaymentExtension(mockUrl, accessToken); expect(getExtensions).toHaveBeenCalledTimes(1); expect(createMock).toHaveBeenCalledTimes(1); @@ -225,7 +229,7 @@ describe('Test extension.commercetools', () => { url: mockUrl, authentication: { type: 'AuthorizationHeader', - headerValue: 'Bearer _token_', + headerValue: `Bearer ${accessToken}`, }, }, triggers: [ diff --git a/processor/tests/service/payment.service.spec.ts b/processor/tests/service/payment.service.spec.ts index 27a5147..bb6ee6c 100644 --- a/processor/tests/service/payment.service.spec.ts +++ b/processor/tests/service/payment.service.spec.ts @@ -1,9 +1,12 @@ +<<<<<<< HEAD import { getMethodConfigObjects, getSingleMethodConfigObject, } from './../../src/commercetools/customObjects.commercetools'; +======= +>>>>>>> main import { afterEach, beforeEach, describe, expect, it, jest, test } from '@jest/globals'; -import { Cart, CustomFields, Payment } from '@commercetools/platform-sdk'; +import { CustomFields, Payment } from '@commercetools/platform-sdk'; import { getCreatePaymentUpdateAction, getPaymentCancelActions, @@ -49,9 +52,12 @@ import { createCartUpdateActions, createMollieCreatePaymentParams } from '../../ import { CustomPayment } from '../../src/types/mollie.types'; import { changeTransactionState } from '../../src/commercetools/action.commercetools'; import { makeCTMoney, shouldRefundStatusUpdate } from '../../src/utils/mollie.utils'; +<<<<<<< HEAD import { getCartFromPayment, updateCart } from '../../src/commercetools/cart.commercetools'; import { calculateTotalSurchargeAmount } from '../../src/utils/app.utils'; import { removeCartMollieCustomLineItem } from '../../src/service/cart.service'; +======= +>>>>>>> main const uuid = '5c8b0375-305a-4f19-ae8e-07806b101999'; jest.mock('uuid', () => ({ @@ -67,6 +73,7 @@ jest.mock('../../src/commercetools/payment.commercetools', () => ({ updatePayment: jest.fn(), })); +<<<<<<< HEAD jest.mock('../../src/commercetools/cart.commercetools', () => ({ getCartFromPayment: jest.fn(), updateCart: jest.fn(), @@ -77,6 +84,8 @@ jest.mock('../../src/commercetools/customObjects.commercetools', () => ({ getSingleMethodConfigObject: jest.fn(), })); +======= +>>>>>>> main jest.mock('../../src/service/payment.service.ts', () => ({ ...(jest.requireActual('../../src/service/payment.service.ts') as object), getCreatePaymentUpdateAction: jest.fn(), @@ -166,46 +175,9 @@ describe('Test listPaymentMethodsByPayment', () => { }, }, }, - { - resource: 'method', - id: 'bancontact', - description: 'Bancontact', - minimumAmount: { value: '0.01', currency: 'EUR' }, - maximumAmount: null, - image: { - size1x: 'https://www.mollie.com/external/icons/payment-methods/paypal.png', - size2x: 'https://www.mollie.com/external/icons/payment-methods/paypal%402x.png', - svg: 'https://www.mollie.com/external/icons/payment-methods/paypal.svg', - }, - status: 'activated', - _links: { - self: { - href: 'https://api.mollie.com/v2/methods/paypal', - type: 'application/hal+json', - }, - }, - }, - { - resource: 'method', - id: 'banktransfer', - description: 'banktransfer', - minimumAmount: { value: '0.01', currency: 'EUR' }, - maximumAmount: null, - image: { - size1x: 'https://www.mollie.com/external/icons/payment-methods/paypal.png', - size2x: 'https://www.mollie.com/external/icons/payment-methods/paypal%402x.png', - svg: 'https://www.mollie.com/external/icons/payment-methods/paypal.svg', - }, - status: 'activated', - _links: { - self: { - href: 'https://api.mollie.com/v2/methods/paypal', - type: 'application/hal+json', - }, - }, - }, ]); +<<<<<<< HEAD (getMethodConfigObjects as jest.Mock).mockReturnValueOnce([ { id: 'e561ae8b-5d55-4659-b4a7-3bf13a177eaf', @@ -304,6 +276,8 @@ describe('Test listPaymentMethodsByPayment', () => { }, ]); +======= +>>>>>>> main mockResource = { id: 'RANDOMID_12345', paymentMethodInfo: { @@ -313,7 +287,7 @@ describe('Test listPaymentMethodsByPayment', () => { amountPlanned: { type: 'centPrecision', currencyCode: 'EUR', - centAmount: 500000, + centAmount: 1000, fractionDigits: 2, }, custom: { @@ -331,40 +305,12 @@ describe('Test listPaymentMethodsByPayment', () => { expect(response.statusCode).toBe(200); expect(response?.actions?.length).toBeGreaterThan(0); expect(response?.actions?.[0]?.action).toBe('setCustomField'); - expect((response?.actions?.[1] as any)?.value).toBe( - JSON.stringify({ - count: 2, - methods: [ - { - id: 'bancontact', - name: { - 'en-GB': 'bancontact', - }, - description: { - 'en-GB': '', - }, - image: 'https://www.mollie.com/external/icons/payment-methods/bancontact.svg', - order: 0, - }, - { - id: 'banktransfer', - name: { - 'en-GB': 'Bank Transfer', - }, - description: { - 'en-GB': '', - }, - image: 'https://www.mollie.com/external/icons/payment-methods/banktransfer.svg', - order: 0, - }, - ], - }), - ); }); test('call listPaymentMethodsByPayment with no object reference', async () => { (listPaymentMethods as jest.Mock).mockReturnValueOnce([]); +<<<<<<< HEAD (getMethodConfigObjects as jest.Mock).mockReturnValueOnce([ { id: 'e561ae8b-5d55-4659-b4a7-3bf13a177eaf', @@ -464,6 +410,8 @@ describe('Test listPaymentMethodsByPayment', () => { }, ]); +======= +>>>>>>> main mockResource = { typeId: 'payment', paymentMethodInfo: { @@ -599,6 +547,7 @@ describe('Test listPaymentMethodsByPayment', () => { }, ]); +<<<<<<< HEAD (getMethodConfigObjects as jest.Mock).mockReturnValueOnce([ { id: 'e561ae8b-5d55-4659-b4a7-3bf13a177eaf', @@ -705,6 +654,8 @@ describe('Test listPaymentMethodsByPayment', () => { (getCartFromPayment as jest.Mock).mockReturnValue(cart); +======= +>>>>>>> main mockResource = { id: 'RANDOMID_12345', paymentMethodInfo: { @@ -714,7 +665,7 @@ describe('Test listPaymentMethodsByPayment', () => { amountPlanned: { type: 'centPrecision', currencyCode: 'EUR', - centAmount: 200000, + centAmount: 1000, fractionDigits: 2, }, custom: { @@ -782,6 +733,7 @@ describe('Test listPaymentMethodsByPayment', () => { }, ]); +<<<<<<< HEAD (getMethodConfigObjects as jest.Mock).mockReturnValueOnce([ { id: 'e561ae8b-5d55-4659-b4a7-3bf13a177eaf', @@ -886,6 +838,8 @@ describe('Test listPaymentMethodsByPayment', () => { country: 'DE', } as Cart); +======= +>>>>>>> main mockResource = { id: 'RANDOMID_12345', paymentMethodInfo: { diff --git a/processor/tests/utils/config.utils.spec.ts b/processor/tests/utils/config.utils.spec.ts index e36231a..bb690f8 100644 --- a/processor/tests/utils/config.utils.spec.ts +++ b/processor/tests/utils/config.utils.spec.ts @@ -12,9 +12,8 @@ describe('Test src/utils/config.utils.ts', () => { projectKey: process.env.CTP_PROJECT_KEY, scope: process.env.CTP_SCOPE, region: process.env.CTP_REGION, + authUrl: process.env.CTP_AUTH_URL, authMode: process.env.AUTHENTICATION_MODE, - sessionAudience: process.env.CTP_SESSION_AUDIENCE, - sessionIssuer: process.env.CTP_SESSION_ISSUER, }, mollie: { liveApiKey: process.env.MOLLIE_API_LIVE_KEY, diff --git a/processor/tests/validators/env.validators.spec.ts b/processor/tests/validators/env.validators.spec.ts index e533b5b..12b81da 100644 --- a/processor/tests/validators/env.validators.spec.ts +++ b/processor/tests/validators/env.validators.spec.ts @@ -67,29 +67,17 @@ describe('Test env.validators.ts', () => { index1: 5, index2: 0, field1: 'commerceTools', - field2: 'sessionAudience', + field2: 'authUrl', error: { - code: 'InvalidSessionAudience', - message: 'Not a valid sessionAudience.', + code: 'InvalidAuthUrl', + message: 'Not a valid url.', referencedBy: 'environmentVariables', }, - condition: { min: 1, max: undefined }, + condition: undefined, }, { index1: 6, index2: 0, - field1: 'commerceTools', - field2: 'sessionIssuer', - error: { - code: 'InvalidSessionIssuer', - message: 'Not a valid sessionIssuer.', - referencedBy: 'environmentVariables', - }, - condition: { min: 1, max: undefined }, - }, - { - index1: 7, - index2: 0, field1: 'mollie', field2: 'testApiKey', error: { @@ -100,7 +88,7 @@ describe('Test env.validators.ts', () => { condition: undefined, }, { - index1: 8, + index1: 7, index2: 0, field1: 'mollie', field2: 'liveApiKey', @@ -112,7 +100,7 @@ describe('Test env.validators.ts', () => { condition: undefined, }, { - index1: 9, + index1: 8, index2: 0, field1: 'mollie', field2: 'profileId', @@ -124,7 +112,7 @@ describe('Test env.validators.ts', () => { condition: undefined, }, { - index1: 10, + index1: 9, index2: 0, field1: 'mollie', field2: 'debug', @@ -136,7 +124,7 @@ describe('Test env.validators.ts', () => { condition: { min: 1, max: 1 }, }, { - index1: 11, + index1: 10, index2: 0, field1: 'mollie', field2: 'cardComponent', @@ -148,7 +136,7 @@ describe('Test env.validators.ts', () => { condition: { min: 1, max: 1 }, }, { - index1: 12, + index1: 11, index2: 0, field1: 'mollie', field2: 'mode', @@ -160,7 +148,7 @@ describe('Test env.validators.ts', () => { condition: { min: 1, max: 4 }, }, { - index1: 13, + index1: 12, index2: 0, field1: 'mollie', field2: 'bankTransferDueDate', @@ -172,7 +160,7 @@ describe('Test env.validators.ts', () => { }, }, { - index1: 14, + index1: 13, index2: 0, field1: 'commerceTools', field2: 'authMode', diff --git a/processor/tests/validators/helpers.validators.spec.ts b/processor/tests/validators/helpers.validators.spec.ts index 509e604..c48b7b6 100644 --- a/processor/tests/validators/helpers.validators.spec.ts +++ b/processor/tests/validators/helpers.validators.spec.ts @@ -255,9 +255,8 @@ describe('Test helpers.validators.ts', () => { projectKey: process.env.CTP_PROJECT_KEY as string, scope: process.env.CTP_SCOPE as string, region: process.env.CTP_REGION as string, + authUrl: process.env.CTP_AUTH_URL as string, authMode: process.env.AUTHENTICATION_MODE as string, - sessionAudience: process.env.CTP_SESSION_AUDIENCE as string, - sessionIssuer: process.env.CTP_SESSION_ISSUER as string, }, mollie: { liveApiKey: process.env.MOLLIE_API_LIVE_KEY as string, @@ -282,9 +281,8 @@ describe('Test helpers.validators.ts', () => { projectKey: process.env.CTP_PROJECT_KEY as string, scope: process.env.CTP_SCOPE as string, region: process.env.CTP_REGION as string, + authUrl: process.env.CTP_AUTH_URL as string, authMode: process.env.AUTHENTICATION_MODE as string, - sessionAudience: process.env.CTP_SESSION_AUDIENCE as string, - sessionIssuer: process.env.CTP_SESSION_ISSUER as string, }, mollie: { liveApiKey: process.env.MOLLIE_API_LIVE_KEY as string, @@ -349,9 +347,8 @@ describe('test getValidateMessages', () => { projectKey: process.env.CTP_PROJECT_KEY as string, scope: process.env.CTP_SCOPE as string, region: process.env.CTP_REGION as string, + authUrl: process.env.CTP_AUTH_URL as string, authMode: process.env.AUTHENTICATION_MODE as string, - sessionAudience: process.env.CTP_SESSION_AUDIENCE as string, - sessionIssuer: process.env.CTP_SESSION_ISSUER as string, }, mollie: { testApiKey: process.env.MOLLIE_API_TEST_KEY as string, @@ -384,9 +381,8 @@ describe('test getValidateMessages', () => { projectKey: process.env.CTP_PROJECT_KEY as string, scope: process.env.CTP_SCOPE as string, region: process.env.CTP_REGION as string, + authUrl: process.env.CTP_AUTH_URL as string, authMode: process.env.AUTHENTICATION_MODE as string, - sessionAudience: process.env.CTP_SESSION_AUDIENCE as string, - sessionIssuer: process.env.CTP_SESSION_ISSUER as string, }, mollie: { testApiKey: process.env.MOLLIE_API_TEST_KEY as string, @@ -419,9 +415,8 @@ describe('test getValidateMessages', () => { projectKey: process.env.CTP_PROJECT_KEY as string, scope: process.env.CTP_SCOPE as string, region: process.env.CTP_REGION as string, + authUrl: process.env.CTP_AUTH_URL as string, authMode: process.env.AUTHENTICATION_MODE as string, - sessionAudience: process.env.CTP_SESSION_AUDIENCE as string, - sessionIssuer: process.env.CTP_SESSION_ISSUER as string, }, mollie: { testApiKey: process.env.MOLLIE_API_TEST_KEY as string,