@owlmeans/server-payment 0.1.18-rc.8 → 0.1.18
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.
- package/README.md +157 -26
- package/agent-meta/manifest.json +30 -4
- package/agent-meta/skills/server-payment/SKILL.md +613 -54
- package/agent-meta/skills/server-payment/parts/reference.md +174 -0
- package/build/access/types.d.ts +46 -0
- package/build/access/types.d.ts.map +1 -0
- package/build/access/types.js +2 -0
- package/build/access/types.js.map +1 -0
- package/build/access.d.ts +6 -0
- package/build/access.d.ts.map +1 -0
- package/build/access.js +45 -0
- package/build/access.js.map +1 -0
- package/build/actions/index.d.ts +1 -0
- package/build/actions/index.d.ts.map +1 -1
- package/build/actions/index.js +1 -0
- package/build/actions/index.js.map +1 -1
- package/build/actions/resync-subscriptions.d.ts +3 -0
- package/build/actions/resync-subscriptions.d.ts.map +1 -0
- package/build/actions/resync-subscriptions.js +7 -0
- package/build/actions/resync-subscriptions.js.map +1 -0
- package/build/actions/resync.d.ts +6 -1
- package/build/actions/resync.d.ts.map +1 -1
- package/build/actions/resync.js +15 -5
- package/build/actions/resync.js.map +1 -1
- package/build/actions/webhook.d.ts +2 -1
- package/build/actions/webhook.d.ts.map +1 -1
- package/build/actions/webhook.js +10 -4
- package/build/actions/webhook.js.map +1 -1
- package/build/bootstrap/types.d.ts +16 -0
- package/build/bootstrap/types.d.ts.map +1 -0
- package/build/bootstrap/types.js +2 -0
- package/build/bootstrap/types.js.map +1 -0
- package/build/bootstrap.d.ts +6 -0
- package/build/bootstrap.d.ts.map +1 -0
- package/build/bootstrap.js +26 -0
- package/build/bootstrap.js.map +1 -0
- package/build/catalogue/types.d.ts +38 -0
- package/build/catalogue/types.d.ts.map +1 -0
- package/build/catalogue/types.js +2 -0
- package/build/catalogue/types.js.map +1 -0
- package/build/catalogue.d.ts +6 -0
- package/build/catalogue.d.ts.map +1 -0
- package/build/catalogue.js +110 -0
- package/build/catalogue.js.map +1 -0
- package/build/commit/types.d.ts +22 -0
- package/build/commit/types.d.ts.map +1 -0
- package/build/commit/types.js +2 -0
- package/build/commit/types.js.map +1 -0
- package/build/commit.d.ts +6 -0
- package/build/commit.d.ts.map +1 -0
- package/build/commit.js +125 -0
- package/build/commit.js.map +1 -0
- package/build/config.d.ts +44 -5
- package/build/config.d.ts.map +1 -1
- package/build/config.js +216 -10
- package/build/config.js.map +1 -1
- package/build/consts.d.ts +74 -16
- package/build/consts.d.ts.map +1 -1
- package/build/consts.js +86 -23
- package/build/consts.js.map +1 -1
- package/build/consts.local.d.ts +94 -0
- package/build/consts.local.d.ts.map +1 -0
- package/build/consts.local.js +44 -0
- package/build/consts.local.js.map +1 -0
- package/build/consumer/cancellation/types.d.ts +11 -0
- package/build/consumer/cancellation/types.d.ts.map +1 -0
- package/build/consumer/cancellation/types.js +2 -0
- package/build/consumer/cancellation/types.js.map +1 -0
- package/build/consumer/cancellation.d.ts +6 -0
- package/build/consumer/cancellation.d.ts.map +1 -0
- package/build/consumer/cancellation.js +33 -0
- package/build/consumer/cancellation.js.map +1 -0
- package/build/consumer/capture/types.d.ts +50 -0
- package/build/consumer/capture/types.d.ts.map +1 -0
- package/build/consumer/capture/types.js +2 -0
- package/build/consumer/capture/types.js.map +1 -0
- package/build/consumer/capture.d.ts +6 -0
- package/build/consumer/capture.d.ts.map +1 -0
- package/build/consumer/capture.js +284 -0
- package/build/consumer/capture.js.map +1 -0
- package/build/consumer/consts.local.d.ts +10 -0
- package/build/consumer/consts.local.d.ts.map +1 -0
- package/build/consumer/consts.local.js +11 -0
- package/build/consumer/consts.local.js.map +1 -0
- package/build/consumer/format/types.d.ts +30 -0
- package/build/consumer/format/types.d.ts.map +1 -0
- package/build/consumer/format/types.js +2 -0
- package/build/consumer/format/types.js.map +1 -0
- package/build/consumer/format.d.ts +4 -0
- package/build/consumer/format.d.ts.map +1 -0
- package/build/consumer/format.js +73 -0
- package/build/consumer/format.js.map +1 -0
- package/build/consumer/handlers.d.ts +21 -0
- package/build/consumer/handlers.d.ts.map +1 -0
- package/build/consumer/handlers.js +174 -0
- package/build/consumer/handlers.js.map +1 -0
- package/build/consumer/index.d.ts +10 -0
- package/build/consumer/index.d.ts.map +1 -0
- package/build/consumer/index.js +6 -0
- package/build/consumer/index.js.map +1 -0
- package/build/consumer/mail/types.d.ts +29 -0
- package/build/consumer/mail/types.d.ts.map +1 -0
- package/build/consumer/mail/types.js +2 -0
- package/build/consumer/mail/types.js.map +1 -0
- package/build/consumer/mail.d.ts +6 -0
- package/build/consumer/mail.d.ts.map +1 -0
- package/build/consumer/mail.js +313 -0
- package/build/consumer/mail.js.map +1 -0
- package/build/consumer/observers/types.d.ts +15 -0
- package/build/consumer/observers/types.d.ts.map +1 -0
- package/build/consumer/observers/types.js +2 -0
- package/build/consumer/observers/types.js.map +1 -0
- package/build/consumer/observers.d.ts +6 -0
- package/build/consumer/observers.d.ts.map +1 -0
- package/build/consumer/observers.js +74 -0
- package/build/consumer/observers.js.map +1 -0
- package/build/consumer/origin/types.d.ts +17 -0
- package/build/consumer/origin/types.d.ts.map +1 -0
- package/build/consumer/origin/types.js +2 -0
- package/build/consumer/origin/types.js.map +1 -0
- package/build/consumer/origin.d.ts +8 -0
- package/build/consumer/origin.d.ts.map +1 -0
- package/build/consumer/origin.js +43 -0
- package/build/consumer/origin.js.map +1 -0
- package/build/consumer/reconcile/types.d.ts +13 -0
- package/build/consumer/reconcile/types.d.ts.map +1 -0
- package/build/consumer/reconcile/types.js +2 -0
- package/build/consumer/reconcile/types.js.map +1 -0
- package/build/consumer/reconcile.d.ts +5 -0
- package/build/consumer/reconcile.d.ts.map +1 -0
- package/build/consumer/reconcile.js +320 -0
- package/build/consumer/reconcile.js.map +1 -0
- package/build/consumer/records/types.d.ts +66 -0
- package/build/consumer/records/types.d.ts.map +1 -0
- package/build/consumer/records/types.js +2 -0
- package/build/consumer/records/types.js.map +1 -0
- package/build/consumer/records.d.ts +6 -0
- package/build/consumer/records.d.ts.map +1 -0
- package/build/consumer/records.js +243 -0
- package/build/consumer/records.js.map +1 -0
- package/build/consumer/service.d.ts +28 -0
- package/build/consumer/service.d.ts.map +1 -0
- package/build/consumer/service.js +706 -0
- package/build/consumer/service.js.map +1 -0
- package/build/consumer/types.d.ts +84 -0
- package/build/consumer/types.d.ts.map +1 -0
- package/build/consumer/types.js +2 -0
- package/build/consumer/types.js.map +1 -0
- package/build/consumer/types.local.d.ts +26 -0
- package/build/consumer/types.local.d.ts.map +1 -0
- package/build/consumer/types.local.js +2 -0
- package/build/consumer/types.local.js.map +1 -0
- package/build/consumer/withdrawal/types.d.ts +36 -0
- package/build/consumer/withdrawal/types.d.ts.map +1 -0
- package/build/consumer/withdrawal/types.js +2 -0
- package/build/consumer/withdrawal/types.js.map +1 -0
- package/build/consumer/withdrawal.d.ts +6 -0
- package/build/consumer/withdrawal.d.ts.map +1 -0
- package/build/consumer/withdrawal.js +237 -0
- package/build/consumer/withdrawal.js.map +1 -0
- package/build/entitlement.d.ts +4 -0
- package/build/entitlement.d.ts.map +1 -0
- package/build/entitlement.js +72 -0
- package/build/entitlement.js.map +1 -0
- package/build/entrypoints.d.ts +19 -2
- package/build/entrypoints.d.ts.map +1 -1
- package/build/entrypoints.js +16 -4
- package/build/entrypoints.js.map +1 -1
- package/build/gate/request.d.ts +4 -0
- package/build/gate/request.d.ts.map +1 -0
- package/build/gate/request.js +17 -0
- package/build/gate/request.js.map +1 -0
- package/build/gate/types.d.ts +15 -0
- package/build/gate/types.d.ts.map +1 -0
- package/build/gate/types.js +2 -0
- package/build/gate/types.js.map +1 -0
- package/build/gate.d.ts +13 -9
- package/build/gate.d.ts.map +1 -1
- package/build/gate.js +36 -21
- package/build/gate.js.map +1 -1
- package/build/index.d.ts +50 -3
- package/build/index.d.ts.map +1 -1
- package/build/index.js +29 -3
- package/build/index.js.map +1 -1
- package/build/limit.d.ts +11 -0
- package/build/limit.d.ts.map +1 -0
- package/build/limit.js +48 -0
- package/build/limit.js.map +1 -0
- package/build/log.d.ts +3 -0
- package/build/log.d.ts.map +1 -0
- package/build/log.js +4 -0
- package/build/log.js.map +1 -0
- package/build/models/declarations/types.d.ts +22 -0
- package/build/models/declarations/types.d.ts.map +1 -0
- package/build/models/declarations/types.js +2 -0
- package/build/models/declarations/types.js.map +1 -0
- package/build/models/declarations.d.ts +4 -0
- package/build/models/declarations.d.ts.map +1 -0
- package/build/models/declarations.js +26 -0
- package/build/models/declarations.js.map +1 -0
- package/build/models/purchase/types.d.ts +13 -0
- package/build/models/purchase/types.d.ts.map +1 -0
- package/build/models/purchase/types.js +2 -0
- package/build/models/purchase/types.js.map +1 -0
- package/build/models/purchase.d.ts +4 -0
- package/build/models/purchase.d.ts.map +1 -0
- package/build/models/purchase.js +37 -0
- package/build/models/purchase.js.map +1 -0
- package/build/observer.d.ts +9 -0
- package/build/observer.d.ts.map +1 -1
- package/build/observer.js +38 -12
- package/build/observer.js.map +1 -1
- package/build/plan/types.d.ts +21 -0
- package/build/plan/types.d.ts.map +1 -0
- package/build/plan/types.js +2 -0
- package/build/plan/types.js.map +1 -0
- package/build/plan.d.ts +7 -0
- package/build/plan.d.ts.map +1 -0
- package/build/plan.js +29 -0
- package/build/plan.js.map +1 -0
- package/build/plugins/checkout-plugins/types.d.ts +25 -0
- package/build/plugins/checkout-plugins/types.d.ts.map +1 -0
- package/build/plugins/checkout-plugins/types.js +2 -0
- package/build/plugins/checkout-plugins/types.js.map +1 -0
- package/build/plugins/checkout-plugins.d.ts +12 -0
- package/build/plugins/checkout-plugins.d.ts.map +1 -0
- package/build/plugins/checkout-plugins.js +72 -0
- package/build/plugins/checkout-plugins.js.map +1 -0
- package/build/plugins/checkout-policy/types.d.ts +18 -0
- package/build/plugins/checkout-policy/types.d.ts.map +1 -0
- package/build/plugins/checkout-policy/types.js +2 -0
- package/build/plugins/checkout-policy/types.js.map +1 -0
- package/build/plugins/checkout-policy.d.ts +4 -0
- package/build/plugins/checkout-policy.d.ts.map +1 -0
- package/build/plugins/checkout-policy.js +26 -0
- package/build/plugins/checkout-policy.js.map +1 -0
- package/build/plugins/checkout-registry/types.d.ts +7 -0
- package/build/plugins/checkout-registry/types.d.ts.map +1 -0
- package/build/plugins/checkout-registry/types.js +2 -0
- package/build/plugins/checkout-registry/types.js.map +1 -0
- package/build/plugins/checkout-registry.d.ts +8 -0
- package/build/plugins/checkout-registry.d.ts.map +1 -0
- package/build/plugins/checkout-registry.js +21 -0
- package/build/plugins/checkout-registry.js.map +1 -0
- package/build/plugins/consts.local.d.ts +13 -0
- package/build/plugins/consts.local.d.ts.map +1 -0
- package/build/plugins/consts.local.js +22 -0
- package/build/plugins/consts.local.js.map +1 -0
- package/build/plugins/customer-lock/types.d.ts +6 -0
- package/build/plugins/customer-lock/types.d.ts.map +1 -0
- package/build/plugins/customer-lock/types.js +2 -0
- package/build/plugins/customer-lock/types.js.map +1 -0
- package/build/plugins/customer-lock.d.ts +5 -0
- package/build/plugins/customer-lock.d.ts.map +1 -0
- package/build/plugins/customer-lock.js +22 -0
- package/build/plugins/customer-lock.js.map +1 -0
- package/build/plugins/estimate/cache.d.ts +4 -0
- package/build/plugins/estimate/cache.d.ts.map +1 -0
- package/build/plugins/estimate/cache.js +7 -0
- package/build/plugins/estimate/cache.js.map +1 -0
- package/build/plugins/estimate/types.d.ts +27 -0
- package/build/plugins/estimate/types.d.ts.map +1 -0
- package/build/plugins/estimate/types.js +2 -0
- package/build/plugins/estimate/types.js.map +1 -0
- package/build/plugins/estimate.d.ts +6 -0
- package/build/plugins/estimate.d.ts.map +1 -0
- package/build/plugins/estimate.js +271 -0
- package/build/plugins/estimate.js.map +1 -0
- package/build/plugins/events/types.d.ts +12 -0
- package/build/plugins/events/types.d.ts.map +1 -0
- package/build/plugins/events/types.js +2 -0
- package/build/plugins/events/types.js.map +1 -0
- package/build/plugins/events.d.ts +6 -13
- package/build/plugins/events.d.ts.map +1 -1
- package/build/plugins/events.js +441 -144
- package/build/plugins/events.js.map +1 -1
- package/build/plugins/fx/types.d.ts +33 -0
- package/build/plugins/fx/types.d.ts.map +1 -0
- package/build/plugins/fx/types.js +2 -0
- package/build/plugins/fx/types.js.map +1 -0
- package/build/plugins/fx.d.ts +6 -0
- package/build/plugins/fx.d.ts.map +1 -0
- package/build/plugins/fx.js +83 -0
- package/build/plugins/fx.js.map +1 -0
- package/build/plugins/portal/types.d.ts +44 -0
- package/build/plugins/portal/types.d.ts.map +1 -0
- package/build/plugins/portal/types.js +2 -0
- package/build/plugins/portal/types.js.map +1 -0
- package/build/plugins/portal.d.ts +6 -0
- package/build/plugins/portal.d.ts.map +1 -0
- package/build/plugins/portal.js +255 -0
- package/build/plugins/portal.js.map +1 -0
- package/build/plugins/refunds/types.d.ts +35 -0
- package/build/plugins/refunds/types.d.ts.map +1 -0
- package/build/plugins/refunds/types.js +2 -0
- package/build/plugins/refunds/types.js.map +1 -0
- package/build/plugins/refunds.d.ts +6 -0
- package/build/plugins/refunds.d.ts.map +1 -0
- package/build/plugins/refunds.js +81 -0
- package/build/plugins/refunds.js.map +1 -0
- package/build/plugins/session/types.d.ts +32 -0
- package/build/plugins/session/types.d.ts.map +1 -0
- package/build/plugins/session/types.js +2 -0
- package/build/plugins/session/types.js.map +1 -0
- package/build/plugins/session.d.ts +4 -0
- package/build/plugins/session.d.ts.map +1 -0
- package/build/plugins/session.js +58 -0
- package/build/plugins/session.js.map +1 -0
- package/build/plugins/status.d.ts +8 -0
- package/build/plugins/status.d.ts.map +1 -0
- package/build/plugins/status.js +21 -0
- package/build/plugins/status.js.map +1 -0
- package/build/plugins/stripe/types.d.ts +20 -0
- package/build/plugins/stripe/types.d.ts.map +1 -0
- package/build/plugins/stripe/types.js +2 -0
- package/build/plugins/stripe/types.js.map +1 -0
- package/build/plugins/stripe.d.ts +5 -13
- package/build/plugins/stripe.d.ts.map +1 -1
- package/build/plugins/stripe.js +481 -129
- package/build/plugins/stripe.js.map +1 -1
- package/build/plugins/subscriptions/types.d.ts +41 -0
- package/build/plugins/subscriptions/types.d.ts.map +1 -0
- package/build/plugins/subscriptions/types.js +2 -0
- package/build/plugins/subscriptions/types.js.map +1 -0
- package/build/plugins/subscriptions.d.ts +6 -0
- package/build/plugins/subscriptions.d.ts.map +1 -0
- package/build/plugins/subscriptions.js +169 -0
- package/build/plugins/subscriptions.js.map +1 -0
- package/build/plugins/types.d.ts +7 -0
- package/build/plugins/types.d.ts.map +1 -0
- package/build/plugins/types.js +2 -0
- package/build/plugins/types.js.map +1 -0
- package/build/plugins/types.local.d.ts +75 -0
- package/build/plugins/types.local.d.ts.map +1 -0
- package/build/plugins/types.local.js +2 -0
- package/build/plugins/types.local.js.map +1 -0
- package/build/plugins/webhook-manager/types.d.ts +62 -0
- package/build/plugins/webhook-manager/types.d.ts.map +1 -0
- package/build/plugins/webhook-manager/types.js +2 -0
- package/build/plugins/webhook-manager/types.js.map +1 -0
- package/build/plugins/webhook-manager.d.ts +8 -0
- package/build/plugins/webhook-manager.d.ts.map +1 -0
- package/build/plugins/webhook-manager.js +245 -0
- package/build/plugins/webhook-manager.js.map +1 -0
- package/build/protocol.d.ts +13 -0
- package/build/protocol.d.ts.map +1 -0
- package/build/protocol.js +17 -0
- package/build/protocol.js.map +1 -0
- package/build/reconcile/types.d.ts +17 -0
- package/build/reconcile/types.d.ts.map +1 -0
- package/build/reconcile/types.js +2 -0
- package/build/reconcile/types.js.map +1 -0
- package/build/reconcile.d.ts +12 -0
- package/build/reconcile.d.ts.map +1 -0
- package/build/reconcile.js +91 -0
- package/build/reconcile.js.map +1 -0
- package/build/resource.d.ts +12 -1
- package/build/resource.d.ts.map +1 -1
- package/build/resource.js +97 -6
- package/build/resource.js.map +1 -1
- package/build/schemas.d.ts +19 -0
- package/build/schemas.d.ts.map +1 -0
- package/build/schemas.js +244 -0
- package/build/schemas.js.map +1 -0
- package/build/service.d.ts +28 -3
- package/build/service.d.ts.map +1 -1
- package/build/service.js +140 -19
- package/build/service.js.map +1 -1
- package/build/subscription/types.d.ts +21 -0
- package/build/subscription/types.d.ts.map +1 -0
- package/build/subscription/types.js +2 -0
- package/build/subscription/types.js.map +1 -0
- package/build/subscription.d.ts +4 -0
- package/build/subscription.d.ts.map +1 -0
- package/build/subscription.js +84 -0
- package/build/subscription.js.map +1 -0
- package/build/sync/types.d.ts +25 -0
- package/build/sync/types.d.ts.map +1 -0
- package/build/sync/types.js +2 -0
- package/build/sync/types.js.map +1 -0
- package/build/sync.d.ts +4 -3
- package/build/sync.d.ts.map +1 -1
- package/build/sync.js +231 -79
- package/build/sync.js.map +1 -1
- package/build/types.d.ts +1258 -36
- package/build/types.d.ts.map +1 -1
- package/build/types.local.d.ts +22 -0
- package/build/types.local.d.ts.map +1 -0
- package/build/types.local.js +2 -0
- package/build/types.local.js.map +1 -0
- package/build/usage/types.d.ts +56 -0
- package/build/usage/types.d.ts.map +1 -0
- package/build/usage/types.js +2 -0
- package/build/usage/types.js.map +1 -0
- package/build/usage.d.ts +6 -0
- package/build/usage.d.ts.map +1 -0
- package/build/usage.js +365 -0
- package/build/usage.js.map +1 -0
- package/build/utils/types.d.ts +31 -0
- package/build/utils/types.d.ts.map +1 -0
- package/build/utils/types.js +2 -0
- package/build/utils/types.js.map +1 -0
- package/build/utils.d.ts +21 -7
- package/build/utils.d.ts.map +1 -1
- package/build/utils.js +56 -17
- package/build/utils.js.map +1 -1
- package/package.json +22 -17
- package/src/access/types.ts +52 -0
- package/src/access.ts +86 -0
- package/src/actions/index.ts +1 -0
- package/src/actions/resync-subscriptions.ts +10 -0
- package/src/actions/resync.ts +14 -5
- package/src/actions/webhook.ts +9 -4
- package/src/bootstrap/types.ts +16 -0
- package/src/bootstrap.ts +31 -0
- package/src/catalogue/types.ts +32 -0
- package/src/catalogue.ts +135 -0
- package/src/commit/types.ts +27 -0
- package/src/commit.ts +152 -0
- package/src/config.ts +234 -14
- package/src/consts.local.ts +62 -0
- package/src/consts.ts +100 -36
- package/src/consumer/cancellation/types.ts +13 -0
- package/src/consumer/cancellation.ts +43 -0
- package/src/consumer/capture/types.ts +53 -0
- package/src/consumer/capture.ts +321 -0
- package/src/consumer/consts.local.ts +18 -0
- package/src/consumer/format/types.ts +29 -0
- package/src/consumer/format.ts +85 -0
- package/src/consumer/handlers.ts +204 -0
- package/src/consumer/index.ts +9 -0
- package/src/consumer/mail/types.ts +31 -0
- package/src/consumer/mail.ts +353 -0
- package/src/consumer/observers/types.ts +22 -0
- package/src/consumer/observers.ts +97 -0
- package/src/consumer/origin/types.ts +17 -0
- package/src/consumer/origin.ts +61 -0
- package/src/consumer/reconcile/types.ts +13 -0
- package/src/consumer/reconcile.ts +330 -0
- package/src/consumer/records/types.ts +64 -0
- package/src/consumer/records.ts +288 -0
- package/src/consumer/service.ts +768 -0
- package/src/consumer/types.local.ts +22 -0
- package/src/consumer/types.ts +96 -0
- package/src/consumer/withdrawal/types.ts +37 -0
- package/src/consumer/withdrawal.ts +268 -0
- package/src/entitlement.ts +85 -0
- package/src/entrypoints.ts +17 -4
- package/src/gate/request.ts +24 -0
- package/src/gate/types.ts +13 -0
- package/src/gate.ts +47 -30
- package/src/index.ts +55 -3
- package/src/limit.ts +54 -0
- package/src/log.ts +4 -0
- package/src/models/declarations/types.ts +22 -0
- package/src/models/declarations.ts +30 -0
- package/src/models/purchase/types.ts +13 -0
- package/src/models/purchase.ts +43 -0
- package/src/observer.ts +44 -11
- package/src/plan/types.ts +21 -0
- package/src/plan.ts +46 -0
- package/src/plugins/checkout-plugins/types.ts +25 -0
- package/src/plugins/checkout-plugins.ts +90 -0
- package/src/plugins/checkout-policy/types.ts +18 -0
- package/src/plugins/checkout-policy.ts +34 -0
- package/src/plugins/checkout-registry/types.ts +7 -0
- package/src/plugins/checkout-registry.ts +23 -0
- package/src/plugins/consts.local.ts +30 -0
- package/src/plugins/customer-lock/types.ts +5 -0
- package/src/plugins/customer-lock.ts +25 -0
- package/src/plugins/estimate/cache.ts +12 -0
- package/src/plugins/estimate/types.ts +28 -0
- package/src/plugins/estimate.ts +305 -0
- package/src/plugins/events/types.ts +11 -0
- package/src/plugins/events.ts +466 -132
- package/src/plugins/fx/types.ts +40 -0
- package/src/plugins/fx.ts +101 -0
- package/src/plugins/portal/types.ts +45 -0
- package/src/plugins/portal.ts +284 -0
- package/src/plugins/refunds/types.ts +31 -0
- package/src/plugins/refunds.ts +95 -0
- package/src/plugins/session/types.ts +28 -0
- package/src/plugins/session.ts +73 -0
- package/src/plugins/status.ts +22 -0
- package/src/plugins/stripe/types.ts +20 -0
- package/src/plugins/stripe.ts +523 -135
- package/src/plugins/subscriptions/types.ts +39 -0
- package/src/plugins/subscriptions.ts +195 -0
- package/src/plugins/types.local.ts +61 -0
- package/src/plugins/types.ts +7 -0
- package/src/plugins/webhook-manager/types.ts +63 -0
- package/src/plugins/webhook-manager.ts +288 -0
- package/src/protocol.ts +29 -0
- package/src/reconcile/types.ts +17 -0
- package/src/reconcile.ts +110 -0
- package/src/resource.ts +158 -11
- package/src/schemas.ts +271 -0
- package/src/service.ts +161 -19
- package/src/subscription/types.ts +23 -0
- package/src/subscription.ts +104 -0
- package/src/sync/types.ts +25 -0
- package/src/sync.ts +255 -72
- package/src/types.local.ts +18 -0
- package/src/types.ts +1365 -32
- package/src/usage/types.ts +51 -0
- package/src/usage.ts +432 -0
- package/src/utils/types.ts +30 -0
- package/src/utils.ts +94 -29
- package/tests/checkout-consumer.spec.ts +366 -0
- package/tests/checkout-locks.spec.ts +161 -0
- package/tests/checkout-plugins.spec.ts +164 -0
- package/tests/checkout.spec.ts +209 -93
- package/tests/consumer-events.spec.ts +215 -0
- package/tests/consumer-fixtures.ts +134 -0
- package/tests/consumer-ops.spec.ts +350 -0
- package/tests/consumer-rights.integration.spec.ts +147 -0
- package/tests/consumer-rights.spec.ts +572 -0
- package/tests/context.ts +110 -0
- package/tests/entitlement.spec.ts +139 -0
- package/tests/estimate.spec.ts +350 -0
- package/tests/events.spec.ts +357 -0
- package/tests/fake-stripe.ts +981 -0
- package/tests/gate-handlers.spec.ts +120 -0
- package/tests/gate.spec.ts +63 -72
- package/tests/gateway-options.spec.ts +180 -0
- package/tests/limit-gate.spec.ts +66 -0
- package/tests/portal.spec.ts +202 -0
- package/tests/protocol.spec.ts +17 -3
- package/tests/sync.spec.ts +114 -0
- package/tests/usage.integration.spec.ts +133 -0
- package/tests/usage.spec.ts +169 -0
- package/tests/webhook-manager.spec.ts +149 -0
- package/build/model.d.ts +0 -6
- package/build/model.d.ts.map +0 -1
- package/build/model.js +0 -33
- package/build/model.js.map +0 -1
- package/src/model.ts +0 -37
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test'
|
|
2
|
+
import { CheckoutLimitExceeded } from '@owlmeans/payment'
|
|
3
|
+
import type { CheckoutPlugin, CheckoutSettled } from '../src/types.js'
|
|
4
|
+
import {
|
|
5
|
+
CREDITS_PRODUCT, ENTITY, makeRightsContext, paidSession, send,
|
|
6
|
+
} from './consumer-fixtures.js'
|
|
7
|
+
import type { FakeContext } from './fake-stripe.js'
|
|
8
|
+
import { paymentAccessOf } from '../src/access.js'
|
|
9
|
+
import { stripeCheckoutOf } from '../src/plugins/stripe.js'
|
|
10
|
+
|
|
11
|
+
const successUrl = 'https://app.example.com/ok'
|
|
12
|
+
const topUp = (fake: FakeContext, amountMinor = 1_000) => stripeCheckoutOf(fake.ctx).createCheckoutLink(fake.stripe, {
|
|
13
|
+
productSku: CREDITS_PRODUCT, entityId: ENTITY, service: 'app', amountMinor, successUrl, country: 'US',
|
|
14
|
+
}, paymentAccessOf(fake.ctx).gateway().checkoutPlugins())
|
|
15
|
+
|
|
16
|
+
interface Journal {
|
|
17
|
+
admitted: unknown[]
|
|
18
|
+
created: unknown[]
|
|
19
|
+
settled: CheckoutSettled[]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const recording = (alias: string, journal: Journal, extra: Partial<CheckoutPlugin> = {}): CheckoutPlugin => ({
|
|
23
|
+
alias,
|
|
24
|
+
admit: async (_ctx, attempt) => { journal.admitted.push({ alias, ...attempt }); return { reservationId: `${alias}-hold` } },
|
|
25
|
+
created: async (_ctx, created) => { journal.created.push({ alias, ...created }) },
|
|
26
|
+
settled: async (_ctx, settled) => { journal.settled.push({ ...settled, alias } as CheckoutSettled) },
|
|
27
|
+
...extra,
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
const journal = (): Journal => ({ admitted: [], created: [], settled: [] })
|
|
31
|
+
|
|
32
|
+
describe('checkout plugins — narrowing', () => {
|
|
33
|
+
test('narrowings compose to the smallest maximum; the amount policy read equals the enforcement', async () => {
|
|
34
|
+
const fake = await makeRightsContext()
|
|
35
|
+
paymentAccessOf(fake.ctx).gateway().use({ alias: 'tier', narrow: async () => ({ maximumMinor: 2_500, reason: 'per-purchase' }) })
|
|
36
|
+
paymentAccessOf(fake.ctx).gateway().use({
|
|
37
|
+
alias: 'window', narrow: async () => ({ maximumMinor: 4_000, reason: 'window', remainingMinor: 4_000 }),
|
|
38
|
+
})
|
|
39
|
+
const view = await paymentAccessOf(fake.ctx).gateway().amountPolicy(fake.ctx, ENTITY, CREDITS_PRODUCT)
|
|
40
|
+
expect(view.limit).toEqual(expect.objectContaining({ maximumMinor: 2_500, reason: 'per-purchase', blocked: false, narrowed: true }))
|
|
41
|
+
expect(view.policy.presetsMinor).toEqual([1_000, 2_000])
|
|
42
|
+
|
|
43
|
+
await topUp(fake, 2_500)
|
|
44
|
+
const refusal = await topUp(fake, 2_600).catch(error => error)
|
|
45
|
+
expect(refusal).toBeInstanceOf(CheckoutLimitExceeded)
|
|
46
|
+
expect(refusal).toEqual(expect.objectContaining({ reason: 'per-purchase', maximumMinor: 2_500, currency: 'usd' }))
|
|
47
|
+
expect(fake.state.checkoutSessions).toHaveLength(1)
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
test('a blocked limit refuses any amount, the minimum too', async () => {
|
|
51
|
+
const fake = await makeRightsContext()
|
|
52
|
+
const resetsAt = new Date(Date.now() + 86_400_000)
|
|
53
|
+
paymentAccessOf(fake.ctx).gateway().use({ alias: 'hold', narrow: async () => ({ maximumMinor: 0, reason: 'hold', resetsAt }) })
|
|
54
|
+
const view = await paymentAccessOf(fake.ctx).gateway().amountPolicy(fake.ctx, ENTITY, CREDITS_PRODUCT)
|
|
55
|
+
expect(view.limit?.blocked).toBe(true)
|
|
56
|
+
const refusal = await topUp(fake, 500).catch(error => error)
|
|
57
|
+
expect(refusal).toBeInstanceOf(CheckoutLimitExceeded)
|
|
58
|
+
expect(refusal.resetsAt?.getTime()).toBe(Math.floor(resetsAt.getTime() / 1000) * 1000 === resetsAt.getTime() ? resetsAt.getTime() : refusal.resetsAt?.getTime())
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
test('a plugin registered twice under one alias replaces the first; a narrowing error fails closed', async () => {
|
|
62
|
+
const fake = await makeRightsContext()
|
|
63
|
+
paymentAccessOf(fake.ctx).gateway().use({ alias: 'tier', narrow: async () => ({ maximumMinor: 600, reason: 'old' }) })
|
|
64
|
+
paymentAccessOf(fake.ctx).gateway().use({ alias: 'tier', narrow: async () => ({ maximumMinor: 3_000, reason: 'new' }) })
|
|
65
|
+
expect(paymentAccessOf(fake.ctx).gateway().checkoutPlugins()).toHaveLength(1)
|
|
66
|
+
expect((await paymentAccessOf(fake.ctx).gateway().amountPolicy(fake.ctx, ENTITY, CREDITS_PRODUCT)).limit?.reason).toBe('new')
|
|
67
|
+
|
|
68
|
+
paymentAccessOf(fake.ctx).gateway().use({ alias: 'broken', narrow: async () => { throw new Error('tier store down') } })
|
|
69
|
+
await expect(topUp(fake)).rejects.toThrow('tier store down')
|
|
70
|
+
expect(fake.state.checkoutSessions).toHaveLength(0)
|
|
71
|
+
})
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
describe('checkout plugins — admission and the session', () => {
|
|
75
|
+
test('admit sees the attempt; created gets the session, the amount, the reservation and the expiry', async () => {
|
|
76
|
+
const fake = await makeRightsContext()
|
|
77
|
+
const log = journal()
|
|
78
|
+
paymentAccessOf(fake.ctx).gateway().use(recording('tier', log, { sessionTtlSeconds: 3_600 }))
|
|
79
|
+
const before = Math.floor(Date.now() / 1000)
|
|
80
|
+
await topUp(fake)
|
|
81
|
+
expect(log.admitted[0]).toEqual(expect.objectContaining({
|
|
82
|
+
alias: 'tier', entityId: ENTITY, productSku: CREDITS_PRODUCT, mode: 'amount', amountMinor: 1_000,
|
|
83
|
+
amountCurrency: 'usd', chargeMinor: 1_021, currency: 'usd', sessionTtlSeconds: 3_600,
|
|
84
|
+
}))
|
|
85
|
+
expect(log.created[0]).toEqual(expect.objectContaining({
|
|
86
|
+
alias: 'tier', sessionId: expect.stringMatching(/^cs_/), url: expect.stringContaining('https://'),
|
|
87
|
+
reservationId: 'tier-hold', amountMinor: 1_000,
|
|
88
|
+
}))
|
|
89
|
+
const expiresAt = fake.state.checkoutSessions[0].expires_at as number
|
|
90
|
+
expect(expiresAt).toBeGreaterThanOrEqual(before + 3_600)
|
|
91
|
+
expect(expiresAt).toBeLessThanOrEqual(before + 3_602)
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
test('the session lifetime is the smallest declared, clamped to Stripe’s 30 min – 24 h', async () => {
|
|
95
|
+
const fake = await makeRightsContext()
|
|
96
|
+
paymentAccessOf(fake.ctx).gateway().use({ alias: 'short', sessionTtlSeconds: 60 })
|
|
97
|
+
paymentAccessOf(fake.ctx).gateway().use({ alias: 'long', sessionTtlSeconds: 7_200 })
|
|
98
|
+
const now = Math.floor(Date.now() / 1000)
|
|
99
|
+
await topUp(fake)
|
|
100
|
+
expect(fake.state.checkoutSessions[0].expires_at - now).toBeGreaterThanOrEqual(1_800)
|
|
101
|
+
expect(fake.state.checkoutSessions[0].expires_at - now).toBeLessThanOrEqual(1_802)
|
|
102
|
+
|
|
103
|
+
const plain = await makeRightsContext()
|
|
104
|
+
await topUp(plain)
|
|
105
|
+
expect(plain.state.checkoutSessions[0].expires_at).toBeUndefined()
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
test('a veto releases what earlier plugins admitted and creates no session', async () => {
|
|
109
|
+
const fake = await makeRightsContext()
|
|
110
|
+
const log = journal()
|
|
111
|
+
paymentAccessOf(fake.ctx).gateway().use(recording('first', log))
|
|
112
|
+
paymentAccessOf(fake.ctx).gateway().use({
|
|
113
|
+
alias: 'veto',
|
|
114
|
+
admit: async () => { throw new CheckoutLimitExceeded({ reason: 'window', maximumMinor: 0, currency: 'usd' }) },
|
|
115
|
+
})
|
|
116
|
+
await expect(topUp(fake)).rejects.toBeInstanceOf(CheckoutLimitExceeded)
|
|
117
|
+
expect(fake.state.checkoutSessions).toHaveLength(0)
|
|
118
|
+
expect(log.settled).toEqual([expect.objectContaining({ alias: 'first', outcome: 'failed', reservationId: 'first-hold' })])
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
test('a created that throws expires the fresh session and releases every hold', async () => {
|
|
122
|
+
const fake = await makeRightsContext()
|
|
123
|
+
const log = journal()
|
|
124
|
+
paymentAccessOf(fake.ctx).gateway().use(recording('first', log))
|
|
125
|
+
paymentAccessOf(fake.ctx).gateway().use(recording('second', log, { created: async () => { throw new Error('reservation lost') } }))
|
|
126
|
+
await expect(topUp(fake)).rejects.toThrow('reservation lost')
|
|
127
|
+
expect(fake.state.expiredSessions).toHaveLength(1)
|
|
128
|
+
expect(log.settled.map(settled => [settled.outcome, settled.reservationId, settled.sessionId]))
|
|
129
|
+
.toEqual([['failed', 'first-hold', fake.state.expiredSessions[0]], ['failed', 'second-hold', fake.state.expiredSessions[0]]])
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
test('Stripe refusing the session releases the holds too', async () => {
|
|
133
|
+
const fake = await makeRightsContext()
|
|
134
|
+
const log = journal()
|
|
135
|
+
paymentAccessOf(fake.ctx).gateway().use(recording('first', log))
|
|
136
|
+
fake.state.failures['checkout.sessions.create'] = 'amount_too_small'
|
|
137
|
+
await expect(topUp(fake)).rejects.toThrow('amount_too_small')
|
|
138
|
+
expect(log.settled).toEqual([expect.objectContaining({ outcome: 'failed', reservationId: 'first-hold' })])
|
|
139
|
+
})
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
describe('checkout plugins — settlement from the webhook', () => {
|
|
143
|
+
test('paid, expired and failed sessions are settled; a settling error never fails the webhook', async () => {
|
|
144
|
+
const fake = await makeRightsContext()
|
|
145
|
+
const log = journal()
|
|
146
|
+
paymentAccessOf(fake.ctx).gateway().use(recording('tier', log))
|
|
147
|
+
paymentAccessOf(fake.ctx).gateway().use({ alias: 'broken', settled: async () => { throw new Error('ignored') } })
|
|
148
|
+
|
|
149
|
+
await send(fake, 'checkout.session.completed', paidSession({ id: 'cs_paid' }))
|
|
150
|
+
await send(fake, 'checkout.session.expired', { ...paidSession({ id: 'cs_gone', payment_status: 'unpaid' }), status: 'expired' })
|
|
151
|
+
await send(fake, 'checkout.session.async_payment_failed', paidSession({ id: 'cs_failed', payment_status: 'unpaid' }))
|
|
152
|
+
expect(log.settled.map(settled => [settled.sessionId, settled.outcome])).toEqual([
|
|
153
|
+
['cs_paid', 'paid'], ['cs_gone', 'expired'], ['cs_failed', 'failed'],
|
|
154
|
+
])
|
|
155
|
+
expect(log.settled[0]).toEqual(expect.objectContaining({ entityId: ENTITY, productSku: CREDITS_PRODUCT, amountMinor: 1_000 }))
|
|
156
|
+
})
|
|
157
|
+
|
|
158
|
+
test('an unmanaged gateway still narrows and answers the amount policy', async () => {
|
|
159
|
+
const fake = await makeRightsContext()
|
|
160
|
+
expect(paymentAccessOf(fake.ctx).gateway().managed).toBe(false)
|
|
161
|
+
paymentAccessOf(fake.ctx).gateway().use({ alias: 'tier', narrow: async () => ({ maximumMinor: 700, reason: 'per-purchase' }) })
|
|
162
|
+
expect((await paymentAccessOf(fake.ctx).gateway().amountPolicy(fake.ctx, ENTITY, CREDITS_PRODUCT)).policy.maximumMinor).toBe(700)
|
|
163
|
+
})
|
|
164
|
+
})
|
package/tests/checkout.spec.ts
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import { describe, expect, test } from 'bun:test'
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
CheckoutPricingMode, PlanDuration, PlanStatus, ProductError, ProductType, TaxBehavior,
|
|
4
|
+
} from '@owlmeans/payment'
|
|
4
5
|
import { createEventHandler } from '../src/plugins/events.js'
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
6
|
+
import type { PaymentPlan, PaymentProduct } from '../src/types.js'
|
|
7
|
+
import { CREDITS_PRODUCT, FREE, makeFakeContext, PLANS_PRODUCT, PRO, TEAM } from './fake-stripe.js'
|
|
8
|
+
import type { FakeContext } from './fake-stripe.js'
|
|
9
|
+
import { stripeCheckoutOf } from '../src/plugins/stripe.js'
|
|
10
|
+
import { stripeSessionHelper } from '../src/plugins/session.js'
|
|
11
|
+
|
|
12
|
+
const proPrice = { id: 'price_pro', product: PLANS_PRODUCT, lookup_key: PRO, active: true, recurring: { interval: 'month' } }
|
|
13
|
+
const successUrl = 'https://app.example.com/ok'
|
|
7
14
|
|
|
8
15
|
const product: PaymentProduct = {
|
|
9
16
|
type: ProductType.Consumable, sku: 'credits', title: 'Credits', services: ['app'],
|
|
@@ -20,42 +27,21 @@ const plan: PaymentPlan = {
|
|
|
20
27
|
|
|
21
28
|
const paid = (overrides: Record<string, unknown> = {}) => ({
|
|
22
29
|
id: 'cs_amount', mode: 'payment', payment_status: 'paid', customer: 'cus_1',
|
|
23
|
-
currency: 'usd', amount_subtotal: 1021,
|
|
30
|
+
currency: 'usd', amount_subtotal: 1021, payment_intent: 'pi_1', invoice: 'in_1',
|
|
24
31
|
metadata: {
|
|
25
32
|
pricingMode: 'amount', amountMinor: '1000', chargeAmountMinor: '1021', currency: 'usd',
|
|
26
|
-
entityId: 'entity-1', service: 'app', productSku:
|
|
33
|
+
entityId: 'entity-1', service: 'app', productSku: CREDITS_PRODUCT, planSku: 'app-credit-unit',
|
|
27
34
|
},
|
|
28
35
|
...overrides,
|
|
29
36
|
})
|
|
30
37
|
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const subscriptions = {
|
|
35
|
-
byExternalId: async (id: string) => records.find(record => record.externalId === id) ?? null,
|
|
36
|
-
create: async (record: PaymentSubscriptionRecord) => {
|
|
37
|
-
const created = { ...record, id: String(records.length + 1) }
|
|
38
|
-
records.push(created)
|
|
39
|
-
return created
|
|
40
|
-
},
|
|
41
|
-
save: async (record: PaymentSubscriptionRecord) => {
|
|
42
|
-
const index = records.findIndex(item => item.id === record.id)
|
|
43
|
-
records[index] = { ...record }
|
|
44
|
-
return records[index]
|
|
45
|
-
},
|
|
46
|
-
}
|
|
47
|
-
const observer = { propagateTopUp: async (completion: TopUpCompletion) => { completions.push(completion) } }
|
|
48
|
-
const context = {
|
|
49
|
-
resource: (alias: string) => alias === RES_PAYMENT_SUBSCRIPTION ? subscriptions : undefined,
|
|
50
|
-
service: (alias: string) => alias === PAYMENT_OBSERVER ? observer : undefined,
|
|
51
|
-
}
|
|
52
|
-
const stripe = { checkout: { sessions: { listLineItems: async () => ({ data: [{ quantity: 7 }] }) } } }
|
|
53
|
-
return { records, completions, context, stripe }
|
|
54
|
-
}
|
|
38
|
+
const process = async (fake: FakeContext, type: string, object: unknown) =>
|
|
39
|
+
await createEventHandler(fake.ctx, fake.stripe).process({ type, data: { object } } as never)
|
|
40
|
+
const fulfillment = (fake: FakeContext) => fake.stores['payment-fulfillment'].rows
|
|
55
41
|
|
|
56
|
-
describe('Stripe
|
|
57
|
-
test('uses one inline, tax-exclusive item and no reusable Price', () => {
|
|
58
|
-
const result = amountCheckoutLineItem(product, plan, 1_000)
|
|
42
|
+
describe('Stripe checkout', () => {
|
|
43
|
+
test('amount checkout uses one inline, tax-exclusive item and no reusable Price', () => {
|
|
44
|
+
const result = stripeSessionHelper.amountCheckoutLineItem(product, plan, 1_000)
|
|
59
45
|
expect(result.chargeMinor).toBe(1_021)
|
|
60
46
|
expect(result.lineItem).toEqual({
|
|
61
47
|
price_data: { product: 'credits', currency: 'usd', unit_amount: 1_021, tax_behavior: 'exclusive' },
|
|
@@ -64,8 +50,8 @@ describe('Stripe amount checkout', () => {
|
|
|
64
50
|
expect(result.lineItem.adjustable_quantity).toBeUndefined()
|
|
65
51
|
})
|
|
66
52
|
|
|
67
|
-
test('keeps reusable Price and adjustable quantity
|
|
68
|
-
expect(quantityCheckoutLineItem({ id: 'price_1' } as never, {
|
|
53
|
+
test('quantity checkout keeps a reusable Price and an adjustable quantity', () => {
|
|
54
|
+
expect(stripeSessionHelper.quantityCheckoutLineItem({ id: 'price_1' } as never, {
|
|
69
55
|
minimum: 5, maximum: 500, default: 10,
|
|
70
56
|
})).toEqual({
|
|
71
57
|
price: 'price_1', quantity: 10,
|
|
@@ -73,63 +59,193 @@ describe('Stripe amount checkout', () => {
|
|
|
73
59
|
})
|
|
74
60
|
})
|
|
75
61
|
|
|
76
|
-
test('
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
expect(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
await
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
expect(
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
expect(
|
|
122
|
-
expect(
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
62
|
+
test('a subscription checkout takes the asked plan, locale and disclosure; a free plan is never checked out', async () => {
|
|
63
|
+
const fake = await makeFakeContext({
|
|
64
|
+
stripe: { prices: [{ id: 'price_team', product: PLANS_PRODUCT, lookup_key: TEAM, active: true, recurring: { interval: 'month' } }] },
|
|
65
|
+
})
|
|
66
|
+
await stripeCheckoutOf(fake.ctx).createCheckoutLink(fake.stripe, {
|
|
67
|
+
productSku: PLANS_PRODUCT, planSku: TEAM, entityId: 'entity-1', service: 'app', successUrl: 'https://app.example.com/ok',
|
|
68
|
+
locale: 'fr', submitText: 'Comprend des crédits prépayés obligatoires.',
|
|
69
|
+
})
|
|
70
|
+
expect(fake.state.checkoutSessions[0]).toEqual(expect.objectContaining({
|
|
71
|
+
mode: 'subscription', line_items: [{ price: 'price_team', quantity: 1 }],
|
|
72
|
+
locale: 'fr', custom_text: { submit: { message: 'Comprend des crédits prépayés obligatoires.' } },
|
|
73
|
+
}))
|
|
74
|
+
expect(fake.state.checkoutSessions[0].subscription_data.metadata).toEqual(expect.objectContaining({ entityId: 'entity-1', planSku: TEAM }))
|
|
75
|
+
expect(fake.state.customers.cus_1.preferred_locales).toEqual(['fr'])
|
|
76
|
+
|
|
77
|
+
await expect(stripeCheckoutOf(fake.ctx).createCheckoutLink(fake.stripe, {
|
|
78
|
+
productSku: PLANS_PRODUCT, planSku: FREE, entityId: 'entity-1', service: 'app',
|
|
79
|
+
})).rejects.toBeInstanceOf(ProductError)
|
|
80
|
+
})
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
describe('Stripe checkout — pricing policy', () => {
|
|
84
|
+
test('an undeclared policy reproduces exactly the session hard-coded before this policy existed', async () => {
|
|
85
|
+
const fake = await makeFakeContext({ stripe: { prices: [proPrice] } })
|
|
86
|
+
await stripeCheckoutOf(fake.ctx).createCheckoutLink(fake.stripe, {
|
|
87
|
+
productSku: PLANS_PRODUCT, planSku: PRO, entityId: 'entity-1', service: 'app', successUrl,
|
|
88
|
+
})
|
|
89
|
+
const session = fake.state.checkoutSessions[0]
|
|
90
|
+
expect(session).toEqual(expect.objectContaining({
|
|
91
|
+
automatic_tax: { enabled: true }, billing_address_collection: 'required',
|
|
92
|
+
tax_id_collection: { enabled: true }, customer_update: { address: 'auto', name: 'auto' },
|
|
93
|
+
}))
|
|
94
|
+
expect(session.adaptive_pricing).toEqual({ enabled: false })
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
test('tax.automatic and tax.collectTaxId are independent switches', async () => {
|
|
98
|
+
const fake = await makeFakeContext({
|
|
99
|
+
pricing: { tax: { automatic: false, collectTaxId: true, estimate: false }, currency: { estimate: false } },
|
|
100
|
+
stripe: { prices: [proPrice] },
|
|
101
|
+
})
|
|
102
|
+
await stripeCheckoutOf(fake.ctx).createCheckoutLink(fake.stripe, {
|
|
103
|
+
productSku: PLANS_PRODUCT, planSku: PRO, entityId: 'entity-1', service: 'app', successUrl,
|
|
104
|
+
})
|
|
105
|
+
const session = fake.state.checkoutSessions[0]
|
|
106
|
+
expect(session.automatic_tax).toBeUndefined()
|
|
107
|
+
expect(session.billing_address_collection).toBeUndefined()
|
|
108
|
+
expect(session.tax_id_collection).toEqual({ enabled: true })
|
|
109
|
+
// only the concern that needs it contributes a `customer_update` field
|
|
110
|
+
expect(session.customer_update).toEqual({ name: 'auto' })
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
test('adaptive_pricing is enabled when currency.adaptive is declared', async () => {
|
|
114
|
+
const fake = await makeFakeContext({
|
|
115
|
+
pricing: { tax: { automatic: true, collectTaxId: true, estimate: false }, currency: { adaptive: true, estimate: false } },
|
|
116
|
+
stripe: { prices: [proPrice] },
|
|
117
|
+
})
|
|
118
|
+
await stripeCheckoutOf(fake.ctx).createCheckoutLink(fake.stripe, {
|
|
119
|
+
productSku: PLANS_PRODUCT, planSku: PRO, entityId: 'entity-1', service: 'app', successUrl,
|
|
120
|
+
})
|
|
121
|
+
expect(fake.state.checkoutSessions[0].adaptive_pricing).toEqual({ enabled: true })
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
test('subscription checkout can explicitly offer recurring-capable payment methods', async () => {
|
|
125
|
+
const fake = await makeFakeContext({
|
|
126
|
+
pricing: {
|
|
127
|
+
tax: { automatic: true, collectTaxId: true, estimate: false }, currency: { estimate: false },
|
|
128
|
+
stripe: { subscriptionPaymentMethodTypes: ['CARD', 'link', 'klarna'] },
|
|
129
|
+
},
|
|
130
|
+
stripe: { prices: [proPrice] },
|
|
131
|
+
})
|
|
132
|
+
await stripeCheckoutOf(fake.ctx).createCheckoutLink(fake.stripe, {
|
|
133
|
+
productSku: PLANS_PRODUCT, planSku: PRO, entityId: 'entity-1', service: 'app', successUrl,
|
|
134
|
+
})
|
|
135
|
+
expect(fake.state.checkoutSessions[0].payment_method_types).toEqual(['card', 'link', 'klarna'])
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
test('currency-specific subscription methods reject invalid currencies and method lists', async () => {
|
|
139
|
+
for (const methods of [
|
|
140
|
+
{ US: ['card'] }, { USD: [] }, { USD: ['CARD', 'card'] },
|
|
141
|
+
{ USD: ['not a method'] }, { USD: ['card'], usd: ['link'] },
|
|
142
|
+
]) {
|
|
143
|
+
await expect(makeFakeContext({ pricing: {
|
|
144
|
+
tax: { automatic: false, collectTaxId: false, estimate: false }, currency: { estimate: false },
|
|
145
|
+
stripe: { subscriptionPaymentMethodTypesByCurrency: methods },
|
|
146
|
+
} })).rejects.toThrow('pricing-policy:subscription-payment-methods')
|
|
147
|
+
}
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
test('a declared behavior is set on the inline amount line item', async () => {
|
|
151
|
+
const fake = await makeFakeContext({
|
|
152
|
+
pricing: { tax: { automatic: true, collectTaxId: true, estimate: false, behavior: TaxBehavior.Inclusive }, currency: { estimate: false } },
|
|
153
|
+
})
|
|
154
|
+
await stripeCheckoutOf(fake.ctx).createCheckoutLink(fake.stripe, {
|
|
155
|
+
productSku: CREDITS_PRODUCT, entityId: 'entity-1', service: 'app', amountMinor: 1_000, successUrl,
|
|
156
|
+
})
|
|
157
|
+
expect(fake.state.checkoutSessions[0].line_items[0].price_data.tax_behavior).toBe('inclusive')
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
test('an amount checkout converts the USD catalogue charge to the settlement currency', async () => {
|
|
161
|
+
const fake = await makeFakeContext({
|
|
162
|
+
pricing: {
|
|
163
|
+
tax: { automatic: true, collectTaxId: true, estimate: false },
|
|
164
|
+
currency: { adaptive: true, estimate: false }, stripe: { settlementCurrency: 'EUR' },
|
|
165
|
+
},
|
|
166
|
+
stripe: { fxRates: { usd: { exchangeRate: 0.853568, referenceRate: 0.8726 } } },
|
|
167
|
+
})
|
|
168
|
+
await stripeCheckoutOf(fake.ctx).createCheckoutLink(fake.stripe, {
|
|
169
|
+
productSku: CREDITS_PRODUCT, entityId: 'entity-1', service: 'app', amountMinor: 1_000, successUrl,
|
|
170
|
+
})
|
|
171
|
+
const session = fake.state.checkoutSessions[0]
|
|
172
|
+
expect(session.line_items[0].price_data).toEqual(expect.objectContaining({ currency: 'eur', unit_amount: 891 }))
|
|
173
|
+
expect(session.metadata).toEqual(expect.objectContaining({
|
|
174
|
+
amountMinor: '1000', sourceChargeAmountMinor: '1021', amountCurrency: 'usd',
|
|
175
|
+
chargeAmountMinor: '891', currency: 'eur',
|
|
176
|
+
}))
|
|
177
|
+
expect(fake.state.rawRequests[0]).toEqual(expect.objectContaining({
|
|
178
|
+
params: { to_currency: 'eur', 'from_currencies[]': 'usd', lock_duration: 'none' },
|
|
179
|
+
}))
|
|
180
|
+
})
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
describe('Stripe checkout fulfillment', () => {
|
|
184
|
+
test('fulfills a paid amount once even when the session carries Adaptive Pricing presentment details', async () => {
|
|
185
|
+
const fake = await makeFakeContext()
|
|
186
|
+
await process(fake, 'checkout.session.completed', paid({
|
|
187
|
+
presentment_details: { presentment_amount: 4_613, presentment_currency: 'eur' },
|
|
188
|
+
}))
|
|
189
|
+
expect(fake.observed.topUp).toEqual([expect.objectContaining({ amountMinor: 1_000, chargeAmountMinor: 1_021 })])
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
test('fulfills a paid amount once, without crediting the adjustment, and records the payment intent', async () => {
|
|
193
|
+
const fake = await makeFakeContext()
|
|
194
|
+
await process(fake, 'checkout.session.completed', paid())
|
|
195
|
+
await process(fake, 'checkout.session.completed', paid())
|
|
196
|
+
expect(fake.observed.topUp).toEqual([expect.objectContaining({
|
|
197
|
+
mode: 'amount', amountMinor: 1_000, chargeAmountMinor: 1_021, externalId: 'cs_amount', entityId: 'entity-1',
|
|
198
|
+
})])
|
|
199
|
+
expect(fulfillment(fake)[0]).toEqual(expect.objectContaining({
|
|
200
|
+
externalId: 'cs_amount', paymentIntentId: 'pi_1', invoiceId: 'in_1', mode: 'amount',
|
|
201
|
+
}))
|
|
202
|
+
expect(fulfillment(fake)[0].fulfilledAt).toBeInstanceOf(Date)
|
|
203
|
+
expect(fake.stores['payment-subscription'].rows).toHaveLength(0)
|
|
204
|
+
})
|
|
205
|
+
|
|
206
|
+
test('fulfills the USD credit value from an EUR settlement charge', async () => {
|
|
207
|
+
const fake = await makeFakeContext()
|
|
208
|
+
await process(fake, 'checkout.session.completed', paid({
|
|
209
|
+
currency: 'eur', amount_subtotal: 891,
|
|
210
|
+
metadata: {
|
|
211
|
+
pricingMode: 'amount', amountMinor: '1000', sourceChargeAmountMinor: '1021', amountCurrency: 'usd',
|
|
212
|
+
chargeAmountMinor: '891', currency: 'eur', entityId: 'entity-1', service: 'app',
|
|
213
|
+
productSku: CREDITS_PRODUCT, planSku: 'app-credit-unit',
|
|
214
|
+
},
|
|
215
|
+
}))
|
|
216
|
+
expect(fake.observed.topUp[0]).toEqual(expect.objectContaining({
|
|
217
|
+
amountMinor: 1_000, sourceChargeAmountMinor: 1_021, amountCurrency: 'usd',
|
|
218
|
+
chargeAmountMinor: 891, currency: 'eur',
|
|
219
|
+
}))
|
|
220
|
+
expect(fulfillment(fake)[0]).toEqual(expect.objectContaining({ amountCurrency: 'usd', currency: 'eur' }))
|
|
221
|
+
})
|
|
222
|
+
|
|
223
|
+
test('grants nothing for an unpaid completion; the asynchronous success does', async () => {
|
|
224
|
+
const fake = await makeFakeContext()
|
|
225
|
+
await process(fake, 'checkout.session.completed', paid({ payment_status: 'unpaid' }))
|
|
226
|
+
expect(fake.observed.topUp).toHaveLength(0)
|
|
227
|
+
await process(fake, 'checkout.session.async_payment_succeeded', paid())
|
|
228
|
+
expect(fake.observed.topUp).toHaveLength(1)
|
|
229
|
+
})
|
|
230
|
+
|
|
231
|
+
test('rejects a currency or subtotal mismatch; retries after a failed observer', async () => {
|
|
232
|
+
const fake = await makeFakeContext()
|
|
233
|
+
await expect(process(fake, 'checkout.session.completed', paid({ amount_subtotal: 1020 }))).rejects.toThrow()
|
|
234
|
+
|
|
235
|
+
fake.observed.failTopUp = 1
|
|
236
|
+
await expect(process(fake, 'checkout.session.completed', paid())).rejects.toThrow('ledger unavailable')
|
|
237
|
+
expect(fulfillment(fake)[0]?.fulfilledAt).toBeUndefined()
|
|
238
|
+
await process(fake, 'checkout.session.completed', paid())
|
|
239
|
+
expect(fake.observed.topUp).toHaveLength(1)
|
|
240
|
+
expect(fulfillment(fake)[0].fulfilledAt).toBeInstanceOf(Date)
|
|
241
|
+
})
|
|
242
|
+
|
|
243
|
+
test('a legacy session without pricing metadata fulfills by quantity', async () => {
|
|
244
|
+
const fake = await makeFakeContext()
|
|
245
|
+
await process(fake, 'checkout.session.completed', paid({
|
|
246
|
+
id: 'cs_legacy', metadata: { entityId: 'entity-1', service: 'app', productSku: CREDITS_PRODUCT, planSku: 'app-credit-unit' },
|
|
247
|
+
}))
|
|
248
|
+
expect(fake.observed.topUp[0]).toEqual(expect.objectContaining({ mode: 'quantity', units: 7 }))
|
|
249
|
+
expect(fulfillment(fake)[0]).toEqual(expect.objectContaining({ mode: 'quantity', units: 7 }))
|
|
134
250
|
})
|
|
135
251
|
})
|