@adonis-agora/payments 0.2.0 → 0.3.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 (319) hide show
  1. package/CHANGELOG.md +2347 -0
  2. package/dist/assets/spa/assets/index-CT5Zon6P.css +1 -0
  3. package/dist/assets/spa/assets/index-CvEbJEnq.js +41 -0
  4. package/dist/assets/spa/assets/index-CvEbJEnq.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/payments_health.d.ts +31 -0
  11. package/dist/commands/payments_health.d.ts.map +1 -0
  12. package/dist/commands/payments_health.js +113 -0
  13. package/dist/commands/payments_health.js.map +1 -0
  14. package/dist/commands/payments_sync.d.ts +18 -4
  15. package/dist/commands/payments_sync.d.ts.map +1 -1
  16. package/dist/commands/payments_sync.js +136 -40
  17. package/dist/commands/payments_sync.js.map +1 -1
  18. package/dist/configure.d.ts +12 -5
  19. package/dist/configure.d.ts.map +1 -1
  20. package/dist/configure.js +18 -5
  21. package/dist/configure.js.map +1 -1
  22. package/dist/providers/dashboard_provider.d.ts +97 -0
  23. package/dist/providers/dashboard_provider.d.ts.map +1 -0
  24. package/dist/providers/dashboard_provider.js +430 -0
  25. package/dist/providers/dashboard_provider.js.map +1 -0
  26. package/dist/providers/payments_client_provider.d.ts +41 -0
  27. package/dist/providers/payments_client_provider.d.ts.map +1 -0
  28. package/dist/providers/payments_client_provider.js +95 -0
  29. package/dist/providers/payments_client_provider.js.map +1 -0
  30. package/dist/providers/payments_provider.d.ts +35 -0
  31. package/dist/providers/payments_provider.d.ts.map +1 -1
  32. package/dist/providers/payments_provider.js +250 -36
  33. package/dist/providers/payments_provider.js.map +1 -1
  34. package/dist/src/billing/billing_health.d.ts +85 -0
  35. package/dist/src/billing/billing_health.d.ts.map +1 -0
  36. package/dist/src/billing/billing_health.js +155 -0
  37. package/dist/src/billing/billing_health.js.map +1 -0
  38. package/dist/src/billing/billing_overview.d.ts +4 -3
  39. package/dist/src/billing/billing_overview.d.ts.map +1 -1
  40. package/dist/src/billing/billing_overview.js +14 -5
  41. package/dist/src/billing/billing_overview.js.map +1 -1
  42. package/dist/src/billing/billing_store.d.ts +634 -5
  43. package/dist/src/billing/billing_store.d.ts.map +1 -1
  44. package/dist/src/billing/billing_store.js +18 -1
  45. package/dist/src/billing/billing_store.js.map +1 -1
  46. package/dist/src/billing/index.d.ts +2 -1
  47. package/dist/src/billing/index.d.ts.map +1 -1
  48. package/dist/src/billing/index.js +1 -0
  49. package/dist/src/billing/index.js.map +1 -1
  50. package/dist/src/billing/list_query.d.ts +16 -0
  51. package/dist/src/billing/list_query.d.ts.map +1 -0
  52. package/dist/src/billing/list_query.js +28 -0
  53. package/dist/src/billing/list_query.js.map +1 -0
  54. package/dist/src/billing/lucid_billing_store.d.ts +122 -4
  55. package/dist/src/billing/lucid_billing_store.d.ts.map +1 -1
  56. package/dist/src/billing/lucid_billing_store.js +811 -13
  57. package/dist/src/billing/lucid_billing_store.js.map +1 -1
  58. package/dist/src/billing/mixins/index.d.ts +3 -0
  59. package/dist/src/billing/mixins/index.d.ts.map +1 -1
  60. package/dist/src/billing/mixins/index.js +3 -0
  61. package/dist/src/billing/mixins/index.js.map +1 -1
  62. package/dist/src/billing/mixins/with_audit_event.d.ts +48 -0
  63. package/dist/src/billing/mixins/with_audit_event.d.ts.map +1 -0
  64. package/dist/src/billing/mixins/with_audit_event.js +77 -0
  65. package/dist/src/billing/mixins/with_audit_event.js.map +1 -0
  66. package/dist/src/billing/mixins/with_customer.d.ts +39 -0
  67. package/dist/src/billing/mixins/with_customer.d.ts.map +1 -0
  68. package/dist/src/billing/mixins/with_customer.js +68 -0
  69. package/dist/src/billing/mixins/with_customer.js.map +1 -0
  70. package/dist/src/billing/mixins/with_dispute.d.ts +68 -0
  71. package/dist/src/billing/mixins/with_dispute.d.ts.map +1 -0
  72. package/dist/src/billing/mixins/with_dispute.js +83 -0
  73. package/dist/src/billing/mixins/with_dispute.js.map +1 -0
  74. package/dist/src/billing/mixins/with_payment.d.ts +42 -0
  75. package/dist/src/billing/mixins/with_payment.d.ts.map +1 -1
  76. package/dist/src/billing/mixins/with_payment.js +29 -3
  77. package/dist/src/billing/mixins/with_payment.js.map +1 -1
  78. package/dist/src/billing/mixins/with_subscription.d.ts +7 -0
  79. package/dist/src/billing/mixins/with_subscription.d.ts.map +1 -1
  80. package/dist/src/billing/mixins/with_subscription.js +15 -1
  81. package/dist/src/billing/mixins/with_subscription.js.map +1 -1
  82. package/dist/src/billing/mixins/with_usage_event.d.ts +7 -0
  83. package/dist/src/billing/mixins/with_usage_event.d.ts.map +1 -1
  84. package/dist/src/billing/mixins/with_usage_event.js +15 -1
  85. package/dist/src/billing/mixins/with_usage_event.js.map +1 -1
  86. package/dist/src/billing/mixins/with_webhook_event.d.ts +18 -0
  87. package/dist/src/billing/mixins/with_webhook_event.d.ts.map +1 -1
  88. package/dist/src/billing/mixins/with_webhook_event.js +18 -1
  89. package/dist/src/billing/mixins/with_webhook_event.js.map +1 -1
  90. package/dist/src/billing/resolve_dispatch.d.ts +22 -0
  91. package/dist/src/billing/resolve_dispatch.d.ts.map +1 -0
  92. package/dist/src/billing/resolve_dispatch.js +44 -0
  93. package/dist/src/billing/resolve_dispatch.js.map +1 -0
  94. package/dist/src/billing/resolve_store.d.ts +18 -0
  95. package/dist/src/billing/resolve_store.d.ts.map +1 -0
  96. package/dist/src/billing/resolve_store.js +35 -0
  97. package/dist/src/billing/resolve_store.js.map +1 -0
  98. package/dist/src/billing/schema.d.ts +108 -0
  99. package/dist/src/billing/schema.d.ts.map +1 -0
  100. package/dist/src/billing/schema.js +350 -0
  101. package/dist/src/billing/schema.js.map +1 -0
  102. package/dist/src/billing/webhook_dispatcher.d.ts +95 -16
  103. package/dist/src/billing/webhook_dispatcher.d.ts.map +1 -1
  104. package/dist/src/billing/webhook_dispatcher.js +186 -33
  105. package/dist/src/billing/webhook_dispatcher.js.map +1 -1
  106. package/dist/src/billing/webhook_events.d.ts +67 -1
  107. package/dist/src/billing/webhook_events.d.ts.map +1 -1
  108. package/dist/src/billing/webhook_events.js +15 -0
  109. package/dist/src/billing/webhook_events.js.map +1 -1
  110. package/dist/src/billing/webhook_processor.d.ts.map +1 -1
  111. package/dist/src/billing/webhook_processor.js +325 -5
  112. package/dist/src/billing/webhook_processor.js.map +1 -1
  113. package/dist/src/client/define_config.d.ts +150 -0
  114. package/dist/src/client/define_config.d.ts.map +1 -0
  115. package/dist/src/client/define_config.js +98 -0
  116. package/dist/src/client/define_config.js.map +1 -0
  117. package/dist/src/client/handlers.d.ts +71 -0
  118. package/dist/src/client/handlers.d.ts.map +1 -0
  119. package/dist/src/client/handlers.js +119 -0
  120. package/dist/src/client/handlers.js.map +1 -0
  121. package/dist/src/client/index.d.ts +16 -0
  122. package/dist/src/client/index.d.ts.map +1 -0
  123. package/dist/src/client/index.js +13 -0
  124. package/dist/src/client/index.js.map +1 -0
  125. package/dist/src/client/statuses.d.ts +38 -0
  126. package/dist/src/client/statuses.d.ts.map +1 -0
  127. package/dist/src/client/statuses.js +42 -0
  128. package/dist/src/client/statuses.js.map +1 -0
  129. package/dist/src/dashboard/actions.d.ts +143 -0
  130. package/dist/src/dashboard/actions.d.ts.map +1 -0
  131. package/dist/src/dashboard/actions.js +112 -0
  132. package/dist/src/dashboard/actions.js.map +1 -0
  133. package/dist/src/dashboard/auth.d.ts +136 -0
  134. package/dist/src/dashboard/auth.d.ts.map +1 -0
  135. package/dist/src/dashboard/auth.js +152 -0
  136. package/dist/src/dashboard/auth.js.map +1 -0
  137. package/dist/src/dashboard/define_config.d.ts +80 -0
  138. package/dist/src/dashboard/define_config.d.ts.map +1 -0
  139. package/dist/src/dashboard/define_config.js +83 -0
  140. package/dist/src/dashboard/define_config.js.map +1 -0
  141. package/dist/src/dashboard/handlers.d.ts +281 -0
  142. package/dist/src/dashboard/handlers.d.ts.map +1 -0
  143. package/dist/src/dashboard/handlers.js +960 -0
  144. package/dist/src/dashboard/handlers.js.map +1 -0
  145. package/dist/src/dashboard/index.d.ts +18 -0
  146. package/dist/src/dashboard/index.d.ts.map +1 -0
  147. package/dist/src/dashboard/index.js +14 -0
  148. package/dist/src/dashboard/index.js.map +1 -0
  149. package/dist/src/dashboard/login_page.d.ts +23 -0
  150. package/dist/src/dashboard/login_page.d.ts.map +1 -0
  151. package/dist/src/dashboard/login_page.js +170 -0
  152. package/dist/src/dashboard/login_page.js.map +1 -0
  153. package/dist/src/dashboard/period.d.ts +31 -0
  154. package/dist/src/dashboard/period.d.ts.map +1 -0
  155. package/dist/src/dashboard/period.js +44 -0
  156. package/dist/src/dashboard/period.js.map +1 -0
  157. package/dist/src/dashboard/session_cookie.d.ts +42 -0
  158. package/dist/src/dashboard/session_cookie.d.ts.map +1 -0
  159. package/dist/src/dashboard/session_cookie.js +97 -0
  160. package/dist/src/dashboard/session_cookie.js.map +1 -0
  161. package/dist/src/dashboard/spa.d.ts +24 -0
  162. package/dist/src/dashboard/spa.d.ts.map +1 -0
  163. package/dist/src/dashboard/spa.js +52 -0
  164. package/dist/src/dashboard/spa.js.map +1 -0
  165. package/dist/src/define_config.d.ts +244 -9
  166. package/dist/src/define_config.d.ts.map +1 -1
  167. package/dist/src/define_config.js +97 -1
  168. package/dist/src/define_config.js.map +1 -1
  169. package/dist/src/diagnostics.d.ts +287 -7
  170. package/dist/src/diagnostics.d.ts.map +1 -1
  171. package/dist/src/diagnostics.js +317 -1
  172. package/dist/src/diagnostics.js.map +1 -1
  173. package/dist/src/driver.d.ts +139 -5
  174. package/dist/src/driver.d.ts.map +1 -1
  175. package/dist/src/drivers/abacate.d.ts +12 -2
  176. package/dist/src/drivers/abacate.d.ts.map +1 -1
  177. package/dist/src/drivers/abacate.js +112 -19
  178. package/dist/src/drivers/abacate.js.map +1 -1
  179. package/dist/src/drivers/adyen.d.ts +164 -0
  180. package/dist/src/drivers/adyen.d.ts.map +1 -0
  181. package/dist/src/drivers/adyen.js +678 -0
  182. package/dist/src/drivers/adyen.js.map +1 -0
  183. package/dist/src/drivers/asaas.d.ts +52 -2
  184. package/dist/src/drivers/asaas.d.ts.map +1 -1
  185. package/dist/src/drivers/asaas.js +364 -29
  186. package/dist/src/drivers/asaas.js.map +1 -1
  187. package/dist/src/drivers/dodo.d.ts +135 -0
  188. package/dist/src/drivers/dodo.d.ts.map +1 -0
  189. package/dist/src/drivers/dodo.js +864 -0
  190. package/dist/src/drivers/dodo.js.map +1 -0
  191. package/dist/src/drivers/efi.d.ts +98 -0
  192. package/dist/src/drivers/efi.d.ts.map +1 -0
  193. package/dist/src/drivers/efi.js +628 -0
  194. package/dist/src/drivers/efi.js.map +1 -0
  195. package/dist/src/drivers/infinitepay.d.ts +156 -0
  196. package/dist/src/drivers/infinitepay.d.ts.map +1 -0
  197. package/dist/src/drivers/infinitepay.js +321 -0
  198. package/dist/src/drivers/infinitepay.js.map +1 -0
  199. package/dist/src/drivers/lemonsqueezy.d.ts +125 -0
  200. package/dist/src/drivers/lemonsqueezy.d.ts.map +1 -0
  201. package/dist/src/drivers/lemonsqueezy.js +632 -0
  202. package/dist/src/drivers/lemonsqueezy.js.map +1 -0
  203. package/dist/src/drivers/mercadopago.d.ts +97 -0
  204. package/dist/src/drivers/mercadopago.d.ts.map +1 -0
  205. package/dist/src/drivers/mercadopago.js +844 -0
  206. package/dist/src/drivers/mercadopago.js.map +1 -0
  207. package/dist/src/drivers/mollie.d.ts +125 -0
  208. package/dist/src/drivers/mollie.d.ts.map +1 -0
  209. package/dist/src/drivers/mollie.js +812 -0
  210. package/dist/src/drivers/mollie.js.map +1 -0
  211. package/dist/src/drivers/paddle.d.ts +148 -0
  212. package/dist/src/drivers/paddle.d.ts.map +1 -0
  213. package/dist/src/drivers/paddle.js +738 -0
  214. package/dist/src/drivers/paddle.js.map +1 -0
  215. package/dist/src/drivers/pagarme.d.ts +97 -0
  216. package/dist/src/drivers/pagarme.d.ts.map +1 -0
  217. package/dist/src/drivers/pagarme.js +829 -0
  218. package/dist/src/drivers/pagarme.js.map +1 -0
  219. package/dist/src/drivers/pagbank.d.ts +57 -0
  220. package/dist/src/drivers/pagbank.d.ts.map +1 -0
  221. package/dist/src/drivers/pagbank.js +499 -0
  222. package/dist/src/drivers/pagbank.js.map +1 -0
  223. package/dist/src/drivers/paypal.d.ts +120 -0
  224. package/dist/src/drivers/paypal.d.ts.map +1 -0
  225. package/dist/src/drivers/paypal.js +891 -0
  226. package/dist/src/drivers/paypal.js.map +1 -0
  227. package/dist/src/drivers/polar.d.ts +118 -0
  228. package/dist/src/drivers/polar.d.ts.map +1 -0
  229. package/dist/src/drivers/polar.js +604 -0
  230. package/dist/src/drivers/polar.js.map +1 -0
  231. package/dist/src/drivers/razorpay.d.ts +103 -0
  232. package/dist/src/drivers/razorpay.d.ts.map +1 -0
  233. package/dist/src/drivers/razorpay.js +867 -0
  234. package/dist/src/drivers/razorpay.js.map +1 -0
  235. package/dist/src/drivers/shared.d.ts +33 -0
  236. package/dist/src/drivers/shared.d.ts.map +1 -0
  237. package/dist/src/drivers/shared.js +37 -0
  238. package/dist/src/drivers/shared.js.map +1 -0
  239. package/dist/src/drivers/square.d.ts +133 -0
  240. package/dist/src/drivers/square.d.ts.map +1 -0
  241. package/dist/src/drivers/square.js +905 -0
  242. package/dist/src/drivers/square.js.map +1 -0
  243. package/dist/src/drivers/stripe.d.ts +40 -3
  244. package/dist/src/drivers/stripe.d.ts.map +1 -1
  245. package/dist/src/drivers/stripe.js +806 -25
  246. package/dist/src/drivers/stripe.js.map +1 -1
  247. package/dist/src/drivers/woovi.d.ts +10 -3
  248. package/dist/src/drivers/woovi.d.ts.map +1 -1
  249. package/dist/src/drivers/woovi.js +162 -29
  250. package/dist/src/drivers/woovi.js.map +1 -1
  251. package/dist/src/ensure_customer.d.ts +34 -1
  252. package/dist/src/ensure_customer.d.ts.map +1 -1
  253. package/dist/src/ensure_customer.js +29 -4
  254. package/dist/src/ensure_customer.js.map +1 -1
  255. package/dist/src/http.d.ts +37 -3
  256. package/dist/src/http.d.ts.map +1 -1
  257. package/dist/src/http.js +69 -5
  258. package/dist/src/http.js.map +1 -1
  259. package/dist/src/index.d.ts +40 -10
  260. package/dist/src/index.d.ts.map +1 -1
  261. package/dist/src/index.js +22 -4
  262. package/dist/src/index.js.map +1 -1
  263. package/dist/src/invoice/emit_invoice.d.ts.map +1 -1
  264. package/dist/src/invoice/emit_invoice.js +31 -11
  265. package/dist/src/invoice/emit_invoice.js.map +1 -1
  266. package/dist/src/money.d.ts +23 -5
  267. package/dist/src/money.d.ts.map +1 -1
  268. package/dist/src/money.js +72 -7
  269. package/dist/src/money.js.map +1 -1
  270. package/dist/src/payments_manager.d.ts +8 -1
  271. package/dist/src/payments_manager.d.ts.map +1 -1
  272. package/dist/src/payments_manager.js +168 -6
  273. package/dist/src/payments_manager.js.map +1 -1
  274. package/dist/src/services/main.d.ts +38 -0
  275. package/dist/src/services/main.d.ts.map +1 -1
  276. package/dist/src/services/main.js +130 -0
  277. package/dist/src/services/main.js.map +1 -1
  278. package/dist/src/telescope/index.d.ts +2 -0
  279. package/dist/src/telescope/index.d.ts.map +1 -1
  280. package/dist/src/telescope/index.js +1 -0
  281. package/dist/src/telescope/index.js.map +1 -1
  282. package/dist/src/telescope/payments_watcher.d.ts +10 -4
  283. package/dist/src/telescope/payments_watcher.d.ts.map +1 -1
  284. package/dist/src/telescope/payments_watcher.js +65 -13
  285. package/dist/src/telescope/payments_watcher.js.map +1 -1
  286. package/dist/src/telescope/register.d.ts +62 -0
  287. package/dist/src/telescope/register.d.ts.map +1 -0
  288. package/dist/src/telescope/register.js +48 -0
  289. package/dist/src/telescope/register.js.map +1 -0
  290. package/dist/src/testing/fake_payments.d.ts +62 -0
  291. package/dist/src/testing/fake_payments.d.ts.map +1 -0
  292. package/dist/src/testing/fake_payments.js +82 -0
  293. package/dist/src/testing/fake_payments.js.map +1 -0
  294. package/dist/src/testing/in_memory_billing_store.d.ts +151 -2
  295. package/dist/src/testing/in_memory_billing_store.d.ts.map +1 -1
  296. package/dist/src/testing/in_memory_billing_store.js +517 -4
  297. package/dist/src/testing/in_memory_billing_store.js.map +1 -1
  298. package/dist/src/testing/index.d.ts +2 -1
  299. package/dist/src/testing/index.d.ts.map +1 -1
  300. package/dist/src/testing/index.js +1 -0
  301. package/dist/src/testing/index.js.map +1 -1
  302. package/dist/src/types.d.ts +161 -5
  303. package/dist/src/types.d.ts.map +1 -1
  304. package/dist/src/types.js +30 -1
  305. package/dist/src/types.js.map +1 -1
  306. package/dist/src/webhook_handlers.d.ts +96 -2
  307. package/dist/src/webhook_handlers.d.ts.map +1 -1
  308. package/dist/src/webhook_handlers.js +91 -10
  309. package/dist/src/webhook_handlers.js.map +1 -1
  310. package/dist/src/webhook_security.d.ts +94 -3
  311. package/dist/src/webhook_security.d.ts.map +1 -1
  312. package/dist/src/webhook_security.js +173 -9
  313. package/dist/src/webhook_security.js.map +1 -1
  314. package/dist/stubs/config/payments.stub +13 -0
  315. package/dist/stubs/config/payments_client.stub +42 -0
  316. package/dist/stubs/config/payments_dashboard.stub +38 -0
  317. package/dist/stubs/database/migrations/create_billing_tables.stub +35 -77
  318. package/dist/stubs/make/webhook_handler/main.stub +29 -11
  319. package/package.json +60 -25
