@adonis-agora/payments 0.2.0 → 0.4.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 (346) hide show
  1. package/CHANGELOG.md +2375 -0
  2. package/dist/assets/spa/assets/index-B7rU8eIL.css +2 -0
  3. package/dist/assets/spa/assets/index-BcM2VH5k.js +10 -0
  4. package/dist/assets/spa/assets/index-BcM2VH5k.js.map +1 -0
  5. package/dist/assets/spa/index.html +20 -0
  6. package/dist/commands/main.d.ts +4 -3
  7. package/dist/commands/main.d.ts.map +1 -1
  8. package/dist/commands/main.js +9 -2
  9. package/dist/commands/main.js.map +1 -1
  10. package/dist/commands/make_billable.d.ts.map +1 -1
  11. package/dist/commands/make_billable.js +1 -1
  12. package/dist/commands/make_billable.js.map +1 -1
  13. package/dist/commands/make_webhook_handler.d.ts.map +1 -1
  14. package/dist/commands/make_webhook_handler.js +1 -1
  15. package/dist/commands/make_webhook_handler.js.map +1 -1
  16. package/dist/commands/payments_health.d.ts +31 -0
  17. package/dist/commands/payments_health.d.ts.map +1 -0
  18. package/dist/commands/payments_health.js +113 -0
  19. package/dist/commands/payments_health.js.map +1 -0
  20. package/dist/commands/payments_sync.d.ts +18 -4
  21. package/dist/commands/payments_sync.d.ts.map +1 -1
  22. package/dist/commands/payments_sync.js +136 -40
  23. package/dist/commands/payments_sync.js.map +1 -1
  24. package/dist/commands/payments_webhook.d.ts.map +1 -1
  25. package/dist/commands/payments_webhook.js.map +1 -1
  26. package/dist/configure.d.ts +12 -5
  27. package/dist/configure.d.ts.map +1 -1
  28. package/dist/configure.js +18 -5
  29. package/dist/configure.js.map +1 -1
  30. package/dist/providers/dashboard_provider.d.ts +97 -0
  31. package/dist/providers/dashboard_provider.d.ts.map +1 -0
  32. package/dist/providers/dashboard_provider.js +430 -0
  33. package/dist/providers/dashboard_provider.js.map +1 -0
  34. package/dist/providers/payments_client_provider.d.ts +41 -0
  35. package/dist/providers/payments_client_provider.d.ts.map +1 -0
  36. package/dist/providers/payments_client_provider.js +95 -0
  37. package/dist/providers/payments_client_provider.js.map +1 -0
  38. package/dist/providers/payments_provider.d.ts +35 -0
  39. package/dist/providers/payments_provider.d.ts.map +1 -1
  40. package/dist/providers/payments_provider.js +250 -36
  41. package/dist/providers/payments_provider.js.map +1 -1
  42. package/dist/src/billing/billing_health.d.ts +85 -0
  43. package/dist/src/billing/billing_health.d.ts.map +1 -0
  44. package/dist/src/billing/billing_health.js +155 -0
  45. package/dist/src/billing/billing_health.js.map +1 -0
  46. package/dist/src/billing/billing_overview.d.ts +4 -3
  47. package/dist/src/billing/billing_overview.d.ts.map +1 -1
  48. package/dist/src/billing/billing_overview.js +14 -5
  49. package/dist/src/billing/billing_overview.js.map +1 -1
  50. package/dist/src/billing/billing_store.d.ts +634 -5
  51. package/dist/src/billing/billing_store.d.ts.map +1 -1
  52. package/dist/src/billing/billing_store.js +18 -1
  53. package/dist/src/billing/billing_store.js.map +1 -1
  54. package/dist/src/billing/index.d.ts +4 -3
  55. package/dist/src/billing/index.d.ts.map +1 -1
  56. package/dist/src/billing/index.js +2 -1
  57. package/dist/src/billing/index.js.map +1 -1
  58. package/dist/src/billing/list_query.d.ts +16 -0
  59. package/dist/src/billing/list_query.d.ts.map +1 -0
  60. package/dist/src/billing/list_query.js +28 -0
  61. package/dist/src/billing/list_query.js.map +1 -0
  62. package/dist/src/billing/lucid_billing_store.d.ts +122 -4
  63. package/dist/src/billing/lucid_billing_store.d.ts.map +1 -1
  64. package/dist/src/billing/lucid_billing_store.js +811 -13
  65. package/dist/src/billing/lucid_billing_store.js.map +1 -1
  66. package/dist/src/billing/mixins/index.d.ts +5 -2
  67. package/dist/src/billing/mixins/index.d.ts.map +1 -1
  68. package/dist/src/billing/mixins/index.js +5 -2
  69. package/dist/src/billing/mixins/index.js.map +1 -1
  70. package/dist/src/billing/mixins/with_audit_event.d.ts +48 -0
  71. package/dist/src/billing/mixins/with_audit_event.d.ts.map +1 -0
  72. package/dist/src/billing/mixins/with_audit_event.js +77 -0
  73. package/dist/src/billing/mixins/with_audit_event.js.map +1 -0
  74. package/dist/src/billing/mixins/with_billable.d.ts.map +1 -1
  75. package/dist/src/billing/mixins/with_customer.d.ts +39 -0
  76. package/dist/src/billing/mixins/with_customer.d.ts.map +1 -0
  77. package/dist/src/billing/mixins/with_customer.js +68 -0
  78. package/dist/src/billing/mixins/with_customer.js.map +1 -0
  79. package/dist/src/billing/mixins/with_dispute.d.ts +68 -0
  80. package/dist/src/billing/mixins/with_dispute.d.ts.map +1 -0
  81. package/dist/src/billing/mixins/with_dispute.js +83 -0
  82. package/dist/src/billing/mixins/with_dispute.js.map +1 -0
  83. package/dist/src/billing/mixins/with_payment.d.ts +42 -0
  84. package/dist/src/billing/mixins/with_payment.d.ts.map +1 -1
  85. package/dist/src/billing/mixins/with_payment.js +29 -3
  86. package/dist/src/billing/mixins/with_payment.js.map +1 -1
  87. package/dist/src/billing/mixins/with_subscription.d.ts +7 -0
  88. package/dist/src/billing/mixins/with_subscription.d.ts.map +1 -1
  89. package/dist/src/billing/mixins/with_subscription.js +15 -1
  90. package/dist/src/billing/mixins/with_subscription.js.map +1 -1
  91. package/dist/src/billing/mixins/with_usage_event.d.ts +7 -0
  92. package/dist/src/billing/mixins/with_usage_event.d.ts.map +1 -1
  93. package/dist/src/billing/mixins/with_usage_event.js +15 -1
  94. package/dist/src/billing/mixins/with_usage_event.js.map +1 -1
  95. package/dist/src/billing/mixins/with_webhook_event.d.ts +18 -0
  96. package/dist/src/billing/mixins/with_webhook_event.d.ts.map +1 -1
  97. package/dist/src/billing/mixins/with_webhook_event.js +18 -1
  98. package/dist/src/billing/mixins/with_webhook_event.js.map +1 -1
  99. package/dist/src/billing/resolve_dispatch.d.ts +22 -0
  100. package/dist/src/billing/resolve_dispatch.d.ts.map +1 -0
  101. package/dist/src/billing/resolve_dispatch.js +44 -0
  102. package/dist/src/billing/resolve_dispatch.js.map +1 -0
  103. package/dist/src/billing/resolve_store.d.ts +18 -0
  104. package/dist/src/billing/resolve_store.d.ts.map +1 -0
  105. package/dist/src/billing/resolve_store.js +35 -0
  106. package/dist/src/billing/resolve_store.js.map +1 -0
  107. package/dist/src/billing/schema.d.ts +108 -0
  108. package/dist/src/billing/schema.d.ts.map +1 -0
  109. package/dist/src/billing/schema.js +350 -0
  110. package/dist/src/billing/schema.js.map +1 -0
  111. package/dist/src/billing/webhook_dispatcher.d.ts +95 -16
  112. package/dist/src/billing/webhook_dispatcher.d.ts.map +1 -1
  113. package/dist/src/billing/webhook_dispatcher.js +186 -33
  114. package/dist/src/billing/webhook_dispatcher.js.map +1 -1
  115. package/dist/src/billing/webhook_events.d.ts +67 -1
  116. package/dist/src/billing/webhook_events.d.ts.map +1 -1
  117. package/dist/src/billing/webhook_events.js +15 -0
  118. package/dist/src/billing/webhook_events.js.map +1 -1
  119. package/dist/src/billing/webhook_processor.d.ts.map +1 -1
  120. package/dist/src/billing/webhook_processor.js +325 -5
  121. package/dist/src/billing/webhook_processor.js.map +1 -1
  122. package/dist/src/client/define_config.d.ts +150 -0
  123. package/dist/src/client/define_config.d.ts.map +1 -0
  124. package/dist/src/client/define_config.js +98 -0
  125. package/dist/src/client/define_config.js.map +1 -0
  126. package/dist/src/client/handlers.d.ts +71 -0
  127. package/dist/src/client/handlers.d.ts.map +1 -0
  128. package/dist/src/client/handlers.js +119 -0
  129. package/dist/src/client/handlers.js.map +1 -0
  130. package/dist/src/client/index.d.ts +15 -0
  131. package/dist/src/client/index.d.ts.map +1 -0
  132. package/dist/src/client/index.js +12 -0
  133. package/dist/src/client/index.js.map +1 -0
  134. package/dist/src/client/statuses.d.ts +38 -0
  135. package/dist/src/client/statuses.d.ts.map +1 -0
  136. package/dist/src/client/statuses.js +42 -0
  137. package/dist/src/client/statuses.js.map +1 -0
  138. package/dist/src/dashboard/actions.d.ts +143 -0
  139. package/dist/src/dashboard/actions.d.ts.map +1 -0
  140. package/dist/src/dashboard/actions.js +112 -0
  141. package/dist/src/dashboard/actions.js.map +1 -0
  142. package/dist/src/dashboard/auth.d.ts +136 -0
  143. package/dist/src/dashboard/auth.d.ts.map +1 -0
  144. package/dist/src/dashboard/auth.js +152 -0
  145. package/dist/src/dashboard/auth.js.map +1 -0
  146. package/dist/src/dashboard/define_config.d.ts +80 -0
  147. package/dist/src/dashboard/define_config.d.ts.map +1 -0
  148. package/dist/src/dashboard/define_config.js +83 -0
  149. package/dist/src/dashboard/define_config.js.map +1 -0
  150. package/dist/src/dashboard/handlers.d.ts +281 -0
  151. package/dist/src/dashboard/handlers.d.ts.map +1 -0
  152. package/dist/src/dashboard/handlers.js +960 -0
  153. package/dist/src/dashboard/handlers.js.map +1 -0
  154. package/dist/src/dashboard/index.d.ts +17 -0
  155. package/dist/src/dashboard/index.d.ts.map +1 -0
  156. package/dist/src/dashboard/index.js +13 -0
  157. package/dist/src/dashboard/index.js.map +1 -0
  158. package/dist/src/dashboard/login_page.d.ts +23 -0
  159. package/dist/src/dashboard/login_page.d.ts.map +1 -0
  160. package/dist/src/dashboard/login_page.js +170 -0
  161. package/dist/src/dashboard/login_page.js.map +1 -0
  162. package/dist/src/dashboard/period.d.ts +31 -0
  163. package/dist/src/dashboard/period.d.ts.map +1 -0
  164. package/dist/src/dashboard/period.js +44 -0
  165. package/dist/src/dashboard/period.js.map +1 -0
  166. package/dist/src/dashboard/session_cookie.d.ts +42 -0
  167. package/dist/src/dashboard/session_cookie.d.ts.map +1 -0
  168. package/dist/src/dashboard/session_cookie.js +97 -0
  169. package/dist/src/dashboard/session_cookie.js.map +1 -0
  170. package/dist/src/dashboard/spa.d.ts +24 -0
  171. package/dist/src/dashboard/spa.d.ts.map +1 -0
  172. package/dist/src/dashboard/spa.js +52 -0
  173. package/dist/src/dashboard/spa.js.map +1 -0
  174. package/dist/src/define_config.d.ts +245 -10
  175. package/dist/src/define_config.d.ts.map +1 -1
  176. package/dist/src/define_config.js +97 -1
  177. package/dist/src/define_config.js.map +1 -1
  178. package/dist/src/diagnostics.d.ts +287 -7
  179. package/dist/src/diagnostics.d.ts.map +1 -1
  180. package/dist/src/diagnostics.js +317 -1
  181. package/dist/src/diagnostics.js.map +1 -1
  182. package/dist/src/driver.d.ts +139 -5
  183. package/dist/src/driver.d.ts.map +1 -1
  184. package/dist/src/drivers/abacate.d.ts +13 -3
  185. package/dist/src/drivers/abacate.d.ts.map +1 -1
  186. package/dist/src/drivers/abacate.js +112 -19
  187. package/dist/src/drivers/abacate.js.map +1 -1
  188. package/dist/src/drivers/adyen.d.ts +164 -0
  189. package/dist/src/drivers/adyen.d.ts.map +1 -0
  190. package/dist/src/drivers/adyen.js +678 -0
  191. package/dist/src/drivers/adyen.js.map +1 -0
  192. package/dist/src/drivers/asaas.d.ts +53 -3
  193. package/dist/src/drivers/asaas.d.ts.map +1 -1
  194. package/dist/src/drivers/asaas.js +364 -29
  195. package/dist/src/drivers/asaas.js.map +1 -1
  196. package/dist/src/drivers/dodo.d.ts +135 -0
  197. package/dist/src/drivers/dodo.d.ts.map +1 -0
  198. package/dist/src/drivers/dodo.js +864 -0
  199. package/dist/src/drivers/dodo.js.map +1 -0
  200. package/dist/src/drivers/efi.d.ts +98 -0
  201. package/dist/src/drivers/efi.d.ts.map +1 -0
  202. package/dist/src/drivers/efi.js +628 -0
  203. package/dist/src/drivers/efi.js.map +1 -0
  204. package/dist/src/drivers/infinitepay.d.ts +156 -0
  205. package/dist/src/drivers/infinitepay.d.ts.map +1 -0
  206. package/dist/src/drivers/infinitepay.js +321 -0
  207. package/dist/src/drivers/infinitepay.js.map +1 -0
  208. package/dist/src/drivers/lemonsqueezy.d.ts +125 -0
  209. package/dist/src/drivers/lemonsqueezy.d.ts.map +1 -0
  210. package/dist/src/drivers/lemonsqueezy.js +632 -0
  211. package/dist/src/drivers/lemonsqueezy.js.map +1 -0
  212. package/dist/src/drivers/mercadopago.d.ts +97 -0
  213. package/dist/src/drivers/mercadopago.d.ts.map +1 -0
  214. package/dist/src/drivers/mercadopago.js +844 -0
  215. package/dist/src/drivers/mercadopago.js.map +1 -0
  216. package/dist/src/drivers/mollie.d.ts +125 -0
  217. package/dist/src/drivers/mollie.d.ts.map +1 -0
  218. package/dist/src/drivers/mollie.js +812 -0
  219. package/dist/src/drivers/mollie.js.map +1 -0
  220. package/dist/src/drivers/paddle.d.ts +148 -0
  221. package/dist/src/drivers/paddle.d.ts.map +1 -0
  222. package/dist/src/drivers/paddle.js +738 -0
  223. package/dist/src/drivers/paddle.js.map +1 -0
  224. package/dist/src/drivers/pagarme.d.ts +97 -0
  225. package/dist/src/drivers/pagarme.d.ts.map +1 -0
  226. package/dist/src/drivers/pagarme.js +829 -0
  227. package/dist/src/drivers/pagarme.js.map +1 -0
  228. package/dist/src/drivers/pagbank.d.ts +57 -0
  229. package/dist/src/drivers/pagbank.d.ts.map +1 -0
  230. package/dist/src/drivers/pagbank.js +499 -0
  231. package/dist/src/drivers/pagbank.js.map +1 -0
  232. package/dist/src/drivers/paypal.d.ts +120 -0
  233. package/dist/src/drivers/paypal.d.ts.map +1 -0
  234. package/dist/src/drivers/paypal.js +891 -0
  235. package/dist/src/drivers/paypal.js.map +1 -0
  236. package/dist/src/drivers/polar.d.ts +118 -0
  237. package/dist/src/drivers/polar.d.ts.map +1 -0
  238. package/dist/src/drivers/polar.js +604 -0
  239. package/dist/src/drivers/polar.js.map +1 -0
  240. package/dist/src/drivers/razorpay.d.ts +103 -0
  241. package/dist/src/drivers/razorpay.d.ts.map +1 -0
  242. package/dist/src/drivers/razorpay.js +867 -0
  243. package/dist/src/drivers/razorpay.js.map +1 -0
  244. package/dist/src/drivers/shared.d.ts +33 -0
  245. package/dist/src/drivers/shared.d.ts.map +1 -0
  246. package/dist/src/drivers/shared.js +37 -0
  247. package/dist/src/drivers/shared.js.map +1 -0
  248. package/dist/src/drivers/square.d.ts +133 -0
  249. package/dist/src/drivers/square.d.ts.map +1 -0
  250. package/dist/src/drivers/square.js +905 -0
  251. package/dist/src/drivers/square.js.map +1 -0
  252. package/dist/src/drivers/stripe.d.ts +41 -4
  253. package/dist/src/drivers/stripe.d.ts.map +1 -1
  254. package/dist/src/drivers/stripe.js +823 -26
  255. package/dist/src/drivers/stripe.js.map +1 -1
  256. package/dist/src/drivers/woovi.d.ts +11 -4
  257. package/dist/src/drivers/woovi.d.ts.map +1 -1
  258. package/dist/src/drivers/woovi.js +162 -29
  259. package/dist/src/drivers/woovi.js.map +1 -1
  260. package/dist/src/ensure_customer.d.ts +34 -1
  261. package/dist/src/ensure_customer.d.ts.map +1 -1
  262. package/dist/src/ensure_customer.js +29 -4
  263. package/dist/src/ensure_customer.js.map +1 -1
  264. package/dist/src/hooks/webhook_handlers.d.ts.map +1 -1
  265. package/dist/src/hooks/webhook_handlers.js.map +1 -1
  266. package/dist/src/http.d.ts +37 -3
  267. package/dist/src/http.d.ts.map +1 -1
  268. package/dist/src/http.js +69 -5
  269. package/dist/src/http.js.map +1 -1
  270. package/dist/src/index.d.ts +54 -26
  271. package/dist/src/index.d.ts.map +1 -1
  272. package/dist/src/index.js +29 -12
  273. package/dist/src/index.js.map +1 -1
  274. package/dist/src/invoice/drivers/asaas.d.ts.map +1 -1
  275. package/dist/src/invoice/drivers/asaas.js.map +1 -1
  276. package/dist/src/invoice/drivers/enotas.d.ts.map +1 -1
  277. package/dist/src/invoice/drivers/enotas.js.map +1 -1
  278. package/dist/src/invoice/drivers/focus.d.ts.map +1 -1
  279. package/dist/src/invoice/drivers/focus.js.map +1 -1
  280. package/dist/src/invoice/drivers/plugnotas.d.ts.map +1 -1
  281. package/dist/src/invoice/drivers/plugnotas.js.map +1 -1
  282. package/dist/src/invoice/drivers/tecnospeed.d.ts.map +1 -1
  283. package/dist/src/invoice/drivers/tecnospeed.js.map +1 -1
  284. package/dist/src/invoice/emit_invoice.d.ts.map +1 -1
  285. package/dist/src/invoice/emit_invoice.js +31 -11
  286. package/dist/src/invoice/emit_invoice.js.map +1 -1
  287. package/dist/src/invoice/invoice_manager.d.ts.map +1 -1
  288. package/dist/src/money.d.ts +23 -5
  289. package/dist/src/money.d.ts.map +1 -1
  290. package/dist/src/money.js +72 -7
  291. package/dist/src/money.js.map +1 -1
  292. package/dist/src/payments_manager.d.ts +8 -1
  293. package/dist/src/payments_manager.d.ts.map +1 -1
  294. package/dist/src/payments_manager.js +168 -6
  295. package/dist/src/payments_manager.js.map +1 -1
  296. package/dist/src/services/main.d.ts +38 -0
  297. package/dist/src/services/main.d.ts.map +1 -1
  298. package/dist/src/services/main.js +130 -0
  299. package/dist/src/services/main.js.map +1 -1
  300. package/dist/src/telescope/index.d.ts +2 -0
  301. package/dist/src/telescope/index.d.ts.map +1 -1
  302. package/dist/src/telescope/index.js +1 -0
  303. package/dist/src/telescope/index.js.map +1 -1
  304. package/dist/src/telescope/payments_watcher.d.ts +10 -4
  305. package/dist/src/telescope/payments_watcher.d.ts.map +1 -1
  306. package/dist/src/telescope/payments_watcher.js +66 -14
  307. package/dist/src/telescope/payments_watcher.js.map +1 -1
  308. package/dist/src/telescope/register.d.ts +62 -0
  309. package/dist/src/telescope/register.d.ts.map +1 -0
  310. package/dist/src/telescope/register.js +48 -0
  311. package/dist/src/telescope/register.js.map +1 -0
  312. package/dist/src/testing/fake_payments.d.ts +62 -0
  313. package/dist/src/testing/fake_payments.d.ts.map +1 -0
  314. package/dist/src/testing/fake_payments.js +82 -0
  315. package/dist/src/testing/fake_payments.js.map +1 -0
  316. package/dist/src/testing/fake_payments_driver.d.ts +1 -1
  317. package/dist/src/testing/fake_payments_driver.d.ts.map +1 -1
  318. package/dist/src/testing/fake_payments_driver.js.map +1 -1
  319. package/dist/src/testing/in_memory_billing_store.d.ts +151 -2
  320. package/dist/src/testing/in_memory_billing_store.d.ts.map +1 -1
  321. package/dist/src/testing/in_memory_billing_store.js +517 -4
  322. package/dist/src/testing/in_memory_billing_store.js.map +1 -1
  323. package/dist/src/testing/index.d.ts +3 -2
  324. package/dist/src/testing/index.d.ts.map +1 -1
  325. package/dist/src/testing/index.js +1 -0
  326. package/dist/src/testing/index.js.map +1 -1
  327. package/dist/src/testing/mutable_clock.d.ts.map +1 -1
  328. package/dist/src/types.d.ts +161 -5
  329. package/dist/src/types.d.ts.map +1 -1
  330. package/dist/src/types.js +30 -1
  331. package/dist/src/types.js.map +1 -1
  332. package/dist/src/webhook_handlers.d.ts +96 -2
  333. package/dist/src/webhook_handlers.d.ts.map +1 -1
  334. package/dist/src/webhook_handlers.js +91 -10
  335. package/dist/src/webhook_handlers.js.map +1 -1
  336. package/dist/src/webhook_security.d.ts +94 -3
  337. package/dist/src/webhook_security.d.ts.map +1 -1
  338. package/dist/src/webhook_security.js +173 -9
  339. package/dist/src/webhook_security.js.map +1 -1
  340. package/dist/stubs/config/payments.stub +13 -0
  341. package/dist/stubs/config/payments_client.stub +42 -0
  342. package/dist/stubs/config/payments_dashboard.stub +38 -0
  343. package/dist/stubs/database/migrations/create_billing_tables.stub +35 -77
  344. package/dist/stubs/main.js.map +1 -1
  345. package/dist/stubs/make/webhook_handler/main.stub +29 -11
  346. package/package.json +67 -32
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/testing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,YAAY,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,YAAY,EACV,uBAAuB,EACvB,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/testing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,YAAY,GACb,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,YAAY,EACV,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACvB,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
@@ -1,3 +1,4 @@
1
+ export { fakePayments, flushWebhooks, swapBillingStore, swapPayments, } from './fake_payments.js';
1
2
  export { FakePaymentsDriver } from './fake_payments_driver.js';
