btrz-api-client 8.26.0 → 8.28.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/lib/client-standalone-min.js +3 -3
- package/lib/client.js +1 -0
- package/lib/endpoints/invoices/infileJson.js +52 -0
- package/lib/endpoints/sales/cancellations.js +39 -1
- package/package.json +1 -1
- package/src/client.js +1 -0
- package/src/endpoints/invoices/infileJson.js +32 -0
- package/src/endpoints/sales/cancellations.js +33 -1
- package/test/endpoints/invoices/infileJson.test.js +33 -0
- package/test/endpoints/sales/cancellations.test.js +28 -0
- package/types/client.d.ts +23 -0
- package/types/endpoints/invoices/infileJson.d.ts +20 -0
- package/types/endpoints/sales/cancellations.d.ts +31 -1
- package/types/initializedClient.d.ts +23 -0
package/lib/client.js
CHANGED
|
@@ -497,6 +497,7 @@ function createInvoices(_ref14) {
|
|
|
497
497
|
providers: require("./endpoints/invoices/providers.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
|
|
498
498
|
providersSequences: require("./endpoints/invoices/providersSequences.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
|
|
499
499
|
infile: require("./endpoints/invoices/infile.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
|
|
500
|
+
infileJson: require("./endpoints/invoices/infileJson.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
|
|
500
501
|
system: require("./endpoints/invoices/system.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
|
|
501
502
|
dlink: require("./endpoints/invoices/dlink.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
|
|
502
503
|
gti: require("./endpoints/invoices/gti.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _require = require("./../endpoints_helpers"),
|
|
4
|
+
authorizationHeaders = _require.authorizationHeaders;
|
|
5
|
+
|
|
6
|
+
function infileJsonFactory(_ref) {
|
|
7
|
+
var client = _ref.client,
|
|
8
|
+
internalAuthTokenProvider = _ref.internalAuthTokenProvider;
|
|
9
|
+
|
|
10
|
+
function create(_ref2) {
|
|
11
|
+
var token = _ref2.token,
|
|
12
|
+
jwtToken = _ref2.jwtToken,
|
|
13
|
+
data = _ref2.data,
|
|
14
|
+
_ref2$query = _ref2.query,
|
|
15
|
+
query = _ref2$query === undefined ? {} : _ref2$query,
|
|
16
|
+
headers = _ref2.headers;
|
|
17
|
+
|
|
18
|
+
return client({
|
|
19
|
+
url: "/infile-json",
|
|
20
|
+
method: "post",
|
|
21
|
+
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers }),
|
|
22
|
+
params: query,
|
|
23
|
+
data: data
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function validateCreate(_ref3) {
|
|
28
|
+
var token = _ref3.token,
|
|
29
|
+
jwtToken = _ref3.jwtToken,
|
|
30
|
+
data = _ref3.data,
|
|
31
|
+
_ref3$query = _ref3.query,
|
|
32
|
+
query = _ref3$query === undefined ? {} : _ref3$query,
|
|
33
|
+
headers = _ref3.headers;
|
|
34
|
+
|
|
35
|
+
// eslint-disable-next-line no-param-reassign
|
|
36
|
+
query.onlyValidateRequest = true;
|
|
37
|
+
return client({
|
|
38
|
+
url: "/infile-json",
|
|
39
|
+
method: "post",
|
|
40
|
+
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers }),
|
|
41
|
+
params: query,
|
|
42
|
+
data: data
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
create: create,
|
|
48
|
+
validateCreate: validateCreate
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
module.exports = infileJsonFactory;
|
|
@@ -19,6 +19,18 @@ var _require = require("./../endpoints_helpers.js"),
|
|
|
19
19
|
* reason: string
|
|
20
20
|
* }
|
|
21
21
|
* }} CancelSetData
|
|
22
|
+
*
|
|
23
|
+
* @typedef {{
|
|
24
|
+
* provider: string,
|
|
25
|
+
* type: string,
|
|
26
|
+
* result: object,
|
|
27
|
+
* createdAt: object,
|
|
28
|
+
* displayName: string,
|
|
29
|
+
* status: string,
|
|
30
|
+
* amount: number,
|
|
31
|
+
* referenceNumber: string,
|
|
32
|
+
* authCode?: string
|
|
33
|
+
* }} CompletePaymentCancellationData
|
|
22
34
|
*/
|
|
23
35
|
|
|
24
36
|
function cancellationEndpointsFactory(_ref) {
|
|
@@ -73,13 +85,39 @@ function cancellationEndpointsFactory(_ref) {
|
|
|
73
85
|
});
|
|
74
86
|
}
|
|
75
87
|
|
|
88
|
+
/**
|
|
89
|
+
* Completes a pending payment for a cancellation transaction (e.g. one terminal refund).
|
|
90
|
+
* @param {Object} params
|
|
91
|
+
* @param {string} params.token Public key
|
|
92
|
+
* @param {string} params.jwtToken Auth token
|
|
93
|
+
* @param {string} params.pendingTransactionId Negative transaction id (ObjectId)
|
|
94
|
+
* @param {CompletePaymentCancellationData} params.paymentResult Payment result for one completed terminal refund
|
|
95
|
+
* @param {Object} params.headers HTTP Headers
|
|
96
|
+
* @returns {Promise} Updated negative transaction (with remaining pending payments if any)
|
|
97
|
+
*/
|
|
98
|
+
function updateCompletePayment(_ref4) {
|
|
99
|
+
var token = _ref4.token,
|
|
100
|
+
jwtToken = _ref4.jwtToken,
|
|
101
|
+
pendingTransactionId = _ref4.pendingTransactionId,
|
|
102
|
+
paymentResult = _ref4.paymentResult,
|
|
103
|
+
headers = _ref4.headers;
|
|
104
|
+
|
|
105
|
+
return client({
|
|
106
|
+
url: "/cancellations/" + pendingTransactionId,
|
|
107
|
+
method: "PUT",
|
|
108
|
+
data: { paymentResult: paymentResult },
|
|
109
|
+
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers })
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
76
113
|
return {
|
|
77
114
|
sets: {
|
|
78
115
|
create: createCancelSet
|
|
79
116
|
},
|
|
80
117
|
refunds: {
|
|
81
118
|
create: createRefund
|
|
82
|
-
}
|
|
119
|
+
},
|
|
120
|
+
update: updateCompletePayment
|
|
83
121
|
};
|
|
84
122
|
}
|
|
85
123
|
|
package/package.json
CHANGED
package/src/client.js
CHANGED
|
@@ -393,6 +393,7 @@ function createInvoices({baseURL, headers, timeout, overrideFn, internalAuthToke
|
|
|
393
393
|
providers: require("./endpoints/invoices/providers.js")({client, internalAuthTokenProvider}),
|
|
394
394
|
providersSequences: require("./endpoints/invoices/providersSequences.js")({client, internalAuthTokenProvider}),
|
|
395
395
|
infile: require("./endpoints/invoices/infile.js")({client, internalAuthTokenProvider}),
|
|
396
|
+
infileJson: require("./endpoints/invoices/infileJson.js")({client, internalAuthTokenProvider}),
|
|
396
397
|
system: require("./endpoints/invoices/system.js")({client, internalAuthTokenProvider}),
|
|
397
398
|
dlink: require("./endpoints/invoices/dlink.js")({client, internalAuthTokenProvider}),
|
|
398
399
|
gti: require("./endpoints/invoices/gti.js")({client, internalAuthTokenProvider}),
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const {authorizationHeaders} = require("./../endpoints_helpers");
|
|
2
|
+
|
|
3
|
+
function infileJsonFactory({client, internalAuthTokenProvider}) {
|
|
4
|
+
function create({token, jwtToken, data, query = {}, headers}) {
|
|
5
|
+
return client({
|
|
6
|
+
url: "/infile-json",
|
|
7
|
+
method: "post",
|
|
8
|
+
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
|
|
9
|
+
params: query,
|
|
10
|
+
data
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function validateCreate({token, jwtToken, data, query = {}, headers}) {
|
|
15
|
+
// eslint-disable-next-line no-param-reassign
|
|
16
|
+
query.onlyValidateRequest = true;
|
|
17
|
+
return client({
|
|
18
|
+
url: "/infile-json",
|
|
19
|
+
method: "post",
|
|
20
|
+
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
|
|
21
|
+
params: query,
|
|
22
|
+
data
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
create,
|
|
28
|
+
validateCreate
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
module.exports = infileJsonFactory;
|
|
@@ -16,6 +16,18 @@ const {authorizationHeaders} = require("./../endpoints_helpers.js");
|
|
|
16
16
|
* reason: string
|
|
17
17
|
* }
|
|
18
18
|
* }} CancelSetData
|
|
19
|
+
*
|
|
20
|
+
* @typedef {{
|
|
21
|
+
* provider: string,
|
|
22
|
+
* type: string,
|
|
23
|
+
* result: object,
|
|
24
|
+
* createdAt: object,
|
|
25
|
+
* displayName: string,
|
|
26
|
+
* status: string,
|
|
27
|
+
* amount: number,
|
|
28
|
+
* referenceNumber: string,
|
|
29
|
+
* authCode?: string
|
|
30
|
+
* }} CompletePaymentCancellationData
|
|
19
31
|
*/
|
|
20
32
|
|
|
21
33
|
function cancellationEndpointsFactory({client, internalAuthTokenProvider}) {
|
|
@@ -57,13 +69,33 @@ function cancellationEndpointsFactory({client, internalAuthTokenProvider}) {
|
|
|
57
69
|
});
|
|
58
70
|
}
|
|
59
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Completes a pending payment for a cancellation transaction (e.g. one terminal refund).
|
|
74
|
+
* @param {Object} params
|
|
75
|
+
* @param {string} params.token Public key
|
|
76
|
+
* @param {string} params.jwtToken Auth token
|
|
77
|
+
* @param {string} params.pendingTransactionId Negative transaction id (ObjectId)
|
|
78
|
+
* @param {CompletePaymentCancellationData} params.paymentResult Payment result for one completed terminal refund
|
|
79
|
+
* @param {Object} params.headers HTTP Headers
|
|
80
|
+
* @returns {Promise} Updated negative transaction (with remaining pending payments if any)
|
|
81
|
+
*/
|
|
82
|
+
function updateCompletePayment({token, jwtToken, pendingTransactionId, paymentResult, headers}) {
|
|
83
|
+
return client({
|
|
84
|
+
url: `/cancellations/${pendingTransactionId}`,
|
|
85
|
+
method: "PUT",
|
|
86
|
+
data: {paymentResult},
|
|
87
|
+
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
60
91
|
return {
|
|
61
92
|
sets: {
|
|
62
93
|
create: createCancelSet
|
|
63
94
|
},
|
|
64
95
|
refunds: {
|
|
65
96
|
create: createRefund
|
|
66
|
-
}
|
|
97
|
+
},
|
|
98
|
+
update: updateCompletePayment
|
|
67
99
|
};
|
|
68
100
|
}
|
|
69
101
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const {axiosMock, expectRequest} = require("./../../test-helpers");
|
|
2
|
+
const api = require("./../../../src/client").createApiClient({baseURL: "http://test.com"});
|
|
3
|
+
|
|
4
|
+
describe("invoices/infileJson", () => {
|
|
5
|
+
const token = "I owe you a token";
|
|
6
|
+
const jwtToken = "I owe you a JWT token";
|
|
7
|
+
|
|
8
|
+
afterEach(() => {
|
|
9
|
+
axiosMock.restore();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("should create an infileJson invoice", () => {
|
|
13
|
+
axiosMock.onPost("/infile-json").reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
14
|
+
return api.invoices.infileJson.create({
|
|
15
|
+
jwtToken,
|
|
16
|
+
token,
|
|
17
|
+
data: {
|
|
18
|
+
transactionId: "trx1",
|
|
19
|
+
invoiceProviderId: "provider1",
|
|
20
|
+
invoiceInfo: {buyer: {type: "AFC", name: ""}}
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("should validate the payload for create an infileJson invoice", () => {
|
|
26
|
+
axiosMock.onPost("/infile-json?onlyValidateRequest=true").reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
27
|
+
return api.invoices.infileJson.validateCreate({
|
|
28
|
+
jwtToken,
|
|
29
|
+
token,
|
|
30
|
+
data: {}
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -47,4 +47,32 @@ describe("sales/cancellations", () => {
|
|
|
47
47
|
headers: {}
|
|
48
48
|
});
|
|
49
49
|
});
|
|
50
|
+
|
|
51
|
+
it("should PUT to update (complete) a pending payment for a cancellation transaction", () => {
|
|
52
|
+
const pendingTransactionId = "507f1f77bcf86cd799439011";
|
|
53
|
+
const paymentResult = {
|
|
54
|
+
provider: "prisma",
|
|
55
|
+
type: "prisma_terminal",
|
|
56
|
+
referenceNumber: "ref1",
|
|
57
|
+
result: {id: "1", paymentStatus: "CONFIRMED"},
|
|
58
|
+
createdAt: {},
|
|
59
|
+
displayName: "Prisma Terminal",
|
|
60
|
+
status: "refunded",
|
|
61
|
+
amount: 10.5
|
|
62
|
+
};
|
|
63
|
+
axiosMock.onPut(`/cancellations/${pendingTransactionId}`).reply(expectRequest({
|
|
64
|
+
statusCode: 200,
|
|
65
|
+
token,
|
|
66
|
+
jwtToken,
|
|
67
|
+
body: {paymentResult}
|
|
68
|
+
}));
|
|
69
|
+
|
|
70
|
+
return api.sales.cancellations.update({
|
|
71
|
+
token,
|
|
72
|
+
jwtToken,
|
|
73
|
+
pendingTransactionId,
|
|
74
|
+
paymentResult,
|
|
75
|
+
headers: {}
|
|
76
|
+
});
|
|
77
|
+
});
|
|
50
78
|
});
|
package/types/client.d.ts
CHANGED
|
@@ -3789,6 +3789,13 @@ export function createApiClient(options: {
|
|
|
3789
3789
|
headers: any;
|
|
3790
3790
|
}) => Promise<any>;
|
|
3791
3791
|
};
|
|
3792
|
+
update: ({ token, jwtToken, pendingTransactionId, paymentResult, headers }: {
|
|
3793
|
+
token: string;
|
|
3794
|
+
jwtToken: string;
|
|
3795
|
+
pendingTransactionId: string;
|
|
3796
|
+
paymentResult: CompletePaymentCancellationData;
|
|
3797
|
+
headers: any;
|
|
3798
|
+
}) => Promise<any>;
|
|
3792
3799
|
};
|
|
3793
3800
|
__test: {
|
|
3794
3801
|
client: axios.AxiosInstance;
|
|
@@ -5523,6 +5530,22 @@ export function createApiClient(options: {
|
|
|
5523
5530
|
headers: any;
|
|
5524
5531
|
}) => any;
|
|
5525
5532
|
};
|
|
5533
|
+
infileJson: {
|
|
5534
|
+
create: ({ token, jwtToken, data, query, headers }: {
|
|
5535
|
+
token: any;
|
|
5536
|
+
jwtToken: any;
|
|
5537
|
+
data: any;
|
|
5538
|
+
query?: {};
|
|
5539
|
+
headers: any;
|
|
5540
|
+
}) => any;
|
|
5541
|
+
validateCreate: ({ token, jwtToken, data, query, headers }: {
|
|
5542
|
+
token: any;
|
|
5543
|
+
jwtToken: any;
|
|
5544
|
+
data: any;
|
|
5545
|
+
query?: {};
|
|
5546
|
+
headers: any;
|
|
5547
|
+
}) => any;
|
|
5548
|
+
};
|
|
5526
5549
|
system: {
|
|
5527
5550
|
create: ({ token, jwtToken, data, query, headers }: {
|
|
5528
5551
|
token: any;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export = infileJsonFactory;
|
|
2
|
+
declare function infileJsonFactory({ client, internalAuthTokenProvider }: {
|
|
3
|
+
client: any;
|
|
4
|
+
internalAuthTokenProvider: any;
|
|
5
|
+
}): {
|
|
6
|
+
create: ({ token, jwtToken, data, query, headers }: {
|
|
7
|
+
token: any;
|
|
8
|
+
jwtToken: any;
|
|
9
|
+
data: any;
|
|
10
|
+
query?: {};
|
|
11
|
+
headers: any;
|
|
12
|
+
}) => any;
|
|
13
|
+
validateCreate: ({ token, jwtToken, data, query, headers }: {
|
|
14
|
+
token: any;
|
|
15
|
+
jwtToken: any;
|
|
16
|
+
data: any;
|
|
17
|
+
query?: {};
|
|
18
|
+
headers: any;
|
|
19
|
+
}) => any;
|
|
20
|
+
};
|
|
@@ -15,6 +15,18 @@ export = cancellationEndpointsFactory;
|
|
|
15
15
|
* reason: string
|
|
16
16
|
* }
|
|
17
17
|
* }} CancelSetData
|
|
18
|
+
*
|
|
19
|
+
* @typedef {{
|
|
20
|
+
* provider: string,
|
|
21
|
+
* type: string,
|
|
22
|
+
* result: object,
|
|
23
|
+
* createdAt: object,
|
|
24
|
+
* displayName: string,
|
|
25
|
+
* status: string,
|
|
26
|
+
* amount: number,
|
|
27
|
+
* referenceNumber: string,
|
|
28
|
+
* authCode?: string
|
|
29
|
+
* }} CompletePaymentCancellationData
|
|
18
30
|
*/
|
|
19
31
|
declare function cancellationEndpointsFactory({ client, internalAuthTokenProvider }: {
|
|
20
32
|
client: any;
|
|
@@ -36,9 +48,16 @@ declare function cancellationEndpointsFactory({ client, internalAuthTokenProvide
|
|
|
36
48
|
headers: any;
|
|
37
49
|
}) => Promise<any>;
|
|
38
50
|
};
|
|
51
|
+
update: ({ token, jwtToken, pendingTransactionId, paymentResult, headers }: {
|
|
52
|
+
token: string;
|
|
53
|
+
jwtToken: string;
|
|
54
|
+
pendingTransactionId: string;
|
|
55
|
+
paymentResult: CompletePaymentCancellationData;
|
|
56
|
+
headers: any;
|
|
57
|
+
}) => Promise<any>;
|
|
39
58
|
};
|
|
40
59
|
declare namespace cancellationEndpointsFactory {
|
|
41
|
-
export { CancelSetData };
|
|
60
|
+
export { CancelSetData, CompletePaymentCancellationData };
|
|
42
61
|
}
|
|
43
62
|
type CancelSetData = {
|
|
44
63
|
fees: string[];
|
|
@@ -55,3 +74,14 @@ type CancelSetData = {
|
|
|
55
74
|
reason: string;
|
|
56
75
|
};
|
|
57
76
|
};
|
|
77
|
+
type CompletePaymentCancellationData = {
|
|
78
|
+
provider: string;
|
|
79
|
+
type: string;
|
|
80
|
+
result: object;
|
|
81
|
+
createdAt: object;
|
|
82
|
+
displayName: string;
|
|
83
|
+
status: string;
|
|
84
|
+
amount: number;
|
|
85
|
+
referenceNumber: string;
|
|
86
|
+
authCode?: string;
|
|
87
|
+
};
|
|
@@ -3743,6 +3743,13 @@ declare const _exports: {
|
|
|
3743
3743
|
headers: any;
|
|
3744
3744
|
}) => Promise<any>;
|
|
3745
3745
|
};
|
|
3746
|
+
update: ({ token, jwtToken, pendingTransactionId, paymentResult, headers }: {
|
|
3747
|
+
token: string;
|
|
3748
|
+
jwtToken: string;
|
|
3749
|
+
pendingTransactionId: string;
|
|
3750
|
+
paymentResult: CompletePaymentCancellationData;
|
|
3751
|
+
headers: any;
|
|
3752
|
+
}) => Promise<any>;
|
|
3746
3753
|
};
|
|
3747
3754
|
__test: {
|
|
3748
3755
|
client: import("axios").AxiosInstance;
|
|
@@ -5477,6 +5484,22 @@ declare const _exports: {
|
|
|
5477
5484
|
headers: any;
|
|
5478
5485
|
}) => any;
|
|
5479
5486
|
};
|
|
5487
|
+
infileJson: {
|
|
5488
|
+
create: ({ token, jwtToken, data, query, headers }: {
|
|
5489
|
+
token: any;
|
|
5490
|
+
jwtToken: any;
|
|
5491
|
+
data: any;
|
|
5492
|
+
query?: {};
|
|
5493
|
+
headers: any;
|
|
5494
|
+
}) => any;
|
|
5495
|
+
validateCreate: ({ token, jwtToken, data, query, headers }: {
|
|
5496
|
+
token: any;
|
|
5497
|
+
jwtToken: any;
|
|
5498
|
+
data: any;
|
|
5499
|
+
query?: {};
|
|
5500
|
+
headers: any;
|
|
5501
|
+
}) => any;
|
|
5502
|
+
};
|
|
5480
5503
|
system: {
|
|
5481
5504
|
create: ({ token, jwtToken, data, query, headers }: {
|
|
5482
5505
|
token: any;
|