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
package/lib/client.js
CHANGED
|
@@ -147,9 +147,9 @@ function createInventory(_ref) {
|
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
/**
|
|
150
|
-
* Creates the trips API client (trips, segmentsInformationTables). Uses inventory base path.
|
|
150
|
+
* Creates the trips API client (trips, tripIds, segmentsInformationTables). Uses inventory base path.
|
|
151
151
|
* @param {CreateModuleOptions} opts - Client options
|
|
152
|
-
* @returns {Object} Object with trips
|
|
152
|
+
* @returns {Object} Object with trips, tripIds, segmentsInformationTables endpoint namespaces and __test_trips.client
|
|
153
153
|
*/
|
|
154
154
|
function createTrips(_ref2) {
|
|
155
155
|
var baseURL = _ref2.baseURL,
|
|
@@ -163,6 +163,7 @@ function createTrips(_ref2) {
|
|
|
163
163
|
|
|
164
164
|
return {
|
|
165
165
|
trips: require("./endpoints/inventory/trips.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
|
|
166
|
+
tripIds: require("./endpoints/inventory/trip-ids.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
|
|
166
167
|
segmentsInformationTables: require("./endpoints/inventory/segments-information-tables.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
|
|
167
168
|
__test_trips: {
|
|
168
169
|
client: client
|
|
@@ -541,6 +542,8 @@ function createBtrzPay(_ref13) {
|
|
|
541
542
|
var client = clientFactory({ baseURL: baseURL, headers: headers, timeout: timeout, overrideFn: overrideFn, agents: agents });
|
|
542
543
|
|
|
543
544
|
return {
|
|
545
|
+
adyen: require("./endpoints/btrzpay/adyen.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
|
|
546
|
+
cybersource3ds: require("./endpoints/btrzpay/cybersource3ds.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
|
|
544
547
|
docs: require("./endpoints/btrzpay/docs.js")({ client: client }),
|
|
545
548
|
cardpointeTerminals: require("./endpoints/btrzpay/cardpointe.js").cardpointeTerminalsFactory({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
|
|
546
549
|
paymentMethods: require("./endpoints/btrzpay/payment-methods.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
|
|
@@ -556,6 +559,7 @@ function createBtrzPay(_ref13) {
|
|
|
556
559
|
prismaTerminals: require("./endpoints/btrzpay/prismaTerminals.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
|
|
557
560
|
terminalPayments: require("./endpoints/btrzpay/terminalPayments.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
|
|
558
561
|
stripeTerminals: require("./endpoints/btrzpay/stripe-terminals.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
|
|
562
|
+
stripe3ds: require("./endpoints/btrzpay/stripe3ds.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
|
|
559
563
|
__test: {
|
|
560
564
|
client: client
|
|
561
565
|
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/* eslint-disable max-len */
|
|
4
|
+
/* eslint-disable import/extensions */
|
|
5
|
+
var _require = require("../endpoints_helpers.js"),
|
|
6
|
+
authorizationHeaders = _require.authorizationHeaders;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Query params for GET /adyen-payment-methods (btrz-api-payments). See getAdyenPaymentMethods getSpec().
|
|
10
|
+
* @typedef {Object} AdyenPaymentMethodsQuery
|
|
11
|
+
* @property {string} [countryCode] - Two-letter ISO country code to filter allowed payment methods
|
|
12
|
+
* @property {string} [currencyCode] - Three-letter ISO currency code to filter allowed payment methods
|
|
13
|
+
* @property {number} [amount] - Amount used to determine allowed payment methods
|
|
14
|
+
* @property {string} [transactionId] - Transaction identifier for the payment session
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Factory for Adyen API (btrz-api-payments).
|
|
19
|
+
* @param {Object} deps
|
|
20
|
+
* @param {import("axios").AxiosInstance} deps.client
|
|
21
|
+
* @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
|
|
22
|
+
* @returns {{ getPaymentMethods: function }}
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
function adyenFactory(_ref) {
|
|
27
|
+
var client = _ref.client,
|
|
28
|
+
internalAuthTokenProvider = _ref.internalAuthTokenProvider;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* GET /adyen-payment-methods - returns allowed Adyen payment methods for the account.
|
|
32
|
+
* @param {Object} opts
|
|
33
|
+
* @param {string} [opts.token] - API key
|
|
34
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
35
|
+
* @param {AdyenPaymentMethodsQuery} [opts.query] - Query params (countryCode, currencyCode, amount, transactionId)
|
|
36
|
+
* @param {Object} [opts.headers] - Optional request headers
|
|
37
|
+
* @returns {Promise<import("axios").AxiosResponse<{ AdyenPaymentMethods: Array<{ name: string, type: string, brands?: string[] }> }>>}
|
|
38
|
+
* Resolves with GetAdyenPaymentMethodsResponse. Rejects with 400 (INVALID_*), 404 (ADYEN_PAYMENT_METHODS_NOT_FOUND, PROVIDER_NOT_FOUND, PAYMENT_METHOD_NOT_FOUND).
|
|
39
|
+
*/
|
|
40
|
+
function getPaymentMethods(_ref2) {
|
|
41
|
+
var token = _ref2.token,
|
|
42
|
+
jwtToken = _ref2.jwtToken,
|
|
43
|
+
_ref2$query = _ref2.query,
|
|
44
|
+
query = _ref2$query === undefined ? {} : _ref2$query,
|
|
45
|
+
headers = _ref2.headers;
|
|
46
|
+
|
|
47
|
+
return client.get("/adyen-payment-methods", {
|
|
48
|
+
params: query,
|
|
49
|
+
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers })
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
getPaymentMethods: getPaymentMethods
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
module.exports = adyenFactory;
|
|
@@ -67,7 +67,7 @@ function cardpointeTerminalsFactory(_ref) {
|
|
|
67
67
|
* @param {Object} opts
|
|
68
68
|
* @param {string} [opts.token] - API key
|
|
69
69
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
70
|
-
* @param {string} opts.readCardResultId - Read card result id
|
|
70
|
+
* @param {string} opts.readCardResultId - Read card result id (UUID v4)
|
|
71
71
|
* @param {Object} [opts.headers] - Optional headers
|
|
72
72
|
* @returns {Promise<import("axios").AxiosResponse>}
|
|
73
73
|
*/
|
|
@@ -84,11 +84,12 @@ function cardpointeTerminalsFactory(_ref) {
|
|
|
84
84
|
},
|
|
85
85
|
|
|
86
86
|
/**
|
|
87
|
-
* POST /cardpointe-terminals/read-card -
|
|
87
|
+
* POST /cardpointe-terminals/read-card - start read card session. API accepts optional query providerId.
|
|
88
88
|
* @param {Object} opts
|
|
89
89
|
* @param {string} [opts.token] - API key
|
|
90
90
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
91
|
-
* @param {Object} opts.readCard - Read card payload
|
|
91
|
+
* @param {Object} opts.readCard - Read card payload (merchantId, terminalId, amount)
|
|
92
|
+
* @param {string} [opts.providerId] - Provider (payment method) ID; if omitted, account ID is used
|
|
92
93
|
* @param {Object} [opts.headers] - Optional headers
|
|
93
94
|
* @returns {Promise<import("axios").AxiosResponse>}
|
|
94
95
|
*/
|
|
@@ -97,11 +98,13 @@ function cardpointeTerminalsFactory(_ref) {
|
|
|
97
98
|
var token = _ref5.token,
|
|
98
99
|
jwtToken = _ref5.jwtToken,
|
|
99
100
|
readCard = _ref5.readCard,
|
|
101
|
+
providerId = _ref5.providerId,
|
|
100
102
|
headers = _ref5.headers;
|
|
101
103
|
|
|
102
104
|
return client({
|
|
103
105
|
url: "/cardpointe-terminals/read-card",
|
|
104
106
|
method: "post",
|
|
107
|
+
params: providerId != null ? { providerId: providerId } : {},
|
|
105
108
|
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers }),
|
|
106
109
|
data: { readCard: readCard }
|
|
107
110
|
});
|
|
@@ -17,15 +17,15 @@ function customerCardsFactory(_ref) {
|
|
|
17
17
|
internalAuthTokenProvider = _ref.internalAuthTokenProvider;
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
* GET
|
|
20
|
+
* GET .../cards/:customerCardId - get one card by id. No query params.
|
|
21
21
|
* @param {Object} opts
|
|
22
22
|
* @param {string} [opts.token] - API key
|
|
23
23
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
24
|
-
* @param {string} opts.paymentMethodId - Payment method
|
|
25
|
-
* @param {string} opts.customerId - Customer
|
|
26
|
-
* @param {string} opts.customerCardId -
|
|
24
|
+
* @param {string} opts.paymentMethodId - Payment method ID (UUID v4)
|
|
25
|
+
* @param {string} opts.customerId - Customer ID (object ID)
|
|
26
|
+
* @param {string} opts.customerCardId - Card ID (UUID v4)
|
|
27
27
|
* @param {Object} [opts.headers] - Optional headers
|
|
28
|
-
* @returns {Promise<import("axios").AxiosResponse
|
|
28
|
+
* @returns {Promise<import("axios").AxiosResponse<{ customerCard: Object }>>}
|
|
29
29
|
*/
|
|
30
30
|
function get(_ref2) {
|
|
31
31
|
var token = _ref2.token,
|
|
@@ -42,14 +42,14 @@ function customerCardsFactory(_ref) {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
|
-
* GET
|
|
45
|
+
* GET .../cards - list all cards for customer. No query params.
|
|
46
46
|
* @param {Object} opts
|
|
47
47
|
* @param {string} [opts.token] - API key
|
|
48
48
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
49
|
-
* @param {string} opts.paymentMethodId - Payment method
|
|
50
|
-
* @param {string} opts.customerId - Customer
|
|
49
|
+
* @param {string} opts.paymentMethodId - Payment method ID (UUID v4)
|
|
50
|
+
* @param {string} opts.customerId - Customer ID (object ID)
|
|
51
51
|
* @param {Object} [opts.headers] - Optional headers
|
|
52
|
-
* @returns {Promise<import("axios").AxiosResponse>}
|
|
52
|
+
* @returns {Promise<import("axios").AxiosResponse<{ customerCards: Array<Object> }>>}
|
|
53
53
|
*/
|
|
54
54
|
function all(_ref3) {
|
|
55
55
|
var token = _ref3.token,
|
|
@@ -65,15 +65,15 @@ function customerCardsFactory(_ref) {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
|
-
* POST
|
|
68
|
+
* POST .../cards - create stored card. Body: { customerCard }. No query params.
|
|
69
69
|
* @param {Object} opts
|
|
70
70
|
* @param {string} [opts.token] - API key
|
|
71
71
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
72
|
-
* @param {string} opts.paymentMethodId - Payment method
|
|
73
|
-
* @param {string} opts.customerId - Customer
|
|
74
|
-
* @param {Object} opts.customerCard -
|
|
72
|
+
* @param {string} opts.paymentMethodId - Payment method ID (UUID v4)
|
|
73
|
+
* @param {string} opts.customerId - Customer ID (object ID)
|
|
74
|
+
* @param {Object} opts.customerCard - Card payload (see PostCustomerCardRequest)
|
|
75
75
|
* @param {Object} [opts.headers] - Optional headers
|
|
76
|
-
* @returns {Promise<import("axios").AxiosResponse
|
|
76
|
+
* @returns {Promise<import("axios").AxiosResponse<{ customerCard: Object }>>}
|
|
77
77
|
*/
|
|
78
78
|
function create(_ref4) {
|
|
79
79
|
var token = _ref4.token,
|
|
@@ -92,15 +92,15 @@ function customerCardsFactory(_ref) {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
/**
|
|
95
|
-
* DELETE
|
|
95
|
+
* DELETE .../cards/:customerCardId - remove stored card. No query params.
|
|
96
96
|
* @param {Object} opts
|
|
97
97
|
* @param {string} [opts.token] - API key
|
|
98
98
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
99
|
-
* @param {string} opts.paymentMethodId - Payment method
|
|
100
|
-
* @param {string} opts.customerId - Customer
|
|
101
|
-
* @param {string} opts.customerCardId -
|
|
99
|
+
* @param {string} opts.paymentMethodId - Payment method ID (UUID v4)
|
|
100
|
+
* @param {string} opts.customerId - Customer ID (object ID)
|
|
101
|
+
* @param {string} opts.customerCardId - Card ID (UUID v4)
|
|
102
102
|
* @param {Object} [opts.headers] - Optional headers
|
|
103
|
-
* @returns {Promise<import("axios").AxiosResponse
|
|
103
|
+
* @returns {Promise<import("axios").AxiosResponse<{ success: boolean }>>}
|
|
104
104
|
*/
|
|
105
105
|
function remove(_ref5) {
|
|
106
106
|
var token = _ref5.token,
|
|
@@ -4,7 +4,7 @@ var _require = require("../endpoints_helpers.js"),
|
|
|
4
4
|
authorizationHeaders = _require.authorizationHeaders;
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Factory for payment-method customers API (btrz-api-payments).
|
|
7
|
+
* Factory for payment-method customers API (btrz-api-payments). Path: payment-methods/{id}/customers.
|
|
8
8
|
* @param {Object} deps
|
|
9
9
|
* @param {import("axios").AxiosInstance} deps.client
|
|
10
10
|
* @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
|
|
@@ -17,14 +17,14 @@ function customersFactory(_ref) {
|
|
|
17
17
|
internalAuthTokenProvider = _ref.internalAuthTokenProvider;
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
* GET
|
|
20
|
+
* GET .../customers/:customerId - get customer. No query params.
|
|
21
21
|
* @param {Object} opts
|
|
22
22
|
* @param {string} [opts.token] - API key
|
|
23
23
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
24
|
-
* @param {string} opts.paymentMethodId - Payment method
|
|
25
|
-
* @param {string} opts.customerId - Customer
|
|
24
|
+
* @param {string} opts.paymentMethodId - Payment method ID (UUID v4)
|
|
25
|
+
* @param {string} opts.customerId - Customer ID (object ID)
|
|
26
26
|
* @param {Object} [opts.headers] - Optional headers
|
|
27
|
-
* @returns {Promise<import("axios").AxiosResponse
|
|
27
|
+
* @returns {Promise<import("axios").AxiosResponse<{ customer: Object }>>}
|
|
28
28
|
*/
|
|
29
29
|
function get(_ref2) {
|
|
30
30
|
var token = _ref2.token,
|
|
@@ -40,14 +40,14 @@ function customersFactory(_ref) {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
|
-
* POST
|
|
43
|
+
* POST .../customers - create customer. Body: { customer } (PostCustomerRequest: channel, customer.id/number/email). No query params.
|
|
44
44
|
* @param {Object} opts
|
|
45
45
|
* @param {string} [opts.token] - API key
|
|
46
46
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
47
|
-
* @param {string} opts.paymentMethodId - Payment method
|
|
48
|
-
* @param {Object} opts.customer -
|
|
47
|
+
* @param {string} opts.paymentMethodId - Payment method ID (UUID v4)
|
|
48
|
+
* @param {Object} opts.customer - PostCustomerRequest (channel, customer with id, number, email)
|
|
49
49
|
* @param {Object} [opts.headers] - Optional headers
|
|
50
|
-
* @returns {Promise<import("axios").AxiosResponse
|
|
50
|
+
* @returns {Promise<import("axios").AxiosResponse<{ customer: Object }>>}
|
|
51
51
|
*/
|
|
52
52
|
function create(_ref3) {
|
|
53
53
|
var token = _ref3.token,
|
|
@@ -65,14 +65,14 @@ function customersFactory(_ref) {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
|
-
* DELETE
|
|
68
|
+
* DELETE .../customers/:customerId - remove customer (and saved cards). No query params.
|
|
69
69
|
* @param {Object} opts
|
|
70
70
|
* @param {string} [opts.token] - API key
|
|
71
71
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
72
|
-
* @param {string} opts.paymentMethodId - Payment method
|
|
73
|
-
* @param {string} opts.customerId - Customer
|
|
72
|
+
* @param {string} opts.paymentMethodId - Payment method ID (UUID v4)
|
|
73
|
+
* @param {string} opts.customerId - Customer ID (object ID)
|
|
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(_ref4) {
|
|
78
78
|
var token = _ref4.token,
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/* eslint-disable max-len */
|
|
4
|
+
var _require = require("../endpoints_helpers.js"),
|
|
5
|
+
authorizationHeaders = _require.authorizationHeaders;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Query params for GET /cbs-token (btrz-api-payments). See getSpec() in get-token-handler.
|
|
9
|
+
* @typedef {Object} Cybersource3dsTokenQuery
|
|
10
|
+
* @property {string} transactionId - Transaction ID for which to create the 3DS token (required). ObjectId format.
|
|
11
|
+
* @property {string} [operatingCompanyId] - Operating company ID when Cybersource uses overrides by operating company. ObjectId format.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Request body for POST /cbs-evaluate-risk. RiskEvaluationPostData.
|
|
16
|
+
* @typedef {Object} RiskEvaluationPostData
|
|
17
|
+
* @property {Object} paymentData - Payment information (required)
|
|
18
|
+
* @property {Object} [cartPayload] - Cart information (CartData)
|
|
19
|
+
* @property {string} [operatingCompanyId] - Operating company ID
|
|
20
|
+
* @property {string} [providerName] - Provider name (e.g. "cybersource")
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Request body for POST /cbs-pa-enrollment. PayerAuthenticationPostData.
|
|
25
|
+
* @typedef {Object} PayerAuthenticationPostData
|
|
26
|
+
* @property {Object} paymentData - Payment information (required)
|
|
27
|
+
* @property {string} [operatingCompanyId] - Operating company ID
|
|
28
|
+
* @property {string} [providerName] - Provider name (e.g. "cybersource")
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Request body for POST /cbs-validate-pa-enrollment. ValidateAuthenticationPostData.
|
|
33
|
+
* @typedef {Object} ValidateAuthenticationPostData
|
|
34
|
+
* @property {Object} paymentData - Payment information (required)
|
|
35
|
+
* @property {string} processorTransactionId - Processor transaction ID from payer authentication enrollment (required)
|
|
36
|
+
* @property {string} [operatingCompanyId] - Operating company ID
|
|
37
|
+
* @property {string} [providerName] - Provider name (e.g. "cybersource")
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Factory for Cybersource 3DS API (btrz-api-payments): Cardinal/Cybersource token, evaluate risk, payer auth enrollment, validate enrollment.
|
|
42
|
+
* @param {Object} deps
|
|
43
|
+
* @param {import("axios").AxiosInstance} deps.client
|
|
44
|
+
* @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
|
|
45
|
+
* @returns {{ getToken: function, evaluateRisk: function, payerAuthenticationEnrollment: function, validatePayerAuthenticationEnrollment: function }}
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
function cybersource3dsFactory(_ref) {
|
|
50
|
+
var client = _ref.client,
|
|
51
|
+
internalAuthTokenProvider = _ref.internalAuthTokenProvider;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* GET /cbs-token - returns JWT to use with Cardinal (3DS).
|
|
55
|
+
* @param {Object} opts
|
|
56
|
+
* @param {string} [opts.token] - API key
|
|
57
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
58
|
+
* @param {Cybersource3dsTokenQuery} opts.query - transactionId (required), optional operatingCompanyId
|
|
59
|
+
* @param {Object} [opts.headers] - Optional request headers
|
|
60
|
+
* @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.
|
|
61
|
+
*/
|
|
62
|
+
function getToken(_ref2) {
|
|
63
|
+
var token = _ref2.token,
|
|
64
|
+
jwtToken = _ref2.jwtToken,
|
|
65
|
+
query = _ref2.query,
|
|
66
|
+
headers = _ref2.headers;
|
|
67
|
+
|
|
68
|
+
return client.get("/cbs-token", {
|
|
69
|
+
params: query,
|
|
70
|
+
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers })
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* POST /cbs-evaluate-risk - evaluate fraud risk (Decision Manager).
|
|
76
|
+
* @param {Object} opts
|
|
77
|
+
* @param {string} [opts.token] - API key
|
|
78
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
79
|
+
* @param {RiskEvaluationPostData} opts.riskEvaluation - paymentData (required), optional cartPayload, operatingCompanyId
|
|
80
|
+
* @param {Object} [opts.headers] - Optional request headers
|
|
81
|
+
* @returns {Promise<import("axios").AxiosResponse<RiskEvaluationResponse>>} RiskEvaluationResponse. Rejects with 400 (EVAL_RISK_*), 401, 409 (CYBERSOURCE_AUTH_FAILED), 500.
|
|
82
|
+
*/
|
|
83
|
+
function evaluateRisk(_ref3) {
|
|
84
|
+
var token = _ref3.token,
|
|
85
|
+
jwtToken = _ref3.jwtToken,
|
|
86
|
+
riskEvaluation = _ref3.riskEvaluation,
|
|
87
|
+
headers = _ref3.headers;
|
|
88
|
+
|
|
89
|
+
return client.post("/cbs-evaluate-risk", riskEvaluation, {
|
|
90
|
+
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers })
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* POST /cbs-pa-enrollment - check payer authentication enrollment.
|
|
96
|
+
* @param {Object} opts
|
|
97
|
+
* @param {string} [opts.token] - API key
|
|
98
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
99
|
+
* @param {PayerAuthenticationPostData} opts.body - paymentData (required), optional operatingCompanyId
|
|
100
|
+
* @param {Object} [opts.headers] - Optional request headers
|
|
101
|
+
* @returns {Promise<import("axios").AxiosResponse<PAEnrollmentResponse>>} PAEnrollmentResponse. Rejects with 400 (PAENROLL_*, PROVIDER_NOT_FOUND, PAYMENT_METHOD_NOT_FOUND), 401, 500.
|
|
102
|
+
*/
|
|
103
|
+
function payerAuthenticationEnrollment(_ref4) {
|
|
104
|
+
var token = _ref4.token,
|
|
105
|
+
jwtToken = _ref4.jwtToken,
|
|
106
|
+
body = _ref4.body,
|
|
107
|
+
headers = _ref4.headers;
|
|
108
|
+
|
|
109
|
+
return client.post("/cbs-pa-enrollment", body, {
|
|
110
|
+
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers })
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* POST /cbs-validate-pa-enrollment - validate payer authentication challenge response.
|
|
116
|
+
* @param {Object} opts
|
|
117
|
+
* @param {string} [opts.token] - API key
|
|
118
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
119
|
+
* @param {ValidateAuthenticationPostData} opts.body - paymentData and processorTransactionId (required)
|
|
120
|
+
* @param {Object} [opts.headers] - Optional request headers
|
|
121
|
+
* @returns {Promise<import("axios").AxiosResponse<ValidatePAEnrollmentResponse>>} ValidatePAEnrollmentResponse. Rejects with 400 (VALIDATE_PAENROLL_*), 401, 500.
|
|
122
|
+
*/
|
|
123
|
+
function validatePayerAuthenticationEnrollment(_ref5) {
|
|
124
|
+
var token = _ref5.token,
|
|
125
|
+
jwtToken = _ref5.jwtToken,
|
|
126
|
+
body = _ref5.body,
|
|
127
|
+
headers = _ref5.headers;
|
|
128
|
+
|
|
129
|
+
return client.post("/cbs-validate-pa-enrollment", body, {
|
|
130
|
+
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers })
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return {
|
|
135
|
+
getToken: getToken,
|
|
136
|
+
evaluateRisk: evaluateRisk,
|
|
137
|
+
payerAuthenticationEnrollment: payerAuthenticationEnrollment,
|
|
138
|
+
validatePayerAuthenticationEnrollment: validatePayerAuthenticationEnrollment
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
module.exports = cybersource3dsFactory;
|
|
@@ -6,11 +6,30 @@ var _require = require("./../endpoints_helpers.js"),
|
|
|
6
6
|
/**
|
|
7
7
|
* Query params for GET /datalogic/payments (btrz-api-payments). See get-payments-handler getSpec().
|
|
8
8
|
* @typedef {Object} DatalogicPaymentsListQuery
|
|
9
|
-
* @property {string}
|
|
9
|
+
* @property {string} referenceNumber - Payment reference number (required)
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Request body for POST /datalogic/payments/:referenceNumber. PostDatalogicPaymentsPayload.
|
|
14
|
+
* @typedef {Object} PostDatalogicPaymentsPayload
|
|
15
|
+
* @property {string} folio - FEMSA transaction id
|
|
16
|
+
* @property {number} id_terminal - Terminal/group ID
|
|
17
|
+
* @property {string} local_date - Local date (e.g. "02/08/2022 20:33:43")
|
|
18
|
+
* @property {string} amount - Debt amount
|
|
19
|
+
* @property {number} trx_no - Transaction number
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Request body for POST /datalogic/reverse/:referenceNumber. PostDatalogicReversePayload.
|
|
24
|
+
* @typedef {Object} PostDatalogicReversePayload
|
|
25
|
+
* @property {string} folio - FEMSA transaction id
|
|
26
|
+
* @property {number} id_terminal - Terminal/group ID
|
|
27
|
+
* @property {string} local_date - Local date (e.g. "02/08/2022 20:33:43")
|
|
28
|
+
* @property {number} trx_no - Transaction number
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Factory for Datalogic API (btrz-api-payments). Endpoints are hideInDocumentation; client for internal use.
|
|
14
33
|
* @param {Object} deps
|
|
15
34
|
* @param {import("axios").AxiosInstance} deps.client
|
|
16
35
|
* @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
|
|
@@ -19,41 +38,51 @@ var _require = require("./../endpoints_helpers.js"),
|
|
|
19
38
|
|
|
20
39
|
|
|
21
40
|
function datalogicFactory(_ref) {
|
|
22
|
-
var client = _ref.client
|
|
41
|
+
var client = _ref.client,
|
|
42
|
+
internalAuthTokenProvider = _ref.internalAuthTokenProvider;
|
|
43
|
+
|
|
44
|
+
function authProvider(opts) {
|
|
45
|
+
return opts !== undefined && opts !== null ? opts : internalAuthTokenProvider;
|
|
46
|
+
}
|
|
23
47
|
|
|
24
48
|
var payments = {
|
|
25
49
|
/**
|
|
26
|
-
* GET /datalogic/payments - list Datalogic payments.
|
|
50
|
+
* GET /datalogic/payments - list Datalogic payments by reference number.
|
|
27
51
|
* @param {Object} opts
|
|
28
52
|
* @param {string} [opts.token] - API key
|
|
29
53
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
30
|
-
* @param {DatalogicPaymentsListQuery}
|
|
54
|
+
* @param {DatalogicPaymentsListQuery} opts.query - referenceNumber (required)
|
|
31
55
|
* @param {Object} [opts.headers] - Optional headers
|
|
32
|
-
* @
|
|
56
|
+
* @param {{ getToken: function(): string }} [opts.internalAuthTokenProvider] - Internal auth provider
|
|
57
|
+
* @returns {Promise<import("axios").AxiosResponse<{ payments: Array }>>}
|
|
58
|
+
* GetDatalogicPaymentsResponse. Rejects 400, 401, 500.
|
|
33
59
|
*/
|
|
34
60
|
all: function all(_ref2) {
|
|
35
61
|
var token = _ref2.token,
|
|
36
62
|
jwtToken = _ref2.jwtToken,
|
|
37
63
|
headers = _ref2.headers,
|
|
38
64
|
query = _ref2.query,
|
|
39
|
-
|
|
65
|
+
optsAuth = _ref2.internalAuthTokenProvider;
|
|
40
66
|
|
|
41
67
|
return client({
|
|
42
68
|
url: "/datalogic/payments",
|
|
43
69
|
params: query,
|
|
44
|
-
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider:
|
|
70
|
+
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: authProvider(optsAuth), headers: headers })
|
|
45
71
|
});
|
|
46
72
|
},
|
|
47
73
|
|
|
48
74
|
/**
|
|
49
|
-
* POST /datalogic/payments/:referenceNumber -
|
|
75
|
+
* POST /datalogic/payments/:referenceNumber - pay by reference (20 digits).
|
|
76
|
+
* Body: datalogicInfo or flat PostDatalogicPaymentsPayload.
|
|
50
77
|
* @param {Object} opts
|
|
51
78
|
* @param {string} [opts.token] - API key
|
|
52
79
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
53
|
-
* @param {string} opts.referenceNumber - Reference number
|
|
54
|
-
* @param {
|
|
80
|
+
* @param {string} opts.referenceNumber - Reference number (20 digits)
|
|
81
|
+
* @param {PostDatalogicPaymentsPayload|{ datalogicInfo: PostDatalogicPaymentsPayload }} opts.data - Body
|
|
55
82
|
* @param {Object} [opts.headers] - Optional headers
|
|
56
|
-
* @
|
|
83
|
+
* @param {{ getToken: function(): string }} [opts.internalAuthTokenProvider] - Internal auth provider
|
|
84
|
+
* @returns {Promise<import("axios").AxiosResponse<{ payment: Object }>>}
|
|
85
|
+
* PostDatalogicPaymentsResponse. Rejects 400, 401, 500.
|
|
57
86
|
*/
|
|
58
87
|
update: function update(_ref3) {
|
|
59
88
|
var token = _ref3.token,
|
|
@@ -62,26 +91,29 @@ function datalogicFactory(_ref) {
|
|
|
62
91
|
query = _ref3.query,
|
|
63
92
|
referenceNumber = _ref3.referenceNumber,
|
|
64
93
|
data = _ref3.data,
|
|
65
|
-
|
|
94
|
+
optsAuth = _ref3.internalAuthTokenProvider;
|
|
66
95
|
|
|
67
96
|
return client({
|
|
68
97
|
url: "/datalogic/payments/" + referenceNumber,
|
|
69
98
|
method: "post",
|
|
70
99
|
params: query,
|
|
71
100
|
data: data,
|
|
72
|
-
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider:
|
|
101
|
+
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: authProvider(optsAuth), headers: headers })
|
|
73
102
|
});
|
|
74
103
|
},
|
|
75
104
|
|
|
76
105
|
/**
|
|
77
|
-
* POST /datalogic/reverse/:referenceNumber - reverse
|
|
106
|
+
* POST /datalogic/reverse/:referenceNumber - reverse by reference (20 digits).
|
|
107
|
+
* Body: datalogicReverseInfo or flat PostDatalogicReversePayload.
|
|
78
108
|
* @param {Object} opts
|
|
79
109
|
* @param {string} [opts.token] - API key
|
|
80
110
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
81
|
-
* @param {string} opts.referenceNumber - Reference number
|
|
82
|
-
* @param {
|
|
111
|
+
* @param {string} opts.referenceNumber - Reference number (20 digits)
|
|
112
|
+
* @param {PostDatalogicReversePayload|{ datalogicReverseInfo: PostDatalogicReversePayload }} opts.data - Body
|
|
83
113
|
* @param {Object} [opts.headers] - Optional headers
|
|
84
|
-
* @
|
|
114
|
+
* @param {{ getToken: function(): string }} [opts.internalAuthTokenProvider] - Internal auth provider
|
|
115
|
+
* @returns {Promise<import("axios").AxiosResponse<{ payment: Object }>>}
|
|
116
|
+
* PostDatalogicPaymentsResponse. Rejects 400, 401, 500.
|
|
85
117
|
*/
|
|
86
118
|
reverse: function reverse(_ref4) {
|
|
87
119
|
var token = _ref4.token,
|
|
@@ -90,58 +122,62 @@ function datalogicFactory(_ref) {
|
|
|
90
122
|
query = _ref4.query,
|
|
91
123
|
referenceNumber = _ref4.referenceNumber,
|
|
92
124
|
data = _ref4.data,
|
|
93
|
-
|
|
125
|
+
optsAuth = _ref4.internalAuthTokenProvider;
|
|
94
126
|
|
|
95
127
|
return client({
|
|
96
128
|
url: "/datalogic/reverse/" + referenceNumber,
|
|
97
129
|
method: "post",
|
|
98
130
|
params: query,
|
|
99
131
|
data: data,
|
|
100
|
-
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider:
|
|
132
|
+
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: authProvider(optsAuth), headers: headers })
|
|
101
133
|
});
|
|
102
134
|
}
|
|
103
135
|
};
|
|
104
136
|
|
|
105
137
|
var referenceNumber = {
|
|
106
138
|
/**
|
|
107
|
-
* GET /datalogic/reference-number - get reference number.
|
|
139
|
+
* GET /datalogic/reference-number - get new Datalogic reference number.
|
|
108
140
|
* @param {Object} opts
|
|
109
141
|
* @param {string} [opts.token] - API key
|
|
110
142
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
111
143
|
* @param {Object} [opts.headers] - Optional headers
|
|
112
|
-
* @
|
|
144
|
+
* @param {{ getToken: function(): string }} [opts.internalAuthTokenProvider] - Internal auth provider
|
|
145
|
+
* @returns {Promise<import("axios").AxiosResponse<{ referenceNumber: string }>>}
|
|
146
|
+
* GetDatalogicReferenceNumberResponse. Rejects 401, 404, 500.
|
|
113
147
|
*/
|
|
114
148
|
get: function get(_ref5) {
|
|
115
149
|
var token = _ref5.token,
|
|
116
150
|
jwtToken = _ref5.jwtToken,
|
|
117
151
|
headers = _ref5.headers,
|
|
118
|
-
|
|
152
|
+
optsAuth = _ref5.internalAuthTokenProvider;
|
|
119
153
|
|
|
120
154
|
return client({
|
|
121
155
|
url: "/datalogic/reference-number",
|
|
122
|
-
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider:
|
|
156
|
+
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: authProvider(optsAuth), headers: headers })
|
|
123
157
|
});
|
|
124
158
|
}
|
|
125
159
|
};
|
|
126
160
|
|
|
127
161
|
var authCode = {
|
|
128
162
|
/**
|
|
129
|
-
* GET /datalogic/auth-code - get
|
|
163
|
+
* GET /datalogic/auth-code - get new Datalogic authorization code.
|
|
130
164
|
* @param {Object} opts
|
|
131
165
|
* @param {string} [opts.token] - API key
|
|
132
166
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
133
167
|
* @param {Object} [opts.headers] - Optional headers
|
|
134
|
-
* @
|
|
168
|
+
* @param {{ getToken: function(): string }} [opts.internalAuthTokenProvider] - Internal auth provider
|
|
169
|
+
* @returns {Promise<import("axios").AxiosResponse<{ authCode: string }>>}
|
|
170
|
+
* GetDatalogicAuthCodeResponse. Rejects 401, 404, 500.
|
|
135
171
|
*/
|
|
136
172
|
get: function get(_ref6) {
|
|
137
173
|
var token = _ref6.token,
|
|
138
174
|
jwtToken = _ref6.jwtToken,
|
|
139
175
|
headers = _ref6.headers,
|
|
140
|
-
|
|
176
|
+
optsAuth = _ref6.internalAuthTokenProvider;
|
|
141
177
|
|
|
142
178
|
return client({
|
|
143
179
|
url: "/datalogic/auth-code",
|
|
144
|
-
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider:
|
|
180
|
+
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: authProvider(optsAuth), headers: headers })
|
|
145
181
|
});
|
|
146
182
|
}
|
|
147
183
|
};
|