From 3c21edc2950eeb3f104661d6dd7ff2df06722b60 Mon Sep 17 00:00:00 2001 From: Win Date: Fri, 10 Jan 2025 19:08:00 +0700 Subject: [PATCH 1/7] MOL-592 + MOL-593 - remove card component enable + banktransfer due date config in processor setting - add card component enable config to custom app - add banktransfer due date config to custom app - minor update for test cases --- application/custom-application-config.ts | 2 +- application/cypress/e2e/method-details.cy.ts | 18 ++ application/package.json | 1 + .../src/components/method-details/messages.ts | 21 ++ .../method-details/method-details-form.tsx | 63 ++++- .../src/components/method-details/validate.ts | 15 +- application/src/types.ts | 2 + application/yarn.lock | 62 +++++ connect.yaml | 7 - processor/package-lock.json | 244 +++++------------- processor/package.json | 4 +- processor/src/service/payment.service.ts | 25 +- processor/src/utils/map.utils.ts | 12 +- .../tests/service/payment.service.spec.ts | 2 + 14 files changed, 261 insertions(+), 217 deletions(-) diff --git a/application/custom-application-config.ts b/application/custom-application-config.ts index 95fe782..5a8d35f 100644 --- a/application/custom-application-config.ts +++ b/application/custom-application-config.ts @@ -15,7 +15,7 @@ const config = { cloudIdentifier: CLOUD_IDENTIFIER, env: { development: { - initialProjectKey: 'shopm-adv-windev', + initialProjectKey: 'your_project_key', }, production: { applicationId: CUSTOM_APPLICATION_ID, diff --git a/application/cypress/e2e/method-details.cy.ts b/application/cypress/e2e/method-details.cy.ts index 9cee950..a8469d1 100644 --- a/application/cypress/e2e/method-details.cy.ts +++ b/application/cypress/e2e/method-details.cy.ts @@ -57,4 +57,22 @@ describe('Test welcome.cy.ts', () => { 20 ); }); + + it('credit card component visibility config should exist', () => { + const paymentMethodIds = ['creditcard']; + + cy.findByTestId(`display-order-column-${paymentMethodIds[0]}`).click(); + cy.url().should('contain', 'general'); + + cy.findByTestId(`display-card-component`).should('exist'); + }); + + it('banktransfer due date config should exist', () => { + const paymentMethodIds = ['banktransfer']; + + cy.findByTestId(`display-order-column-${paymentMethodIds[0]}`).click(); + cy.url().should('contain', 'general'); + + cy.findByTestId(`banktransfer-due-date`).should('exist'); + }); }); diff --git a/application/package.json b/application/package.json index 4bd9fb0..7693f99 100644 --- a/application/package.json +++ b/application/package.json @@ -54,6 +54,7 @@ "@commercetools-uikit/grid": "^19.9.0", "@commercetools-uikit/hooks": "^19.9.0", "@commercetools-uikit/icons": "^19.9.0", + "@commercetools-uikit/label": "^19.20.1", "@commercetools-uikit/link": "^19.9.0", "@commercetools-uikit/loading-spinner": "^19.9.0", "@commercetools-uikit/localized-text-field": "^19.9.0", diff --git a/application/src/components/method-details/messages.ts b/application/src/components/method-details/messages.ts index 4b13eb7..0f53f4f 100644 --- a/application/src/components/method-details/messages.ts +++ b/application/src/components/method-details/messages.ts @@ -86,4 +86,25 @@ export default defineMessages({ id: 'MethodDetails.fieldMustBeEqualOrGreaterThanZero', defaultMessage: 'The amount must be equal or greater than 0', }, + fieldDisplayCardComponenet: { + id: 'MethodDetails.fieldDisplayCardComponent', + defaultMessage: 'Display card component', + }, + fieldDisplayCardComponenetDescription: { + id: 'MethodDetails.fieldDisplayCardComponenetDescription', + defaultMessage: + 'Enable Mollie card components (0 = disabled or 1 = enabled)', + }, + fieldBanktransaferDueDate: { + id: 'MethodDetails.fieldBanktransaferDueDate', + defaultMessage: 'Banktransfer due date', + }, + fieldBanktransaferDueDateDescription: { + id: 'MethodDetails.fieldBankDueDateDescription', + defaultMessage: 'Set due date between (1d -> 100d)', + }, + fieldBanktransaferDueDateIsNotAString: { + id: 'MethodDetails.fieldBanktransaferDueDateIsNotAString', + defaultMessage: 'Due date must be a string e.g. 25d, 9d', + }, }); diff --git a/application/src/components/method-details/method-details-form.tsx b/application/src/components/method-details/method-details-form.tsx index abac5e6..c4554ba 100644 --- a/application/src/components/method-details/method-details-form.tsx +++ b/application/src/components/method-details/method-details-form.tsx @@ -13,6 +13,10 @@ import { } from '@commercetools-frontend/application-components'; import Text from '@commercetools-uikit/text'; import validate from './validate'; +import ToggleInput from '@commercetools-uikit/toggle-input'; +import Constraints from '@commercetools-uikit/constraints'; +import { SupportedPaymentMethods } from '../../types/app'; +import FieldLabel from '@commercetools-uikit/field-label'; type Formik = ReturnType; type FormProps = { @@ -170,6 +174,55 @@ const MethodDetailsForm = (props: TCustomObjectDetailsFormProps) => { + {formik.values.id === SupportedPaymentMethods.creditcard && ( + + + + + )} + + {formik.values.id === SupportedPaymentMethods.banktransfer && ( + (formik.errors) + .banktransferDueDate + } + touched={Boolean(formik.touched.banktransferDueDate)} + onChange={formik.handleChange} + onBlur={formik.handleBlur} + isReadOnly={props.isReadOnly} + horizontalConstraint={13} + renderError={(errorKey) => { + if (errorKey === 'IsNotAString') { + return intl.formatMessage( + messages.fieldBanktransaferDueDateIsNotAString + ); + } + return null; + }} + data-testid="banktransfer-due-date" + > + )} ); @@ -190,19 +243,11 @@ const MethodDetailsForm = (props: TCustomObjectDetailsFormProps) => { TextField.toFieldErrors(formik.errors) .imageUrl } - touched={Boolean(formik.touched.displayOrder)} + touched={Boolean(formik.touched.imageUrl)} onChange={formik.handleChange} onBlur={formik.handleBlur} isReadOnly={props.isReadOnly} horizontalConstraint={13} - renderError={(errorKey) => { - if (errorKey === 'isNotInteger') { - return intl.formatMessage( - messages.fieldMethodDisplayOrderIsNotInteger - ); - } - return null; - }} data-testid="image-url-input" > diff --git a/application/src/components/method-details/validate.ts b/application/src/components/method-details/validate.ts index b970158..f4828df 100644 --- a/application/src/components/method-details/validate.ts +++ b/application/src/components/method-details/validate.ts @@ -1,11 +1,12 @@ import omitEmpty from 'omit-empty-es'; -import type { FormikErrors } from 'formik'; +import { type FormikErrors } from 'formik'; import type { TMethodObjectValueFormValues } from '../../types'; type TMethodObjectErrors = { name: { invalidLength?: boolean }; description: { invalidLength?: boolean }; displayOrder: { isNotInteger?: boolean }; + banktransferDueDate: { IsNotAString?: boolean }; }; const validate = ( @@ -15,6 +16,7 @@ const validate = ( name: {}, description: {}, displayOrder: {}, + banktransferDueDate: {}, }; if ( @@ -38,6 +40,17 @@ const validate = ( ) { errors.displayOrder.isNotInteger = true; } + if (formikValues.banktransferDueDate) { + const dateValue = formikValues.banktransferDueDate.replace('d', ''); + if ( + !formikValues.banktransferDueDate.includes('d') || + isNaN(parseInt(dateValue)) || + parseInt(dateValue) < 0 || + parseInt(dateValue) > 100 + ) { + errors.banktransferDueDate.IsNotAString = true; + } + } return omitEmpty(errors); }; diff --git a/application/src/types.ts b/application/src/types.ts index 39411af..36c4bd4 100644 --- a/application/src/types.ts +++ b/application/src/types.ts @@ -30,6 +30,8 @@ export type TMethodObjectValueFormValues = { status: string; displayOrder: number; pricingConstraints?: TPricingConstraintItem[]; + displayCardComponent?: boolean; + banktransferDueDate?: string; }; export type TAvailabilityObjectValueFormValues = { diff --git a/application/yarn.lock b/application/yarn.lock index d363cf4..df9f278 100644 --- a/application/yarn.lock +++ b/application/yarn.lock @@ -2417,6 +2417,19 @@ prop-types "15.8.1" react "17.0.2" +"@commercetools-uikit/design-system@19.20.1": + version "19.20.1" + resolved "https://registry.yarnpkg.com/@commercetools-uikit/design-system/-/design-system-19.20.1.tgz#b0a2f3b9fdf68cb335c12b670941e7ac12457a1e" + integrity sha512-AVtdulOkX+mQKZynRNfOOZSkNcGOaC668pWjXWwM1bH4T+kqnMqnAAMgxHd3P6/Xi5cQy6+ul+lJ1HkJWywcyA== + dependencies: + "@babel/runtime" "^7.20.13" + "@babel/runtime-corejs3" "^7.20.13" + "@commercetools-uikit/hooks" "19.20.1" + "@emotion/react" "^11.10.5" + lodash "4.17.21" + prop-types "15.8.1" + react "17.0.2" + "@commercetools-uikit/dropdown-menu@19.13.0": version "19.13.0" resolved "https://registry.yarnpkg.com/@commercetools-uikit/dropdown-menu/-/dropdown-menu-19.13.0.tgz#fc59495a756b4c1999aab11a8c74bce6e6266b20" @@ -2524,6 +2537,18 @@ lodash "4.17.21" raf-schd "^4.0.3" +"@commercetools-uikit/hooks@19.20.1": + version "19.20.1" + resolved "https://registry.yarnpkg.com/@commercetools-uikit/hooks/-/hooks-19.20.1.tgz#d40f99af7ce06a84174f5d6529741fb23bed5f62" + integrity sha512-A4sfyW2Sj3RFjhIf/4yz2hh0JUPT2mKQ50pJx/XV4wpIFxsL5i4v8iPIlO20m806EVUVIjT31u2zV++ICUHs/w== + dependencies: + "@babel/runtime" "^7.20.13" + "@babel/runtime-corejs3" "^7.20.13" + "@commercetools-uikit/utils" "19.20.1" + "@types/raf-schd" "^4.0.1" + lodash "4.17.21" + raf-schd "^4.0.3" + "@commercetools-uikit/i18n@^19.9.0": version "19.13.0" resolved "https://registry.yarnpkg.com/@commercetools-uikit/i18n/-/i18n-19.13.0.tgz#c02dbe1584aea6d556bb2db1d5d241c4f2d49569" @@ -2595,6 +2620,20 @@ "@emotion/styled" "^11.10.5" prop-types "15.8.1" +"@commercetools-uikit/label@^19.20.1": + version "19.20.1" + resolved "https://registry.yarnpkg.com/@commercetools-uikit/label/-/label-19.20.1.tgz#7e94ab2a30fc76d3ea5c82c62bb9ad50e5bba15f" + integrity sha512-sX4rixFzUjt/RMBkvP50ZgDQ6Q727QRVjVNg8HNsT9VxsYao38YozF22LO3o1Hj4BukL+vepK1+gtyfk9b/cWg== + dependencies: + "@babel/runtime" "^7.20.13" + "@babel/runtime-corejs3" "^7.20.13" + "@commercetools-uikit/design-system" "19.20.1" + "@commercetools-uikit/text" "19.20.1" + "@commercetools-uikit/utils" "19.20.1" + "@emotion/react" "^11.10.5" + "@emotion/styled" "^11.10.5" + prop-types "15.8.1" + "@commercetools-uikit/link@^19.9.0": version "19.13.0" resolved "https://registry.yarnpkg.com/@commercetools-uikit/link/-/link-19.13.0.tgz#603c3b051b098b9102dc94e5a76890f4fbe74c59" @@ -3083,6 +3122,20 @@ prop-types "15.8.1" warning "4.0.3" +"@commercetools-uikit/text@19.20.1": + version "19.20.1" + resolved "https://registry.yarnpkg.com/@commercetools-uikit/text/-/text-19.20.1.tgz#4b3a549dbbb1e5a2d72574701e75ca63f9d17a47" + integrity sha512-G2rYV5q0nT2cNFjE2t6hyiI3G/fdYL8FUL8E22bp1RzokotCGTpmQIzETiCW29qc+ZpmXYjl57xxE6B0FCcEQg== + dependencies: + "@babel/runtime" "^7.20.13" + "@babel/runtime-corejs3" "^7.20.13" + "@commercetools-uikit/design-system" "19.20.1" + "@commercetools-uikit/utils" "19.20.1" + "@emotion/react" "^11.10.5" + lodash "4.17.21" + prop-types "15.8.1" + warning "4.0.3" + "@commercetools-uikit/toggle-input@^19.11.0": version "19.13.0" resolved "https://registry.yarnpkg.com/@commercetools-uikit/toggle-input/-/toggle-input-19.13.0.tgz#01e8efe46d5b774511dbb0de0877ce71108a4fb6" @@ -3125,6 +3178,15 @@ "@babel/runtime-corejs3" "^7.20.13" "@emotion/is-prop-valid" "1.3.1" +"@commercetools-uikit/utils@19.20.1": + version "19.20.1" + resolved "https://registry.yarnpkg.com/@commercetools-uikit/utils/-/utils-19.20.1.tgz#2691045a826eaebbc230478bf5964aaad799181a" + integrity sha512-8nYmB4BD4dFXzP2zxyj6BcrMgo6LCyus9i+bLX9Y2vtqybWsipH6N87wpM6R+IATA8C4k76QLz5J2wwVWYOqeQ== + dependencies: + "@babel/runtime" "^7.20.13" + "@babel/runtime-corejs3" "^7.20.13" + "@emotion/is-prop-valid" "1.3.1" + "@commercetools/api-request-builder@6.0.0": version "6.0.0" resolved "https://registry.yarnpkg.com/@commercetools/api-request-builder/-/api-request-builder-6.0.0.tgz#7c0b8104f4d3655ac8bdb79dee3087d747018c0b" diff --git a/connect.yaml b/connect.yaml index d8b5790..6864f32 100644 --- a/connect.yaml +++ b/connect.yaml @@ -15,10 +15,6 @@ deployAs: description: Commercetools Auth URL default: https://auth.europe-west1.gcp.commercetools.com required: true - - key: MOLLIE_CARD_COMPONENT - description: Enable Mollie cart component (0 or 1) - required: false - default: "0" - key: CONNECTOR_MODE description: Either test or live required: true @@ -27,9 +23,6 @@ deployAs: description: Debug mode (0 or 1) required: false default: "0" - - key: MOLLIE_BANK_TRANSFER_DUE_DATE - description: Payment method Bank Transfer due date (1d -> 100d) - default: "14d" - key: AUTHENTICATION_MODE description: To enable secure mode for connector requests using OAuth authentication (0 or 1) required: true diff --git a/processor/package-lock.json b/processor/package-lock.json index a4b3130..dbcf526 100644 --- a/processor/package-lock.json +++ b/processor/package-lock.json @@ -11,7 +11,7 @@ "license": "MIT", "dependencies": { "@commercetools-backend/express": "^22.32.2", - "@commercetools-backend/loggers": "^21.25.2", + "@commercetools-backend/loggers": "^22.37.0", "@commercetools/connect-payments-sdk": "^0.10.0", "@commercetools/platform-sdk": "^4.11.0", "@commercetools/sdk-client-v2": "^2.5.0", @@ -63,9 +63,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 +129,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", @@ -555,34 +542,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 +585,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 +917,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 +1026,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", @@ -1882,9 +1822,9 @@ } }, "node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", "dev": true, "dependencies": { "path-key": "^3.1.0", @@ -2431,6 +2371,11 @@ "pend": "~1.2.0" } }, + "node_modules/express/node_modules/path-to-regexp": { + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz", + "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==" + }, "node_modules/@commercetools/connect-payments-sdk/node_modules/@commercetools-backend/loggers/node_modules/logform": { "version": "2.6.0", "resolved": "https://registry.npmjs.org/logform/-/logform-2.6.0.tgz", @@ -2872,11 +2817,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", @@ -3339,14 +3279,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 +3311,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", @@ -4275,9 +4199,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 +4417,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", @@ -4549,11 +4461,6 @@ "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", @@ -5597,9 +5504,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 +5693,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 +5853,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.37.0", + "resolved": "https://registry.npmjs.org/@commercetools-backend/loggers/-/loggers-22.37.0.tgz", + "integrity": "sha512-85SnVxR0OTJR7RFXFR2KYZQ9wZgEbDahejXXJSL189Cv0N92B8dgzPSR2Jghb5erhWZflXpULH57QbowTEKIqA==", + "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": { @@ -6451,17 +6353,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", @@ -7056,14 +6947,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 +7040,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 +7054,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", @@ -7579,9 +7454,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.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.21.2.tgz", + "integrity": "sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA==", "dependencies": { "type-is": "~1.6.18", "safe-buffer": "5.2.1", @@ -7590,7 +7465,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", @@ -7599,7 +7474,7 @@ "debug": "2.6.9", "encodeurl": "~2.0.0", "etag": "~1.8.1", - "path-to-regexp": "0.1.10", + "path-to-regexp": "0.1.12", "statuses": "2.0.1", "parseurl": "~1.3.3", "setprototypeof": "1.2.0", @@ -7617,6 +7492,10 @@ }, "engines": { "node": ">= 0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, "node_modules/@jest/globals": { @@ -8629,9 +8508,9 @@ "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==", + "version": "22.37.0", + "resolved": "https://registry.npmjs.org/@commercetools-backend/express/-/express-22.37.0.tgz", + "integrity": "sha512-35GnvHA9IwwhRkbs4Wu6bmStrrhZ7dz27RSGOTd0Fnps39yAkU+4GIud9cWvU2Pt8W3vuqSf1wehtGILomUlBg==", "dependencies": { "@babel/runtime": "^7.22.15", "@babel/runtime-corejs3": "^7.22.15", @@ -8973,11 +8852,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", diff --git a/processor/package.json b/processor/package.json index c0c0c2d..c82f5f4 100644 --- a/processor/package.json +++ b/processor/package.json @@ -61,9 +61,9 @@ }, "dependencies": { "@commercetools-backend/express": "^22.32.2", - "@commercetools-backend/loggers": "^21.25.2", - "@commercetools/platform-sdk": "^4.11.0", + "@commercetools-backend/loggers": "^22.37.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/service/payment.service.ts b/processor/src/service/payment.service.ts index da91c83..cad35fc 100644 --- a/processor/src/service/payment.service.ts +++ b/processor/src/service/payment.service.ts @@ -57,7 +57,6 @@ import { setTransactionCustomType, } from '../commercetools/action.commercetools'; import { readConfiguration } from '../utils/config.utils'; -import { toBoolean } from 'validator'; import { CancelParameters, CreateParameters, @@ -134,13 +133,16 @@ const mapMethodToCustomMethod = (method: CustomMethod, configObjects: CustomObje * Determines if the card component should be enabled. * * @param {CustomMethod[]} validatedMethods - The validated payment methods. + * @param {CustomObject[]} configObjects - The configuration objects. * @return {boolean} - True if the card component should be enabled, false otherwise. */ -const shouldEnableCardComponent = (validatedMethods: CustomMethod[]): boolean => { - return ( - toBoolean(readConfiguration().mollie.cardComponent, true) && - validatedMethods.some((method) => method.id === PaymentMethod.creditcard) - ); +const shouldEnableCardComponent = (validatedMethods: CustomMethod[], configObjects: CustomObject[]): boolean => { + if (!configObjects || !configObjects.length) { + return false; + } + + const creditCardConfig = configObjects.find((config) => config.key === PaymentMethod.creditcard); + return creditCardConfig?.value.displayCardComponent?.valueOf() ?? false; }; const mapMollieMethodToCustomMethod = (method: Method) => ({ @@ -214,7 +216,7 @@ export const handleListPaymentMethodsByPayment = async (ctPayment: Payment): Pro const validatedMethods = validateAndSortMethods(customMethods, configObjects); - const enableCardComponent = shouldEnableCardComponent(validatedMethods); + const enableCardComponent = shouldEnableCardComponent(validatedMethods, configObjects); if (billingCountry) { filterMethodsByPricingConstraints(validatedMethods, configObjects, ctPayment, billingCountry); @@ -397,6 +399,7 @@ export const handleCreatePayment = async (ctPayment: Payment): Promise { return ( @@ -412,7 +415,13 @@ export const handleCreatePayment = async (ctPayment: Payment): Promise { @@ -77,7 +76,11 @@ export const mapCommercetoolsPaymentCustomFieldsToMollieListParams = async ( } }; -const getSpecificPaymentParams = (method: PaymentMethod | CustomPaymentMethod, paymentRequest: any) => { +const getSpecificPaymentParams = ( + method: PaymentMethod | CustomPaymentMethod, + paymentRequest: any, + banktransferDueDate: string, +) => { switch (method) { case PaymentMethod.applepay: return paymentRequest.applePayPaymentToken @@ -85,7 +88,7 @@ const getSpecificPaymentParams = (method: PaymentMethod | CustomPaymentMethod, p : {}; case PaymentMethod.banktransfer: return { - dueDate: calculateDueDate(readConfiguration().mollie.bankTransferDueDate), + dueDate: calculateDueDate(banktransferDueDate), }; case PaymentMethod.przelewy24: return { billingEmail: paymentRequest.billingEmail ?? '' }; @@ -115,6 +118,7 @@ export const createMollieCreatePaymentParams = ( extensionUrl: string, surchargeAmountInCent: number, cart: Cart, + banktransferDueDate?: string, ): PaymentCreateParams => { const { amountPlanned, paymentMethodInfo } = payment; @@ -170,7 +174,7 @@ export const createMollieCreatePaymentParams = ( include: paymentRequest.include ?? '', captureMode: paymentRequest.captureMode ?? '', lines: mollieLines, - ...getSpecificPaymentParams(method as PaymentMethod, paymentRequest), + ...getSpecificPaymentParams(method as PaymentMethod, paymentRequest, banktransferDueDate ?? ''), }; return removeEmptyProperties(createPaymentParams) as PaymentCreateParams; diff --git a/processor/tests/service/payment.service.spec.ts b/processor/tests/service/payment.service.spec.ts index e51aeb9..bf454c3 100644 --- a/processor/tests/service/payment.service.spec.ts +++ b/processor/tests/service/payment.service.spec.ts @@ -428,6 +428,7 @@ describe('Test listPaymentMethodsByPayment', () => { surchargeCost: '2%', }, ], + banktransferDueDate: '14d', }, }, { @@ -813,6 +814,7 @@ describe('Test listPaymentMethodsByPayment', () => { surchargeCost: '2%', }, ], + displayCardComponent: true, }, }, { From 25865bc7ad553984264d8a324a967a28899104d5 Mon Sep 17 00:00:00 2001 From: Win Date: Mon, 13 Jan 2025 21:23:49 +0700 Subject: [PATCH 2/7] MOL-592 + MOL-593 - update processor logic + update test cases --- .../method-details/method-details.spec.tsx | 3 +- .../src/validators/payment.validators.ts | 9 +- .../validators/payment.validators.spec.ts | 535 +++++++++++++++++- 3 files changed, 521 insertions(+), 26 deletions(-) diff --git a/application/src/components/method-details/method-details.spec.tsx b/application/src/components/method-details/method-details.spec.tsx index ab4865c..b3bc91a 100644 --- a/application/src/components/method-details/method-details.spec.tsx +++ b/application/src/components/method-details/method-details.spec.tsx @@ -48,7 +48,7 @@ describe('Test method-details.tsx', () => { method: { id: '43c3f945-c429-4719-878f-008cd507c581', container: 'sctm-app-methods', - key: 'paypal', + key: 'creditcard', value: { id: 'creditcard', technicalName: 'Card', @@ -72,6 +72,7 @@ describe('Test method-details.tsx', () => { 'https://www.mollie.com/external/icons/payment-methods/creditcard.svg', status: 'Inactive', displayOrder: 0, + displayCardComponent: false, }, __typename: 'CustomObject', }, diff --git a/processor/src/validators/payment.validators.ts b/processor/src/validators/payment.validators.ts index 62f2fe6..6a677dd 100644 --- a/processor/src/validators/payment.validators.ts +++ b/processor/src/validators/payment.validators.ts @@ -7,9 +7,8 @@ import { ConnectorActions, CustomFields } from '../utils/constant.utils'; import { DeterminePaymentActionType } from '../types/controller.types'; import { CTTransactionState, CTTransactionType } from '../types/commercetools.types'; import { parseStringToJsonObject, validateEmail } from '../utils/app.utils'; -import { readConfiguration } from '../utils/config.utils'; -import { toBoolean } from 'validator'; import { CustomPaymentMethod, SupportedPaymentMethods } from '../types/mollie.types'; +import { getSingleMethodConfigObject } from '../commercetools/customObjects.commercetools'; const throwError = (process: string, errorMessage: string, ctPayment?: CTPayment): void => { logger.error(`SCTM - ${process} - ${errorMessage}`, { @@ -254,7 +253,7 @@ export const checkValidSuccessAuthorizationTransaction = (ctPayment: CTPayment): * The `isInvalid` property indicates if the payment method input is invalid. * The `errorMessage` property contains the error message if the input is invalid. */ -export const checkPaymentMethodSpecificParameters = (ctPayment: CTPayment, method: string): void => { +export const checkPaymentMethodSpecificParameters = async (ctPayment: CTPayment, method: string): Promise => { const paymentCustomFields = parseStringToJsonObject( ctPayment.custom?.fields?.[CustomFields.createPayment.request], CustomFields.createPayment.request, @@ -262,8 +261,10 @@ export const checkPaymentMethodSpecificParameters = (ctPayment: CTPayment, metho ctPayment.id, ); + const paymentMethodConfig = await getSingleMethodConfigObject(method as string); + if (method === MolliePaymentMethods.creditcard) { - const cardComponentEnabled = toBoolean(readConfiguration().mollie.cardComponent, true); + const cardComponentEnabled = paymentMethodConfig.value.banktransferDueDate; if (cardComponentEnabled) { validateCardToken(paymentCustomFields?.cardToken, ctPayment); diff --git a/processor/tests/validators/payment.validators.spec.ts b/processor/tests/validators/payment.validators.spec.ts index 4bfaf56..10cafda 100644 --- a/processor/tests/validators/payment.validators.spec.ts +++ b/processor/tests/validators/payment.validators.spec.ts @@ -19,6 +19,7 @@ import { describe, it, expect, jest, afterEach, test } from '@jest/globals'; import CustomError from '../../src/errors/custom.error'; import SkipError from '../../src/errors/skip.error'; import { logger } from '../../src/utils/logger.utils'; +import { getSingleMethodConfigObject } from '../../src/commercetools/customObjects.commercetools'; jest.mock('@mollie/api-client', () => ({ PaymentMethod: { @@ -31,6 +32,70 @@ jest.mock('@mollie/api-client', () => ({ }, })); +jest.mock('../../src/commercetools/customObjects.commercetools', () => ({ + getMethodConfigObjects: jest.fn().mockReturnValue([ + { + id: 'f15d2887-8f42-49b4-92db-4ca2b75f243c', + version: 10, + versionModifiedAt: '2025-01-13T07:25:41.708Z', + createdAt: '2025-01-09T06:57:32.504Z', + lastModifiedAt: '2025-01-13T07:25:41.708Z', + lastModifiedBy: { + isPlatformClient: true, + user: { typeId: 'user', id: '36c6f34a-44bf-421a-8c1f-0b6aa2be2749' }, + }, + createdBy: { + isPlatformClient: true, + user: { typeId: 'user', id: '36c6f34a-44bf-421a-8c1f-0b6aa2be2749' }, + }, + container: 'sctm-app-methods', + key: 'creditcard', + value: { + id: 'creditcard', + technicalName: 'Card', + name: { 'en-GB': 'Card', 'de-DE': 'Card', 'en-US': 'Card' }, + description: { 'en-GB': '', 'de-DE': '', 'en-US': '' }, + imageUrl: 'https://www.mollie.com/external/icons/payment-methods/creditcard.svg', + status: 'Active', + displayOrder: 20, + displayCardComponent: true, + }, + }, + { + id: '3838910f-6570-40a8-aee7-bf71dc3a4066', + version: 27, + versionModifiedAt: '2025-01-13T09:46:54.989Z', + createdAt: '2025-01-09T06:57:32.599Z', + lastModifiedAt: '2025-01-13T09:46:54.989Z', + lastModifiedBy: { + isPlatformClient: true, + user: { typeId: 'user', id: '36c6f34a-44bf-421a-8c1f-0b6aa2be2749' }, + }, + createdBy: { + isPlatformClient: true, + user: { typeId: 'user', id: '36c6f34a-44bf-421a-8c1f-0b6aa2be2749' }, + }, + container: 'sctm-app-methods', + key: 'banktransfer', + value: { + id: 'banktransfer', + technicalName: 'Bank transfer', + name: { + 'en-GB': 'Bank transfer', + 'de-DE': 'Bank transfer', + 'en-US': 'Bank transfer', + }, + description: { 'en-GB': '', 'de-DE': '', 'en-US': '' }, + imageUrl: 'https://www.mollie.com/external/icons/payment-methods/banktransfer.svg', + status: 'Active', + displayOrder: 0, + banktransferDueDate: '1d', + }, + }, + ]), + getSingleMethodConfigObject: jest.fn(), +})); + describe('checkExtensionAction', () => { afterEach(() => { jest.clearAllMocks(); // Clear all mocks after each test case @@ -248,6 +313,34 @@ describe('checkPaymentMethodInput', () => { it('should call checkPaymentMethodSpecificParameters if the payment method is "creditcard', () => { const paymentValidators = require('../../src/validators/payment.validators'); + (getSingleMethodConfigObject as jest.Mock).mockReturnValue({ + id: 'f15d2887-8f42-49b4-92db-4ca2b75f243c', + version: 10, + versionModifiedAt: '2025-01-13T07:25:41.708Z', + createdAt: '2025-01-09T06:57:32.504Z', + lastModifiedAt: '2025-01-13T07:25:41.708Z', + lastModifiedBy: { + isPlatformClient: true, + user: { typeId: 'user', id: '36c6f34a-44bf-421a-8c1f-0b6aa2be2749' }, + }, + createdBy: { + isPlatformClient: true, + user: { typeId: 'user', id: '36c6f34a-44bf-421a-8c1f-0b6aa2be2749' }, + }, + container: 'sctm-app-methods', + key: 'creditcard', + value: { + id: 'creditcard', + technicalName: 'Card', + name: { 'en-GB': 'Card', 'de-DE': 'Card', 'en-US': 'Card' }, + description: { 'en-GB': '', 'de-DE': '', 'en-US': '' }, + imageUrl: 'https://www.mollie.com/external/icons/payment-methods/creditcard.svg', + status: 'Active', + displayOrder: 20, + displayCardComponent: true, + }, + }); + jest.spyOn(paymentValidators, 'checkPaymentMethodSpecificParameters'); const CTPayment: Payment = { @@ -287,6 +380,38 @@ describe('checkPaymentMethodInput', () => { it('should validate the billing email for banktransfer method', () => { const paymentValidators = require('../../src/validators/payment.validators'); + (getSingleMethodConfigObject as jest.Mock).mockReturnValue({ + id: '3838910f-6570-40a8-aee7-bf71dc3a4066', + version: 27, + versionModifiedAt: '2025-01-13T09:46:54.989Z', + createdAt: '2025-01-09T06:57:32.599Z', + lastModifiedAt: '2025-01-13T09:46:54.989Z', + lastModifiedBy: { + isPlatformClient: true, + user: { typeId: 'user', id: '36c6f34a-44bf-421a-8c1f-0b6aa2be2749' }, + }, + createdBy: { + isPlatformClient: true, + user: { typeId: 'user', id: '36c6f34a-44bf-421a-8c1f-0b6aa2be2749' }, + }, + container: 'sctm-app-methods', + key: 'banktransfer', + value: { + id: 'banktransfer', + technicalName: 'Bank transfer', + name: { + 'en-GB': 'Bank transfer', + 'de-DE': 'Bank transfer', + 'en-US': 'Bank transfer', + }, + description: { 'en-GB': '', 'de-DE': '', 'en-US': '' }, + imageUrl: 'https://www.mollie.com/external/icons/payment-methods/banktransfer.svg', + status: 'Active', + displayOrder: 0, + banktransferDueDate: '1d', + }, + }); + jest.spyOn(paymentValidators, 'checkPaymentMethodSpecificParameters'); jest.spyOn(paymentValidators, 'validateBanktransfer'); @@ -314,7 +439,7 @@ describe('checkPaymentMethodInput', () => { }, fields: { sctm_create_payment_request: - '{"description":"Test","locale":"en_GB","redirectUrl":"https://www.google.com/","cardToken":"token_12345"}', + '{"description":"Test","locale":"en_GB","redirectUrl":"https://www.google.com/","cardToken":"token_12345","billingAddress":{"email":"test@test.com"}}', }, }, }; @@ -345,6 +470,34 @@ describe('checkPaymentMethodSpecificParameters', () => { it('should throw an error if the payment method is creditcard and card component is enabled and cardToken is not defined in Custom Field', () => { process.env.MOLLIE_CARD_COMPONENT = '1'; + (getSingleMethodConfigObject as jest.Mock).mockReturnValue({ + id: 'f15d2887-8f42-49b4-92db-4ca2b75f243c', + version: 10, + versionModifiedAt: '2025-01-13T07:25:41.708Z', + createdAt: '2025-01-09T06:57:32.504Z', + lastModifiedAt: '2025-01-13T07:25:41.708Z', + lastModifiedBy: { + isPlatformClient: true, + user: { typeId: 'user', id: '36c6f34a-44bf-421a-8c1f-0b6aa2be2749' }, + }, + createdBy: { + isPlatformClient: true, + user: { typeId: 'user', id: '36c6f34a-44bf-421a-8c1f-0b6aa2be2749' }, + }, + container: 'sctm-app-methods', + key: 'creditcard', + value: { + id: 'creditcard', + technicalName: 'Card', + name: { 'en-GB': 'Card', 'de-DE': 'Card', 'en-US': 'Card' }, + description: { 'en-GB': '', 'de-DE': '', 'en-US': '' }, + imageUrl: 'https://www.mollie.com/external/icons/payment-methods/creditcard.svg', + status: 'Active', + displayOrder: 20, + displayCardComponent: true, + }, + }); + const CTPayment: Payment = { id: '5c8b0375-305a-4f19-ae8e-07806b101999', version: 1, @@ -411,6 +564,34 @@ describe('checkPaymentMethodSpecificParameters', () => { }, }; + (getSingleMethodConfigObject as jest.Mock).mockReturnValue({ + id: 'f15d2887-8f42-49b4-92db-4ca2b75f243c', + version: 10, + versionModifiedAt: '2025-01-13T07:25:41.708Z', + createdAt: '2025-01-09T06:57:32.504Z', + lastModifiedAt: '2025-01-13T07:25:41.708Z', + lastModifiedBy: { + isPlatformClient: true, + user: { typeId: 'user', id: '36c6f34a-44bf-421a-8c1f-0b6aa2be2749' }, + }, + createdBy: { + isPlatformClient: true, + user: { typeId: 'user', id: '36c6f34a-44bf-421a-8c1f-0b6aa2be2749' }, + }, + container: 'sctm-app-methods', + key: 'creditcard', + value: { + id: 'creditcard', + technicalName: 'Card', + name: { 'en-GB': 'Card', 'de-DE': 'Card', 'en-US': 'Card' }, + description: { 'en-GB': '', 'de-DE': '', 'en-US': '' }, + imageUrl: 'https://www.mollie.com/external/icons/payment-methods/creditcard.svg', + status: 'Active', + displayOrder: 20, + displayCardComponent: true, + }, + }); + try { checkPaymentMethodSpecificParameters(CTPayment, CTPayment.paymentMethodInfo.method as string); } catch (error: unknown) { @@ -428,7 +609,7 @@ describe('checkPaymentMethodSpecificParameters', () => { } }); - it('should throw CustomError if the payment method is creditcard and the custom field sctm_create_payment_request is not a JSON string', () => { + it('should throw CustomError if the payment method is creditcard and the custom field sctm_create_payment_request is not a JSON string', async () => { const CTPayment: Payment = { id: '5c8b0375-305a-4f19-ae8e-07806b101999', version: 1, @@ -457,8 +638,36 @@ describe('checkPaymentMethodSpecificParameters', () => { }, }; + (getSingleMethodConfigObject as jest.Mock).mockReturnValue({ + id: 'f15d2887-8f42-49b4-92db-4ca2b75f243c', + version: 10, + versionModifiedAt: '2025-01-13T07:25:41.708Z', + createdAt: '2025-01-09T06:57:32.504Z', + lastModifiedAt: '2025-01-13T07:25:41.708Z', + lastModifiedBy: { + isPlatformClient: true, + user: { typeId: 'user', id: '36c6f34a-44bf-421a-8c1f-0b6aa2be2749' }, + }, + createdBy: { + isPlatformClient: true, + user: { typeId: 'user', id: '36c6f34a-44bf-421a-8c1f-0b6aa2be2749' }, + }, + container: 'sctm-app-methods', + key: 'creditcard', + value: { + id: 'creditcard', + technicalName: 'Card', + name: { 'en-GB': 'Card', 'de-DE': 'Card', 'en-US': 'Card' }, + description: { 'en-GB': '', 'de-DE': '', 'en-US': '' }, + imageUrl: 'https://www.mollie.com/external/icons/payment-methods/creditcard.svg', + status: 'Active', + displayOrder: 20, + displayCardComponent: true, + }, + }); + try { - checkPaymentMethodSpecificParameters(CTPayment, CTPayment.paymentMethodInfo.method as string); + await checkPaymentMethodSpecificParameters(CTPayment, CTPayment.paymentMethodInfo.method as string); } catch (error: unknown) { expect(error).toBeInstanceOf(CustomError); expect(logger.error).toBeCalledTimes(1); @@ -471,7 +680,7 @@ describe('checkPaymentMethodSpecificParameters', () => { } }); - it('should return true if the payment method is creditcard and cardToken is defined and not an empty string in the Payment custom fields', () => { + it('should return true if the payment method is creditcard and cardToken is defined and not an empty string in the Payment custom fields', async () => { const CTPayment: Payment = { id: '5c8b0375-305a-4f19-ae8e-07806b101999', version: 1, @@ -501,16 +710,76 @@ describe('checkPaymentMethodSpecificParameters', () => { }, }; - expect(checkPaymentMethodSpecificParameters(CTPayment, CTPayment.paymentMethodInfo.method as string)).toBe( + (getSingleMethodConfigObject as jest.Mock).mockReturnValue({ + id: 'f15d2887-8f42-49b4-92db-4ca2b75f243c', + version: 10, + versionModifiedAt: '2025-01-13T07:25:41.708Z', + createdAt: '2025-01-09T06:57:32.504Z', + lastModifiedAt: '2025-01-13T07:25:41.708Z', + lastModifiedBy: { + isPlatformClient: true, + user: { typeId: 'user', id: '36c6f34a-44bf-421a-8c1f-0b6aa2be2749' }, + }, + createdBy: { + isPlatformClient: true, + user: { typeId: 'user', id: '36c6f34a-44bf-421a-8c1f-0b6aa2be2749' }, + }, + container: 'sctm-app-methods', + key: 'creditcard', + value: { + id: 'creditcard', + technicalName: 'Card', + name: { 'en-GB': 'Card', 'de-DE': 'Card', 'en-US': 'Card' }, + description: { 'en-GB': '', 'de-DE': '', 'en-US': '' }, + imageUrl: 'https://www.mollie.com/external/icons/payment-methods/creditcard.svg', + status: 'Active', + displayOrder: 20, + displayCardComponent: true, + }, + }); + + expect(await checkPaymentMethodSpecificParameters(CTPayment, CTPayment.paymentMethodInfo.method as string)).toBe( undefined, ); }); - it('should throw an error if the payment method is banktransfer and the billingAddress is not specified', () => { + it('should throw an error if the payment method is banktransfer and the billingAddress is not specified', async () => { const paymentRequest = { description: 'Test', }; + (getSingleMethodConfigObject as jest.Mock).mockReturnValue({ + id: '3838910f-6570-40a8-aee7-bf71dc3a4066', + version: 27, + versionModifiedAt: '2025-01-13T09:46:54.989Z', + createdAt: '2025-01-09T06:57:32.599Z', + lastModifiedAt: '2025-01-13T09:46:54.989Z', + lastModifiedBy: { + isPlatformClient: true, + user: { typeId: 'user', id: '36c6f34a-44bf-421a-8c1f-0b6aa2be2749' }, + }, + createdBy: { + isPlatformClient: true, + user: { typeId: 'user', id: '36c6f34a-44bf-421a-8c1f-0b6aa2be2749' }, + }, + container: 'sctm-app-methods', + key: 'banktransfer', + value: { + id: 'banktransfer', + technicalName: 'Bank transfer', + name: { + 'en-GB': 'Bank transfer', + 'de-DE': 'Bank transfer', + 'en-US': 'Bank transfer', + }, + description: { 'en-GB': '', 'de-DE': '', 'en-US': '' }, + imageUrl: 'https://www.mollie.com/external/icons/payment-methods/banktransfer.svg', + status: 'Active', + displayOrder: 0, + banktransferDueDate: '1d', + }, + }); + const CTPayment: Payment = { id: '5c8b0375-305a-4f19-ae8e-07806b101999', version: 1, @@ -540,7 +809,7 @@ describe('checkPaymentMethodSpecificParameters', () => { }; try { - checkPaymentMethodSpecificParameters(CTPayment, CTPayment.paymentMethodInfo.method as string); + await checkPaymentMethodSpecificParameters(CTPayment, CTPayment.paymentMethodInfo.method as string); } catch (error: unknown) { expect(error).toBeInstanceOf(CustomError); expect((error as CustomError).message).toBe( @@ -556,7 +825,7 @@ describe('checkPaymentMethodSpecificParameters', () => { } }); - it('should throw an error if the payment method is banktransfer and the billingAddress is specified but does not provide email', () => { + it('should throw an error if the payment method is banktransfer and the billingAddress is specified but does not provide email', async () => { const paymentRequest = { description: 'Test', billingAddress: { @@ -564,6 +833,38 @@ describe('checkPaymentMethodSpecificParameters', () => { }, }; + (getSingleMethodConfigObject as jest.Mock).mockReturnValue({ + id: '3838910f-6570-40a8-aee7-bf71dc3a4066', + version: 27, + versionModifiedAt: '2025-01-13T09:46:54.989Z', + createdAt: '2025-01-09T06:57:32.599Z', + lastModifiedAt: '2025-01-13T09:46:54.989Z', + lastModifiedBy: { + isPlatformClient: true, + user: { typeId: 'user', id: '36c6f34a-44bf-421a-8c1f-0b6aa2be2749' }, + }, + createdBy: { + isPlatformClient: true, + user: { typeId: 'user', id: '36c6f34a-44bf-421a-8c1f-0b6aa2be2749' }, + }, + container: 'sctm-app-methods', + key: 'banktransfer', + value: { + id: 'banktransfer', + technicalName: 'Bank transfer', + name: { + 'en-GB': 'Bank transfer', + 'de-DE': 'Bank transfer', + 'en-US': 'Bank transfer', + }, + description: { 'en-GB': '', 'de-DE': '', 'en-US': '' }, + imageUrl: 'https://www.mollie.com/external/icons/payment-methods/banktransfer.svg', + status: 'Active', + displayOrder: 0, + banktransferDueDate: '1d', + }, + }); + const CTPayment: Payment = { id: '5c8b0375-305a-4f19-ae8e-07806b101999', version: 1, @@ -593,7 +894,7 @@ describe('checkPaymentMethodSpecificParameters', () => { }; try { - checkPaymentMethodSpecificParameters(CTPayment, CTPayment.paymentMethodInfo.method as string); + await checkPaymentMethodSpecificParameters(CTPayment, CTPayment.paymentMethodInfo.method as string); } catch (error: unknown) { expect(error).toBeInstanceOf(CustomError); expect((error as CustomError).message).toBe( @@ -609,7 +910,7 @@ describe('checkPaymentMethodSpecificParameters', () => { } }); - it('should throw an error if the payment method is banktransfer and the email is not valid', () => { + it('should throw an error if the payment method is banktransfer and the email is not valid', async () => { const paymentRequest = { description: 'Test', billingAddress: { @@ -618,6 +919,38 @@ describe('checkPaymentMethodSpecificParameters', () => { }, }; + (getSingleMethodConfigObject as jest.Mock).mockReturnValue({ + id: '3838910f-6570-40a8-aee7-bf71dc3a4066', + version: 27, + versionModifiedAt: '2025-01-13T09:46:54.989Z', + createdAt: '2025-01-09T06:57:32.599Z', + lastModifiedAt: '2025-01-13T09:46:54.989Z', + lastModifiedBy: { + isPlatformClient: true, + user: { typeId: 'user', id: '36c6f34a-44bf-421a-8c1f-0b6aa2be2749' }, + }, + createdBy: { + isPlatformClient: true, + user: { typeId: 'user', id: '36c6f34a-44bf-421a-8c1f-0b6aa2be2749' }, + }, + container: 'sctm-app-methods', + key: 'banktransfer', + value: { + id: 'banktransfer', + technicalName: 'Bank transfer', + name: { + 'en-GB': 'Bank transfer', + 'de-DE': 'Bank transfer', + 'en-US': 'Bank transfer', + }, + description: { 'en-GB': '', 'de-DE': '', 'en-US': '' }, + imageUrl: 'https://www.mollie.com/external/icons/payment-methods/banktransfer.svg', + status: 'Active', + displayOrder: 0, + banktransferDueDate: '1d', + }, + }); + const CTPayment: Payment = { id: '5c8b0375-305a-4f19-ae8e-07806b101999', version: 1, @@ -647,7 +980,7 @@ describe('checkPaymentMethodSpecificParameters', () => { }; try { - checkPaymentMethodSpecificParameters(CTPayment, CTPayment.paymentMethodInfo.method as string); + await checkPaymentMethodSpecificParameters(CTPayment, CTPayment.paymentMethodInfo.method as string); } catch (error: unknown) { expect(error).toBeInstanceOf(CustomError); expect((error as CustomError).message).toBe('SCTM - validateBanktransfer - email must be a valid email address.'); @@ -658,7 +991,7 @@ describe('checkPaymentMethodSpecificParameters', () => { } }); - it('should should not throw any error or terminate the process if the payment method is banktransfer and the email is provided correctly', () => { + it('should should not throw any error or terminate the process if the payment method is banktransfer and the email is provided correctly', async () => { const paymentRequest = { description: 'Test', billingAddress: { @@ -667,6 +1000,38 @@ describe('checkPaymentMethodSpecificParameters', () => { }, }; + (getSingleMethodConfigObject as jest.Mock).mockReturnValue({ + id: '3838910f-6570-40a8-aee7-bf71dc3a4066', + version: 27, + versionModifiedAt: '2025-01-13T09:46:54.989Z', + createdAt: '2025-01-09T06:57:32.599Z', + lastModifiedAt: '2025-01-13T09:46:54.989Z', + lastModifiedBy: { + isPlatformClient: true, + user: { typeId: 'user', id: '36c6f34a-44bf-421a-8c1f-0b6aa2be2749' }, + }, + createdBy: { + isPlatformClient: true, + user: { typeId: 'user', id: '36c6f34a-44bf-421a-8c1f-0b6aa2be2749' }, + }, + container: 'sctm-app-methods', + key: 'banktransfer', + value: { + id: 'banktransfer', + technicalName: 'Bank transfer', + name: { + 'en-GB': 'Bank transfer', + 'de-DE': 'Bank transfer', + 'en-US': 'Bank transfer', + }, + description: { 'en-GB': '', 'de-DE': '', 'en-US': '' }, + imageUrl: 'https://www.mollie.com/external/icons/payment-methods/banktransfer.svg', + status: 'Active', + displayOrder: 0, + banktransferDueDate: '1d', + }, + }); + const CTPayment: Payment = { id: '5c8b0375-305a-4f19-ae8e-07806b101999', version: 1, @@ -695,13 +1060,13 @@ describe('checkPaymentMethodSpecificParameters', () => { }, }; - expect(checkPaymentMethodSpecificParameters(CTPayment, CTPayment.paymentMethodInfo.method as string)).toBe( + expect(await checkPaymentMethodSpecificParameters(CTPayment, CTPayment.paymentMethodInfo.method as string)).toBe( undefined, ); expect(logger.error).toBeCalledTimes(0); }); - it('should throw an error if the payment method is blik and the currency code is not PLN', () => { + it('should throw an error if the payment method is blik and the currency code is not PLN', async () => { const CTPayment: Payment = { id: '5c8b0375-305a-4f19-ae8e-07806b101999', version: 1, @@ -731,8 +1096,40 @@ describe('checkPaymentMethodSpecificParameters', () => { }, }; + (getSingleMethodConfigObject as jest.Mock).mockReturnValue({ + id: '3838910f-6aa0-40a8-aee7-bf71dc3a4066', + version: 15, + versionModifiedAt: '2025-01-13T09:46:54.989Z', + createdAt: '2025-01-09T06:57:32.599Z', + lastModifiedAt: '2025-01-13T09:46:54.989Z', + lastModifiedBy: { + isPlatformClient: true, + user: { typeId: 'user', id: '36c6f34a-44bf-421a-8c1f-0b6aa2be2749' }, + }, + createdBy: { + isPlatformClient: true, + user: { typeId: 'user', id: '36c6f34a-44bf-421a-8c1f-0b6aa2be2749' }, + }, + container: 'sctm-app-methods', + key: 'blik', + value: { + id: 'blik', + technicalName: 'BLIK', + name: { + 'en-GB': 'BLIK', + 'de-DE': 'BLIK', + 'en-US': 'BLIK', + }, + description: { 'en-GB': '', 'de-DE': '', 'en-US': '' }, + imageUrl: 'https://www.mollie.com/external/icons/payment-methods/banktransfer.svg', + status: 'Active', + displayOrder: 0, + banktransferDueDate: '1d', + }, + }); + try { - checkPaymentMethodSpecificParameters(CTPayment, CTPayment.paymentMethodInfo.method as string); + await checkPaymentMethodSpecificParameters(CTPayment, CTPayment.paymentMethodInfo.method as string); } catch (error: unknown) { expect(error).toBeInstanceOf(CustomError); expect((error as CustomError).message).toBe( @@ -745,7 +1142,7 @@ describe('checkPaymentMethodSpecificParameters', () => { } }); - it('should throw an error if the payment method is blik and the billing email is not provided', () => { + it('should throw an error if the payment method is blik and the billing email is not provided', async () => { const CTPayment: Payment = { id: '5c8b0375-305a-4f19-ae8e-07806b101999', version: 1, @@ -775,8 +1172,40 @@ describe('checkPaymentMethodSpecificParameters', () => { }, }; + (getSingleMethodConfigObject as jest.Mock).mockReturnValue({ + id: '3838910f-6aa0-40a8-aee7-bf71dc3a4066', + version: 15, + versionModifiedAt: '2025-01-13T09:46:54.989Z', + createdAt: '2025-01-09T06:57:32.599Z', + lastModifiedAt: '2025-01-13T09:46:54.989Z', + lastModifiedBy: { + isPlatformClient: true, + user: { typeId: 'user', id: '36c6f34a-44bf-421a-8c1f-0b6aa2be2749' }, + }, + createdBy: { + isPlatformClient: true, + user: { typeId: 'user', id: '36c6f34a-44bf-421a-8c1f-0b6aa2be2749' }, + }, + container: 'sctm-app-methods', + key: 'blik', + value: { + id: 'blik', + technicalName: 'BLIK', + name: { + 'en-GB': 'BLIK', + 'de-DE': 'BLIK', + 'en-US': 'BLIK', + }, + description: { 'en-GB': '', 'de-DE': '', 'en-US': '' }, + imageUrl: 'https://www.mollie.com/external/icons/payment-methods/banktransfer.svg', + status: 'Active', + displayOrder: 0, + banktransferDueDate: '1d', + }, + }); + try { - checkPaymentMethodSpecificParameters(CTPayment, CTPayment.paymentMethodInfo.method as string); + await checkPaymentMethodSpecificParameters(CTPayment, CTPayment.paymentMethodInfo.method as string); } catch (error: unknown) { expect(error).toBeInstanceOf(CustomError); expect((error as CustomError).message).toBe( @@ -789,7 +1218,7 @@ describe('checkPaymentMethodSpecificParameters', () => { } }); - it('should throw an error if the payment method is blik and the billing email is provided incorrectly', () => { + it('should throw an error if the payment method is blik and the billing email is provided incorrectly', async () => { const CTPayment: Payment = { id: '5c8b0375-305a-4f19-ae8e-07806b101999', version: 1, @@ -819,8 +1248,40 @@ describe('checkPaymentMethodSpecificParameters', () => { }, }; + (getSingleMethodConfigObject as jest.Mock).mockReturnValue({ + id: '3838910f-6aa0-40a8-aee7-bf71dc3a4066', + version: 15, + versionModifiedAt: '2025-01-13T09:46:54.989Z', + createdAt: '2025-01-09T06:57:32.599Z', + lastModifiedAt: '2025-01-13T09:46:54.989Z', + lastModifiedBy: { + isPlatformClient: true, + user: { typeId: 'user', id: '36c6f34a-44bf-421a-8c1f-0b6aa2be2749' }, + }, + createdBy: { + isPlatformClient: true, + user: { typeId: 'user', id: '36c6f34a-44bf-421a-8c1f-0b6aa2be2749' }, + }, + container: 'sctm-app-methods', + key: 'blik', + value: { + id: 'blik', + technicalName: 'BLIK', + name: { + 'en-GB': 'BLIK', + 'de-DE': 'BLIK', + 'en-US': 'BLIK', + }, + description: { 'en-GB': '', 'de-DE': '', 'en-US': '' }, + imageUrl: 'https://www.mollie.com/external/icons/payment-methods/banktransfer.svg', + status: 'Active', + displayOrder: 0, + banktransferDueDate: '1d', + }, + }); + try { - checkPaymentMethodSpecificParameters(CTPayment, CTPayment.paymentMethodInfo.method as string); + await checkPaymentMethodSpecificParameters(CTPayment, CTPayment.paymentMethodInfo.method as string); } catch (error: unknown) { expect(error).toBeInstanceOf(CustomError); expect((error as CustomError).message).toBe('SCTM - validateBlik - billingEmail must be a valid email address.'); @@ -831,7 +1292,7 @@ describe('checkPaymentMethodSpecificParameters', () => { } }); - it('should should not throw any error or terminate the process if the payment method is blik and the currency code is PLN and the billing email is provided correctly', () => { + it('should should not throw any error or terminate the process if the payment method is blik and the currency code is PLN and the billing email is provided correctly', async () => { const CTPayment: Payment = { id: '5c8b0375-305a-4f19-ae8e-07806b101999', version: 1, @@ -861,7 +1322,39 @@ describe('checkPaymentMethodSpecificParameters', () => { }, }; - expect(checkPaymentMethodSpecificParameters(CTPayment, CTPayment.paymentMethodInfo.method as string)).toBe( + (getSingleMethodConfigObject as jest.Mock).mockReturnValue({ + id: '3838910f-6aa0-40a8-aee7-bf71dc3a4066', + version: 15, + versionModifiedAt: '2025-01-13T09:46:54.989Z', + createdAt: '2025-01-09T06:57:32.599Z', + lastModifiedAt: '2025-01-13T09:46:54.989Z', + lastModifiedBy: { + isPlatformClient: true, + user: { typeId: 'user', id: '36c6f34a-44bf-421a-8c1f-0b6aa2be2749' }, + }, + createdBy: { + isPlatformClient: true, + user: { typeId: 'user', id: '36c6f34a-44bf-421a-8c1f-0b6aa2be2749' }, + }, + container: 'sctm-app-methods', + key: 'blik', + value: { + id: 'blik', + technicalName: 'BLIK', + name: { + 'en-GB': 'BLIK', + 'de-DE': 'BLIK', + 'en-US': 'BLIK', + }, + description: { 'en-GB': '', 'de-DE': '', 'en-US': '' }, + imageUrl: 'https://www.mollie.com/external/icons/payment-methods/banktransfer.svg', + status: 'Active', + displayOrder: 0, + banktransferDueDate: '1d', + }, + }); + + expect(await checkPaymentMethodSpecificParameters(CTPayment, CTPayment.paymentMethodInfo.method as string)).toBe( undefined, ); expect(logger.error).toBeCalledTimes(0); From d24028d791f6fa23d9f16d3d14dee8f2771771f5 Mon Sep 17 00:00:00 2001 From: Win Date: Tue, 14 Jan 2025 10:39:24 +0700 Subject: [PATCH 3/7] MOL-592 + MOL-593 - update processor logic + update test cases --- processor/package-lock.json | 4 ++-- processor/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/processor/package-lock.json b/processor/package-lock.json index 8db0fc9..36cbb2f 100644 --- a/processor/package-lock.json +++ b/processor/package-lock.json @@ -1,12 +1,12 @@ { "name": "shopmacher-mollie-processor", - "version": "1.2.1", + "version": "1.2.0-build14.01.24.1038", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "shopmacher-mollie-processor", - "version": "1.2.1", + "version": "1.2.0-build14.01.24.1038", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/processor/package.json b/processor/package.json index 9291297..1cd3fc8 100644 --- a/processor/package.json +++ b/processor/package.json @@ -1,7 +1,7 @@ { "name": "shopmacher-mollie-processor", "description": "Integration between commercetools and mollie payment service provider", - "version": "1.2.1", + "version": "1.2.0-build14.01.24.1038", "main": "index.js", "private": true, "scripts": { From 5995e1eb0a36afe1b5624e1dfc4cfbaa97d4d9b4 Mon Sep 17 00:00:00 2001 From: Win Date: Tue, 14 Jan 2025 14:19:42 +0700 Subject: [PATCH 4/7] MOL-592 + MOL-593 - remove no longer used env. vars --- processor/.env.example | 2 - processor/.env.jest | 2 - processor/package-lock.json | 2 +- processor/src/types/index.types.ts | 2 - processor/src/utils/config.utils.ts | 2 - processor/src/validators/env.validators.ts | 21 +-- processor/tests/utils/config.utils.spec.ts | 12 -- .../tests/validators/env.validators.spec.ts | 26 +--- .../validators/helpers.validators.spec.ts | 144 ------------------ 9 files changed, 3 insertions(+), 210 deletions(-) diff --git a/processor/.env.example b/processor/.env.example index e78df8a..caa579e 100644 --- a/processor/.env.example +++ b/processor/.env.example @@ -27,8 +27,6 @@ CONNECTOR_MODE= ## Either test or live MOLLIE_API_TEST_KEY= MOLLIE_API_LIVE_KEY= MOLLIE_PROFILE_ID= -MOLLIE_CARD_COMPONENT=0 ## Either 1 for enable or 0 for disable -MOLLIE_BANK_TRANSFER_DUE_DATE=14d ## NGROK - only required for development CONNECTOR_EXTENSION_TOKEN= diff --git a/processor/.env.jest b/processor/.env.jest index 4a873a6..a947354 100644 --- a/processor/.env.jest +++ b/processor/.env.jest @@ -13,10 +13,8 @@ CTP_SESSION_ISSUER=gcp-eu ## MOLLIE vars MOLLIE_PROFILE_ID=pfl_12345 DEBUG=0 -MOLLIE_CARD_COMPONENT=0 CONNECTOR_MODE=test ## Either test or live MOLLIE_API_TEST_KEY=test_12345 MOLLIE_API_LIVE_KEY=live_12345 -MOLLIE_BANK_TRANSFER_DUE_DATE=14d CONNECT_SERVICE_URL=http://localhost:3000/processor diff --git a/processor/package-lock.json b/processor/package-lock.json index 36cbb2f..b83342f 100644 --- a/processor/package-lock.json +++ b/processor/package-lock.json @@ -9332,4 +9332,4 @@ } } } -} +} \ No newline at end of file diff --git a/processor/src/types/index.types.ts b/processor/src/types/index.types.ts index 7808e76..7bdf906 100644 --- a/processor/src/types/index.types.ts +++ b/processor/src/types/index.types.ts @@ -32,7 +32,5 @@ export type ConnectorEnvVars = { mode: string; profileId: string; debug: string; - cardComponent: string; - bankTransferDueDate: string; }; }; diff --git a/processor/src/utils/config.utils.ts b/processor/src/utils/config.utils.ts index 58e6f6e..8f0515e 100644 --- a/processor/src/utils/config.utils.ts +++ b/processor/src/utils/config.utils.ts @@ -27,8 +27,6 @@ export const readConfiguration = () => { mode: process.env.CONNECTOR_MODE as string, debug: process.env.DEBUG as string, profileId: process.env.MOLLIE_PROFILE_ID as string, - cardComponent: process.env.MOLLIE_CARD_COMPONENT as string, - bankTransferDueDate: process.env.MOLLIE_BANK_TRANSFER_DUE_DATE as string, }, }; diff --git a/processor/src/validators/env.validators.ts b/processor/src/validators/env.validators.ts index fba7ebe..185e108 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 } from './helpers.validators'; /** * Create here your own validators @@ -97,19 +97,6 @@ const envValidators = [ }, ), - standardString( - ['mollie', 'cardComponent'], - { - code: 'InvalidEnableCardComponent', - message: 'Enable Mollie card component should be a valid string of either "0" or "1".', - referencedBy: 'environmentVariables', - }, - { - min: 1, - max: 1, - }, - ), - standardString( ['mollie', 'mode'], { @@ -122,12 +109,6 @@ const envValidators = [ max: 4, }, ), - standardDueDate(['mollie', 'bankTransferDueDate'], { - code: 'InvalidBankTransferDueDate', - message: - 'Bank transfer due date must be from 1d to 100d, the number must be an integer. If it was not set, the default will be 14d', - referencedBy: 'environmentVariables', - }), standardString( ['commerceTools', 'authMode'], diff --git a/processor/tests/utils/config.utils.spec.ts b/processor/tests/utils/config.utils.spec.ts index e5a5426..0ebfe24 100644 --- a/processor/tests/utils/config.utils.spec.ts +++ b/processor/tests/utils/config.utils.spec.ts @@ -23,8 +23,6 @@ describe('Test src/utils/config.utils.ts', () => { mode: process.env.CONNECTOR_MODE, debug: process.env.DEBUG, profileId: process.env.MOLLIE_PROFILE_ID, - cardComponent: process.env.MOLLIE_CARD_COMPONENT, - bankTransferDueDate: process.env.MOLLIE_BANK_TRANSFER_DUE_DATE, }, }); }); @@ -69,21 +67,11 @@ describe('Test src/utils/config.utils.ts', () => { expect(() => readConfiguration()).toThrow(CustomError); }); - test('should throw an error when MOLLIE_CARD_COMPONENT is not defined', () => { - delete process.env.MOLLIE_CARD_COMPONENT; - expect(() => readConfiguration()).toThrow(CustomError); - }); - test('should throw an error when CONNECTOR_MODE is not defined', () => { delete process.env.CONNECTOR_MODE; expect(() => readConfiguration()).toThrow(CustomError); }); - test('should throw an error when MOLLIE_BANK_TRANSFER_DUE_DATE is invalid', () => { - process.env.MOLLIE_BANK_TRANSFER_DUE_DATE = 'dummy'; - expect(() => readConfiguration()).toThrow(CustomError); - }); - test('should throw an error when AUTHENTICATION_MODE is invalid', () => { process.env.AUTHENTICATION_MODE = 'dummy'; expect(() => readConfiguration()).toThrow(CustomError); diff --git a/processor/tests/validators/env.validators.spec.ts b/processor/tests/validators/env.validators.spec.ts index e533b5b..6b471aa 100644 --- a/processor/tests/validators/env.validators.spec.ts +++ b/processor/tests/validators/env.validators.spec.ts @@ -139,18 +139,6 @@ describe('Test env.validators.ts', () => { index1: 11, index2: 0, field1: 'mollie', - field2: 'cardComponent', - error: { - code: 'InvalidEnableCardComponent', - message: 'Enable Mollie card component should be a valid string of either "0" or "1".', - referencedBy: 'environmentVariables', - }, - condition: { min: 1, max: 1 }, - }, - { - index1: 12, - index2: 0, - field1: 'mollie', field2: 'mode', error: { code: 'InvalidMode', @@ -160,19 +148,7 @@ describe('Test env.validators.ts', () => { condition: { min: 1, max: 4 }, }, { - index1: 13, - index2: 0, - field1: 'mollie', - field2: 'bankTransferDueDate', - error: { - code: 'InvalidBankTransferDueDate', - message: - 'Bank transfer due date must be from 1d to 100d, the number must be an integer. If it was not set, the default will be 14d', - referencedBy: 'environmentVariables', - }, - }, - { - index1: 14, + index1: 12, 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 5bcdc64..e22ade6 100644 --- a/processor/tests/validators/helpers.validators.spec.ts +++ b/processor/tests/validators/helpers.validators.spec.ts @@ -68,15 +68,6 @@ const mockObject = { referencedBy: 'environmentVariables', } as Message, }, - standardDueDate: { - path: ['./demo/path/dueDate'] as string[], - message: { - code: 'InvalidBankTransferDueDate', - message: - 'Bank transfer due date must be from 1d to 100d, the number must be an integer. If it was not set, the default will be 14d', - referencedBy: 'environmentVariables', - } as Message, - }, }; const mockResponse = { @@ -108,20 +99,6 @@ const mockResponse = { ], ], ], - standardDueDate: [ - ['./demo/path/dueDate'], - [ - [ - [jest.fn()], - { - code: 'InvalidBankTransferDueDate', - message: - 'Bank transfer due date must be from 1d to 100d, the number must be an integer. If it was not set, the default will be 14d', - referencedBy: 'environmentVariables', - }, - ], - ], - ], standardNaturalNumber: [ ['./demo/path/naturalNumber'], [ @@ -266,8 +243,6 @@ describe('Test helpers.validators.ts', () => { mode: process.env.CONNECTOR_MODE as string, debug: (process.env.DEBUG ?? '0') as string, profileId: process.env.MOLLIE_PROFILE_ID as string, - cardComponent: (process.env.MOLLIE_CARD_COMPONENT ?? '0') as string, - bankTransferDueDate: process.env.MOLLIE_BANK_TRANSFER_DUE_DATE, }, }; const error = getValidateMessages(envValidators, vars); @@ -294,8 +269,6 @@ describe('Test helpers.validators.ts', () => { mode: process.env.CONNECTOR_MODE as string, debug: (process.env.DEBUG ?? '0') as string, profileId: process.env.MOLLIE_PROFILE_ID as string, - cardComponent: (process.env.MOLLIE_CARD_COMPONENT ?? '0') as string, - bankTransferDueDate: process.env.MOLLIE_BANK_TRANSFER_DUE_DATE, }, }; const error = getValidateMessages(envValidators, vars); @@ -333,121 +306,4 @@ describe('Test helpers.validators.ts', () => { expect(response[0]).toStrictEqual(mockResponse.region[0]); expect(response[1][0][1]).toStrictEqual(mockResponse.region[1][0][1]); }); - - test('call standardDuedate', async () => { - const response = standardDueDate(mockObject.standardDueDate.path, mockObject.standardDueDate.message); - expect(response).toBeDefined(); - expect(response[0]).toStrictEqual(mockResponse.standardDueDate[0]); - expect(response[1][0][1]).toStrictEqual(mockResponse.standardDueDate[1][0][1]); - }); -}); - -describe('test getValidateMessages', () => { - it('should able to return suitable error message when MOLLIE_BANK_TRANSFER_DUE_DATE is invalid', () => { - const envVars: ConnectorEnvVars = { - commerceTools: { - clientId: process.env.CTP_CLIENT_ID as string, - clientSecret: process.env.CTP_CLIENT_SECRET as string, - 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, - liveApiKey: process.env.MOLLIE_API_LIVE_KEY as string, - mode: process.env.CONNECTOR_MODE as string, - debug: process.env.DEBUG as string, - profileId: process.env.MOLLIE_PROFILE_ID as string, - cardComponent: process.env.MOLLIE_CARD_COMPONENT as string, - bankTransferDueDate: 'dummy', - }, - }; - - const result = getValidateMessages(envValidators, envVars); - - expect(result).toEqual([ - { - code: 'InvalidBankTransferDueDate', - message: - 'Bank transfer due date must be from 1d to 100d, the number must be an integer. If it was not set, the default will be 14d', - referencedBy: 'environmentVariables', - }, - ]); - }); - - it('should able to return suitable error message when MOLLIE_BANK_TRANSFER_DUE_DATE is invalid', () => { - const envVars: ConnectorEnvVars = { - commerceTools: { - clientId: process.env.CTP_CLIENT_ID as string, - clientSecret: process.env.CTP_CLIENT_SECRET as string, - 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, - liveApiKey: process.env.MOLLIE_API_LIVE_KEY as string, - mode: process.env.CONNECTOR_MODE as string, - debug: process.env.DEBUG as string, - profileId: process.env.MOLLIE_PROFILE_ID as string, - cardComponent: process.env.MOLLIE_CARD_COMPONENT as string, - bankTransferDueDate: 'dummy', - }, - }; - - const result = getValidateMessages(envValidators, envVars); - - expect(result).toEqual([ - { - code: 'InvalidBankTransferDueDate', - message: - 'Bank transfer due date must be from 1d to 100d, the number must be an integer. If it was not set, the default will be 14d', - referencedBy: 'environmentVariables', - }, - ]); - }); - - it('should able to return suitable error message when MOLLIE_BANK_TRANSFER_DUE_DATE is more than 100 days', () => { - const envVars: ConnectorEnvVars = { - commerceTools: { - clientId: process.env.CTP_CLIENT_ID as string, - clientSecret: process.env.CTP_CLIENT_SECRET as string, - 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, - liveApiKey: process.env.MOLLIE_API_LIVE_KEY as string, - mode: process.env.CONNECTOR_MODE as string, - debug: process.env.DEBUG as string, - profileId: process.env.MOLLIE_PROFILE_ID as string, - cardComponent: process.env.MOLLIE_CARD_COMPONENT as string, - bankTransferDueDate: '101d', - }, - }; - - const result = getValidateMessages(envValidators, envVars); - - expect(result).toEqual([ - { - code: 'InvalidBankTransferDueDate', - message: - 'Bank transfer due date must be from 1d to 100d, the number must be an integer. If it was not set, the default will be 14d', - referencedBy: 'environmentVariables', - }, - ]); - }); }); From bd9fb5f1fd545c155f5e1cec32ce4f1c2f9d89d2 Mon Sep 17 00:00:00 2001 From: Win Date: Tue, 14 Jan 2025 14:20:39 +0700 Subject: [PATCH 5/7] MOL-592 + MOL-593 - remove no longer used env. vars --- processor/package-lock.json | 4 ++-- processor/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/processor/package-lock.json b/processor/package-lock.json index b83342f..9459397 100644 --- a/processor/package-lock.json +++ b/processor/package-lock.json @@ -1,12 +1,12 @@ { "name": "shopmacher-mollie-processor", - "version": "1.2.0-build14.01.24.1038", + "version": "1.2.0-build14.01.25.1420", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "shopmacher-mollie-processor", - "version": "1.2.0-build14.01.24.1038", + "version": "1.2.0-build14.01.25.1420", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/processor/package.json b/processor/package.json index 1cd3fc8..534f07c 100644 --- a/processor/package.json +++ b/processor/package.json @@ -1,7 +1,7 @@ { "name": "shopmacher-mollie-processor", "description": "Integration between commercetools and mollie payment service provider", - "version": "1.2.0-build14.01.24.1038", + "version": "1.2.0-build14.01.25.1420", "main": "index.js", "private": true, "scripts": { From e44936a2df31ea2b43e2f52a4a81ca4c45c4b2a5 Mon Sep 17 00:00:00 2001 From: Win Date: Tue, 14 Jan 2025 14:27:58 +0700 Subject: [PATCH 6/7] Merge branch 'develop' into feature/MOL-592_resolved-dev --- processor/tests/validators/helpers.validators.spec.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/processor/tests/validators/helpers.validators.spec.ts b/processor/tests/validators/helpers.validators.spec.ts index e22ade6..fe613b8 100644 --- a/processor/tests/validators/helpers.validators.spec.ts +++ b/processor/tests/validators/helpers.validators.spec.ts @@ -1,5 +1,4 @@ import { - standardDueDate, array, standardEmail, standardNaturalNumber, @@ -10,8 +9,8 @@ import { optional, region, } from './../../src/validators/helpers.validators'; -import { describe, test, expect, jest, it } from '@jest/globals'; -import { ConnectorEnvVars, Message } from '../../src/types/index.types'; +import { describe, test, expect, jest } from '@jest/globals'; +import { Message } from '../../src/types/index.types'; import envValidators from '../../src/validators/env.validators'; const mockObject = { From 13d4a9fed1bcfd73614ef022b8fad1e601ec811c Mon Sep 17 00:00:00 2001 From: Win Date: Wed, 22 Jan 2025 18:42:46 +0700 Subject: [PATCH 7/7] [UPDATE] - release version - postman collection --- ...tm_connector_v121.postman_collection.json} | 406 +++++++++++++++++- ...m_connector_v121.postman_environment.json} | 0 processor/package-lock.json | 4 +- processor/package.json | 2 +- 4 files changed, 394 insertions(+), 18 deletions(-) rename docs/postman/{sctm_connector_v101.postman_collection.json => sctm_connector_v121.postman_collection.json} (72%) rename docs/postman/{sctm_connector_v101.postman_environment.json => sctm_connector_v121.postman_environment.json} (100%) diff --git a/docs/postman/sctm_connector_v101.postman_collection.json b/docs/postman/sctm_connector_v121.postman_collection.json similarity index 72% rename from docs/postman/sctm_connector_v101.postman_collection.json rename to docs/postman/sctm_connector_v121.postman_collection.json index 68f72a5..291467f 100644 --- a/docs/postman/sctm_connector_v101.postman_collection.json +++ b/docs/postman/sctm_connector_v121.postman_collection.json @@ -1,10 +1,10 @@ { "info": { "_postman_id": "8fb1a9c2-1d84-49cb-8871-5c80b3d92e15", - "name": "SCTM Collection v1.0.1", + "name": "SCTM Collection v1.2.1", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", "_exporter_id": "14200932", - "_collection_link": "https://adventure-1591.postman.co/workspace/Adventure-Workspace~471ca30a-668a-4dde-88b2-8fa80e5dae88/collection/14200932-8fb1a9c2-1d84-49cb-8871-5c80b3d92e15?action=share&source=collection_link&creator=14200932" + "_collection_link": "https://mol-1591.postman.co/workspace/MOL~471ca30a-668a-4dde-88b2-8fa80e5dae88/collection/14200932-8fb1a9c2-1d84-49cb-8871-5c80b3d92e15?action=share&source=collection_link&creator=14200932" }, "item": [ { @@ -16,7 +16,6 @@ { "listen": "test", "script": { - "type": "text/javascript", "exec": [ "tests[\"Status code is 200\"] = responseCode.code === 200;", "var data = JSON.parse(responseBody);", @@ -36,7 +35,9 @@ " }", " }", "}" - ] + ], + "type": "text/javascript", + "packages": {} } } ], @@ -59,8 +60,8 @@ "method": "POST", "header": [], "body": { - "mode": "raw", - "raw": "" + "mode": "urlencoded", + "urlencoded": [] }, "url": { "raw": "{{auth_url}}/oauth/token?grant_type=client_credentials", @@ -144,7 +145,7 @@ ], "body": { "mode": "raw", - "raw": "{\n \"destination\" : {\n \"type\" : \"HTTP\",\n \"url\" : \"https://efd6-115-74-115-119.ngrok-free.app/processor\"\n },\n \"triggers\" : [ {\n \"resourceTypeId\" : \"payment\",\n \"actions\" : [ \"Create\", \"Update\" ]\n } ],\n \"key\" : \"sctm-payment-create-update-extension\"\n}" + "raw": "{\n \"destination\": {\n \"type\": \"HTTP\",\n \"url\": \"https://efd6-115-74-115-119.ngrok-free.app/processor\",\n \"authorization\": {\n \"type\": \"AuthorizationHeader\",\n \"headerValue\": \"_token_\"\n }\n },\n \"triggers\": [\n {\n \"resourceTypeId\": \"payment\",\n \"actions\": [\n \"Create\",\n \"Update\"\n ]\n }\n ],\n \"key\": \"sctm-payment-create-update-extension\"\n}" }, "url": { "raw": "{{host}}/{{project-key}}/extensions", @@ -414,9 +415,170 @@ "description": "null" }, "response": [] + }, + { + "name": "Get Extension by key", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "tests[\"Status code \" + responseCode.code] = responseCode.code === 200 || responseCode.code === 201;", + "var data = JSON.parse(responseBody);", + "if(data.results && data.results[0] && data.results[0].id && data.results[0].version){", + " pm.environment.set(\"extension-id\", data.results[0].id); ", + " pm.environment.set(\"extension-version\", data.results[0].version);", + "}", + "if(data.results && data.results[0] && data.results[0].key){", + " pm.environment.set(\"extension-key\", data.results[0].key); ", + "}", + "if(data.version){", + " pm.environment.set(\"extension-version\", data.version);", + "}", + "if(data.id){", + " pm.environment.set(\"extension-id\", data.id); ", + "}", + "if(data.key){", + " pm.environment.set(\"extension-key\", data.key);", + "}", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "auth": { + "type": "oauth2", + "oauth2": [ + { + "key": "accessToken", + "value": "{{ctp_access_token}}", + "type": "string" + }, + { + "key": "addTokenTo", + "value": "header", + "type": "string" + }, + { + "key": "tokenType", + "value": "Bearer", + "type": "string" + } + ] + }, + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{host}}/{{project-key}}/extensions/key=sctm-payment-create-update-extension", + "host": [ + "{{host}}" + ], + "path": [ + "{{project-key}}", + "extensions", + "key=sctm-payment-create-update-extension" + ] + }, + "description": "null" + }, + "response": [] + }, + { + "name": "Update Extension Destination", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "tests[\"Status code \" + responseCode.code] = responseCode.code === 200 || responseCode.code === 201;", + "var data = JSON.parse(responseBody);", + "if(data.results && data.results[0] && data.results[0].id && data.results[0].version){", + " pm.environment.set(\"extension-id\", data.results[0].id); ", + " pm.environment.set(\"extension-version\", data.results[0].version);", + "}", + "if(data.results && data.results[0] && data.results[0].key){", + " pm.environment.set(\"extension-key\", data.results[0].key); ", + "}", + "if(data.version){", + " pm.environment.set(\"extension-version\", data.version);", + "}", + "if(data.id){", + " pm.environment.set(\"extension-id\", data.id); ", + "}", + "if(data.key){", + " pm.environment.set(\"extension-key\", data.key);", + "}", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "auth": { + "type": "oauth2", + "oauth2": [ + { + "key": "accessToken", + "value": "{{ctp_access_token}}", + "type": "string" + }, + { + "key": "addTokenTo", + "value": "header", + "type": "string" + }, + { + "key": "tokenType", + "value": "Bearer", + "type": "string" + } + ] + }, + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"version\": {{YOUR_EXTENSION_VERSION}},\n \"actions\": [\n {\n \"action\": \"changeDestination\",\n \"destination\": {\n \"type\": \"HTTP\",\n \"url\": \"{{_YOUR_EXTENSION_URL}}\",\n \"authentication\": {\n \"type\": \"AuthorizationHeader\",\n \"headerValue\": \"Bearer {{_YOUR_TOKEN_}}\"\n }\n }\n }\n ]\n}" + }, + "url": { + "raw": "{{host}}/{{project-key}}/extensions/key=sctm-payment-create-update-extension", + "host": [ + "{{host}}" + ], + "path": [ + "{{project-key}}", + "extensions", + "key=sctm-payment-create-update-extension" + ] + }, + "description": "null" + }, + "response": [] } ], - "description": "To be able to use the connector as well as making the API calls in the next sections to trigger the connector to do its job, you must follow these points below:\n\n1. Install the connector to your merchant center:\n \n 1. Installing the connector to your merchant center will trigger creating an API extension to listen the changes on `Create` and `Update` a CommerceTools Payment\n \n 2. It will also create some specific connector's custom fields, here is the list (will be updated continously):\n \n 1. `sctm-payment-custom-type` on **Payment**, it includes the fields: `sctm_mollie_profile_id`, `sctm_payment_methods_request`, `sctm_payment_methods_response`, `sctm_create_payment_request`\n \n 2. `sctm_interface_interaction_type` on **Interface Interaction of Payment**, it includes the fields: `sctmId`, `sctmActionType`, `sctmCreatedAt`, `sctmRequest`, `sctmResponse`\n \n 3. `sctm_payment_cancel_refund` on **Transaction of Payment**, it includes the fields: `reasonText`, `statusText`\n \n 4. In case you want to have a look at the details of creating process or want to re-run it manually when got trouble, we have put all the requests you need in this folder, please have a look if necessary.\n \n2. Update the environments in Postman collection to adapt with your CommerceTools and Mollie credentials\n \n3. To able to make API calls to CommerceTools endpoints, you absolutely need to obtain the access token from your account, we provide you a request to do that in this folder, just make sure you have updated all your credentials and then you are good to go, whenever a request failed because of invalid token, just need to call it again." + "description": "To be able to use the connector as well as making the API calls in the next sections to trigger the connector to do its job, you must follow these points below:\n\n1. Install the connector to your merchant center:\n \n 1. Installing the connector to your merchant center will trigger creating an API extension to listen the changes on `Create` and `Update` a CommerceTools Payment\n \n 2. It will also create some specific connector's custom fields, here is the list (will be updated continously):\n \n 1. `sctm-payment-custom-type` on **Payment**, it includes the fields: `sctm_mollie_profile_id`, `sctm_payment_methods_request`, `sctm_payment_methods_response`, `sctm_create_payment_request`\n \n 2. `sctm_interface_interaction_type` on **Interface Interaction of Payment**, it includes the fields: `sctm_id`, `sctm_action_type`, `sctm_created_at`, `sctm_request`, `sctm_response`\n \n 3. `sctm_payment_cancel_refund` on **Transaction of Payment**, it includes the fields: `reasonText`, `statusText`\n \n 4. In case you want to have a look at the details of creating process or want to re-run it manually when got trouble, we have put all the requests you need in this folder, please have a look if necessary.\n \n2. Update the environments in Postman collection to adapt with your CommerceTools and Mollie credentials\n \n3. To able to make API calls to CommerceTools endpoints, you absolutely need to obtain the access token from your account, we provide you a request to do that in this folder, just make sure you have updated all your credentials and then you are good to go, whenever a request failed because of invalid token, just need to call it again. \n **Notice:** The processor endpoint" }, { "name": "II. Connector Requests", @@ -491,7 +653,7 @@ ], "body": { "mode": "raw", - "raw": "{\n \"amountPlanned\" : {\n \"currencyCode\" : \"EUR\",\n \"centAmount\" : 1000,\n \"fractionDigits\": 2\n },\n \"paymentMethodInfo\" : {\n \"paymentInterface\" : \"Mollie\" // required to be verify with our connector\n },\n \"custom\": {\n \"type\": {\n \"typeId\": \"type\",\n \"key\": \"sctm-payment-custom-type\"\n },\n \"fields\": {\n // hold all the filter options\n \"sctm_payment_methods_request\": \"{\\\"locale\\\":\\\"de_DE\\\",\\\"billingCountry\\\":\\\"DE\\\",\\\"includeWallets\\\":\\\"applepay\\\",\\\"sequenceType\\\":\\\"oneoff\\\",\\\"orderLineCategories\\\":\\\"\\\",\\\"include\\\":\\\"\\\"}\",\n \"sctm_payment_methods_response\": \"\" // hold the payment list from Mollie response\n }\n }\n}" + "raw": "{\n \"amountPlanned\" : {\n \"currencyCode\" : \"EUR\",\n \"centAmount\" : 1000,\n \"fractionDigits\": 2\n },\n \"paymentMethodInfo\" : {\n \"paymentInterface\" : \"Mollie\" // required to be verify with our connector\n },\n \"custom\": {\n \"type\": {\n \"typeId\": \"type\",\n \"key\": \"sctm-payment-custom-type\"\n },\n \"fields\": {\n // hold all the filter options\n \"sctm_payment_methods_request\": \"{\\\"locale\\\":\\\"de_DE\\\",\\\"billingCountry\\\":\\\"PL\\\",\\\"includeWallets\\\":\\\"applepay\\\",\\\"sequenceType\\\":\\\"oneoff\\\",\\\"orderLineCategories\\\":\\\"\\\",\\\"include\\\":\\\"\\\"}\",\n \"sctm_payment_methods_response\": \"\" // hold the payment list from Mollie response\n }\n }\n}" }, "url": { "raw": "{{host}}/{{project-key}}/payments", @@ -601,7 +763,7 @@ "response": [] } ], - "description": "## GET PAYMENT METHODS\n\n**Integration steps**\n\nNo matter when payment methods is retrieved, the `payment` object has to be **create/update** for the connector procedure to be triggered\n\n1. A `payment` object must be instantiated/modified via CT extension actions\n \n2. The object has several parameters as described in the table below\n \n3. The connector will return the corresponding update actions to this `payment` object\n \n4. Then, these update actions will be consumed and update the `payment` object with its Mollie responses\n \n\n**Parameters**\n\n| **Name** | **Required** | **Note** |\n| --- | --- | --- |\n| amountPlanned | √ | To detemine Mollie payment amount |\n| paymentMethodInfo.paymentInterface | √ | To be verified by the connector |\n| custom.fields.sctm_payment_methods_response | √ | To trigger the listing payment method action - **its value should be empty** |\n| custom.fields.sctm_payment_methods_request | √ | To hold all the listing option for Mollie |\n| custom.fields.sctm_payment_methods_request.sequenceType | | To hold Mollie `sequenceType` option |\n| custom.fields.sctm_payment_methods_request.locale | | To hold Mollie `locale` option |\n| custom.fields.sctm_payment_methods_request.resource | | To hold Mollie `resource` option |\n| custom.fields.sctm_payment_methods_request.billingCountry | | To hold Mollie `billingCountry` option |\n| custom.fields.sctm_payment_methods_request.includeWallets | | To hold Mollie `includeWallets` option |\n| custom.fields.sctm_payment_methods_request.orderLineCategories | | To hold Mollie `orderLineCategories` option |\n| custom.fields.sctm_payment_methods_request.include | | To hold Mollie `include` option |\n\n_Example payload_\n\n``` json\n{\n \"action\": \"Create\",\n \"resource\": {\n \"typeId\": \"payment\",\n \"id\": \"PM-112555\",\n \"obj\": {\n \"id\": \"PID-123456\",\n \"amountPlanned\": {\n \"type\": \"centPrecision\",\n \"currencyCode\": \"EUR\",\n \"centAmount\": 1000,\n \"fractionDigits\": 2\n },\n \"paymentMethodInfo\": {\n \"paymentInterface\": \"Mollie\"\n },\n \"custom\": {\n \"fields\": {\n \"sctm_payment_methods_request\": {\n \"sequenceType\": \"oneoff\",\n \"locale\": \"de_DE\",\n \"resource\": \"payments\",\n \"billingCountry\": \"DE\",\n \"includeWallets\": \"applepay\"\n },\n \"sctm_payment_methods_response: {}\n }\n }\n }\n }\n}\n\n ```\n\n**Response**\n\n_Status:_ 200\n\n_Body:_\n\n``` json\n{\n \"actions\": [\n {\n \"action\": \"setCustomField\",\n \"name\": \"sctm_payment_methods_response\",\n \"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/applepay2x.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/creditcard2x.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/paypal2x.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/banktransfer2x.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/ideal2x.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/bancontact2x.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/eps2x.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/przelewy242x.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/kbc2x.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/belfius2x.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/bancomatpay2x.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\\\"}}}]}\"\n },\n {\n \"action\": \"setCustomField\",\n \"name\": \"sctm_mollie_profile_id\",\n \"value\": \"pfl_SPkYGiEQjf\"\n }\n ]\n}\n\n ```" + "description": "## GET PAYMENT METHODS\n\n**Integration steps**\n\nNo matter when payment methods is retrieved, the `payment` object has to be **create/update** for the connector procedure to be triggered\n\n1. A `payment` object must be instantiated/modified via CT extension actions\n \n2. The object has several parameters as described in the table below\n \n3. The connector will return the corresponding update actions to this `payment` object\n \n4. Then, these update actions will be consumed and update the `payment` object with its Mollie responses\n \n\n**Parameters**\n\n| **Name** | **Required** | **Note** |\n| --- | --- | --- |\n| amountPlanned | √ | To detemine Mollie payment amount |\n| paymentMethodInfo.paymentInterface | √ | To be verified by the connector |\n| custom.fields.sctm_payment_methods_response | √ | To trigger the listing payment method action - **its value should be empty** |\n| custom.fields.sctm_payment_methods_request | √ | To hold all the listing option for Mollie |\n| custom.fields.sctm_payment_methods_request.sequenceType | | To hold Mollie `sequenceType` option |\n| custom.fields.sctm_payment_methods_request.locale | | To hold Mollie `locale` option |\n| custom.fields.sctm_payment_methods_request.resource | | To hold Mollie `resource` option |\n| custom.fields.sctm_payment_methods_request.billingCountry | √ | To hold Mollie `billingCountry` option |\n| custom.fields.sctm_payment_methods_request.includeWallets | | To hold Mollie `includeWallets` option |\n| custom.fields.sctm_payment_methods_request.orderLineCategories | | To hold Mollie `orderLineCategories` option |\n| custom.fields.sctm_payment_methods_request.include | | To hold Mollie `include` option |\n\n_Example payload_\n\n``` json\n{\n \"action\": \"Create\",\n \"resource\": {\n \"typeId\": \"payment\",\n \"id\": \"PM-112555\",\n \"obj\": {\n \"id\": \"PID-123456\",\n \"amountPlanned\": {\n \"type\": \"centPrecision\",\n \"currencyCode\": \"EUR\",\n \"centAmount\": 1000,\n \"fractionDigits\": 2\n },\n \"paymentMethodInfo\": {\n \"paymentInterface\": \"Mollie\"\n },\n \"custom\": {\n \"fields\": {\n \"sctm_payment_methods_request\": {\n \"sequenceType\": \"oneoff\",\n \"locale\": \"de_DE\",\n \"resource\": \"payments\",\n \"billingCountry\": \"DE\",\n \"includeWallets\": \"applepay\"\n },\n \"sctm_payment_methods_response: {}\n }\n }\n }\n }\n}\n\n ```\n\n**Response**\n\n_Status:_ 200\n\n_Body:_\n\n``` json\n{\n \"actions\": [\n {\n \"action\": \"setCustomField\",\n \"name\": \"sctm_payment_methods_response\",\n \"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/applepay2x.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/creditcard2x.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/paypal2x.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/banktransfer2x.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/ideal2x.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/bancontact2x.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/eps2x.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/przelewy242x.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/kbc2x.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/belfius2x.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/bancomatpay2x.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\\\"}}}]}\"\n },\n {\n \"action\": \"setCustomField\",\n \"name\": \"sctm_mollie_profile_id\",\n \"value\": \"pfl_SPkYGiEQjf\"\n }\n ]\n}\n\n ```" }, { "name": "Create Payment", @@ -671,7 +833,7 @@ ], "body": { "mode": "raw", - "raw": "{\n \"amountPlanned\" : {\n \"currencyCode\" : \"EUR\",\n \"centAmount\" : 1000,\n \"fractionDigits\": 2\n },\n \"paymentMethodInfo\" : {\n \"paymentInterface\" : \"Mollie\",\n \"method\" : \"banktransfer\",\n \"name\" : {\n \"en\" : \"Bank Transfer\"\n }\n },\n \"transactions\" : [ {\n \"timestamp\" : \"2015-10-20T08:54:24.000Z\",\n \"type\" : \"Charge\",\n \"amount\" : {\n \"currencyCode\" : \"USD\",\n \"centAmount\" : 1000\n },\n \"state\" : \"Initial\"\n } ],\n \"custom\": {\n \"type\": {\n \"typeId\": \"type\",\n \"key\": \"sctm-payment-custom-type\"\n },\n \"fields\": {\n \"sctm_create_payment_request\": \"{\\\"description\\\":\\\"Test payment\\\",\\\"locale\\\":\\\"en_GB\\\",\\\"redirectUrl\\\":\\\"https://www.google.com/\\\",\\\"billingEmail\\\":\\\"n.tran@shopmacher.de\\\",\\\"dueDate\\\":\\\"2024-09-10\\\"}\"\n }\n }\n}" + "raw": "{\n \"amountPlanned\" : {\n \"currencyCode\" : \"EUR\",\n \"centAmount\" : 1000,\n \"fractionDigits\": 2\n },\n \"paymentMethodInfo\" : {\n \"paymentInterface\" : \"Mollie\",\n \"method\" : \"banktransfer\",\n \"name\" : {\n \"en\" : \"Bank Transfer\"\n }\n },\n \"transactions\" : [ {\n \"timestamp\" : \"2015-10-20T08:54:24.000Z\",\n \"type\" : \"Charge\",\n \"amount\" : {\n \"currencyCode\" : \"USD\",\n \"centAmount\" : 1000\n },\n \"state\" : \"Initial\"\n } ],\n \"custom\": {\n \"type\": {\n \"typeId\": \"type\",\n \"key\": \"sctm-payment-custom-type\"\n },\n \"fields\": {\n \"sctm_create_payment_request\": \"{\\\"description\\\":\\\"Test payment\\\",\\\"locale\\\":\\\"en_GB\\\",\\\"redirectUrl\\\":\\\"https://www.google.com/\\\",\\\"dueDate\\\":\\\"2024-09-10\\\",\\\"billingAddress\\\":{\\\"email\\\":\\\"n.tran@shopmacher.de\\\"}}\"\n }\n }\n}" }, "url": { "raw": "{{host}}/{{project-key}}/payments", @@ -697,6 +859,97 @@ ], "description": "Play around with the Postman request:\n\n- Here I have described an example to make a payment with method banktransfer. From the payload, please update the `billingEmail` and/or `dueDate` custom.fields.sctm_create_payment_request\n \n\n\n\n- Next, pressing on Send button, after response returned successfully, you will see the `checkoutUrl` in `interfaceInteractions.fields`, please access it via the browser and process the checkout.\n \n- After finishing, you will receive an email to your specified email address which is to notify that the payment has been made. Which means that the billingEmail and the dueDate has been sent along with our request to the targeted Mollie endpoint when creating the payment" }, + { + "name": "Create Payment With Line Items", + "item": [ + { + "name": "Create Payment With Line Items", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "tests[\"Status code \" + responseCode.code] = responseCode.code === 200 || responseCode.code === 201;", + "var data = JSON.parse(responseBody);", + "if(data.results && data.results[0] && data.results[0].id && data.results[0].version){", + " pm.environment.set(\"payment-id\", data.results[0].id); ", + " pm.environment.set(\"payment-version\", data.results[0].version);", + "}", + "if(data.results && data.results[0] && data.results[0].key){", + " pm.environment.set(\"payment-key\", data.results[0].key); ", + "}", + "if(data.version){", + " pm.environment.set(\"payment-version\", data.version);", + "}", + "if(data.id){", + " pm.environment.set(\"payment-id\", data.id); ", + "}", + "if(data.key){", + " pm.environment.set(\"payment-key\", data.key);", + "}", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "auth": { + "type": "oauth2", + "oauth2": [ + { + "key": "accessToken", + "value": "{{ctp_access_token}}", + "type": "string" + }, + { + "key": "addTokenTo", + "value": "header", + "type": "string" + }, + { + "key": "tokenType", + "value": "Bearer", + "type": "string" + } + ] + }, + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"amountPlanned\" : {\n \"currencyCode\" : \"EUR\",\n \"centAmount\" : 1000,\n \"fractionDigits\": 2\n },\n \"paymentMethodInfo\" : {\n \"paymentInterface\" : \"Mollie\",\n \"method\" : \"paypal\",\n \"name\" : {\n \"en\" : \"PayPal\"\n }\n },\n \"transactions\" : [ {\n \"timestamp\" : \"2015-10-20T08:54:24.000Z\",\n \"type\" : \"Charge\",\n \"amount\" : {\n \"currencyCode\" : \"USD\",\n \"centAmount\" : 1000\n },\n \"state\" : \"Initial\"\n } ],\n \"custom\": {\n \"type\": {\n \"typeId\": \"type\",\n \"key\": \"sctm-payment-custom-type\"\n },\n \"fields\": {\n \"sctm_create_payment_request\": \"{\\\"description\\\":\\\"Test payment with line items\\\",\\\"locale\\\":\\\"en_GB\\\",\\\"redirectUrl\\\":\\\"https://www.google.com/\\\",\\\"billingAddress\\\":{\\\"email\\\":\\\"example@test.de\\\"},\\\"lines\\\":[{\\\"description\\\":\\\"Item 1\\\",\\\"quantity\\\":1,\\\"quantityUnit\\\":\\\"pcs\\\",\\\"unitPrice\\\":{\\\"currency\\\":\\\"EUR\\\",\\\"value\\\":\\\"5.00\\\"},\\\"totalAmount\\\":{\\\"currency\\\":\\\"EUR\\\",\\\"value\\\":\\\"5.00\\\"},\\\"sku\\\":\\\"TEST1\\\",\\\"imageUrl\\\":\\\"https://example.com/image1.jpg\\\",\\\"productUrl\\\":\\\"https://example.com/product1\\\"},{\\\"description\\\":\\\"Item 2\\\",\\\"quantity\\\":1,\\\"quantityUnit\\\":\\\"pcs\\\",\\\"unitPrice\\\":{\\\"currency\\\":\\\"EUR\\\",\\\"value\\\":\\\"5.00\\\"},\\\"totalAmount\\\":{\\\"currency\\\":\\\"EUR\\\",\\\"value\\\":\\\"5.00\\\"},\\\"sku\\\":\\\"TEST2\\\",\\\"imageUrl\\\":\\\"https://example.com/image2.jpg\\\",\\\"productUrl\\\":\\\"https://example.com/product2\\\"}]}\"\n }\n }\n}" + }, + "url": { + "raw": "{{host}}/{{project-key}}/payments", + "host": [ + "{{host}}" + ], + "path": [ + "{{project-key}}", + "payments" + ], + "query": [ + { + "key": "expand", + "value": "", + "disabled": true + } + ] + }, + "description": "Creating a Payment produces the [PaymentCreated](ctp:api:type:PaymentCreatedMessage) Message.\n" + }, + "response": [] + } + ], + "description": "Play around with the Postman request:\n\n- Here I have described an example to make a payment with PayPal including the information of line items\n \n\n\n\n- Next, pressing on Send button, after response returned successfully, you will see the `checkoutUrl` in `interfaceInteractions.fields`, please access it via the browser and process the checkout.\n \n- After finishing, head over to the Mollie payment dashboard and navigate to the corresponding payment checking whether the line items data is transferred or not.\n \n\n" + }, { "name": "With Method Blik", "item": [ @@ -762,7 +1015,7 @@ ], "body": { "mode": "raw", - "raw": "{\n \"amountPlanned\": {\n \"currencyCode\": \"EUR\",\n \"centAmount\": 2000,\n \"fractionDigits\": 2\n },\n \"paymentMethodInfo\": {\n \"paymentInterface\": \"Mollie\",\n \"method\": \"creditcard\",\n \"name\": {\n \"en\": \"creditcard\"\n }\n },\n \"transactions\": [\n {\n \"timestamp\": \"2015-10-20T08:54:24.000Z\",\n \"type\": \"Charge\",\n \"amount\": {\n \"currencyCode\": \"EUR\",\n \"centAmount\": 2000\n },\n \"state\": \"Initial\"\n }\n ],\n \"custom\": {\n \"type\": {\n \"typeId\": \"type\",\n \"key\": \"sctm-payment-custom-type\"\n },\n \"fields\": {\n \"sctm_create_payment_request\": \"{\\\"description\\\":\\\"Test payment method blik\\\",\\\"locale\\\":\\\"en_GB\\\",\\\"redirectUrl\\\":\\\"https://www.google.com/\\\",\\\"billingEmail\\\":\\\"n.tran+w@shopmacher.de\\\"}\"\n }\n }\n}" + "raw": "{\n \"amountPlanned\": {\n \"currencyCode\": \"PLN\",\n \"centAmount\": 2000,\n \"fractionDigits\": 2\n },\n \"paymentMethodInfo\": {\n \"paymentInterface\": \"Mollie\",\n \"method\": \"blik\",\n \"name\": {\n \"en\": \"blik\"\n }\n },\n \"transactions\": [\n {\n \"timestamp\": \"2015-10-20T08:54:24.000Z\",\n \"type\": \"Charge\",\n \"amount\": {\n \"currencyCode\": \"PLN\",\n \"centAmount\": 2000\n },\n \"state\": \"Initial\"\n }\n ],\n \"custom\": {\n \"type\": {\n \"typeId\": \"type\",\n \"key\": \"sctm-payment-custom-type\"\n },\n \"fields\": {\n \"sctm_create_payment_request\": \"{\\\"description\\\":\\\"Test payment method blik\\\",\\\"locale\\\":\\\"en_GB\\\",\\\"redirectUrl\\\":\\\"https://www.google.com/\\\",\\\"billingEmail\\\":\\\"n.tran+w@shopmacher.de\\\"}\"\n\n }\n }\n}" }, "url": { "raw": "{{host}}/{{project-key}}/payments", @@ -877,7 +1130,7 @@ "response": [] } ], - "description": "Play around with Postman request:\n\n- First, go to the connector settings, you should able to see a configuration name MOLLIE_BANK_TRANSFER_DUE_DATE, it is set by default to be 14d which mean the payment will be expired after 14 days from the day payment created. You can update it to be in the range from 1d to 100d, just make sure to redeploy the connector again after changing it.\n \n\n\"\"\n\n- Make a call with the `Create Payment` request in this folder, please update the email in `custom.fields.sctm_create_payment_request` of the request body before doing that.\n \n\n\n\n- After the response returned successfully, you will see the `checkoutUrl` and `molliePaymentId` in `interfaceInteractions.fields`, please access the checkout URL and process the payment and select the status as you want to, then go to the Mollie Dashboard and use the value of molliePaymentId to search for the payment, it should indicate the status that you selected.\n \n- You should have receive an email which will include the due date, it should be calculated correctly ( = today + due date set on connector config)" + "description": "Play around with Postman request:\n\n- First, go to the custom application, you should able to see a configuration name Banktransfer due date under the Banktransfer payment method setting, it is set by default to be 14d which mean the payment will be expired after 14 days from the day payment created. You can update it to be in the range from 1d to 100d, just make sure to redeploy the connector again after changing it.\n \n\n\"\"\n\n- Make a call with the `Create Payment` request in this folder, please update the email in `custom.fields.sctm_create_payment_request` of the request body before doing that.\n \n\n\n\n- After the response returned successfully, you will see the `checkoutUrl` and `molliePaymentId` in `interfaceInteractions.fields`, please access the checkout URL and process the payment and select the status as you want to, then go to the Mollie Dashboard and use the value of molliePaymentId to search for the payment, it should indicate the status that you selected.\n \n- You should have receive an email which will include the due date, it should be calculated correctly ( = today + due date set on connector config)" }, { "name": "With Method ApplePay", @@ -1140,7 +1393,7 @@ "response": [] } ], - "description": "## Overview\n\nThis functionality is used to create a new Payment on Mollie:\n\nThis calls Mollie's [create payment](https://docs.mollie.com/reference/create-payment) endpoint.\n\n## Conditions\n\nAdding a new transaction to an existing order with type `Charge` and state `Initial` triggers create order payment.\n\nThere should be only one transaction with type `Charge` and state `Initial` in your CommerceTools Payment object.\n\nAnd also, the targeted Payment object should not have any transactions with type `Charge` and state is `Pending` or `Success`.\n\n## Parameters map\n\n| CT `Payment` object | Parameter (Mollie Payment) | Required |\n| --- | --- | --- |\n| `paymentMethodInfo.method: \"applepay\"` | `method: applepay` | YES |\n| `amountPlanned.currencyCode: \"EUR\"` | `amount.currency: EUR` | YES |\n| `amountPlanned.centAmount: \"1000\"` and `amountPlanned.fractionDigits: \"2\"` | `amount.value: \"10.00\"` | YES |\n| `custom.fields.sctm_create_payment_request.redirectUrl: \"https://webshop.example.org/order/12345/\"` | `redirectUrl: \"https://webshop.example.org/order/12345/\"` | YES |\n| `custom.fields.sctm_create_payment_request.description: \"Testing creating Mollie Payment\"` | `description: \"Testing creating Mollie Payment\"` | YES |\n\nThe others params which listed [here](https://docs.mollie.com/reference/create-payment) can be passed through the custom field of the Payment object name **sctm_create_payment_request** with exactly the same format like the field `redirectUrl` above\n\n## Representation: CommerceTools Payment\n\nExample CommerceTools Payment object triggering creating a Mollie Payment\n\n## Creating CommerceTools actions from Mollie's response\n\nWhen create order payment is successfully added on Mollie, we update CommerceTools payment with following actions\n\n| Action name (CT) | Value |\n| --- | --- |\n| `changeTransactionState` | `transactionId: , state: 'Pending'` |\n| `changeTransactionTimestamp` | `transactionId: , timestamp:` |\n| `changeTransactionInteractionId` | `transactionId: , interactionId:` |\n| `addInterfaceInteraction` | `actionType: \"CreatePayment\", id: , timestamp: , requestValue: {, responseValue:` |\n\n\\* Actions will always use first `Initial` transaction. There should only be one per payment. Transaction id will be the ID of the transaction which triggered the create payment.\n\n## **Demo with Postman**\n\nIn here we will just focus on the change on CommerceTools Payment object which will trigger our connector to create a Mollie Payment.\n\nIn the real project, it would be more complex when we will have a cart, then attach/create the Payment object for it then update the Payment object. But in general, the trigger point is that creating/updating the Payment object which satisfies the conditions above.\n\n**Steps to trigger the connector to create a Mollie Payment:**\n\n1\\. Obtain the access token:\n\n- Open the `Obtain access token` request, press on the send button to send request. After sending the request succesfully, it will automatically store the access_token in the response for later use\n \n\n2.\n\na. Create Payment with one transaction\n\n- Represent for the case that the user want to make a payment right after shopping.\n \n- Response expectation:\n \n - Transaction state will be updated to `Pending`\n \n - Transaction timestamp will be updated\n \n - Transaction `interactionId` will have a value like tr_XXXXXX, this is the Mollie Payment ID\n \n - interfaceInteractions now will have a custom field, that custom fieldset will include:\n \n - id: Unique string generated by the connector\n \n - actionType: will be `createPayment` in this case\n \n - requestValue: JSON string contain CommerceTools transaction ID and payment method\n \n - resoponeValue: JSON string contain Mollie Payment ID, Checkout URL and the CommerceTools transaction ID\n \n\nb. Create Payment with more than one transaction\n\n- Represent the case that the user could made a payment before but failed or something like that, therefor he wants to make a new payment again, therefor our CommerceTools Payment object will have at least 2 transactions: the first one is the failed one (called transaction A) and the second one represent for the current creating payment process (call transaction B)\n \n- Response expectation: really the same with the 2.a, except that the only target transaction (the one which will be updated) is the transaction B above" + "description": "## Overview\n\nThis functionality is used to create a new Payment on Mollie:\n\nThis calls Mollie's [create payment](https://docs.mollie.com/reference/create-payment) endpoint.\n\n## Conditions\n\nAdding a new transaction to an existing order with type `Charge` and state `Initial` triggers create order payment.\n\nThere should be only one transaction with type `Charge` and state `Initial` in your CommerceTools Payment object.\n\nAnd also, the targeted Payment object should not have any transactions with type `Charge` and state is `Pending` or `Success`.\n\n## Parameters map\n\n| CT `Payment` object | Parameter (Mollie Payment) | Required |\n| --- | --- | --- |\n| `paymentMethodInfo.method: \"applepay\"` | `method: applepay` | YES |\n| `amountPlanned.currencyCode: \"EUR\"` | `amount.currency: EUR` | YES |\n| `amountPlanned.centAmount: \"1000\"` and `amountPlanned.fractionDigits: \"2\"` | `amount.value: \"10.00\"` | YES |\n| `custom.fields.sctm_create_payment_request.redirectUrl: \"https://webshop.example.org/order/12345/\"` | `redirectUrl: \"https://webshop.example.org/order/12345/\"` | YES |\n| `custom.fields.sctm_create_payment_request.description: \"Testing creating Mollie Payment\"` | `description: \"Testing creating Mollie Payment\"` | YES |\n| `custom.fields.sctm_create_payment_request.lines: [ { description: 'Item 1', quantity: 1, quantityUnit: 'pcs', unitPrice: { currency: 'EUR', value: '10.00' }, totalAmount: { currency: 'EUR', value: '10.00' }, sku: 'TEST1', imageUrl: '`[https://example.com/image1.jpg'](https://example.com/image1.jpg')`, productUrl: '`[https://example.com/product1'](https://example.com/product1')`, }, { description: 'Item 2', quantity: 1, quantityUnit: 'pcs', unitPrice: { currency: 'EUR', value: '10.00' }, totalAmount: { currency: 'EUR', value: '10.00' }, sku: 'TEST2', imageUrl: '`[https://example.com/image2.jpg'](https://example.com/image2.jpg')`, productUrl: '`[https://example.com/product2'](https://example.com/product2')`, }, ]` | `lines: [ { description: 'Item 1', quantity: 1, quantityUnit: 'pcs', unitPrice: { currency: 'EUR', value: '10.00' }, totalAmount: { currency: 'EUR', value: '10.00' }, sku: 'TEST1', imageUrl: '`[https://example.com/image1.jpg'](https://example.com/image1.jpg')`, productUrl: '`[https://example.com/product1'](https://example.com/product1')`, }, { description: 'Item 2', quantity: 1, quantityUnit: 'pcs', unitPrice: { currency: 'EUR', value: '10.00' }, totalAmount: { currency: 'EUR', value: '10.00' }, sku: 'TEST2', imageUrl: '`[https://example.com/image2.jpg'](https://example.com/image2.jpg')`, productUrl: '`[https://example.com/product2'](https://example.com/product2')`, }, ]` | NO |\n\nThe others params which listed [here](https://docs.mollie.com/reference/create-payment) can be passed through the custom field of the Payment object name **sctm_create_payment_request** with exactly the same format like the field `redirectUrl` above\n\n## Representation: CommerceTools Payment\n\nExample CommerceTools Payment object triggering creating a Mollie Payment\n\n## Creating CommerceTools actions from Mollie's response\n\nWhen create order payment is successfully added on Mollie, we update CommerceTools payment with following actions\n\n| Action name (CT) | Value |\n| --- | --- |\n| `changeTransactionState` | `transactionId: , state: 'Pending'` |\n| `changeTransactionTimestamp` | `transactionId: , timestamp:` |\n| `changeTransactionInteractionId` | `transactionId: , interactionId:` |\n| `addInterfaceInteraction` | `actionType: \"CreatePayment\", id: , timestamp: , requestValue: {, responseValue:` |\n\n\\* Actions will always use first `Initial` transaction. There should only be one per payment. Transaction id will be the ID of the transaction which triggered the create payment.\n\n## **Demo with Postman**\n\nIn here we will just focus on the change on CommerceTools Payment object which will trigger our connector to create a Mollie Payment.\n\nIn the real project, it would be more complex when we will have a cart, then attach/create the Payment object for it then update the Payment object. But in general, the trigger point is that creating/updating the Payment object which satisfies the conditions above.\n\n**Steps to trigger the connector to create a Mollie Payment:**\n\n1\\. Obtain the access token:\n\n- Open the `Obtain access token` request, press on the send button to send request. After sending the request succesfully, it will automatically store the access_token in the response for later use\n \n\n2.\n\na. Create Payment with one transaction\n\n- Represent for the case that the user want to make a payment right after shopping.\n \n- Response expectation:\n \n - Transaction state will be updated to `Pending`\n \n - Transaction timestamp will be updated\n \n - Transaction `interactionId` will have a value like tr_XXXXXX, this is the Mollie Payment ID\n \n - interfaceInteractions now will have a custom field, that custom fieldset will include:\n \n - id: Unique string generated by the connector\n \n - actionType: will be `createPayment` in this case\n \n - requestValue: JSON string contain CommerceTools transaction ID and payment method\n \n - resoponeValue: JSON string contain Mollie Payment ID, Checkout URL and the CommerceTools transaction ID\n \n\nb. Create Payment with more than one transaction\n\n- Represent the case that the user could made a payment before but failed or something like that, therefor he wants to make a new payment again, therefor our CommerceTools Payment object will have at least 2 transactions: the first one is the failed one (called transaction A) and the second one represent for the current creating payment process (call transaction B)\n \n- Response expectation: really the same with the 2.a, except that the only target transaction (the one which will be updated) is the transaction B above" }, { "name": "Cancel Payment", @@ -1297,7 +1550,7 @@ ], "body": { "mode": "raw", - "raw": "{\n \"version\" : {{payment-targeted-version}},\n \"actions\" : [ {\n \"action\" : \"addTransaction\",\n \"transaction\": {\n \"type\": \"CancelAuthorization\",\n \"amount\": {\n \"currencyCode\" : \"EUR\",\n \"centAmount\" : 1100\n },\n \"state\": \"Initial\",\n \"custom\": {\n \"type\": {\n \"typeId\": \"type\",\n \"key\": \"sctm_payment_cancel_reason\"\n },\n \"fields\": {\n \"reasonText\": \"Testing cancel payment\"\n }\n }\n }\n } ]\n}" + "raw": "{\n \"version\" : {{payment-version}},\n \"actions\" : [ {\n \"action\" : \"addTransaction\",\n \"transaction\": {\n \"type\": \"CancelAuthorization\",\n \"amount\": {\n \"currencyCode\" : \"EUR\",\n \"centAmount\" : 5000\n },\n \"state\": \"Initial\",\n \"custom\": {\n \"type\": {\n \"typeId\": \"type\",\n \"key\": \"sctm_payment_cancel_reason\"\n },\n \"fields\": {\n \"reasonText\": \"Testing cancel payment\"\n }\n }\n }\n } ]\n}" }, "url": { "raw": "{{host}}/{{project-key}}/payments/{{payment-id}}", @@ -2121,6 +2374,129 @@ "response": [] } ] + }, + { + "name": "III. Custom Application Requests", + "item": [ + { + "name": "Get Method Objects", + "event": [ + { + "listen": "test", + "script": { + "type": "text/javascript", + "exec": [ + "tests[\"Status code \" + responseCode.code] = responseCode.code === 200 || responseCode.code === 201;", + "var data = JSON.parse(responseBody);", + "if(data.results && data.results[0] && data.results[0].id && data.results[0].version){", + " pm.environment.set(\"custom-object-id\", data.results[0].id); ", + " pm.environment.set(\"custom-object-version\", data.results[0].version);", + "}", + "if(data.results && data.results[0] && data.results[0].key){", + " pm.environment.set(\"custom-object-key\", data.results[0].key); ", + "}", + "if(data.version){", + " pm.environment.set(\"custom-object-version\", data.version);", + "}", + "if(data.id){", + " pm.environment.set(\"custom-object-id\", data.id); ", + "}", + "if(data.key){", + " pm.environment.set(\"custom-object-key\", data.key);", + "}", + "" + ] + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "auth": { + "type": "oauth2", + "oauth2": [ + { + "key": "accessToken", + "value": "{{ctp_access_token}}", + "type": "string" + }, + { + "key": "addTokenTo", + "value": "header", + "type": "string" + }, + { + "key": "tokenType", + "value": "Bearer", + "type": "string" + } + ] + }, + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{host}}/{{project-key}}/custom-objects/{{container}}", + "host": [ + "{{host}}" + ], + "path": [ + "{{project-key}}", + "custom-objects", + "{{container}}" + ], + "query": [ + { + "key": "sort", + "value": "", + "disabled": true + }, + { + "key": "where", + "value": "", + "disabled": true + }, + { + "key": "expand", + "value": "", + "disabled": true + }, + { + "key": "/^var[.][a-zA-Z0-9]+$/", + "value": "", + "disabled": true + }, + { + "key": "limit", + "value": "", + "disabled": true + }, + { + "key": "offset", + "value": "", + "disabled": true + }, + { + "key": "withTotal", + "value": "", + "disabled": true + } + ] + }, + "description": "null" + }, + "response": [] + } + ] } ] } \ No newline at end of file diff --git a/docs/postman/sctm_connector_v101.postman_environment.json b/docs/postman/sctm_connector_v121.postman_environment.json similarity index 100% rename from docs/postman/sctm_connector_v101.postman_environment.json rename to docs/postman/sctm_connector_v121.postman_environment.json diff --git a/processor/package-lock.json b/processor/package-lock.json index 9459397..321a2ca 100644 --- a/processor/package-lock.json +++ b/processor/package-lock.json @@ -1,6 +1,6 @@ { "name": "shopmacher-mollie-processor", - "version": "1.2.0-build14.01.25.1420", + "version": "1.2.1", "lockfileVersion": 3, "requires": true, "packages": { @@ -9332,4 +9332,4 @@ } } } -} \ No newline at end of file +} diff --git a/processor/package.json b/processor/package.json index 534f07c..9291297 100644 --- a/processor/package.json +++ b/processor/package.json @@ -1,7 +1,7 @@ { "name": "shopmacher-mollie-processor", "description": "Integration between commercetools and mollie payment service provider", - "version": "1.2.0-build14.01.25.1420", + "version": "1.2.1", "main": "index.js", "private": true, "scripts": {