@etohq/utils 1.4.0 → 1.5.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 (337) hide show
  1. package/dist/analytics/abstract-analytics-provider.d.ts +110 -0
  2. package/dist/analytics/abstract-analytics-provider.d.ts.map +1 -0
  3. package/dist/analytics/abstract-analytics-provider.js +107 -0
  4. package/dist/analytics/abstract-analytics-provider.js.map +1 -0
  5. package/dist/analytics/index.d.ts +2 -0
  6. package/dist/analytics/index.d.ts.map +1 -0
  7. package/dist/analytics/index.js +18 -0
  8. package/dist/analytics/index.js.map +1 -0
  9. package/dist/auth/token.d.ts +4 -2
  10. package/dist/auth/token.d.ts.map +1 -1
  11. package/dist/auth/token.js +5 -2
  12. package/dist/auth/token.js.map +1 -1
  13. package/dist/bundles.d.ts +1 -0
  14. package/dist/bundles.d.ts.map +1 -1
  15. package/dist/bundles.js +2 -1
  16. package/dist/bundles.js.map +1 -1
  17. package/dist/common/build-query.d.ts +1 -1
  18. package/dist/common/build-query.d.ts.map +1 -1
  19. package/dist/common/compress-name.d.ts +2 -0
  20. package/dist/common/compress-name.d.ts.map +1 -0
  21. package/dist/common/compress-name.js +34 -0
  22. package/dist/common/compress-name.js.map +1 -0
  23. package/dist/common/container.d.ts +98 -0
  24. package/dist/common/container.d.ts.map +1 -1
  25. package/dist/common/container.js +94 -0
  26. package/dist/common/container.js.map +1 -1
  27. package/dist/common/create-psql-index-helper.d.ts +1 -1
  28. package/dist/common/define-config.d.ts +4 -4
  29. package/dist/common/define-config.d.ts.map +1 -1
  30. package/dist/common/define-config.js +45 -26
  31. package/dist/common/define-config.js.map +1 -1
  32. package/dist/common/errors.d.ts +3 -0
  33. package/dist/common/errors.d.ts.map +1 -1
  34. package/dist/common/errors.js +1 -0
  35. package/dist/common/errors.js.map +1 -1
  36. package/dist/common/exec-mode.d.ts +2 -0
  37. package/dist/common/exec-mode.d.ts.map +1 -0
  38. package/dist/common/exec-mode.js +15 -0
  39. package/dist/common/exec-mode.js.map +1 -0
  40. package/dist/common/flatten-object-to-key-value-pairs.d.ts.map +1 -1
  41. package/dist/common/flatten-object-to-key-value-pairs.js +214 -72
  42. package/dist/common/flatten-object-to-key-value-pairs.js.map +1 -1
  43. package/dist/common/get-resolved-plugins.d.ts +4 -0
  44. package/dist/common/get-resolved-plugins.d.ts.map +1 -0
  45. package/dist/common/get-resolved-plugins.js +121 -0
  46. package/dist/common/get-resolved-plugins.js.map +1 -0
  47. package/dist/common/get-selects-and-relations-from-object-array.d.ts +2 -1
  48. package/dist/common/get-selects-and-relations-from-object-array.d.ts.map +1 -1
  49. package/dist/common/get-selects-and-relations-from-object-array.js +7 -5
  50. package/dist/common/get-selects-and-relations-from-object-array.js.map +1 -1
  51. package/dist/common/index.d.ts +19 -5
  52. package/dist/common/index.d.ts.map +1 -1
  53. package/dist/common/index.js +19 -5
  54. package/dist/common/index.js.map +1 -1
  55. package/dist/common/load-env.d.ts +3 -0
  56. package/dist/common/load-env.d.ts.map +1 -1
  57. package/dist/common/load-env.js +7 -4
  58. package/dist/common/load-env.js.map +1 -1
  59. package/dist/common/math.d.ts +2 -2
  60. package/dist/common/math.d.ts.map +1 -1
  61. package/dist/common/math.js +13 -6
  62. package/dist/common/math.js.map +1 -1
  63. package/dist/common/merge-metadata.d.ts +15 -0
  64. package/dist/common/merge-metadata.d.ts.map +1 -0
  65. package/dist/common/merge-metadata.js +34 -0
  66. package/dist/common/merge-metadata.js.map +1 -0
  67. package/dist/common/normalize-csv-value.d.ts +6 -0
  68. package/dist/common/normalize-csv-value.d.ts.map +1 -0
  69. package/dist/common/normalize-csv-value.js +14 -0
  70. package/dist/common/normalize-csv-value.js.map +1 -0
  71. package/dist/common/retry-execution.d.ts +18 -0
  72. package/dist/common/retry-execution.d.ts.map +1 -0
  73. package/dist/common/retry-execution.js +50 -0
  74. package/dist/common/retry-execution.js.map +1 -0
  75. package/dist/common/to-unix-slash.d.ts +2 -0
  76. package/dist/common/to-unix-slash.d.ts.map +1 -0
  77. package/dist/common/to-unix-slash.js +11 -0
  78. package/dist/common/to-unix-slash.js.map +1 -0
  79. package/dist/common/try-convert-to-boolean.d.ts +7 -0
  80. package/dist/common/try-convert-to-boolean.d.ts.map +1 -0
  81. package/dist/common/try-convert-to-boolean.js +15 -0
  82. package/dist/common/try-convert-to-boolean.js.map +1 -0
  83. package/dist/common/try-convert-to-number.d.ts +7 -0
  84. package/dist/common/try-convert-to-number.d.ts.map +1 -0
  85. package/dist/common/try-convert-to-number.js +10 -0
  86. package/dist/common/try-convert-to-number.js.map +1 -0
  87. package/dist/common/unflatten-object-keys.d.ts +29 -0
  88. package/dist/common/unflatten-object-keys.d.ts.map +1 -0
  89. package/dist/common/unflatten-object-keys.js +67 -0
  90. package/dist/common/unflatten-object-keys.js.map +1 -0
  91. package/dist/common/validate-module-name.d.ts +2 -0
  92. package/dist/common/validate-module-name.d.ts.map +1 -0
  93. package/dist/common/validate-module-name.js +27 -0
  94. package/dist/common/validate-module-name.js.map +1 -0
  95. package/dist/common/wrap-handler.d.ts +2 -0
  96. package/dist/common/wrap-handler.d.ts.map +1 -0
  97. package/dist/common/wrap-handler.js +40 -0
  98. package/dist/common/wrap-handler.js.map +1 -0
  99. package/dist/core-flows/events.d.ts +57 -0
  100. package/dist/core-flows/events.d.ts.map +1 -1
  101. package/dist/core-flows/events.js +58 -8
  102. package/dist/core-flows/events.js.map +1 -1
  103. package/dist/dal/index.d.ts +1 -0
  104. package/dist/dal/index.d.ts.map +1 -1
  105. package/dist/dal/index.js +1 -0
  106. package/dist/dal/index.js.map +1 -1
  107. package/dist/dal/mikro-orm/big-number-field.d.ts.map +1 -1
  108. package/dist/dal/mikro-orm/big-number-field.js +36 -21
  109. package/dist/dal/mikro-orm/big-number-field.js.map +1 -1
  110. package/dist/dal/mikro-orm/mikro-orm-create-connection.d.ts +10 -4
  111. package/dist/dal/mikro-orm/mikro-orm-create-connection.d.ts.map +1 -1
  112. package/dist/dal/mikro-orm/mikro-orm-create-connection.js +53 -11
  113. package/dist/dal/mikro-orm/mikro-orm-create-connection.js.map +1 -1
  114. package/dist/dal/mikro-orm/mikro-orm-free-text-search-filter.d.ts +3 -6
  115. package/dist/dal/mikro-orm/mikro-orm-free-text-search-filter.d.ts.map +1 -1
  116. package/dist/dal/mikro-orm/mikro-orm-free-text-search-filter.js +16 -21
  117. package/dist/dal/mikro-orm/mikro-orm-free-text-search-filter.js.map +1 -1
  118. package/dist/dal/mikro-orm/mikro-orm-repository.d.ts +4 -7
  119. package/dist/dal/mikro-orm/mikro-orm-repository.d.ts.map +1 -1
  120. package/dist/dal/mikro-orm/mikro-orm-repository.js +94 -79
  121. package/dist/dal/mikro-orm/mikro-orm-repository.js.map +1 -1
  122. package/dist/dal/mikro-orm/mikro-orm-serializer.d.ts +7 -3
  123. package/dist/dal/mikro-orm/mikro-orm-serializer.d.ts.map +1 -1
  124. package/dist/dal/mikro-orm/mikro-orm-serializer.js +18 -15
  125. package/dist/dal/mikro-orm/mikro-orm-serializer.js.map +1 -1
  126. package/dist/dal/mikro-orm/sql-migration-generator.d.ts +6 -4
  127. package/dist/dal/mikro-orm/sql-migration-generator.d.ts.map +1 -1
  128. package/dist/dal/mikro-orm/sql-migration-generator.js +120 -70
  129. package/dist/dal/mikro-orm/sql-migration-generator.js.map +1 -1
  130. package/dist/dal/mikro-orm/utils.d.ts +14 -1
  131. package/dist/dal/mikro-orm/utils.d.ts.map +1 -1
  132. package/dist/dal/mikro-orm/utils.js +82 -38
  133. package/dist/dal/mikro-orm/utils.js.map +1 -1
  134. package/dist/defaults/countries.d.ts.map +1 -1
  135. package/dist/defaults/countries.js +0 -6
  136. package/dist/defaults/countries.js.map +1 -1
  137. package/dist/defaults/currencies.d.ts.map +1 -1
  138. package/dist/defaults/currencies.js +9 -0
  139. package/dist/defaults/currencies.js.map +1 -1
  140. package/dist/dml/entity-builder.d.ts.map +1 -1
  141. package/dist/dml/entity-builder.js.map +1 -1
  142. package/dist/dml/entity.d.ts +4 -5
  143. package/dist/dml/entity.d.ts.map +1 -1
  144. package/dist/dml/entity.js +0 -2
  145. package/dist/dml/entity.js.map +1 -1
  146. package/dist/dml/helpers/create-graphql.d.ts.map +1 -1
  147. package/dist/dml/helpers/create-graphql.js +27 -2
  148. package/dist/dml/helpers/create-graphql.js.map +1 -1
  149. package/dist/dml/helpers/create-mikro-orm-entity.d.ts.map +1 -1
  150. package/dist/dml/helpers/create-mikro-orm-entity.js +9 -6
  151. package/dist/dml/helpers/create-mikro-orm-entity.js.map +1 -1
  152. package/dist/dml/helpers/entity-builder/define-property.d.ts.map +1 -1
  153. package/dist/dml/helpers/entity-builder/define-property.js +9 -7
  154. package/dist/dml/helpers/entity-builder/define-property.js.map +1 -1
  155. package/dist/dml/helpers/entity-builder/define-relationship.d.ts +1 -1
  156. package/dist/dml/helpers/entity-builder/define-relationship.d.ts.map +1 -1
  157. package/dist/dml/helpers/entity-builder/define-relationship.js +41 -25
  158. package/dist/dml/helpers/entity-builder/define-relationship.js.map +1 -1
  159. package/dist/dml/helpers/entity-builder/index.d.ts +1 -0
  160. package/dist/dml/helpers/entity-builder/index.d.ts.map +1 -1
  161. package/dist/dml/helpers/entity-builder/index.js +1 -0
  162. package/dist/dml/helpers/entity-builder/index.js.map +1 -1
  163. package/dist/dml/helpers/entity-builder/relationship-helpers.d.ts +6 -0
  164. package/dist/dml/helpers/entity-builder/relationship-helpers.d.ts.map +1 -0
  165. package/dist/dml/helpers/entity-builder/relationship-helpers.js +12 -0
  166. package/dist/dml/helpers/entity-builder/relationship-helpers.js.map +1 -0
  167. package/dist/dml/helpers/graphql-builder/get-attribute.js +2 -2
  168. package/dist/dml/helpers/graphql-builder/get-attribute.js.map +1 -1
  169. package/dist/dml/index.d.ts +1 -1
  170. package/dist/dml/index.d.ts.map +1 -1
  171. package/dist/dml/index.js +1 -1
  172. package/dist/dml/index.js.map +1 -1
  173. package/dist/dml/integration-tests/utils.js +1 -1
  174. package/dist/dml/integration-tests/utils.js.map +1 -1
  175. package/dist/dml/properties/autoincrement.d.ts +20 -1
  176. package/dist/dml/properties/autoincrement.d.ts.map +1 -1
  177. package/dist/dml/properties/autoincrement.js +19 -0
  178. package/dist/dml/properties/autoincrement.js.map +1 -1
  179. package/dist/dml/properties/number.d.ts +20 -1
  180. package/dist/dml/properties/number.d.ts.map +1 -1
  181. package/dist/dml/properties/number.js +19 -0
  182. package/dist/dml/properties/number.js.map +1 -1
  183. package/dist/event-bus/index.d.ts +1 -1
  184. package/dist/event-bus/index.d.ts.map +1 -1
  185. package/dist/event-bus/index.js +5 -6
  186. package/dist/event-bus/index.js.map +1 -1
  187. package/dist/event-bus/message-aggregator.js +1 -1
  188. package/dist/event-bus/message-aggregator.js.map +1 -1
  189. package/dist/feature-flags/eto-v2.d.ts +3 -0
  190. package/dist/feature-flags/eto-v2.d.ts.map +1 -0
  191. package/dist/feature-flags/eto-v2.js +10 -0
  192. package/dist/feature-flags/eto-v2.js.map +1 -0
  193. package/dist/feature-flags/many-to-many-inventory.d.ts +3 -0
  194. package/dist/feature-flags/many-to-many-inventory.d.ts.map +1 -0
  195. package/dist/feature-flags/many-to-many-inventory.js +10 -0
  196. package/dist/feature-flags/many-to-many-inventory.js.map +1 -0
  197. package/dist/feature-flags/order-editing.d.ts +3 -0
  198. package/dist/feature-flags/order-editing.d.ts.map +1 -0
  199. package/dist/feature-flags/order-editing.js +10 -0
  200. package/dist/feature-flags/order-editing.js.map +1 -0
  201. package/dist/feature-flags/product-categories.d.ts +3 -0
  202. package/dist/feature-flags/product-categories.d.ts.map +1 -0
  203. package/dist/feature-flags/product-categories.js +10 -0
  204. package/dist/feature-flags/product-categories.js.map +1 -0
  205. package/dist/feature-flags/sales-channels.d.ts +3 -0
  206. package/dist/feature-flags/sales-channels.d.ts.map +1 -0
  207. package/dist/feature-flags/sales-channels.js +10 -0
  208. package/dist/feature-flags/sales-channels.js.map +1 -0
  209. package/dist/feature-flags/tax-inclusive-pricing.d.ts +3 -0
  210. package/dist/feature-flags/tax-inclusive-pricing.d.ts.map +1 -0
  211. package/dist/feature-flags/tax-inclusive-pricing.js +10 -0
  212. package/dist/feature-flags/tax-inclusive-pricing.js.map +1 -0
  213. package/dist/file/abstract-file-provider.d.ts +70 -11
  214. package/dist/file/abstract-file-provider.d.ts.map +1 -1
  215. package/dist/file/abstract-file-provider.js +73 -11
  216. package/dist/file/abstract-file-provider.js.map +1 -1
  217. package/dist/graphql/graphql-to-ts-types.d.ts.map +1 -1
  218. package/dist/graphql/graphql-to-ts-types.js +23 -2
  219. package/dist/graphql/graphql-to-ts-types.js.map +1 -1
  220. package/dist/index.d.ts +1 -0
  221. package/dist/index.d.ts.map +1 -1
  222. package/dist/index.js +1 -0
  223. package/dist/index.js.map +1 -1
  224. package/dist/migrations/index.d.ts +8 -0
  225. package/dist/migrations/index.d.ts.map +1 -1
  226. package/dist/migrations/index.js +27 -2
  227. package/dist/migrations/index.js.map +1 -1
  228. package/dist/modules-sdk/build-query.d.ts.map +1 -1
  229. package/dist/modules-sdk/build-query.js +14 -13
  230. package/dist/modules-sdk/build-query.js.map +1 -1
  231. package/dist/modules-sdk/create-pg-connection.d.ts +2 -1
  232. package/dist/modules-sdk/create-pg-connection.d.ts.map +1 -1
  233. package/dist/modules-sdk/create-pg-connection.js +1 -1
  234. package/dist/modules-sdk/decorators/inject-manager.d.ts.map +1 -1
  235. package/dist/modules-sdk/decorators/inject-manager.js +6 -0
  236. package/dist/modules-sdk/decorators/inject-manager.js.map +1 -1
  237. package/dist/modules-sdk/decorators/inject-transaction-manager.js +5 -5
  238. package/dist/modules-sdk/decorators/inject-transaction-manager.js.map +1 -1
  239. package/dist/modules-sdk/define-link.d.ts +2 -0
  240. package/dist/modules-sdk/define-link.d.ts.map +1 -1
  241. package/dist/modules-sdk/define-link.js +16 -0
  242. package/dist/modules-sdk/define-link.js.map +1 -1
  243. package/dist/modules-sdk/definition.d.ts +9 -0
  244. package/dist/modules-sdk/definition.d.ts.map +1 -1
  245. package/dist/modules-sdk/definition.js +5 -2
  246. package/dist/modules-sdk/definition.js.map +1 -1
  247. package/dist/modules-sdk/eto-internal-service.d.ts.map +1 -1
  248. package/dist/modules-sdk/eto-internal-service.js +35 -37
  249. package/dist/modules-sdk/eto-internal-service.js.map +1 -1
  250. package/dist/modules-sdk/eto-service.d.ts.map +1 -1
  251. package/dist/modules-sdk/eto-service.js +25 -41
  252. package/dist/modules-sdk/eto-service.js.map +1 -1
  253. package/dist/modules-sdk/event-builder-factory.js +9 -9
  254. package/dist/modules-sdk/event-builder-factory.js.map +1 -1
  255. package/dist/modules-sdk/joiner-config-builder.js +1 -1
  256. package/dist/modules-sdk/joiner-config-builder.js.map +1 -1
  257. package/dist/modules-sdk/load-module-database-config.d.ts.map +1 -1
  258. package/dist/modules-sdk/load-module-database-config.js +3 -0
  259. package/dist/modules-sdk/load-module-database-config.js.map +1 -1
  260. package/dist/modules-sdk/loaders/mikro-orm-connection-loader.d.ts.map +1 -1
  261. package/dist/modules-sdk/loaders/mikro-orm-connection-loader.js +0 -7
  262. package/dist/modules-sdk/loaders/mikro-orm-connection-loader.js.map +1 -1
  263. package/dist/modules-sdk/migration-scripts/index.d.ts +1 -0
  264. package/dist/modules-sdk/migration-scripts/index.d.ts.map +1 -1
  265. package/dist/modules-sdk/migration-scripts/index.js +1 -0
  266. package/dist/modules-sdk/migration-scripts/index.js.map +1 -1
  267. package/dist/modules-sdk/migration-scripts/migration-down.js +2 -2
  268. package/dist/modules-sdk/migration-scripts/migration-down.js.map +1 -1
  269. package/dist/modules-sdk/migration-scripts/migration-generate.d.ts.map +1 -1
  270. package/dist/modules-sdk/migration-scripts/migration-generate.js +7 -3
  271. package/dist/modules-sdk/migration-scripts/migration-generate.js.map +1 -1
  272. package/dist/modules-sdk/migration-scripts/migration-up.js +2 -2
  273. package/dist/modules-sdk/migration-scripts/migration-up.js.map +1 -1
  274. package/dist/modules-sdk/migration-scripts/service-migration-generate.d.ts +7 -0
  275. package/dist/modules-sdk/migration-scripts/service-migration-generate.d.ts.map +1 -0
  276. package/dist/modules-sdk/migration-scripts/service-migration-generate.js +49 -0
  277. package/dist/modules-sdk/migration-scripts/service-migration-generate.js.map +1 -0
  278. package/dist/modules-sdk/mikro-orm-cli-config-builder.d.ts +0 -1
  279. package/dist/modules-sdk/mikro-orm-cli-config-builder.d.ts.map +1 -1
  280. package/dist/modules-sdk/mikro-orm-cli-config-builder.js +7 -6
  281. package/dist/modules-sdk/mikro-orm-cli-config-builder.js.map +1 -1
  282. package/dist/modules-sdk/module.d.ts.map +1 -1
  283. package/dist/modules-sdk/module.js +12 -14
  284. package/dist/modules-sdk/module.js.map +1 -1
  285. package/dist/modules-sdk/modules-to-container-types.d.ts.map +1 -1
  286. package/dist/modules-sdk/modules-to-container-types.js +30 -3
  287. package/dist/modules-sdk/modules-to-container-types.js.map +1 -1
  288. package/dist/modules-sdk/query-context.d.ts +2 -2
  289. package/dist/modules-sdk/query-context.d.ts.map +1 -1
  290. package/dist/modules-sdk/query-context.js.map +1 -1
  291. package/dist/modules-sdk/types/eto-service.d.ts +34 -10
  292. package/dist/modules-sdk/types/eto-service.d.ts.map +1 -1
  293. package/dist/notification/abstract-notification-provider.d.ts +10 -0
  294. package/dist/notification/abstract-notification-provider.d.ts.map +1 -1
  295. package/dist/notification/abstract-notification-provider.js.map +1 -1
  296. package/dist/payment/abstract-payment-provider.d.ts +253 -263
  297. package/dist/payment/abstract-payment-provider.d.ts.map +1 -1
  298. package/dist/payment/abstract-payment-provider.js +7 -15
  299. package/dist/payment/abstract-payment-provider.js.map +1 -1
  300. package/dist/payment/index.d.ts +0 -2
  301. package/dist/payment/index.d.ts.map +1 -1
  302. package/dist/payment/index.js +0 -2
  303. package/dist/payment/index.js.map +1 -1
  304. package/dist/payment/payment-collection.d.ts +13 -1
  305. package/dist/payment/payment-collection.d.ts.map +1 -1
  306. package/dist/payment/payment-collection.js +12 -0
  307. package/dist/payment/payment-collection.js.map +1 -1
  308. package/dist/payment/webhook.d.ts +13 -1
  309. package/dist/payment/webhook.d.ts.map +1 -1
  310. package/dist/payment/webhook.js +13 -1
  311. package/dist/payment/webhook.js.map +1 -1
  312. package/dist/totals/big-number.d.ts +23 -0
  313. package/dist/totals/big-number.d.ts.map +1 -0
  314. package/dist/totals/big-number.js +115 -0
  315. package/dist/totals/big-number.js.map +1 -0
  316. package/dist/totals/create-raw-properties-from-bignumber.d.ts +5 -0
  317. package/dist/totals/create-raw-properties-from-bignumber.d.ts.map +1 -0
  318. package/dist/totals/create-raw-properties-from-bignumber.js +52 -0
  319. package/dist/totals/create-raw-properties-from-bignumber.js.map +1 -0
  320. package/dist/totals/index.d.ts +6 -0
  321. package/dist/totals/index.d.ts.map +1 -0
  322. package/dist/totals/index.js +22 -0
  323. package/dist/totals/index.js.map +1 -0
  324. package/dist/totals/math.d.ts +24 -0
  325. package/dist/totals/math.d.ts.map +1 -0
  326. package/dist/totals/math.js +106 -0
  327. package/dist/totals/math.js.map +1 -0
  328. package/dist/totals/transform-properties-to-bignumber.d.ts +6 -0
  329. package/dist/totals/transform-properties-to-bignumber.d.ts.map +1 -0
  330. package/dist/totals/transform-properties-to-bignumber.js +40 -0
  331. package/dist/totals/transform-properties-to-bignumber.js.map +1 -0
  332. package/dist/tsconfig.tsbuildinfo +1 -1
  333. package/package.json +10 -10
  334. package/dist/payment/get-smallest-unit.d.ts +0 -17
  335. package/dist/payment/get-smallest-unit.d.ts.map +0 -1
  336. package/dist/payment/get-smallest-unit.js +0 -68
  337. package/dist/payment/get-smallest-unit.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { CreatePaymentProviderSession, IPaymentProvider, PaymentProviderError, PaymentProviderSessionResponse, PaymentSessionStatus, ProviderWebhookPayload, UpdatePaymentProviderSession, WebhookActionResult } from "@etohq/types";