@@ -1,3 +1,11 @@
1
+ /**
2
+ * The `@adonis-agora/diagnostics` emit capability, published on this global slot at that
3
+ * package's module load. `@adonis-agora/payments` reads it STRUCTURALLY — it never imports
4
+ * or depends on the diagnostics package. When diagnostics isn't installed the slot is
5
+ * empty and emitting is an inert no-op. (Same pattern as `@adonis-agora/media`.)
6
+ */
7
+ import { AsyncLocalStorage } from 'node:async_hooks';
8
+ import { randomUUID } from 'node:crypto';
1
9
  const EMIT_SLOT = Symbol.for('@agora/diagnostics:emit');
2
10
  /**
3
11
  * The `@adonis-agora/diagnostics` trace capability. Like {@link EMIT_SLOT} it is read
@@ -16,6 +24,10 @@ const TRACE_SLOT = Symbol.for('@agora/diagnostics:trace');
16
24
  * state change (`payment.succeeded`/`failed`/`refunded`/`updated`,
17
25
  * `subscription.updated`, plus `subscription.created`/`canceled` from webhooks) and
18
26
  * the webhook lifecycle (`webhook.received`/`processed`/`failed`).
27
+ * - **Debug** events, which exist for the developer holding one broken payment rather
28
+ * than for the dashboard: `gateway.request`/`gateway.request.failed` (what was actually
29
+ * sent to the gateway, what came back, how long it took) and `webhook.verification`
30
+ * (whether the signature verified, under which scheme, or that nothing verified it).
19
31
  */
