@owlmeans/server-payment 0.1.20-rc.1 → 0.2.0-alpha.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 (296) hide show
  1. package/README.md +52 -54
  2. package/agent-meta/manifest.json +2 -2
  3. package/agent-meta/skills/server-payment/SKILL.md +272 -330
  4. package/agent-meta/skills/server-payment/parts/reference.md +3 -3
  5. package/build/access/types.d.ts +7 -16
  6. package/build/access/types.d.ts.map +1 -1
  7. package/build/access.d.ts.map +1 -1
  8. package/build/access.js +6 -8
  9. package/build/access.js.map +1 -1
  10. package/build/actions/resync.d.ts +3 -3
  11. package/build/actions/resync.js +5 -5
  12. package/build/actions/resync.js.map +1 -1
  13. package/build/actions/webhook.d.ts +4 -1
  14. package/build/actions/webhook.d.ts.map +1 -1
  15. package/build/actions/webhook.js +8 -4
  16. package/build/actions/webhook.js.map +1 -1
  17. package/build/bootstrap/types.d.ts +13 -7
  18. package/build/bootstrap/types.d.ts.map +1 -1
  19. package/build/bootstrap.d.ts +4 -4
  20. package/build/bootstrap.d.ts.map +1 -1
  21. package/build/bootstrap.js +19 -10
  22. package/build/bootstrap.js.map +1 -1
  23. package/build/catalogue/types.d.ts +3 -3
  24. package/build/catalogue/types.d.ts.map +1 -1
  25. package/build/catalogue.d.ts.map +1 -1
  26. package/build/catalogue.js +4 -8
  27. package/build/catalogue.js.map +1 -1
  28. package/build/checkout/types.d.ts +21 -0
  29. package/build/checkout/types.d.ts.map +1 -0
  30. package/build/{plugins/stripe → checkout}/types.js.map +1 -1
  31. package/build/checkout.d.ts +6 -0
  32. package/build/checkout.d.ts.map +1 -0
  33. package/build/checkout.js +374 -0
  34. package/build/checkout.js.map +1 -0
  35. package/build/config.d.ts +10 -16
  36. package/build/config.d.ts.map +1 -1
  37. package/build/config.js +18 -59
  38. package/build/config.js.map +1 -1
  39. package/build/consts.d.ts +3 -49
  40. package/build/consts.d.ts.map +1 -1
  41. package/build/consts.js +3 -61
  42. package/build/consts.js.map +1 -1
  43. package/build/consumer/cancellation/types.d.ts +6 -4
  44. package/build/consumer/cancellation/types.d.ts.map +1 -1
  45. package/build/consumer/cancellation.d.ts.map +1 -1
  46. package/build/consumer/cancellation.js +11 -5
  47. package/build/consumer/cancellation.js.map +1 -1
  48. package/build/consumer/capture/types.d.ts +8 -12
  49. package/build/consumer/capture/types.d.ts.map +1 -1
  50. package/build/consumer/capture.d.ts.map +1 -1
  51. package/build/consumer/capture.js +48 -53
  52. package/build/consumer/capture.js.map +1 -1
  53. package/build/consumer/index.d.ts +4 -0
  54. package/build/consumer/index.d.ts.map +1 -1
  55. package/build/consumer/index.js +2 -0
  56. package/build/consumer/index.js.map +1 -1
  57. package/build/consumer/reconcile.d.ts.map +1 -1
  58. package/build/consumer/reconcile.js +82 -72
  59. package/build/consumer/reconcile.js.map +1 -1
  60. package/build/consumer/records/types.d.ts +4 -4
  61. package/build/consumer/records/types.d.ts.map +1 -1
  62. package/build/consumer/records.d.ts.map +1 -1
  63. package/build/consumer/records.js +16 -13
  64. package/build/consumer/records.js.map +1 -1
  65. package/build/consumer/service.d.ts +2 -2
  66. package/build/consumer/service.d.ts.map +1 -1
  67. package/build/consumer/service.js +28 -21
  68. package/build/consumer/service.js.map +1 -1
  69. package/build/consumer/types.d.ts +1 -4
  70. package/build/consumer/types.d.ts.map +1 -1
  71. package/build/consumer/types.local.d.ts +1 -9
  72. package/build/consumer/types.local.d.ts.map +1 -1
  73. package/build/consumer/withdrawal/types.d.ts +14 -12
  74. package/build/consumer/withdrawal/types.d.ts.map +1 -1
  75. package/build/consumer/withdrawal.d.ts.map +1 -1
  76. package/build/consumer/withdrawal.js +55 -71
  77. package/build/consumer/withdrawal.js.map +1 -1
  78. package/build/index.d.ts +12 -6
  79. package/build/index.d.ts.map +1 -1
  80. package/build/index.js +7 -4
  81. package/build/index.js.map +1 -1
  82. package/build/paygate/providers.d.ts +13 -0
  83. package/build/paygate/providers.d.ts.map +1 -0
  84. package/build/paygate/providers.js +38 -0
  85. package/build/paygate/providers.js.map +1 -0
  86. package/build/paygate/registry.d.ts +6 -0
  87. package/build/paygate/registry.d.ts.map +1 -0
  88. package/build/paygate/registry.js +37 -0
  89. package/build/paygate/registry.js.map +1 -0
  90. package/build/paygate/types.d.ts +577 -0
  91. package/build/paygate/types.d.ts.map +1 -0
  92. package/build/{plugins/session → paygate}/types.js.map +1 -1
  93. package/build/plan/types.d.ts +6 -1
  94. package/build/plan/types.d.ts.map +1 -1
  95. package/build/plan.d.ts.map +1 -1
  96. package/build/plan.js +16 -2
  97. package/build/plan.js.map +1 -1
  98. package/build/plugins/checkout-policy/types.d.ts +5 -3
  99. package/build/plugins/checkout-policy/types.d.ts.map +1 -1
  100. package/build/plugins/checkout-policy.d.ts.map +1 -1
  101. package/build/plugins/checkout-policy.js +5 -3
  102. package/build/plugins/checkout-policy.js.map +1 -1
  103. package/build/plugins/consts.local.d.ts +8 -10
  104. package/build/plugins/consts.local.d.ts.map +1 -1
  105. package/build/plugins/consts.local.js +2 -19
  106. package/build/plugins/consts.local.js.map +1 -1
  107. package/build/plugins/customer-lock/types.d.ts +2 -2
  108. package/build/plugins/customer-lock/types.d.ts.map +1 -1
  109. package/build/plugins/customer-lock.js +2 -2
  110. package/build/plugins/customer-lock.js.map +1 -1
  111. package/build/plugins/estimate/cache.js +1 -1
  112. package/build/plugins/estimate/cache.js.map +1 -1
  113. package/build/plugins/estimate/types.d.ts +10 -10
  114. package/build/plugins/estimate/types.d.ts.map +1 -1
  115. package/build/plugins/estimate.d.ts.map +1 -1
  116. package/build/plugins/estimate.js +48 -122
  117. package/build/plugins/estimate.js.map +1 -1
  118. package/build/plugins/events/types.d.ts +17 -10
  119. package/build/plugins/events/types.d.ts.map +1 -1
  120. package/build/plugins/events.d.ts +6 -5
  121. package/build/plugins/events.d.ts.map +1 -1
  122. package/build/plugins/events.js +162 -173
  123. package/build/plugins/events.js.map +1 -1
  124. package/build/plugins/fx/types.d.ts +10 -21
  125. package/build/plugins/fx/types.d.ts.map +1 -1
  126. package/build/plugins/fx.d.ts +1 -1
  127. package/build/plugins/fx.d.ts.map +1 -1
  128. package/build/plugins/fx.js +17 -54
  129. package/build/plugins/fx.js.map +1 -1
  130. package/build/plugins/portal/types.d.ts +8 -37
  131. package/build/plugins/portal/types.d.ts.map +1 -1
  132. package/build/plugins/portal.d.ts.map +1 -1
  133. package/build/plugins/portal.js +38 -208
  134. package/build/plugins/portal.js.map +1 -1
  135. package/build/plugins/refunds/types.d.ts +11 -11
  136. package/build/plugins/refunds/types.d.ts.map +1 -1
  137. package/build/plugins/refunds.d.ts.map +1 -1
  138. package/build/plugins/refunds.js +14 -39
  139. package/build/plugins/refunds.js.map +1 -1
  140. package/build/plugins/snapshot/types.d.ts +11 -0
  141. package/build/plugins/snapshot/types.d.ts.map +1 -0
  142. package/build/plugins/snapshot/types.js +2 -0
  143. package/build/plugins/snapshot/types.js.map +1 -0
  144. package/build/plugins/snapshot.d.ts +4 -0
  145. package/build/plugins/snapshot.d.ts.map +1 -0
  146. package/build/plugins/snapshot.js +19 -0
  147. package/build/plugins/snapshot.js.map +1 -0
  148. package/build/plugins/subscriptions/types.d.ts +17 -17
  149. package/build/plugins/subscriptions/types.d.ts.map +1 -1
  150. package/build/plugins/subscriptions.d.ts +4 -4
  151. package/build/plugins/subscriptions.d.ts.map +1 -1
  152. package/build/plugins/subscriptions.js +69 -77
  153. package/build/plugins/subscriptions.js.map +1 -1
  154. package/build/plugins/types.local.d.ts +9 -43
  155. package/build/plugins/types.local.d.ts.map +1 -1
  156. package/build/plugins/webhook-manager/types.d.ts +15 -43
  157. package/build/plugins/webhook-manager/types.d.ts.map +1 -1
  158. package/build/plugins/webhook-manager.d.ts +3 -3
  159. package/build/plugins/webhook-manager.d.ts.map +1 -1
  160. package/build/plugins/webhook-manager.js +21 -199
  161. package/build/plugins/webhook-manager.js.map +1 -1
  162. package/build/protocol.d.ts +1 -1
  163. package/build/protocol.d.ts.map +1 -1
  164. package/build/protocol.js +1 -1
  165. package/build/protocol.js.map +1 -1
  166. package/build/service.d.ts +11 -11
  167. package/build/service.d.ts.map +1 -1
  168. package/build/service.js +59 -23
  169. package/build/service.js.map +1 -1
  170. package/build/sync/types.d.ts +17 -13
  171. package/build/sync/types.d.ts.map +1 -1
  172. package/build/sync.d.ts.map +1 -1
  173. package/build/sync.js +22 -122
  174. package/build/sync.js.map +1 -1
  175. package/build/types.d.ts +46 -101
  176. package/build/types.d.ts.map +1 -1
  177. package/build/utils/types.d.ts +0 -8
  178. package/build/utils/types.d.ts.map +1 -1
  179. package/build/utils.d.ts +1 -4
  180. package/build/utils.d.ts.map +1 -1
  181. package/build/utils.js +1 -15
  182. package/build/utils.js.map +1 -1
  183. package/package.json +20 -22
  184. package/src/access/types.ts +7 -16
  185. package/src/access.ts +7 -15
  186. package/src/actions/resync.ts +5 -5
  187. package/src/actions/webhook.ts +8 -4
  188. package/src/bootstrap/types.ts +13 -7
  189. package/src/bootstrap.ts +23 -13
  190. package/src/catalogue/types.ts +3 -3
  191. package/src/catalogue.ts +4 -8
  192. package/src/checkout/types.ts +21 -0
  193. package/src/checkout.ts +414 -0
  194. package/src/config.ts +19 -66
  195. package/src/consts.ts +3 -69
  196. package/src/consumer/cancellation/types.ts +6 -4
  197. package/src/consumer/cancellation.ts +13 -7
  198. package/src/consumer/capture/types.ts +8 -12
  199. package/src/consumer/capture.ts +50 -59
  200. package/src/consumer/index.ts +4 -0
  201. package/src/consumer/reconcile.ts +69 -68
  202. package/src/consumer/records/types.ts +4 -4
  203. package/src/consumer/records.ts +19 -14
  204. package/src/consumer/service.ts +35 -22
  205. package/src/consumer/types.local.ts +1 -8
  206. package/src/consumer/types.ts +1 -4
  207. package/src/consumer/withdrawal/types.ts +14 -12
  208. package/src/consumer/withdrawal.ts +61 -77
  209. package/src/index.ts +12 -6
  210. package/src/paygate/providers.ts +48 -0
  211. package/src/paygate/registry.ts +53 -0
  212. package/src/paygate/types.ts +640 -0
  213. package/src/plan/types.ts +6 -1
  214. package/src/plan.ts +21 -3
  215. package/src/plugins/checkout-policy/types.ts +5 -3
  216. package/src/plugins/checkout-policy.ts +6 -5
  217. package/src/plugins/consts.local.ts +2 -26
  218. package/src/plugins/customer-lock/types.ts +2 -2
  219. package/src/plugins/customer-lock.ts +2 -2
  220. package/src/plugins/estimate/cache.ts +1 -1
  221. package/src/plugins/estimate/types.ts +10 -10
  222. package/src/plugins/estimate.ts +52 -128
  223. package/src/plugins/events/types.ts +17 -9
  224. package/src/plugins/events.ts +172 -190
  225. package/src/plugins/fx/types.ts +10 -23
  226. package/src/plugins/fx.ts +28 -64
  227. package/src/plugins/portal/types.ts +8 -38
  228. package/src/plugins/portal.ts +48 -229
  229. package/src/plugins/refunds/types.ts +11 -11
  230. package/src/plugins/refunds.ts +16 -40
  231. package/src/plugins/snapshot/types.ts +11 -0
  232. package/src/plugins/snapshot.ts +22 -0
  233. package/src/plugins/subscriptions/types.ts +17 -17
  234. package/src/plugins/subscriptions.ts +81 -81
  235. package/src/plugins/types.local.ts +9 -33
  236. package/src/plugins/webhook-manager/types.ts +15 -43
  237. package/src/plugins/webhook-manager.ts +24 -220
  238. package/src/protocol.ts +1 -1
  239. package/src/service.ts +66 -30
  240. package/src/sync/types.ts +17 -13
  241. package/src/sync.ts +25 -143
  242. package/src/types.ts +47 -97
  243. package/src/utils/types.ts +0 -9
  244. package/src/utils.ts +2 -20
  245. package/tests/capabilities.spec.ts +219 -0
  246. package/tests/entitlement.spec.ts +4 -4
  247. package/tests/gate-handlers.spec.ts +6 -6
  248. package/tests/gate.spec.ts +2 -2
  249. package/tests/grants.spec.ts +2 -2
  250. package/tests/internal-plan.spec.ts +2 -2
  251. package/tests/limit-gate.spec.ts +2 -2
  252. package/tests/paygates.spec.ts +132 -0
  253. package/tests/protocol.spec.ts +4 -5
  254. package/tests/usage.spec.ts +2 -2
  255. package/tests/webhook.spec.ts +137 -0
  256. package/build/plugins/session/types.d.ts +0 -34
  257. package/build/plugins/session/types.d.ts.map +0 -1
  258. package/build/plugins/session.d.ts +0 -4
  259. package/build/plugins/session.d.ts.map +0 -1
  260. package/build/plugins/session.js +0 -71
  261. package/build/plugins/session.js.map +0 -1
  262. package/build/plugins/status.d.ts +0 -8
  263. package/build/plugins/status.d.ts.map +0 -1
  264. package/build/plugins/status.js +0 -21
  265. package/build/plugins/status.js.map +0 -1
  266. package/build/plugins/stripe/types.d.ts +0 -20
  267. package/build/plugins/stripe/types.d.ts.map +0 -1
  268. package/build/plugins/stripe.d.ts +0 -6
  269. package/build/plugins/stripe.d.ts.map +0 -1
  270. package/build/plugins/stripe.js +0 -518
  271. package/build/plugins/stripe.js.map +0 -1
  272. package/src/plugins/session/types.ts +0 -30
  273. package/src/plugins/session.ts +0 -86
  274. package/src/plugins/status.ts +0 -22
  275. package/src/plugins/stripe/types.ts +0 -20
  276. package/src/plugins/stripe.ts +0 -571
  277. package/tests/checkout-consumer.spec.ts +0 -366
  278. package/tests/checkout-locks.spec.ts +0 -161
  279. package/tests/checkout-plugins.spec.ts +0 -164
  280. package/tests/checkout.spec.ts +0 -313
  281. package/tests/consumer-events.spec.ts +0 -215
  282. package/tests/consumer-fixtures.ts +0 -141
  283. package/tests/consumer-ops.spec.ts +0 -361
  284. package/tests/consumer-rights.integration.spec.ts +0 -147
  285. package/tests/consumer-rights.spec.ts +0 -606
  286. package/tests/context.ts +0 -110
  287. package/tests/estimate.spec.ts +0 -350
  288. package/tests/events.spec.ts +0 -367
  289. package/tests/fake-stripe.ts +0 -1004
  290. package/tests/gateway-options.spec.ts +0 -180
  291. package/tests/portal.spec.ts +0 -202
  292. package/tests/sync.spec.ts +0 -114
  293. package/tests/usage.integration.spec.ts +0 -165
  294. package/tests/webhook-manager.spec.ts +0 -149
  295. /package/build/{plugins/session → checkout}/types.js +0 -0
  296. /package/build/{plugins/stripe → paygate}/types.js +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../src/sync.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAUjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AA4ExD,eAAO,MAAM,qBAAqB,QAAS,UAAU,KAAG,iBA2LvD,CAAA;AAED,yDAAyD;AACzD,eAAO,MAAM,aAAa,kFAA4C,CAAA"}
