From aa20fab997ccd873624a32ef86b92d17a13c5ffd Mon Sep 17 00:00:00 2001 From: Win Date: Wed, 21 Aug 2024 13:44:05 +0700 Subject: [PATCH] MOL-303: add additional info to the version string --- processor/package-lock.json | 4 ++-- processor/package.json | 2 +- processor/src/client/mollie.client.ts | 6 +++--- processor/src/mollie/payment.mollie.ts | 4 ++-- processor/src/utils/constant.utils.ts | 4 ++++ processor/tests/client/mollie.client.spec.ts | 4 ++-- processor/tests/mollie/payment.mollie.spec.ts | 10 +++++----- processor/tests/routes/webhook.route.spec.ts | 2 +- 8 files changed, 20 insertions(+), 16 deletions(-) diff --git a/processor/package-lock.json b/processor/package-lock.json index 43c2f56..a7acad8 100644 --- a/processor/package-lock.json +++ b/processor/package-lock.json @@ -1,12 +1,12 @@ { "name": "shopmacher-mollie-processor", - "version": "0.0.32", + "version": "0.0.33", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "shopmacher-mollie-processor", - "version": "0.0.32", + "version": "0.0.33", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/processor/package.json b/processor/package.json index c734c85..c9f1c8d 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": "0.0.32", + "version": "0.0.33", "main": "index.js", "private": true, "scripts": { diff --git a/processor/src/client/mollie.client.ts b/processor/src/client/mollie.client.ts index d5dc369..41a8e13 100644 --- a/processor/src/client/mollie.client.ts +++ b/processor/src/client/mollie.client.ts @@ -1,6 +1,6 @@ import createMollieClient, { MollieClient } from '@mollie/api-client'; import { getApiKey, readConfiguration } from '../utils/config.utils'; -import { VERSION_STRING } from '../utils/constant.utils'; +import { MOLLIE_VERSION_STRINGS } from '../utils/constant.utils'; /** * Initializes the Mollie client using the API key from the configuration. @@ -10,13 +10,13 @@ import { VERSION_STRING } from '../utils/constant.utils'; export const initMollieClient = (): MollieClient => { return createMollieClient({ apiKey: getApiKey(), - versionStrings: `${VERSION_STRING}`, + versionStrings: MOLLIE_VERSION_STRINGS, }); }; export const initMollieClientForApplePaySession = (): MollieClient => { return createMollieClient({ apiKey: readConfiguration().mollie.liveApiKey, - versionStrings: `${VERSION_STRING}`, + versionStrings: MOLLIE_VERSION_STRINGS, }); }; diff --git a/processor/src/mollie/payment.mollie.ts b/processor/src/mollie/payment.mollie.ts index 588f0a3..3beea2f 100644 --- a/processor/src/mollie/payment.mollie.ts +++ b/processor/src/mollie/payment.mollie.ts @@ -13,7 +13,7 @@ import { logger } from '../utils/logger.utils'; import { ApplePaySessionRequest, CustomPayment } from '../types/mollie.types'; import ApplePaySession from '@mollie/api-client/dist/types/src/data/applePaySession/ApplePaySession'; import { getApiKey } from '../utils/config.utils'; -import { VERSION_STRING } from '../utils/constant.utils'; +import { MOLLIE_VERSION_STRINGS } from '../utils/constant.utils'; import fetch from 'node-fetch'; /** @@ -111,7 +111,7 @@ export const createPaymentWithCustomMethod = async (paymentParams: PaymentCreate const headers = { 'Content-Type': 'application/json', Authorization: `Bearer ${getApiKey()}`, - versionStrings: `${VERSION_STRING}`, + versionStrings: MOLLIE_VERSION_STRINGS, }; const response = await fetch('https://api.mollie.com/v2/payments', { diff --git a/processor/src/utils/constant.utils.ts b/processor/src/utils/constant.utils.ts index 82cfab4..b86d4f9 100644 --- a/processor/src/utils/constant.utils.ts +++ b/processor/src/utils/constant.utils.ts @@ -5,8 +5,12 @@ export const LIBRARY_NAME = 'ShopmacherCommercetoolsMollieConnector'; export const LIBRARY_VERSION = PACKAGE_VERSION; +export const MOLLIE_AGENT_INFO = 'uap/NJTCs6RvSnqbvawh'; + export const VERSION_STRING = `${LIBRARY_NAME}/${LIBRARY_VERSION}`; +export const MOLLIE_VERSION_STRINGS = [VERSION_STRING, MOLLIE_AGENT_INFO]; + export const CustomFields = { payment: { error: 'sctm_payment_methods_error', diff --git a/processor/tests/client/mollie.client.spec.ts b/processor/tests/client/mollie.client.spec.ts index 1d01417..cbd8edb 100644 --- a/processor/tests/client/mollie.client.spec.ts +++ b/processor/tests/client/mollie.client.spec.ts @@ -2,7 +2,7 @@ import { getApiKey } from '../../src/utils/config.utils'; import { initMollieClient } from '../../src/client/mollie.client'; import createMollieClient, { MollieClient } from '@mollie/api-client'; import { describe, jest, expect, it } from '@jest/globals'; -import { LIBRARY_NAME, LIBRARY_VERSION } from '../../src/utils/constant.utils'; +import { MOLLIE_VERSION_STRINGS } from '../../src/utils/constant.utils'; jest.mock('@mollie/api-client', () => ({ // @ts-expect-error ignore type error @@ -30,7 +30,7 @@ describe('Test mollie.client.ts', () => { expect(mockGetApiKey).toHaveBeenCalled(); expect(mockCreateMollieClient).toHaveBeenCalledWith({ apiKey: 'test-api-key', - versionStrings: `${LIBRARY_NAME}/${LIBRARY_VERSION}`, + versionStrings: MOLLIE_VERSION_STRINGS, }); expect(client).toBe(mockMollieClient); }); diff --git a/processor/tests/mollie/payment.mollie.spec.ts b/processor/tests/mollie/payment.mollie.spec.ts index 990ff49..d7a5033 100644 --- a/processor/tests/mollie/payment.mollie.spec.ts +++ b/processor/tests/mollie/payment.mollie.spec.ts @@ -10,7 +10,7 @@ import { import { MollieApiError, PaymentCreateParams } from '@mollie/api-client'; import { logger } from '../../src/utils/logger.utils'; import CustomError from '../../src/errors/custom.error'; -import { VERSION_STRING } from '../../src/utils/constant.utils'; +import { MOLLIE_VERSION_STRINGS } from '../../src/utils/constant.utils'; import { getApiKey } from '../../src/utils/config.utils'; import fetch from 'node-fetch'; @@ -136,7 +136,7 @@ describe('createPaymentWithCustomMethod', () => { const headers = { 'Content-Type': 'application/json', Authorization: `Bearer ${getApiKey()}`, - versionStrings: `${VERSION_STRING}`, + versionStrings: MOLLIE_VERSION_STRINGS, }; (fetch as unknown as jest.Mock).mockImplementation(async () => @@ -174,7 +174,7 @@ describe('createPaymentWithCustomMethod', () => { const headers = { 'Content-Type': 'application/json', Authorization: `Bearer ${getApiKey()}`, - versionStrings: `${VERSION_STRING}`, + versionStrings: MOLLIE_VERSION_STRINGS, }; const response = { @@ -239,7 +239,7 @@ describe('createPaymentWithCustomMethod', () => { const headers = { 'Content-Type': 'application/json', Authorization: `Bearer ${getApiKey()}`, - versionStrings: `${VERSION_STRING}`, + versionStrings: MOLLIE_VERSION_STRINGS, }; const response = { @@ -295,7 +295,7 @@ describe('createPaymentWithCustomMethod', () => { const headers = { 'Content-Type': 'application/json', Authorization: `Bearer ${getApiKey()}`, - versionStrings: `${VERSION_STRING}`, + versionStrings: MOLLIE_VERSION_STRINGS, }; const errorMessage = 'SCTM - createPaymentWithCustomMethod - Failed to create a payment with unknown errors'; diff --git a/processor/tests/routes/webhook.route.spec.ts b/processor/tests/routes/webhook.route.spec.ts index a179eed..dd6b4c9 100644 --- a/processor/tests/routes/webhook.route.spec.ts +++ b/processor/tests/routes/webhook.route.spec.ts @@ -1,4 +1,4 @@ -import { describe, it, jest, beforeEach } from '@jest/globals'; +import { describe, it, jest, beforeEach, expect } from '@jest/globals'; import { Request, Response, NextFunction } from 'express'; import webhookRouter from '../../src/routes/webhook.route';