20
32
  export const PAYMENTS_DIAGNOSTIC_EVENTS = [
21
33
  'charge.created',
@@ -26,11 +38,18 @@ export const PAYMENTS_DIAGNOSTIC_EVENTS = [
26
38
  'payment.succeeded',
27
39
  'payment.failed',
28
40
  'payment.refunded',
41
+ 'payment.disputed',
42
+ 'payment.dispute_warning',
43
+ 'payment.dispute_closed',
29
44
  'payment.updated',
30
45
  'invoice.emitted',
46
+ 'invoice.failed',
31
47
  'webhook.received',
48
+ 'webhook.verification',
32
49
  'webhook.processed',
33
50
  'webhook.failed',
51
+ 'gateway.request',
52
+ 'gateway.request.failed',
34
53
  ];
35
54
  /**
36
55
  * The claim registry, published by `@adonis-agora/diagnostics` under this global slot as
@@ -80,16 +99,205 @@ export function isPaymentsDiagnosticClaimed(event) {
80
99
  const registry = globalThis[CLAIMS_SLOT];
81
100
  return registry?.has(`payments:${event}`) ?? false;
82
101
  }
102
+ const diagnosticsOptions = {
103
+ recordHttpBodies: false,
104
+ bodyMaxChars: 2_000,
105
+ };
106
+ /**
107
+ * Turn on the opt-in debug recording. Call it once, before the app serves traffic:
108
+ *
109
+ * ```ts title="start/telescope.ts"
110
+ * import { configurePaymentsDiagnostics } from '@adonis-agora/payments'
111
+ *
112
+ * configurePaymentsDiagnostics({ recordHttpBodies: true })
113
+ * ```
114
+ *
115
+ * It is a module-level switch rather than a `config/payments.ts` key because it is read
116
+ * by {@link publishGatewayRequest} on the HTTP path, which has no access to the app
117
+ * config — and because it is a debugging toggle, not a deployment setting.
118
+ */
119
+ export function configurePaymentsDiagnostics(options) {
120
+ if (options.recordHttpBodies !== undefined) {
121
+ diagnosticsOptions.recordHttpBodies = options.recordHttpBodies;
122
+ }
123
+ if (options.bodyMaxChars !== undefined) {
124
+ diagnosticsOptions.bodyMaxChars = options.bodyMaxChars;
125
+ }
126
+ }
127
+ /** The current opt-in switches (a copy — mutating it changes nothing). */
128
+ export function paymentsDiagnosticsOptions() {
129
+ return { ...diagnosticsOptions };
130
+ }
131
+ /** Reset the switches to their defaults. Exists for tests. */
132
+ export function resetPaymentsDiagnosticsOptions() {
133
+ diagnosticsOptions.recordHttpBodies = false;
134
+ diagnosticsOptions.bodyMaxChars = 2_000;
135
+ }
136
+ // ─── redaction ───────────────────────────────────────────────────────────────
137
+ /**
138
+ * Key fragments whose VALUE is a credential, a card, or a tax document. Matched
139
+ * case-insensitively as a substring of the key, so `cpfCnpj`, `X-Api-Key`, `cardNumber`
140
+ * and `access_token` are all caught by one entry each.
141
+ *
142
+ * The list errs towards over-redaction on purpose: a diagnostics entry exists to be
143
+ * pasted into a bug report, so a redacted field that was harmless costs a follow-up
144
+ * question, while a leaked one costs a credential rotation.
145
+ */
146
+ const SENSITIVE_KEY_FRAGMENTS = [
147
+ 'auth',
148
+ 'token',
149
+ 'secret',
150
+ 'password',
151
+ 'passwd',
152
+ 'apikey',
153
+ 'api_key',
154
+ 'api-key',
155
+ 'signature',
156
+ 'credential',
157
+ 'key',
158
+ 'card',
159
+ 'cvv',
160
+ 'cvc',
161
+ 'pan',
162
+ 'holder',
163
+ 'expiry',
164
+ 'exp_month',
165
+ 'exp_year',
166
+ 'cpf',
167
+ 'cnpj',
168
+ 'taxid',
169
+ 'tax_id',
170
+ 'document',
171
+ 'ssn',
172
+ 'iban',
173
+ ];
174
+ /** The marker left where a value was removed. Recognisable on sight in an entry. */
175
+ export const REDACTED = '[redacted]';
176
+ /** Whether a query parameter / body key names something that must never be recorded. */
177
+ function isSensitiveKey(key) {
178
+ const lower = key.toLowerCase();
179
+ return SENSITIVE_KEY_FRAGMENTS.some((fragment) => lower.includes(fragment));
180
+ }
181
+ /**
182
+ * Redact a URL query string, keeping the parameter NAMES (which are what makes a call
183
+ * identifiable) and dropping any value that names a credential — Asaas passes
184
+ * `access_token`, several gateways accept `?api_key=`.
185
+ *
186
+ * Takes and returns the string with its leading `?`, so it round-trips a `URL.search`.
187
+ */
188
+ export function redactQueryString(search) {
189
+ if (search === '' || search === '?')
190
+ return search;
191
+ const body = search.startsWith('?') ? search.slice(1) : search;
192
+ const redacted = body
193
+ .split('&')
194
+ .map((pair) => {
195
+ const eq = pair.indexOf('=');
196
+ if (eq === -1)
197
+ return pair;
198
+ const name = pair.slice(0, eq);
199
+ return isSensitiveKey(decodeURIComponent(name)) ? `${name}=${REDACTED}` : pair;
200
+ })
201
+ .join('&');
202
+ return `?${redacted}`;
203
+ }
204
+ /**
205
+ * Redact a free-text string that may embed `name=value` credentials — a transport error
206
+ * message that quotes the URL, say. Only the values are removed; the shape of the message
207
+ * survives, which is the part worth reading.
208
+ */
209
+ export function redactText(text) {
210
+ return text.replace(/([?&;]\s*)([\w.-]+)=([^&;\s]+)/g, (match, sep, name) => isSensitiveKey(name) ? `${sep}${name}=${REDACTED}` : match);
211
+ }
212
+ /**
213
+ * Redact a request/response body: every value under a sensitive key is replaced, long
214
+ * strings are truncated, and long arrays are cut short — so one pathological response
215
+ * cannot flood the Telescope store.
216
+ *
217
+ * Only ever reached when `recordHttpBodies` is on.
218
+ */
219
+ export function redactBody(value, maxChars = diagnosticsOptions.bodyMaxChars) {
220
+ return redactAt(value, maxChars, 0);
221
+ }
222
+ const MAX_BODY_DEPTH = 6;
223
+ const MAX_BODY_ARRAY = 20;
224
+ function redactAt(value, maxChars, depth) {
225
+ if (typeof value === 'string') {
226
+ return value.length > maxChars ? `${value.slice(0, maxChars)}…[truncated]` : value;
227
+ }
228
+ if (value === null || typeof value !== 'object')
229
+ return value;
230
+ if (depth >= MAX_BODY_DEPTH)
231
+ return '[depth limit]';
232
+ if (Array.isArray(value)) {
233
+ const head = value.slice(0, MAX_BODY_ARRAY).map((item) => redactAt(item, maxChars, depth + 1));
234
+ return value.length > MAX_BODY_ARRAY
235
+ ? [...head, `…${value.length - MAX_BODY_ARRAY} more`]
236
+ : head;
237
+ }
238
+ const out = {};
239
+ for (const [key, item] of Object.entries(value)) {
240
+ out[key] = isSensitiveKey(key) ? REDACTED : redactAt(item, maxChars, depth + 1);
241
+ }
242
+ return out;
243
+ }
244
+ const traceStore = new AsyncLocalStorage();
245
+ /** A fresh correlation id for one webhook delivery attempt. */
246
+ export function newPaymentsTraceId() {
247
+ return randomUUID();
248
+ }
249
+ /** Run `fn` with `frame` as the ambient payments trace. The frame is mutable by design. */
250
+ export function runWithPaymentsTrace(frame, fn) {
251
+ return traceStore.run(frame, fn);
252
+ }
253
+ /** The ambient trace frame, when one is active. */
254
+ export function currentPaymentsTrace() {
255
+ return traceStore.getStore();
256
+ }
257
+ /**
258
+ * Record that a shared webhook-verification helper ran, and whether it matched.
259
+ *
260
+ * Called by `webhook_security.ts`, so a driver gets this for free by using the shared
261
+ * primitives. A driver that verifies inside its own SDK (Stripe) reports nothing, which
262
+ * is why the published outcome for that case is `unreported` rather than `verified`.
263
+ *
264
+ * A passing report wins over a failing one: schemes are tried in sequence (Woovi checks
265
+ * HMAC then RSA) and the one that matched is the one that authenticated the delivery.
266
+ */
267
+ export function reportWebhookVerification(scheme, ok) {
268
+ const frame = traceStore.getStore();
269
+ if (frame === undefined)
270
+ return;
271
+ if (frame.verification?.ok === true)
272
+ return;
273
+ frame.verification = { scheme, ok };
274
+ }
275
+ // ─── publishing ──────────────────────────────────────────────────────────────
276
+ /** Whether anything is listening — the cheap gate before building a debug payload. */
277
+ export function paymentsDiagnosticsEnabled() {
278
+ return typeof globalThis[EMIT_SLOT] === 'function';
279
+ }
83
280
  /**
84
281
  * Publish a payments event on `agora:payments:<event>` via the structural diagnostics
85
282
  * slot. No-op when diagnostics isn't installed (the slot is empty) — and it never throws
86
283
  * back into the library.
284
+ *
285
+ * When a {@link PaymentsTraceFrame} is active and the payload does not already carry a
286
+ * `traceId`, the frame's id is stamped onto the payload. It goes on the PAYLOAD, not on
287
+ * the envelope: the structural emit slot is `(lib, event, payload)`, so payments cannot
288
+ * set `DiagnosticEvent.traceId` — and it should not want to, since diagnostics fills that
289
+ * field from the host's own request-context accessor and overwriting it would break
290
+ * cross-library correlation. The watcher merges the two, envelope first.
87
291
  */
88
292
  export function publishPayments(event, payload) {
89
293
  const emit = globalThis[EMIT_SLOT];
90
294
  if (typeof emit === 'function') {
91
295
  try {
92
- emit('payments', event, payload);
296
+ const traceId = traceStore.getStore()?.traceId;
297
+ const withTrace = traceId !== undefined && payload.traceId === undefined
298
+ ? { ...payload, traceId }
299
+ : payload;
300
+ emit('payments', event, withTrace);
93
301
  }
94
302
  catch {
95
303
  // diagnostics must never break a payment operation
@@ -142,6 +350,10 @@ export function publishSubscriptionDiagnostics(subscription, event) {
142
350
  });
143
351
  }
144
352
  }
353
+ /** Publish `invoice.failed` — a charge that went through with no fiscal invoice behind it. */
354
+ export function publishInvoiceFailedDiagnostics(failure) {
355
+ publishPayments('invoice.failed', failure);
356
+ }
145
357
  export function publishInvoiceEmittedDiagnostics(invoice) {
146
358
  publishPayments('invoice.emitted', {
147
359
  gatewayId: invoice.gatewayId,
@@ -150,4 +362,108 @@ export function publishInvoiceEmittedDiagnostics(invoice) {
150
362
  ...(invoice.url !== undefined ? { url: invoice.url } : {}),
151
363
  });
152
364
  }
365
+ /**
366
+ * Split `baseUrl + path` into host / path / redacted query.
367
+ *
368
+ * The query is kept (redacted) rather than dropped because it is often the whole
369
+ * question — `?limit=100&status=PENDING` is why the list came back empty — while the raw
370
+ * string is never recorded, since Asaas and friends accept `?access_token=`.
371
+ */
372
+ function gatewayTarget(baseUrl, path) {
373
+ try {
374
+ const url = new URL(`${baseUrl}${path}`);
375
+ return {
376
+ host: url.host,
377
+ path: url.pathname,
378
+ ...(url.search !== '' ? { query: redactQueryString(url.search) } : {}),
379
+ };
380
+ }
381
+ catch {
382
+ // A driver may pass an already-absolute or otherwise unparsable target; record what
383
+ // we can rather than losing the entry.
384
+ const [rawPath = path, rawQuery] = path.split('?', 2);
385
+ return {
386
+ host: baseUrl,
387
+ path: rawPath,
388
+ ...(rawQuery !== undefined ? { query: redactQueryString(`?${rawQuery}`) } : {}),
389
+ };
390
+ }
391
+ }
392
+ /**
393
+ * Publish `gateway.request` / `gateway.request.failed` for one outbound gateway call.
394
+ *
395
+ * Everything here is best-effort and swallowed: an observability channel must never be
396
+ * the reason a charge fails. Returns immediately when nothing is listening, so the URL
397
+ * parsing and redaction below are not paid for on an app without diagnostics installed.
398
+ */
399
+ export function publishGatewayRequest(call, outcome) {
400
+ if (!paymentsDiagnosticsEnabled())
401
+ return;
402
+ try {
403
+ const target = gatewayTarget(call.baseUrl, call.path);
404
+ const durationMs = Math.max(0, Date.now() - call.startedAt);
405
+ const bodies = diagnosticsOptions.recordHttpBodies;
406
+ const requestBody = bodies && call.requestBody !== undefined ? { requestBody: redactBody(call.requestBody) } : {};
407
+ const responseBody = bodies && outcome.responseBody !== undefined
408
+ ? { responseBody: redactBody(outcome.responseBody) }
409
+ : {};
410
+ const base = {
411
+ ...(call.provider !== undefined ? { provider: call.provider } : {}),
412
+ method: call.method,
413
+ host: target.host,
414
+ path: target.path,
415
+ ...(target.query !== undefined ? { query: target.query } : {}),
416
+ };
417
+ if (outcome.ok) {
418
+ publishPayments('gateway.request', {
419
+ ...base,
420
+ status: outcome.status,
421
+ durationMs,
422
+ ...requestBody,
423
+ ...responseBody,
424
+ });
425
+ return;
426
+ }
427
+ publishPayments('gateway.request.failed', {
428
+ ...base,
429
+ ...(outcome.status !== undefined ? { status: outcome.status } : {}),
430
+ durationMs,
431
+ outcome: outcome.outcome,
432
+ error: outcome.error,
433
+ ...requestBody,
434
+ ...responseBody,
435
+ });
436
+ }
437
+ catch {
438
+ // never break a payment operation
439
+ }
440
+ }
441
+ /**
442
+ * Work out what authenticated one delivery, from what the shared verification helpers
443
+ * reported into `frame` while the driver parsed it.
444
+ *
445
+ * - a report that PASSED → `verified`, named by its scheme.
446
+ * - a report that FAILED, or a `failure` message from a thrown `parseWebhook` → `failed`.
447
+ * - nothing reported and no failure → `unreported`. Note what this does NOT claim: it
448
+ * does not say the delivery was unverified. Stripe verifies inside its own SDK and
449
+ * reports nothing, and a driver whose webhook credential is unset skips the check and
450
+ * also reports nothing. Both land here, and the entry says so rather than guessing.
451
+ */
452
+ export function webhookVerificationOutcome(frame, failure) {
453
+ const scheme = frame?.verification !== undefined ? { scheme: frame.verification.scheme } : {};
454
+ if (failure !== undefined)
455
+ return { outcome: 'failed', ...scheme, reason: failure };
456
+ if (frame?.verification === undefined)
457
+ return { outcome: 'unreported' };
458
+ return { outcome: frame.verification.ok ? 'verified' : 'failed', ...scheme };
459
+ }
460
+ /**
461
+ * Publish `webhook.verification` for one delivery: what authenticated it, or that
462
+ * nothing did.
463
+ *
464
+ * `outcome` is derived rather than asserted — see {@link webhookVerificationOutcome}.
465
+ */
466
+ export function publishWebhookVerification(payload) {
467
+ publishPayments('webhook.verification', payload);
468
+ }
153
469
  //# sourceMappingURL=diagnostics.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"diagnostics.js","sourceRoot":"","sources":["../../src/diagnostics.ts"],"names":[],"mappings":"AAQA,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;AAGxD;;;GAGG;AACH,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;AAG1D;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,gBAAgB;IAChB,iBAAiB;IACjB,sBAAsB;IACtB,sBAAsB;IACtB,uBAAuB;IACvB,mBAAmB;IACnB,gBAAgB;IAChB,kBAAkB;IAClB,iBAAiB;IACjB,iBAAiB;IACjB,kBA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,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9F,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;IACpF,IAAI,KAAK,EAAE,YAAY,KAAK,SAAS;QAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;IACxE,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,EAAE,GAAG,MAAM,EAAE,CAAC;AAC/E,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,0BAA0B,CAAC,OAAmC;IAC5E,eAAe,CAAC,sBAAsB,EAAE,OAAO,CAAC,CAAC;AACnD,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { CheckoutSession, Customer, Invoice, InvoiceOptions, Money, Payment, PaymentMethodName, Refund, Subscription, WebhookEvent } from './types.js';
1
+ import type { CheckoutSession, Customer, Dispute, DisputeEvidence, Invoice, InvoiceOptions, Money, Payment, PaymentMethodName, Refund, Subscription, WebhookEvent } from './types.js';
2
2
  /**
3
3
  * The provider-agnostic payment driver contract (Omnipay-style).
4
4
  *
@@ -6,6 +6,8 @@ import type { CheckoutSession, Customer, Invoice, InvoiceOptions, Money, Payment
6
6
  * normalizing its own API onto the shared domain types. The billing layer and application
7
7
  * code depend only on this contract, so swapping gateways is a config change.
8
8
  */
9
+ /** See {@link PaymentsDriver.webhookVerification}. */
10
+ export type WebhookVerificationState = 'configured' | 'unconfigured' | 'unsupported';
9
11
  export interface PaymentsDriver {
10
12
  /** Stable provider name, e.g. `'stripe'`, `'abacate'`, `'asaas'`, `'woovi'`. */
11
13
  readonly provider: string;
@@ -22,6 +24,12 @@ export interface PaymentsDriver {
22
24
  * the limitation early instead of at the gateway.
23
25
  */
24
26
  readonly capabilities?: {
27
+ /**
28
+ * Whether the gateway exposes a dispute API — reading a chargeback and submitting
29
+ * evidence for it. Separate from the rest because a gateway can settle money perfectly
30
+ * and give you nothing but an email when one is filed.
31
+ */
32
+ disputes?: boolean;
25
33
  /** Full refunds against a payment. Woovi/OpenPix lacks it. */
26
34
  refunds?: boolean;
27
35
  /** Lists gateway invoices. Woovi/OpenPix has no invoice concept. */
@@ -29,6 +37,31 @@ export interface PaymentsDriver {
29
37
  /** Recurring subscriptions. InfinitePay-style links lack it. */
30
38
  subscriptions?: boolean;
31
39
  };
40
+ /**
41
+ * Whether this driver can authenticate an incoming webhook delivery, and whether it was
42
+ * given what it needs to.
43
+ *
44
+ * The failure it exists to close: a driver with a credential SLOT and no credential in it
45
+ * verified nothing — `if (this.#webhookToken !== undefined)` — so the mounted
46
+ * `POST /payments/webhook/:provider` accepted any body anyone posted, and the built-in sync
47
+ * dutifully marked payments paid. Nothing anywhere said so. The ecosystem app that found it
48
+ * had to write the warning into its config, into `start/env.ts`, and into a dedicated test
49
+ * asserting the env var was non-empty, because otherwise its two webhook-security tests
50
+ * passed vacuously.
51
+ *
52
+ * Reporting `'unconfigured'` here makes the provider refuse at boot instead
53
+ * ({@link import('./webhook_security.js').assertWebhookVerification}).
54
+ *
55
+ * - `'configured'` — it can verify and it has the credential.
56
+ * - `'unconfigured'` — it CAN verify but nothing was configured. Fails the boot check.
57
+ * - `'unsupported'` — the gateway signs nothing (Efí's Pix callback carries no signature;
58
+ * authenticity is the edge's job), so there is nothing to configure and nothing to warn
59
+ * about.
60
+ *
61
+ * Optional so a custom driver outside this package keeps compiling; absent is read as
62
+ * `'unsupported'`, because a driver that never opted in cannot be assumed to verify.
63
+ */
64
+ readonly webhookVerification?: WebhookVerificationState;
32
65
  /** Create a customer at the gateway. Returns the gateway customer. */
33
66
  createCustomer(input: CreateCustomerInput): Promise<Customer>;
34
67
  /** Look up a customer by its gateway id. */
@@ -40,7 +73,9 @@ export interface PaymentsDriver {
40
73
  /** Find a payment by its gateway id. */
41
74
  findPayment(gatewayId: string): Promise<Payment | null>;
42
75
  /** Refund a payment, optionally a partial amount. */
43
- refund(paymentGatewayId: string, amount?: Money): Promise<Refund>;
76
+ refund(paymentGatewayId: string, amount?: Money, options?: {
77
+ idempotencyKey?: string;
78
+ }): Promise<Refund>;
44
79
  /** Create a hosted checkout session and return the redirect URL. */
45
80
  createCheckout(input: CheckoutInput): Promise<CheckoutSession>;
46
81
  /** Create a recurring subscription at the gateway. */
@@ -56,12 +91,71 @@ export interface PaymentsDriver {
56
91
  /** List invoices for a customer. */
57
92
  listInvoices(customerId: string): Promise<Invoice[]>;
58
93
  /**
59
- * Verify the webhook signature and normalize the raw payload into a {@link WebhookEvent}.
60
- * Throws when the signature is invalid.
94
+ * Fetch a chargeback by the gateway's dispute id.
95
+ *
96
+ * Optional: a gateway with no dispute API declares `capabilities.disputes = false` and
97
+ * omits this, rather than returning something invented. The webhook still reports the
98
+ * dispute — what is missing is the ability to read or answer it over the API.
99
+ */
100
+ findDispute?(disputeGatewayId: string): Promise<Dispute | null>;
101
+ /**
102
+ * Submit evidence for a chargeback — a representment.
103
+ *
104
+ * **Most gateways accept this ONCE.** A driver must not retry it on its own, and the
105
+ * library never submits automatically: whether to fight a dispute or refund it is a risk
106
+ * decision about the merchant's own economics — refunding costs the sale, losing costs
107
+ * the fee and the ratio — and no library has the standing to make it. The library's job
108
+ * ends at making the deadline visible and the submission one honest call.
61
109
  */
62
- parseWebhook(rawBody: string, headers: Record<string, string | string[] | undefined>): WebhookEvent;
110
+ submitDisputeEvidence?(disputeGatewayId: string, evidence: DisputeEvidence): Promise<Dispute>;
111
+ /**
112
+ * Verify the webhook signature and normalize the raw payload into a {@link WebhookEvent},
113
+ * or into an ARRAY of them when the delivery carries more than one. Throws when the
114
+ * signature is invalid.
115
+ *
116
+ * May return a promise. Most gateways sign a self-describing payload, so this is a pure
117
+ * function of the body and headers — but not all: Mollie's webhook is a bare payment id
118
+ * with no status and no signature, and the ONLY way to learn what happened, or that the
119
+ * call is genuine, is an authenticated fetch of that payment. A synchronous signature
120
+ * forced such a driver to report `payment.updated` and nothing else, so the mounted route
121
+ * ledgered the event and never marked the payment paid. The mounted route awaits this.
122
+ *
123
+ * **Why the array half exists.** Two gateways put a LIST in the delivery envelope: Adyen's
124
+ * `notificationItems` and Efí's `pix`. Adyen documents that JSON/HTTP POST webhooks carry a
125
+ * single item (only the legacy SOAP transport batches, up to six), and Efí sends one Pix in
126
+ * practice — but "sends one in practice" is a fact about traffic, not about the contract,
127
+ * and the shape that arrives is a list either way. Returning only the first entry drops
128
+ * captures, refunds and settled Pix silently, with the money already moved; refusing the
129
+ * whole delivery loses the entries that were fine. So the contract carries what the
130
+ * envelope carries, and the mounted route loops.
131
+ *
132
+ * **A single event is still the normal answer.** Every other driver returns one
133
+ * `WebhookEvent` and the union lets it: this is a widening, not a migration. A driver
134
+ * whose gateway sends one event per request should keep returning one — an array of length
135
+ * one adds nothing and reads as if batching were possible.
136
+ *
137
+ * **Each returned event is independent.** The ledger keys on `WebhookEvent.id`, so every
138
+ * event in a batch needs an id of its own (Adyen's per-item `pspReference`, Efí's
139
+ * `endToEndId`) — reusing one id across the batch would make the second event look like a
140
+ * redelivery of the first and skip it. Idempotency, handlers and retries are all per event,
141
+ * never per delivery.
142
+ *
143
+ * **Verification is per event where the gateway signs per event.** Adyen's HMAC lives in
144
+ * each item's own `additionalData.hmacSignature`, so a driver that verifies the first item
145
+ * and trusts the rest is a forgery hole: an attacker replays one genuine item and appends
146
+ * whatever they like. A driver returning N events must have authenticated all N.
147
+ */
148
+ parseWebhook(rawBody: string, headers: Record<string, string | string[] | undefined>): WebhookEvent | WebhookEvent[] | Promise<WebhookEvent | WebhookEvent[]>;
63
149
  }
64
150
  export interface CreateCustomerInput {
151
+ /**
152
+ * Idempotency key — reusing it must not perform the operation twice.
153
+ *
154
+ * A driver whose gateway has no deduplication mechanism must REFUSE this rather than
155
+ * accept and ignore it: silently dropping it turns a caller's retry guarantee into a
156
+ * second charge, a second refund, or a second subscription.
157
+ */
158
+ idempotencyKey?: string;
65
159
  email?: string;
66
160
  name?: string;
67
161
  /** CPF/CNPJ (BR gateways) or tax id. */
@@ -164,12 +258,44 @@ export interface CheckoutInput {
164
258
  trialDays?: number;
165
259
  /** Idempotency key — reusing it must not create a duplicate session. */
166
260
  idempotencyKey?: string;
261
+ /**
262
+ * Your own id for this purchase, echoed back on the gateway's webhooks.
263
+ *
264
+ * The same contract as {@link ChargeInput.externalReference}, and it matters MORE here:
265
+ * several gateways (Paddle, Lemon Squeezy, PayPal, and any merchant-of-record) have no
266
+ * server-side charge at all, so a hosted session is the only way a purchase starts. A
267
+ * session opened without a reference produces a confirmation the handler cannot route
268
+ * back to an order, and the failure is a silent `return`.
269
+ */
270
+ externalReference?: string;
271
+ /**
272
+ * The payer's identity, for gateways that demand it up front rather than collecting it
273
+ * on the hosted page.
274
+ *
275
+ * Most checkouts ask the payer who they are, so this is usually unnecessary. PagBank's
276
+ * Orders API is the counter-example: every order carries the payer inline and is refused
277
+ * without a CPF/CNPJ, so a checkout there cannot be opened at all without it. Same shape
278
+ * as {@link ChargeInput.customer}, so a flow that already has the data passes it either way.
279
+ */
280
+ customer?: {
281
+ name?: string;
282
+ taxId?: string;
283
+ email?: string;
284
+ };
167
285
  /** Emit an invoice for this checkout: `true`/name/options. */
168
286
  invoice?: boolean | string | InvoiceOptions;
169
287
  /** Extra provider-specific fields. */
170
288
  metadata?: Record<string, unknown>;
171
289
  }
172
290
  export interface CreateSubscriptionInput {
291
+ /**
292
+ * Idempotency key — reusing it must not perform the operation twice.
293
+ *
294
+ * A driver whose gateway has no deduplication mechanism must REFUSE this rather than
295
+ * accept and ignore it: silently dropping it turns a caller's retry guarantee into a
296
+ * second charge, a second refund, or a second subscription.
297
+ */
298
+ idempotencyKey?: string;
173
299
  customerId: string;
174
300
  /** Price/plan id at the gateway. */
175
301
  planId: string;
@@ -212,6 +338,14 @@ export interface CreateSubscriptionInput {
212
338
  metadata?: Record<string, unknown>;
213
339
  }
214
340
  export interface UpdateSubscriptionInput {
341
+ /**
342
+ * Idempotency key — reusing it must not perform the operation twice.
343
+ *
344
+ * A driver whose gateway has no deduplication mechanism must REFUSE this rather than
345
+ * accept and ignore it: silently dropping it turns a caller's retry guarantee into a
346
+ * second charge, a second refund, or a second subscription.
347
+ */
348
+ idempotencyKey?: string;
215
349
  /** New amount in the currency's smallest unit. */
216
350
  amount?: Money;
217
351
  /** New description. */
@@ -1 +1 @@
1
- {"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../../src/driver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,QAAQ,EACR,OAAO,EACP,cAAc,EACd,KAAK,EACL,OAAO,EACP,iBAAiB,EACjB,MAAM,EACN,YAAY,EACZ,YAAY,EACb,MAAM,YAAY,CAAC;AAEpB;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,gFAAgF;IAChF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B;;;;OAIG;IACH,QAAQ,CAAC,gBAAgB,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAExD;;;;;OAKG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE;QACtB,8DAA8D;QAC9D,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,oEAAoE;QACpE,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,gEAAgE;QAChE,aAAa,CAAC,EAAE,OAAO,CAAC;KACzB,CAAC;IAIF,sEAAsE;IACtE,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC9D,4CAA4C;IAC5C,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;IAC3D,8CAA8C;IAC9C,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAIlF,yEAAyE;IACzE,MAAM,CAAC,K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