@portablecore/commerce 0.1.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.
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Stripe Connect Onboarding
3
+ *
4
+ * Shared infrastructure for onboarding marketplace creators across all
5
+ * Portable platforms. Each platform (Expert, Team, Theater, Coach) uses
6
+ * these same helpers to create Connect Express accounts, generate
7
+ * onboarding links, and check account status.
8
+ *
9
+ * All functions accept a Stripe client — no env vars, works everywhere.
10
+ */
11
+ import type Stripe from "stripe";
12
+ import type { ConnectAccountStatus, MarketplacePlatform } from "@portablecore/types";
13
+ export interface CreateConnectAccountParams {
14
+ /** Creator's email */
15
+ email: string;
16
+ /** Connect account type — Express is recommended for marketplace creators */
17
+ account_type?: "express" | "standard";
18
+ /** Business type */
19
+ business_type?: "individual" | "company";
20
+ /** Country code (ISO 3166-1 alpha-2) */
21
+ country?: string;
22
+ /** Which platform marketplace */
23
+ platform: MarketplacePlatform;
24
+ /** Platform-specific creator ID */
25
+ creator_id: string;
26
+ /** Additional metadata */
27
+ metadata?: Record<string, string>;
28
+ }
29
+ export interface CreateOnboardingLinkParams {
30
+ /** Stripe Connect account ID */
31
+ account_id: string;
32
+ /** URL to redirect to if onboarding needs to be restarted */
33
+ refresh_url: string;
34
+ /** URL to redirect to after onboarding completes */
35
+ return_url: string;
36
+ /** Link type */
37
+ type?: "account_onboarding" | "account_update";
38
+ }
39
+ /**
40
+ * Create a Stripe Connect Express account for a marketplace creator.
41
+ * Returns the Stripe account ID, which should be stored on the creator record.
42
+ */
43
+ export declare function createConnectAccount(stripe: Stripe, params: CreateConnectAccountParams): Promise<Stripe.Account>;
44
+ /**
45
+ * Create an account onboarding link. Redirect the creator to this URL
46
+ * to complete their Stripe Connect setup.
47
+ */
48
+ export declare function createOnboardingLink(stripe: Stripe, params: CreateOnboardingLinkParams): Promise<Stripe.AccountLink>;
49
+ /**
50
+ * Get the current status of a Connect account — whether onboarding is
51
+ * complete, charges are enabled, and what requirements are outstanding.
52
+ */
53
+ export declare function getConnectAccountStatus(stripe: Stripe, accountId: string): Promise<ConnectAccountStatus>;
54
+ /**
55
+ * Generate a login link for a Connect Express account.
56
+ * Lets creators access their Stripe Express Dashboard to manage
57
+ * payouts, bank accounts, and tax information.
58
+ */
59
+ export declare function createDashboardLoginLink(stripe: Stripe, accountId: string): Promise<string>;
60
+ //# sourceMappingURL=connect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAChC,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,qBAAqB,CAAA;AAM5B,MAAM,WAAW,0BAA0B;IACzC,sBAAsB;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,6EAA6E;IAC7E,YAAY,CAAC,EAAE,SAAS,GAAG,UAAU,CAAA;IACrC,oBAAoB;IACpB,aAAa,CAAC,EAAE,YAAY,GAAG,SAAS,CAAA;IACxC,wCAAwC;IACxC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,iCAAiC;IACjC,QAAQ,EAAE,mBAAmB,CAAA;IAC7B,mCAAmC;IACnC,UAAU,EAAE,MAAM,CAAA;IAClB,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAClC;AAED,MAAM,WAAW,0BAA0B;IACzC,gCAAgC;IAChC,UAAU,EAAE,MAAM,CAAA;IAClB,6DAA6D;IAC7D,WAAW,EAAE,MAAM,CAAA;IACnB,oDAAoD;IACpD,UAAU,EAAE,MAAM,CAAA;IAClB,gBAAgB;IAChB,IAAI,CAAC,EAAE,oBAAoB,GAAG,gBAAgB,CAAA;CAC/C;AAMD;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,0BAA0B,GACjC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CA0BzB;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,0BAA0B,GACjC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAU7B;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,oBAAoB,CAAC,CAc/B;AAED;;;;GAIG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC,CAGjB"}
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ /**
3
+ * Stripe Connect Onboarding
4
+ *
5
+ * Shared infrastructure for onboarding marketplace creators across all
6
+ * Portable platforms. Each platform (Expert, Team, Theater, Coach) uses
7
+ * these same helpers to create Connect Express accounts, generate
8
+ * onboarding links, and check account status.
9
+ *
10
+ * All functions accept a Stripe client — no env vars, works everywhere.
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.createConnectAccount = createConnectAccount;
14
+ exports.createOnboardingLink = createOnboardingLink;
15
+ exports.getConnectAccountStatus = getConnectAccountStatus;
16
+ exports.createDashboardLoginLink = createDashboardLoginLink;
17
+ // ---------------------------------------------------------------------------
18
+ // Connect account management
19
+ // ---------------------------------------------------------------------------
20
+ /**
21
+ * Create a Stripe Connect Express account for a marketplace creator.
22
+ * Returns the Stripe account ID, which should be stored on the creator record.
23
+ */
24
+ async function createConnectAccount(stripe, params) {
25
+ const { email, account_type = "express", business_type = "individual", country = "US", platform, creator_id, metadata = {}, } = params;
26
+ return stripe.accounts.create({
27
+ type: account_type,
28
+ country,
29
+ email,
30
+ business_type,
31
+ capabilities: {
32
+ card_payments: { requested: true },
33
+ transfers: { requested: true },
34
+ },
35
+ metadata: {
36
+ portable_platform: platform,
37
+ portable_creator_id: creator_id,
38
+ ...metadata,
39
+ },
40
+ });
41
+ }
42
+ /**
43
+ * Create an account onboarding link. Redirect the creator to this URL
44
+ * to complete their Stripe Connect setup.
45
+ */
46
+ async function createOnboardingLink(stripe, params) {
47
+ const { account_id, refresh_url, return_url, type = "account_onboarding" } = params;
48
+ return stripe.accountLinks.create({
49
+ account: account_id,
50
+ refresh_url,
51
+ return_url,
52
+ type,
53
+ });
54
+ }
55
+ /**
56
+ * Get the current status of a Connect account — whether onboarding is
57
+ * complete, charges are enabled, and what requirements are outstanding.
58
+ */
59
+ async function getConnectAccountStatus(stripe, accountId) {
60
+ const account = await stripe.accounts.retrieve(accountId);
61
+ return {
62
+ account_id: accountId,
63
+ details_submitted: account.details_submitted || false,
64
+ charges_enabled: account.charges_enabled || false,
65
+ payouts_enabled: account.payouts_enabled || false,
66
+ requirements: {
67
+ currently_due: account.requirements?.currently_due || [],
68
+ eventually_due: account.requirements?.eventually_due || [],
69
+ past_due: account.requirements?.past_due || [],
70
+ },
71
+ };
72
+ }
73
+ /**
74
+ * Generate a login link for a Connect Express account.
75
+ * Lets creators access their Stripe Express Dashboard to manage
76
+ * payouts, bank accounts, and tax information.
77
+ */
78
+ async function createDashboardLoginLink(stripe, accountId) {
79
+ const loginLink = await stripe.accounts.createLoginLink(accountId);
80
+ return loginLink.url;
81
+ }
82
+ //# sourceMappingURL=connect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connect.js","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;AAgDH,oDA6BC;AAMD,oDAaC;AAMD,0DAiBC;AAOD,4DAMC;AA5FD,8EAA8E;AAC9E,6BAA6B;AAC7B,8EAA8E;AAE9E;;;GAGG;AACI,KAAK,UAAU,oBAAoB,CACxC,MAAc,EACd,MAAkC;IAElC,MAAM,EACJ,KAAK,EACL,YAAY,GAAG,SAAS,EACxB,aAAa,GAAG,YAAY,EAC5B,OAAO,GAAG,I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,YAAY,EAAE,QAAQ,IAAI,EAAE;SAC/C;KACF,CAAA;AACH,CAAC;AAED;;;;GAIG;AACI,KAAK,UAAU,wBAAwB,CAC5C,MAAc,EACd,SAAiB;IAEjB,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,SAAS,CAAC,CAAA;IAClE,OAAO,SAAS,CAAC,GAAG,CAAA;AACtB,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @portablecore/commerce
3
+ *
4
+ * Shared marketplace commerce infrastructure for all Portable platforms.
5
+ * Connect onboarding, revenue splits, and payout execution.
6
+ *
7
+ * Each platform (Expert, Team, Theater, Coach) uses these helpers to
8
+ * power its marketplace. The platform-specific business logic (what
9
+ * products look like, how they're priced, discovery UI) stays in the
10
+ * platform app. The money movement is shared here.
11
+ *
12
+ * "One engine, many marketplaces."
13
+ */
14
+ export { createConnectAccount, createOnboardingLink, getConnectAccountStatus, createDashboardLoginLink, } from "./connect.js";
15
+ export type { CreateConnectAccountParams, CreateOnboardingLinkParams, } from "./connect.js";
16
+ export { calculateRevenueSplit, calculateApplicationFee, validateRevenueSplit, formatCents, DEFAULT_REVENUE_CONFIG, } from "./revenue.js";
17
+ export { createDestinationCharge, createConnectCheckoutSession, createTransfer, getTransfer, } from "./payout.js";
18
+ export type { DestinationChargeParams, TransferParams, CheckoutWithConnectParams, } from "./payout.js";
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,cAAc,CAAA;AACrB,YAAY,EACV,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,cAAc,CAAA;AAGrB,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,EACpB,WAAW,EACX,sBAAsB,GACvB,MAAM,cAAc,CAAA;AAGrB,OAAO,EACL,uBAAuB,EACvB,4BAA4B,EAC5B,cAAc,EACd,WAAW,GACZ,MAAM,aAAa,CAAA;AACpB,YAAY,EACV,uBAAuB,EACvB,cAAc,EACd,yBAAyB,GAC1B,MAAM,aAAa,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ /**
3
+ * @portablecore/commerce
4
+ *
5
+ * Shared marketplace commerce infrastructure for all Portable platforms.
6
+ * Connect onboarding, revenue splits, and payout execution.
7
+ *
8
+ * Each platform (Expert, Team, Theater, Coach) uses these helpers to
9
+ * power its marketplace. The platform-specific business logic (what
10
+ * products look like, how they're priced, discovery UI) stays in the
11
+ * platform app. The money movement is shared here.
12
+ *
13
+ * "One engine, many marketplaces."
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.getTransfer = exports.createTransfer = exports.createConnectCheckoutSession = exports.createDestinationCharge = exports.DEFAULT_REVENUE_CONFIG = exports.formatCents = exports.validateRevenueSplit = exports.calculateApplicationFee = exports.calculateRevenueSplit = exports.createDashboardLoginLink = exports.getConnectAccountStatus = exports.createOnboardingLink = exports.createConnectAccount = void 0;
17
+ // Stripe Connect onboarding
18
+ var connect_js_1 = require("./connect.js");
19
+ Object.defineProperty(exports, "createConnectAccount", { enumerable: true, get: function () { return connect_js_1.createConnectAccount; } });
20
+ Object.defineProperty(exports, "createOnboardingLink", { enumerable: true, get: function () { return connect_js_1.createOnboardingLink; } });
21
+ Object.defineProperty(exports, "getConnectAccountStatus", { enumerable: true, get: function () { return connect_js_1.getConnectAccountStatus; } });
22
+ Object.defineProperty(exports, "createDashboardLoginLink", { enumerable: true, get: function () { return connect_js_1.createDashboardLoginLink; } });
23
+ // Revenue split calculation
24
+ var revenue_js_1 = require("./revenue.js");
25
+ Object.defineProperty(exports, "calculateRevenueSplit", { enumerable: true, get: function () { return revenue_js_1.calculateRevenueSplit; } });
26
+ Object.defineProperty(exports, "calculateApplicationFee", { enumerable: true, get: function () { return revenue_js_1.calculateApplicationFee; } });
27
+ Object.defineProperty(exports, "validateRevenueSplit", { enumerable: true, get: function () { return revenue_js_1.validateRevenueSplit; } });
28
+ Object.defineProperty(exports, "formatCents", { enumerable: true, get: function () { return revenue_js_1.formatCents; } });
29
+ Object.defineProperty(exports, "DEFAULT_REVENUE_CONFIG", { enumerable: true, get: function () { return revenue_js_1.DEFAULT_REVENUE_CONFIG; } });
30
+ // Payout execution
31
+ var payout_js_1 = require("./payout.js");
32
+ Object.defineProperty(exports, "createDestinationCharge", { enumerable: true, get: function () { return payout_js_1.createDestinationCharge; } });
33
+ Object.defineProperty(exports, "createConnectCheckoutSession", { enumerable: true, get: function () { return payout_js_1.createConnectCheckoutSession; } });
34
+ Object.defineProperty(exports, "createTransfer", { enumerable: true, get: function () { return payout_js_1.createTransfer; } });
35
+ Object.defineProperty(exports, "getTransfer", { enumerable: true, get: function () { return payout_js_1.getTransfer; } });
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;AAEH,4BAA4B;AAC5B,2CAKqB;AAJnB,kHAAA,oBAAoB,OAAA;AACpB,kHAAA,oBAAoB,OAAA;AACpB,qHAAA,uBAAuB,OAAA;AACvB,sHAAA,wBAAwB,OAAA;AAO1B,4BAA4B;AAC5B,2CAMqB;AALnB,mHAAA,qBAAqB,OAAA;AACrB,qHAAA,uBAAuB,OAAA;AACvB,kHAAA,oBAAoB,OAAA;AACpB,yGAAA,WAAW,OAAA;AACX,oHAAA,sBAAsB,OAAA;AAGxB,mBAAmB;AACnB,yCAKoB;AAJlB,oHAAA,uBAAuB,OAAA;AACvB,yHAAA,4BAA4B,OAAA;AAC5B,2GAAA,cAAc,OAAA;AACd,wGAAA,WAAW,OAAA"}
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Payout Execution
3
+ *
4
+ * Handles the actual movement of money from Portable to creators
5
+ * via Stripe Connect. Supports both immediate (per-transaction)
6
+ * and batched (periodic) payouts.
7
+ */
8
+ import type Stripe from "stripe";
9
+ import type { MarketplacePlatform } from "@portablecore/types";
10
+ export interface DestinationChargeParams {
11
+ /** Total amount to charge the customer in cents */
12
+ amount_cents: number;
13
+ /** Currency */
14
+ currency?: string;
15
+ /** Stripe customer ID (the buyer) */
16
+ customer_id: string;
17
+ /** Creator's Stripe Connect account ID (receives the payout) */
18
+ destination_account_id: string;
19
+ /** Platform fee percentage (defaults to 20%) */
20
+ platform_fee_percent?: number;
21
+ /** Which platform marketplace */
22
+ platform: MarketplacePlatform;
23
+ /** Platform-specific product ID */
24
+ product_id: string;
25
+ /** Product name (for Stripe metadata) */
26
+ product_name?: string;
27
+ /** Additional metadata */
28
+ metadata?: Record<string, string>;
29
+ }
30
+ export interface TransferParams {
31
+ /** Amount to transfer in cents */
32
+ amount_cents: number;
33
+ /** Currency */
34
+ currency?: string;
35
+ /** Creator's Stripe Connect account ID */
36
+ destination_account_id: string;
37
+ /** Description visible to the creator */
38
+ description?: string;
39
+ /** Which platform marketplace */
40
+ platform: MarketplacePlatform;
41
+ /** Reference IDs for the sales this transfer covers */
42
+ sale_ids?: string[];
43
+ /** Additional metadata */
44
+ metadata?: Record<string, string>;
45
+ }
46
+ export interface CheckoutWithConnectParams {
47
+ /** Stripe customer ID (the buyer) */
48
+ customer_id: string;
49
+ /** Stripe Price ID for the product */
50
+ price_id: string;
51
+ /** Checkout mode */
52
+ mode: "payment" | "subscription";
53
+ /** Creator's Stripe Connect account ID */
54
+ destination_account_id: string;
55
+ /** Platform fee percentage */
56
+ platform_fee_percent?: number;
57
+ /** Success redirect URL */
58
+ success_url: string;
59
+ /** Cancel redirect URL */
60
+ cancel_url: string;
61
+ /** Which platform marketplace */
62
+ platform: MarketplacePlatform;
63
+ /** Platform-specific product ID */
64
+ product_id: string;
65
+ /** Additional metadata */
66
+ metadata?: Record<string, string>;
67
+ }
68
+ /**
69
+ * Create a destination charge — the buyer pays, Portable takes the
70
+ * application fee, and the rest goes to the creator's Connect account.
71
+ *
72
+ * This is the recommended approach for immediate per-transaction payouts.
73
+ */
74
+ export declare function createDestinationCharge(stripe: Stripe, params: DestinationChargeParams): Promise<Stripe.PaymentIntent>;
75
+ /**
76
+ * Create a Stripe Checkout session with Connect destination.
77
+ * For marketplace purchases that go through Stripe Checkout.
78
+ */
79
+ export declare function createConnectCheckoutSession(stripe: Stripe, params: CheckoutWithConnectParams): Promise<Stripe.Checkout.Session>;
80
+ /**
81
+ * Create a manual transfer to a creator's Connect account.
82
+ * Used for batched payouts (e.g., monthly IAP revenue distribution)
83
+ * where we don't use destination charges.
84
+ */
85
+ export declare function createTransfer(stripe: Stripe, params: TransferParams): Promise<Stripe.Transfer>;
86
+ /**
87
+ * Retrieve a transfer by ID — for checking payout status.
88
+ */
89
+ export declare function getTransfer(stripe: Stripe, transferId: string): Promise<Stripe.Transfer>;
90
+ //# sourceMappingURL=payout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payout.d.ts","sourceRoot":"","sources":["../src/payout.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAChC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAO9D,MAAM,WAAW,uBAAuB;IACtC,mDAAmD;IACnD,YAAY,EAAE,MAAM,CAAA;IACpB,eAAe;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,qCAAqC;IACrC,WAAW,EAAE,MAAM,CAAA;IACnB,gEAAgE;IAChE,sBAAsB,EAAE,MAAM,CAAA;IAC9B,gDAAgD;IAChD,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,iCAAiC;IACjC,QAAQ,EAAE,mBAAmB,CAAA;IAC7B,mCAAmC;IACnC,UAAU,EAAE,MAAM,CAAA;IAClB,yCAAyC;IACzC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GAGG;AACH,wBAAsB,4BAA4B,CAChD,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,yBAAyB,GAChC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CA8ClC;AAMD;;;;GAIG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,cAAc,GACrB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAsB1B;AAED;;GAEG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAE1B"}
package/dist/payout.js ADDED
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ /**
3
+ * Payout Execution
4
+ *
5
+ * Handles the actual movement of money from Portable to creators
6
+ * via Stripe Connect. Supports both immediate (per-transaction)
7
+ * and batched (periodic) payouts.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.createDestinationCharge = createDestinationCharge;
11
+ exports.createConnectCheckoutSession = createConnectCheckoutSession;
12
+ exports.createTransfer = createTransfer;
13
+ exports.getTransfer = getTransfer;
14
+ const revenue_js_1 = require("./revenue.js");
15
+ // ---------------------------------------------------------------------------
16
+ // Destination charges
17
+ // ---------------------------------------------------------------------------
18
+ /**
19
+ * Create a destination charge — the buyer pays, Portable takes the
20
+ * application fee, and the rest goes to the creator's Connect account.
21
+ *
22
+ * This is the recommended approach for immediate per-transaction payouts.
23
+ */
24
+ async function createDestinationCharge(stripe, params) {
25
+ const { amount_cents, currency = "usd", customer_id, destination_account_id, platform_fee_percent = revenue_js_1.DEFAULT_REVENUE_CONFIG.platform_fee_percent, platform, product_id, product_name, metadata = {}, } = params;
26
+ const applicationFee = (0, revenue_js_1.calculateApplicationFee)(amount_cents, platform_fee_percent);
27
+ return stripe.paymentIntents.create({
28
+ amount: amount_cents,
29
+ currency,
30
+ customer: customer_id,
31
+ application_fee_amount: applicationFee,
32
+ transfer_data: {
33
+ destination: destination_account_id,
34
+ },
35
+ metadata: {
36
+ portable_platform: platform,
37
+ portable_product_id: product_id,
38
+ portable_product_name: product_name || "",
39
+ ...metadata,
40
+ },
41
+ automatic_payment_methods: {
42
+ enabled: true,
43
+ },
44
+ });
45
+ }
46
+ /**
47
+ * Create a Stripe Checkout session with Connect destination.
48
+ * For marketplace purchases that go through Stripe Checkout.
49
+ */
50
+ async function createConnectCheckoutSession(stripe, params) {
51
+ const { customer_id, price_id, mode, destination_account_id, platform_fee_percent = revenue_js_1.DEFAULT_REVENUE_CONFIG.platform_fee_percent, success_url, cancel_url, platform, product_id, metadata = {}, } = params;
52
+ const sessionParams = {
53
+ customer: customer_id,
54
+ mode,
55
+ line_items: [{ price: price_id, quantity: 1 }],
56
+ success_url,
57
+ cancel_url,
58
+ payment_intent_data: mode === "payment"
59
+ ? {
60
+ application_fee_amount: undefined, // calculated by Stripe from transfer
61
+ transfer_data: {
62
+ destination: destination_account_id,
63
+ },
64
+ }
65
+ : undefined,
66
+ subscription_data: mode === "subscription"
67
+ ? {
68
+ application_fee_percent: platform_fee_percent,
69
+ transfer_data: {
70
+ destination: destination_account_id,
71
+ },
72
+ }
73
+ : undefined,
74
+ metadata: {
75
+ portable_platform: platform,
76
+ portable_product_id: product_id,
77
+ ...metadata,
78
+ },
79
+ };
80
+ return stripe.checkout.sessions.create(sessionParams);
81
+ }
82
+ // ---------------------------------------------------------------------------
83
+ // Manual transfers (for batched payouts)
84
+ // ---------------------------------------------------------------------------
85
+ /**
86
+ * Create a manual transfer to a creator's Connect account.
87
+ * Used for batched payouts (e.g., monthly IAP revenue distribution)
88
+ * where we don't use destination charges.
89
+ */
90
+ async function createTransfer(stripe, params) {
91
+ const { amount_cents, currency = "usd", destination_account_id, description, platform, sale_ids = [], metadata = {}, } = params;
92
+ return stripe.transfers.create({
93
+ amount: amount_cents,
94
+ currency,
95
+ destination: destination_account_id,
96
+ description: description || `Portable ${platform} payout`,
97
+ metadata: {
98
+ portable_platform: platform,
99
+ sale_ids: sale_ids.join(","),
100
+ ...metadata,
101
+ },
102
+ });
103
+ }
104
+ /**
105
+ * Retrieve a transfer by ID — for checking payout status.
106
+ */
107
+ async function getTransfer(stripe, transferId) {
108
+ return stripe.transfers.retrieve(transferId);
109
+ }
110
+ //# sourceMappingURL=payout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payout.js","sourceRoot":"","sources":["../src/payout.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAiFH,0DAuCC;AAMD,oEAiDC;AAWD,wCAyBC;AAKD,kCAKC;AAzND,6CAA8E;AAmE9E,8EAA8E;AAC9E,sBAAsB;AACtB,8EAA8E;AAE9E;;;;;GAKG;AACI,KAAK,UAAU,uBAAuB,CAC3C,MAAc,EACd,MAA+B;IAE/B,MAAM,EACJ,YAAY,EACZ,QAAQ,GAAG,KAAK,EAChB,WAAW,EACX,sBAAsB,EACtB,oBAAoB,GAAG,mCAAsB,CAAC,oBAAoB,EAClE,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,QAAQ,GAAG,EAAE,GACd,GAAG,MAAM,CAAA;IAEV,MAAM,cAAc,GAAG,IAAA,oCAAuB,EAC5C,YAAY,EACZ,oBAAoB,CACrB,CAAA;IAED,OAAO,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC;QAClC,MAAM,EAAE,YAAY;QACpB,QAAQ;QACR,QAAQ,EAAE,WAAW;QACrB,sBAAsB,EAAE,cAAc;QACtC,aAAa,EAAE;YACb,WAAW,EAAE,sBAAsB;SACpC;QACD,QAAQ,EAAE;YACR,iBAAiB,EAAE,QAAQ;YAC3B,mBAAmB,EAAE,UAAU;YAC/B,qBAAqB,EAAE,YAAY,IAAI,EAAE;YACzC,GAAG,QAAQ;SACZ;QACD,yBAAyB,EAAE;YACzB,OAAO,EAAE,IAAI;SACd;KACF,CAAC,CAAA;AACJ,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,4BAA4B,CAChD,MAAc,EACd,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AAC;QAC7B,MAAM,EAAE,YAAY;QACpB,QAAQ;QACR,WAAW,EAAE,sBAAsB;QACnC,WAAW,EAAE,WAAW,IAAI,YAAY,QAAQ,SAAS;QACzD,QAAQ,EAAE;YACR,iBAAiB,EAAE,QAAQ;YAC3B,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC;YAC5B,GAAG,QAAQ;SACZ;KACF,CAAC,CAAA;AACJ,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,WAAW,CAC/B,MAAc,EACd,UAAkB;IAElB,OAAO,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAA;AAC9C,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Revenue Split Engine
3
+ *
4
+ * Calculates how marketplace revenue is divided between the platform
5
+ * (Portable) and the creator. Supports different revenue sources
6
+ * (Stripe, Apple IAP, Google IAP) with appropriate fee adjustments.
7
+ *
8
+ * Default split: 80% creator / 20% platform (more generous than
9
+ * app stores' 70/30, acknowledging that creators provide the
10
+ * differentiated value).
11
+ */
12
+ import type { RevenueSplitConfig, RevenueSplitResult, RevenueSource } from "@portablecore/types";
13
+ /** Default revenue split configuration */
14
+ export declare const DEFAULT_REVENUE_CONFIG: RevenueSplitConfig;
15
+ /**
16
+ * Calculate the revenue split for a marketplace transaction.
17
+ *
18
+ * For Stripe purchases: Portable takes platform_fee_percent, creator gets the rest.
19
+ * For IAP purchases: Store takes their cut first, then Portable and creator split the remainder.
20
+ */
21
+ export declare function calculateRevenueSplit(totalCents: number, config?: Partial<RevenueSplitConfig>, revenueSource?: RevenueSource, options?: {
22
+ apple_small_business?: boolean;
23
+ }): RevenueSplitResult;
24
+ /**
25
+ * Calculate the Stripe application fee amount for a Connect destination charge.
26
+ * This is what Stripe deducts from the payment and sends to the platform.
27
+ */
28
+ export declare function calculateApplicationFee(totalCents: number, platformFeePercent?: number): number;
29
+ /**
30
+ * Validate that a revenue split adds up correctly.
31
+ */
32
+ export declare function validateRevenueSplit(result: RevenueSplitResult): boolean;
33
+ /**
34
+ * Format cents to a human-readable dollar string.
35
+ */
36
+ export declare function formatCents(cents: number): string;
37
+ //# sourceMappingURL=revenue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"revenue.d.ts","sourceRoot":"","sources":["../src/revenue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EACd,MAAM,qBAAqB,CAAA;AAM5B,0CAA0C;AAC1C,eAAO,MAAM,sBAAsB,EAAE,kBAKpC,CAAA;AAmBD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,MAAM,EAClB,MAAM,GAAE,OAAO,CAAC,kBAAkB,CAAM,EACxC,aAAa,GAAE,aAAwB,EACvC,OAAO,CAAC,EAAE;IAAE,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAAE,GAC3C,kBAAkB,CAuDpB;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,MAAM,EAClB,kBAAkB,GAAE,MAAoD,GACvE,MAAM,CAER;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CASxE;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEjD"}
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ /**
3
+ * Revenue Split Engine
4
+ *
5
+ * Calculates how marketplace revenue is divided between the platform
6
+ * (Portable) and the creator. Supports different revenue sources
7
+ * (Stripe, Apple IAP, Google IAP) with appropriate fee adjustments.
8
+ *
9
+ * Default split: 80% creator / 20% platform (more generous than
10
+ * app stores' 70/30, acknowledging that creators provide the
11
+ * differentiated value).
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.DEFAULT_REVENUE_CONFIG = void 0;
15
+ exports.calculateRevenueSplit = calculateRevenueSplit;
16
+ exports.calculateApplicationFee = calculateApplicationFee;
17
+ exports.validateRevenueSplit = validateRevenueSplit;
18
+ exports.formatCents = formatCents;
19
+ // ---------------------------------------------------------------------------
20
+ // Defaults
21
+ // ---------------------------------------------------------------------------
22
+ /** Default revenue split configuration */
23
+ exports.DEFAULT_REVENUE_CONFIG = {
24
+ platform_fee_percent: 20,
25
+ creator_share_percent: 80,
26
+ minimum_payout_cents: 5000, // $50 minimum
27
+ payout_schedule: "monthly",
28
+ };
29
+ /** Stripe processing fee: ~2.9% + 30¢ */
30
+ const STRIPE_FEE_PERCENT = 2.9;
31
+ const STRIPE_FEE_FIXED_CENTS = 30;
32
+ /** Apple IAP fee (standard rate) */
33
+ const APPLE_IAP_FEE_PERCENT = 30;
34
+ /** Apple IAP fee (small business program) */
35
+ const APPLE_IAP_SMALL_BUSINESS_FEE_PERCENT = 15;
36
+ /** Google Play fee */
37
+ const GOOGLE_IAP_FEE_PERCENT = 15;
38
+ // ---------------------------------------------------------------------------
39
+ // Revenue split calculation
40
+ // ---------------------------------------------------------------------------
41
+ /**
42
+ * Calculate the revenue split for a marketplace transaction.
43
+ *
44
+ * For Stripe purchases: Portable takes platform_fee_percent, creator gets the rest.
45
+ * For IAP purchases: Store takes their cut first, then Portable and creator split the remainder.
46
+ */
47
+ function calculateRevenueSplit(totalCents, config = {}, revenueSource = "stripe", options) {
48
+ const platformFeePercent = config.platform_fee_percent ?? exports.DEFAULT_REVENUE_CONFIG.platform_fee_percent;
49
+ const creatorSharePercent = 100 - platformFeePercent;
50
+ let platformFeeCents;
51
+ let creatorShareCents;
52
+ let stripeFeeCents;
53
+ if (revenueSource === "stripe") {
54
+ // Stripe: platform takes fee, creator gets the rest
55
+ platformFeeCents = Math.round(totalCents * (platformFeePercent / 100));
56
+ creatorShareCents = totalCents - platformFeeCents;
57
+ // Stripe processing fee is typically absorbed by the platform
58
+ stripeFeeCents = Math.round(totalCents * (STRIPE_FEE_PERCENT / 100) + STRIPE_FEE_FIXED_CENTS);
59
+ }
60
+ else if (revenueSource === "apple_iap") {
61
+ // Apple takes their cut first
62
+ const applePercent = options?.apple_small_business
63
+ ? APPLE_IAP_SMALL_BUSINESS_FEE_PERCENT
64
+ : APPLE_IAP_FEE_PERCENT;
65
+ const appleCut = Math.round(totalCents * (applePercent / 100));
66
+ const afterApple = totalCents - appleCut;
67
+ // Then Portable and creator split the remainder
68
+ platformFeeCents = Math.round(afterApple * (platformFeePercent / 100));
69
+ creatorShareCents = afterApple - platformFeeCents;
70
+ // No additional Stripe fee for IAP (Apple handles payment processing)
71
+ stripeFeeCents = 0;
72
+ }
73
+ else {
74
+ // Google IAP
75
+ const googleCut = Math.round(totalCents * (GOOGLE_IAP_FEE_PERCENT / 100));
76
+ const afterGoogle = totalCents - googleCut;
77
+ platformFeeCents = Math.round(afterGoogle * (platformFeePercent / 100));
78
+ creatorShareCents = afterGoogle - platformFeeCents;
79
+ stripeFeeCents = 0;
80
+ }
81
+ // Creator's estimated net (after Stripe payout fees for Connect transfers)
82
+ // Connect transfers have a small fee, but for simplicity we estimate ~0
83
+ // since Stripe charges Connect fees to the connected account
84
+ const creatorNetCents = creatorShareCents;
85
+ return {
86
+ total_cents: totalCents,
87
+ platform_fee_cents: platformFeeCents,
88
+ creator_share_cents: creatorShareCents,
89
+ stripe_fee_cents: stripeFeeCents,
90
+ creator_net_cents: creatorNetCents,
91
+ platform_fee_percent: platformFeePercent,
92
+ creator_share_percent: creatorSharePercent,
93
+ revenue_source: revenueSource,
94
+ };
95
+ }
96
+ /**
97
+ * Calculate the Stripe application fee amount for a Connect destination charge.
98
+ * This is what Stripe deducts from the payment and sends to the platform.
99
+ */
100
+ function calculateApplicationFee(totalCents, platformFeePercent = exports.DEFAULT_REVENUE_CONFIG.platform_fee_percent) {
101
+ return Math.round(totalCents * (platformFeePercent / 100));
102
+ }
103
+ /**
104
+ * Validate that a revenue split adds up correctly.
105
+ */
106
+ function validateRevenueSplit(result) {
107
+ if (result.revenue_source === "stripe") {
108
+ return (result.platform_fee_cents + result.creator_share_cents ===
109
+ result.total_cents);
110
+ }
111
+ // For IAP, platform + creator should equal total minus store cut
112
+ return result.platform_fee_cents >= 0 && result.creator_share_cents >= 0;
113
+ }
114
+ /**
115
+ * Format cents to a human-readable dollar string.
116
+ */
117
+ function formatCents(cents) {
118
+ return `$${(cents / 100).toFixed(2)}`;
119
+ }
120
+ //# sourceMappingURL=revenue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"revenue.js","sourceRoot":"","sources":["../src/revenue.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AA2CH,sDA4DC;AAMD,0DAKC;AAKD,oDASC;AAKD,kCAEC;AA/HD,8EAA8E;AAC9E,WAAW;AACX,8EAA8E;AAE9E,0CAA0C;AAC7B,QAAA,sBAAsB,GAAuB;IACxD,oBAAoB,EAAE,EAAE;IACxB,qBAAqB,EAAE,EAAE;IACzB,oBAAoB,EAAE,IAAI,EAAE,cAAc;IAC1C,eAAe,EAAE,SAAS;CAC3B,CAAA;AAED,yCAAyC;AACzC,MAAM,kBAAkB,GAAG,GAAG,CAAA;AAC9B,MAAM,sBAAsB,GAAG,EAAE,CAAA;AAEjC,oCAAoC;AACpC,MAAM,qBAAqB,GAAG,EAAE,CAAA;AAEhC,6CAA6C;AAC7C,MAAM,oCAAoC,GAAG,EAAE,CAAA;AAE/C,sBAAsB;AACtB,MAAM,sBAAsB,GAAG,EAAE,CAAA;AAEjC,8EAA8E;AAC9E,4BAA4B;AAC5B,8EAA8E;AAE9E;;;;;GAKG;AACH,SAAgB,qBAAqB,CACnC,UAAkB,EAClB,SAAsC,EAAE,EACxC,gBAA+B,QAAQ,EACvC,OAA4C;IAE5C,MAAM,kBAAkB,GACtB,MAAM,CAAC,oBAAoB,IAAI,8BAAsB,CAAC,oBAAoB,CAAA;IAC5E,MAAM,mBAAmB,GAAG,GAAG,GAAG,kBAAkB,CAAA;IAEpD,IAAI,gBAAwB,CAAA;IAC5B,IAAI,iB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G,gBAAgB,CAAA;QAClD,cAAc,GAAG,CAAC,CAAA;IACpB,CAAC;IAED,2EAA2E;IAC3E,wEAAwE;IACxE,6DAA6D;IAC7D,MAAM,eAAe,GAAG,iBAAiB,CAAA;IAEzC,OAAO;QACL,WAAW,EAAE,UAAU;QACvB,kBAAkB,EAAE,gBAAgB;QACpC,mBAAmB,EAAE,iBAAiB;QACtC,gBAAgB,EAAE,cAAc;QAChC,iBAAiB,EAAE,eAAe;QAClC,oBAAoB,EAAE,kBAAkB;QACxC,qBAAqB,EAAE,mBAAmB;QAC1C,cAAc,EAAE,aAAa;KAC9B,CAAA;AACH,CAAC;AAED;;;GAGG;AACH,SAAgB,uBAAuB,CACrC,UAAkB,EAClB,qBAA6B,8BAAsB,CAAC,oBAAoB;IAExE,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,kBAAkB,GAAG,GAAG,CAAC,CAAC,CAAA;AAC5D,CAAC;AAED;;GAEG;AACH,SAAgB,oBAAoB,CAAC,MAA0B;IAC7D,IAAI,MAAM,CAAC,cAAc,KAAK,QAAQ,EAAE,CAAC;QACvC,OAAO,CACL,MAAM,CAAC,kBAAkB,GAAG,MAAM,CAAC,mBAAmB;YACtD,MAAM,CAAC,WAAW,CACnB,CAAA;IACH,CAAC;IACD,iEAAiE;IACjE,OAAO,MAAM,CAAC,kBAAkB,IAAI,CAAC,IAAI,MAAM,CAAC,mBAAmB,IAAI,CAAC,CAAA;AAC1E,CAAC;AAED;;GAEG;AACH,SAAgB,WAAW,CAAC,KAAa;IACvC,OAAO,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAA;AACvC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@portablecore/commerce",
3
+ "version": "0.1.0",
4
+ "description": "Shared marketplace commerce infrastructure for Portable platforms — Connect onboarding, revenue splits, and payout execution",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "default": "./dist/index.js"
11
+ },
12
+ "./connect": {
13
+ "types": "./dist/connect.d.ts",
14
+ "default": "./dist/connect.js"
15
+ },
16
+ "./revenue": {
17
+ "types": "./dist/revenue.d.ts",
18
+ "default": "./dist/revenue.js"
19
+ },
20
+ "./payout": {
21
+ "types": "./dist/payout.d.ts",
22
+ "default": "./dist/payout.js"
23
+ }
24
+ },
25
+ "files": [
26
+ "dist"
27
+ ],
28
+ "scripts": {
29
+ "build": "tsc",
30
+ "dev": "tsc --watch",
31
+ "clean": "rm -rf dist",
32
+ "typecheck": "tsc --noEmit"
33
+ },
34
+ "keywords": [
35
+ "portable",
36
+ "commerce",
37
+ "marketplace",
38
+ "stripe",
39
+ "connect",
40
+ "payout"
41
+ ],
42
+ "author": "Portable",
43
+ "license": "UNLICENSED",
44
+ "dependencies": {
45
+ "@portablecore/types": "^0.5.0"
46
+ },
47
+ "peerDependencies": {
48
+ "stripe": ">=14.0.0"
49
+ },
50
+ "devDependencies": {
51
+ "stripe": "^17.0.0",
52
+ "typescript": "^5.3.0"
53
+ }
54
+ }