@volter/twin-stripe 3.0.0 → 3.0.1
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 +51 -21
- package/dist/generated/pack-facts.json +3 -3
- 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 +52 -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 +4 -3
- 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 +53 -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/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,5 +0,0 @@
|
|
|
1
|
-
// Payment Link and Quote semantics. Both carry line items resolved from existing prices. A payment
|
|
2
|
-
// link is a reusable hosted-checkout URL, active until switched off; a quote moves draft → open
|
|
3
|
-
// (finalize) → accepted or canceled, the machine in ../manifest.ts. Link retrieve and update
|
|
4
|
-
// (`active`, its machine), quote retrieve and the quote list are the derived core's.
|
|
5
|
-
export const PL = 'payment_link';
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { Row } from './common.js';
|
|
2
|
-
export declare const INTERVALS: Set<string>;
|
|
3
|
-
/** A recurring price in the plan object's shape (the create page's example response). */
|
|
4
|
-
export declare function planOf(price: Row): Row;
|
|
5
|
-
/** Metadata after an update: an empty value unsets the key, an empty `metadata` unsets them all. */
|
|
6
|
-
export declare function metadataAfter(was: Row, given: unknown): Row;
|
package/dist/src/engine/plans.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export const INTERVALS = new Set(['day', 'week', 'month', 'year']);
|
|
2
|
-
/** A recurring price in the plan object's shape (the create page's example response). */
|
|
3
|
-
export function planOf(price) {
|
|
4
|
-
const r = (price.recurring ?? {});
|
|
5
|
-
const amount = typeof price.unit_amount === 'number' ? price.unit_amount : null;
|
|
6
|
-
const decimal = typeof price.unit_amount_decimal === 'string' ? price.unit_amount_decimal : amount === null ? null : String(amount);
|
|
7
|
-
return {
|
|
8
|
-
id: price.id, object: 'plan', active: price.active ?? true, amount, amount_decimal: decimal,
|
|
9
|
-
billing_scheme: price.billing_scheme ?? 'per_unit', created: price.created, currency: price.currency, interval: r.interval ?? null,
|
|
10
|
-
interval_count: r.interval_count ?? 1, livemode: false, metadata: price.metadata ?? {}, meter: r.meter ?? null, nickname: price.nickname ?? null,
|
|
11
|
-
product: price.product, tiers_mode: price.tiers_mode ?? null, transform_usage: price.transform_quantity ?? null,
|
|
12
|
-
trial_period_days: r.trial_period_days ?? null, usage_type: r.usage_type ?? 'licensed',
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
/** Metadata after an update: an empty value unsets the key, an empty `metadata` unsets them all. */
|
|
16
|
-
export function metadataAfter(was, given) {
|
|
17
|
-
if (given === '' || given === null || typeof given !== 'object')
|
|
18
|
-
return {};
|
|
19
|
-
const next = { ...was };
|
|
20
|
-
for (const [k, v] of Object.entries(given))
|
|
21
|
-
if (v === '' || v === null)
|
|
22
|
-
delete next[k];
|
|
23
|
-
else
|
|
24
|
-
next[k] = v;
|
|
25
|
-
return next;
|
|
26
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { Row } from './common.js';
|
|
2
|
-
export declare const CLIMATE_SUPPLIERS: readonly [{
|
|
3
|
-
readonly id: "climsup_charm_industrial";
|
|
4
|
-
readonly name: "Charm Industrial";
|
|
5
|
-
readonly removal_pathway: "biomass_carbon_removal_and_storage";
|
|
6
|
-
readonly info_url: "https://frontierclimate.com/portfolio/charm-industrial";
|
|
7
|
-
readonly locations: readonly [{
|
|
8
|
-
readonly city: "San Francisco";
|
|
9
|
-
readonly country: "US";
|
|
10
|
-
readonly latitude: 37.7749;
|
|
11
|
-
readonly longitude: -122.4194;
|
|
12
|
-
readonly region: "CA";
|
|
13
|
-
}];
|
|
14
|
-
}];
|
|
15
|
-
export declare const CLIMATE_PRODUCTS: readonly [{
|
|
16
|
-
readonly id: "climsku_frontier_offtake_portfolio_2027";
|
|
17
|
-
readonly name: "Frontier's 2027 offtake portfolio";
|
|
18
|
-
readonly subtotal: 55000;
|
|
19
|
-
readonly fees: 1650;
|
|
20
|
-
readonly currency: "usd";
|
|
21
|
-
readonly delivery_year: 2027;
|
|
22
|
-
readonly metric_tons_available: "18000";
|
|
23
|
-
readonly created: 1881439203;
|
|
24
|
-
readonly suppliers: readonly ["climsup_charm_industrial"];
|
|
25
|
-
}];
|
|
26
|
-
export declare const supplierView: (s: (typeof CLIMATE_SUPPLIERS)[number]) => Row;
|
|
27
|
-
export declare const productView: (p: (typeof CLIMATE_PRODUCTS)[number]) => Row;
|
|
28
|
-
export declare const ORDER = "climate.order";
|
|
29
|
-
export declare const FCS = "financial_connections.session";
|
|
30
|
-
export declare const FCA = "financial_connections.account";
|
|
31
|
-
export declare const FCT = "financial_connections.transaction";
|
|
32
|
-
export declare const REPORT_TYPES: Array<{
|
|
33
|
-
id: string;
|
|
34
|
-
name: string;
|
|
35
|
-
}>;
|
|
36
|
-
export declare const reportTypeView: (t: {
|
|
37
|
-
id: string;
|
|
38
|
-
name: string;
|
|
39
|
-
}) => Row;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// ── Climate: Stripe's catalog is managed and account-independent. The twin serves the catalog Stripe's reference
|
|
2
|
-
// publishes (docs.stripe.com/api/climate/product/object, /api/climate/supplier/object): Frontier's 2027 offtake
|
|
3
|
-
// portfolio at $550 a ton plus Frontier's service fees of $16.50 (3%), 18,000 tons, from Charm Industrial.
|
|
4
|
-
// Where the documentation stops and the twin decides: the catalog is that one product and supplier. ──
|
|
5
|
-
export const CLIMATE_SUPPLIERS = [
|
|
6
|
-
{ id: 'climsup_charm_industrial', name: 'Charm Industrial', removal_pathway: 'biomass_carbon_removal_and_storage', info_url: 'https://frontierclimate.com/portfolio/charm-industrial', locations: [{ city: 'San Francisco', country: 'US', latitude: 37.7749, longitude: -122.4194, region: 'CA' }] },
|
|
7
|
-
];
|
|
8
|
-
export const CLIMATE_PRODUCTS = [
|
|
9
|
-
{ id: 'climsku_frontier_offtake_portfolio_2027', name: "Frontier's 2027 offtake portfolio", subtotal: 55000, fees: 1650, currency: 'usd', delivery_year: 2027, metric_tons_available: '18000', created: 1881439203, suppliers: ['climsup_charm_industrial'] },
|
|
10
|
-
];
|
|
11
|
-
export const supplierView = (s) => ({ id: s.id, object: 'climate.supplier', name: s.name, removal_pathway: s.removal_pathway, info_url: s.info_url, locations: s.locations, livemode: false });
|
|
12
|
-
export const productView = (p) => ({
|
|
13
|
-
id: p.id, object: 'climate.product', name: p.name, livemode: false, delivery_year: p.delivery_year,
|
|
14
|
-
metric_tons_available: p.metric_tons_available, created: p.created,
|
|
15
|
-
current_prices_per_metric_ton: { [p.currency]: { amount_fees: p.fees, amount_subtotal: p.subtotal, amount_total: p.subtotal + p.fees } },
|
|
16
|
-
suppliers: p.suppliers.map((id) => supplierView(CLIMATE_SUPPLIERS.find((s) => s.id === id))),
|
|
17
|
-
});
|
|
18
|
-
export const ORDER = 'climate.order';
|
|
19
|
-
// ── Financial Connections: a session is created for an account holder and its permissions; accounts
|
|
20
|
-
// are linked in the authentication flow Stripe.js opens (../screens/financial-connections.tsx) ──
|
|
21
|
-
export const FCS = 'financial_connections.session';
|
|
22
|
-
export const FCA = 'financial_connections.account';
|
|
23
|
-
export const FCT = 'financial_connections.transaction';
|
|
24
|
-
// ── Reporting: a representative subset of Stripe's report types; a run succeeds at once ──
|
|
25
|
-
export const REPORT_TYPES = [
|
|
26
|
-
{ id: 'balance.summary.1', name: 'Balance summary' },
|
|
27
|
-
{ id: 'balance_change_from_activity.summary.1', name: 'Balance change from activity (summary)' },
|
|
28
|
-
{ id: 'payouts.summary.1', name: 'Payouts (summary)' },
|
|
29
|
-
{ id: 'payout_reconciliation.by_id.itemized.4', name: 'Payout reconciliation (itemized)' },
|
|
30
|
-
];
|
|
31
|
-
export const reportTypeView = (t) => ({
|
|
32
|
-
id: t.id, object: 'reporting.report_type', name: t.name, version: 1,
|
|
33
|
-
data_available_start: 0, data_available_end: 0, default_columns: null, updated: 0, livemode: false,
|
|
34
|
-
});
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const SI = "setup_intent";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const SS = 'subscription_schedule';
|
package/dist/src/engine/tax.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { Row } from './common.js';
|
|
2
|
-
export declare const TWIN_TAX_RATE_PCT = 10;
|
|
3
|
-
export declare const ADDRESS_LINES: string[];
|
|
4
|
-
export declare function settingsBody(stored: Row | undefined): Row;
|
|
5
|
-
export declare const TX = "tax.transaction";
|
|
6
|
-
export declare const txLine: (id: string, i: number, l: Row, sign: 1 | -1, reversal: Row | null, type: string) => Row;
|
|
7
|
-
export declare const linesOf: (holder: Row) => Row[];
|
package/dist/src/engine/tax.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export const TWIN_TAX_RATE_PCT = 10;
|
|
2
|
-
// ── settings: active once a head office is set; the answer has no id ──
|
|
3
|
-
// the defaults' provider: "The tax calculation provider this account uses. Defaults to `stripe` when not using a
|
|
4
|
-
// third-party provider" (the served spec's tax settings defaults); the head office's address answers each line, the
|
|
5
|
-
// lines not given null (the served spec's address: each "(string, nullable)"; the settings page's example answers
|
|
6
|
-
// line2 null)
|
|
7
|
-
export const ADDRESS_LINES = ['city', 'country', 'line1', 'line2', 'postal_code', 'state'];
|
|
8
|
-
export function settingsBody(stored) {
|
|
9
|
-
const given = (stored?.head_office ?? null);
|
|
10
|
-
const address = given && typeof given.address === 'object' && given.address ? given.address : undefined;
|
|
11
|
-
const headOffice = given ? { ...given, ...(address ? { address: Object.fromEntries(ADDRESS_LINES.map((k) => [k, address[k] ?? null])) } : {}) } : null;
|
|
12
|
-
const active = !!headOffice;
|
|
13
|
-
return {
|
|
14
|
-
object: 'tax.settings', livemode: false,
|
|
15
|
-
defaults: { provider: 'stripe', ...(stored?.defaults ?? { tax_behavior: null, tax_code: null }) }, head_office: headOffice,
|
|
16
|
-
status: active ? 'active' : 'pending',
|
|
17
|
-
status_details: active ? { active: {} } : { pending: { missing_fields: ['head_office'] } },
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
// ── transactions: committing a calculation, or reversing a transaction with negated amounts ──
|
|
21
|
-
export const TX = 'tax.transaction';
|
|
22
|
-
export const txLine = (id, i, l, sign, reversal, type) => ({
|
|
23
|
-
object: 'tax.transaction_line_item', id: `tax_li_${id}_${i + 1}`,
|
|
24
|
-
amount: sign === 1 ? l.amount : -(Number(l.amount) || 0), amount_tax: sign === 1 ? l.amount_tax : -(Number(l.amount_tax) || 0),
|
|
25
|
-
reference: l.reference ?? null, tax_behavior: l.tax_behavior ?? 'exclusive', tax_code: l.tax_code ?? 'txcd_99999999',
|
|
26
|
-
quantity: l.quantity ?? 1, reversal, type, livemode: false, metadata: {},
|
|
27
|
-
});
|
|
28
|
-
export const linesOf = (holder) => holder.line_items?.data ?? [];
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
// Terminal and top-up semantics: in-person locations, readers (handed a PaymentIntent to process)
|
|
2
|
-
// and their configurations, the reader SDK's connection tokens, and top-ups that fund the balance
|
|
3
|
-
// (a test top-up succeeds at once; only a pending one cancels, the machine in ../manifest.ts). In test mode a
|
|
4
|
-
// simulated reader is presented a card by a test helper: the PaymentIntent the reader is processing is paid with a
|
|
5
|
-
// card_present payment method (succeeded, or requires_capture under manual capture) and the reader's action succeeds
|
|
6
|
-
// (docs.stripe.com/terminal/references/testing#simulated-test-cards,
|
|
7
|
-
// docs.stripe.com/api/terminal/readers/present_payment_method). Where the documentation stops and the twin decides:
|
|
8
|
-
// the presented card is the simulated reader's default Visa, and the reader answers at once.
|
|
9
|
-
// Lists and retrieves are the derived core's.
|
|
10
|
-
export const LOC = 'terminal.location';
|
|
11
|
-
export const READER = 'terminal.reader';
|
|
12
|
-
export const CONF = 'terminal.configuration';
|
|
13
|
-
// ── top-ups ──
|
|
14
|
-
// a top-up adds money to the balance it names, through the ledger, once its funds arrive: "USA (USD) ACH Debit Transfer
|
|
15
|
-
// 5 days" (docs.stripe.com/connect/top-ups), and to the Issuing balance alike: "Top-ups debit your bank account. Your
|
|
16
|
-
// top-ups can take up to 5 business days to become available. While they're pending, they won't be added to your
|
|
17
|
-
// Issuing balance" (docs.stripe.com/issuing/funding/balance). It is pending until its expected_availability_date, then
|
|
18
|
-
// settled by settleTopups. Where the documentation stops and the twin decides: every top-up takes exactly five days,
|
|
19
|
-
// whatever its currency and balance, and succeeds.
|
|
20
|
-
export const TOPUP_DAYS = 5;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export declare const CLOCK = "test_helpers.test_clock";
|
|
2
|
-
/** How long an advance takes: "it takes a few seconds to advance to the specified time"
|
|
3
|
-
* (docs.stripe.com/billing/testing/test-clocks/api-advanced-usage). Where the documentation stops and the twin decides:
|
|
4
|
-
* five seconds of World time from the advance. */
|
|
5
|
-
export declare const ADVANCE_SECONDS = 5;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// Test clock semantics. A test clock is Stripe's own door for a transition no API verb makes: the
|
|
2
|
-
// passage of time. Advancing it moves the subscriptions of the clock's customers as a real clock tick does:
|
|
3
|
-
// trials that ended end, and periods that ended renew (./renewals.ts advanceBilling). List, retrieve and delete are
|
|
4
|
-
// the derived core's.
|
|
5
|
-
export const CLOCK = 'test_helpers.test_clock';
|
|
6
|
-
/** How long an advance takes: "it takes a few seconds to advance to the specified time"
|
|
7
|
-
* (docs.stripe.com/billing/testing/test-clocks/api-advanced-usage). Where the documentation stops and the twin decides:
|
|
8
|
-
* five seconds of World time from the advance. */
|
|
9
|
-
export const ADVANCE_SECONDS = 5;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { Row } from './common.js';
|
|
2
|
-
/** The Card object a card token carries, as the served spec's `card` describes it: its brand as a name ("Card brand.
|
|
3
|
-
* Can be `American Express`, ... `MasterCard`, `UnionPay`, `Visa`, or `Unknown`"), the holder's name and address as
|
|
4
|
-
* given ("Cardholder name"), and the CVC's check when one was given ("If a CVC was provided, results of the check:
|
|
5
|
-
* pass, fail, unavailable, or unchecked"). Where the documentation stops and the twin decides: a test card's CVC passes. */
|
|
6
|
-
export declare const BRAND_NAMES: Record<string, string>;
|
|
7
|
-
export declare function legacyCard(id: string, card: Row): Row;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
// Token semantics: the older integrations' single-use tokens for a card, a bank account or PII. A
|
|
2
|
-
// token carries only the safe fields of its instrument, never the card or account number. Retrieve
|
|
3
|
-
// is the derived core's.
|
|
4
|
-
import { paymentMethodSubObject } from "./stripe.js";
|
|
5
|
-
/** The Card object a card token carries, as the served spec's `card` describes it: its brand as a name ("Card brand.
|
|
6
|
-
* Can be `American Express`, ... `MasterCard`, `UnionPay`, `Visa`, or `Unknown`"), the holder's name and address as
|
|
7
|
-
* given ("Cardholder name"), and the CVC's check when one was given ("If a CVC was provided, results of the check:
|
|
8
|
-
* pass, fail, unavailable, or unchecked"). Where the documentation stops and the twin decides: a test card's CVC passes. */
|
|
9
|
-
export const BRAND_NAMES = { amex: 'American Express', cartes_bancaires: 'Cartes Bancaires', diners: 'Diners Club', discover: 'Discover', eftpos_au: 'Eftpos Australia', girocard: 'Girocard', jcb: 'JCB', mastercard: 'MasterCard', unionpay: 'UnionPay', visa: 'Visa' };
|
|
10
|
-
export function legacyCard(id, card) {
|
|
11
|
-
const pm = paymentMethodSubObject('card', { card }).card;
|
|
12
|
-
const given = (k) => (typeof card[k] === 'string' && card[k] !== '' ? card[k] : null);
|
|
13
|
-
return {
|
|
14
|
-
id, object: 'card', brand: BRAND_NAMES[String(pm.brand)] ?? 'Unknown', last4: pm.last4, exp_month: pm.exp_month, exp_year: pm.exp_year,
|
|
15
|
-
funding: pm.funding ?? 'credit', country: pm.country ?? null, fingerprint: pm.fingerprint ?? null, name: given('name'),
|
|
16
|
-
address_line1: given('address_line1'), address_line2: given('address_line2'), address_city: given('address_city'), address_state: given('address_state'),
|
|
17
|
-
address_zip: given('address_zip'), address_country: given('address_country'), address_line1_check: null, address_zip_check: null,
|
|
18
|
-
cvc_check: card.cvc !== undefined && card.cvc !== '' ? 'pass' : null, dynamic_last4: null, tokenization_method: null, metadata: {}, customer: null,
|
|
19
|
-
};
|
|
20
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { Row } from './common.js';
|
|
2
|
-
export declare const FA = "treasury.financial_account";
|
|
3
|
-
export declare const TX = "treasury.transaction";
|
|
4
|
-
export declare const ENTRY = "treasury.transaction_entry";
|
|
5
|
-
export declare const ENTRY_TYPES: Set<string>;
|
|
6
|
-
/** A financial account's features as the served spec's treasury.financial_account_features gives them: a toggle
|
|
7
|
-
* (card_issuing, deposit_insurance, intra_stripe_flows) or a feature per network (financial_addresses.aba,
|
|
8
|
-
* inbound_transfers.ach, outbound_payments.ach and .us_domestic_wire, outbound_transfers likewise), each
|
|
9
|
-
* { requested, status, status_details }. What a request asks for is laid over what the account had. Where the
|
|
10
|
-
* documentation stops and the twin decides: a requested feature is active at once (test mode), and one never requested
|
|
11
|
-
* is left out (each is optional in the served spec). Answers the features and the active features' paths. */
|
|
12
|
-
export declare const NETWORKS: Record<string, string[]>;
|
|
13
|
-
export declare const TOGGLES: string[];
|
|
14
|
-
export declare function featuresOf(requested: Row, had?: Row): {
|
|
15
|
-
features: Row;
|
|
16
|
-
active: string[];
|
|
17
|
-
};
|
|
18
|
-
export declare const noTransitions: {
|
|
19
|
-
canceled_at: null;
|
|
20
|
-
failed_at: null;
|
|
21
|
-
posted_at: null;
|
|
22
|
-
returned_at: null;
|
|
23
|
-
};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
export const FA = 'treasury.financial_account';
|
|
2
|
-
export const TX = 'treasury.transaction';
|
|
3
|
-
export const ENTRY = 'treasury.transaction_entry';
|
|
4
|
-
export const ENTRY_TYPES = new Set(['credit_reversal', 'debit_reversal', 'inbound_transfer', 'inbound_transfer_return', 'issuing_authorization_hold', 'issuing_authorization_release', 'outbound_payment', 'outbound_transfer', 'received_credit', 'received_debit']);
|
|
5
|
-
/** A financial account's features as the served spec's treasury.financial_account_features gives them: a toggle
|
|
6
|
-
* (card_issuing, deposit_insurance, intra_stripe_flows) or a feature per network (financial_addresses.aba,
|
|
7
|
-
* inbound_transfers.ach, outbound_payments.ach and .us_domestic_wire, outbound_transfers likewise), each
|
|
8
|
-
* { requested, status, status_details }. What a request asks for is laid over what the account had. Where the
|
|
9
|
-
* documentation stops and the twin decides: a requested feature is active at once (test mode), and one never requested
|
|
10
|
-
* is left out (each is optional in the served spec). Answers the features and the active features' paths. */
|
|
11
|
-
export const NETWORKS = { financial_addresses: ['aba'], inbound_transfers: ['ach'], outbound_payments: ['ach', 'us_domestic_wire'], outbound_transfers: ['ach', 'us_domestic_wire'] };
|
|
12
|
-
export const TOGGLES = ['card_issuing', 'deposit_insurance', 'intra_stripe_flows'];
|
|
13
|
-
export function featuresOf(requested, had = {}) {
|
|
14
|
-
const on = (v) => v === true || v === 'true';
|
|
15
|
-
const setting = (asked) => ({ requested: asked, status: asked ? 'active' : 'restricted', status_details: [] });
|
|
16
|
-
const features = { ...had };
|
|
17
|
-
for (const t of TOGGLES) {
|
|
18
|
-
const r = requested[t];
|
|
19
|
-
if (r && typeof r === 'object' && r.requested !== undefined)
|
|
20
|
-
features[t] = setting(on(r.requested));
|
|
21
|
-
}
|
|
22
|
-
for (const [f, nets] of Object.entries(NETWORKS)) {
|
|
23
|
-
const r = requested[f];
|
|
24
|
-
if (!r || typeof r !== 'object')
|
|
25
|
-
continue;
|
|
26
|
-
const current = features[f] ?? {};
|
|
27
|
-
const next = { ...current };
|
|
28
|
-
for (const n of nets) {
|
|
29
|
-
const nr = r[n];
|
|
30
|
-
if (nr && typeof nr === 'object' && nr.requested !== undefined)
|
|
31
|
-
next[n] = setting(on(nr.requested));
|
|
32
|
-
}
|
|
33
|
-
features[f] = next;
|
|
34
|
-
}
|
|
35
|
-
const active = [];
|
|
36
|
-
for (const t of TOGGLES)
|
|
37
|
-
if (features[t]?.status === 'active')
|
|
38
|
-
active.push(t);
|
|
39
|
-
for (const [f, nets] of Object.entries(NETWORKS))
|
|
40
|
-
for (const n of nets)
|
|
41
|
-
if (features[f]?.[n]?.status === 'active')
|
|
42
|
-
active.push(`${f}.${n}`);
|
|
43
|
-
return { features, active };
|
|
44
|
-
}
|
|
45
|
-
export const noTransitions = { canceled_at: null, failed_at: null, posted_at: null, returned_at: null };
|