2
3
  export { InMemoryBillingStore } from './in_memory_billing_store.js';
3
4
  export { MutableClock } from './mutable_clock.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/testing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAMpE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/testing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,YAAY,GACb,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAS/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"mutable_clock.d.ts","sourceRoot":"","sources":["../../../src/testing/mutable_clock.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,qBAAa,YAAY;;gBAGX,KAAK,OAAuC;IAIxD,GAAG,IAAI,IAAI;IAIX,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAIzB,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;CAGtB"}
1
+ {"version":3,"file":"mutable_clock.d.ts","sourceRoot":"","sources":["../../../src/testing/mutable_clock.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,qBAAa,YAAY;;IAGvB,YAAY,KAAK,OAAuC,EAEvD;IAED,GAAG,IAAI,IAAI,CAEV;IAED,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAExB;IAED,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAEpB;CACF"}
@@ -9,18 +9,149 @@
9
9
  export type Money = number;
10
10
  /** ISO 4217 currency code, lowercase (e.g. `'brl'`, `'usd'`). */
11
11
  export type Currency = string;
12
- export type BillingStatus = 'pending' | 'paid' | 'failed' | 'refunded' | 'canceled' | 'disputed';
13
- export type SubscriptionStatus = 'trialing' | 'active' | 'past_due' | 'incomplete' | 'canceled' | 'ended';
14
- export type PaymentMethodType = 'card' | 'pix' | 'boleto' | 'debit_card' | 'unknown';
12
+ /**
13
+ * Where a payment stands.
14
+ *
15
+ * `authorized` is NOT `paid`: the funds are held on the customer's card and nothing has
16
+ * moved until a capture. Card gateways that separate the two (Razorpay, Square, Adyen,
17
+ * PayPal) had no name for it, so it collapsed into `pending` — which understates it — or
18
+ * `paid`, which grants access against money that can still evaporate.
19
+ */
20
+ export type BillingStatus = 'pending' | 'authorized' | 'paid' | 'failed' | 'refunded' | 'canceled' | 'disputed';
21
+ /**
22
+ * `paused` is a real state, not a flavour of `active`: the subscription exists, will bill
23
+ * again, and must NOT entitle the subscriber right now. Mapping it to `active` — which
24
+ * several gateways forced — grants access to someone who is not paying.
25
+ */
26
+ export type SubscriptionStatus = 'trialing' | 'active' | 'paused' | 'past_due' | 'incomplete' | 'canceled' | 'ended';
27
+ /** How a payment was actually paid, as reported back on a {@link Payment}. */
28
+ export type PaymentMethodType = 'card' | 'pix' | 'boleto' | 'debit_card' | 'wallet' | 'bank_transfer' | 'bank_debit' | 'upi' | 'bnpl' | 'voucher' | 'unknown';
15
29
  /**
16
30
  * Canonical payment method names used to route charges to a provider (`config.methods`).
17
31
  * `undefined` means "let the customer choose at checkout" (gateway's `UNDEFINED`).
32
+ *
33
+ * These are CATEGORIES, not brands, and deliberately so. Enumerating every local method a
34
+ * gateway offers — iDEAL, Bancontact, EPS, Przelewy24, BLIK, TWINT, MB Way, Multibanco,
35
+ * Klarna, paysafecard, and a new one every quarter — is a union that never closes, and a
36
+ * union that never closes cannot make routing a typo fail at the manager, which is the only
37
+ * reason this type is closed at all.
38
+ *
39
+ * So route by category and name the brand where it belongs: the gateway's own field, via
40
+ * `metadata`. `bank_transfer` covers the push-from-your-bank methods (iDEAL, Bancontact,
41
+ * Multibanco, Trustly); `bank_debit` the pull-from-your-account ones (SEPA Direct Debit,
42
+ * ACH); `wallet` the stored-balance and device wallets (PayPal, Apple Pay, Google Pay);
43
+ * `bnpl` the buy-now-pay-later ones; `upi` is named outright because in India it is the
44
+ * default way people pay, not a local alternative.
18
45
  */
19
- export type PaymentMethodName = 'pix' | 'credit_card' | 'debit_card' | 'boleto' | 'undefined';
46
+ export declare const PAYMENT_METHOD_NAMES: readonly ['pix', 'credit_card', 'debit_card', 'boleto', 'wallet', 'bank_transfer', 'bank_debit', 'upi', 'bnpl', 'voucher', 'undefined'];
47
+ /**
48
+ * The union, derived from the list above rather than written twice.
49
+ *
50
+ * The list exists because the routing error message used to spell the members out by hand,
51
+ * and said "pix, credit_card, debit_card, boleto, undefined" long after six more were added
52
+ * — so a reader routing `wallet` was told, by the library, that it was not a known method.
53
+ */
54
+ export type PaymentMethodName = (typeof PAYMENT_METHOD_NAMES)[number];
20
55
  export interface MoneyAmount {
21
56
  amount: Money;
22
57
  currency: Currency;
23
58
  }
59
+ /**
60
+ * Where a dispute stands. A chargeback is the only thing in this library that takes money
61
+ * back AFTER it settled, and the window to answer is measured in days.
62
+ *
63
+ * `warning` is not a dispute yet — it is the pre-chargeback alert the card networks relay
64
+ * (Stripe's Early Fraud Warning, Adyen's `NOTIFICATION_OF_FRAUD`), where refunding inside
65
+ * the window stops the chargeback from ever being filed. That matters beyond the one sale:
66
+ * a chargeback counts against the ratio that puts a merchant into a card network's
67
+ * monitoring programme, so it can be worth refunding a dispute you would have won.
68
+ */
69
+ export type DisputeStatus = 'warning' | 'open' | 'under_review' | 'won' | 'lost' | 'canceled' | 'expired';
70
+ /** A chargeback or pre-chargeback alert, normalized across gateways. */
71
+ export interface Dispute {
72
+ /** The gateway's id for the dispute itself — NOT the payment's. */
73
+ id: string;
74
+ provider: string;
75
+ /** The disputed payment's gateway id. */
76
+ paymentGatewayId: string;
77
+ status: DisputeStatus;
78
+ /**
79
+ * How much is being disputed, in the currency's smallest unit. Not always the whole
80
+ * payment: a partial chargeback is normal.
81
+ */
82
+ amount?: MoneyAmount;
83
+ /** The gateway's own reason code, verbatim — the vocabulary is per-network. */
84
+ reason?: string;
85
+ /**
86
+ * When evidence must be submitted by. The single most operationally important field
87
+ * here: past it, the dispute is lost by default and nothing can be done.
88
+ */
89
+ evidenceDueBy?: string;
90
+ /** Whether this gateway will still accept evidence — most accept it ONCE. */
91
+ canSubmitEvidence?: boolean;
92
+ createdAt?: string;
93
+ payload: Record<string, unknown>;
94
+ }
95
+ /**
96
+ * Evidence for a representment.
97
+ *
98
+ * Every field is optional because no gateway wants all of them and no app has all of them,
99
+ * but the shape is deliberately concrete rather than a bag: a driver has to map onto the
100
+ * gateway's own field names, and it cannot map what it cannot recognize.
101
+ */
102
+ export interface DisputeEvidence {
103
+ /** Free-text explanation. Most gateways weigh this heavily. */
104
+ explanation?: string;
105
+ shippingCarrier?: string;
106
+ shippingTrackingNumber?: string;
107
+ shippingDate?: string;
108
+ serviceDate?: string;
109
+ /** When the customer accepted the terms. The terms themselves are a {@link DisputeDocument}. */
110
+ termsAcceptedAt?: string;
111
+ customerName?: string;
112
+ customerEmail?: string;
113
+ customerIpAddress?: string;
114
+ /**
115
+ * Prior charges to the same customer that were never disputed — the strongest signal the
116
+ * card networks accept, and the reason this is a list of transactions rather than a count.
117
+ * Visa's Compelling Evidence 3.0 wants the charges themselves, each with the account, device
118
+ * and IP it was made from; a number is not evidence of anything.
119
+ */
120
+ priorUndisputedPayments?: PriorUndisputedPayment[];
121
+ /** Documents already uploaded to the gateway, each addressed by what it proves. */
122
+ documents?: DisputeDocument[];
123
+ /** Anything gateway-specific the shape above has no name for. */
124
+ metadata?: Record<string, unknown>;
125
+ }
126
+ /**
127
+ * What a piece of evidence proves, which is what every gateway files it by.
128
+ *
129
+ * Not a free-form label: a bare list of upload ids cannot be submitted anywhere, because
130
+ * the gateway needs to know which id is the receipt and which is the shipping proof. Stripe
131
+ * has nine separate file fields, Adyen has a `defenseDocumentTypeCode`, and neither can be
132
+ * reached with "here are some files".
133
+ */
134
+ export type DisputeDocumentKind = 'receipt' | 'invoice' | 'customer_communication' | 'customer_signature' | 'shipping' | 'service' | 'refund_policy' | 'cancellation_policy' | 'terms' | 'duplicate_charge' | 'other';
135
+ /**
136
+ * A document already uploaded to the gateway, by its own file id.
137
+ *
138
+ * A file id, never a URL. The banks reviewing a dispute do not follow links, and no gateway
139
+ * in this package accepts one — the evidence has to be bytes the gateway already holds.
140
+ */
141
+ export interface DisputeDocument {
142
+ kind: DisputeDocumentKind;
143
+ /** The gateway's own id for the uploaded file. */
144
+ id: string;
145
+ }
146
+ /** A prior charge to the same customer that was never disputed. */
147
+ export interface PriorUndisputedPayment {
148
+ /** The gateway's id for that charge. */
149
+ paymentGatewayId: string;
150
+ /** The account the customer was signed into, if the gateway asks for one. */
151
+ customerAccountId?: string;
152
+ customerIpAddress?: string;
153
+ customerDeviceId?: string;
154
+ }
24
155
  /** A customer as seen by the gateway. */
25
156
  export interface Customer {
26
157
  id: string;
@@ -46,8 +177,26 @@ export interface Payment {
46
177
  payload: Record<string, unknown>;
47
178
  createdAt: string;
48
179
  paidAt?: string;
49
- /** Pix QR code / copy-paste code when the gateway provides one. */
180
+ /**
181
+ * Base64-encoded PNG of the Pix QR code, when the gateway returns one.
182
+ * Render it directly (`data:image/png;base64,${pixQrCodeImage}`) — it is an image,
183
+ * not something the customer can copy.
184
+ */
185
+ pixQrCodeImage?: string;
186
+ /**
187
+ * The Pix BR Code (EMV payload) — the plain-text string behind the QR code, and the
188
+ * one the customer copies and pastes into their bank app ("Pix copia e cola").
189
+ */
190
+ pixCode?: string;
191
+ /**
192
+ * @deprecated Misleading name — it holds the QR **image**, not a code. Use {@link Payment.pixQrCodeImage}.
193
+ * Still populated with the same value for backward compatibility.
194
+ */
50
195
  pixQrCode?: string;
196
+ /**
197
+ * @deprecated Portuguese name for the BR Code payload. Use {@link Payment.pixCode}.
198
+ * Still populated with the same value for backward compatibility.
199
+ */
51
200
  pixCopiaECola?: string;
52
201
  /** URL to a hosted checkout/charge page when the gateway provides one. */
53
202
  hostedUrl?: string;
@@ -70,6 +219,13 @@ export interface CheckoutSession {
70
219
  provider: string;
71
220
  /** URL to redirect the customer to (hosted checkout). */
72
221
  url: string;
222
+ /**
223
+ * Pix BR Code (EMV payload) for a checkout the gateway settles over Pix — the
224
+ * string the payer copies. Same field as {@link Payment.pixCode}.
225
+ */
226
+ pixCode?: string;
227
+ /** @deprecated Renamed to {@link CheckoutSession.pixCode}. Still populated. */
228
+ pixCopiaECola?: string;
73
229
  status: 'open' | 'complete' | 'expired';
74
230
  amount?: MoneyAmount;
75
231
  /** The subscription created by this checkout, when it was a subscription checkout. */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,kFAAkF;AAClF,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC;AAE3B,iEAAiE;AACjE,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE9B,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,UAAU,GAAG,UAAU,GAAG,UAAU,CAAC;AAEjG,MAAM,MAAM,kBAAkB,GAC1B,UAAU,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, so the
6
6
  * billing layer and application code never touch gateway-specific payloads.
7
7
  */
8
- export {};
8
+ /**
9
+ * Canonical payment method names used to route charges to a provider (`config.methods`).
10
+ * `undefined` means "let the customer choose at checkout" (gateway's `UNDEFINED`).
11
+ *
12
+ * These are CATEGORIES, not brands, and deliberately so. Enumerating every local method a
13
+ * gateway offers — iDEAL, Bancontact, EPS, Przelewy24, BLIK, TWINT, MB Way, Multibanco,
14
+ * Klarna, paysafecard, and a new one every quarter — is a union that never closes, and a
15
+ * union that never closes cannot make routing a typo fail at the manager, which is the only
16
+ * reason this type is closed at all.
17
+ *
18
+ * So route by category and name the brand where it belongs: the gateway's own field, via
19
+ * `metadata`. `bank_transfer` covers the push-from-your-bank methods (iDEAL, Bancontact,
20
+ * Multibanco, Trustly); `bank_debit` the pull-from-your-account ones (SEPA Direct Debit,
21
+ * ACH); `wallet` the stored-balance and device wallets (PayPal, Apple Pay, Google Pay);
22
+ * `bnpl` the buy-now-pay-later ones; `upi` is named outright because in India it is the
23
+ * default way people pay, not a local alternative.
24
+ */
25
+ export const PAYMENT_METHOD_NAMES = [
26
+ 'pix',
27
+ 'credit_card',
28
+ 'debit_card',
29
+ 'boleto',
30
+ 'wallet',
31
+ 'bank_transfer',
32
+ 'bank_debit',
33
+ 'upi',
34
+ 'bnpl',
35
+ 'voucher',
36
+ 'undefined',
37
+ ];
9
38
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAqDH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,KAAK;IACL,aAAa;IACb,YAAY;IACZ,QAAQ;IACR,QAAQ;IACR,eAAe;IACf,YAAY;IACZ,KAAK;IACL,MAAM;IACN,SAAS;IACT,WAAW;CACH,CAAC"}
@@ -1,5 +1,67 @@
1
+ import type { DisputeWebhookData, PaymentWebhookData, SubscriptionWebhookData, WebhookEventType } from './billing/webhook_events.js';
1
2
  import type { WebhookHandler } from './billing/webhook_processor.js';
2
3
  import type { WebhookEvent } from './types.js';
4
+ /**
5
+ * Which normalized payload each canonical event type carries.
6
+ *
7
+ * The map exists because `WebhookEvent<T = unknown>` made every handler open with a cast —
8
+ * `const data = event.data as PaymentWebhookData` — and a cast is a claim nothing checks.
9
+ * `payment.disputed` carries a {@link DisputeWebhookData}, not a payment payload, so the
10
+ * copy-pasted cast was simply WRONG on that one handler: it read `amount`/`currency` as
11
+ * required off a shape where a Stripe early fraud warning has neither.
12
+ *
13
+ * Pair a type with its payload here once and {@link defineWebhookHandler} infers it, so the
14
+ * wrong pairing is a compile error instead of a runtime `undefined`.
15
+ */
16
+ export interface WebhookEventDataMap {
17
+ 'payment.succeeded': PaymentWebhookData;
18
+ 'payment.failed': PaymentWebhookData;
19
+ 'payment.refunded': PaymentWebhookData;
20
+ 'payment.updated': PaymentWebhookData;
21
+ 'payment.disputed': DisputeWebhookData;
22
+ 'payment.dispute_warning': DisputeWebhookData;
23
+ 'payment.dispute_closed': DisputeWebhookData;
24
+ 'subscription.created': SubscriptionWebhookData;
25
+ 'subscription.updated': SubscriptionWebhookData;
26
+ 'subscription.canceled': SubscriptionWebhookData;
27
+ }
28
+ /**
29
+ * The payload a handler for `T` receives. Canonical types resolve through
30
+ * {@link WebhookEventDataMap}; anything else is a driver passthrough (drivers lowercase the
31
+ * gateway events they cannot map) whose shape this library cannot know, so it stays
32
+ * `unknown` — which is honest, and forces a narrowing the app can see.
33
+ */
34
+ export type WebhookEventDataFor<T extends string> = T extends WebhookEventType ? WebhookEventDataMap[T] : unknown;
35
+ /** A {@link WebhookEvent} narrowed to one event type, payload included. */
36
+ export type WebhookEventFor<T extends string> = WebhookEvent<WebhookEventDataFor<T>> & {
37
+ type: T;
38
+ };
39
+ /** A handler that knows which event it is for — and therefore what `event.data` is. */
40
+ export type TypedWebhookHandler<T extends string> = (event: WebhookEventFor<T>) => void | Promise<void>;
41
+ /**
42
+ * What {@link defineWebhookHandler} returns: callable as a plain {@link WebhookHandler} (so
43
+ * it drops straight into `billing.handlers`) AND carrying `type`/`handle` (so it is a valid
44
+ * default export for the `app/payment_handlers/` convention). One value, both wiring styles.
45
+ */
46
+ export interface WebhookHandlerDefinition<T extends string = string> {
47
+ (event: WebhookEvent): void | Promise<void>;
48
+ readonly type: T;
49
+ readonly handle: WebhookHandler;
50
+ }
51
+ /**
52
+ * Declare a webhook handler for ONE event type, with `event.data` inferred from the type.
53
+ *
54
+ * ```ts
55
+ * export default defineWebhookHandler('payment.disputed', async (event) => {
56
+ * event.data.actionableUntil // DisputeWebhookData — no cast
57
+ * event.data.paidAt // compile error: that is a payment payload
58
+ * })
59
+ * ```
60
+ *
61
+ * A passthrough type the driver did not map is accepted (it is a real thing a gateway
62
+ * sends), and its `data` is `unknown` because nothing normalized it.
63
+ */
64
+ export declare function defineWebhookHandler<T extends WebhookEventType | (string & {})>(type: T, handle: TypedWebhookHandler<T>): WebhookHandlerDefinition<T>;
3
65
  /**
4
66
  * A webhook-handler service constructor: the lib resolves it from the Adonis container
5
67
  * (DI works) and calls `handle(event)` for each event of the registered type. A class
@@ -34,6 +96,13 @@ export declare function resolveWebhookHandler(entry: WebhookHandler | WebhookHan
34
96
  export interface DiscoveredWebhookHandler {
35
97
  type: string;
36
98
  entry: WebhookHandler | WebhookHandlerService;
99
+ /**
100
+ * Where it came from — the module path for a scan, the barrel key for a build-time
101
+ * barrel, `config.billing.handlers` for a configured one. Only ever used in messages, and
102
+ * that is the point: "two handlers claim payment.succeeded" is not actionable without the
103
+ * two file names.
104
+ */
105
+ source?: string;
37
106
  }
38
107
  /** Shape each file in the conventions folder must default-export. */
39
108
  export interface WebhookHandlerModule {
@@ -41,14 +110,39 @@ export interface WebhookHandlerModule {
41
110
  * Normalized event type this handler listens to (e.g. `'payment.succeeded'`). A service
42
111
  * class declares it as `static eventType` instead.
43
112
  */
44
- type?: string;
113
+ type?: WebhookEventType | (string & {});
45
114
  /** Event-type static on a service class form. */
46
- eventType?: string;
115
+ eventType?: WebhookEventType | (string & {});
47
116
  /** The handler function (object form). */
48
117
  handle?: WebhookHandler;
49
118
  }
50
119
  /** Normalize a module's default export into a {@link DiscoveredWebhookHandler}, or null. */
51
120
  export declare function normalizeWebhookHandlerModule(mod: unknown): DiscoveredWebhookHandler | null;
121
+ /**
122
+ * One handler registration, as the boot-time check sees it: which type it claims and where
123
+ * it came from.
124
+ */
125
+ export interface WebhookHandlerRegistration {
126
+ type: string;
127
+ source: string;
128
+ }
129
+ /**
130
+ * Refuse, at boot, a handler registered for an event type nothing will ever deliver.
131
+ *
132
+ * The failure this closes is silent end to end: `normalizeWebhookHandlerModule` accepted any
133
+ * string, the provider did `handlers[type] = ...`, and the processor looked up
134
+ * `#handlers[event.type]` and skipped a miss. So `'payment.suceeded'` registered a handler
135
+ * nothing called, the ledger still marked the delivery `processed`, and the grant simply
136
+ * never happened — with a 200 to the gateway promising it never has to send that event
137
+ * again.
138
+ *
139
+ * Two registrations of the SAME type are refused for the same reason: `handlers[type] = ...`
140
+ * overwrites, so the second file silently replaced the first and one of the two handlers
141
+ * never ran again.
142
+ */
143
+ export declare function assertWebhookHandlerTypes(registrations: readonly WebhookHandlerRegistration[], options?: {
144
+ passthroughEvents?: readonly string[];
145
+ }): void;
52
146
  /** The build-time barrel the Assembler `init` hook generates — a map of key → lazy import. */
53
147
  export type WebhookHandlersBarrel = Record<string, () => Promise<Record<string, unknown>>>;
54
148
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"webhook_handlers.d.ts","sourceRoot":"","sources":["../../src/webhook_handlers.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C;;;;GAIG;A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AyB9F"}
@@ -1,6 +1,30 @@
1
1
  import { readdir } from 'node:fs/promises';
2
2
  import { extname, join } from 'node:path';
3
3
  import { pathToFileURL } from 'node:url';
4
+ import { WEBHOOK_EVENT_TYPES } from './billing/webhook_events.js';
5
+ /**
6
+ * Declare a webhook handler for ONE event type, with `event.data` inferred from the type.
7
+ *
8
+ * ```ts
9
+ * export default defineWebhookHandler('payment.disputed', async (event) => {
10
+ * event.data.actionableUntil // DisputeWebhookData — no cast
11
+ * event.data.paidAt // compile error: that is a payment payload
12
+ * })
13
+ * ```
14
+ *
15
+ * A passthrough type the driver did not map is accepted (it is a real thing a gateway
16
+ * sends), and its `data` is `unknown` because nothing normalized it.
17
+ */
18
+ export function defineWebhookHandler(type, handle) {
19
+ // The ONE cast, here, instead of one in every application handler. It is sound in exactly
20
+ // the way the app-side cast was not: the type is checked against the same map the payload
21
+ // came from, and validated at boot by `assertWebhookHandlerTypes`.
22
+ const wrapped = (event) => handle(event);
23
+ return Object.assign(wrapped, {
24
+ type,
25
+ handle: wrapped,
26
+ });
27
+ }
4
28
  /**
5
29
  * Detect a {@link WebhookHandlerService} (a class with a `handle` method) vs a plain
6
30
  * handler function. Arrow functions have no prototype; named functions have one without
@@ -31,17 +55,74 @@ export function normalizeWebhookHandlerModule(mod) {
31
55
  const type = candidate.type ?? candidate.eventType;
32
56
  if (typeof type !== 'string')
33
57
  return null;
34
- if (typeof mod === 'function') {
35
- // Service class form: `static eventType` + instance `handle`.
36
- if (isWebhookHandlerService(mod))
37
- return { type, entry: mod };
38
- return null;
39
- }
40
- // Object form: `{ type, handle }`.
58
+ // Service class form: `static eventType` + instance `handle` (on the prototype, so the
59
+ // class itself has no own `handle` and never reaches the branch below).
60
+ if (typeof mod === 'function' && isWebhookHandlerService(mod))
61
+ return { type, entry: mod };
62
+ // Object form `{ type, handle }` — and the function form {@link defineWebhookHandler}
63
+ // returns, which is a callable carrying the same two members.
41
64
  if (typeof candidate.handle !== 'function')
42
65
  return null;
43
66
  return { type, entry: candidate.handle };
44
67
  }
68
+ /**
69
+ * A type that LOOKS canonical: same namespace as the library's own types, so a typo lands
70
+ * here rather than being waved through as a gateway passthrough.
71
+ *
72
+ * This is the whole honest rule. A driver that cannot map a gateway event passes it through
73
+ * lowercased — Asaas turns `PAYMENT_ANTICIPATED` into `payment_anticipated`, Adyen turns
74
+ * `REPORT_AVAILABLE` into `report_available` — and a library cannot enumerate every event
75
+ * eighteen gateways can send. What it CAN say is that `payment.` and `subscription.`
76
+ * followed by a dot are ITS namespace: every member of {@link WEBHOOK_EVENT_TYPES} is in it,
77
+ * a passthrough of an unmapped event is not (`payment_anticipated` has no dot), and
78
+ * `payment.suceeded` is a misspelling of something the library owns.
79
+ */
80
+ function isCanonicalNamespace(type) {
81
+ return /^(payment|subscription)\.[a-z_]+$/.test(type);
82
+ }
83
+ /**
84
+ * Refuse, at boot, a handler registered for an event type nothing will ever deliver.
85
+ *
86
+ * The failure this closes is silent end to end: `normalizeWebhookHandlerModule` accepted any
87
+ * string, the provider did `handlers[type] = ...`, and the processor looked up
88
+ * `#handlers[event.type]` and skipped a miss. So `'payment.suceeded'` registered a handler
89
+ * nothing called, the ledger still marked the delivery `processed`, and the grant simply
90
+ * never happened — with a 200 to the gateway promising it never has to send that event
91
+ * again.
92
+ *
93
+ * Two registrations of the SAME type are refused for the same reason: `handlers[type] = ...`
94
+ * overwrites, so the second file silently replaced the first and one of the two handlers
95
+ * never ran again.
96
+ */
97
+ export function assertWebhookHandlerTypes(registrations, options = {}) {
98
+ const allowed = new Set(options.passthroughEvents ?? []);
99
+ const seen = new Map();
100
+ for (const { type, source } of registrations) {
101
+ const known = WEBHOOK_EVENT_TYPES.includes(type);
102
+ if (!known && !allowed.has(type) && isCanonicalNamespace(type)) {
103
+ throw new Error([
104
+ `[payments] Webhook handler (${source}) is registered for "${type}", which is not a`,
105
+ 'normalized event type — nothing will ever call it, and the delivery will still be',
106
+ `recorded as processed. Normalized types: ${WEBHOOK_EVENT_TYPES.join(', ')}.`,
107
+ 'A type in the `payment.*`/`subscription.*` namespace must be one of those, because',
108
+ "that namespace is the library's own. A gateway type the driver could not map arrives",
109
+ 'lowercased as the gateway spells it (Asaas `PAYMENT_ANTICIPATED` →',
110
+ '"payment_anticipated"), which is accepted as-is; if your gateway really does spell one',
111
+ 'with a dot in this namespace, list it in `billing.passthroughEvents`.',
112
+ ].join(' '));
113
+ }
114
+ const previous = seen.get(type);
115
+ if (previous !== undefined) {
116
+ throw new Error([
117
+ `[payments] Two webhook handlers claim "${type}": ${previous} and ${source}.`,
118
+ 'Registration is a map keyed by event type, so the second silently replaced the first',
119
+ 'and one of them would never run. Keep one handler per type (call the other from it)',
120
+ 'or give them different types.',
121
+ ].join(' '));
122
+ }
123
+ seen.set(type, source);
124
+ }
125
+ }
45
126
  /**
46
127
  * Load the generated barrel (`.adonisjs/payments/webhook_handlers.js`) — the build-time
47
128
  * equivalent of a directory scan, with no runtime `readdir`. Each module's default export
@@ -50,7 +131,7 @@ export function normalizeWebhookHandlerModule(mod) {
50
131
  export async function loadWebhookHandlersFromBarrel(barrel) {
51
132
  const found = [];
52
133
  const seen = new Set();
53
- for (const load of Object.values(barrel)) {
134
+ for (const [key, load] of Object.entries(barrel)) {
54
135
  const mod = await load();
55
136
  for (const exported of Object.values(mod)) {
56
137
  if (seen.has(exported))
@@ -59,7 +140,7 @@ export async function loadWebhookHandlersFromBarrel(barrel) {
59
140
  if (!normalized)
60
141
  continue;
61
142
  seen.add(exported);
62
- found.push(normalized);
143
+ found.push({ ...normalized, source: key });
63
144
  }
64
145
  }
65
146
  return found;
@@ -121,7 +202,7 @@ export async function discoverWebhookHandlers(dir) {
121
202
  if (seen.has(normalized.entry))
122
203
  continue;
123
204
  seen.add(normalized.entry);
124
- found.push(normalized);
205
+ found.push({ ...normalized, source: join(dir, entry) });
125
206
  }
126
207
  return found;
127
208
  }
@@ -1 +1 @@
1
- {"version":3,"file":"webhook_handlers.js","sourceRoot":"","sources":["../../src/webhook_handlers.ts"],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