btrz-api-client 8.33.0 → 8.34.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 +6 -2
- package/lib/endpoints/btrzpay/adyen.js +58 -0
- package/lib/endpoints/btrzpay/cardpointe.js +6 -3
- package/lib/endpoints/btrzpay/customerCards.js +19 -19
- package/lib/endpoints/btrzpay/customers.js +13 -13
- package/lib/endpoints/btrzpay/cybersource3ds.js +142 -0
- package/lib/endpoints/btrzpay/datalogic.js +64 -28
- package/lib/endpoints/btrzpay/oxxo.js +54 -28
- package/lib/endpoints/btrzpay/prismaTerminals.js +24 -15
- package/lib/endpoints/btrzpay/referenced-payments.js +4 -4
- package/lib/endpoints/btrzpay/square.js +8 -8
- package/lib/endpoints/btrzpay/stripe-terminals.js +16 -11
- package/lib/endpoints/btrzpay/stripe3ds.js +54 -0
- package/lib/endpoints/btrzpay/terminalPayments.js +19 -19
- package/lib/endpoints/inventory/segments-information-tables.js +13 -7
- package/lib/endpoints/inventory/trip-ids.js +67 -0
- package/lib/endpoints/inventory/trips.js +60 -13
- package/lib/endpoints/invoices/emails.js +15 -5
- package/lib/endpoints/invoices/invoices.js +46 -25
- package/lib/endpoints/invoices/pdfs.js +15 -8
- package/lib/endpoints/invoices/providers.js +42 -25
- package/lib/endpoints/invoices/tax-ids.js +11 -7
- package/lib/endpoints/sales/cancellations.js +43 -31
- package/lib/endpoints/sales/cart.js +21 -18
- package/lib/endpoints/sales/flexpasses.js +2 -5
- package/lib/endpoints/sales/order.js +41 -7
- package/lib/endpoints/sales/parcel-quotes.js +2 -2
- package/package.json +1 -1
- package/src/client.js +6 -2
- package/src/endpoints/btrzpay/adyen.js +44 -0
- package/src/endpoints/btrzpay/cardpointe.js +6 -4
- package/src/endpoints/btrzpay/customerCards.js +19 -19
- package/src/endpoints/btrzpay/customers.js +13 -13
- package/src/endpoints/btrzpay/cybersource3ds.js +114 -0
- package/src/endpoints/btrzpay/datalogic.js +63 -28
- package/src/endpoints/btrzpay/oxxo.js +53 -26
- package/src/endpoints/btrzpay/prismaTerminals.js +24 -15
- package/src/endpoints/btrzpay/referenced-payments.js +4 -4
- package/src/endpoints/btrzpay/square.js +8 -8
- package/src/endpoints/btrzpay/stripe-terminals.js +17 -10
- package/src/endpoints/btrzpay/stripe3ds.js +40 -0
- package/src/endpoints/btrzpay/terminalPayments.js +19 -19
- package/src/endpoints/inventory/segments-information-tables.js +13 -7
- package/src/endpoints/inventory/trip-ids.js +54 -0
- package/src/endpoints/inventory/trips.js +52 -14
- package/src/endpoints/invoices/emails.js +15 -5
- package/src/endpoints/invoices/invoices.js +46 -25
- package/src/endpoints/invoices/pdfs.js +15 -8
- package/src/endpoints/invoices/providers.js +42 -25
- package/src/endpoints/invoices/tax-ids.js +11 -7
- package/src/endpoints/sales/cancellations.js +43 -31
- package/src/endpoints/sales/cart.js +20 -18
- package/src/endpoints/sales/flexpasses.js +3 -4
- package/src/endpoints/sales/order.js +34 -7
- package/src/endpoints/sales/parcel-quotes.js +2 -2
- package/test/endpoints/btrzpay/adyen.tests.js +27 -0
- package/test/endpoints/btrzpay/carpointe.tests.js +14 -0
- package/test/endpoints/btrzpay/customerCards.test.js +9 -6
- package/test/endpoints/btrzpay/cybersource3ds.tests.js +55 -0
- package/test/endpoints/btrzpay/stripe-terminals.tests.js +5 -6
- package/test/endpoints/btrzpay/stripe3ds.tests.js +31 -0
- package/test/endpoints/inventory/trip-ids.test.js +27 -0
- package/test/endpoints/inventory/trips.test.js +19 -14
- package/test/endpoints/sales/order.test.js +7 -1
|
@@ -23,6 +23,13 @@ var _require = require("./../endpoints_helpers.js"),
|
|
|
23
23
|
* @property {string} [internalId] - Internal id or code of the financing cost to match
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Query params for DELETE /carts/:cartId/paid-in-items (btrz-api-sales delete-cart-paid-in-items-handler getSpec).
|
|
28
|
+
* @typedef {Object} CartDeletePaidInItemsQuery
|
|
29
|
+
* @property {string} [operationId] - Optional operation id to filter which paid-in items to remove
|
|
30
|
+
* @property {string} [productId] - Optional product id to filter which paid-in items to remove
|
|
31
|
+
*/
|
|
32
|
+
|
|
26
33
|
/**
|
|
27
34
|
* Factory for cart API (btrz-api-sales).
|
|
28
35
|
* @param {Object} deps
|
|
@@ -37,28 +44,24 @@ function cartFactory(_ref) {
|
|
|
37
44
|
internalAuthTokenProvider = _ref.internalAuthTokenProvider;
|
|
38
45
|
|
|
39
46
|
/**
|
|
40
|
-
* GET /cart/:id - get cart by id.
|
|
47
|
+
* GET /cart/:id - get cart by id.
|
|
41
48
|
* @param {Object} opts
|
|
42
49
|
* @param {string} [opts.token] - API key
|
|
43
50
|
* @param {string} opts.id - Cart id
|
|
44
|
-
* @param {
|
|
51
|
+
* @param {CartGetQuery} [opts.query] - Query params (providerId, transactionStatus)
|
|
45
52
|
* @param {Object} [opts.headers] - Optional headers
|
|
46
53
|
* @returns {Promise<import("axios").AxiosResponse>}
|
|
47
54
|
*/
|
|
48
55
|
function get(_ref2) {
|
|
49
56
|
var token = _ref2.token,
|
|
50
57
|
id = _ref2.id,
|
|
51
|
-
|
|
58
|
+
_ref2$query = _ref2.query,
|
|
59
|
+
query = _ref2$query === undefined ? {} : _ref2$query,
|
|
52
60
|
headers = _ref2.headers;
|
|
53
61
|
|
|
54
|
-
var url = "/cart/" + id;
|
|
55
|
-
|
|
56
|
-
if (providerId) {
|
|
57
|
-
url = url + "?providerId=" + providerId;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
62
|
return client({
|
|
61
|
-
url:
|
|
63
|
+
url: "/cart/" + id,
|
|
64
|
+
params: query,
|
|
62
65
|
headers: authorizationHeaders({ token: token, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers })
|
|
63
66
|
});
|
|
64
67
|
}
|
|
@@ -161,11 +164,11 @@ function cartFactory(_ref) {
|
|
|
161
164
|
}
|
|
162
165
|
|
|
163
166
|
/**
|
|
164
|
-
* DELETE /carts/:cartId/paid-in-items - delete paid-in items.
|
|
167
|
+
* DELETE /carts/:cartId/paid-in-items - delete paid-in items.
|
|
165
168
|
* @param {Object} opts
|
|
166
169
|
* @param {string} [opts.token] - API key
|
|
167
170
|
* @param {string} opts.cartId - Cart id
|
|
168
|
-
* @param {
|
|
171
|
+
* @param {CartDeletePaidInItemsQuery} [opts.params] - Query params (operationId, productId)
|
|
169
172
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
170
173
|
* @param {Object} [opts.headers] - Optional headers
|
|
171
174
|
* @returns {Promise<import("axios").AxiosResponse>}
|
|
@@ -181,7 +184,7 @@ function cartFactory(_ref) {
|
|
|
181
184
|
url: "/carts/" + cartId + "/paid-in-items",
|
|
182
185
|
method: "delete",
|
|
183
186
|
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers }),
|
|
184
|
-
params: params
|
|
187
|
+
params: params || {}
|
|
185
188
|
});
|
|
186
189
|
}
|
|
187
190
|
|
|
@@ -238,13 +241,13 @@ function cartFactory(_ref) {
|
|
|
238
241
|
|
|
239
242
|
var partialDepositStatus = {
|
|
240
243
|
/**
|
|
241
|
-
* GET /cart/:shiftId/partial-deposit-status - get partial deposit status. API does not accept query params.
|
|
244
|
+
* GET /cart/:shiftId/partial-deposit-status - get shift partial deposit status. API does not accept query params. Response: partialDeposit.
|
|
242
245
|
* @param {Object} opts
|
|
243
246
|
* @param {string} [opts.token] - API key
|
|
244
247
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
245
|
-
* @param {string} opts.shiftId - Shift id
|
|
248
|
+
* @param {string} opts.shiftId - Shift id (24 hex characters)
|
|
246
249
|
* @param {Object} [opts.headers] - Optional headers
|
|
247
|
-
* @returns {Promise<import("axios").AxiosResponse
|
|
250
|
+
* @returns {Promise<import("axios").AxiosResponse<{ partialDeposit: * }>>}
|
|
248
251
|
*/
|
|
249
252
|
get: function get(_ref10) {
|
|
250
253
|
var token = _ref10.token,
|
|
@@ -309,13 +312,13 @@ function cartFactory(_ref) {
|
|
|
309
312
|
|
|
310
313
|
var taxExemptPaymentMethod = {
|
|
311
314
|
/**
|
|
312
|
-
* POST /carts/:cartId/tax-exempt-payment-method -
|
|
315
|
+
* POST /carts/:cartId/tax-exempt-payment-method - recalculate taxes for a tax exempt payment method. Body: amountExempt (number).
|
|
313
316
|
* @param {Object} opts
|
|
314
317
|
* @param {string} [opts.token] - API key
|
|
315
318
|
* @param {string} opts.cartId - Cart id
|
|
316
319
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
317
320
|
* @param {Object} [opts.headers] - Optional headers
|
|
318
|
-
* @param {Object}
|
|
321
|
+
* @param {Object} opts.data - Request body; must include amountExempt (number, amount exempted of taxes)
|
|
319
322
|
* @returns {Promise<import("axios").AxiosResponse>}
|
|
320
323
|
*/
|
|
321
324
|
post: function post(_ref13) {
|
|
@@ -18,11 +18,11 @@ function flexpassesEndpointsFactory(_ref) {
|
|
|
18
18
|
internalAuthTokenProvider = _ref.internalAuthTokenProvider;
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
* GET /flexpasses/:flexpassId - get flexpass by id. API does not accept query params
|
|
21
|
+
* GET /flexpasses/:flexpassId - get flexpass by id. API does not accept query params.
|
|
22
22
|
* @param {Object} opts
|
|
23
23
|
* @param {string} [opts.token] - API key
|
|
24
24
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
25
|
-
* @param {string} opts.flexpassId - Flexpass id
|
|
25
|
+
* @param {string} opts.flexpassId - Flexpass id (24 hex characters)
|
|
26
26
|
* @param {Object} [opts.headers] - Optional headers
|
|
27
27
|
* @returns {Promise<import("axios").AxiosResponse>}
|
|
28
28
|
*/
|
|
@@ -30,13 +30,10 @@ function flexpassesEndpointsFactory(_ref) {
|
|
|
30
30
|
var token = _ref2.token,
|
|
31
31
|
jwtToken = _ref2.jwtToken,
|
|
32
32
|
flexpassId = _ref2.flexpassId,
|
|
33
|
-
_ref2$query = _ref2.query,
|
|
34
|
-
query = _ref2$query === undefined ? {} : _ref2$query,
|
|
35
33
|
headers = _ref2.headers;
|
|
36
34
|
|
|
37
35
|
return client({
|
|
38
36
|
url: "/flexpasses/" + flexpassId,
|
|
39
|
-
params: query,
|
|
40
37
|
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers })
|
|
41
38
|
});
|
|
42
39
|
}
|
|
@@ -17,12 +17,18 @@ var _require = require("./../endpoints_helpers.js"),
|
|
|
17
17
|
* @property {string} [providerId] - Provider account id
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Query params for PATCH /orders (btrz-api-sales patch-handler getSpec).
|
|
22
|
+
* @typedef {Object} OrderPatchQuery
|
|
23
|
+
* @property {string} [includePaidOrExpired] - 'true' or 'false'; whether to update when transaction is already paid or expired
|
|
24
|
+
*/
|
|
25
|
+
|
|
20
26
|
/**
|
|
21
27
|
* Factory for order API (btrz-api-sales).
|
|
22
28
|
* @param {Object} deps
|
|
23
29
|
* @param {import("axios").AxiosInstance} deps.client
|
|
24
30
|
* @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
|
|
25
|
-
* @returns {{ create: function, get: function, overwrite: function }}
|
|
31
|
+
* @returns {{ create: function, get: function, overwrite: function, patch: function }}
|
|
26
32
|
*/
|
|
27
33
|
|
|
28
34
|
|
|
@@ -31,10 +37,10 @@ function orderFactory(_ref) {
|
|
|
31
37
|
internalAuthTokenProvider = _ref.internalAuthTokenProvider;
|
|
32
38
|
|
|
33
39
|
/**
|
|
34
|
-
* POST /order - create order.
|
|
40
|
+
* POST /order - create order. Body: orderRequest (cartId, customerInfo, payments, channel, etc.).
|
|
35
41
|
* @param {Object} opts
|
|
36
42
|
* @param {string} [opts.token] - API key
|
|
37
|
-
* @param {Object} opts.order - Order
|
|
43
|
+
* @param {Object} opts.order - Order request body (orderRequest)
|
|
38
44
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
39
45
|
* @param {Object} [opts.headers] - Optional headers
|
|
40
46
|
* @returns {Promise<import("axios").AxiosResponse>}
|
|
@@ -77,11 +83,11 @@ function orderFactory(_ref) {
|
|
|
77
83
|
}
|
|
78
84
|
|
|
79
85
|
/**
|
|
80
|
-
* POST /orders/:orderId/payments - overwrite order payments.
|
|
86
|
+
* POST /orders/:orderId/payments - overwrite order payments. Body must include payments (array). Endpoint is internal (hideInDocumentation).
|
|
81
87
|
* @param {Object} opts
|
|
82
88
|
* @param {string} [opts.token] - API key
|
|
83
|
-
* @param {string} opts.orderId - Order id
|
|
84
|
-
* @param {Object} opts.payments -
|
|
89
|
+
* @param {string} opts.orderId - Order (transaction) id
|
|
90
|
+
* @param {Object} opts.payments - Request body; must include property payments (array of payment objects)
|
|
85
91
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
86
92
|
* @param {Object} [opts.headers] - Optional headers
|
|
87
93
|
* @param {OrderPaymentsQuery} [opts.query] - Query params (channel, providerId)
|
|
@@ -105,10 +111,38 @@ function orderFactory(_ref) {
|
|
|
105
111
|
});
|
|
106
112
|
}
|
|
107
113
|
|
|
114
|
+
/**
|
|
115
|
+
* PATCH /orders - complete order creation after referenced payment (e.g. waitForPaymentCompletion). Body: operation (name, data with transactionId, paymentResult). Query: includePaidOrExpired.
|
|
116
|
+
* @param {Object} opts
|
|
117
|
+
* @param {string} [opts.token] - API key
|
|
118
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
119
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
120
|
+
* @param {Object} opts.operation - Operation object: { name, data: { transactionId, paymentResult } }
|
|
121
|
+
* @param {OrderPatchQuery} [opts.query] - Query params (includePaidOrExpired)
|
|
122
|
+
* @returns {Promise<import("axios").AxiosResponse>}
|
|
123
|
+
*/
|
|
124
|
+
function patch(_ref5) {
|
|
125
|
+
var token = _ref5.token,
|
|
126
|
+
jwtToken = _ref5.jwtToken,
|
|
127
|
+
headers = _ref5.headers,
|
|
128
|
+
operation = _ref5.operation,
|
|
129
|
+
_ref5$query = _ref5.query,
|
|
130
|
+
query = _ref5$query === undefined ? {} : _ref5$query;
|
|
131
|
+
|
|
132
|
+
return client({
|
|
133
|
+
url: "/orders",
|
|
134
|
+
method: "patch",
|
|
135
|
+
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers }),
|
|
136
|
+
data: { operation: operation },
|
|
137
|
+
params: query
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
108
141
|
return {
|
|
109
142
|
create: create,
|
|
110
143
|
get: get,
|
|
111
|
-
overwrite: overwrite
|
|
144
|
+
overwrite: overwrite,
|
|
145
|
+
patch: patch
|
|
112
146
|
};
|
|
113
147
|
}
|
|
114
148
|
|
|
@@ -18,10 +18,10 @@ function parcelQuotesFactory(_ref) {
|
|
|
18
18
|
internalAuthTokenProvider = _ref.internalAuthTokenProvider;
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
* POST /parcel-quotes -
|
|
21
|
+
* POST /parcel-quotes - request a parcel quote. Body: parcelQuoteData (fromId, toId, productId, channel, parcels). API does not accept query params.
|
|
22
22
|
* @param {Object} opts
|
|
23
23
|
* @param {string} [opts.token] - API key
|
|
24
|
-
* @param {Object} opts.parcelQuoteData - Parcel quote request
|
|
24
|
+
* @param {Object} opts.parcelQuoteData - Parcel quote request: fromId, toId, productId, channel, parcels (array of { fareId, weight, measure })
|
|
25
25
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
26
26
|
* @param {Object} [opts.headers] - Optional headers
|
|
27
27
|
* @returns {Promise<import("axios").AxiosResponse>}
|
package/package.json
CHANGED
package/src/client.js
CHANGED
|
@@ -134,15 +134,16 @@ function createInventory({baseURL, headers, timeout, overrideFn, internalAuthTok
|
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
/**
|
|
137
|
-
* Creates the trips API client (trips, segmentsInformationTables). Uses inventory base path.
|
|
137
|
+
* Creates the trips API client (trips, tripIds, segmentsInformationTables). Uses inventory base path.
|
|
138
138
|
* @param {CreateModuleOptions} opts - Client options
|
|
139
|
-
* @returns {Object} Object with trips
|
|
139
|
+
* @returns {Object} Object with trips, tripIds, segmentsInformationTables endpoint namespaces and __test_trips.client
|
|
140
140
|
*/
|
|
141
141
|
function createTrips({baseURL, headers, timeout, overrideFn, internalAuthTokenProvider, agents}) {
|
|
142
142
|
const client = clientFactory({baseURL, headers, timeout, overrideFn, agents});
|
|
143
143
|
|
|
144
144
|
return {
|
|
145
145
|
trips: require("./endpoints/inventory/trips.js")({client, internalAuthTokenProvider}),
|
|
146
|
+
tripIds: require("./endpoints/inventory/trip-ids.js")({client, internalAuthTokenProvider}),
|
|
146
147
|
segmentsInformationTables: require("./endpoints/inventory/segments-information-tables.js")({client, internalAuthTokenProvider}),
|
|
147
148
|
__test_trips: {
|
|
148
149
|
client
|
|
@@ -444,6 +445,8 @@ function createBtrzPay({baseURL, headers, timeout, overrideFn, internalAuthToken
|
|
|
444
445
|
const client = clientFactory({baseURL, headers, timeout, overrideFn, agents});
|
|
445
446
|
|
|
446
447
|
return {
|
|
448
|
+
adyen: require("./endpoints/btrzpay/adyen.js")({client, internalAuthTokenProvider}),
|
|
449
|
+
cybersource3ds: require("./endpoints/btrzpay/cybersource3ds.js")({client, internalAuthTokenProvider}),
|
|
447
450
|
docs: require("./endpoints/btrzpay/docs.js")({client}),
|
|
448
451
|
cardpointeTerminals: require("./endpoints/btrzpay/cardpointe.js").cardpointeTerminalsFactory({client, internalAuthTokenProvider}),
|
|
449
452
|
paymentMethods: require("./endpoints/btrzpay/payment-methods.js")({client, internalAuthTokenProvider}),
|
|
@@ -459,6 +462,7 @@ function createBtrzPay({baseURL, headers, timeout, overrideFn, internalAuthToken
|
|
|
459
462
|
prismaTerminals: require("./endpoints/btrzpay/prismaTerminals.js")({client, internalAuthTokenProvider}),
|
|
460
463
|
terminalPayments: require("./endpoints/btrzpay/terminalPayments.js")({client, internalAuthTokenProvider}),
|
|
461
464
|
stripeTerminals: require("./endpoints/btrzpay/stripe-terminals.js")({client, internalAuthTokenProvider}),
|
|
465
|
+
stripe3ds: require("./endpoints/btrzpay/stripe3ds.js")({client, internalAuthTokenProvider}),
|
|
462
466
|
__test: {
|
|
463
467
|
client
|
|
464
468
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/* eslint-disable max-len */
|
|
2
|
+
/* eslint-disable import/extensions */
|
|
3
|
+
const {authorizationHeaders} = require("../endpoints_helpers.js");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Query params for GET /adyen-payment-methods (btrz-api-payments). See getAdyenPaymentMethods getSpec().
|
|
7
|
+
* @typedef {Object} AdyenPaymentMethodsQuery
|
|
8
|
+
* @property {string} [countryCode] - Two-letter ISO country code to filter allowed payment methods
|
|
9
|
+
* @property {string} [currencyCode] - Three-letter ISO currency code to filter allowed payment methods
|
|
10
|
+
* @property {number} [amount] - Amount used to determine allowed payment methods
|
|
11
|
+
* @property {string} [transactionId] - Transaction identifier for the payment session
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Factory for Adyen API (btrz-api-payments).
|
|
16
|
+
* @param {Object} deps
|
|
17
|
+
* @param {import("axios").AxiosInstance} deps.client
|
|
18
|
+
* @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
|
|
19
|
+
* @returns {{ getPaymentMethods: function }}
|
|
20
|
+
*/
|
|
21
|
+
function adyenFactory({client, internalAuthTokenProvider}) {
|
|
22
|
+
/**
|
|
23
|
+
* GET /adyen-payment-methods - returns allowed Adyen payment methods for the account.
|
|
24
|
+
* @param {Object} opts
|
|
25
|
+
* @param {string} [opts.token] - API key
|
|
26
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
27
|
+
* @param {AdyenPaymentMethodsQuery} [opts.query] - Query params (countryCode, currencyCode, amount, transactionId)
|
|
28
|
+
* @param {Object} [opts.headers] - Optional request headers
|
|
29
|
+
* @returns {Promise<import("axios").AxiosResponse<{ AdyenPaymentMethods: Array<{ name: string, type: string, brands?: string[] }> }>>}
|
|
30
|
+
* Resolves with GetAdyenPaymentMethodsResponse. Rejects with 400 (INVALID_*), 404 (ADYEN_PAYMENT_METHODS_NOT_FOUND, PROVIDER_NOT_FOUND, PAYMENT_METHOD_NOT_FOUND).
|
|
31
|
+
*/
|
|
32
|
+
function getPaymentMethods({token, jwtToken, query = {}, headers}) {
|
|
33
|
+
return client.get("/adyen-payment-methods", {
|
|
34
|
+
params: query,
|
|
35
|
+
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
getPaymentMethods
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
module.exports = adyenFactory;
|
|
@@ -51,7 +51,7 @@ function cardpointeTerminalsFactory({client, internalAuthTokenProvider}) {
|
|
|
51
51
|
* @param {Object} opts
|
|
52
52
|
* @param {string} [opts.token] - API key
|
|
53
53
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
54
|
-
* @param {string} opts.readCardResultId - Read card result id
|
|
54
|
+
* @param {string} opts.readCardResultId - Read card result id (UUID v4)
|
|
55
55
|
* @param {Object} [opts.headers] - Optional headers
|
|
56
56
|
* @returns {Promise<import("axios").AxiosResponse>}
|
|
57
57
|
*/
|
|
@@ -62,19 +62,21 @@ function cardpointeTerminalsFactory({client, internalAuthTokenProvider}) {
|
|
|
62
62
|
});
|
|
63
63
|
},
|
|
64
64
|
/**
|
|
65
|
-
* POST /cardpointe-terminals/read-card -
|
|
65
|
+
* POST /cardpointe-terminals/read-card - start read card session. API accepts optional query providerId.
|
|
66
66
|
* @param {Object} opts
|
|
67
67
|
* @param {string} [opts.token] - API key
|
|
68
68
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
69
|
-
* @param {Object} opts.readCard - Read card payload
|
|
69
|
+
* @param {Object} opts.readCard - Read card payload (merchantId, terminalId, amount)
|
|
70
|
+
* @param {string} [opts.providerId] - Provider (payment method) ID; if omitted, account ID is used
|
|
70
71
|
* @param {Object} [opts.headers] - Optional headers
|
|
71
72
|
* @returns {Promise<import("axios").AxiosResponse>}
|
|
72
73
|
*/
|
|
73
74
|
// eslint-disable-next-line no-shadow
|
|
74
|
-
create({token, jwtToken, readCard, headers}) {
|
|
75
|
+
create({token, jwtToken, readCard, providerId, headers}) {
|
|
75
76
|
return client({
|
|
76
77
|
url: "/cardpointe-terminals/read-card",
|
|
77
78
|
method: "post",
|
|
79
|
+
params: providerId != null ? {providerId} : {},
|
|
78
80
|
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
|
|
79
81
|
data: {readCard}
|
|
80
82
|
});
|
|
@@ -9,15 +9,15 @@ const {authorizationHeaders} = require("../endpoints_helpers.js");
|
|
|
9
9
|
*/
|
|
10
10
|
function customerCardsFactory({client, internalAuthTokenProvider}) {
|
|
11
11
|
/**
|
|
12
|
-
* GET
|
|
12
|
+
* GET .../cards/:customerCardId - get one card by id. No query params.
|
|
13
13
|
* @param {Object} opts
|
|
14
14
|
* @param {string} [opts.token] - API key
|
|
15
15
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
16
|
-
* @param {string} opts.paymentMethodId - Payment method
|
|
17
|
-
* @param {string} opts.customerId - Customer
|
|
18
|
-
* @param {string} opts.customerCardId -
|
|
16
|
+
* @param {string} opts.paymentMethodId - Payment method ID (UUID v4)
|
|
17
|
+
* @param {string} opts.customerId - Customer ID (object ID)
|
|
18
|
+
* @param {string} opts.customerCardId - Card ID (UUID v4)
|
|
19
19
|
* @param {Object} [opts.headers] - Optional headers
|
|
20
|
-
* @returns {Promise<import("axios").AxiosResponse
|
|
20
|
+
* @returns {Promise<import("axios").AxiosResponse<{ customerCard: Object }>>}
|
|
21
21
|
*/
|
|
22
22
|
function get({token, jwtToken, paymentMethodId, customerId, customerCardId, headers}) {
|
|
23
23
|
return client.get(`/payment-methods/${paymentMethodId}/customers/${customerId}/cards/${customerCardId}`, {
|
|
@@ -27,14 +27,14 @@ function customerCardsFactory({client, internalAuthTokenProvider}) {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
|
-
* GET
|
|
30
|
+
* GET .../cards - list all cards for customer. No query params.
|
|
31
31
|
* @param {Object} opts
|
|
32
32
|
* @param {string} [opts.token] - API key
|
|
33
33
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
34
|
-
* @param {string} opts.paymentMethodId - Payment method
|
|
35
|
-
* @param {string} opts.customerId - Customer
|
|
34
|
+
* @param {string} opts.paymentMethodId - Payment method ID (UUID v4)
|
|
35
|
+
* @param {string} opts.customerId - Customer ID (object ID)
|
|
36
36
|
* @param {Object} [opts.headers] - Optional headers
|
|
37
|
-
* @returns {Promise<import("axios").AxiosResponse>}
|
|
37
|
+
* @returns {Promise<import("axios").AxiosResponse<{ customerCards: Array<Object> }>>}
|
|
38
38
|
*/
|
|
39
39
|
function all({token, jwtToken, paymentMethodId, customerId, headers}) {
|
|
40
40
|
return client.get(`/payment-methods/${paymentMethodId}/customers/${customerId}/cards`, {
|
|
@@ -44,15 +44,15 @@ function customerCardsFactory({client, internalAuthTokenProvider}) {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
|
-
* POST
|
|
47
|
+
* POST .../cards - create stored card. Body: { customerCard }. No query params.
|
|
48
48
|
* @param {Object} opts
|
|
49
49
|
* @param {string} [opts.token] - API key
|
|
50
50
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
51
|
-
* @param {string} opts.paymentMethodId - Payment method
|
|
52
|
-
* @param {string} opts.customerId - Customer
|
|
53
|
-
* @param {Object} opts.customerCard -
|
|
51
|
+
* @param {string} opts.paymentMethodId - Payment method ID (UUID v4)
|
|
52
|
+
* @param {string} opts.customerId - Customer ID (object ID)
|
|
53
|
+
* @param {Object} opts.customerCard - Card payload (see PostCustomerCardRequest)
|
|
54
54
|
* @param {Object} [opts.headers] - Optional headers
|
|
55
|
-
* @returns {Promise<import("axios").AxiosResponse
|
|
55
|
+
* @returns {Promise<import("axios").AxiosResponse<{ customerCard: Object }>>}
|
|
56
56
|
*/
|
|
57
57
|
function create({token, jwtToken, paymentMethodId, customerId, customerCard, headers}) {
|
|
58
58
|
return client({
|
|
@@ -64,15 +64,15 @@ function customerCardsFactory({client, internalAuthTokenProvider}) {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
|
-
* DELETE
|
|
67
|
+
* DELETE .../cards/:customerCardId - remove stored card. No query params.
|
|
68
68
|
* @param {Object} opts
|
|
69
69
|
* @param {string} [opts.token] - API key
|
|
70
70
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
71
|
-
* @param {string} opts.paymentMethodId - Payment method
|
|
72
|
-
* @param {string} opts.customerId - Customer
|
|
73
|
-
* @param {string} opts.customerCardId -
|
|
71
|
+
* @param {string} opts.paymentMethodId - Payment method ID (UUID v4)
|
|
72
|
+
* @param {string} opts.customerId - Customer ID (object ID)
|
|
73
|
+
* @param {string} opts.customerCardId - Card ID (UUID v4)
|
|
74
74
|
* @param {Object} [opts.headers] - Optional headers
|
|
75
|
-
* @returns {Promise<import("axios").AxiosResponse
|
|
75
|
+
* @returns {Promise<import("axios").AxiosResponse<{ success: boolean }>>}
|
|
76
76
|
*/
|
|
77
77
|
function remove({token, jwtToken, paymentMethodId, customerId, customerCardId, headers}) {
|
|
78
78
|
return client({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const {authorizationHeaders} = require("../endpoints_helpers.js");
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Factory for payment-method customers API (btrz-api-payments).
|
|
4
|
+
* Factory for payment-method customers API (btrz-api-payments). Path: payment-methods/{id}/customers.
|
|
5
5
|
* @param {Object} deps
|
|
6
6
|
* @param {import("axios").AxiosInstance} deps.client
|
|
7
7
|
* @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
|
|
@@ -9,14 +9,14 @@ const {authorizationHeaders} = require("../endpoints_helpers.js");
|
|
|
9
9
|
*/
|
|
10
10
|
function customersFactory({client, internalAuthTokenProvider}) {
|
|
11
11
|
/**
|
|
12
|
-
* GET
|
|
12
|
+
* GET .../customers/:customerId - get customer. No query params.
|
|
13
13
|
* @param {Object} opts
|
|
14
14
|
* @param {string} [opts.token] - API key
|
|
15
15
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
16
|
-
* @param {string} opts.paymentMethodId - Payment method
|
|
17
|
-
* @param {string} opts.customerId - Customer
|
|
16
|
+
* @param {string} opts.paymentMethodId - Payment method ID (UUID v4)
|
|
17
|
+
* @param {string} opts.customerId - Customer ID (object ID)
|
|
18
18
|
* @param {Object} [opts.headers] - Optional headers
|
|
19
|
-
* @returns {Promise<import("axios").AxiosResponse
|
|
19
|
+
* @returns {Promise<import("axios").AxiosResponse<{ customer: Object }>>}
|
|
20
20
|
*/
|
|
21
21
|
function get({token, jwtToken, paymentMethodId, customerId, headers}) {
|
|
22
22
|
return client.get(`/payment-methods/${paymentMethodId}/customers/${customerId}`, {
|
|
@@ -26,14 +26,14 @@ function customersFactory({client, internalAuthTokenProvider}) {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
* POST
|
|
29
|
+
* POST .../customers - create customer. Body: { customer } (PostCustomerRequest: channel, customer.id/number/email). No query params.
|
|
30
30
|
* @param {Object} opts
|
|
31
31
|
* @param {string} [opts.token] - API key
|
|
32
32
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
33
|
-
* @param {string} opts.paymentMethodId - Payment method
|
|
34
|
-
* @param {Object} opts.customer -
|
|
33
|
+
* @param {string} opts.paymentMethodId - Payment method ID (UUID v4)
|
|
34
|
+
* @param {Object} opts.customer - PostCustomerRequest (channel, customer with id, number, email)
|
|
35
35
|
* @param {Object} [opts.headers] - Optional headers
|
|
36
|
-
* @returns {Promise<import("axios").AxiosResponse
|
|
36
|
+
* @returns {Promise<import("axios").AxiosResponse<{ customer: Object }>>}
|
|
37
37
|
*/
|
|
38
38
|
function create({token, jwtToken, paymentMethodId, customer, headers}) {
|
|
39
39
|
return client({
|
|
@@ -45,14 +45,14 @@ function customersFactory({client, internalAuthTokenProvider}) {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
|
-
* DELETE
|
|
48
|
+
* DELETE .../customers/:customerId - remove customer (and saved cards). No query params.
|
|
49
49
|
* @param {Object} opts
|
|
50
50
|
* @param {string} [opts.token] - API key
|
|
51
51
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
52
|
-
* @param {string} opts.paymentMethodId - Payment method
|
|
53
|
-
* @param {string} opts.customerId - Customer
|
|
52
|
+
* @param {string} opts.paymentMethodId - Payment method ID (UUID v4)
|
|
53
|
+
* @param {string} opts.customerId - Customer ID (object ID)
|
|
54
54
|
* @param {Object} [opts.headers] - Optional headers
|
|
55
|
-
* @returns {Promise<import("axios").AxiosResponse
|
|
55
|
+
* @returns {Promise<import("axios").AxiosResponse<{ success: boolean }>>}
|
|
56
56
|
*/
|
|
57
57
|
function remove({token, jwtToken, paymentMethodId, customerId, headers}) {
|
|
58
58
|
return client({
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/* eslint-disable max-len */
|
|
2
|
+
const {authorizationHeaders} = require("../endpoints_helpers.js");
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Query params for GET /cbs-token (btrz-api-payments). See getSpec() in get-token-handler.
|
|
6
|
+
* @typedef {Object} Cybersource3dsTokenQuery
|
|
7
|
+
* @property {string} transactionId - Transaction ID for which to create the 3DS token (required). ObjectId format.
|
|
8
|
+
* @property {string} [operatingCompanyId] - Operating company ID when Cybersource uses overrides by operating company. ObjectId format.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Request body for POST /cbs-evaluate-risk. RiskEvaluationPostData.
|
|
13
|
+
* @typedef {Object} RiskEvaluationPostData
|
|
14
|
+
* @property {Object} paymentData - Payment information (required)
|
|
15
|
+
* @property {Object} [cartPayload] - Cart information (CartData)
|
|
16
|
+
* @property {string} [operatingCompanyId] - Operating company ID
|
|
17
|
+
* @property {string} [providerName] - Provider name (e.g. "cybersource")
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Request body for POST /cbs-pa-enrollment. PayerAuthenticationPostData.
|
|
22
|
+
* @typedef {Object} PayerAuthenticationPostData
|
|
23
|
+
* @property {Object} paymentData - Payment information (required)
|
|
24
|
+
* @property {string} [operatingCompanyId] - Operating company ID
|
|
25
|
+
* @property {string} [providerName] - Provider name (e.g. "cybersource")
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Request body for POST /cbs-validate-pa-enrollment. ValidateAuthenticationPostData.
|
|
30
|
+
* @typedef {Object} ValidateAuthenticationPostData
|
|
31
|
+
* @property {Object} paymentData - Payment information (required)
|
|
32
|
+
* @property {string} processorTransactionId - Processor transaction ID from payer authentication enrollment (required)
|
|
33
|
+
* @property {string} [operatingCompanyId] - Operating company ID
|
|
34
|
+
* @property {string} [providerName] - Provider name (e.g. "cybersource")
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Factory for Cybersource 3DS API (btrz-api-payments): Cardinal/Cybersource token, evaluate risk, payer auth enrollment, validate enrollment.
|
|
39
|
+
* @param {Object} deps
|
|
40
|
+
* @param {import("axios").AxiosInstance} deps.client
|
|
41
|
+
* @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
|
|
42
|
+
* @returns {{ getToken: function, evaluateRisk: function, payerAuthenticationEnrollment: function, validatePayerAuthenticationEnrollment: function }}
|
|
43
|
+
*/
|
|
44
|
+
function cybersource3dsFactory({client, internalAuthTokenProvider}) {
|
|
45
|
+
/**
|
|
46
|
+
* GET /cbs-token - returns JWT to use with Cardinal (3DS).
|
|
47
|
+
* @param {Object} opts
|
|
48
|
+
* @param {string} [opts.token] - API key
|
|
49
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
50
|
+
* @param {Cybersource3dsTokenQuery} opts.query - transactionId (required), optional operatingCompanyId
|
|
51
|
+
* @param {Object} [opts.headers] - Optional request headers
|
|
52
|
+
* @returns {Promise<import("axios").AxiosResponse<{ token: string }>>} ThreeDSTokenResponse. Rejects with 400 (WRONG_DATA, INVALID_TRANSACTION_ID, PROVIDER_NOT_FOUND, PAYMENT_METHOD_NOT_FOUND), 401, 500.
|
|
53
|
+
*/
|
|
54
|
+
function getToken({token, jwtToken, query, headers}) {
|
|
55
|
+
return client.get("/cbs-token", {
|
|
56
|
+
params: query,
|
|
57
|
+
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* POST /cbs-evaluate-risk - evaluate fraud risk (Decision Manager).
|
|
63
|
+
* @param {Object} opts
|
|
64
|
+
* @param {string} [opts.token] - API key
|
|
65
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
66
|
+
* @param {RiskEvaluationPostData} opts.riskEvaluation - paymentData (required), optional cartPayload, operatingCompanyId
|
|
67
|
+
* @param {Object} [opts.headers] - Optional request headers
|
|
68
|
+
* @returns {Promise<import("axios").AxiosResponse<RiskEvaluationResponse>>} RiskEvaluationResponse. Rejects with 400 (EVAL_RISK_*), 401, 409 (CYBERSOURCE_AUTH_FAILED), 500.
|
|
69
|
+
*/
|
|
70
|
+
function evaluateRisk({token, jwtToken, riskEvaluation, headers}) {
|
|
71
|
+
return client.post("/cbs-evaluate-risk", riskEvaluation, {
|
|
72
|
+
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* POST /cbs-pa-enrollment - check payer authentication enrollment.
|
|
78
|
+
* @param {Object} opts
|
|
79
|
+
* @param {string} [opts.token] - API key
|
|
80
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
81
|
+
* @param {PayerAuthenticationPostData} opts.body - paymentData (required), optional operatingCompanyId
|
|
82
|
+
* @param {Object} [opts.headers] - Optional request headers
|
|
83
|
+
* @returns {Promise<import("axios").AxiosResponse<PAEnrollmentResponse>>} PAEnrollmentResponse. Rejects with 400 (PAENROLL_*, PROVIDER_NOT_FOUND, PAYMENT_METHOD_NOT_FOUND), 401, 500.
|
|
84
|
+
*/
|
|
85
|
+
function payerAuthenticationEnrollment({token, jwtToken, body, headers}) {
|
|
86
|
+
return client.post("/cbs-pa-enrollment", body, {
|
|
87
|
+
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* POST /cbs-validate-pa-enrollment - validate payer authentication challenge response.
|
|
93
|
+
* @param {Object} opts
|
|
94
|
+
* @param {string} [opts.token] - API key
|
|
95
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
96
|
+
* @param {ValidateAuthenticationPostData} opts.body - paymentData and processorTransactionId (required)
|
|
97
|
+
* @param {Object} [opts.headers] - Optional request headers
|
|
98
|
+
* @returns {Promise<import("axios").AxiosResponse<ValidatePAEnrollmentResponse>>} ValidatePAEnrollmentResponse. Rejects with 400 (VALIDATE_PAENROLL_*), 401, 500.
|
|
99
|
+
*/
|
|
100
|
+
function validatePayerAuthenticationEnrollment({token, jwtToken, body, headers}) {
|
|
101
|
+
return client.post("/cbs-validate-pa-enrollment", body, {
|
|
102
|
+
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
getToken,
|
|
108
|
+
evaluateRisk,
|
|
109
|
+
payerAuthenticationEnrollment,
|
|
110
|
+
validatePayerAuthenticationEnrollment
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
module.exports = cybersource3dsFactory;
|