btrz-api-client 8.25.0 → 8.27.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 +1 -1
- package/lib/endpoints/btrzpay/prismaTerminals.js +46 -29
- package/lib/endpoints/sales/cancellations.js +39 -1
- package/package.json +1 -1
- package/src/endpoints/btrzpay/prismaTerminals.js +9 -0
- package/src/endpoints/sales/cancellations.js +33 -1
- package/test/endpoints/btrzpay/prismaTerminals.tests.js +18 -0
- package/test/endpoints/sales/cancellations.test.js +28 -0
- package/types/client.d.ts +15 -0
- package/types/endpoints/btrzpay/prismaTerminals.d.ts +8 -0
- package/types/endpoints/sales/cancellations.d.ts +31 -1
- package/types/initializedClient.d.ts +15 -0
|
@@ -100,63 +100,80 @@ function prismaTerminalsFactory(_ref) {
|
|
|
100
100
|
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers }),
|
|
101
101
|
params: query
|
|
102
102
|
});
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
var payments = {
|
|
107
|
-
get: function get(_ref8) {
|
|
103
|
+
},
|
|
104
|
+
update: function update(_ref8) {
|
|
108
105
|
var token = _ref8.token,
|
|
109
106
|
jwtToken = _ref8.jwtToken,
|
|
110
107
|
id = _ref8.id,
|
|
108
|
+
prismaRefund = _ref8.prismaRefund,
|
|
111
109
|
_ref8$query = _ref8.query,
|
|
112
110
|
query = _ref8$query === undefined ? {} : _ref8$query,
|
|
113
111
|
headers = _ref8.headers;
|
|
114
112
|
|
|
115
|
-
return client
|
|
113
|
+
return client({
|
|
114
|
+
url: "/prisma-terminals/refunds/" + id,
|
|
115
|
+
method: "put",
|
|
116
|
+
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers }),
|
|
116
117
|
params: query,
|
|
117
|
-
|
|
118
|
+
data: { prismaRefund: prismaRefund }
|
|
118
119
|
});
|
|
119
|
-
}
|
|
120
|
-
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
var payments = {
|
|
124
|
+
get: function get(_ref9) {
|
|
121
125
|
var token = _ref9.token,
|
|
122
126
|
jwtToken = _ref9.jwtToken,
|
|
123
|
-
|
|
127
|
+
id = _ref9.id,
|
|
124
128
|
_ref9$query = _ref9.query,
|
|
125
129
|
query = _ref9$query === undefined ? {} : _ref9$query,
|
|
126
130
|
headers = _ref9.headers;
|
|
127
131
|
|
|
128
|
-
return client({
|
|
129
|
-
url: "/prisma-terminals/payments",
|
|
130
|
-
method: "post",
|
|
131
|
-
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers }),
|
|
132
|
+
return client.get("/prisma-terminals/payments/" + id, {
|
|
132
133
|
params: query,
|
|
133
|
-
|
|
134
|
+
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers })
|
|
134
135
|
});
|
|
135
136
|
},
|
|
136
|
-
|
|
137
|
+
create: function create(_ref10) {
|
|
137
138
|
var token = _ref10.token,
|
|
138
139
|
jwtToken = _ref10.jwtToken,
|
|
139
|
-
|
|
140
|
+
prismaPayment = _ref10.prismaPayment,
|
|
140
141
|
_ref10$query = _ref10.query,
|
|
141
142
|
query = _ref10$query === undefined ? {} : _ref10$query,
|
|
142
143
|
headers = _ref10.headers;
|
|
143
144
|
|
|
144
145
|
return client({
|
|
145
|
-
url: "/prisma-terminals/payments
|
|
146
|
-
method: "
|
|
146
|
+
url: "/prisma-terminals/payments",
|
|
147
|
+
method: "post",
|
|
147
148
|
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers }),
|
|
148
|
-
params: query
|
|
149
|
+
params: query,
|
|
150
|
+
data: { prismaPayment: prismaPayment }
|
|
149
151
|
});
|
|
150
152
|
},
|
|
151
|
-
|
|
153
|
+
delete: function _delete(_ref11) {
|
|
152
154
|
var token = _ref11.token,
|
|
153
155
|
jwtToken = _ref11.jwtToken,
|
|
154
156
|
id = _ref11.id,
|
|
155
|
-
prismaPayment = _ref11.prismaPayment,
|
|
156
157
|
_ref11$query = _ref11.query,
|
|
157
158
|
query = _ref11$query === undefined ? {} : _ref11$query,
|
|
158
159
|
headers = _ref11.headers;
|
|
159
160
|
|
|
161
|
+
return client({
|
|
162
|
+
url: "/prisma-terminals/payments/" + id,
|
|
163
|
+
method: "delete",
|
|
164
|
+
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers }),
|
|
165
|
+
params: query
|
|
166
|
+
});
|
|
167
|
+
},
|
|
168
|
+
update: function update(_ref12) {
|
|
169
|
+
var token = _ref12.token,
|
|
170
|
+
jwtToken = _ref12.jwtToken,
|
|
171
|
+
id = _ref12.id,
|
|
172
|
+
prismaPayment = _ref12.prismaPayment,
|
|
173
|
+
_ref12$query = _ref12.query,
|
|
174
|
+
query = _ref12$query === undefined ? {} : _ref12$query,
|
|
175
|
+
headers = _ref12.headers;
|
|
176
|
+
|
|
160
177
|
return client({
|
|
161
178
|
url: "/prisma-terminals/payments/" + id,
|
|
162
179
|
method: "put",
|
|
@@ -171,13 +188,13 @@ function prismaTerminalsFactory(_ref) {
|
|
|
171
188
|
};
|
|
172
189
|
|
|
173
190
|
var settlements = {
|
|
174
|
-
create: function create(
|
|
175
|
-
var token =
|
|
176
|
-
jwtToken =
|
|
177
|
-
settlement =
|
|
178
|
-
|
|
179
|
-
query =
|
|
180
|
-
headers =
|
|
191
|
+
create: function create(_ref13) {
|
|
192
|
+
var token = _ref13.token,
|
|
193
|
+
jwtToken = _ref13.jwtToken,
|
|
194
|
+
settlement = _ref13.settlement,
|
|
195
|
+
_ref13$query = _ref13.query,
|
|
196
|
+
query = _ref13$query === undefined ? {} : _ref13$query,
|
|
197
|
+
headers = _ref13.headers;
|
|
181
198
|
|
|
182
199
|
return client({
|
|
183
200
|
url: "/prisma-terminals/settlements",
|
|
@@ -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
|
@@ -52,6 +52,15 @@ function prismaTerminalsFactory({client, internalAuthTokenProvider}) {
|
|
|
52
52
|
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
|
|
53
53
|
params: query
|
|
54
54
|
});
|
|
55
|
+
},
|
|
56
|
+
update({token, jwtToken, id, prismaRefund, query = {}, headers}) {
|
|
57
|
+
return client({
|
|
58
|
+
url: `/prisma-terminals/refunds/${id}`,
|
|
59
|
+
method: "put",
|
|
60
|
+
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
|
|
61
|
+
params: query,
|
|
62
|
+
data: {prismaRefund}
|
|
63
|
+
});
|
|
55
64
|
}
|
|
56
65
|
};
|
|
57
66
|
|
|
@@ -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
|
|
|
@@ -152,6 +152,24 @@ describe("btrzpay/prisma-terminals", () => {
|
|
|
152
152
|
});
|
|
153
153
|
});
|
|
154
154
|
|
|
155
|
+
it("should update a prisma terminal refund (complete pending payment)", () => {
|
|
156
|
+
const prismaRefund = {
|
|
157
|
+
result: {id: "refund-uuid", refundStatus: "CONFIRMED"},
|
|
158
|
+
pendingTransactionId: "6870086aa339562f5c6bd4fe",
|
|
159
|
+
referenceNumber: "ref-123"
|
|
160
|
+
};
|
|
161
|
+
axiosMock.onPut("/prisma-terminals/refunds/refund-uuid").reply(expectRequest({
|
|
162
|
+
statusCode: 200, token, jwtToken, query, body: {prismaRefund}
|
|
163
|
+
}));
|
|
164
|
+
return api.btrzpay.prismaTerminals.payments.refunds.update({
|
|
165
|
+
token,
|
|
166
|
+
jwtToken,
|
|
167
|
+
query,
|
|
168
|
+
id: "refund-uuid",
|
|
169
|
+
prismaRefund
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
|
|
155
173
|
it("should create a prisma terminal settlement intent", () => {
|
|
156
174
|
axiosMock.onPost("/prisma-terminals/settlements").reply(expectRequest({
|
|
157
175
|
statusCode: 200, token, jwtToken, query
|
|
@@ -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;
|
|
@@ -5356,6 +5363,14 @@ export function createApiClient(options: {
|
|
|
5356
5363
|
query?: {};
|
|
5357
5364
|
headers: any;
|
|
5358
5365
|
}): any;
|
|
5366
|
+
update({ token, jwtToken, id, prismaRefund, query, headers }: {
|
|
5367
|
+
token: any;
|
|
5368
|
+
jwtToken: any;
|
|
5369
|
+
id: any;
|
|
5370
|
+
prismaRefund: any;
|
|
5371
|
+
query?: {};
|
|
5372
|
+
headers: any;
|
|
5373
|
+
}): any;
|
|
5359
5374
|
};
|
|
5360
5375
|
};
|
|
5361
5376
|
settlements: {
|
|
@@ -80,6 +80,14 @@ declare function prismaTerminalsFactory({ client, internalAuthTokenProvider }: {
|
|
|
80
80
|
query?: {};
|
|
81
81
|
headers: any;
|
|
82
82
|
}): any;
|
|
83
|
+
update({ token, jwtToken, id, prismaRefund, query, headers }: {
|
|
84
|
+
token: any;
|
|
85
|
+
jwtToken: any;
|
|
86
|
+
id: any;
|
|
87
|
+
prismaRefund: any;
|
|
88
|
+
query?: {};
|
|
89
|
+
headers: any;
|
|
90
|
+
}): any;
|
|
83
91
|
};
|
|
84
92
|
};
|
|
85
93
|
settlements: {
|
|
@@ -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;
|
|
@@ -5310,6 +5317,14 @@ declare const _exports: {
|
|
|
5310
5317
|
query?: {};
|
|
5311
5318
|
headers: any;
|
|
5312
5319
|
}): any;
|
|
5320
|
+
update({ token, jwtToken, id, prismaRefund, query, headers }: {
|
|
5321
|
+
token: any;
|
|
5322
|
+
jwtToken: any;
|
|
5323
|
+
id: any;
|
|
5324
|
+
prismaRefund: any;
|
|
5325
|
+
query?: {};
|
|
5326
|
+
headers: any;
|
|
5327
|
+
}): any;
|
|
5313
5328
|
};
|
|
5314
5329
|
};
|
|
5315
5330
|
settlements: {
|