@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.
- package/README.md +52 -54
- package/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/server-payment/SKILL.md +272 -330
- package/agent-meta/skills/server-payment/parts/reference.md +3 -3
- package/build/access/types.d.ts +7 -16
- package/build/access/types.d.ts.map +1 -1
- package/build/access.d.ts.map +1 -1
- package/build/access.js +6 -8
- package/build/access.js.map +1 -1
- package/build/actions/resync.d.ts +3 -3
- package/build/actions/resync.js +5 -5
- package/build/actions/resync.js.map +1 -1
- package/build/actions/webhook.d.ts +4 -1
- package/build/actions/webhook.d.ts.map +1 -1
- package/build/actions/webhook.js +8 -4
- package/build/actions/webhook.js.map +1 -1
- package/build/bootstrap/types.d.ts +13 -7
- package/build/bootstrap/types.d.ts.map +1 -1
- package/build/bootstrap.d.ts +4 -4
- package/build/bootstrap.d.ts.map +1 -1
- package/build/bootstrap.js +19 -10
- package/build/bootstrap.js.map +1 -1
- package/build/catalogue/types.d.ts +3 -3
- package/build/catalogue/types.d.ts.map +1 -1
- package/build/catalogue.d.ts.map +1 -1
- package/build/catalogue.js +4 -8
- package/build/catalogue.js.map +1 -1
- package/build/checkout/types.d.ts +21 -0
- package/build/checkout/types.d.ts.map +1 -0
- package/build/{plugins/stripe → checkout}/types.js.map +1 -1
- package/build/checkout.d.ts +6 -0
- package/build/checkout.d.ts.map +1 -0
- package/build/checkout.js +374 -0
- package/build/checkout.js.map +1 -0
- package/build/config.d.ts +10 -16
- package/build/config.d.ts.map +1 -1
- package/build/config.js +18 -59
- package/build/config.js.map +1 -1
- package/build/consts.d.ts +3 -49
- package/build/consts.d.ts.map +1 -1
- package/build/consts.js +3 -61
- package/build/consts.js.map +1 -1
- package/build/consumer/cancellation/types.d.ts +6 -4
- package/build/consumer/cancellation/types.d.ts.map +1 -1
- package/build/consumer/cancellation.d.ts.map +1 -1
- package/build/consumer/cancellation.js +11 -5
- package/build/consumer/cancellation.js.map +1 -1
- package/build/consumer/capture/types.d.ts +8 -12
- package/build/consumer/capture/types.d.ts.map +1 -1
- package/build/consumer/capture.d.ts.map +1 -1
- package/build/consumer/capture.js +48 -53
- package/build/consumer/capture.js.map +1 -1
- package/build/consumer/index.d.ts +4 -0
- package/build/consumer/index.d.ts.map +1 -1
- package/build/consumer/index.js +2 -0
- package/build/consumer/index.js.map +1 -1
- package/build/consumer/reconcile.d.ts.map +1 -1
- package/build/consumer/reconcile.js +82 -72
- package/build/consumer/reconcile.js.map +1 -1
- package/build/consumer/records/types.d.ts +4 -4
- package/build/consumer/records/types.d.ts.map +1 -1
- package/build/consumer/records.d.ts.map +1 -1
- package/build/consumer/records.js +16 -13
- package/build/consumer/records.js.map +1 -1
- package/build/consumer/service.d.ts +2 -2
- package/build/consumer/service.d.ts.map +1 -1
- package/build/consumer/service.js +28 -21
- package/build/consumer/service.js.map +1 -1
- package/build/consumer/types.d.ts +1 -4
- package/build/consumer/types.d.ts.map +1 -1
- package/build/consumer/types.local.d.ts +1 -9
- package/build/consumer/types.local.d.ts.map +1 -1
- package/build/consumer/withdrawal/types.d.ts +14 -12
- package/build/consumer/withdrawal/types.d.ts.map +1 -1
- package/build/consumer/withdrawal.d.ts.map +1 -1
- package/build/consumer/withdrawal.js +55 -71
- package/build/consumer/withdrawal.js.map +1 -1
- package/build/index.d.ts +12 -6
- package/build/index.d.ts.map +1 -1
- package/build/index.js +7 -4
- package/build/index.js.map +1 -1
- package/build/paygate/providers.d.ts +13 -0
- package/build/paygate/providers.d.ts.map +1 -0
- package/build/paygate/providers.js +38 -0
- package/build/paygate/providers.js.map +1 -0
- package/build/paygate/registry.d.ts +6 -0
- package/build/paygate/registry.d.ts.map +1 -0
- package/build/paygate/registry.js +37 -0
- package/build/paygate/registry.js.map +1 -0
- package/build/paygate/types.d.ts +577 -0
- package/build/paygate/types.d.ts.map +1 -0
- package/build/{plugins/session → paygate}/types.js.map +1 -1
- package/build/plan/types.d.ts +6 -1
- package/build/plan/types.d.ts.map +1 -1
- package/build/plan.d.ts.map +1 -1
- package/build/plan.js +16 -2
- package/build/plan.js.map +1 -1
- package/build/plugins/checkout-policy/types.d.ts +5 -3
- package/build/plugins/checkout-policy/types.d.ts.map +1 -1
- package/build/plugins/checkout-policy.d.ts.map +1 -1
- package/build/plugins/checkout-policy.js +5 -3
- package/build/plugins/checkout-policy.js.map +1 -1
- package/build/plugins/consts.local.d.ts +8 -10
- package/build/plugins/consts.local.d.ts.map +1 -1
- package/build/plugins/consts.local.js +2 -19
- package/build/plugins/consts.local.js.map +1 -1
- package/build/plugins/customer-lock/types.d.ts +2 -2
- package/build/plugins/customer-lock/types.d.ts.map +1 -1
- package/build/plugins/customer-lock.js +2 -2
- package/build/plugins/customer-lock.js.map +1 -1
- package/build/plugins/estimate/cache.js +1 -1
- package/build/plugins/estimate/cache.js.map +1 -1
- package/build/plugins/estimate/types.d.ts +10 -10
- package/build/plugins/estimate/types.d.ts.map +1 -1
- package/build/plugins/estimate.d.ts.map +1 -1
- package/build/plugins/estimate.js +48 -122
- package/build/plugins/estimate.js.map +1 -1
- package/build/plugins/events/types.d.ts +17 -10
- package/build/plugins/events/types.d.ts.map +1 -1
- package/build/plugins/events.d.ts +6 -5
- package/build/plugins/events.d.ts.map +1 -1
- package/build/plugins/events.js +162 -173
- package/build/plugins/events.js.map +1 -1
- package/build/plugins/fx/types.d.ts +10 -21
- package/build/plugins/fx/types.d.ts.map +1 -1
- package/build/plugins/fx.d.ts +1 -1
- package/build/plugins/fx.d.ts.map +1 -1
- package/build/plugins/fx.js +17 -54
- package/build/plugins/fx.js.map +1 -1
- package/build/plugins/portal/types.d.ts +8 -37
- package/build/plugins/portal/types.d.ts.map +1 -1
- package/build/plugins/portal.d.ts.map +1 -1
- package/build/plugins/portal.js +38 -208
- package/build/plugins/portal.js.map +1 -1
- package/build/plugins/refunds/types.d.ts +11 -11
- package/build/plugins/refunds/types.d.ts.map +1 -1
- package/build/plugins/refunds.d.ts.map +1 -1
- package/build/plugins/refunds.js +14 -39
- package/build/plugins/refunds.js.map +1 -1
- package/build/plugins/snapshot/types.d.ts +11 -0
- package/build/plugins/snapshot/types.d.ts.map +1 -0
- package/build/plugins/snapshot/types.js +2 -0
- package/build/plugins/snapshot/types.js.map +1 -0
- package/build/plugins/snapshot.d.ts +4 -0
- package/build/plugins/snapshot.d.ts.map +1 -0
- package/build/plugins/snapshot.js +19 -0
- package/build/plugins/snapshot.js.map +1 -0
- package/build/plugins/subscriptions/types.d.ts +17 -17
- package/build/plugins/subscriptions/types.d.ts.map +1 -1
- package/build/plugins/subscriptions.d.ts +4 -4
- package/build/plugins/subscriptions.d.ts.map +1 -1
- package/build/plugins/subscriptions.js +69 -77
- package/build/plugins/subscriptions.js.map +1 -1
- package/build/plugins/types.local.d.ts +9 -43
- package/build/plugins/types.local.d.ts.map +1 -1
- package/build/plugins/webhook-manager/types.d.ts +15 -43
- package/build/plugins/webhook-manager/types.d.ts.map +1 -1
- package/build/plugins/webhook-manager.d.ts +3 -3
- package/build/plugins/webhook-manager.d.ts.map +1 -1
- package/build/plugins/webhook-manager.js +21 -199
- package/build/plugins/webhook-manager.js.map +1 -1
- package/build/protocol.d.ts +1 -1
- package/build/protocol.d.ts.map +1 -1
- package/build/protocol.js +1 -1
- package/build/protocol.js.map +1 -1
- package/build/service.d.ts +11 -11
- package/build/service.d.ts.map +1 -1
- package/build/service.js +59 -23
- package/build/service.js.map +1 -1
- package/build/sync/types.d.ts +17 -13
- package/build/sync/types.d.ts.map +1 -1
- package/build/sync.d.ts.map +1 -1
- package/build/sync.js +22 -122
- package/build/sync.js.map +1 -1
- package/build/types.d.ts +46 -101
- package/build/types.d.ts.map +1 -1
- package/build/utils/types.d.ts +0 -8
- package/build/utils/types.d.ts.map +1 -1
- package/build/utils.d.ts +1 -4
- package/build/utils.d.ts.map +1 -1
- package/build/utils.js +1 -15
- package/build/utils.js.map +1 -1
- package/package.json +20 -22
- package/src/access/types.ts +7 -16
- package/src/access.ts +7 -15
- package/src/actions/resync.ts +5 -5
- package/src/actions/webhook.ts +8 -4
- package/src/bootstrap/types.ts +13 -7
- package/src/bootstrap.ts +23 -13
- package/src/catalogue/types.ts +3 -3
- package/src/catalogue.ts +4 -8
- package/src/checkout/types.ts +21 -0
- package/src/checkout.ts +414 -0
- package/src/config.ts +19 -66
- package/src/consts.ts +3 -69
- package/src/consumer/cancellation/types.ts +6 -4
- package/src/consumer/cancellation.ts +13 -7
- package/src/consumer/capture/types.ts +8 -12
- package/src/consumer/capture.ts +50 -59
- package/src/consumer/index.ts +4 -0
- package/src/consumer/reconcile.ts +69 -68
- package/src/consumer/records/types.ts +4 -4
- package/src/consumer/records.ts +19 -14
- package/src/consumer/service.ts +35 -22
- package/src/consumer/types.local.ts +1 -8
- package/src/consumer/types.ts +1 -4
- package/src/consumer/withdrawal/types.ts +14 -12
- package/src/consumer/withdrawal.ts +61 -77
- package/src/index.ts +12 -6
- package/src/paygate/providers.ts +48 -0
- package/src/paygate/registry.ts +53 -0
- package/src/paygate/types.ts +640 -0
- package/src/plan/types.ts +6 -1
- package/src/plan.ts +21 -3
- package/src/plugins/checkout-policy/types.ts +5 -3
- package/src/plugins/checkout-policy.ts +6 -5
- package/src/plugins/consts.local.ts +2 -26
- package/src/plugins/customer-lock/types.ts +2 -2
- package/src/plugins/customer-lock.ts +2 -2
- package/src/plugins/estimate/cache.ts +1 -1
- package/src/plugins/estimate/types.ts +10 -10
- package/src/plugins/estimate.ts +52 -128
- package/src/plugins/events/types.ts +17 -9
- package/src/plugins/events.ts +172 -190
- package/src/plugins/fx/types.ts +10 -23
- package/src/plugins/fx.ts +28 -64
- package/src/plugins/portal/types.ts +8 -38
- package/src/plugins/portal.ts +48 -229
- package/src/plugins/refunds/types.ts +11 -11
- package/src/plugins/refunds.ts +16 -40
- package/src/plugins/snapshot/types.ts +11 -0
- package/src/plugins/snapshot.ts +22 -0
- package/src/plugins/subscriptions/types.ts +17 -17
- package/src/plugins/subscriptions.ts +81 -81
- package/src/plugins/types.local.ts +9 -33
- package/src/plugins/webhook-manager/types.ts +15 -43
- package/src/plugins/webhook-manager.ts +24 -220
- package/src/protocol.ts +1 -1
- package/src/service.ts +66 -30
- package/src/sync/types.ts +17 -13
- package/src/sync.ts +25 -143
- package/src/types.ts +47 -97
- package/src/utils/types.ts +0 -9
- package/src/utils.ts +2 -20
- package/tests/capabilities.spec.ts +219 -0
- package/tests/entitlement.spec.ts +4 -4
- package/tests/gate-handlers.spec.ts +6 -6
- package/tests/gate.spec.ts +2 -2
- package/tests/grants.spec.ts +2 -2
- package/tests/internal-plan.spec.ts +2 -2
- package/tests/limit-gate.spec.ts +2 -2
- package/tests/paygates.spec.ts +132 -0
- package/tests/protocol.spec.ts +4 -5
- package/tests/usage.spec.ts +2 -2
- package/tests/webhook.spec.ts +137 -0
- package/build/plugins/session/types.d.ts +0 -34
- package/build/plugins/session/types.d.ts.map +0 -1
- package/build/plugins/session.d.ts +0 -4
- package/build/plugins/session.d.ts.map +0 -1
- package/build/plugins/session.js +0 -71
- package/build/plugins/session.js.map +0 -1
- package/build/plugins/status.d.ts +0 -8
- package/build/plugins/status.d.ts.map +0 -1
- package/build/plugins/status.js +0 -21
- package/build/plugins/status.js.map +0 -1
- package/build/plugins/stripe/types.d.ts +0 -20
- package/build/plugins/stripe/types.d.ts.map +0 -1
- package/build/plugins/stripe.d.ts +0 -6
- package/build/plugins/stripe.d.ts.map +0 -1
- package/build/plugins/stripe.js +0 -518
- package/build/plugins/stripe.js.map +0 -1
- package/src/plugins/session/types.ts +0 -30
- package/src/plugins/session.ts +0 -86
- package/src/plugins/status.ts +0 -22
- package/src/plugins/stripe/types.ts +0 -20
- package/src/plugins/stripe.ts +0 -571
- package/tests/checkout-consumer.spec.ts +0 -366
- package/tests/checkout-locks.spec.ts +0 -161
- package/tests/checkout-plugins.spec.ts +0 -164
- package/tests/checkout.spec.ts +0 -313
- package/tests/consumer-events.spec.ts +0 -215
- package/tests/consumer-fixtures.ts +0 -141
- package/tests/consumer-ops.spec.ts +0 -361
- package/tests/consumer-rights.integration.spec.ts +0 -147
- package/tests/consumer-rights.spec.ts +0 -606
- package/tests/context.ts +0 -110
- package/tests/estimate.spec.ts +0 -350
- package/tests/events.spec.ts +0 -367
- package/tests/fake-stripe.ts +0 -1004
- package/tests/gateway-options.spec.ts +0 -180
- package/tests/portal.spec.ts +0 -202
- package/tests/sync.spec.ts +0 -114
- package/tests/usage.integration.spec.ts +0 -165
- package/tests/webhook-manager.spec.ts +0 -149
- /package/build/{plugins/session → checkout}/types.js +0 -0
- /package/build/{plugins/stripe → paygate}/types.js +0 -0
|
@@ -0,0 +1,577 @@
|
|
|
1
|
+
import type { LazyService } from '@owlmeans/context';
|
|
2
|
+
import type { PortalFlow, SubscriptionStatus, TaxBehavior, TaxEstimate } from '@owlmeans/payment';
|
|
3
|
+
import type { Context as ApiContext } from '@owlmeans/server-api';
|
|
4
|
+
import type { DisputePhase, PaymentPlan, PaymentProduct, PaymentWebhookRecord, SyncedPriceOption } from '../types.js';
|
|
5
|
+
/**
|
|
6
|
+
* What a paygate can put on a checkout beyond the required core. The host compares them with the
|
|
7
|
+
* declared policies when the gateway initializes: a declared policy feature a registered paygate
|
|
8
|
+
* lacks fails the boot (`PaygateError('feature:<flag>:<paygate>')`).
|
|
9
|
+
*/
|
|
10
|
+
export interface PaygateFeatures {
|
|
11
|
+
/** The session calculates tax itself — required by the pricing policy's `tax.automatic`. */
|
|
12
|
+
automaticTax: boolean;
|
|
13
|
+
/** The session collects a business tax id — required by `tax.collectTaxId`. */
|
|
14
|
+
taxIdCollection: boolean;
|
|
15
|
+
/** The session shows and charges the buyer's local currency — required by `currency.adaptive`. */
|
|
16
|
+
adaptiveCurrency: boolean;
|
|
17
|
+
/** The session collects the acceptance of the terms — required by the consumer-rights `checkoutTerms`. */
|
|
18
|
+
termsConsent: boolean;
|
|
19
|
+
/** The longest text the session shows beside a control. Absent: no length is asserted. */
|
|
20
|
+
customTextMax?: number;
|
|
21
|
+
/**
|
|
22
|
+
* The session lifetime the paygate accepts. The smallest `sessionTtlSeconds` of the checkout
|
|
23
|
+
* plugins is clamped into it; absent, a session takes no lifetime from the plugins at all.
|
|
24
|
+
*/
|
|
25
|
+
sessionTtl?: {
|
|
26
|
+
minSeconds: number;
|
|
27
|
+
maxSeconds: number;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A payment provider: one paygate implementation, registered with
|
|
32
|
+
* `ensurePaymentProviders(ctx).register(provider)` (a provider package's `append…` helper does it).
|
|
33
|
+
* `bind` builds the paygate of one context; `paygatesOf(ctx)` calls it once per context and provider.
|
|
34
|
+
*/
|
|
35
|
+
export interface PaymentProvider {
|
|
36
|
+
/** The paygate id stored on every record the paygate produced (`paygate`) and named in its webhook path. */
|
|
37
|
+
readonly id: string;
|
|
38
|
+
readonly features: PaygateFeatures;
|
|
39
|
+
bind: (ctx: ApiContext) => Paygate;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* One paygate bound to a context. `customers` and `checkout` are required; every other capability is
|
|
43
|
+
* optional and its absence has a defined host reaction:
|
|
44
|
+
*
|
|
45
|
+
* | Absent | Host reaction |
|
|
46
|
+
* |---|---|
|
|
47
|
+
* | `subscriptions` | recurring plans are not for sale through it; resync skips it; a subscription withdrawal is `review`; a cancellation is only received |
|
|
48
|
+
* | `payments` | every withdrawal is `review`; refunds and disputes resolve without charge or invoice reads |
|
|
49
|
+
* | `payments.creditNotes` | a withdrawal refunds proportionally, without a corrective document |
|
|
50
|
+
* | `webhook` | its webhook route throws `PaygateError('capability:webhook')`; the bootstrap skips the endpoint |
|
|
51
|
+
* | `catalogue` | the product sync skips it; a quantity or subscription checkout throws `ProductError('price:<lookup key>')` |
|
|
52
|
+
* | `portal` | a portal link throws `PortalUnavailable('paygate')`; the bootstrap skips the configuration |
|
|
53
|
+
* | `tax` | an estimate answers `at-checkout` |
|
|
54
|
+
* | `fx` | a conversion between two currencies throws `PaygateError('fx-rate:<from>:<to>')`; an estimate has no local line |
|
|
55
|
+
* | `checkout.listCompleted` | the consumer-rights reconcile backfills no purchase |
|
|
56
|
+
*/
|
|
57
|
+
export interface Paygate {
|
|
58
|
+
readonly id: string;
|
|
59
|
+
readonly features: PaygateFeatures;
|
|
60
|
+
/** The currency the paygate settles in (lowercase), when it declares one; catalogue prices are converted into it. */
|
|
61
|
+
settlementCurrency: () => Promise<string | undefined>;
|
|
62
|
+
customers: PaygateCustomers;
|
|
63
|
+
checkout: PaygateCheckout;
|
|
64
|
+
subscriptions?: PaygateSubscriptions;
|
|
65
|
+
payments?: PaygatePayments;
|
|
66
|
+
webhook?: PaygateWebhook;
|
|
67
|
+
catalogue?: PaygateCatalogue;
|
|
68
|
+
portal?: PaygatePortal;
|
|
69
|
+
tax?: PaygateTax;
|
|
70
|
+
fx?: PaygateFx;
|
|
71
|
+
}
|
|
72
|
+
/** Every call that moves money or ends a contract carries the host's idempotency key and a note. */
|
|
73
|
+
export interface PaygateCall {
|
|
74
|
+
/** The key the paygate deduplicates a retried call by (`withdrawal:<id>:<step>[:<attempt>]`, `cancellation:<id>:schedule[:<attempt>]`). */
|
|
75
|
+
idempotencyKey: string;
|
|
76
|
+
/** A note kept on the changed object (`withdrawal:<id>`, `cancellation:<id>`). */
|
|
77
|
+
comment?: string;
|
|
78
|
+
}
|
|
79
|
+
/** Whose paygate state a call touches: the gateway's `owner`. */
|
|
80
|
+
export interface PaygateOwner {
|
|
81
|
+
owner: string;
|
|
82
|
+
}
|
|
83
|
+
/** One deployment: its owner and its public webhook URL (`webhookOf(ctx).webhookUrlOf(paygate)`). */
|
|
84
|
+
export interface PaygateDeployment extends PaygateOwner {
|
|
85
|
+
webhookUrl: string;
|
|
86
|
+
}
|
|
87
|
+
export interface PaygateTaxId {
|
|
88
|
+
type: string;
|
|
89
|
+
value: string;
|
|
90
|
+
country?: string;
|
|
91
|
+
}
|
|
92
|
+
/** A paygate customer as the host reads it. */
|
|
93
|
+
export interface PaygateCustomer {
|
|
94
|
+
id: string;
|
|
95
|
+
email?: string;
|
|
96
|
+
/** The saved address's country, as the paygate keeps it. */
|
|
97
|
+
country?: string;
|
|
98
|
+
/** The saved address alone lets the paygate calculate tax (a country, plus what some countries need). */
|
|
99
|
+
taxLocatable: boolean;
|
|
100
|
+
/** Read only when asked for (`retrieve(id, { taxIds: true })`). */
|
|
101
|
+
taxIds?: PaygateTaxId[];
|
|
102
|
+
taxExempt?: 'none' | 'exempt' | 'reverse';
|
|
103
|
+
}
|
|
104
|
+
export interface CustomerInput {
|
|
105
|
+
entityId: string;
|
|
106
|
+
profileId?: string;
|
|
107
|
+
service: string;
|
|
108
|
+
/** The checkout locale, kept as the customer's preferred locale. */
|
|
109
|
+
locale?: string;
|
|
110
|
+
/** Written to the customer — only passed under the paygate's own e-mail lock. */
|
|
111
|
+
email?: string;
|
|
112
|
+
}
|
|
113
|
+
/** The customer fields the application pins on the paygate customer (provider configuration). */
|
|
114
|
+
export interface CustomerLocks {
|
|
115
|
+
/** Every checkout passes the buyer's verified e-mail, which the customer carries. */
|
|
116
|
+
email: boolean;
|
|
117
|
+
/** The known billing country is pinned on the customer and Checkout keeps it. */
|
|
118
|
+
country: boolean;
|
|
119
|
+
}
|
|
120
|
+
export interface PaygateCustomers {
|
|
121
|
+
/**
|
|
122
|
+
* The entity's customer — the stored one (its locale and, given, e-mail brought up to date), else a
|
|
123
|
+
* new one; the host's `payment-paygate-customer` row follows.
|
|
124
|
+
*/
|
|
125
|
+
ensure: (input: CustomerInput) => Promise<PaygateCustomer>;
|
|
126
|
+
/** A customer by id, or `null` when the paygate has none (deleted or missing). */
|
|
127
|
+
retrieve: (customerId: string, opts?: {
|
|
128
|
+
taxIds?: boolean;
|
|
129
|
+
}) => Promise<PaygateCustomer | null>;
|
|
130
|
+
/**
|
|
131
|
+
* Save a billing country on the customer: `replace` writes a country-only address (any other line
|
|
132
|
+
* cleared); without it the country is only preselected on an address-less customer.
|
|
133
|
+
*/
|
|
134
|
+
setCountry: (customerId: string, country: string, opts: {
|
|
135
|
+
replace: boolean;
|
|
136
|
+
}) => Promise<PaygateCustomer>;
|
|
137
|
+
locks: () => Promise<CustomerLocks>;
|
|
138
|
+
}
|
|
139
|
+
export type CheckoutMode = 'amount' | 'quantity' | 'subscription';
|
|
140
|
+
/** An amount checkout's single inline line. */
|
|
141
|
+
export interface AmountSessionLine {
|
|
142
|
+
kind: 'amount';
|
|
143
|
+
productSku: string;
|
|
144
|
+
currency: string;
|
|
145
|
+
unitAmountMinor: number;
|
|
146
|
+
taxBehavior?: TaxBehavior;
|
|
147
|
+
}
|
|
148
|
+
/** A quantity checkout's line on the product's reusable price, the quantity adjustable. */
|
|
149
|
+
export interface QuantitySessionLine {
|
|
150
|
+
kind: 'quantity';
|
|
151
|
+
priceId: string;
|
|
152
|
+
minimum: number;
|
|
153
|
+
maximum: number;
|
|
154
|
+
default: number;
|
|
155
|
+
}
|
|
156
|
+
/** A subscription's line on the plan's reusable price, quantity 1. */
|
|
157
|
+
export interface SubscriptionSessionLine {
|
|
158
|
+
kind: 'subscription';
|
|
159
|
+
priceId: string;
|
|
160
|
+
}
|
|
161
|
+
export type SessionLine = AmountSessionLine | QuantitySessionLine | SubscriptionSessionLine;
|
|
162
|
+
/** The texts a session shows; each already within `features.customTextMax`. */
|
|
163
|
+
export interface SessionTexts {
|
|
164
|
+
submit?: string;
|
|
165
|
+
afterSubmit?: string;
|
|
166
|
+
/** The label of the terms acceptance — only with `collectTerms`. */
|
|
167
|
+
terms?: string;
|
|
168
|
+
}
|
|
169
|
+
/** One checkout session as the host decided it. */
|
|
170
|
+
export interface SessionInput {
|
|
171
|
+
mode: CheckoutMode;
|
|
172
|
+
entityId: string;
|
|
173
|
+
productSku: string;
|
|
174
|
+
planSku: string;
|
|
175
|
+
customerId: string;
|
|
176
|
+
line: SessionLine;
|
|
177
|
+
/** The session's charge currency (lowercase). */
|
|
178
|
+
currency: string;
|
|
179
|
+
/** Force a quantity or subscription session onto `currency` (its reusable price carries it). */
|
|
180
|
+
forceCurrency: boolean;
|
|
181
|
+
successUrl?: string;
|
|
182
|
+
cancelUrl?: string;
|
|
183
|
+
locale?: string;
|
|
184
|
+
expiresAt?: Date;
|
|
185
|
+
automaticTax: boolean;
|
|
186
|
+
collectTaxId: boolean;
|
|
187
|
+
/** The customer's saved address is kept: tax follows it and nothing typed at the paygate moves it. */
|
|
188
|
+
keepAddress: boolean;
|
|
189
|
+
/** Show and charge the buyer's local currency on this session. */
|
|
190
|
+
adaptiveCurrency: boolean;
|
|
191
|
+
/** Collect the acceptance of the terms, labelled `texts.terms`. */
|
|
192
|
+
collectTerms: boolean;
|
|
193
|
+
texts: SessionTexts;
|
|
194
|
+
/** The session's metadata — the host reads it back from every checkout event. */
|
|
195
|
+
metadata: Record<string, string>;
|
|
196
|
+
/** A subscription session: the metadata of the subscription it creates. */
|
|
197
|
+
subscriptionMetadata?: Record<string, string>;
|
|
198
|
+
}
|
|
199
|
+
export interface PaygateSession {
|
|
200
|
+
id: string;
|
|
201
|
+
/** Where the buyer pays; `null` when the paygate made no usable session. */
|
|
202
|
+
url: string | null;
|
|
203
|
+
}
|
|
204
|
+
export type CheckoutPaymentStatus = 'paid' | 'unpaid' | 'not-required';
|
|
205
|
+
/** What a checkout session says about its buyer. */
|
|
206
|
+
export interface CheckoutBuyer {
|
|
207
|
+
/** The billing address's country, as the paygate keeps it. */
|
|
208
|
+
country?: string;
|
|
209
|
+
email?: string;
|
|
210
|
+
name?: string;
|
|
211
|
+
/** A business tax id was given, or the buyer is reverse-charged. */
|
|
212
|
+
business?: boolean;
|
|
213
|
+
}
|
|
214
|
+
/** A checkout session as the host reads it from an event, a listing or a backfill. */
|
|
215
|
+
export interface CheckoutSnapshot {
|
|
216
|
+
id: string;
|
|
217
|
+
/** A one-time `payment`, a `subscription`, or any other kind the host does not fulfil. */
|
|
218
|
+
mode: 'payment' | 'subscription' | 'other';
|
|
219
|
+
status?: string;
|
|
220
|
+
payment: CheckoutPaymentStatus;
|
|
221
|
+
/** Promotion codes could be entered. */
|
|
222
|
+
promotionCodes: boolean;
|
|
223
|
+
metadata: Record<string, string>;
|
|
224
|
+
customerId?: string;
|
|
225
|
+
currency?: string;
|
|
226
|
+
amountSubtotalMinor?: number | null;
|
|
227
|
+
amountTotalMinor?: number | null;
|
|
228
|
+
amountTaxMinor?: number | null;
|
|
229
|
+
amountDiscountMinor?: number | null;
|
|
230
|
+
paymentId?: string;
|
|
231
|
+
invoiceId?: string;
|
|
232
|
+
subscriptionId?: string;
|
|
233
|
+
buyer: CheckoutBuyer;
|
|
234
|
+
/** What the buyer saw in their own currency (local-currency pricing). */
|
|
235
|
+
presentment?: {
|
|
236
|
+
currency?: string;
|
|
237
|
+
amountMinor?: number;
|
|
238
|
+
};
|
|
239
|
+
/** The terms acceptance the session collected; absent when it collected none. */
|
|
240
|
+
termsAccepted?: boolean;
|
|
241
|
+
createdAt?: Date;
|
|
242
|
+
}
|
|
243
|
+
export interface CheckoutPage {
|
|
244
|
+
items: CheckoutSnapshot[];
|
|
245
|
+
/** Pass back for the next page; absent on the last one. */
|
|
246
|
+
cursor?: string;
|
|
247
|
+
}
|
|
248
|
+
export interface PaygateCheckout {
|
|
249
|
+
/** Create the session; a session the paygate refuses for its own configuration alone may be created once more without that option. */
|
|
250
|
+
createSession: (input: SessionInput) => Promise<PaygateSession>;
|
|
251
|
+
expireSession: (sessionId: string) => Promise<void>;
|
|
252
|
+
/** The units a completed quantity checkout bought. */
|
|
253
|
+
units: (sessionId: string) => Promise<number>;
|
|
254
|
+
/** Completed sessions created since `since`, one page at a time. */
|
|
255
|
+
listCompleted?: (since: Date, cursor?: string) => Promise<CheckoutPage>;
|
|
256
|
+
}
|
|
257
|
+
/** A paygate subscription as the host reads it. */
|
|
258
|
+
export interface PaygateSubscription {
|
|
259
|
+
id: string;
|
|
260
|
+
customerId?: string;
|
|
261
|
+
metadata: Record<string, string>;
|
|
262
|
+
status: SubscriptionStatus;
|
|
263
|
+
/** The paygate's own status word. */
|
|
264
|
+
externalStatus: string;
|
|
265
|
+
/** Collection is paused (or the subscription is). */
|
|
266
|
+
paused: boolean;
|
|
267
|
+
/** The plan its item's price names (the price's lookup key, else its own plan sku). */
|
|
268
|
+
planSku?: string;
|
|
269
|
+
itemId?: string;
|
|
270
|
+
priceId?: string;
|
|
271
|
+
unitAmountMinor?: number;
|
|
272
|
+
quantity?: number;
|
|
273
|
+
priceCurrency?: string;
|
|
274
|
+
taxBehavior?: string;
|
|
275
|
+
periodStart?: Date;
|
|
276
|
+
periodEnd?: Date;
|
|
277
|
+
cancelAtPeriodEnd: boolean;
|
|
278
|
+
canceledAt?: Date;
|
|
279
|
+
endedAt?: Date;
|
|
280
|
+
trialEnd?: Date;
|
|
281
|
+
latestInvoiceId?: string;
|
|
282
|
+
currency?: string;
|
|
283
|
+
createdAt?: Date;
|
|
284
|
+
}
|
|
285
|
+
/** When an ordinary cancellation takes effect: the period end, or a later instant. */
|
|
286
|
+
export interface CancelSchedule {
|
|
287
|
+
atPeriodEnd: boolean;
|
|
288
|
+
/** Without `atPeriodEnd`: the instant it ends (no proration). */
|
|
289
|
+
at?: Date;
|
|
290
|
+
}
|
|
291
|
+
export interface PaygateSubscriptions {
|
|
292
|
+
/** A subscription by id, or `null` when the paygate no longer has it. */
|
|
293
|
+
retrieve: (subscriptionId: string) => Promise<PaygateSubscription | null>;
|
|
294
|
+
/** End it at once, without proration or a final invoice. `alreadyCanceled`: it had ended. */
|
|
295
|
+
cancelNow: (subscriptionId: string, call: PaygateCall) => Promise<{
|
|
296
|
+
alreadyCanceled: boolean;
|
|
297
|
+
}>;
|
|
298
|
+
scheduleCancel: (subscriptionId: string, when: CancelSchedule, call: PaygateCall) => Promise<void>;
|
|
299
|
+
}
|
|
300
|
+
export interface PaygateCharge {
|
|
301
|
+
id: string;
|
|
302
|
+
paymentId?: string;
|
|
303
|
+
invoiceId?: string;
|
|
304
|
+
/** What the customer paid, tax included. */
|
|
305
|
+
amountMinor?: number;
|
|
306
|
+
/** Refunded on it so far. */
|
|
307
|
+
refundedMinor?: number;
|
|
308
|
+
}
|
|
309
|
+
export interface PaygateInvoice {
|
|
310
|
+
id: string;
|
|
311
|
+
number?: string;
|
|
312
|
+
/** Its first line — what a credit note corrects. */
|
|
313
|
+
firstLineId?: string;
|
|
314
|
+
paymentId?: string;
|
|
315
|
+
subscriptionId?: string;
|
|
316
|
+
/** The customer address's country, as the paygate keeps it. */
|
|
317
|
+
country?: string;
|
|
318
|
+
subtotalMinor?: number;
|
|
319
|
+
taxMinor?: number;
|
|
320
|
+
totalMinor?: number;
|
|
321
|
+
currency?: string;
|
|
322
|
+
}
|
|
323
|
+
export interface PaygateRefund {
|
|
324
|
+
id: string;
|
|
325
|
+
/** The paygate's own status word; the host applies only a succeeded one. */
|
|
326
|
+
status: string;
|
|
327
|
+
succeeded: boolean;
|
|
328
|
+
amountMinor: number;
|
|
329
|
+
currency: string;
|
|
330
|
+
paymentId?: string;
|
|
331
|
+
chargeId?: string;
|
|
332
|
+
metadata: Record<string, string>;
|
|
333
|
+
}
|
|
334
|
+
export interface PaygateDispute {
|
|
335
|
+
id: string;
|
|
336
|
+
status: string;
|
|
337
|
+
amountMinor: number;
|
|
338
|
+
currency: string;
|
|
339
|
+
paymentId?: string;
|
|
340
|
+
chargeId?: string;
|
|
341
|
+
}
|
|
342
|
+
export interface RefundInput {
|
|
343
|
+
paymentId: string;
|
|
344
|
+
amountMinor: number;
|
|
345
|
+
/** Kept on the refund and read back from its events (`withdrawalId`, `purchaseId`). */
|
|
346
|
+
metadata: Record<string, string>;
|
|
347
|
+
}
|
|
348
|
+
/** One invoice line credited by an amount. */
|
|
349
|
+
export interface CreditNoteLine {
|
|
350
|
+
invoiceId: string;
|
|
351
|
+
lineId: string;
|
|
352
|
+
amountMinor: number;
|
|
353
|
+
}
|
|
354
|
+
export interface CreditNoteInput extends CreditNoteLine {
|
|
355
|
+
/** The refund the credit note documents. */
|
|
356
|
+
refundId: string;
|
|
357
|
+
memo: string;
|
|
358
|
+
metadata: Record<string, string>;
|
|
359
|
+
}
|
|
360
|
+
export interface PaygateCreditNote {
|
|
361
|
+
id: string;
|
|
362
|
+
totalMinor: number;
|
|
363
|
+
currency: string;
|
|
364
|
+
}
|
|
365
|
+
export interface PaygateCreditNotes {
|
|
366
|
+
/** What a credit note of this line would total (tax included). */
|
|
367
|
+
preview: (line: CreditNoteLine) => Promise<{
|
|
368
|
+
totalMinor: number;
|
|
369
|
+
}>;
|
|
370
|
+
create: (input: CreditNoteInput, call: PaygateCall) => Promise<PaygateCreditNote>;
|
|
371
|
+
/** A live credit note of the invoice carrying this metadata — what a retry adopts. */
|
|
372
|
+
find: (invoiceId: string, metadata: Record<string, string>) => Promise<PaygateCreditNote | null>;
|
|
373
|
+
}
|
|
374
|
+
export interface PaygatePayments {
|
|
375
|
+
/** A charge by id, or `null` when the paygate has none. */
|
|
376
|
+
charge: (chargeId: string) => Promise<PaygateCharge | null>;
|
|
377
|
+
/** An invoice by id, or `null` when the paygate has none. */
|
|
378
|
+
invoice: (invoiceId: string) => Promise<PaygateInvoice | null>;
|
|
379
|
+
refund: (input: RefundInput, call: PaygateCall) => Promise<PaygateRefund>;
|
|
380
|
+
/** A live refund of the payment carrying this metadata — what a retry adopts. */
|
|
381
|
+
findRefund: (paymentId: string, metadata: Record<string, string>) => Promise<PaygateRefund | null>;
|
|
382
|
+
creditNotes?: PaygateCreditNotes;
|
|
383
|
+
}
|
|
384
|
+
/** A webhook delivery exactly as it arrived: the untouched raw body and the headers. */
|
|
385
|
+
export interface PaygateDelivery {
|
|
386
|
+
rawBody?: string | Buffer;
|
|
387
|
+
headers: Record<string, string | string[] | undefined>;
|
|
388
|
+
}
|
|
389
|
+
export interface EventCustomer {
|
|
390
|
+
id: string;
|
|
391
|
+
email?: string;
|
|
392
|
+
name?: string;
|
|
393
|
+
taxId?: string;
|
|
394
|
+
/** The saved address's country, as the paygate keeps it. */
|
|
395
|
+
country?: string;
|
|
396
|
+
currency?: string;
|
|
397
|
+
metadata: Record<string, string>;
|
|
398
|
+
}
|
|
399
|
+
export interface CustomerEvent {
|
|
400
|
+
type: 'customer';
|
|
401
|
+
change: 'upserted' | 'deleted';
|
|
402
|
+
customer: EventCustomer;
|
|
403
|
+
}
|
|
404
|
+
export interface CheckoutEvent {
|
|
405
|
+
type: 'checkout';
|
|
406
|
+
/** `completed` also for a delayed payment that succeeded; `failed` a delayed payment that failed. */
|
|
407
|
+
outcome: 'completed' | 'failed' | 'expired';
|
|
408
|
+
session: CheckoutSnapshot;
|
|
409
|
+
}
|
|
410
|
+
export interface SubscriptionChangedEvent {
|
|
411
|
+
type: 'subscription';
|
|
412
|
+
eventId: string;
|
|
413
|
+
/** When the paygate produced the event; an older payload than the stored state is not applied. */
|
|
414
|
+
createdAt: Date;
|
|
415
|
+
subscription: PaygateSubscription;
|
|
416
|
+
/** The subscription was deleted: stored as canceled, whatever its payload says. */
|
|
417
|
+
deleted: boolean;
|
|
418
|
+
/** The paygate announced the trial ends soon. */
|
|
419
|
+
trialEnding: boolean;
|
|
420
|
+
}
|
|
421
|
+
export interface EventInvoice {
|
|
422
|
+
id: string;
|
|
423
|
+
subscriptionId?: string;
|
|
424
|
+
customerId?: string;
|
|
425
|
+
/** A renewal of the subscription's cycle. */
|
|
426
|
+
renewal: boolean;
|
|
427
|
+
attempt?: number;
|
|
428
|
+
nextAttemptAt?: Date;
|
|
429
|
+
}
|
|
430
|
+
export interface InvoiceEvent {
|
|
431
|
+
type: 'invoice';
|
|
432
|
+
eventId: string;
|
|
433
|
+
change: 'paid' | 'payment-failed' | 'action-required' | 'uncollectible' | 'voided';
|
|
434
|
+
invoice: EventInvoice;
|
|
435
|
+
}
|
|
436
|
+
export interface RefundChangedEvent {
|
|
437
|
+
type: 'refund';
|
|
438
|
+
refund: PaygateRefund;
|
|
439
|
+
/** The refunded charge, when the event carries it. */
|
|
440
|
+
charge?: PaygateCharge;
|
|
441
|
+
}
|
|
442
|
+
export interface DisputeChangedEvent {
|
|
443
|
+
type: 'dispute';
|
|
444
|
+
phase: DisputePhase;
|
|
445
|
+
dispute: PaygateDispute;
|
|
446
|
+
}
|
|
447
|
+
export type PaygateEvent = CustomerEvent | CheckoutEvent | SubscriptionChangedEvent | InvoiceEvent | RefundChangedEvent | DisputeChangedEvent;
|
|
448
|
+
export interface PaygateWebhook {
|
|
449
|
+
/**
|
|
450
|
+
* Verify a delivery against the owner's secrets and translate it into the events the host applies,
|
|
451
|
+
* in order — none for an event type the host does not process.
|
|
452
|
+
*
|
|
453
|
+
* @throws PaygateSignatureError | WebhookSetupError('secret')
|
|
454
|
+
*/
|
|
455
|
+
verify: (delivery: PaygateDelivery, owner: PaygateOwner) => Promise<PaygateEvent[]>;
|
|
456
|
+
/** Keep the deployment's endpoint at its webhook URL; the row is the host's `payment-webhook` record. */
|
|
457
|
+
ensureEndpoint: (deployment: PaygateDeployment, opts?: {
|
|
458
|
+
force?: boolean;
|
|
459
|
+
}) => Promise<PaymentWebhookRecord | null>;
|
|
460
|
+
}
|
|
461
|
+
/** A reusable price as the paygate holds it. */
|
|
462
|
+
export interface PaygatePrice {
|
|
463
|
+
id: string;
|
|
464
|
+
currency: string;
|
|
465
|
+
unitAmountMinor?: number;
|
|
466
|
+
/** Further currencies it can be charged in. */
|
|
467
|
+
options: Record<string, {
|
|
468
|
+
unitAmountMinor?: number;
|
|
469
|
+
}>;
|
|
470
|
+
}
|
|
471
|
+
/** One plan resolved for the paygate: its lookup key, its amount in the paygate's currency and its options. */
|
|
472
|
+
export interface CataloguePlan {
|
|
473
|
+
plan: PaymentPlan;
|
|
474
|
+
lookupKey: string;
|
|
475
|
+
unitAmountMinor: number;
|
|
476
|
+
currency: string;
|
|
477
|
+
options: SyncedPriceOption[];
|
|
478
|
+
}
|
|
479
|
+
export interface CatalogueSync {
|
|
480
|
+
productId: string;
|
|
481
|
+
prices: Array<{
|
|
482
|
+
planSku: string;
|
|
483
|
+
priceId: string;
|
|
484
|
+
taxBehavior?: string;
|
|
485
|
+
}>;
|
|
486
|
+
}
|
|
487
|
+
export interface PaygateCatalogue {
|
|
488
|
+
/** The active reusable price under a lookup key. @throws ProductError('price:<lookup key>') */
|
|
489
|
+
price: (productSku: string, lookupKey: string) => Promise<PaygatePrice>;
|
|
490
|
+
/**
|
|
491
|
+
* Bring one product and its plans' prices to what is declared; an amount plan has no reusable price
|
|
492
|
+
* (its stale ones are deactivated). Answers the price of every other plan.
|
|
493
|
+
*/
|
|
494
|
+
syncProduct: (product: PaymentProduct, plans: CataloguePlan[], opts: {
|
|
495
|
+
behavior: TaxBehavior | null;
|
|
496
|
+
}) => Promise<CatalogueSync>;
|
|
497
|
+
}
|
|
498
|
+
export interface PortalSessionInput {
|
|
499
|
+
customerId: string;
|
|
500
|
+
flow: PortalFlow;
|
|
501
|
+
returnUrl: string;
|
|
502
|
+
/** `Cancel`, `Update`, `Change`: the subscription acted on. */
|
|
503
|
+
subscriptionId?: string;
|
|
504
|
+
/** `Change`: the subscription's item switched… */
|
|
505
|
+
itemId?: string;
|
|
506
|
+
/** …to the price under this lookup key. */
|
|
507
|
+
lookupKey?: string;
|
|
508
|
+
owner: string;
|
|
509
|
+
/** The deployment, computed only when the configuration must be ensured first. */
|
|
510
|
+
deployment: () => PaygateDeployment;
|
|
511
|
+
}
|
|
512
|
+
export interface PaygatePortal {
|
|
513
|
+
ensureConfiguration: (deployment: PaygateDeployment, opts?: {
|
|
514
|
+
force?: boolean;
|
|
515
|
+
}) => Promise<string | null>;
|
|
516
|
+
/** The portal session URL. */
|
|
517
|
+
createSession: (input: PortalSessionInput) => Promise<string>;
|
|
518
|
+
}
|
|
519
|
+
export interface TaxInput {
|
|
520
|
+
currency: string;
|
|
521
|
+
amountMinor: number;
|
|
522
|
+
/** The line's own reference (the plan sku). */
|
|
523
|
+
reference: string;
|
|
524
|
+
taxBehavior: TaxBehavior;
|
|
525
|
+
taxCode?: string;
|
|
526
|
+
country: string;
|
|
527
|
+
/** The customer's tax ids of `country`. */
|
|
528
|
+
taxIds: Array<{
|
|
529
|
+
type: string;
|
|
530
|
+
value: string;
|
|
531
|
+
}>;
|
|
532
|
+
exemption?: 'exempt' | 'reverse';
|
|
533
|
+
}
|
|
534
|
+
export interface PaygateTax {
|
|
535
|
+
/** The tax at one country; `null` when the paygate cannot place the buyer (the estimate says `at-checkout`). */
|
|
536
|
+
calculate: (input: TaxInput) => Promise<TaxEstimate | null>;
|
|
537
|
+
}
|
|
538
|
+
/** One unlocked rate: `to` units per one `from` unit. */
|
|
539
|
+
export interface FxQuote {
|
|
540
|
+
from: string;
|
|
541
|
+
to: string;
|
|
542
|
+
/** The fee-inclusive rate. */
|
|
543
|
+
exchangeRate: number;
|
|
544
|
+
/** The rate before any fee. */
|
|
545
|
+
baseRate: number;
|
|
546
|
+
/** The rate a catalogue amount is converted into the settlement currency at. */
|
|
547
|
+
referenceRate: number;
|
|
548
|
+
fxFeeRate?: number;
|
|
549
|
+
}
|
|
550
|
+
export interface PaygateFx {
|
|
551
|
+
quote: (from: string, to: string) => Promise<FxQuote | null>;
|
|
552
|
+
}
|
|
553
|
+
/** The registered payment providers of a context — a lazy service: providers register while the application is wired. */
|
|
554
|
+
export interface PaymentProvidersService extends LazyService {
|
|
555
|
+
/** Register a provider; one with the same id is replaced. */
|
|
556
|
+
register: (provider: PaymentProvider) => void;
|
|
557
|
+
/** The provider of an id, or `null`. */
|
|
558
|
+
provider: (id: string) => PaymentProvider | null;
|
|
559
|
+
/** Every registered provider, in registration order. */
|
|
560
|
+
providers: () => readonly PaymentProvider[];
|
|
561
|
+
}
|
|
562
|
+
/** The paygates of a context — each provider bound once. */
|
|
563
|
+
export interface PaygateRegistry {
|
|
564
|
+
/** The paygate of an id, or `null` when no provider of that id is registered. */
|
|
565
|
+
find: (id: string) => Paygate | null;
|
|
566
|
+
/** @throws UnknownPaygate */
|
|
567
|
+
get: (id: string) => Paygate;
|
|
568
|
+
/** Every registered paygate, in registration order. */
|
|
569
|
+
all: () => Paygate[];
|
|
570
|
+
/**
|
|
571
|
+
* The paygates a plan is for sale through, in registration order: the ones it is sold through
|
|
572
|
+
* (`planHelper.isSoldThrough` — absent `gateways` is any paygate) that can sell it (a recurring plan
|
|
573
|
+
* needs `subscriptions`), narrowed to `requested` when given.
|
|
574
|
+
*/
|
|
575
|
+
forSale: (product: PaymentProduct, plan: PaymentPlan, requested?: string) => Paygate[];
|
|
576
|
+
}
|
|
577
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/paygate/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACjG,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAMrH;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,4FAA4F;IAC5F,YAAY,EAAE,OAAO,CAAA;IACrB,+EAA+E;IAC/E,eAAe,EAAE,OAAO,CAAA;IACxB,kGAAkG;IAClG,gBAAgB,EAAE,OAAO,CAAA;IACzB,0GAA0G;IAC1G,YAAY,EAAE,OAAO,CAAA;IACrB,0FAA0F;IAC1F,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;;OAGG;IACH,UAAU,CAAC,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAA;CACxD;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,4GAA4G;IAC5G,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAA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AAE,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAA;CAC7D;AAMD,yHAAyH;AACzH,MAAM,WAAW,uBAAwB,SAAQ,WAAW;IAC1D,6DAA6D;IAC7D,QAAQ,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,IAAI,CAAA;IAC7C,wCAAwC;IACxC,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,eAAe,GAAG,IAAI,CAAA;IAChD,wDAAwD;IACxD,SAAS,EAAE,MAAM,SAAS,eAAe,EAAE,CAAA;CAC5C;AAED,4DAA4D;AAC5D,MAAM,WAAW,eAAe;IAC9B,iFAAiF;IACjF,IAAI,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,GAAG,IAAI,CAAA;IACpC,6BAA6B;IAC7B,GAAG,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAA;IAC5B,uDAAuD;IACvD,GAAG,EAAE,MAAM,OAAO,EAAE,CAAA;IACpB;;;;OAIG;IACH,OAAO,EAAE,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,CAAC,EAAE,MAAM,KAAK,OAAO,EAAE,CAAA;CACvF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/paygate/types.ts"],"names":[],"mappings":""}
|
package/build/plan/types.d.ts
CHANGED
|
@@ -15,7 +15,12 @@ export interface PlanHelper {
|
|
|
15
15
|
*/
|
|
16
16
|
overriddenPlan: (plan: PaymentPlan, row: Pick<PaymentSubscriptionRecord, 'overrides'> | null | undefined) => PaymentPlan;
|
|
17
17
|
planLookupKey: (product: PaymentProduct, plan: PaymentPlan) => string;
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Whether a plan is sold through a paygate: never a free plan; otherwise its own `gateways`, else
|
|
20
|
+
* the product's — and neither declared means every paygate.
|
|
21
|
+
*/
|
|
19
22
|
isSoldThrough: (product: PaymentProduct, plan: PaymentPlan, paygate: string) => boolean;
|
|
23
|
+
/** Whether a plan is sold at all: not free, and its gateways (its own, else the product's) are absent or not empty. */
|
|
24
|
+
isForSale: (product: PaymentProduct, plan: PaymentPlan) => boolean;
|
|
20
25
|
}
|
|
21
26
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/plan/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAEzF,sEAAsE;AACtE,MAAM,WAAW,UAAU;IACzB,kDAAkD;IAClD,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,KAAK,MAAM,CAAA;IACrD;;;;;;;;OAQG;IACH,cAAc,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,IAAI,CAAC,yBAAyB,EAAE,WAAW,CAAC,GAAG,IAAI,GAAG,SAAS,KAAK,WAAW,CAAA;IACxH,aAAa,EAAE,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,WAAW,KAAK,MAAM,CAAA;IACrE
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/plan/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAEzF,sEAAsE;AACtE,MAAM,WAAW,UAAU;IACzB,kDAAkD;IAClD,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,KAAK,MAAM,CAAA;IACrD;;;;;;;;OAQG;IACH,cAAc,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,IAAI,CAAC,yBAAyB,EAAE,WAAW,CAAC,GAAG,IAAI,GAAG,SAAS,KAAK,WAAW,CAAA;IACxH,aAAa,EAAE,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,WAAW,KAAK,MAAM,CAAA;IACrE;;;OAGG;IACH,aAAa,EAAE,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAA;IACvF,uHAAuH;IACvH,SAAS,EAAE,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,WAAW,KAAK,OAAO,CAAA;CACnE"}
|
package/build/plan.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../src/plan.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAkB,yBAAyB,EAAE,MAAM,YAAY,CAAA;AACxF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,eAAO,MAAM,gBAAgB,QAAO,
|
|
1
|
+
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../src/plan.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAkB,yBAAyB,EAAE,MAAM,YAAY,CAAA;AACxF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,eAAO,MAAM,gBAAgB,QAAO,UAoDnC,CAAA;AAED,eAAO,MAAM,UAAU,YAAqB,CAAA;AAE5C,+EAA+E;AAC/E,eAAO,MAAM,cAAc,SACnB,WAAW,OAAO,IAAI,CAAC,yBAAyB,EAAE,WAAW,CAAC,GAAG,IAAI,GAAG,SAAS,KACtF,WAAmD,CAAA"}
|
package/build/plan.js
CHANGED
|
@@ -20,8 +20,22 @@ export const createPlanHelper = () => {
|
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
22
|
const planLookupKey = (product, plan) => product.type === ProductType.Consumable ? `${product.sku}-consumable` : plan.sku;
|
|
23
|
-
const
|
|
24
|
-
|
|
23
|
+
const gatewaysOf = (product, plan) => plan.gateways ?? product.gateways ?? undefined;
|
|
24
|
+
const isSoldThrough = (product, plan, paygate) => {
|
|
25
|
+
if (plan.free === true) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
const gateways = gatewaysOf(product, plan);
|
|
29
|
+
return gateways == null || gateways.includes(paygate);
|
|
30
|
+
};
|
|
31
|
+
const isForSale = (product, plan) => {
|
|
32
|
+
if (plan.free === true) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
const gateways = gatewaysOf(product, plan);
|
|
36
|
+
return gateways == null || gateways.length > 0;
|
|
37
|
+
};
|
|
38
|
+
return { planRank, overriddenPlan, planLookupKey, isSoldThrough, isForSale };
|
|
25
39
|
};
|
|
26
40
|
export const planHelper = createPlanHelper();
|
|
27
41
|
/** @deprecated compat:factory-refactor — use `planHelper.overriddenPlan(…)` */
|