@commercetools/connect-payments-sdk 0.20.1 → 0.21.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
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Payment, PaymentDraft, Transaction } from '@commercetools/platform-sdk';
|
|
2
|
-
import { FindPaymentsByInterfaceId, GetPayment, PaymentService, PaymentServiceOptions, TransactionData, UpdatePayment } from '../types/payment.type';
|
|
2
|
+
import { FindPaymentsByInterfaceId, FindTransaction, GetPayment, PaymentService, PaymentServiceOptions, TransactionData, UpdatePayment } from '../types/payment.type';
|
|
3
3
|
/**
|
|
4
4
|
* This is the default implementation of the PaymentService interface.
|
|
5
5
|
*/
|
|
@@ -20,5 +20,6 @@ export declare class DefaultPaymentService implements PaymentService {
|
|
|
20
20
|
private populateSetCustomType;
|
|
21
21
|
private populateAddInterfaceInteractions;
|
|
22
22
|
findMatchingTransactions(payment: Payment, transaction: TransactionData): Transaction[];
|
|
23
|
+
hasTransactionInState(opts: FindTransaction): boolean;
|
|
23
24
|
private consolidateTransactionChanges;
|
|
24
25
|
}
|
|
@@ -141,6 +141,9 @@ class DefaultPaymentService {
|
|
|
141
141
|
tx.state === 'Initial')));
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
|
+
hasTransactionInState(opts) {
|
|
145
|
+
return opts.payment.transactions.some((tx) => tx.type === opts.transactionType && opts.states.includes(tx.state));
|
|
146
|
+
}
|
|
144
147
|
consolidateTransactionChanges(payment, transaction) {
|
|
145
148
|
const actions = [];
|
|
146
149
|
// If the transaction is in Initial state and has no interactionId, we discard it as it does not provide any value
|
|
@@ -35,12 +35,18 @@ export type UpdatePayment = {
|
|
|
35
35
|
paymentMethod?: string;
|
|
36
36
|
customFields?: CustomFieldsDraft;
|
|
37
37
|
};
|
|
38
|
+
export type FindTransaction = {
|
|
39
|
+
payment: Payment;
|
|
40
|
+
transactionType: TransactionType;
|
|
41
|
+
states: TransactionState[];
|
|
42
|
+
};
|
|
38
43
|
/**
|
|
39
44
|
* Payment service interface exposes methods to interact with the commercetools platform API.
|
|
40
45
|
*/
|
|
41
46
|
export interface PaymentService {
|
|
42
47
|
getPayment(opts: GetPayment): Promise<Payment>;
|
|
43
48
|
findPaymentsByInterfaceId(opts: FindPaymentsByInterfaceId): Promise<Payment[]>;
|
|
49
|
+
hasTransactionInState(opts: FindTransaction): boolean;
|
|
44
50
|
createPayment(draft: PaymentDraft): Promise<Payment>;
|
|
45
51
|
updatePayment(opts: UpdatePayment): Promise<Payment>;
|
|
46
52
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools/connect-payments-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "Payment SDK for commercetools payment connectors",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
],
|
|
16
16
|
"license": "ISC",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@commercetools-backend/loggers": "23.2.
|
|
18
|
+
"@commercetools-backend/loggers": "23.2.2",
|
|
19
19
|
"@commercetools/platform-sdk": "8.5.0",
|
|
20
20
|
"@commercetools/sdk-client-v2": "2.5.0",
|
|
21
21
|
"jsonwebtoken": "9.0.2",
|