@commercetools/connect-payments-sdk 0.8.1 → 0.9.0
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 +12 -0
- package/dist/api/handlers/status.handler.js +28 -16
- package/dist/commercetools/api/root-api.js +3 -1
- package/dist/commercetools/index.d.ts +1 -0
- package/dist/commercetools/services/ct-payment.service.d.ts +1 -0
- package/dist/commercetools/services/ct-payment.service.js +13 -0
- package/dist/commercetools/types/payment.type.d.ts +5 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @commercetools/connect-payments-sdk
|
|
2
2
|
|
|
3
|
+
## 0.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 673f3c0: Added support to update the payment custom fields
|
|
8
|
+
|
|
9
|
+
## 0.8.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- c10522b: - Do not crash the commercetools permissions health check if the config is incorrect. Instead return a proper health check status.
|
|
14
|
+
|
|
3
15
|
## 0.8.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -68,26 +68,38 @@ exports.statusHandler = statusHandler;
|
|
|
68
68
|
* @returns
|
|
69
69
|
*/
|
|
70
70
|
const healthCheckCommercetoolsPermissions = (opts) => async () => {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
try {
|
|
72
|
+
const token = await opts.ctAuthorizationService.getAccessToken();
|
|
73
|
+
const foundAll = opts.requiredPermissions.every((currentScope) => token.scope.split(' ').some((scopeInToken) => scopeInToken === `${currentScope}:${opts.projectKey}`));
|
|
74
|
+
if (foundAll) {
|
|
75
|
+
return {
|
|
76
|
+
name: 'commercetools permissions',
|
|
77
|
+
status: 'UP',
|
|
78
|
+
details: {
|
|
79
|
+
scope: token.scope,
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|
|
74
83
|
return {
|
|
75
|
-
name: '
|
|
76
|
-
status: '
|
|
84
|
+
name: 'commercetools permissions',
|
|
85
|
+
status: 'DOWN',
|
|
86
|
+
message: `commercetools permissions are not correct, expected scopes: ${opts.requiredPermissions.join(' ')}, actual scopes: ${token.scope}`,
|
|
77
87
|
details: {
|
|
78
|
-
|
|
88
|
+
expectedScopes: opts.requiredPermissions,
|
|
89
|
+
actualScopes: token.scope,
|
|
90
|
+
reason: 'scopes not available',
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
return {
|
|
96
|
+
name: 'commercetools permissions',
|
|
97
|
+
status: 'DOWN',
|
|
98
|
+
message: `Not able to talk with commercetools API`,
|
|
99
|
+
details: {
|
|
100
|
+
error,
|
|
79
101
|
},
|
|
80
102
|
};
|
|
81
103
|
}
|
|
82
|
-
return {
|
|
83
|
-
name: 'CoCo Permissions',
|
|
84
|
-
status: 'DOWN',
|
|
85
|
-
message: `CoCo permissions are not correct, expected scopes: ${opts.requiredPermissions.join(' ')}, actual scopes: ${token.scope}`,
|
|
86
|
-
details: {
|
|
87
|
-
expectedScopes: opts.requiredPermissions,
|
|
88
|
-
actualScopes: token.scope,
|
|
89
|
-
reason: 'scopes not available',
|
|
90
|
-
},
|
|
91
|
-
};
|
|
92
104
|
};
|
|
93
105
|
exports.healthCheckCommercetoolsPermissions = healthCheckCommercetoolsPermissions;
|
|
@@ -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
|
|
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.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools/connect-payments-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
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.
|
|
19
|
-
"@commercetools/platform-sdk": "7.
|
|
18
|
+
"@commercetools-backend/loggers": "22.31.0",
|
|
19
|
+
"@commercetools/platform-sdk": "7.11.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.
|
|
24
|
+
"logform": "2.6.1"
|
|
25
25
|
}
|
|
26
26
|
}
|