@commercetools/connect-payments-sdk 0.8.2 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @commercetools/connect-payments-sdk
2
2
 
3
+ ## 0.9.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 36e1a4b: Updated various dependencies to their latest versions for improved performance and security
8
+
9
+ ## 0.9.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 673f3c0: Added support to update the payment custom fields
14
+
3
15
  ## 0.8.2
4
16
 
5
17
  ### Patch Changes
@@ -6,6 +6,7 @@ const sdk_client_v2_1 = require("@commercetools/sdk-client-v2");
6
6
  const cart_api_1 = require("./cart-api");
7
7
  const payment_api_1 = require("./payment-api");
8
8
  const order_api_1 = require("./order-api");
9
+ const crypto_1 = require("crypto");
9
10
  class DefaultCommercetoolsAPI {
10
11
  client;
11
12
  cart;
@@ -35,7 +36,8 @@ const createClient = (opts) => {
35
36
  };
36
37
  const correlationIdMiddlewareOptions = {
37
38
  generate: () => {
38
- const correlationID = opts.contextProvider.getContextData().correlationId;
39
+ const contextData = opts.contextProvider.getContextData();
40
+ const correlationID = contextData.correlationId && contextData.correlationId.length > 0 ? contextData.correlationId : (0, crypto_1.randomUUID)();
39
41
  return correlationID;
40
42
  },
41
43
  };
@@ -3,4 +3,5 @@ export { PaymentService as CommercetoolsPaymentService, TransactionData, UpdateP
3
3
  export { SessionService as CommercetoolsSessionService, Session } from './types/session.type';
4
4
  export { AuthorizationService as CommercetoolsAuthorizationService } from './types/authorization.type';
5
5
  export { OrderService as CommercetoolsOrderService } from './types/order.type';
6
+ export { CommercetoolsClient } from './types/api.type';
6
7
  export { Cart, Order, OrderPagedQueryResponse, Payment, PaymentDraft, Money, LineItem, CustomLineItem, Address, Transaction, TransactionType, TransactionState, ShippingInfo, } from '@commercetools/platform-sdk';
@@ -16,6 +16,7 @@ export declare class DefaultPaymentService implements PaymentService {
16
16
  private populateAddTransactionAction;
17
17
  private populateChangeTransactionState;
18
18
  private populateSetPaymentMethod;
19
+ private populateSetCustomType;
19
20
  findMatchingTransactions(payment: Payment, transaction: TransactionData): Transaction[];
20
21
  private consolidateTransactionChanges;
21
22
  }
@@ -69,6 +69,9 @@ class DefaultPaymentService {
69
69
  actions.push(...transactionChanges);
70
70
  }
71
71
  }
72
+ if (updateInfo.customFields) {
73
+ actions.push(this.populateSetCustomType(updateInfo.customFields));
74
+ }
72
75
  return actions;
73
76
  }
74
77
  populateSetInterfaceIdAction(interfaceId) {
@@ -106,6 +109,16 @@ class DefaultPaymentService {
106
109
  method: paymentMethod,
107
110
  };
108
111
  }
