btrz-api-client 8.33.0 → 8.35.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.
Files changed (160) hide show
  1. package/lib/client-standalone-min.js +3 -3
  2. package/lib/client.js +10 -2
  3. package/lib/endpoints/btrzpay/adyen.js +58 -0
  4. package/lib/endpoints/btrzpay/cardpointe.js +6 -3
  5. package/lib/endpoints/btrzpay/customerCards.js +19 -19
  6. package/lib/endpoints/btrzpay/customers.js +13 -13
  7. package/lib/endpoints/btrzpay/cybersource3ds.js +142 -0
  8. package/lib/endpoints/btrzpay/datalogic.js +64 -28
  9. package/lib/endpoints/btrzpay/oxxo.js +54 -28
  10. package/lib/endpoints/btrzpay/prismaTerminals.js +24 -15
  11. package/lib/endpoints/btrzpay/referenced-payments.js +4 -4
  12. package/lib/endpoints/btrzpay/square.js +8 -8
  13. package/lib/endpoints/btrzpay/stripe-terminals.js +16 -11
  14. package/lib/endpoints/btrzpay/stripe3ds.js +54 -0
  15. package/lib/endpoints/btrzpay/terminalPayments.js +19 -19
  16. package/lib/endpoints/inventory/banks.js +39 -21
  17. package/lib/endpoints/inventory/change-requests.js +59 -31
  18. package/lib/endpoints/inventory/control-classes.js +39 -20
  19. package/lib/endpoints/inventory/countries.js +25 -9
  20. package/lib/endpoints/inventory/custom-content.js +39 -21
  21. package/lib/endpoints/inventory/custom-fields.js +25 -17
  22. package/lib/endpoints/inventory/document-types.js +33 -42
  23. package/lib/endpoints/inventory/external-wallets.js +26 -20
  24. package/lib/endpoints/inventory/fees.js +19 -13
  25. package/lib/endpoints/inventory/filtered-trips.js +34 -8
  26. package/lib/endpoints/inventory/financing-costs.js +19 -14
  27. package/lib/endpoints/inventory/garages.js +19 -14
  28. package/lib/endpoints/inventory/getnet-terminals.js +20 -15
  29. package/lib/endpoints/inventory/gift-certificate-definitions.js +10 -5
  30. package/lib/endpoints/inventory/holidays.js +158 -0
  31. package/lib/endpoints/inventory/insurances.js +17 -13
  32. package/lib/endpoints/inventory/items.js +13 -9
  33. package/lib/endpoints/inventory/labels.js +16 -11
  34. package/lib/endpoints/inventory/marital-status.js +16 -11
  35. package/lib/endpoints/inventory/marketplace-modifiers.js +16 -11
  36. package/lib/endpoints/inventory/mit-terminal-settings.js +15 -10
  37. package/lib/endpoints/inventory/mit-terminals.js +16 -11
  38. package/lib/endpoints/inventory/operation-messages.js +18 -12
  39. package/lib/endpoints/inventory/operation-reasons.js +15 -10
  40. package/lib/endpoints/inventory/pay-on-accounts.js +5 -4
  41. package/lib/endpoints/inventory/payment-terminals.js +15 -10
  42. package/lib/endpoints/inventory/products.js +22 -10
  43. package/lib/endpoints/inventory/promos.js +27 -18
  44. package/lib/endpoints/inventory/segments-information-tables.js +13 -7
  45. package/lib/endpoints/inventory/station-groups.js +2 -4
  46. package/lib/endpoints/inventory/taxes.js +11 -2
  47. package/lib/endpoints/inventory/traveller-card-providers-types.js +6 -6
  48. package/lib/endpoints/inventory/trip-ids.js +67 -0
  49. package/lib/endpoints/inventory/trips.js +60 -13
  50. package/lib/endpoints/inventory/vehicle-types.js +2 -5
  51. package/lib/endpoints/inventory/vehicles.js +4 -2
  52. package/lib/endpoints/invoices/emails.js +15 -5
  53. package/lib/endpoints/invoices/invoices.js +46 -25
  54. package/lib/endpoints/invoices/pdfs.js +15 -8
  55. package/lib/endpoints/invoices/providers.js +42 -25
  56. package/lib/endpoints/invoices/tax-ids.js +11 -7
  57. package/lib/endpoints/notifications/customers.js +1 -1
  58. package/lib/endpoints/notifications/external-customers.js +54 -0
  59. package/lib/endpoints/notifications/pdfs.js +0 -3
  60. package/lib/endpoints/operations/accounting_items.js +7 -1
  61. package/lib/endpoints/operations/flexpasses.js +9 -7
  62. package/lib/endpoints/operations/gift-certificates.js +53 -0
  63. package/lib/endpoints/operations/loans.js +16 -10
  64. package/lib/endpoints/operations/movements.js +17 -6
  65. package/lib/endpoints/operations/pago-express.js +96 -0
  66. package/lib/endpoints/operations/parcels.js +11 -11
  67. package/lib/endpoints/operations/parcels_manifests.js +7 -4
  68. package/lib/endpoints/sales/cancellations.js +43 -31
  69. package/lib/endpoints/sales/cart.js +21 -18
  70. package/lib/endpoints/sales/flexpasses.js +2 -5
  71. package/lib/endpoints/sales/order.js +41 -7
  72. package/lib/endpoints/sales/parcel-quotes.js +2 -2
  73. package/package.json +1 -1
  74. package/src/client.js +10 -2
  75. package/src/endpoints/btrzpay/adyen.js +44 -0
  76. package/src/endpoints/btrzpay/cardpointe.js +6 -4
  77. package/src/endpoints/btrzpay/customerCards.js +19 -19
  78. package/src/endpoints/btrzpay/customers.js +13 -13
  79. package/src/endpoints/btrzpay/cybersource3ds.js +114 -0
  80. package/src/endpoints/btrzpay/datalogic.js +63 -28
  81. package/src/endpoints/btrzpay/oxxo.js +53 -26
  82. package/src/endpoints/btrzpay/prismaTerminals.js +24 -15
  83. package/src/endpoints/btrzpay/referenced-payments.js +4 -4
  84. package/src/endpoints/btrzpay/square.js +8 -8
  85. package/src/endpoints/btrzpay/stripe-terminals.js +17 -10
  86. package/src/endpoints/btrzpay/stripe3ds.js +40 -0
  87. package/src/endpoints/btrzpay/terminalPayments.js +19 -19
  88. package/src/endpoints/inventory/banks.js +39 -21
  89. package/src/endpoints/inventory/change-requests.js +59 -31
  90. package/src/endpoints/inventory/control-classes.js +39 -20
  91. package/src/endpoints/inventory/countries.js +25 -10
  92. package/src/endpoints/inventory/custom-content.js +39 -22
  93. package/src/endpoints/inventory/custom-fields.js +25 -19
  94. package/src/endpoints/inventory/document-types.js +34 -33
  95. package/src/endpoints/inventory/external-wallets.js +25 -20
  96. package/src/endpoints/inventory/fees.js +19 -14
  97. package/src/endpoints/inventory/filtered-trips.js +29 -8
  98. package/src/endpoints/inventory/financing-costs.js +19 -14
  99. package/src/endpoints/inventory/garages.js +19 -14
  100. package/src/endpoints/inventory/getnet-terminals.js +20 -15
  101. package/src/endpoints/inventory/gift-certificate-definitions.js +10 -5
  102. package/src/endpoints/inventory/holidays.js +121 -0
  103. package/src/endpoints/inventory/insurances.js +17 -13
  104. package/src/endpoints/inventory/items.js +13 -9
  105. package/src/endpoints/inventory/labels.js +16 -11
  106. package/src/endpoints/inventory/marital-status.js +16 -11
  107. package/src/endpoints/inventory/marketplace-modifiers.js +16 -11
  108. package/src/endpoints/inventory/mit-terminal-settings.js +15 -10
  109. package/src/endpoints/inventory/mit-terminals.js +16 -11
  110. package/src/endpoints/inventory/operation-messages.js +18 -12
  111. package/src/endpoints/inventory/operation-reasons.js +15 -10
  112. package/src/endpoints/inventory/pay-on-accounts.js +5 -4
  113. package/src/endpoints/inventory/payment-terminals.js +15 -10
  114. package/src/endpoints/inventory/products.js +22 -10
  115. package/src/endpoints/inventory/promos.js +27 -18
  116. package/src/endpoints/inventory/segments-information-tables.js +13 -7
  117. package/src/endpoints/inventory/station-groups.js +2 -4
  118. package/src/endpoints/inventory/taxes.js +11 -2
  119. package/src/endpoints/inventory/traveller-card-providers-types.js +6 -5
  120. package/src/endpoints/inventory/trip-ids.js +54 -0
  121. package/src/endpoints/inventory/trips.js +52 -14
  122. package/src/endpoints/inventory/vehicle-types.js +3 -4
  123. package/src/endpoints/inventory/vehicles.js +4 -3
  124. package/src/endpoints/invoices/emails.js +15 -5
  125. package/src/endpoints/invoices/invoices.js +46 -25
  126. package/src/endpoints/invoices/pdfs.js +15 -8
  127. package/src/endpoints/invoices/providers.js +42 -25
  128. package/src/endpoints/invoices/tax-ids.js +11 -7
  129. package/src/endpoints/notifications/customers.js +1 -1
  130. package/src/endpoints/notifications/external-customers.js +41 -0
  131. package/src/endpoints/notifications/pdfs.js +0 -3
  132. package/src/endpoints/operations/accounting_items.js +7 -2
  133. package/src/endpoints/operations/flexpasses.js +9 -7
  134. package/src/endpoints/operations/gift-certificates.js +39 -0
  135. package/src/endpoints/operations/loans.js +16 -11
  136. package/src/endpoints/operations/movements.js +17 -6
  137. package/src/endpoints/operations/pago-express.js +73 -0
  138. package/src/endpoints/operations/parcels.js +11 -11
  139. package/src/endpoints/operations/parcels_manifests.js +7 -5
  140. package/src/endpoints/sales/cancellations.js +43 -31
  141. package/src/endpoints/sales/cart.js +20 -18
  142. package/src/endpoints/sales/flexpasses.js +3 -4
  143. package/src/endpoints/sales/order.js +34 -7
  144. package/src/endpoints/sales/parcel-quotes.js +2 -2
  145. package/test/endpoints/btrzpay/adyen.tests.js +27 -0
  146. package/test/endpoints/btrzpay/carpointe.tests.js +14 -0
  147. package/test/endpoints/btrzpay/customerCards.test.js +9 -6
  148. package/test/endpoints/btrzpay/cybersource3ds.tests.js +55 -0
  149. package/test/endpoints/btrzpay/stripe-terminals.tests.js +5 -6
  150. package/test/endpoints/btrzpay/stripe3ds.tests.js +31 -0
  151. package/test/endpoints/inventory/banks.test.js +8 -10
  152. package/test/endpoints/inventory/filtered-trips.test.js +6 -0
  153. package/test/endpoints/inventory/holidays.test.js +52 -0
  154. package/test/endpoints/inventory/traveller-card-providers-types.test.js +3 -2
  155. package/test/endpoints/inventory/trip-ids.test.js +27 -0
  156. package/test/endpoints/inventory/trips.test.js +19 -14
  157. package/test/endpoints/notifications/external-customers.test.js +30 -0
  158. package/test/endpoints/operations/gift_certificates.test.js +37 -0
  159. package/test/endpoints/operations/operations.test.js +30 -0
  160. package/test/endpoints/sales/order.test.js +7 -1
