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
@@ -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 - create read card. API does not accept query params.
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 /payment-methods/:paymentMethodId/customers/:customerId/cards/:customerCardId - get card. API does not accept query params.
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 id
17
- * @param {string} opts.customerId - Customer id
18
- * @param {string} opts.customerCardId - Customer card id
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 /payment-methods/:paymentMethodId/customers/:customerId/cards - list cards. API does not accept query params.
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 id
35
- * @param {string} opts.customerId - Customer id
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 /payment-methods/:paymentMethodId/customers/:customerId/cards - create card. API does not accept query params.
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 id
52
- * @param {string} opts.customerId - Customer id
53
- * @param {Object} opts.customerCard - Customer card payload
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 /payment-methods/:paymentMethodId/customers/:customerId/cards/:customerCardId - remove card. API does not accept query params.
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 id
72
- * @param {string} opts.customerId - Customer id
73
- * @param {string} opts.customerCardId - Customer card id
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 /payment-methods/:paymentMethodId/customers/:customerId - get customer. API does not accept query params.
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 id
17
- * @param {string} opts.customerId - Customer id
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 /payment-methods/:paymentMethodId/customers - create customer. API does not accept query params.
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 id
34
- * @param {Object} opts.customer - Customer payload
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 /payment-methods/:paymentMethodId/customers/:customerId - remove customer. API does not accept query params.
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 id
53
- * @param {string} opts.customerId - Customer id
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;
@@ -5,104 +5,139 @@ const {
5
5
  /**
6
6
  * Query params for GET /datalogic/payments (btrz-api-payments). See get-payments-handler getSpec().
7
7
  * @typedef {Object} DatalogicPaymentsListQuery
8
- * @property {string} [referenceNumber] - The payment reference number
8
+ * @property {string} referenceNumber - Payment reference number (required)
9
9
  */
10
10
 
11
11
  /**
12
- * Factory for Datalogic API (btrz-api-payments).
12
+ * Request body for POST /datalogic/payments/:referenceNumber. PostDatalogicPaymentsPayload.
13
+ * @typedef {Object} PostDatalogicPaymentsPayload
14
+ * @property {string} folio - FEMSA transaction id
15
+ * @property {number} id_terminal - Terminal/group ID
16
+ * @property {string} local_date - Local date (e.g. "02/08/2022 20:33:43")
17
+ * @property {string} amount - Debt amount
18
+ * @property {number} trx_no - Transaction number
19
+ */
20
+
21
+ /**
22
+ * Request body for POST /datalogic/reverse/:referenceNumber. PostDatalogicReversePayload.
23
+ * @typedef {Object} PostDatalogicReversePayload
24
+ * @property {string} folio - FEMSA transaction id
25
+ * @property {number} id_terminal - Terminal/group ID
26
+ * @property {string} local_date - Local date (e.g. "02/08/2022 20:33:43")
27
+ * @property {number} trx_no - Transaction number
28
+ */
29
+
30
+ /**
31
+ * Factory for Datalogic API (btrz-api-payments). Endpoints are hideInDocumentation; client for internal use.
13
32
  * @param {Object} deps
14
33
  * @param {import("axios").AxiosInstance} deps.client
15
34
  * @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
16
35
  * @returns {{ payments: Object, referenceNumber: Object, authCode: Object }}
17
36
  */
18
- function datalogicFactory({client}) {
37
+ function datalogicFactory({client, internalAuthTokenProvider}) {
38
+ function authProvider(opts) {
39
+ return opts !== undefined && opts !== null ? opts : internalAuthTokenProvider;
40
+ }
41
+
19
42
  const payments = {
20
43
  /**
21
- * GET /datalogic/payments - list Datalogic payments.
44
+ * GET /datalogic/payments - list Datalogic payments by reference number.
22
45
  * @param {Object} opts
23
46
  * @param {string} [opts.token] - API key
24
47
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
25
- * @param {DatalogicPaymentsListQuery} [opts.query] - Query params (referenceNumber)
48
+ * @param {DatalogicPaymentsListQuery} opts.query - referenceNumber (required)
26
49
  * @param {Object} [opts.headers] - Optional headers
27
- * @returns {Promise<import("axios").AxiosResponse>}
50
+ * @param {{ getToken: function(): string }} [opts.internalAuthTokenProvider] - Internal auth provider
51
+ * @returns {Promise<import("axios").AxiosResponse<{ payments: Array }>>}
52
+ * GetDatalogicPaymentsResponse. Rejects 400, 401, 500.
28
53
  */
29
- all({token, jwtToken, headers, query, internalAuthTokenProvider}) {
54
+ all({token, jwtToken, headers, query, internalAuthTokenProvider: optsAuth}) {
30
55
  return client({
31
56
  url: "/datalogic/payments",
32
57
  params: query,
33
- headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
58
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider: authProvider(optsAuth), headers})
34
59
  });
35
60
  },
36
61
  /**
37
- * POST /datalogic/payments/:referenceNumber - update Datalogic payment. API does not accept query params.
62
+ * POST /datalogic/payments/:referenceNumber - pay by reference (20 digits).
63
+ * Body: datalogicInfo or flat PostDatalogicPaymentsPayload.
38
64
  * @param {Object} opts
39
65
  * @param {string} [opts.token] - API key
40
66
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
41
- * @param {string} opts.referenceNumber - Reference number
42
- * @param {Object} [opts.data] - Request body
67
+ * @param {string} opts.referenceNumber - Reference number (20 digits)
68
+ * @param {PostDatalogicPaymentsPayload|{ datalogicInfo: PostDatalogicPaymentsPayload }} opts.data - Body
43
69
  * @param {Object} [opts.headers] - Optional headers
44
- * @returns {Promise<import("axios").AxiosResponse>}
70
+ * @param {{ getToken: function(): string }} [opts.internalAuthTokenProvider] - Internal auth provider
71
+ * @returns {Promise<import("axios").AxiosResponse<{ payment: Object }>>}
72
+ * PostDatalogicPaymentsResponse. Rejects 400, 401, 500.
45
73
  */
46
- update({token, jwtToken, headers, query, referenceNumber, data, internalAuthTokenProvider}) {
74
+ update({token, jwtToken, headers, query, referenceNumber, data, internalAuthTokenProvider: optsAuth}) {
47
75
  return client({
48
76
  url: `/datalogic/payments/${referenceNumber}`,
49
77
  method: "post",
50
78
  params: query,
51
79
  data,
52
- headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
80
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider: authProvider(optsAuth), headers})
53
81
  });
54
82
  },
55
83
  /**
56
- * POST /datalogic/reverse/:referenceNumber - reverse Datalogic payment. API does not accept query params.
84
+ * POST /datalogic/reverse/:referenceNumber - reverse by reference (20 digits).
85
+ * Body: datalogicReverseInfo or flat PostDatalogicReversePayload.
57
86
  * @param {Object} opts
58
87
  * @param {string} [opts.token] - API key
59
88
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
60
- * @param {string} opts.referenceNumber - Reference number
61
- * @param {Object} [opts.data] - Request body
89
+ * @param {string} opts.referenceNumber - Reference number (20 digits)
90
+ * @param {PostDatalogicReversePayload|{ datalogicReverseInfo: PostDatalogicReversePayload }} opts.data - Body
62
91
  * @param {Object} [opts.headers] - Optional headers
63
- * @returns {Promise<import("axios").AxiosResponse>}
92
+ * @param {{ getToken: function(): string }} [opts.internalAuthTokenProvider] - Internal auth provider
93
+ * @returns {Promise<import("axios").AxiosResponse<{ payment: Object }>>}
94
+ * PostDatalogicPaymentsResponse. Rejects 400, 401, 500.
64
95
  */
65
- reverse({token, jwtToken, headers, query, referenceNumber, data, internalAuthTokenProvider}) {
96
+ reverse({token, jwtToken, headers, query, referenceNumber, data, internalAuthTokenProvider: optsAuth}) {
66
97
  return client({
67
98
  url: `/datalogic/reverse/${referenceNumber}`,
68
99
  method: "post",
69
100
  params: query,
70
101
  data,
71
- headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
102
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider: authProvider(optsAuth), headers})
72
103
  });
73
104
  }
74
105
  };
