Skip to content

Commit

Permalink
Merge pull request #44 from mollie/feature/MOL-303
Browse files Browse the repository at this point in the history
MOL-303: add additional info to the version string
  • Loading branch information
Tung-Huynh-Shopmacher authored Aug 21, 2024
2 parents 2404828 + aa20fab commit c170cd3
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 16 deletions.
4 changes: 2 additions & 2 deletions processor/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion processor/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
6 changes: 3 additions & 3 deletions processor/src/client/mollie.client.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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,
});
};
4 changes: 2 additions & 2 deletions processor/src/mollie/payment.mollie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand Down Expand Up @@ -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', {
Expand Down
4 changes: 4 additions & 0 deletions processor/src/utils/constant.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions processor/tests/client/mollie.client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
});
Expand Down
10 changes: 5 additions & 5 deletions processor/tests/mollie/payment.mollie.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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 () =>
Expand Down Expand Up @@ -174,7 +174,7 @@ describe('createPaymentWithCustomMethod', () => {
const headers = {
'Content-Type': 'application/json',
Authorization: `Bearer ${getApiKey()}`,
versionStrings: `${VERSION_STRING}`,
versionStrings: MOLLIE_VERSION_STRINGS,
};

const response = {
Expand Down Expand Up @@ -239,7 +239,7 @@ describe('createPaymentWithCustomMethod', () => {
const headers = {
'Content-Type': 'application/json',
Authorization: `Bearer ${getApiKey()}`,
versionStrings: `${VERSION_STRING}`,
versionStrings: MOLLIE_VERSION_STRINGS,
};

const response = {
Expand Down Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion processor/tests/routes/webhook.route.spec.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down

0 comments on commit c170cd3

Please sign in to comment.