package/lib/client.js CHANGED
@@ -98,6 +98,7 @@ function createInventory(_ref) {
98
98
  getnetTerminals: require("./endpoints/inventory/getnet-terminals.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
99
99
  giftCertificateDefinitions: require("./endpoints/inventory/gift-certificate-definitions.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
100
100
  healthCheck: require("./endpoints/inventory/healthcheck.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
101
+ holidays: require("./endpoints/inventory/holidays.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
101
102
  insurances: require("./endpoints/inventory/insurances.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
102
103
  insurancesCost: require("./endpoints/inventory/insurancesCost.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
103
104
  items: require("./endpoints/inventory/items.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
@@ -147,9 +148,9 @@ function createInventory(_ref) {
147
148
  }
148
149
 
149
150
  /**
150
- * Creates the trips API client (trips, segmentsInformationTables). Uses inventory base path.
151
+ * Creates the trips API client (trips, tripIds, segmentsInformationTables). Uses inventory base path.
151
152
  * @param {CreateModuleOptions} opts - Client options
152
- * @returns {Object} Object with trips and segmentsInformationTables endpoint namespaces and __test_trips.client
153
+ * @returns {Object} Object with trips, tripIds, segmentsInformationTables endpoint namespaces and __test_trips.client
153
154
  */
154
155
  function createTrips(_ref2) {
155
156
  var baseURL = _ref2.baseURL,
@@ -163,6 +164,7 @@ function createTrips(_ref2) {
163
164
 
164
165
  return {
165
166
  trips: require("./endpoints/inventory/trips.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
167
+ tripIds: require("./endpoints/inventory/trip-ids.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
166
168
  segmentsInformationTables: require("./endpoints/inventory/segments-information-tables.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
167
169
  __test_trips: {
168
170
  client: client
@@ -340,11 +342,13 @@ function createOperations(_ref6) {
340
342
  calendarEntries: require("./endpoints/operations/calendar_entries.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
341
343
  externalBookings: require("./endpoints/operations/external-bookings.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
342
344
  flexpasses: require("./endpoints/operations/flexpasses.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
345
+ giftCertificates: require("./endpoints/operations/gift-certificates.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
343
346
  loans: require("./endpoints/operations/loans.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
344
347
  manifest: require("./endpoints/operations/manifest.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
345
348
  manifestLegForTickets: require("./endpoints/operations/manifest_leg_for_tickets.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
346
349
  movements: require("./endpoints/operations/movements.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
347
350
  outlookTrips: require("./endpoints/operations/outlook-trips.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
351
+ pagoExpress: require("./endpoints/operations/pago-express.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
348
352
  parcel: require("./endpoints/operations/parcels.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
349
353
  parcelManifests: require("./endpoints/operations/parcels_manifests.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
350
354
  passengerCheckInInfo: require("./endpoints/operations/passenger_check_in_info.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
@@ -417,6 +421,7 @@ function createNotifications(_ref8) {
417
421
  pdfData: require("./endpoints/notifications/pdf-data.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
418
422
  email: require("./endpoints/notifications/email.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
419
423
  customers: require("./endpoints/notifications/customers.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
424
+ externalCustomers: require("./endpoints/notifications/external-customers.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
420
425
  twilio: require("./endpoints/notifications/twilio.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
421
426
  salesforce: require("./endpoints/notifications/salesforce.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
422
427
  notify: require("./endpoints/notifications/notify.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
@@ -541,6 +546,8 @@ function createBtrzPay(_ref13) {
541
546
  var client = clientFactory({ baseURL: baseURL, headers: headers, timeout: timeout, overrideFn: overrideFn, agents: agents });
542
547
 
543
548
  return {
549
+ adyen: require("./endpoints/btrzpay/adyen.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
550
+ cybersource3ds: require("./endpoints/btrzpay/cybersource3ds.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
544
551
  docs: require("./endpoints/btrzpay/docs.js")({ client: client }),
545
552
  cardpointeTerminals: require("./endpoints/btrzpay/cardpointe.js").cardpointeTerminalsFactory({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
546
553
  paymentMethods: require("./endpoints/btrzpay/payment-methods.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
@@ -556,6 +563,7 @@ function createBtrzPay(_ref13) {
556
563
  prismaTerminals: require("./endpoints/btrzpay/prismaTerminals.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
557
564
  terminalPayments: require("./endpoints/btrzpay/terminalPayments.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
558
565
  stripeTerminals: require("./endpoints/btrzpay/stripe-terminals.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
566
+ stripe3ds: require("./endpoints/btrzpay/stripe3ds.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
559
567
  __test: {
560
568
  client: client
561
569
  }
@@ -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 - create read card. API does not accept query params.
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 /payment-methods/:paymentMethodId/customers/:customerId/cards/:customerCardId - get card. API does not accept query params.
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 id
25
- * @param {string} opts.customerId - Customer id
26
- * @param {string} opts.customerCardId - Customer card id
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 /payment-methods/:paymentMethodId/customers/:customerId/cards - list cards. API does not accept query params.
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 id
50
- * @param {string} opts.customerId - Customer id
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 /payment-methods/:paymentMethodId/customers/:customerId/cards - create card. API does not accept query params.
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 id
73
- * @param {string} opts.customerId - Customer id
74
- * @param {Object} opts.customerCard - Customer card payload
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 /payment-methods/:paymentMethodId/customers/:customerId/cards/:customerCardId - remove card. API does not accept query params.
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 id
100
- * @param {string} opts.customerId - Customer id
101
- * @param {string} opts.customerCardId - Customer card id
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 /payment-methods/:paymentMethodId/customers/:customerId - get customer. API does not accept query params.
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 id
25
- * @param {string} opts.customerId - Customer id
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 /payment-methods/:paymentMethodId/customers - create customer. API does not accept query params.
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 id
48
- * @param {Object} opts.customer - Customer payload
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 /payment-methods/:paymentMethodId/customers/:customerId - remove customer. API does not accept query params.
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 id
73
- * @param {string} opts.customerId - Customer id
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;