1
+ import { IPaymentProvider, ProviderWebhookPayload, WebhookActionResult, CapturePaymentInput, CapturePaymentOutput, AuthorizePaymentInput, AuthorizePaymentOutput, CancelPaymentInput, CancelPaymentOutput, InitiatePaymentInput, InitiatePaymentOutput, DeletePaymentInput, DeletePaymentOutput, GetPaymentStatusInput, GetPaymentStatusOutput, RefundPaymentInput, RefundPaymentOutput, RetrievePaymentInput, RetrievePaymentOutput, UpdatePaymentInput, UpdatePaymentOutput } from "@etohq/types";
2
2
  export declare abstract class AbstractPaymentProvider<TConfig = Record<string, unknown>> implements IPaymentProvider {
3
3
  /**
4
4
  * @ignore
@@ -10,11 +10,12 @@ export declare abstract class AbstractPaymentProvider<TConfig = Record<string, u
10
10
  protected readonly container: Record<string, unknown>;
11
11
  /**
12
12
  * This method validates the options of the provider set in `eto-config.ts`.
13
- * Implementing this method is optional. It's useful if your provider requires custom validation.
13
+ * Implementing this method is optional, but it's useful to ensure that the required
14
+ * options are passed to the provider, or if you have any custom validation logic.
14
15
  *
15
16
  * If the options aren't valid, throw an error.
16
17
  *
17
- * @param options - The provider's options.
18
+ * @param options - The provider's options passed in `eto-config.ts`.
18
19
  *
19
20
  * @example
20
21
  * class MyPaymentProviderService extends AbstractPaymentProvider<Options> {
@@ -30,16 +31,18 @@ export declare abstract class AbstractPaymentProvider<TConfig = Record<string, u
30
31
  */
31
32
  static validateOptions(options: Record<any, any>): void | never;
32
33
  /**
33
- * The constructor allows you to access resources from the [module's container](https://docs.etohq.com/learn/fundamentals/commerce-modules/container)
34
+ * The constructor allows you to access resources from the [module's container](https://docs.etohq.com/learn/fundamentals/modules/container)
34
35
  * using the first parameter, and the module's options using the second parameter.
35
36
  *
37
+ * If you're creating a client or establishing a connection with a third-party service, do it in the constructor.
38
+ *
36
39
  * :::note
37
40
  *
38
41
  * A module's options are passed when you register it in the Eto application.
39
42
  *
40
43
  * :::
41
44
  *
42
- * @param {Record<string, unknown>} cradle - The module's container cradle used to resolve resources.
45
+ * @param {Record<string, unknown>} cradle - The module's container used to resolve resources.
43
46
  * @param {Record<string, unknown>} config - The options passed to the Payment Module provider.
44
47
  * @typeParam TConfig - The type of the provider's options passed as a second parameter.
45
48
  *
@@ -111,75 +114,90 @@ export declare abstract class AbstractPaymentProvider<TConfig = Record<string, u
111
114
  */
112
115
  getIdentifier(): string;
113
116
  /**
114
- * This method is used to capture a payment. The payment is captured in one of the following scenarios:
117
+ * This method captures a payment using the third-party provider. In this method, use the third-party provider to capture the payment.
115
118
  *
116
- * - The {@link authorizePayment} method returns the status `captured`, which automatically executed this method after authorization.
117
- * - The merchant requests to capture the payment after its associated payment session was authorized.
118
- * - A webhook event occurred that instructs the payment provider to capture the payment session. Learn more about handing webhook events in [this guide](https://docs.etohq.com/resources/commerce-modules/payment/webhook-events).
119
+ * When an order is placed, the payment is authorized using the {@link authorizePayment} method. Then, the admin
120
+ * user can capture the payment, which triggers this method.
119
121
  *
120
- * In this method, use the third-party provider to capture the payment.
122
+ * ![Diagram showcasing capture payment flow](https://res.cloudinary.com/dza7lstvk/image/upload/v1747307414/Eto%20Resources/Klarna_Payment_Graphic_2025_1_lii7bw.jpg)
121
123
  *
122
- * @param paymentData - The `data` property of the payment. Make sure to store in it
123
- * any helpful identification for your third-party integration.
124
- * @returns The new data to store in the payment's `data` property, or an error object.
124
+ * This method can also be triggered by a webhook event if the {@link getWebhookActionAndData} method returns the action `captured`.
125
+ *
126
+ * #### Understanding `data` property
127
+ *
128
+ * The `data` property of the input parameter contains data that was previously stored in the Payment record's `data` property, which was
129
+ * returned by the {@link authorizePayment} method.
130
+ *
131
+ * The `data` property returned by this method is then stored in the `Payment` record. You can store data relevant to later refund or process the payment.
132
+ * For example, you can store the ID of the payment in the third-party provider to reference it later.
133
+ *
134
+ * ![Diagram showcasing data flow between methods](https://res.cloudinary.com/dza7lstvk/image/upload/v1747309870/Eto%20Resources/capture-data_acgdhf.jpg)
135
+ *
136
+ * @param input - The input to capture the payment. The `data` field should contain the data from the payment provider. when the payment was created.
137
+ * @returns The new data to store in the payment's `data` property. Throws in case of an error.
125
138
  *
126
139
  * @example
127
140
  * // other imports...
128
141
  * import {
129
- * PaymentProviderError,
130
- * PaymentProviderSessionResponse,
142
+ * CapturePaymentInput,
143
+ * CapturePaymentOutput,
131
144
  * } from "@etohq/framework/types"
132
145
  *
133
146
  * class MyPaymentProviderService extends AbstractPaymentProvider<
134
147
  * Options
135
148
  * > {
136
149
  * async capturePayment(
137
- * paymentData: Record<string, unknown>
138
- * ): Promise<PaymentProviderError | PaymentProviderSessionResponse["data"]> {
139
- * const externalId = paymentData.id
150
+ * input: CapturePaymentInput
151
+ * ): Promise<CapturePaymentOutput> {
152
+ * const externalId = input.data?.id
140
153
  *
141
- * try {
142
154
  * // assuming you have a client that captures the payment
143
- * const newData = await this.client.capturePayment(externalId)
144
- *
145
- * return {
155
+ * const newData = await this.client.capturePayment(externalId)
156
+ * return {
157
+ * data: {
146
158
  * ...newData,
147
- * id: externalId
148
- * }
149
- * } catch (e) {
150
- * return {
151
- * error: e,
152
- * code: "unknown",
153
- * detail: e
159
+ * id: externalId,
154
160
  * }
155
161
  * }
156
162
  * }
157
- *
158
163
  * // ...
159
164
  * }
160
165
  */
161
- abstract capturePayment(paymentData: Record<string, unknown>): Promise<PaymentProviderError | PaymentProviderSessionResponse["data"]>;
166
+ abstract capturePayment(input: CapturePaymentInput): Promise<CapturePaymentOutput>;
162
167
  /**
163
- * This method authorizes a payment session. When authorized successfully, a payment is created by the Payment
164
- * Module which can be later captured using the {@link capturePayment} method.
168
+ * This method authorizes a payment session using the third-party payment provider.
165
169
  *
166
- * Refer to [this guide](https://docs.etohq.com/resources/commerce-modules/payment/payment-flow#3-authorize-payment-session)
167
- * to learn more about how this fits into the payment flow and how to handle required actions.
170
+ * During checkout, the customer may need to perform actions required by the payment provider,
171
+ * such as entering their card details or confirming the payment. Once that is done,
172
+ * the customer can place their order.
168
173
  *
169
- * To automatically capture the payment after authorization, return the status `captured`.
174
+ * During cart-completion before placing the order, this method is used to authorize the cart's payment session with the
175
+ * third-party payment provider. The payment can later be captured
176
+ * using the {@link capturePayment} method.
170
177
  *
171
- * @param paymentSessionData - The `data` property of the payment session. Make sure to store in it
172
- * any helpful identification for your third-party integration.
173
- * @param context - The context in which the payment is being authorized. For example, in checkout,
174
- * the context has a `cart_id` property indicating the ID of the associated cart.
175
- * @returns Either an object of the new data to store in the created payment's `data` property and the
176
- * payment's status, or an error object. Make sure to set in `data` anything useful to later retrieve the session.
178
+ * ![Diagram showcasing authorize payment flow](https://res.cloudinary.com/dza7lstvk/image/upload/v1747307795/Eto%20Resources/authorize-payment_qzpy6e.jpg)
179
+ *
180
+ * When authorized successfully, a `Payment` is created by the Payment
181
+ * Module, and it's associated with the order.
182
+ *
183
+ * #### Understanding `data` property
184
+ *
185
+ * The `data` property of the method's parameter contains the `PaymentSession` record's `data` property, which was
186
+ * returned by the {@link initiatePayment} method.
187
+ *
188
+ * The `data` property returned by this method is then stored in the created `Payment` record. You can store data relevant to later capture or process the payment.
189
+ * For example, you can store the ID of the payment in the third-party provider to reference it later.
190
+ *
191
+ * ![Diagram showcasing data flow between methods](https://res.cloudinary.com/dza7lstvk/image/upload/v1747309278/Eto%20Resources/authorize-data_erjg7r.jpg)
192
+ *
193
+ * @param input - The input to authorize the payment. The `data` field should contain the data from the payment provider. when the payment was created.
194
+ * @returns The status of the authorization, along with the `data` field about the payment. Throws in case of an error.
177
195
  *
178
196
  * @example
179
197
  * // other imports...
180
198
  * import {
181
- * PaymentProviderError,
182
- * PaymentProviderSessionResponse,
199
+ * AuthorizePaymentInput,
200
+ * AuthorizePaymentOutput,
183
201
  * PaymentSessionStatus
184
202
  * } from "@etohq/framework/types"
185
203
  *
@@ -188,55 +206,39 @@ export declare abstract class AbstractPaymentProvider<TConfig = Record<string, u
188
206
  * Options
189
207
  * > {
190
208
  * async authorizePayment(
191
- * paymentSessionData: Record<string, unknown>,
192
- * context: Record<string, unknown>
193
- * ): Promise<
194
- * PaymentProviderError | {
195
- * status: PaymentSessionStatus
196
- * data: PaymentProviderSessionResponse["data"]
197
- * }
198
- * > {
199
- * const externalId = paymentSessionData.id
209
+ * input: AuthorizePaymentInput
210
+ * ): Promise<AuthorizePaymentOutput> {
211
+ * const externalId = input.data?.id
200
212
  *
201
- * try {
202
- * // assuming you have a client that authorizes the payment
203
- * const paymentData = await this.client.authorizePayment(externalId)
213
+ * // assuming you have a client that authorizes the payment
214
+ * const paymentData = await this.client.authorizePayment(externalId)
204
215
  *
205
- * return {
206
- * data: {
207
- * ...paymentData,
208
- * id: externalId
209
- * },
210
- * status: "authorized"
211
- * }
212
- * } catch (e) {
213
- * return {
214
- * error: e,
215
- * code: "unknown",
216
- * detail: e
217
- * }
216
+ * return {
217
+ * data: paymentData,
218
+ * status: "authorized"
218
219
  * }
219
220
  * }
220
221
  *
221
222
  * // ...
222
223
  * }
223
224
  */
224
- abstract authorizePayment(paymentSessionData: Record<string, unknown>, context: Record<string, unknown>): Promise<PaymentProviderError | {
225
- /**
226
- * The new status of the payment.
227
- */
228
- status: PaymentSessionStatus;
229
- /**
230
- * The data to store in the created payment's `data` property.
231
- */
232
- data: PaymentProviderSessionResponse["data"];
233
- }>;
225
+ abstract authorizePayment(input: AuthorizePaymentInput): Promise<AuthorizePaymentOutput>;
234
226
  /**
235
- * This method cancels a payment.
227
+ * This method cancels a payment in the third-party payment provider. It's used when
228
+ * the admin user cancels an order. The order can only be canceled if the payment
229
+ * is not captured yet.
230
+ *
231
+ * #### Understanding `data` property
232
+ *
233
+ * The `data` property of the method's parameter contains the `Payment` record's `data` property, which was
234
+ * returned by the {@link authorizePayment} method.
235
+ *
236
+ * The `data` property returned by this method is then stored in the `Payment` record. You can store data relevant for any further processing of the payment.
236
237
  *
237
- * @param paymentData - The `data` property of the payment. Make sure to store in it
238
- * any helpful identification for your third-party integration.
239
- * @returns An error object if an error occurs, or the data received from the integration.
238
+ * ![Diagram showcasing data flow between methods](https://res.cloudinary.com/dza7lstvk/image/upload/v1747310189/Eto%20Resources/cancel-data_gzcgbc.jpg)
239
+ *
240
+ * @param input - The input to cancel the payment. The `data` field should contain the data from the payment provider. when the payment was created.
241
+ * @returns The new data to store in the payment's `data` property, if any. Throws in case of an error.
240
242
  *
241
243
  * @example
242
244
  * // other imports...
@@ -250,39 +252,51 @@ export declare abstract class AbstractPaymentProvider<TConfig = Record<string, u
250
252
  * Options
251
253
  * > {
252
254
  * async cancelPayment(
253
- * paymentData: Record<string, unknown>
254
- * ): Promise<PaymentProviderError | PaymentProviderSessionResponse["data"]> {
255
- * const externalId = paymentData.id
255
+ * input: CancelPaymentInput
256
+ * ): Promise<CancelPaymentOutput> {
257
+ * const externalId = input.data?.id
256
258
  *
257
- * try {
258
- * // assuming you have a client that cancels the payment
259
- * const paymentData = await this.client.cancelPayment(externalId)
260
- * } catch (e) {
261
- * return {
262
- * error: e,
263
- * code: "unknown",
264
- * detail: e
265
- * }
266
- * }
259
+ * // assuming you have a client that cancels the payment
260
+ * const paymentData = await this.client.cancelPayment(externalId)
261
+ * return { data: paymentData }
267
262
  * }
268
263
  *
269
264
  * // ...
270
265
  * }
271
266
  */
272
- abstract cancelPayment(paymentData: Record<string, unknown>): Promise<PaymentProviderError | PaymentProviderSessionResponse["data"]>;
267
+ abstract cancelPayment(input: CancelPaymentInput): Promise<CancelPaymentOutput>;
273
268
  /**
274
- * This method is used when a payment session is created. It can be used to initiate the payment
275
- * in the third-party session, before authorizing or capturing the payment later.
269
+ * This method initializes a payment session with the third-party payment provider.
270
+ *
271
+ * When a customer chooses a payment method during checkout, this method is triggered to
272
+ * perform any initialization action with the third-party provider, such as creating a payment session.
273
+ *
274
+ * ![Diagram showcasing initiate payment flow](https://res.cloudinary.com/dza7lstvk/image/upload/v1747310624/Eto%20Resources/initiate-payment_dpoa2g.jpg)
276
275
  *
277
- * @param context - The details of the payment session and its context.
278
- * @returns An object whose `data` property is set in the created payment session, or an error
279
- * object. Make sure to set in `data` anything useful to later retrieve the session.
276
+ * #### Understanding `data` property
277
+ *
278
+ * The `data` property returned by this method will be stored in the created `PaymentSession` record. You can store data relevant to later authorize or process the payment.
279
+ * For example, you can store the ID of the payment session in the third-party provider to reference it later.
280
+ *
281
+ * The `data` property is also available to storefronts, allowing you to store data necessary for the storefront to integrate
282
+ * the payment provider in the checkout flow. For example, you can store the client token to use with the payment provider's SDK.
283
+ *
284
+ * :::note
285
+ *
286
+ * This also means you shouldn't store sensitive data and tokens in the `data` property, as it's publicly accessible.
287
+ *
288
+ * :::
289
+ *
290
+ * ![Diagram showcasing data flow between methods](https://res.cloudinary.com/dza7lstvk/image/upload/v1747310699/Eto%20Resources/initiate-data_ikc05t.jpg)
291
+ *
292
+ * @param input - The input to create the payment session.
293
+ * @returns The new data to store in the payment's `data` property. Throws in case of an error.
280
294
  *
281
295
  * @example
282
296
  * // other imports...
283
297
  * import {
284
- * PaymentProviderError,
285
- * PaymentProviderSessionResponse,
298
+ * InitiatePaymentInput,
299
+ * InitiatePaymentOutput,
286
300
  * } from "@etohq/framework/types"
287
301
  *
288
302
  *
@@ -290,53 +304,55 @@ export declare abstract class AbstractPaymentProvider<TConfig = Record<string, u
290
304
  * Options
291
305
  * > {
292
306
  * async initiatePayment(
293
- * context: CreatePaymentProviderSession
294
- * ): Promise<PaymentProviderError | PaymentProviderSessionResponse> {
307
+ * input: InitiatePaymentInput
308
+ * ): Promise<InitiatePaymentOutput> {
295
309
  * const {
296
310
  * amount,
297
311
  * currency_code,
298
312
  * context: customerDetails
299
- * } = context
313
+ * } = input
300
314
  *
301
- * try {
302
- * // assuming you have a client that initializes the payment
303
- * const response = await this.client.init(
304
- * amount, currency_code, customerDetails
305
- * )
315
+ * // assuming you have a client that initializes the payment
316
+ * const response = await this.client.init(
317
+ * amount, currency_code, customerDetails
318
+ * )
306
319
  *
307
- * return {
308
- * ...response,
309
- * data: {
310
- * id: response.id
311
- * }
312
- * }
313
- * } catch (e) {
314
- * return {
315
- * error: e,
316
- * code: "unknown",
317
- * detail: e
318
- * }
320
+ * return {
321
+ * id: response.id,
322
+ * data: response,
319
323
  * }
320
324
  * }
321
325
  *
322
326
  * // ...
323
327
  * }
324
328
  */
325
- abstract initiatePayment(context: CreatePaymentProviderSession): Promise<PaymentProviderError | PaymentProviderSessionResponse>;
329
+ abstract initiatePayment(input: InitiatePaymentInput): Promise<InitiatePaymentOutput>;
326
330
  /**
327
- * This method is used when a payment session is deleted, which can only happen if it isn't authorized, yet.
331
+ * This method deletes a payment session in the third-party payment provider.
332
+ *
333
+ * When a customer chooses a payment method during checkout, then chooses a different one,
334
+ * this method is triggered to delete the previous payment session.
335
+ *
336
+ * If your provider doesn't support deleting a payment session, you can just return an empty object or
337
+ * an object that contains the same received `data` property.
338
+ *
339
+ * ![Diagram showcasing delete payment flow](https://res.cloudinary.com/dza7lstvk/image/upload/v1747311084/Eto%20Resources/delete-payment_smxsiq.jpg)
328
340
  *
329
- * Use this to delete or cancel the payment in the third-party service.
341
+ * #### Understanding `data` property
330
342
  *
331
- * @param paymentSessionData - The `data` property of the payment session. Make sure to store in it
332
- * any helpful identification for your third-party integration.
333
- * @returns An error object or the response from the third-party service.
343
+ * The `data` property of the method's parameter contains the `PaymentSession` record's `data` property, which was
344
+ * returned by the {@link initiatePayment} method.
345
+ *
346
+ * ![Diagram showcasing data flow between methods](https://res.cloudinary.com/dza7lstvk/image/upload/v1747311084/Eto%20Resources/delete-data_xg65ck.jpg)
347
+ *
348
+ * @param input - The input to delete the payment session. The `data` field should contain the data from the payment provider. when the payment was created.
349
+ * @returns The new data to store in the payment's `data` property, if any. Throws in case of an error.
334
350
  *
335
351
  * @example
336
352
  * // other imports...
337
353
  * import {
338
- * PaymentProviderError,
339
- * PaymentProviderSessionResponse,
354
+ * DeletePaymentInput,
355
+ * DeletePaymentOutput,
340
356
  * } from "@etohq/framework/types"
341
357
  *
342
358
  *
@@ -344,38 +360,32 @@ export declare abstract class AbstractPaymentProvider<TConfig = Record<string, u
344
360
  * Options
345
361
  * > {
346
362
  * async deletePayment(
347
- * paymentSessionData: Record<string, unknown>
348
- * ): Promise<
349
- * PaymentProviderError | PaymentProviderSessionResponse["data"]
350
- * > {
351
- * const externalId = paymentSessionData.id
352
- *
353
- * try {
354
- * // assuming you have a client that cancels the payment
355
- * await this.client.cancelPayment(externalId)
356
- * } catch (e) {
357
- * return {
358
- * error: e,
359
- * code: "unknown",
360
- * detail: e
361
- * }
363
+ * input: DeletePaymentInput
364
+ * ): Promise<DeletePaymentOutput> {
365
+ * const externalId = input.data?.id
366
+ *
367
+ * // assuming you have a client that cancels the payment
368
+ * await this.client.cancelPayment(externalId)
369
+ * return {
370
+ * data: input.data
362
371
  * }
363
372
  * }
364
373
  *
365
374
  * // ...
366
375
  * }
367
376
  */
368
- abstract deletePayment(paymentSessionData: Record<string, unknown>): Promise<PaymentProviderError | PaymentProviderSessionResponse["data"]>;
377
+ abstract deletePayment(input: DeletePaymentInput): Promise<DeletePaymentOutput>;
369
378
  /**
370
379
  * This method gets the status of a payment session based on the status in the third-party integration.
371
380
  *
372
- * @param paymentSessionData - The `data` property of the payment session. Make sure to store in it
373
- * any helpful identification for your third-party integration.
374
- * @returns The payment session's status.
381
+ * @param input - The input to get the payment status. The `data` field should contain the data from the payment provider. when the payment was created.
382
+ * @returns The payment session's status. It can also return additional `data` from the payment provider.
375
383
  *
376
384
  * @example
377
385
  * // other imports...
378
386
  * import {
387
+ * GetPaymentStatusInput,
388
+ * GetPaymentStatusOutput,
379
389
  * PaymentSessionStatus
380
390
  * } from "@etohq/framework/types"
381
391
  *
@@ -384,46 +394,58 @@ export declare abstract class AbstractPaymentProvider<TConfig = Record<string, u
384
394
  * Options
385
395
  * > {
386
396
  * async getPaymentStatus(
387
- * paymentSessionData: Record<string, unknown>
388
- * ): Promise<PaymentSessionStatus> {
389
- * const externalId = paymentSessionData.id
397
+ * input: GetPaymentStatusInput
398
+ * ): Promise<GetPaymentStatusOutput> {
399
+ * const externalId = input.data?.id
390
400
  *
391
- * try {
392
- * // assuming you have a client that retrieves the payment status
393
- * const status = await this.client.getStatus(externalId)
401
+ * // assuming you have a client that retrieves the payment status
402
+ * const status = await this.client.getStatus(externalId)
394
403
  *
395
- * switch (status) {
396
- * case "requires_capture":
397
- * return "authorized"
404
+ * switch (status) {
405
+ * case "requires_capture":
406
+ * return {status: "authorized"}
398
407
  * case "success":
399
- * return "captured"
408
+ * return {status: "captured"}
400
409
  * case "canceled":
401
- * return "canceled"
410
+ * return {status: "canceled"}
402
411
  * default:
403
- * return "pending"
404
- * }
405
- * } catch (e) {
406
- * return "error"
407
- * }
412
+ * return {status: "pending"}
413
+ * }
408
414
  * }
409
415
  *
410
416
  * // ...
411
417
  * }
412
418
  */
413
- abstract getPaymentStatus(paymentSessionData: Record<string, unknown>): Promise<PaymentSessionStatus>;
419
+ abstract getPaymentStatus(input: GetPaymentStatusInput): Promise<GetPaymentStatusOutput>;
414
420
  /**
415
- * This method refunds an amount of a payment previously captured.
421
+ * This method refunds an amount using the third-party payment provider. This method
422
+ * is triggered when the admin user refunds a payment of an order.
423
+ *
424
+ * #### Understanding `data` property
425
+ *
426
+ * The `data` property of the method's parameter contains the `Payment` record's `data` property, which was
427
+ * returned by the {@link capturePayment} or {@link refundPayment} method.
428
+ *
429
+ * The `data` property returned by this method is then stored in the `Payment` record. You can store data relevant to later refund or process the payment.
430
+ * For example, you can store the ID of the payment in the third-party provider to reference it later.
416
431
  *
417
- * @param paymentData - The `data` property of the payment. Make sure to store in it
418
- * any helpful identification for your third-party integration.
419
- * @param refundAmount The amount to refund.
432
+ * :::note
433
+ *
434
+ * A payment may be refunded multiple times with different amounts. In this case, the `data` property
435
+ * of the input parameter contains the data from the last refund.
436
+ *
437
+ * :::
438
+ *
439
+ * ![Diagram showcasing data flow between methods](https://res.cloudinary.com/dza7lstvk/image/upload/v1747311296/Eto%20Resources/refund-data_plcjl0.jpg)
440
+ *
441
+ * @param input - The input to refund the payment. The `data` field should contain the data from the payment provider. when the payment was created.
420
442
  * @returns The new data to store in the payment's `data` property, or an error object.
421
443
  *
422
444
  * @example
423
445
  * // other imports...
424
446
  * import {
425
- * PaymentProviderError,
426
- * PaymentProviderSessionResponse,
447
+ * RefundPaymentInput,
448
+ * RefundPaymentOutput,
427
449
  * } from "@etohq/framework/types"
428
450
  *
429
451
  *
@@ -431,49 +453,35 @@ export declare abstract class AbstractPaymentProvider<TConfig = Record<string, u
431
453
  * Options
432
454
  * > {
433
455
  * async refundPayment(
434
- * paymentData: Record<string, unknown>,
435
- * refundAmount: number
436
- * ): Promise<
437
- * PaymentProviderError | PaymentProviderSessionResponse["data"]
438
- * > {
439
- * const externalId = paymentData.id
456
+ * input: RefundPaymentInput
457
+ * ): Promise<RefundPaymentOutput> {
458
+ * const externalId = input.data?.id
440
459
  *
441
- * try {
442
- * // assuming you have a client that refunds the payment
443
- * const newData = await this.client.refund(
460
+ * // assuming you have a client that refunds the payment
461
+ * const newData = await this.client.refund(
444
462
  * externalId,
445
- * refundAmount
463
+ * input.amount
446
464
  * )
447
465
  *
448
- * return {
449
- * ...newData,
450
- * id: externalId
451
- * }
452
- * } catch (e) {
453
- * return {
454
- * error: e,
455
- * code: "unknown",
456
- * detail: e
457
- * }
466
+ * return {
467
+ * data: input.data,
458
468
  * }
459
469
  * }
460
- *
461
470
  * // ...
462
471
  * }
463
472
  */
464
- abstract refundPayment(paymentData: Record<string, unknown>, refundAmount: number): Promise<PaymentProviderError | PaymentProviderSessionResponse["data"]>;
473
+ abstract refundPayment(input: RefundPaymentInput): Promise<RefundPaymentOutput>;
465
474
  /**
466
- * Retrieves the payment's data from the third-party service.
475
+ * This method retrieves the payment's data from the third-party payment provider.
467
476
  *
468
- * @param paymentSessionData - The `data` property of the payment. Make sure to store in it
469
- * any helpful identification for your third-party integration.
470
- * @returns An object to be stored in the payment's `data` property, or an error object.
477
+ * @param input - The input to retrieve the payment. The `data` field should contain the data from the payment provider when the payment was created.
478
+ * @returns The payment's data as found in the the payment provider.
471
479
  *
472
480
  * @example
473
481
  * // other imports...
474
482
  * import {
475
- * PaymentProviderError,
476
- * PaymentProviderSessionResponse,
483
+ * RetrievePaymentInput,
484
+ * RetrievePaymentOutput,
477
485
  * } from "@etohq/framework/types"
478
486
  *
479
487
  *
@@ -481,41 +489,28 @@ export declare abstract class AbstractPaymentProvider<TConfig = Record<string, u
481
489
  * Options
482
490
  * > {
483
491
  * async retrievePayment(
484
- * paymentSessionData: Record<string, unknown>
485
- * ): Promise<
486
- * PaymentProviderError | PaymentProviderSessionResponse["data"]
487
- * > {
488
- * const externalId = paymentSessionData.id
492
+ * input: RetrievePaymentInput
493
+ * ): Promise<RetrievePaymentOutput> {
494
+ * const externalId = input.data?.id
489
495
  *
490
- * try {
491
- * // assuming you have a client that retrieves the payment
492
- * return await this.client.retrieve(externalId)
493
- * } catch (e) {
494
- * return {
495
- * error: e,
496
- * code: "unknown",
497
- * detail: e
498
- * }
499
- * }
496
+ * // assuming you have a client that retrieves the payment
497
+ * return await this.client.retrieve(externalId)
500
498
  * }
501
- *
502
499
  * // ...
503
500
  * }
504
501
  */
505
- abstract retrievePayment(paymentSessionData: Record<string, unknown>): Promise<PaymentProviderError | PaymentProviderSessionResponse["data"]>;
502
+ abstract retrievePayment(input: RetrievePaymentInput): Promise<RetrievePaymentOutput>;
506
503
  /**
507
- * Update a payment in the third-party service that was previously initiated with the {@link initiatePayment} method.
504
+ * This method updates a payment in the third-party service that was previously initiated with the {@link initiatePayment} method.
508
505
  *
509
- * @param context - The details of the payment session and its context.
510
- * @returns An object whose `data` property is set in the updated payment session, or an error
511
- * object. Make sure to set in `data` anything useful to later retrieve the session.
506
+ * @param input - The input to update the payment. The `data` field should contain the data from the payment provider. when the payment was created.
507
+ * @returns The new data to store in the payment's `data` property. Throws in case of an error.
512
508
  *
513
509
  * @example
514
510
  * // other imports...
515
511
  * import {
516
- * UpdatePaymentProviderSession,
517
- * PaymentProviderError,
518
- * PaymentProviderSessionResponse,
512
+ * UpdatePaymentInput,
513
+ * UpdatePaymentOutput,
519
514
  * } from "@etohq/framework/types"
520
515
  *
521
516
  *
@@ -523,55 +518,44 @@ export declare abstract class AbstractPaymentProvider<TConfig = Record<string, u
523
518
  * Options
524
519
  * > {
525
520
  * async updatePayment(
526
- * context: UpdatePaymentProviderSession
527
- * ): Promise<PaymentProviderError | PaymentProviderSessionResponse> {
528
- * const {
529
- * amount,
530
- * currency_code,
531
- * context: customerDetails,
532
- * data
533
- * } = context
534
- * const externalId = data.id
521
+ * input: UpdatePaymentInput
522
+ * ): Promise<UpdatePaymentOutput> {
523
+ * const { amount, currency_code, context } = input
524
+ * const externalId = input.data?.id
525
+ *
526
+ * // Validate context.customer
527
+ * if (!context || !context.customer) {
528
+ * throw new Error("Context must include a valid customer.");
529
+ * }
535
530
  *
536
- * try {
537
- * // assuming you have a client that updates the payment
538
- * const response = await this.client.update(
539
- * externalId,
531
+ * // assuming you have a client that updates the payment
532
+ * const response = await this.client.update(
533
+ * externalId,
540
534
  * {
541
535
  * amount,
542
536
  * currency_code,
543
- * customerDetails
537
+ * customer: context.customer
544
538
  * }
545
539
  * )
546
540
  *
547
- * return {
548
- * ...response,
549
- * data: {
550
- * id: response.id
551
- * }
552
- * }
553
- * } catch (e) {
554
- * return {
555
- * error: e,
556
- * code: "unknown",
557
- * detail: e
558
- * }
559
- * }
541
+ * return response
560
542
  * }
561
543
  *
562
544
  * // ...
563
545
  * }
564
546
  */
565
- abstract updatePayment(context: UpdatePaymentProviderSession): Promise<PaymentProviderError | PaymentProviderSessionResponse>;
547
+ abstract updatePayment(input: UpdatePaymentInput): Promise<UpdatePaymentOutput>;
566
548
  /**
567
- * This method is executed when a webhook event is received from the third-party payment provider. Use it
568
- * to process the action of the payment provider.
549
+ * This method is executed when a webhook event is received from the third-party payment provider. Eto uses
550
+ * the data returned by this method to perform actions in the Eto application, such as completing the associated cart
551
+ * if the payment was authorized successfully.
569
552
  *
570
- * Learn more in [this documentation](https://docs.etohq.com/resources/commerce-modules/payment/webhook-events)
553
+ * Learn more in the [Webhook Events](https://docs.etohq.com/resources/commerce-modules/payment/webhook-events) documentation.
571
554
  *
572
555
  * @param data - The webhook event's data
573
556
  * @returns The webhook result. If the `action`'s value is `captured`, the payment is captured within Eto as well.
574
- * If the `action`'s value is `authorized`, the associated payment session is authorized within Eto.
557
+ * If the `action`'s value is `authorized`, the associated payment session is authorized within Eto and the associated cart
558
+ * will be completed to create an order.
575
559
  *
576
560
  * @example
577
561
  * // other imports...
@@ -602,6 +586,8 @@ export declare abstract class AbstractPaymentProvider<TConfig = Record<string, u
602
586
  * return {
603
587
  * action: "authorized",
604
588
  * data: {
589
+ * // assuming the session_id is stored in the metadata of the payment
590
+ * // in the third-party provider
605
591
  * session_id: (data.metadata as Record<string, any>).session_id,
606
592
  * amount: new BigNumber(data.amount as number)
607
593
  * }
@@ -610,19 +596,27 @@ export declare abstract class AbstractPaymentProvider<TConfig = Record<string, u
610
596
  * return {
611
597
  * action: "captured",
612
598
  * data: {
599
+ * // assuming the session_id is stored in the metadata of the payment
600
+ * // in the third-party provider
613
601
  * session_id: (data.metadata as Record<string, any>).session_id,
614
602
  * amount: new BigNumber(data.amount as number)
615
603
  * }
616
604
  * }
617
605
  * default:
618
606
  * return {
619
- * action: "not_supported"
607
+ * action: "not_supported",
608
+ * data: {
609
+ * session_id: "",
610
+ * amount: new BigNumber(0)
611
+ * }
620
612
  * }
621
613
  * }
622
614
  * } catch (e) {
623
615
  * return {
624
616
  * action: "failed",
625
617
  * data: {
618
+ * // assuming the session_id is stored in the metadata of the payment
619
+ * // in the third-party provider
626
620
  * session_id: (data.metadata as Record<string, any>).session_id,
627
621
  * amount: new BigNumber(data.amount as number)
628
622
  * }
@@ -635,8 +629,4 @@ export declare abstract class AbstractPaymentProvider<TConfig = Record<string, u
635
629
  */
636
630
  abstract getWebhookActionAndData(data: ProviderWebhookPayload["payload"]): Promise<WebhookActionResult>;
637
631
  }
638
- /**
639
- * @ignore
640
- */
641
- export declare function isPaymentProviderError(obj: any): obj is PaymentProviderError;
642
632
  //# sourceMappingURL=abstract-payment-provider.d.ts.map