75
106
 
76
107
  const referenceNumber = {
77
108
  /**
78
- * GET /datalogic/reference-number - get reference number. API does not accept query params.
109
+ * GET /datalogic/reference-number - get new Datalogic reference number.
79
110
  * @param {Object} opts
80
111
  * @param {string} [opts.token] - API key
81
112
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
82
113
  * @param {Object} [opts.headers] - Optional headers
83
- * @returns {Promise<import("axios").AxiosResponse>}
114
+ * @param {{ getToken: function(): string }} [opts.internalAuthTokenProvider] - Internal auth provider
115
+ * @returns {Promise<import("axios").AxiosResponse<{ referenceNumber: string }>>}
116
+ * GetDatalogicReferenceNumberResponse. Rejects 401, 404, 500.
84
117
  */
85
- get({token, jwtToken, headers, internalAuthTokenProvider}) {
118
+ get({token, jwtToken, headers, internalAuthTokenProvider: optsAuth}) {
86
119
  return client({
87
120
  url: "/datalogic/reference-number",
88
- headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
121
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider: authProvider(optsAuth), headers})
89
122
  });
90
123
  }
91
124
  };
92
125
 
93
126
  const authCode = {
94
127
  /**
95
- * GET /datalogic/auth-code - get auth code. API does not accept query params.
128
+ * GET /datalogic/auth-code - get new Datalogic authorization code.
96
129
  * @param {Object} opts
97
130
  * @param {string} [opts.token] - API key
98
131
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
99
132
  * @param {Object} [opts.headers] - Optional headers
100
- * @returns {Promise<import("axios").AxiosResponse>}
133
+ * @param {{ getToken: function(): string }} [opts.internalAuthTokenProvider] - Internal auth provider
134
+ * @returns {Promise<import("axios").AxiosResponse<{ authCode: string }>>}
135
+ * GetDatalogicAuthCodeResponse. Rejects 401, 404, 500.
101
136
  */
102
- get({token, jwtToken, headers, internalAuthTokenProvider}) {
137
+ get({token, jwtToken, headers, internalAuthTokenProvider: optsAuth}) {
103
138
  return client({
104
139
  url: "/datalogic/auth-code",
105
- headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
140
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider: authProvider(optsAuth), headers})
106
141
  });
107
142
  }
108
143
  };