@commercetools/connect-payments-sdk 0.22.0 → 0.23.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.23.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- a26f6de: Added missing transition from Success to Failure that prevented to update the payment in some special cases
|
|
8
|
+
|
|
9
|
+
## 0.23.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 45ed8ad: Upgrade dependencies to latest versions
|
|
14
|
+
|
|
3
15
|
## 0.22.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DefaultCommercetoolsAPI = void 0;
|
|
4
4
|
const platform_sdk_1 = require("@commercetools/platform-sdk");
|
|
5
|
-
const
|
|
5
|
+
const ts_client_1 = require("@commercetools/ts-client");
|
|
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");
|
|
@@ -30,11 +30,13 @@ const createClient = (opts) => {
|
|
|
30
30
|
clientId: opts.clientId,
|
|
31
31
|
clientSecret: opts.clientSecret,
|
|
32
32
|
},
|
|
33
|
+
...(opts.httpClient ? { httpClient: opts.httpClient } : {}),
|
|
33
34
|
};
|
|
34
35
|
const httpMiddlewareOptions = {
|
|
35
36
|
host: opts.apiUrl,
|
|
36
37
|
//Enables SDK retries when CoCo returns a 503 error. It retries up to 10 times with an 200ms backoff.
|
|
37
38
|
enableRetry: true,
|
|
39
|
+
...(opts.httpClient ? { httpClient: opts.httpClient } : {}),
|
|
38
40
|
};
|
|
39
41
|
const correlationIdMiddlewareOptions = {
|
|
40
42
|
generate: () => {
|
|
@@ -43,7 +45,7 @@ const createClient = (opts) => {
|
|
|
43
45
|
return correlationID;
|
|
44
46
|
},
|
|
45
47
|
};
|
|
46
|
-
const ctpClient = new
|
|
48
|
+
const ctpClient = new ts_client_1.ClientBuilder()
|
|
47
49
|
.withClientCredentialsFlow(authMiddlewareOptions)
|
|
48
50
|
.withCorrelationIdMiddleware(correlationIdMiddlewareOptions)
|
|
49
51
|
.withHttpMiddleware(httpMiddlewareOptions)
|
|
@@ -178,9 +178,16 @@ class DefaultPaymentService {
|
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
shouldUpdateTransactionState(existingTx, newTransaction) {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
181
|
+
const { state: currentState } = existingTx;
|
|
182
|
+
const { state: newState } = newTransaction;
|
|
183
|
+
// Define allowed state transitions
|
|
184
|
+
const allowedTransitions = {
|
|
185
|
+
Initial: ['Pending', 'Success', 'Failure'],
|
|
186
|
+
Pending: ['Success', 'Failure'],
|
|
187
|
+
Failure: ['Success'],
|
|
188
|
+
Success: ['Failure'],
|
|
189
|
+
};
|
|
190
|
+
return currentState !== newState && allowedTransitions[currentState]?.includes(newState);
|
|
184
191
|
}
|
|
185
192
|
shouldUpdateInteractionId(existingTx, newTransaction) {
|
|
186
193
|
return !existingTx.interactionId && !!newTransaction.interactionId;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools/connect-payments-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.1",
|
|
4
4
|
"description": "Payment SDK for commercetools payment connectors",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
],
|
|
16
16
|
"license": "ISC",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@commercetools-backend/loggers": "
|
|
19
|
-
"@commercetools/platform-sdk": "8.
|
|
20
|
-
"@commercetools/
|
|
18
|
+
"@commercetools-backend/loggers": "24.1.0",
|
|
19
|
+
"@commercetools/platform-sdk": "8.10.0",
|
|
20
|
+
"@commercetools/ts-client": "3.4.0",
|
|
21
21
|
"jsonwebtoken": "9.0.2",
|
|
22
22
|
"jwks-rsa": "3.2.0",
|
|
23
23
|
"lodash": "4.17.21",
|