1
+ {"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../src/sync.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAYjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAwDxD,eAAO,MAAM,qBAAqB,QAAS,UAAU,KAAG,iBAwFvD,CAAA;AAED,yDAAyD;AACzD,eAAO,MAAM,aAAa,kFAA4C,CAAA"}
package/build/sync.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { createHash } from 'node:crypto';
2
- import { CheckoutPricingMode, ProductType, TaxBehavior } from '@owlmeans/payment';
2
+ import { CheckoutPricingMode, TaxBehavior } from '@owlmeans/payment';
3
3
  import { memoHelper } from '@owlmeans/context';
4
+ import { paygatesOf } from './paygate/registry.js';
4
5
  import { log } from './log.js';
5
6
  import { fxOf } from './plugins/fx.js';
6
7
  import { paymentAccessOf } from './access.js';
@@ -54,125 +55,20 @@ const fingerprintOf = (product, plans, behavior) => createHash('sha256')
54
55
  ...(options.length > 0 ? { options } : {}),
55
56
  })).sort((a, b) => a.sku.localeCompare(b.sku)),
56
57
  })).digest('hex');
57
- /** A price's `currency_options` besides its default currency (read only once expanded). */
58
- const priceOptionsOf = (price) => Object.fromEntries(Object.entries(price.currency_options ?? {}).filter(([code]) => code !== price.currency));
59
- /** Whether a price carries exactly these options (and, with a declared behavior, with that behavior). */
60
- const optionsMatch = (price, options, behavior) => {
61
- const current = priceOptionsOf(price);
62
- if (Object.keys(current).length !== options.length) {
63
- return false;
64
- }
65
- return options.every(option => current[option.currency]?.unit_amount === option.unitAmount
66
- && (behavior == null || current[option.currency]?.tax_behavior == null
67
- || current[option.currency]?.tax_behavior === 'unspecified' || current[option.currency]?.tax_behavior === behavior));
68
- };
69
- /** Whether `price` already carries the OPPOSITE of `behavior` — never `unspecified`, which is not a conflict. */
70
- const opposesBehavior = (price, behavior) => behavior != null && price.tax_behavior !== 'unspecified' && price.tax_behavior !== behavior;
71
58
  export const makeProductSyncHelper = (ctx) => {
72
59
  const access = paymentAccessOf(ctx);
73
- const ensureStripeProduct = async (stripe, product) => {
74
- const params = {
75
- name: product.title, description: product.description || undefined, tax_code: product.taxCode,
76
- active: true,
77
- metadata: { sku: product.sku, ...(product.services && { services: product.services.join(',') }) },
78
- };
79
- if (product.type === ProductType.Consumable && product.unitLabel != null)
80
- params.unit_label = product.unitLabel;
81
- try {
82
- await stripe.products.retrieve(product.sku);
83
- return await stripe.products.update(product.sku, params);
84
- }
85
- catch {
86
- return await stripe.products.create({ id: product.sku, ...params });
87
- }
88
- };
89
- const activePrices = async (stripe, product) => (await stripe.prices.list({ product: product.sku, active: true, limit: 100, expand: ['data.currency_options'] })).data;
90
- const deactivateAmountPrice = async (stripe, product, plan) => {
91
- const lookup = planHelper.planLookupKey(product, plan);
92
- for (const price of (await activePrices(stripe, product)).filter(item => item.lookup_key === lookup)) {
93
- await stripe.prices.update(price.id, { active: false });
60
+ const syncProducts = async (paygate) => {
61
+ const catalogue = paygate.catalogue;
62
+ if (catalogue == null) {
63
+ return;
94
64
  }
95
- };
96
- /**
97
- * The behavior the Stripe account's own Tax Settings resolve to for `currency`, or `null` when no
98
- * default is configured yet (nothing established to disrupt). `inferred_by_currency` follows
99
- * Stripe's own rule: exclusive for USD/CAD, inclusive otherwise.
100
- */
101
- const accountDefaultBehavior = async (stripe, currency) => {
102
- const { defaults } = await stripe.tax.settings.retrieve();
103
- if (defaults.tax_behavior === 'inferred_by_currency') {
104
- return ['usd', 'cad'].includes(currency.toLowerCase()) ? TaxBehavior.Exclusive : TaxBehavior.Inclusive;
105
- }
106
- if (defaults.tax_behavior === 'exclusive')
107
- return TaxBehavior.Exclusive;
108
- if (defaults.tax_behavior === 'inclusive')
109
- return TaxBehavior.Inclusive;
110
- return null;
111
- };
112
- /**
113
- * Give `price` the declared `behavior` while it is still `unspecified` (the only state Stripe lets
114
- * an existing price's `tax_behavior` be set from). Skipped, with a `log.error`, when the
115
- * account's own default resolves to the opposite behavior — applying ours would then change what an
116
- * existing renewal actually charges — unless `migrateUnspecifiedPrices` opts into that migration.
117
- */
118
- const applyUnspecifiedBehavior = async (stripe, price, lookupKey, behavior, migrateUnspecifiedPrices) => {
119
- if (!migrateUnspecifiedPrices) {
120
- const resolved = await accountDefaultBehavior(stripe, price.currency);
121
- if (resolved != null && resolved !== behavior) {
122
- log.error('Price left unspecified: the Stripe account\'s default tax behavior differs from the declared one — '
123
- + 'applying it would change existing renewal amounts; set `stripe.migrateUnspecifiedPrices` to override', { lookupKey, currency: price.currency, accountBehavior: resolved, declaredBehavior: behavior });
124
- return;
125
- }
126
- }
127
- await stripe.prices.update(price.id, { tax_behavior: behavior });
128
- };
129
- const ensureStripePrice = async (stripe, product, resolved, behavior, migrateUnspecifiedPrices) => {
130
- const { plan, unitAmount, currency, options } = resolved;
131
- if (plan.pricingMode === CheckoutPricingMode.Amount) {
132
- await deactivateAmountPrice(stripe, product, plan);
133
- return null;
134
- }
135
- const lookupKey = planHelper.planLookupKey(product, plan);
136
- const recurring = plan.recurring != null
137
- ? { interval: plan.recurring.interval } : undefined;
138
- const existing = await activePrices(stripe, product);
139
- const candidate = existing.find(price => price.lookup_key === lookupKey && price.unit_amount === unitAmount
140
- && price.currency === currency
141
- && ((price.recurring?.interval ?? null) === (recurring?.interval ?? null))
142
- && optionsMatch(price, options, behavior));
143
- if (candidate != null && !opposesBehavior(candidate, behavior)) {
144
- if (behavior != null && candidate.tax_behavior === 'unspecified') {
145
- await applyUnspecifiedBehavior(stripe, candidate, lookupKey, behavior, migrateUnspecifiedPrices);
146
- }
147
- return candidate;
148
- }
149
- // A changed option replaces the Price like any other change — options are never edited in place,
150
- // so a subscriber keeps exactly the Price (and currency amounts) they accepted.
151
- for (const price of existing.filter(item => item.lookup_key === lookupKey)) {
152
- await stripe.prices.update(price.id, { active: false });
153
- }
154
- return await stripe.prices.create({
155
- product: product.sku, currency, unit_amount: unitAmount, lookup_key: lookupKey,
156
- transfer_lookup_key: true, nickname: plan.sku,
157
- ...(recurring != null ? { recurring } : { billing_scheme: 'per_unit' }),
158
- ...(behavior != null ? { tax_behavior: behavior } : {}),
159
- ...(options.length > 0 ? {
160
- currency_options: Object.fromEntries(options.map(option => [option.currency, {
161
- unit_amount: option.unitAmount, ...(behavior != null ? { tax_behavior: behavior } : {}),
162
- }])),
163
- } : {}),
164
- metadata: { sku: plan.sku, ...(product.services && { services: product.services.join(',') }) },
165
- });
166
- };
167
- const syncStripeProducts = async (stripe) => {
168
65
  const fpRes = access.fingerprints();
169
66
  const behavior = (await access.payment().pricingPolicy()).tax.behavior ?? null;
170
- const migrateUnspecifiedPrices = (await access.stripePricingConfig())?.migrateUnspecifiedPrices ?? false;
171
67
  const fxRates = new Map();
172
68
  const rights = await access.payment().consumerRightsPolicy();
173
69
  const regionCurrencies = new Set(Object.values(rights?.currencies ?? {})
174
70
  .filter((code) => typeof code === 'string').map(code => code.toLowerCase()));
175
- for (const { product, plans } of await catalogueOf(ctx).stripePlansOf()) {
71
+ for (const { product, plans } of await catalogueOf(ctx).plansSoldThrough(paygate.id)) {
176
72
  const resolvedPlans = [];
177
73
  for (const plan of plans) {
178
74
  const sourceUnitAmount = Math.round(plan.price * 100);
@@ -181,7 +77,7 @@ export const makeProductSyncHelper = (ctx) => {
181
77
  resolvedPlans.push({ plan, unitAmount: sourceUnitAmount, currency: sourceCurrency, sourceUnitAmount, sourceCurrency, options: [] });
182
78
  continue;
183
79
  }
184
- const settled = await fxOf(ctx).settlementAmount(stripe, sourceUnitAmount, sourceCurrency, fxRates);
80
+ const settled = await fxOf(ctx).settlementAmount(paygate, sourceUnitAmount, sourceCurrency, fxRates);
185
81
  const { unitAmount, options } = optionsOf(plan, settled.currency, sourceUnitAmount, sourceCurrency, regionCurrencies);
186
82
  resolvedPlans.push({
187
83
  plan, unitAmount: unitAmount ?? settled.amountMinor, currency: settled.currency, sourceUnitAmount, sourceCurrency,
@@ -193,28 +89,31 @@ export const makeProductSyncHelper = (ctx) => {
193
89
  // A row from before prices were persisted syncs once more, so `planPrices` can read it.
194
90
  if (stored != null && stored.hash === hash && stored.prices != null)
195
91
  continue;
196
- const stripeProduct = await ensureStripeProduct(stripe, product);
92
+ const synced = await catalogue.syncProduct(product, resolvedPlans.map(resolved => ({
93
+ plan: resolved.plan, lookupKey: planHelper.planLookupKey(product, resolved.plan), unitAmountMinor: resolved.unitAmount,
94
+ currency: resolved.currency, options: resolved.options,
95
+ })), { behavior });
197
96
  const prices = [];
198
97
  const syncedAt = new Date();
199
98
  for (const resolved of resolvedPlans) {
200
- const price = await ensureStripePrice(stripe, product, resolved, behavior, migrateUnspecifiedPrices);
99
+ const price = synced.prices.find(entry => entry.planSku === resolved.plan.sku);
201
100
  if (price != null) {
202
101
  prices.push({
203
- planSku: resolved.plan.sku, priceId: price.id, lookupKey: planHelper.planLookupKey(product, resolved.plan),
102
+ planSku: resolved.plan.sku, priceId: price.priceId, lookupKey: planHelper.planLookupKey(product, resolved.plan),
204
103
  currency: resolved.currency, unitAmount: resolved.unitAmount, options: resolved.options,
205
- ...(behavior != null ? { taxBehavior: behavior } : price.tax_behavior != null ? { taxBehavior: price.tax_behavior } : {}),
104
+ ...(behavior != null ? { taxBehavior: behavior } : price.taxBehavior != null ? { taxBehavior: price.taxBehavior } : {}),
206
105
  ...(resolved.plan.recurring != null ? { interval: resolved.plan.recurring.interval } : {}),
207
106
  sourceUnitAmount: resolved.sourceUnitAmount, sourceCurrency: resolved.sourceCurrency, syncedAt,
208
107
  });
209
108
  }
210
109
  }
211
110
  if (stored != null) {
212
- await fpRes.update({ ...stored, hash, productId: stripeProduct.id, prices, updatedAt: new Date() });
111
+ await fpRes.update({ ...stored, hash, productId: synced.productId, prices, updatedAt: new Date() });
213
112
  }
214
113
  else {
215
- await fpRes.create({ sku: product.sku, hash, productId: stripeProduct.id, prices, updatedAt: new Date() });
114
+ await fpRes.create({ sku: product.sku, hash, productId: synced.productId, prices, updatedAt: new Date() });
216
115
  }
217
- log.info('Product synced to Stripe', { sku: product.sku, plans: plans.length }, { event: 'payment.product.synced' });
116
+ log.info('Product synced to the paygate', { sku: product.sku, plans: plans.length, paygate: paygate.id }, { event: 'payment.product.synced' });
218
117
  }
219
118
  };
220
119
  const syncedPlanPrices = async (productSku) => {
@@ -235,10 +134,11 @@ export const makeProductSyncHelper = (ctx) => {
235
134
  return views;
236
135
  };
237
136
  const syncPaymentProducts = async () => {
238
- const factory = access.gatewayOf()?.stripe;
239
- await syncStripeProducts(factory != null ? await factory(ctx) : await access.stripeClient());
137
+ for (const paygate of paygatesOf(ctx).all()) {
138
+ await syncProducts(paygate);
139
+ }
240
140
  };
241
- return { syncStripeProducts, syncedPlanPrices, syncPaymentProducts };
141
+ return { syncProducts, syncedPlanPrices, syncPaymentProducts };
242
142
  };
243
143
  /** The catalogue sync of a context — one per context. */
244
144
  export const productSyncOf = memoHelper.oncePer(makeProductSyncHelper);
package/build/sync.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"sync.js","sourceRoot":"","sources":["../src/sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,WAAW,EAAsB,MAAM,mBAAmB,CAAA;AAErG,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAG9C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAE9B,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM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QAAQ,EAAE,eAAe,EAAE,MAAM,CAAC,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAA;YAC1G,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAA;IACd,CAAC,CAAA;IAED,MAAM,mBAAmB,GAAG,KAAK,IAAmB,EAAE;QACpD,KAAK,MAAM,OAAO,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC;YAC5C,MAAM,YAAY,CAAC,OAAO,CAAC,CAAA;QAC7B,CAAC;IACH,CAAC,CAAA;IAED,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,CAAA;AAChE,CAAC,CAAA;AAED,yDAAyD;AACzD,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAA"}
package/build/types.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import type Stripe from 'stripe';
2
1
  import type { InitializedService, LazyService } from '@owlmeans/context';
3
2
  import type { ResourceRecord } from '@owlmeans/resource';
4
3
  import type { MongoResource } from '@owlmeans/mongo-resource';
@@ -29,7 +28,7 @@ export interface PaymentPlan extends ProductPlan {
29
28
  quantityPolicy?: QuantityCheckoutPolicy;
30
29
  /**
31
30
  * Exact prices in further currencies, major units by lowercase ISO 4217 code (`{ usd: 20 }`).
32
- * Synced as the reusable Price's `currency_options`, never converted.
31
+ * Synced as further currencies of the reusable price, never converted.
33
32
  */
34
33
  currencyPrices?: Record<string, number>;
35
34
  }
@@ -76,7 +75,7 @@ export interface PaymentPlanDef {
76
75
  defaultQuantity?: number;
77
76
  /**
78
77
  * Exact prices in further currencies, major units by ISO 4217 code (`{ usd: 20 }`): a recurring
79
- * or quantity plan's synced Price carries each as a `currency_options` entry at exactly this
78
+ * or quantity plan's synced reusable price carries each as a further currency at exactly this
80
79
  * amount, while its default currency (the settlement currency) is converted as before.
81
80
  */
82
81
  currencyPrices?: Record<string, number>;
@@ -88,60 +87,11 @@ export interface PaymentPlanDef {
88
87
  components: PlanWithdrawalComponent[];
89
88
  };
90
89
  }
91
- /** File paths (or values) of the Stripe secrets. The webhook secret is an optional override. */
92
- export interface StripeSecretsDef {
93
- api: string;
94
- webhook?: string;
95
- }
96
- export interface StripePluginConfig extends PluginConfig {
97
- api: string;
98
- webhook?: string;
99
- }
100
- /** Stripe-only pricing settings — never a browser-visible field (see `PricingPolicy` for those). */
101
- export interface StripePricingDef {
102
- /** Enable promotion-code entry on amount checkouts; absent/false keeps it disabled. */
103
- amountPromotionCodes?: boolean;
104
- /** Overrides `STRIPE_FX_QUOTES_API_VERSION`, when Stripe moves or renames the preview. */
105
- fxApiVersion?: string;
106
- /**
107
- * Stripe settlement currency used when a catalogue price is declared in another currency.
108
- * Recurring prices are converted during product sync; amount checkout is converted per session.
109
- */
110
- settlementCurrency?: string;
111
- /** Explicit Stripe payment methods for subscription Checkout; absent keeps Stripe's dynamic selection. */
112
- subscriptionPaymentMethodTypes?: string[];
113
- /** Payment methods for a specific subscription charge currency; overrides the default list. */
114
- subscriptionPaymentMethodTypesByCurrency?: Record<string, string[]>;
115
- /**
116
- * Let a matching `unspecified` price take the declared `tax.behavior` even when the Stripe
117
- * account's own tax-settings default resolves to the opposite one — which changes what an
118
- * existing subscriber is charged at their next renewal. Absent/`false`: such a price is left
119
- * `unspecified` and a `log.error` explains why.
120
- */
121
- migrateUnspecifiedPrices?: boolean;
122
- /**
123
- * The Stripe customer's e-mail is the application's: every checkout must pass
124
- * `CreateLinkParams.email` (else `PaygateError('customer-email')`), which is written to the
125
- * customer before the session — Checkout shows a customer's valid e-mail read-only, so no other
126
- * address can be typed — and the portal configuration never offers to edit it.
127
- */
128
- lockCustomerEmail?: boolean;
129
- /**
130
- * The billing country a checkout knows — the locked profile's, else `CreateLinkParams.country` —
131
- * is pinned on the Stripe customer (replacing a saved address of another country before any lock)
132
- * and Checkout never collects another (`customer_update.address: 'never'`, collection `'auto'`):
133
- * tax is calculated on it whatever the card form's "Country or region" says, the first completed
134
- * purchase locks it, and the portal never offers to edit the address. Where Stripe Tax needs more
135
- * than a country (US: a postal code; CA, IN: a postal code or province) and the customer carries
136
- * none, Checkout still collects the address — Stripe refuses a session otherwise.
137
- */
138
- lockCustomerCountry?: boolean;
139
- }
140
- export interface StripePricingPluginConfig extends PluginConfig, StripePricingDef {
141
- }
142
- /** `declarePaymentPricing`'s argument: the browser-safe `PricingPolicy` plus Stripe-only settings. */
90
+ /**
91
+ * `declarePaymentPricing`'s argument: the browser-safe `PricingPolicy`. A provider's own pricing
92
+ * settings are declared through its own package.
93
+ */
143
94
  export interface PricingDef extends PricingPolicy {
144
- stripe?: StripePricingDef;
145
95
  }
146
96
  /**
147
97
  * The business the consumer contracts with — backend only, never advertised. `name` is what the
@@ -173,16 +123,6 @@ export interface ConsumerRightsDef extends ConsumerRightsDeclaration {
173
123
  trader?: TraderDef;
174
124
  mail?: ConsumerMailDef;
175
125
  }
176
- /** What the managed customer portal configuration shows. */
177
- export interface PortalBrandingDef {
178
- headline?: string;
179
- privacyPolicyUrl?: string;
180
- termsOfServiceUrl?: string;
181
- /** Where the portal's "return" link leads when a session names none. Absolute URL. */
182
- returnUrl: string;
183
- }
184
- export interface PortalBrandingConfig extends PluginConfig, PortalBrandingDef {
185
- }
186
126
  export interface CreateLinkParams {
187
127
  productSku: string;
188
128
  /** Stable database key resolved by the application before this in-process call. */
@@ -191,7 +131,7 @@ export interface CreateLinkParams {
191
131
  service: string;
192
132
  planSku?: string;
193
133
  amountMinor?: number;
194
- /** Stripe Checkout and future paid-invoice language. Caller supplies a Stripe-supported locale. */
134
+ /** The checkout and future paid-invoice language. The caller supplies a locale the paygate supports. */
195
135
  locale?: string;
196
136
  /**
197
137
  * Trusted application copy shown beside the Checkout confirmation button — never caller-provided
@@ -210,9 +150,12 @@ export interface CreateLinkParams {
210
150
  ipCountry?: string;
211
151
  /**
212
152
  * The buyer's e-mail as the application verified it (the signed-in person's account). Read only
213
- * under `stripe.lockCustomerEmail`, where it is required and pinned on the Stripe customer.
153
+ * under the paygate's customer e-mail lock (`customers.locks().email`), where it is required and
154
+ * pinned on the paygate customer.
214
155
  */
215
156
  email?: string;
157
+ /** The paygate to check out through. Absent: the first registered paygate the plan is for sale through. */
158
+ paygate?: string;
216
159
  }
217
160
  /** What a submit-text function is told about the session it labels. */
218
161
  export interface CheckoutTextContext {
@@ -247,7 +190,7 @@ export interface CheckoutAttempt {
247
190
  /** Amount mode: the pre-tax charge in `currency`. */
248
191
  chargeMinor?: number;
249
192
  currency: string;
250
- /** The session lifetime the gateway will set; absent: Stripe's default (24 h). */
193
+ /** The session lifetime the gateway will set; absent: the paygate's own default. */
251
194
  sessionTtlSeconds?: number;
252
195
  expiresAt?: Date;
253
196
  at: Date;
@@ -266,7 +209,7 @@ export interface CheckoutCreated extends CheckoutAttempt {
266
209
  export type CheckoutOutcome = 'paid' | 'expired' | 'failed';
267
210
  /**
268
211
  * How a checkout ended: `paid` (completed and paid), `expired`, or `failed` — an asynchronous
269
- * payment failure, or a session that never became usable (a later plugin vetoed, Stripe refused,
212
+ * payment failure, or a session that never became usable (a later plugin vetoed, the paygate refused,
270
213
  * a `created` threw; then `sessionId` may be absent and `reservationId` names the hold to release).
271
214
  */
272
215
  export interface CheckoutSettled {
@@ -295,7 +238,7 @@ export interface CheckoutPlugin {
295
238
  created?: (ctx: ApiContext, created: CheckoutCreated) => Promise<void>;
296
239
  /** From the webhook (paid, expired, failed) or from a checkout that never became usable. */
297
240
  settled?: (ctx: ApiContext, settled: CheckoutSettled) => Promise<void>;
298
- /** The longest a session may stay open; the gateway uses the smallest, clamped to 30 min–24 h. */
241
+ /** The longest a session may stay open; the gateway uses the smallest, clamped into the paygate's `features.sessionTtl`. */
299
242
  sessionTtlSeconds?: number;
300
243
  }
301
244
  export interface PortalLinkOptions {
@@ -303,6 +246,11 @@ export interface PortalLinkOptions {
303
246
  /** The target plan of `PortalFlow.Change`. */
304
247
  planSku?: string;
305
248
  returnUrl: string;
249
+ /**
250
+ * The paygate whose portal opens. Absent: the paygate of the entity's entitling subscription, else
251
+ * the first registered paygate holding a customer of the entity.
252
+ */
253
+ paygate?: string;
306
254
  }
307
255
  export interface PriceEstimateParams {
308
256
  productSku: string;
@@ -312,6 +260,8 @@ export interface PriceEstimateParams {
312
260
  planSku?: string;
313
261
  /** ISO 3166-1 alpha-2. Absent: taken from the entity's paygate customer address. */
314
262
  country?: string;
263
+ /** The paygate to estimate through. Absent: the first registered paygate the plan is for sale through. */
264
+ paygate?: string;
315
265
  }
316
266
  export interface GrantInternalPlanOptions {
317
267
  /** Required to grant a plan that is not `free`. */
@@ -321,20 +271,20 @@ export interface GrantInternalPlanOptions {
321
271
  }
322
272
  export interface SubscriptionRef {
323
273
  entityId?: string;
324
- /** The paygate subscription id (`sub_…`). */
274
+ /** The paygate subscription id. */
325
275
  subscriptionId?: string;
276
+ /** The paygate of `subscriptionId`. Absent: its row's paygate, else the first registered one with subscriptions. */
277
+ paygate?: string;
326
278
  }
327
279
  export interface GatewayService extends InitializedService {
328
- /** `false` when registered with `manage: false`: every Stripe-calling method throws. */
280
+ /** `false` when registered with `manage: false`: every paygate-calling method throws. */
329
281
  managed: boolean;
330
- /** Whether the boot-time `bootstrapStripe` runs: the `bootstrap` option, else `managed`. */
282
+ /** Whether the boot-time paygate bootstrap runs: the `bootstrap` option, else `managed`. */
331
283
  bootstrap: boolean;
332
284
  /** The alias whose host and base form the webhook URL: the `webhookService` option, else `cfg.service`. */
333
285
  readonly webhookService: string;
334
- /** The key of this deployment's Stripe rows: the `owner` option, else `cfg.service`. */
286
+ /** The key of this deployment's paygate rows: the `owner` option, else `cfg.service`. */
335
287
  readonly owner: string;
336
- /** The Stripe client every paygate call of this gateway uses: the `stripe` option, else the configured secret. */
337
- stripe: StripeFactory;
338
288
  createLink: (ctx: ApiContext, params: CreateLinkParams) => Promise<string>;
339
289
  portalLink: (ctx: ApiContext, entityId: string, opts: PortalLinkOptions) => Promise<string>;
340
290
  /** @throws PaygateError('unmanaged') when `managed` is `false`. */
@@ -367,23 +317,24 @@ export interface GatewayService extends InitializedService {
367
317
  * `createLink` enforces. Mongo and plugins only; works unmanaged.
368
318
  */
369
319
  amountPolicy: (ctx: ApiContext, entityId: string, productSku: string, planSku?: string) => Promise<AmountPolicyView>;
370
- /** The synced prices of a product's plans, per currency — stored rows, no Stripe call. */
320
+ /** The synced prices of a product's plans, per currency — stored rows, no paygate call. */
371
321
  planPrices: (ctx: ApiContext, productSku: string) => Promise<PlanPriceView[]>;
372
322
  }
373
323
  export interface PaymentGatewayOptions {
374
324
  dbAlias?: string;
375
325
  serviceAlias?: string;
376
326
  /**
377
- * `false` for a process that must read entitlements but never talk to Stripe: no Stripe
327
+ * `false` for a process that must read entitlements but never talk to a paygate: no paygate
378
328
  * bootstrap at init, and `createLink` / `portalLink` / `resync*` / the webhook route throw
379
329
  * `PaygateError('unmanaged')`.
380
330
  */
381
331
  manage?: boolean;
382
332
  /**
383
- * Whether this process brings Stripe to the declared state at boot (`bootstrapStripe`: products,
384
- * portal configuration, webhook endpoint). Default: `manage`. A managed process with `false`
385
- * still serves checkout, the portal, estimates and the resyncs, and still runs a FORCED
386
- * bootstrap (`resync`, an application's `stripeBootstrapOf(ctx).bootstrapStripe(stripe, { force: true })`).
333
+ * Whether this process brings every registered paygate to the declared state at boot
334
+ * (`paygateBootstrapOf(ctx).bootstrap()`: products, portal configuration, webhook endpoint).
335
+ * Default: `manage`. A managed process with `false` still serves checkout, the portal, estimates
336
+ * and the resyncs, and still runs a FORCED bootstrap (`resync`, an application's
337
+ * `paygateBootstrapOf(ctx).bootstrap({ force: true })`).
387
338
  * `true` on an unmanaged gateway is refused at construction.
388
339
  */
389
340
  bootstrap?: boolean;
@@ -395,19 +346,13 @@ export interface PaymentGatewayOptions {
395
346
  */
396
347
  webhookService?: string;
397
348
  /**
398
- * The key this deployment's Stripe rows are stored under: the `payment-webhook` rows' `service`,
349
+ * The key this deployment's paygate rows are stored under: the `payment-webhook` rows' `service`,
399
350
  * the signing-secret lookup, the endpoint's `owlmeans:<owner>` description and `service`
400
351
  * metadata, the `portal:<owner>` fingerprint and the portal configuration's `service` metadata.
401
352
  * Default: `cfg.service`. Give every process sharing the database the same value, so they read
402
353
  * and replace one another's rows.
403
354
  */
404
355
  owner?: string;
405
- /** The Stripe client for this gateway's paygate calls. Default: the configured secret (`stripeClient`). */
406
- stripe?: StripeFactory;
407
- }
408
- /** A Stripe client for one context — the default reads the configured secret. */
409
- export interface StripeFactory {
410
- (ctx: ApiContext): Promise<Stripe>;
411
356
  }
412
357
  /** @deprecated use `PaymentGatewayOptions` */
413
358
  export type PaymentResourceOptions = PaymentGatewayOptions;
@@ -432,9 +377,9 @@ export interface AmountTopUpCompletion extends TopUpBase {
432
377
  sourceChargeAmountMinor: number;
433
378
  /** The amount policy's catalogue currency. */
434
379
  amountCurrency: string;
435
- /** Pre-tax subtotal actually charged by Stripe, in `currency`. */
380
+ /** Pre-tax subtotal actually charged by the paygate, in `currency`. */
436
381
  chargeAmountMinor: number;
437
- /** Stripe integration/settlement currency. */
382
+ /** The charge currency of the paygate. */
438
383
  currency: string;
439
384
  }
440
385
  export type TopUpCompletion = QuantityTopUpCompletion | AmountTopUpCompletion;
@@ -920,7 +865,7 @@ export interface SyncedPriceOption {
920
865
  currency: string;
921
866
  unitAmount: number;
922
867
  }
923
- /** A reusable price as the last sync left it — what `planPrices` and checkout read without Stripe. */
868
+ /** A reusable price as the last sync left it — what `planPrices` and checkout read without the paygate. */
924
869
  export interface SyncedPrice {
925
870
  planSku: string;
926
871
  priceId: string;
@@ -928,7 +873,7 @@ export interface SyncedPrice {
928
873
  /** The default currency and its amount. */
929
874
  currency: string;
930
875
  unitAmount: number;
931
- /** `currency_options` besides the default currency. */
876
+ /** The further currencies besides the default currency. */
932
877
  options: SyncedPriceOption[];
933
878
  taxBehavior?: string;
934
879
  interval?: 'month' | 'year';
@@ -1084,7 +1029,7 @@ export interface BillingProfileResource extends MongoResource<BillingProfileReco
1084
1029
  * subscription's first invoice (`subscription`). Renewals are not purchases.
1085
1030
  */
1086
1031
  export interface PurchaseRecord extends ResourceRecord {
1087
- /** `stripe:<session id>` (one-time) or `stripe:<subscription id>`. */
1032
+ /** `<paygate>:<checkout session id>` (one-time) or `<paygate>:<subscription id>`. */
1088
1033
  purchaseId: string;
1089
1034
  /** `CR-YYMMDD-XXXXXX` — what a consumer quotes. */
1090
1035
  contractRef: string;
@@ -1122,8 +1067,8 @@ export interface PurchaseRecord extends ResourceRecord {
1122
1067
  units?: number;
1123
1068
  taxBehavior?: string;
1124
1069
  /**
1125
- * Stripe's own `consent.terms_of_service` of the checkout — absent when the session did not
1126
- * collect it (the policy's `checkoutTerms` off, or the fallback of a Dashboard without a terms URL).
1070
+ * The terms acceptance the checkout itself collected — absent when the session did not collect it
1071
+ * (the policy's `checkoutTerms` off, or a paygate that created the session without the checkbox).
1127
1072
  */
1128
1073
  termsAccepted?: boolean;
1129
1074
  textVersion?: string;
@@ -1335,6 +1280,8 @@ export interface ConsumerMailRenderer {
1335
1280
  (kind: ConsumerMailKind, data: ConsumerMailData, rendered: MailMessage): MailMessage | null | undefined | Promise<MailMessage | null | undefined>;
1336
1281
  }
1337
1282
  export interface LockOptions {
1283
+ /** The paygate the lock came from (its customer, its checkout). Default: the first registered paygate. */
1284
+ paygate?: string;
1338
1285
  customerId?: string;
1339
1286
  sessionId?: string;
1340
1287
  ipCountry?: string;
@@ -1427,7 +1374,7 @@ export interface ConsumerRightsService extends LazyService {
1427
1374
  reconcile: (opts?: ConsumerReconcileOptions) => Promise<ConsumerReconcileResult>;
1428
1375
  }
1429
1376
  /**
1430
- * `appendConsumerRights` options. `manage`, `usage` and `stripe` apply to the service whenever the
1377
+ * `appendConsumerRights` options. `manage` and `usage` apply to the service whenever the
1431
1378
  * call comes — before or after the gateway registered it; the resources' `dbAlias` / `serviceAlias`
1432
1379
  * are those of the first registration.
1433
1380
  */
@@ -1440,8 +1387,6 @@ export interface ConsumerRightsOptions {
1440
1387
  /** The application's usage meter; without one a withdrawal is left to an operator (`review`). */
1441
1388
  usage?: UsageMeter;
1442
1389
  alias?: string;
1443
- /** The paygate client; default: the configured Stripe secret. */
1444
- stripe?: StripeFactory;
1445
1390
  dbAlias?: string;
1446
1391
  serviceAlias?: string;
1447
1392
  }
@@ -1503,7 +1448,7 @@ export interface CapabilityGateOptions extends EntityResolverOption {
1503
1448
  export type EntitlementGateOptions = CapabilityGateOptions;
1504
1449
  export interface LimitGateOptions extends EntityResolverOption {
1505
1450
  }
1506
- export interface StripeBootstrapOptions {
1451
+ export interface PaygateBootstrapOptions {
1507
1452
  /** Re-verify what the stored fingerprints say is in place. */
1508
1453
  force?: boolean;
1509
1454
  }