@commercetools/connect-payments-sdk 0.15.0 → 0.16.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 +12 -0
- package/dist/commercetools/helpers/currency.converter.d.ts +3 -0
- package/dist/commercetools/helpers/currency.converter.js +6 -1
- package/dist/commercetools/services/ct-payment.service.d.ts +2 -1
- package/dist/commercetools/services/ct-payment.service.js +4 -0
- package/dist/commercetools/types/payment.type.d.ts +4 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @commercetools/connect-payments-sdk
|
|
2
2
|
|
|
3
|
+
## 0.16.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 36f0d66: Fix the issue with rounding currency amounts
|
|
8
|
+
|
|
9
|
+
## 0.16.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 84c0cda: added new method to find payments by interfaceId
|
|
14
|
+
|
|
3
15
|
## 0.15.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
* @example (12345, 2) => 1234500
|
|
16
16
|
* @example (12345, 3) => 12345000
|
|
17
17
|
*
|
|
18
|
+
*
|
|
19
|
+
* @param amount Integer value to apply the fraction digit to
|
|
20
|
+
* @param fractionDigit The fraction digit to apply
|
|
18
21
|
* @throws an Error if the given fraction digit (either via mapping or directly) is not a integer value
|
|
19
22
|
*/
|
|
20
23
|
declare const convert: (amount: number, fractionDigit: number) => number;
|
|
@@ -23,11 +23,16 @@ const validateFractionDigit = (fractionDigit) => {
|
|
|
23
23
|
* @example (12345, 2) => 1234500
|
|
24
24
|
* @example (12345, 3) => 12345000
|
|
25
25
|
*
|
|
26
|
+
*
|
|
27
|
+
* @param amount Integer value to apply the fraction digit to
|
|
28
|
+
* @param fractionDigit The fraction digit to apply
|
|
26
29
|
* @throws an Error if the given fraction digit (either via mapping or directly) is not a integer value
|
|
27
30
|
*/
|
|
28
31
|
const convert = (amount, fractionDigit) => {
|
|
29
32
|
validateFractionDigit(fractionDigit);
|
|
30
|
-
|
|
33
|
+
const result = amount * Math.pow(10, fractionDigit);
|
|
34
|
+
const strResult = result.toFixed(Math.abs(fractionDigit));
|
|
35
|
+
return parseFloat(strResult);
|
|
31
36
|
};
|
|
32
37
|
exports.convert = convert;
|
|
33
38
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Payment, PaymentDraft, Transaction } from '@commercetools/platform-sdk';
|
|
2
|
-
import { GetPayment, PaymentService, PaymentServiceOptions, TransactionData, UpdatePayment } from '../types/payment.type';
|
|
2
|
+
import { FindPaymentsByInterfaceId, GetPayment, PaymentService, PaymentServiceOptions, TransactionData, UpdatePayment } from '../types/payment.type';
|
|
3
3
|
/**
|
|
4
4
|
* This is the default implementation of the PaymentService interface.
|
|
5
5
|
*/
|
|
@@ -8,6 +8,7 @@ export declare class DefaultPaymentService implements PaymentService {
|
|
|
8
8
|
private logger;
|
|
9
9
|
constructor(opts: PaymentServiceOptions);
|
|
10
10
|
getPayment(opts: GetPayment): Promise<Payment>;
|
|
11
|
+
findPaymentsByInterfaceId(opts: FindPaymentsByInterfaceId): Promise<Payment[]>;
|
|
11
12
|
createPayment(draft: PaymentDraft): Promise<Payment>;
|
|
12
13
|
updatePayment(opts: UpdatePayment): Promise<Payment>;
|
|
13
14
|
private consolidateUpdateActions;
|
|
@@ -15,6 +15,10 @@ class DefaultPaymentService {
|
|
|
15
15
|
async getPayment(opts) {
|
|
16
16
|
return await this.ctAPI.payment.getPaymentById(opts.id);
|
|
17
17
|
}
|
|
18
|
+
async findPaymentsByInterfaceId(opts) {
|
|
19
|
+
const predicate = `interfaceId="${opts.interfaceId}"`;
|
|
20
|
+
return (await this.ctAPI.payment.find(predicate)).results;
|
|
21
|
+
}
|
|
18
22
|
async createPayment(draft) {
|
|
19
23
|
return await this.ctAPI.payment.createPayment(draft);
|
|
20
24
|
}
|
|
@@ -14,6 +14,9 @@ export type GetPayment = {
|
|
|
14
14
|
id: string;
|
|
15
15
|
version?: number;
|
|
16
16
|
};
|
|
17
|
+
export type FindPaymentsByInterfaceId = {
|
|
18
|
+
interfaceId: string;
|
|
19
|
+
};
|
|
17
20
|
export type PSPInteraction = {
|
|
18
21
|
request?: string;
|
|
19
22
|
response?: string;
|
|
@@ -41,6 +44,7 @@ export type UpdatePayment = {
|
|
|
41
44
|
*/
|
|
42
45
|
export interface PaymentService {
|
|
43
46
|
getPayment(opts: GetPayment): Promise<Payment>;
|
|
47
|
+
findPaymentsByInterfaceId(opts: FindPaymentsByInterfaceId): Promise<Payment[]>;
|
|
44
48
|
createPayment(draft: PaymentDraft): Promise<Payment>;
|
|
45
49
|
updatePayment(opts: UpdatePayment): Promise<Payment>;
|
|
46
50
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools/connect-payments-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.1",
|
|
4
4
|
"description": "Payment SDK for commercetools payment connectors",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"license": "ISC",
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@commercetools-backend/loggers": "22.38.1",
|
|
19
|
-
"@commercetools/platform-sdk": "8.
|
|
19
|
+
"@commercetools/platform-sdk": "8.1.0",
|
|
20
20
|
"@commercetools/sdk-client-v2": "2.5.0",
|
|
21
21
|
"jsonwebtoken": "9.0.2",
|
|
22
22
|
"jwks-rsa": "3.1.0",
|