@volter/twin-stripe 3.0.0 → 3.0.2
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 +75 -21
- package/dist/journeys/coverage.json +596 -0
- package/dist/journeys/customer-life.json +6108 -0
- package/dist/journeys/customer-life.outline.md +371 -0
- package/dist/journeys/decisions.json +677 -0
- package/dist/journeys/demand.json +706 -0
- package/dist/journeys/score.json +853 -0
- package/dist/journeys/unreachable.json +102 -0
- package/dist/journeys/vendor-examples.json +8010 -0
- package/dist/spec/SOURCE.md +5 -1
- package/dist/spec/doc-examples.json +445 -0
- package/dist/spec/sources.json +135 -207
- package/dist/src/cli.d.ts +0 -1
- package/dist/src/cli.js +0 -2
- package/dist/src/engine/after-payment.d.ts +0 -1
- package/dist/src/engine/after-payment.js +0 -1
- package/dist/src/engine/common.d.ts +5 -5
- package/dist/src/engine/common.js +13 -11
- package/dist/src/engine/connect.d.ts +0 -21
- package/dist/src/engine/connect.js +1 -82
- package/dist/src/engine/customers.d.ts +0 -8
- package/dist/src/engine/customers.js +0 -22
- package/dist/src/engine/display.d.ts +0 -3
- package/dist/src/engine/display.js +0 -3
- package/dist/src/engine/files.d.ts +0 -7
- package/dist/src/engine/files.js +0 -10
- package/dist/src/engine/invoices.d.ts +6 -9
- package/dist/src/engine/invoices.js +56 -29
- package/dist/src/engine/issuing.d.ts +6 -8
- package/dist/src/engine/issuing.js +19 -10
- package/dist/src/engine/ledger.d.ts +0 -1
- package/dist/src/engine/ledger.js +0 -1
- package/dist/src/engine/oauth.js +1 -2
- package/dist/src/engine/refunds.js +2 -27
- package/dist/src/engine/stripe.d.ts +2 -7
- package/dist/src/engine/stripe.js +34 -83
- package/dist/src/engine/subscriptions.d.ts +0 -1
- package/dist/src/engine/subscriptions.js +0 -1
- package/dist/src/engine/version.d.ts +0 -2
- package/dist/src/engine/version.js +17 -6
- package/dist/src/fetch.js +2 -2
- package/dist/src/generated/surface.gen.json +1 -1
- package/dist/src/generated/ui.gen.json +1 -1
- package/dist/src/index.js +5 -3
- package/dist/src/manifest.js +348 -220
- package/dist/src/screens/billing-portal.js +5 -5
- package/dist/src/screens/{connect-oauth.d.ts → checkout-js.d.ts} +0 -1
- package/dist/src/screens/checkout-js.js +84 -0
- package/dist/src/screens/connect-onboarding.js +3 -3
- package/dist/src/screens/dashboard.d.ts +1 -1
- package/dist/src/screens/dashboard.js +56 -53
- package/dist/src/screens/stripe-js.js +53 -93
- package/dist/src/semantics/account.d.ts +2 -0
- package/dist/src/semantics/account.js +8 -0
- package/dist/src/semantics/accounts.js +3 -1
- package/dist/src/semantics/around.js +3 -6
- package/dist/src/semantics/billing_portal.d.ts +0 -1
- package/dist/src/semantics/billing_portal.js +1 -7
- package/dist/src/semantics/checkout.d.ts +1 -1
- package/dist/src/semantics/checkout.js +18 -15
- package/dist/src/semantics/clock.js +1 -7
- package/dist/src/semantics/customers.d.ts +1 -2
- package/dist/src/semantics/customers.js +32 -38
- package/dist/src/semantics/entitlements.d.ts +0 -2
- package/dist/src/semantics/entitlements.js +4 -50
- package/dist/src/semantics/events.d.ts +2 -3
- package/dist/src/semantics/events.js +6 -11
- package/dist/src/semantics/index.js +16 -38
- package/dist/src/semantics/invoices.d.ts +3 -8
- package/dist/src/semantics/invoices.js +134 -127
- package/dist/src/semantics/issuing.d.ts +6 -0
- package/dist/src/semantics/issuing.js +77 -0
- package/dist/src/semantics/payment_intents.d.ts +0 -1
- package/dist/src/semantics/payment_intents.js +5 -13
- package/dist/src/semantics/payment_methods.d.ts +0 -2
- package/dist/src/semantics/payment_methods.js +2 -26
- package/dist/src/semantics/payouts.d.ts +1 -0
- package/dist/src/semantics/payouts.js +8 -1
- package/dist/src/semantics/products.d.ts +1 -3
- package/dist/src/semantics/products.js +3 -14
- package/dist/src/semantics/refunds.d.ts +1 -2
- package/dist/src/semantics/refunds.js +1 -5
- package/dist/src/semantics/shared.d.ts +64 -336
- package/dist/src/semantics/shared.js +326 -1336
- package/dist/src/semantics/states.d.ts +20 -89
- package/dist/src/semantics/states.js +116 -334
- package/dist/src/semantics/subscriptions.d.ts +1 -2
- package/dist/src/semantics/subscriptions.js +23 -145
- package/dist/src/semantics/test_helpers.d.ts +2 -5
- package/dist/src/semantics/test_helpers.js +121 -43
- package/dist/src/semantics/webhook_endpoints.d.ts +2 -0
- package/dist/src/semantics/webhook_endpoints.js +26 -0
- package/generated/pack-facts.json +3 -3
- package/journeys/coverage.json +596 -0
- package/journeys/customer-life.json +6108 -0
- package/journeys/customer-life.outline.md +371 -0
- package/journeys/decisions.json +677 -0
- package/journeys/demand.json +706 -0
- package/journeys/score.json +853 -0
- package/journeys/unreachable.json +102 -0
- package/journeys/vendor-examples.json +8010 -0
- package/package.json +11 -10
- package/spec/SOURCE.md +5 -1
- package/spec/doc-examples.json +445 -0
- package/spec/sources.json +135 -207
- package/src/cli.ts +0 -3
- package/src/engine/after-payment.ts +0 -2
- package/src/engine/balance.ts +0 -1
- package/src/engine/checkout.ts +0 -1
- package/src/engine/common.ts +19 -17
- package/src/engine/connect.ts +1 -79
- package/src/engine/customers.ts +0 -25
- package/src/engine/display.ts +2 -3
- package/src/engine/files.ts +0 -13
- package/src/engine/invoices.ts +64 -33
- package/src/engine/issuing.ts +16 -11
- package/src/engine/ledger.ts +0 -2
- package/src/engine/oauth.ts +1 -2
- package/src/engine/onboarding.ts +0 -1
- package/src/engine/params.ts +0 -1
- package/src/engine/payment-intents.ts +0 -1
- package/src/engine/payment-methods.ts +0 -1
- package/src/engine/refunds.ts +2 -28
- package/src/engine/renewals.ts +0 -1
- package/src/engine/stripe.ts +35 -83
- package/src/engine/subscriptions.ts +0 -3
- package/src/engine/transfers.ts +0 -1
- package/src/engine/version.ts +15 -7
- package/src/engine/webhooks.ts +0 -2
- package/src/fetch.ts +2 -2
- package/src/generated/surface.gen.json +1 -1
- package/src/generated/ui.gen.json +1 -1
- package/src/index.ts +6 -4
- package/src/manifest.ts +348 -220
- package/src/screens/billing-portal.tsx +5 -7
- package/src/screens/checkout-js.ts +80 -0
- package/src/screens/checkout.tsx +0 -2
- package/src/screens/connect-onboarding.tsx +3 -5
- package/src/screens/dashboard.tsx +55 -73
- package/src/screens/stripe-js.ts +57 -125
- package/src/semantics/account.ts +10 -0
- package/src/semantics/account_links.ts +0 -1
- package/src/semantics/accounts.ts +8 -7
- package/src/semantics/apps.ts +1 -2
- package/src/semantics/around.ts +3 -6
- package/src/semantics/balance.ts +0 -1
- package/src/semantics/balance_transactions.ts +1 -3
- package/src/semantics/billing_portal.ts +1 -7
- package/src/semantics/charges.ts +1 -6
- package/src/semantics/checkout.ts +16 -12
- package/src/semantics/clock.ts +1 -8
- package/src/semantics/coupons.ts +0 -1
- package/src/semantics/customers.ts +32 -35
- package/src/semantics/doors.ts +2 -3
- package/src/semantics/entitlements.ts +1 -45
- package/src/semantics/events.ts +7 -14
- package/src/semantics/index.ts +16 -38
- package/src/semantics/invoice_payments.ts +1 -3
- package/src/semantics/invoices.ts +124 -119
- package/src/semantics/issuing.ts +74 -0
- package/src/semantics/payment_intents.ts +10 -17
- package/src/semantics/payment_methods.ts +2 -25
- package/src/semantics/payouts.ts +9 -3
- package/src/semantics/prices.ts +0 -1
- package/src/semantics/products.ts +4 -14
- package/src/semantics/promotion_codes.ts +0 -1
- package/src/semantics/radar.ts +1 -3
- package/src/semantics/refunds.ts +2 -11
- package/src/semantics/shared.ts +350 -1382
- package/src/semantics/states.ts +109 -330
- package/src/semantics/subscriptions.ts +25 -145
- package/src/semantics/test_helpers.ts +109 -43
- package/src/semantics/transfers.ts +1 -3
- package/src/semantics/webhook_endpoints.ts +27 -0
- package/src/server.ts +0 -1
- package/dist/generated/pack-facts.json +0 -94
- package/dist/src/engine/billing.d.ts +0 -5
- package/dist/src/engine/billing.js +0 -6
- package/dist/src/engine/charges.d.ts +0 -6
- package/dist/src/engine/charges.js +0 -13
- package/dist/src/engine/connect-settings.d.ts +0 -16
- package/dist/src/engine/connect-settings.js +0 -26
- package/dist/src/engine/coupons.d.ts +0 -0
- package/dist/src/engine/coupons.js +0 -5
- package/dist/src/engine/credit-notes.d.ts +0 -1
- package/dist/src/engine/credit-notes.js +0 -5
- package/dist/src/engine/disputes.d.ts +0 -0
- package/dist/src/engine/disputes.js +0 -9
- package/dist/src/engine/entitlements.d.ts +0 -1
- package/dist/src/engine/entitlements.js +0 -4
- package/dist/src/engine/ephemeral-keys.d.ts +0 -0
- package/dist/src/engine/ephemeral-keys.js +0 -4
- package/dist/src/engine/front.d.ts +0 -5
- package/dist/src/engine/front.js +0 -25
- package/dist/src/engine/payment-links.d.ts +0 -1
- package/dist/src/engine/payment-links.js +0 -5
- package/dist/src/engine/plans.d.ts +0 -6
- package/dist/src/engine/plans.js +0 -26
- package/dist/src/engine/platform.d.ts +0 -39
- package/dist/src/engine/platform.js +0 -34
- package/dist/src/engine/products.d.ts +0 -0
- package/dist/src/engine/products.js +0 -4
- package/dist/src/engine/setup-intents.d.ts +0 -1
- package/dist/src/engine/setup-intents.js +0 -4
- package/dist/src/engine/subscription-schedules.d.ts +0 -3
- package/dist/src/engine/subscription-schedules.js +0 -1
- package/dist/src/engine/tax.d.ts +0 -7
- package/dist/src/engine/tax.js +0 -28
- package/dist/src/engine/terminal.d.ts +0 -4
- package/dist/src/engine/terminal.js +0 -20
- package/dist/src/engine/test-clocks.d.ts +0 -5
- package/dist/src/engine/test-clocks.js +0 -9
- package/dist/src/engine/tokens.d.ts +0 -7
- package/dist/src/engine/tokens.js +0 -20
- package/dist/src/engine/treasury.d.ts +0 -23
- package/dist/src/engine/treasury.js +0 -45
- package/dist/src/screens/connect-oauth.js +0 -333
- package/dist/src/semantics/disputes.d.ts +0 -2
- package/dist/src/semantics/disputes.js +0 -5
- package/dist/src/semantics/invoiceitems.d.ts +0 -3
- package/dist/src/semantics/invoiceitems.js +0 -59
- package/dist/src/semantics/setup_intents.d.ts +0 -3
- package/dist/src/semantics/setup_intents.js +0 -41
- package/dist/src/semantics/subscription_items.d.ts +0 -5
- package/dist/src/semantics/subscription_items.js +0 -55
- package/dist/src/semantics/subscription_schedules.d.ts +0 -4
- package/dist/src/semantics/subscription_schedules.js +0 -60
- package/src/engine/billing.ts +0 -16
- package/src/engine/charges.ts +0 -19
- package/src/engine/connect-settings.ts +0 -23
- package/src/engine/coupons.ts +0 -5
- package/src/engine/credit-notes.ts +0 -6
- package/src/engine/disputes.ts +0 -9
- package/src/engine/entitlements.ts +0 -5
- package/src/engine/ephemeral-keys.ts +0 -3
- package/src/engine/front.ts +0 -31
- package/src/engine/payment-links.ts +0 -6
- package/src/engine/plans.ts +0 -42
- package/src/engine/platform.ts +0 -47
- package/src/engine/products.ts +0 -3
- package/src/engine/setup-intents.ts +0 -5
- package/src/engine/subscription-schedules.ts +0 -10
- package/src/engine/tax.ts +0 -39
- package/src/engine/terminal.ts +0 -23
- package/src/engine/test-clocks.ts +0 -11
- package/src/engine/tokens.ts +0 -22
- package/src/engine/treasury.ts +0 -47
- package/src/screens/connect-oauth.tsx +0 -376
- package/src/semantics/disputes.ts +0 -12
- package/src/semantics/invoiceitems.ts +0 -59
- package/src/semantics/setup_intents.ts +0 -45
- package/src/semantics/subscription_items.ts +0 -54
- package/src/semantics/subscription_schedules.ts +0 -66
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
// Stripe's accounts operations (docs/contributing/architecture.md, "What an author writes"): each handler over the
|
|
2
2
|
// handler contract's context, computing with the engine (../engine/).
|
|
3
3
|
import type { HandlerContext } from '@volter/world-core';
|
|
4
|
-
import { externalList
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { accountExternal, accountMissing, accountPerson, accountRow, at, connectReview, created, externalMissing, fail, list, newest, path, personMissing, refuseExternalWrite, syncExternals } from './shared.ts';
|
|
9
|
-
|
|
4
|
+
import { externalList } from '../engine/common.ts';
|
|
5
|
+
import { controllerOf, expressRequirements, keptKyc } from '../engine/connect.ts';
|
|
6
|
+
import { ACCOUNT_TYPES, accountCapabilities, accountRequirements, accountSettings, nowUnix } from '../engine/stripe.ts';
|
|
7
|
+
import { accountMissing, accountRow, at, connectReview, created, fail, list, newest } from './shared.ts';
|
|
10
8
|
export async function GetAccountsAccountExternalAccounts(ctx: HandlerContext): Promise<Response> {
|
|
11
9
|
const account = at(ctx, 'account');
|
|
12
10
|
if (!accountRow(ctx, account)) return accountMissing(ctx, account);
|
|
@@ -31,7 +29,7 @@ export async function PostAccounts(ctx: HandlerContext): Promise<Response> {
|
|
|
31
29
|
tos_acceptance: { date: null, ip: null, user_agent: null },
|
|
32
30
|
});
|
|
33
31
|
await connectReview(ctx, String(made.id));
|
|
34
|
-
return ctx.reply(ctx.get('account', String(made.id))!);
|
|
32
|
+
return ctx.reply(ctx.expand('account', ctx.get('account', String(made.id))!));
|
|
35
33
|
}
|
|
36
34
|
|
|
37
35
|
// a single-use Express dashboard link, not stored
|
|
@@ -41,3 +39,6 @@ export async function PostAccountsAccountLoginLinks(ctx: HandlerContext): Promis
|
|
|
41
39
|
return ctx.reply({ object: 'login_link', created: nowUnix(ctx.occurredAt), url: `https://connect.twin.local/express/${id}` });
|
|
42
40
|
}
|
|
43
41
|
|
|
42
|
+
|
|
43
|
+
// source: spec:PostAccountsAccount "left unchanged."
|
|
44
|
+
// source: https://docs.stripe.com/connect/account-capabilities "If a connected account has both card_payments and transfers"
|
package/src/semantics/apps.ts
CHANGED
|
@@ -4,8 +4,7 @@ import type { HandlerContext } from '@volter/world-core';
|
|
|
4
4
|
import { SECRET } from '../engine/apps-secrets.ts';
|
|
5
5
|
import type { Row } from '../engine/common.ts';
|
|
6
6
|
import { nowUnix } from '../engine/stripe.ts';
|
|
7
|
-
import { created, fail,
|
|
8
|
-
|
|
7
|
+
import { created, fail, named, scopeKeyOf } from './shared.ts';
|
|
9
8
|
export async function GetAppsSecretsFind(ctx: HandlerContext): Promise<Response> {
|
|
10
9
|
const name = typeof ctx.params.name === 'string' ? ctx.params.name : '';
|
|
11
10
|
if (!name) return fail(ctx, 'Missing required param: name.', 400, 'parameter_missing');
|
package/src/semantics/around.ts
CHANGED
|
@@ -4,17 +4,14 @@
|
|
|
4
4
|
// refused and the parameters are checked against the operation's; a metadata hash merges; and every answer is rendered
|
|
5
5
|
// in the caller's API version (../engine/front.ts).
|
|
6
6
|
import type { HandlerContext } from '@volter/world-core';
|
|
7
|
-
import {
|
|
8
|
-
|
|
7
|
+
import { platformKeyRefused, publishableKeyRefused, refuseParameters, rendered, withMetadata } from './shared.ts';
|
|
9
8
|
export async function around(ctx: HandlerContext, next: (request?: Request) => Promise<Response>): Promise<Response> {
|
|
10
9
|
const arrived = ctx.call.request;
|
|
11
10
|
const unkeyed = platformKeyRefused(ctx, arrived);
|
|
12
11
|
if (unkeyed) return unkeyed;
|
|
13
|
-
const acting = await actingAsOAuthKey(ctx, arrived.clone());
|
|
14
|
-
if (acting instanceof Response) return acting;
|
|
15
12
|
if (ctx.call.operation.id !== 'unmatched') {
|
|
16
|
-
const refused = publishableKeyRefused(ctx) ??
|
|
13
|
+
const refused = publishableKeyRefused(ctx) ?? refuseParameters(ctx);
|
|
17
14
|
if (refused) return refused;
|
|
18
15
|
}
|
|
19
|
-
return rendered(arrived, await next(withMetadata(ctx,
|
|
16
|
+
return rendered(arrived, await next(withMetadata(ctx, arrived.clone())));
|
|
20
17
|
}
|
package/src/semantics/balance.ts
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
// handler contract's context, computing with the engine (../engine/).
|
|
3
3
|
import type { HandlerContext } from '@volter/world-core';
|
|
4
4
|
import { balanceBody } from './shared.ts';
|
|
5
|
-
|
|
6
5
|
export async function GetBalance(ctx: HandlerContext): Promise<Response> {
|
|
7
6
|
return ctx.reply(balanceBody(ctx));
|
|
8
7
|
}
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
import type { HandlerContext } from '@volter/world-core';
|
|
4
4
|
import { inRange } from '../engine/common.ts';
|
|
5
5
|
import { BT } from '../engine/ledger.ts';
|
|
6
|
-
import {
|
|
7
|
-
|
|
6
|
+
import { commonAsOf, kept, list, mine, newest, where } from './shared.ts';
|
|
8
7
|
export async function GetBalanceTransactions(ctx: HandlerContext): Promise<Response> {
|
|
9
8
|
const own = mine(ctx);
|
|
10
9
|
return list(ctx, BT, where(ctx, newest(ctx, BT).filter((t) => own.has(t.id)).map((t) => commonAsOf(ctx, t)), {
|
|
@@ -17,4 +16,3 @@ export async function GetBalanceTransactions(ctx: HandlerContext): Promise<Respo
|
|
|
17
16
|
created: (t, v) => inRange(t.created, v),
|
|
18
17
|
}));
|
|
19
18
|
}
|
|
20
|
-
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
import type { HandlerContext } from '@volter/world-core';
|
|
4
4
|
import { filled, PBC, PORTAL_FEATURES } from '../engine/files.ts';
|
|
5
5
|
import { asBool, nowUnix } from '../engine/stripe.ts';
|
|
6
|
-
import { actingAccount,
|
|
7
|
-
|
|
6
|
+
import { actingAccount, created, fail, list, newest, where } from './shared.ts';
|
|
8
7
|
export async function GetBillingPortalConfigurations(ctx: HandlerContext): Promise<Response> {
|
|
9
8
|
return list(ctx, PBC, where(ctx, newest(ctx, PBC), {
|
|
10
9
|
active: (c, v) => asBool(c.active) === asBool(v),
|
|
@@ -23,11 +22,6 @@ export async function PostBillingPortalConfigurations(ctx: HandlerContext): Prom
|
|
|
23
22
|
);
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
export async function PostBillingPortalConfigurationsConfiguration(ctx: HandlerContext): Promise<Response> {
|
|
27
|
-
const id = at(ctx, 'configuration');
|
|
28
|
-
if (!ctx.get(PBC, id)) return ctx.notFound(PBC, id);
|
|
29
|
-
return ctx.reply(await ctx.write(PBC, id, mergeUpdate(ctx, PBC, id, { ...ctx.params, updated: nowUnix(ctx.occurredAt) }), 'billing_portal.configuration.update'));
|
|
30
|
-
}
|
|
31
25
|
|
|
32
26
|
// ── the customer portal ──
|
|
33
27
|
|
package/src/semantics/charges.ts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
// Stripe's charges operations (docs/contributing/architecture.md, "What an author writes"): each handler over the
|
|
2
2
|
// handler contract's context, computing with the engine (../engine/).
|
|
3
3
|
import type { HandlerContext } from '@volter/world-core';
|
|
4
|
-
import {
|
|
5
|
-
import type { Row } from '../engine/common.ts';
|
|
6
|
-
import { asBool, chargeDefaults, declineFor, searchOver, validateMoney } from '../engine/stripe.ts';
|
|
7
|
-
import { afterCharge, at, captureAuthorization, chargeBody, chargeMissing, chargeRefund, created, declinedCharge, expanded, fail, finder, fraudReport, list, newest, path, paymentMethodDetails, refundCharge, send, settleCharge, where } from './shared.ts';
|
|
8
|
-
|
|
4
|
+
import { at, chargeBody, chargeMissing, expanded, list, newest, where } from './shared.ts';
|
|
9
5
|
export async function GetCharges(ctx: HandlerContext): Promise<Response> {
|
|
10
6
|
const items = where(ctx, newest(ctx, 'charge'), {
|
|
11
7
|
customer: (c, v) => c.customer === v,
|
|
@@ -18,4 +14,3 @@ export async function GetChargesCharge(ctx: HandlerContext): Promise<Response> {
|
|
|
18
14
|
const c = ctx.get('charge', at(ctx, 'charge'));
|
|
19
15
|
return c ? ctx.reply(expanded(ctx, 'charge', chargeBody(ctx, c))) : chargeMissing(ctx, at(ctx, 'charge'));
|
|
20
16
|
}
|
|
21
|
-
|
|
@@ -6,14 +6,24 @@ import type { Row } from '../engine/common.ts';
|
|
|
6
6
|
import { applyCouponDiscount, lineItemEntries, nowUnix, paginate, resolveLineItem } from '../engine/stripe.ts';
|
|
7
7
|
import { actingAccount, at, checkoutNoDestination, created, discountOf, fail, finder, noLineItems, path, sessionMissing, sessionTrialRefused } from './shared.ts';
|
|
8
8
|
|
|
9
|
+
export async function GetCheckoutSessionsSessionLineItems(ctx: HandlerContext): Promise<Response> {
|
|
10
|
+
const s = ctx.get(CS, at(ctx, 'session'));
|
|
11
|
+
if (!s) return sessionMissing(ctx, at(ctx, 'session'));
|
|
12
|
+
// source: spec:GetCheckoutSessionsSessionLineItems "There is also a URL where you can retrieve the full (paginated) list of line items."
|
|
13
|
+
const li = s.line_items as { data?: Row[] } | undefined;
|
|
14
|
+
const { page, hasMore } = paginate(Array.isArray(li?.data) ? li!.data! : [], ctx.params);
|
|
15
|
+
return ctx.reply({ object: 'list', url: path(ctx), has_more: hasMore, data: page });
|
|
16
|
+
}
|
|
17
|
+
|
|
9
18
|
export async function PostCheckoutSessions(ctx: HandlerContext): Promise<Response> {
|
|
10
19
|
const params = ctx.params;
|
|
11
20
|
const mode = typeof params.mode === 'string' ? params.mode : 'payment';
|
|
12
21
|
if (!['payment', 'subscription', 'setup'].includes(mode)) return fail(ctx, 'Invalid mode: must be one of payment, subscription, or setup.', 400, 'parameter_invalid_string_enum');
|
|
13
22
|
const entries = lineItemEntries(params);
|
|
14
23
|
if (mode !== 'setup' && entries.length === 0) return noLineItems(ctx);
|
|
15
|
-
//
|
|
16
|
-
|
|
24
|
+
// source: spec:/paths/~1v1~1checkout~1sessions/post/requestBody/content/application~1x-www-form-urlencoded/schema/properties/ui_mode "The UI mode of the Session."
|
|
25
|
+
const custom = params.ui_mode === 'custom';
|
|
26
|
+
if (!custom && (params.success_url === undefined || params.success_url === '')) return fail(ctx, 'Missing required param: success_url.', 400, 'parameter_missing');
|
|
17
27
|
const sessionCurrency = typeof params.currency === 'string' ? params.currency : 'usd';
|
|
18
28
|
const resolved = entries.map((e, i) => resolveLineItem(e, i, sessionCurrency, finder(ctx)));
|
|
19
29
|
const missing = resolved.find((r) => r.priceMissing);
|
|
@@ -31,7 +41,10 @@ export async function PostCheckoutSessions(ctx: HandlerContext): Promise<Respons
|
|
|
31
41
|
const fields: Row = {
|
|
32
42
|
mode, status: 'open',
|
|
33
43
|
payment_status: mode === 'setup' ? 'no_payment_required' : 'unpaid',
|
|
34
|
-
|
|
44
|
+
ui_mode: custom ? 'custom' : 'hosted',
|
|
45
|
+
...(custom ? { client_secret: `${id}_secret_${await ctx.secret(`checkout-secret:${id}`)}`, return_url: params.return_url ?? null } : {}),
|
|
46
|
+
allow_promotion_codes: params.allow_promotion_codes === true || params.allow_promotion_codes === 'true',
|
|
47
|
+
url: custom ? null : `https://checkout.stripe.com/c/pay/${id}`, success_url: params.success_url ?? null, cancel_url: params.cancel_url ?? null,
|
|
35
48
|
customer: params.customer ?? null, client_reference_id: params.client_reference_id ?? null,
|
|
36
49
|
customer_email: params.customer_email ?? null,
|
|
37
50
|
// whether paying makes a customer: in payment mode only when asked (`always`), `if_required` by default
|
|
@@ -67,12 +80,3 @@ export async function PostCheckoutSessions(ctx: HandlerContext): Promise<Respons
|
|
|
67
80
|
if (discount) fields._discount = { coupon: String(discount.coupon.id), promotion_code: discount.promotion ?? null };
|
|
68
81
|
return ctx.reply(await created(ctx, CS, { id, ...fields }, {}));
|
|
69
82
|
}
|
|
70
|
-
|
|
71
|
-
export async function PostCheckoutSessionsSessionExpire(ctx: HandlerContext): Promise<Response> {
|
|
72
|
-
const id = at(ctx, 'session');
|
|
73
|
-
const s = ctx.get(CS, id);
|
|
74
|
-
if (!s) return sessionMissing(ctx, id);
|
|
75
|
-
const refused = ctx.legal(CS, 'status', 'PostCheckoutSessionsSessionExpire', s.status, undefined, id);
|
|
76
|
-
if (refused) return ctx.refuse(refused);
|
|
77
|
-
return ctx.reply(await ctx.write(CS, id, { status: 'expired', url: null }, 'checkout.session.expire'));
|
|
78
|
-
}
|
package/src/semantics/clock.ts
CHANGED
|
@@ -2,21 +2,14 @@
|
|
|
2
2
|
// the World's clock before anything is answered, so every door (the API, the hosted pages) reads the account as it
|
|
3
3
|
// stands now. Each move is the engine's.
|
|
4
4
|
import type { HandlerContext } from '@volter/world-core';
|
|
5
|
-
import { advanceBilling, advancePayouts,
|
|
6
|
-
|
|
5
|
+
import { advanceBilling, advancePayouts, lapseCoupons, lapseRealtimeRequests, settleBankDebits, settleHeldRefunds } from './shared.ts';
|
|
7
6
|
export async function clock(ctx: HandlerContext): Promise<void> {
|
|
8
|
-
// a test clock advanced by the last request has reached its time
|
|
9
|
-
await finishClockAdvances(ctx);
|
|
10
7
|
// a subscription renews at its period's end, its renewal charged an hour later
|
|
11
8
|
await advanceBilling(ctx);
|
|
12
9
|
// a submitted bank debit settles (in test mode at once)
|
|
13
10
|
await settleBankDebits(ctx);
|
|
14
11
|
// a coupon past its redeem_by is no longer valid
|
|
15
12
|
await lapseCoupons(ctx);
|
|
16
|
-
// a top-up's funds arrive five days after it is made
|
|
17
|
-
await settleTopups(ctx);
|
|
18
|
-
// a report run completes
|
|
19
|
-
await finishReportRuns(ctx);
|
|
20
13
|
// a real-time authorization request no one answered is decided when its window ends
|
|
21
14
|
await lapseRealtimeRequests(ctx);
|
|
22
15
|
// a refund held for want of balance is made when funds cover it, before any payout takes them
|
package/src/semantics/coupons.ts
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
// handler contract's context, computing with the engine (../engine/).
|
|
3
3
|
import type { HandlerContext } from '@volter/world-core';
|
|
4
4
|
import { amountOffOf, created, fail } from './shared.ts';
|
|
5
|
-
|
|
6
5
|
export async function PostCoupons(ctx: HandlerContext): Promise<Response> {
|
|
7
6
|
const params = ctx.params;
|
|
8
7
|
const hasPct = params.percent_off !== undefined;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
// Stripe's customers operations (docs/contributing/architecture.md, "What an author writes"): each handler over the
|
|
2
2
|
// handler contract's context, computing with the engine (../engine/).
|
|
3
3
|
import type { HandlerContext } from '@volter/world-core';
|
|
4
|
-
import { deletedDiscount, type Row } from '../engine/common.ts';
|
|
5
4
|
import { newCustomer } from '../engine/customers.ts';
|
|
6
5
|
import { nowUnix } from '../engine/stripe.ts';
|
|
7
|
-
import { at, attachable, attachPaymentMethod,
|
|
8
|
-
|
|
6
|
+
import { at, attachable, attachPaymentMethod, created, customerMissing, expanded, fail, search } from './shared.ts';
|
|
9
7
|
// "If it’s for a deleted Customer, a subset of the customer’s information is returned, including a `deleted` property
|
|
10
8
|
// that’s set to true" (docs.stripe.com/api/customers/retrieve)
|
|
11
9
|
export async function GetCustomersCustomer(ctx: HandlerContext): Promise<Response> {
|
|
@@ -16,23 +14,11 @@ export async function GetCustomersCustomer(ctx: HandlerContext): Promise<Respons
|
|
|
16
14
|
return ctx.reply(expanded(ctx, 'customer', ctx.get('customer', id)!));
|
|
17
15
|
}
|
|
18
16
|
|
|
19
|
-
// the payment methods attached to a customer (customers.listPaymentMethods), optionally by `type`
|
|
20
|
-
export async function GetCustomersCustomerPaymentMethods(ctx: HandlerContext): Promise<Response> {
|
|
21
|
-
const customer = at(ctx, 'customer');
|
|
22
|
-
if (!ctx.get('customer', customer)) return customerMissing(ctx, customer);
|
|
23
|
-
const items = where(ctx, newest(ctx, 'payment_method').filter((m) => m.customer === customer), { type: (m, v) => m.type === v });
|
|
24
|
-
return list(ctx, 'payment_method', items);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
17
|
export async function GetCustomersSearch(ctx: HandlerContext): Promise<Response> {
|
|
28
18
|
return search(ctx, 'customer');
|
|
29
19
|
}
|
|
30
20
|
|
|
31
21
|
export async function PostCustomers(ctx: HandlerContext): Promise<Response> {
|
|
32
|
-
// a `coupon` on create materializes the discount object on the customer (the coupon must exist)
|
|
33
|
-
const couponId = typeof ctx.params.coupon === 'string' ? ctx.params.coupon : '';
|
|
34
|
-
const discount = couponId ? customerDiscount(ctx, couponId) : null;
|
|
35
|
-
if (discount instanceof Response) return discount;
|
|
36
22
|
// `payment_method` attaches that method to the new customer; it is not a field of the customer
|
|
37
23
|
// (docs.stripe.com/api/customers/create#create_customer-payment_method)
|
|
38
24
|
const pmId = typeof ctx.params.payment_method === 'string' ? ctx.params.payment_method : '';
|
|
@@ -40,30 +26,41 @@ export async function PostCustomers(ctx: HandlerContext): Promise<Response> {
|
|
|
40
26
|
const given = ctx.params;
|
|
41
27
|
const { coupon: _c, payment_method: _pm, ...rest } = given;
|
|
42
28
|
const id = ctx.mint('customer');
|
|
43
|
-
const customer = await created(ctx, 'customer', { ...rest, id }, { livemode: false, discount:
|
|
44
|
-
|
|
29
|
+
const customer = await created(ctx, 'customer', { ...rest, id }, { livemode: false, discount: null, ...newCustomer(id) });
|
|
30
|
+
// source: https://docs.stripe.com/billing/customer/balance "Represents the starting value of the customer invoice balance when a customer is created using the API with a non-zero invoice balance."
|
|
31
|
+
if (Number(customer.balance ?? 0) !== 0) {
|
|
32
|
+
await created(ctx, 'customer_balance_transaction', {
|
|
33
|
+
customer: id, amount: Number(customer.balance), ending_balance: Number(customer.balance),
|
|
34
|
+
currency: customer.currency ?? 'usd', type: 'initial', description: null, metadata: {},
|
|
35
|
+
livemode: false, invoice: null, credit_note: null, checkout_session: null, customer_account: null,
|
|
36
|
+
}, {});
|
|
37
|
+
}
|
|
45
38
|
if (pmId) await attachPaymentMethod(ctx, pmId, String(customer.id));
|
|
46
39
|
return ctx.reply(customer);
|
|
47
40
|
}
|
|
48
41
|
|
|
49
42
|
// ── the credit-balance ledger: a negative amount is a credit; `ending_balance` is the running sum,
|
|
50
43
|
// mirrored onto the customer's `balance` ──
|
|
51
|
-
export async function PostCustomersCustomerBalanceTransactions(ctx: HandlerContext): Promise<Response> {
|
|
52
|
-
const customer = at(ctx, 'customer');
|
|
53
|
-
if (!ctx.get('customer', customer)) return customerMissing(ctx, customer);
|
|
54
|
-
const params = ctx.params;
|
|
55
|
-
if (params.amount === undefined) return fail(ctx, 'Missing required param: amount.', 400, 'parameter_missing');
|
|
56
|
-
const amount = Number(params.amount);
|
|
57
|
-
if (!Number.isInteger(amount)) return fail(ctx, 'Invalid integer: amount.', 400, 'parameter_invalid_integer');
|
|
58
|
-
if (params.currency === undefined || params.currency === '') return fail(ctx, 'Missing required param: currency.', 400, 'parameter_missing');
|
|
59
|
-
const prior = ctx.rows('customer_balance_transaction').filter((t) => t.customer === customer).reduce((s, t) => s + (Number(t.amount) || 0), 0);
|
|
60
|
-
const ending = prior + amount;
|
|
61
|
-
const body = await created(ctx, 'customer_balance_transaction', { ...params, customer, amount }, {
|
|
62
|
-
ending_balance: ending, type: 'adjustment', livemode: false, metadata: {},
|
|
63
|
-
description: params.description ?? null, credit_note: null, invoice: null, checkout_session: null,
|
|
64
|
-
});
|
|
65
|
-
// keyed by the new transaction so two adjustments at one instant are two writes, the last winning
|
|
66
|
-
await ctx.write('customer', customer, { balance: ending }, `customer.balance_adjusted:${String(body.id)}`);
|
|
67
|
-
return ctx.reply(body);
|
|
68
|
-
}
|
|
69
44
|
|
|
45
|
+
|
|
46
|
+
// source: spec:PostCustomersCustomer "Updates the specified customer by setting the values of the parameters passed."
|
|
47
|
+
export async function PostCustomersCustomer(ctx: HandlerContext): Promise<Response> {
|
|
48
|
+
const id = at(ctx, 'customer');
|
|
49
|
+
const customer = ctx.get('customer', id);
|
|
50
|
+
if (!customer) return customerMissing(ctx, id);
|
|
51
|
+
const { customer: _pathCustomer, ...fields } = ctx.params;
|
|
52
|
+
// source: https://docs.stripe.com/billing/customer/balance "All modifications to the invoice balance are recorded as Transactions"
|
|
53
|
+
// source: https://docs.stripe.com/billing/customer/balance "All Transactions created with the API or in the Dashboard have a type value of adjustment"
|
|
54
|
+
if (typeof fields.balance === 'number' && fields.balance !== Number(customer.balance ?? 0)) {
|
|
55
|
+
const balance = fields.balance;
|
|
56
|
+
await created(ctx, 'customer_balance_transaction', {
|
|
57
|
+
customer: id, amount: balance - Number(customer.balance ?? 0), ending_balance: balance,
|
|
58
|
+
// Stripe inherits the customer's billing currency. Where no invoice has set it, this World's invoice currency is USD.
|
|
59
|
+
currency: customer.currency ?? 'usd', type: 'adjustment',
|
|
60
|
+
description: null, metadata: {}, livemode: false,
|
|
61
|
+
invoice: null, credit_note: null, checkout_session: null, customer_account: null,
|
|
62
|
+
created: nowUnix(ctx.occurredAt),
|
|
63
|
+
}, {});
|
|
64
|
+
}
|
|
65
|
+
return ctx.reply(ctx.expand('customer', await ctx.write('customer', id, fields, 'customer.update')));
|
|
66
|
+
}
|
package/src/semantics/doors.ts
CHANGED
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
import type { HandlerContext } from '@volter/world-core';
|
|
3
3
|
import type { Row } from '../engine/common.ts';
|
|
4
4
|
import { platformAccountDefault } from '../engine/connect.ts';
|
|
5
|
-
import { accountSettings,
|
|
6
|
-
import {
|
|
7
|
-
|
|
5
|
+
import { accountSettings, PLATFORM_ACCOUNT_ID } from '../engine/stripe.ts';
|
|
6
|
+
import { balanceBody, payDuePayouts, settleDueEntries } from './shared.ts';
|
|
8
7
|
/** The platform's own account settings (its payout schedule, its public name) change on Stripe's Dashboard, which has no
|
|
9
8
|
* API: this stands in for that page. The account is Stripe's default until the page first changes it (the same default
|
|
10
9
|
* GET /v1/account answers); a hash is merged into what the account holds, as an update merges it. */
|
|
@@ -1,47 +1,3 @@
|
|
|
1
1
|
// Stripe's entitlements operations (docs/contributing/architecture.md, "What an author writes"): each handler over the
|
|
2
2
|
// handler contract's context, computing with the engine (../engine/).
|
|
3
|
-
|
|
4
|
-
import type { Row } from '../engine/common.ts';
|
|
5
|
-
import { FEAT } from '../engine/entitlements.ts';
|
|
6
|
-
import { asBool, subscriptionItemPairs } from '../engine/stripe.ts';
|
|
7
|
-
import { at, created, fail, kept, list, lookupKeyTaken, newest, path, where } from './shared.ts';
|
|
8
|
-
|
|
9
|
-
// a customer is entitled to every feature granted to a product its live subscriptions bill, as the product stood when
|
|
10
|
-
// the subscription's current period began: "When a customer purchases or subscribes to a product with an attached
|
|
11
|
-
// feature, Stripe creates and manages an Active Entitlement for that customer and feature"; "Existing subscriptions will
|
|
12
|
-
// create active entitlements for any product feature changes at the start of the next billing period"
|
|
13
|
-
// (docs.stripe.com/billing/entitlements). Where the documentation stops and the twin decides: a feature removed from a
|
|
14
|
-
// product is kept, the same way, until the next period begins.
|
|
15
|
-
export async function GetEntitlementsActiveEntitlements(ctx: HandlerContext): Promise<Response> {
|
|
16
|
-
const customer = typeof ctx.params.customer === 'string' ? ctx.params.customer : '';
|
|
17
|
-
if (!customer) return fail(ctx, 'Missing required param: customer.', 400, 'parameter_missing');
|
|
18
|
-
if (!ctx.row('customer', customer, { withDeleted: true })) return fail(ctx, `No such customer: '${customer}'`, 404, 'resource_missing');
|
|
19
|
-
// each product a live subscription bills, with the start of the period it is billed for
|
|
20
|
-
const productIds = new Map<string, number>();
|
|
21
|
-
for (const sub of newest(ctx, 'subscription')) {
|
|
22
|
-
// a subscription entitles while it runs: not before its first payment (incomplete), nor once it has ended
|
|
23
|
-
// (docs.stripe.com/billing/entitlements; past_due keeps access during retries — that edge is the twin's reading)
|
|
24
|
-
if (sub.customer !== customer || !['active', 'trialing', 'past_due'].includes(String(sub.status))) continue;
|
|
25
|
-
const periodStart = Number(sub.current_period_start ?? sub.start_date ?? sub.created ?? 0);
|
|
26
|
-
for (const it of subscriptionItemPairs(sub)) {
|
|
27
|
-
const price = ctx.get('price', it.price);
|
|
28
|
-
if (price && typeof price.product === 'string') productIds.set(price.product, Math.max(productIds.get(price.product) ?? -Infinity, periodStart));
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
const seen = new Set<string>();
|
|
32
|
-
const data: Row[] = [];
|
|
33
|
-
for (const pf of ctx.rowsRaw('product_feature', { withDeleted: true })) {
|
|
34
|
-
const periodStart = productIds.get(String(pf._product));
|
|
35
|
-
if (periodStart === undefined) continue;
|
|
36
|
-
// attached by the period's start, and not removed before it
|
|
37
|
-
if (Number(pf._created ?? 0) > periodStart) continue;
|
|
38
|
-
if (pf.deleted && !(Number(pf._removed_at) > periodStart)) continue;
|
|
39
|
-
const featId = String(pf._feature ?? (pf.entitlement_feature as Row | undefined)?.id ?? pf.entitlement_feature);
|
|
40
|
-
if (seen.has(featId)) continue;
|
|
41
|
-
seen.add(featId);
|
|
42
|
-
const feat = ctx.get(FEAT, featId);
|
|
43
|
-
if (feat) data.push({ id: `ent_twin_${customer}_${featId}`, object: 'entitlements.active_entitlement', feature: featId, lookup_key: feat.lookup_key, livemode: false });
|
|
44
|
-
}
|
|
45
|
-
return ctx.reply({ object: 'list', url: path(ctx), has_more: false, data });
|
|
46
|
-
}
|
|
47
|
-
|
|
3
|
+
// source: spec:PostEntitlementsFeatures "Creates a feature"
|
package/src/semantics/events.ts
CHANGED
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
// Stripe's Events API (the events family: the account's stored events, which the kernel keeps as each is sent), and how
|
|
2
2
|
// Stripe renders the events its writes send (`data` and `values`, bound in the manifest's `events`).
|
|
3
|
-
import type { EventWrite,
|
|
4
|
-
import {
|
|
5
|
-
import { planOf } from '../engine/plans.ts';
|
|
6
|
-
import { embedIssuingAuthorizationCard, isValidApiVersion, PLATFORM_ACCOUNT_ID, TWIN_API_VERSION } from '../engine/stripe.ts';
|
|
3
|
+
import type { EventWrite, WriteHookContext } from '@volter/world-core';
|
|
4
|
+
import { isValidApiVersion, PLATFORM_ACCOUNT_ID, TWIN_API_VERSION } from '../engine/stripe.ts';
|
|
7
5
|
import { render } from '../engine/version.ts';
|
|
8
|
-
import { at, connectionRevoked, finder, list, newest, ownEvent, where } from './shared.ts';
|
|
9
|
-
|
|
10
6
|
// ── the events Stripe's writes send (the manifest's `events`: ./shared.ts STRIPE_EVENTS) ──
|
|
11
7
|
|
|
12
|
-
/** An event's `data`: the object the write concerns, as Stripe sends it in the event's API version.
|
|
13
|
-
*
|
|
14
|
-
* the balance notice the drain writes carries the account's Balance. */
|
|
8
|
+
/** An event's `data`: the object the write concerns, as Stripe sends it in the event's API version. An Issuing
|
|
9
|
+
* authorization carries its full card; the balance notice the drain writes carries the account's Balance. */
|
|
15
10
|
export function data(ctx: WriteHookContext, write: EventWrite): Record<string, unknown> {
|
|
16
11
|
const object = write.storedType === '_balance_notice' ? (write.body.balance as Record<string, unknown>)
|
|
17
|
-
: write.storedType === '
|
|
18
|
-
: write.storedType === '
|
|
19
|
-
: write.body;
|
|
12
|
+
: write.storedType === 'issuing_authorization' ? ctx.expand('issuing.authorization', write.body)
|
|
13
|
+
: write.storedType === 'issuing_card' ? ctx.expand('issuing.card', write.body) : ctx.expand(String(write.body.object ?? write.storedType), write.body);
|
|
20
14
|
return { object: render(object, eventVersion(write)) as Record<string, unknown> };
|
|
21
15
|
}
|
|
22
16
|
|
|
@@ -33,8 +27,7 @@ export function values(ctx: WriteHookContext, write: EventWrite, type: string):
|
|
|
33
27
|
?? (write.storedType === 'account' && typeof id === 'string' && id !== PLATFORM_ACCOUNT_ID ? id : undefined)
|
|
34
28
|
?? (write.storedType === '_balance_notice' && typeof write.body.account === 'string' ? write.body.account : undefined)
|
|
35
29
|
?? (typeof kept === 'string' ? kept : undefined);
|
|
36
|
-
|
|
37
|
-
return { $account: account, $version: eventVersion(write), ...(withheld ? { $send: false } : {}) };
|
|
30
|
+
return { $account: account, $version: eventVersion(write) };
|
|
38
31
|
}
|
|
39
32
|
|
|
40
33
|
/** The API version an event is rendered in: the one the writing request pinned, when it is one, else the served one. */
|
package/src/semantics/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// GENERATED by scripts/create-pack.ts --index: the handler map, by operationId, from the families' files (each
|
|
2
2
|
// handler named as its operation). Do not edit; add a handler to its family's file and generate again.
|
|
3
3
|
import type { Handler } from '@volter/world-core';
|
|
4
|
+
import * as account from './account.ts';
|
|
4
5
|
import * as account_links from './account_links.ts';
|
|
5
6
|
import * as accounts from './accounts.ts';
|
|
6
7
|
import * as apps from './apps.ts';
|
|
@@ -11,11 +12,9 @@ import * as charges from './charges.ts';
|
|
|
11
12
|
import * as checkout from './checkout.ts';
|
|
12
13
|
import * as coupons from './coupons.ts';
|
|
13
14
|
import * as customers from './customers.ts';
|
|
14
|
-
import * as disputes from './disputes.ts';
|
|
15
|
-
import * as entitlements from './entitlements.ts';
|
|
16
15
|
import * as invoice_payments from './invoice_payments.ts';
|
|
17
|
-
import * as invoiceitems from './invoiceitems.ts';
|
|
18
16
|
import * as invoices from './invoices.ts';
|
|
17
|
+
import * as issuing from './issuing.ts';
|
|
19
18
|
import * as payment_intents from './payment_intents.ts';
|
|
20
19
|
import * as payment_methods from './payment_methods.ts';
|
|
21
20
|
import * as payouts from './payouts.ts';
|
|
@@ -24,20 +23,15 @@ import * as products from './products.ts';
|
|
|
24
23
|
import * as promotion_codes from './promotion_codes.ts';
|
|
25
24
|
import * as radar from './radar.ts';
|
|
26
25
|
import * as refunds from './refunds.ts';
|
|
27
|
-
import * as setup_intents from './setup_intents.ts';
|
|
28
|
-
import * as subscription_items from './subscription_items.ts';
|
|
29
|
-
import * as subscription_schedules from './subscription_schedules.ts';
|
|
30
26
|
import * as subscriptions from './subscriptions.ts';
|
|
31
27
|
import * as test_helpers from './test_helpers.ts';
|
|
32
28
|
import * as transfers from './transfers.ts';
|
|
29
|
+
import * as webhook_endpoints from './webhook_endpoints.ts';
|
|
33
30
|
|
|
34
31
|
export const stripeSemantics: Record<string, Handler> = {
|
|
35
|
-
DeleteInvoiceitemsInvoiceitem: invoiceitems.DeleteInvoiceitemsInvoiceitem,
|
|
36
|
-
DeleteInvoicesInvoice: invoices.DeleteInvoicesInvoice,
|
|
37
|
-
DeleteProductsId: products.DeleteProductsId,
|
|
38
|
-
DeleteSubscriptionItemsItem: subscription_items.DeleteSubscriptionItemsItem,
|
|
39
32
|
DeleteSubscriptionsSubscriptionExposedId: subscriptions.DeleteSubscriptionsSubscriptionExposedId,
|
|
40
|
-
|
|
33
|
+
DeleteSubscriptionsSubscriptionExposedIdDiscount: subscriptions.DeleteSubscriptionsSubscriptionExposedIdDiscount,
|
|
34
|
+
GetAccount: account.GetAccount,
|
|
41
35
|
GetAccountsAccountExternalAccounts: accounts.GetAccountsAccountExternalAccounts,
|
|
42
36
|
GetAppsSecretsFind: apps.GetAppsSecretsFind,
|
|
43
37
|
GetBalance: balance.GetBalance,
|
|
@@ -45,25 +39,19 @@ export const stripeSemantics: Record<string, Handler> = {
|
|
|
45
39
|
GetBillingPortalConfigurations: billing_portal.GetBillingPortalConfigurations,
|
|
46
40
|
GetCharges: charges.GetCharges,
|
|
47
41
|
GetChargesCharge: charges.GetChargesCharge,
|
|
42
|
+
GetCheckoutSessionsSessionLineItems: checkout.GetCheckoutSessionsSessionLineItems,
|
|
48
43
|
GetCustomersCustomer: customers.GetCustomersCustomer,
|
|
49
|
-
GetCustomersCustomerPaymentMethods: customers.GetCustomersCustomerPaymentMethods,
|
|
50
44
|
GetCustomersSearch: customers.GetCustomersSearch,
|
|
51
|
-
GetDisputesDispute: disputes.GetDisputesDispute,
|
|
52
|
-
GetEntitlementsActiveEntitlements: entitlements.GetEntitlementsActiveEntitlements,
|
|
53
45
|
GetInvoicePayments: invoice_payments.GetInvoicePayments,
|
|
54
46
|
GetInvoicesInvoice: invoices.GetInvoicesInvoice,
|
|
55
|
-
|
|
47
|
+
GetIssuingCardsCard: issuing.GetIssuingCardsCard,
|
|
56
48
|
GetPaymentMethodsPaymentMethod: payment_methods.GetPaymentMethodsPaymentMethod,
|
|
49
|
+
GetPayouts: payouts.GetPayouts,
|
|
57
50
|
GetPrices: prices.GetPrices,
|
|
58
51
|
GetPricesPrice: prices.GetPricesPrice,
|
|
59
52
|
GetProducts: products.GetProducts,
|
|
60
|
-
GetProductsSearch: products.GetProductsSearch,
|
|
61
53
|
GetPromotionCodes: promotion_codes.GetPromotionCodes,
|
|
62
|
-
GetRefundsRefund: refunds.GetRefundsRefund,
|
|
63
|
-
GetSubscriptionItemsItem: subscription_items.GetSubscriptionItemsItem,
|
|
64
|
-
GetSubscriptionSchedulesSchedule: subscription_schedules.GetSubscriptionSchedulesSchedule,
|
|
65
54
|
GetSubscriptions: subscriptions.GetSubscriptions,
|
|
66
|
-
GetSubscriptionsSearch: subscriptions.GetSubscriptionsSearch,
|
|
67
55
|
GetSubscriptionsSubscriptionExposedId: subscriptions.GetSubscriptionsSubscriptionExposedId,
|
|
68
56
|
PostAccountLinks: account_links.PostAccountLinks,
|
|
69
57
|
PostAccounts: accounts.PostAccounts,
|
|
@@ -71,25 +59,21 @@ export const stripeSemantics: Record<string, Handler> = {
|
|
|
71
59
|
PostAppsSecrets: apps.PostAppsSecrets,
|
|
72
60
|
PostAppsSecretsDelete: apps.PostAppsSecretsDelete,
|
|
73
61
|
PostBillingPortalConfigurations: billing_portal.PostBillingPortalConfigurations,
|
|
74
|
-
PostBillingPortalConfigurationsConfiguration: billing_portal.PostBillingPortalConfigurationsConfiguration,
|
|
75
62
|
PostBillingPortalSessions: billing_portal.PostBillingPortalSessions,
|
|
76
63
|
PostCheckoutSessions: checkout.PostCheckoutSessions,
|
|
77
|
-
PostCheckoutSessionsSessionExpire: checkout.PostCheckoutSessionsSessionExpire,
|
|
78
64
|
PostCoupons: coupons.PostCoupons,
|
|
79
65
|
PostCustomers: customers.PostCustomers,
|
|
80
|
-
|
|
81
|
-
PostInvoiceitems: invoiceitems.PostInvoiceitems,
|
|
66
|
+
PostCustomersCustomer: customers.PostCustomersCustomer,
|
|
82
67
|
PostInvoices: invoices.PostInvoices,
|
|
83
68
|
PostInvoicesCreatePreview: invoices.PostInvoicesCreatePreview,
|
|
84
|
-
PostInvoicesInvoiceFinalize: invoices.PostInvoicesInvoiceFinalize,
|
|
85
69
|
PostInvoicesInvoicePay: invoices.PostInvoicesInvoicePay,
|
|
86
|
-
PostInvoicesInvoiceSend: invoices.PostInvoicesInvoiceSend,
|
|
87
70
|
PostInvoicesInvoiceVoid: invoices.PostInvoicesInvoiceVoid,
|
|
71
|
+
PostIssuingAuthorizationsAuthorizationApprove: issuing.PostIssuingAuthorizationsAuthorizationApprove,
|
|
72
|
+
PostIssuingAuthorizationsAuthorizationDecline: issuing.PostIssuingAuthorizationsAuthorizationDecline,
|
|
73
|
+
PostIssuingCards: issuing.PostIssuingCards,
|
|
74
|
+
PostIssuingCardsCard: issuing.PostIssuingCardsCard,
|
|
88
75
|
PostPaymentIntents: payment_intents.PostPaymentIntents,
|
|
89
76
|
PostPaymentIntentsIntentCancel: payment_intents.PostPaymentIntentsIntentCancel,
|
|
90
|
-
PostPaymentIntentsIntentConfirm: payment_intents.PostPaymentIntentsIntentConfirm,
|
|
91
|
-
PostPaymentMethods: payment_methods.PostPaymentMethods,
|
|
92
|
-
PostPaymentMethodsPaymentMethodAttach: payment_methods.PostPaymentMethodsPaymentMethodAttach,
|
|
93
77
|
PostPaymentMethodsPaymentMethodDetach: payment_methods.PostPaymentMethodsPaymentMethodDetach,
|
|
94
78
|
PostPayouts: payouts.PostPayouts,
|
|
95
79
|
PostPrices: prices.PostPrices,
|
|
@@ -97,15 +81,9 @@ export const stripeSemantics: Record<string, Handler> = {
|
|
|
97
81
|
PostPromotionCodes: promotion_codes.PostPromotionCodes,
|
|
98
82
|
PostRadarValueListItems: radar.PostRadarValueListItems,
|
|
99
83
|
PostRefunds: refunds.PostRefunds,
|
|
100
|
-
PostSetupIntents: setup_intents.PostSetupIntents,
|
|
101
|
-
PostSetupIntentsIntentConfirm: setup_intents.PostSetupIntentsIntentConfirm,
|
|
102
|
-
PostSubscriptionItems: subscription_items.PostSubscriptionItems,
|
|
103
|
-
PostSubscriptionItemsItem: subscription_items.PostSubscriptionItemsItem,
|
|
104
|
-
PostSubscriptionSchedules: subscription_schedules.PostSubscriptionSchedules,
|
|
105
|
-
PostSubscriptionSchedulesScheduleRelease: subscription_schedules.PostSubscriptionSchedulesScheduleRelease,
|
|
106
|
-
PostSubscriptions: subscriptions.PostSubscriptions,
|
|
107
84
|
PostSubscriptionsSubscriptionExposedId: subscriptions.PostSubscriptionsSubscriptionExposedId,
|
|
108
|
-
|
|
109
|
-
|
|
85
|
+
PostTestHelpersIssuingAuthorizations: test_helpers.PostTestHelpersIssuingAuthorizations,
|
|
86
|
+
PostTestHelpersIssuingAuthorizationsAuthorizationCapture: test_helpers.PostTestHelpersIssuingAuthorizationsAuthorizationCapture,
|
|
110
87
|
PostTransfers: transfers.PostTransfers,
|
|
88
|
+
PostWebhookEndpoints: webhook_endpoints.PostWebhookEndpoints,
|
|
111
89
|
};
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
import type { HandlerContext } from '@volter/world-core';
|
|
4
4
|
import type { Row } from '../engine/common.ts';
|
|
5
5
|
import { INV, invoicePayment } from '../engine/invoices.ts';
|
|
6
|
-
import {
|
|
7
|
-
|
|
6
|
+
import { list, newest } from './shared.ts';
|
|
8
7
|
export async function GetInvoicePayments(ctx: HandlerContext): Promise<Response> {
|
|
9
8
|
const p = ctx.params;
|
|
10
9
|
const wanted = (p.payment as Row | undefined)?.payment_intent;
|
|
@@ -15,4 +14,3 @@ export async function GetInvoicePayments(ctx: HandlerContext): Promise<Response>
|
|
|
15
14
|
.filter((x) => typeof p.status !== 'string' || x.status === p.status);
|
|
16
15
|
return list(ctx, 'invoice_payment', items);
|
|
17
16
|
}
|
|
18
|
-
|