112
+ populateSetCustomType(customFields) {
113
+ return {
114
+ action: 'setCustomType',
115
+ type: {
116
+ typeId: 'type',
117
+ key: customFields.typeKey,
118
+ },
119
+ fields: customFields.fields,
120
+ };
121
+ }
109
122
  findMatchingTransactions(payment, transaction) {
110
123
  return payment.transactions.filter((tx) => {
111
124
  return (tx.type === transaction.type &&
@@ -23,12 +23,17 @@ export type TransactionData = {
23
23
  interactionId?: string;
24
24
  state: TransactionState;
25
25
  };
26
+ export type CustomFieldsData = {
27
+ typeKey: string;
28
+ fields: Record<string, unknown>;
29
+ };
26
30
  export type UpdatePayment = {
27
31
  id: string;
28
32
  pspReference?: string;
29
33
  pspInteraction?: PSPInteraction;
30
34
  transaction?: TransactionData;
31
35
  paymentMethod?: string;
36
+ customFields?: CustomFieldsData;
32
37
  };
33
38
  /**
34
39
  * Payment service interface exposes methods to interact with the commercetools platform API.
@@ -23,6 +23,7 @@ class SessionQueryParamAuthenticationManager {
23
23
  });
24
24
  }
25
25
  catch (e) {
26
+ this.logger.error({ err: e }, 'Failed to authenticate session');
26
27
  throw new errorx_1.ErrorAuthErrorResponse('Session is not active');
27
28
  }
28
29
  }
@@ -0,0 +1,76 @@
1
+ import typescriptEslint from '@typescript-eslint/eslint-plugin';
2
+ import jest from 'eslint-plugin-jest';
3
+ import prettier from 'eslint-plugin-prettier';
4
+ import unusedImports from 'eslint-plugin-unused-imports';
5
+ import globals from 'globals';
6
+ import tsParser from '@typescript-eslint/parser';
7
+ import path from 'node:path';
8
+ import { fileURLToPath } from 'node:url';
9
+ import js from '@eslint/js';
10
+ import { FlatCompat } from '@eslint/eslintrc';
11
+
12
+ const __filename = fileURLToPath(import.meta.url);
13
+ const __dirname = path.dirname(__filename);
14
+ const compat = new FlatCompat({
15
+ baseDirectory: __dirname,
16
+ recommendedConfig: js.configs.recommended,
17
+ allConfig: js.configs.all,
18
+ });
19
+
20
+ export default [
21
+ ...compat.extends(
22
+ 'eslint:recommended',
23
+ 'plugin:@typescript-eslint/recommended',
24
+ 'prettier',
25
+ 'plugin:prettier/recommended',
26
+ ),
27
+ {
28
+ plugins: {
29
+ '@typescript-eslint': typescriptEslint,
30
+ jest,
31
+ prettier,
32
+ 'unused-imports': unusedImports,
33
+ },
34
+ files: ['*.ts'],
35
+ languageOptions: {
36
+ globals: {
37
+ ...globals.node,
38
+ ...globals.jest,
39
+ },
40
+
41
+ parser: tsParser,
42
+ },
43
+
44
+ rules: {
45
+ 'no-redeclare': ['warn'],
46
+ 'no-console': ['error'],
47
+ 'no-unused-vars': 'off',
48
+ 'no-irregular-whitespace': 'warn',
49
+ 'unused-imports/no-unused-imports': 'error',
50
+
51
+ 'unused-imports/no-unused-vars': [
52
+ 'warn',
53
+ {
54
+ vars: 'all',
55
+ varsIgnorePattern: '^_',
56
+ args: 'after-used',
57
+ argsIgnorePattern: '^_',
58
+ },
59
+ ],
60
+
61
+ '@typescript-eslint/no-unused-vars': ['warn'],
62
+ '@typescript-eslint/no-explicit-any': 'off',
63
+ '@typescript-eslint/no-var-requires': 'off',
64
+
65
+ 'sort-imports': [
66
+ 'error',
67
+ {
68
+ ignoreCase: true,
69
+ ignoreDeclarationSort: true,
70
+ ignoreMemberSort: false,
71
+ memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
72
+ },
73
+ ],
74
+ },
75
+ },
76
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools/connect-payments-sdk",
3
- "version": "0.8.2",
3
+ "version": "0.9.1",
4
4
  "description": "Payment SDK for commercetools payment connectors",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -15,12 +15,12 @@
15
15
  ],
16
16
  "license": "ISC",
17
17
  "dependencies": {
18
- "@commercetools-backend/loggers": "22.29.0",
19
- "@commercetools/platform-sdk": "7.9.0",
18
+ "@commercetools-backend/loggers": "22.32.2",
19
+ "@commercetools/platform-sdk": "7.14.0",
20
20
  "@commercetools/sdk-client-v2": "2.5.0",
21
21
  "jsonwebtoken": "9.0.2",
22
22
  "jwks-rsa": "3.1.0",
23
23
  "lodash": "4.17.21",
24
- "logform": "2.6.0"
24
+ "logform": "2.6.1"
25
25
  }
26
26
  }