@commercetools/connect-payments-sdk 0.8.2 → 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 +6 -0
- 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
|
@@ -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
|
}
|