@shware/purchase 0.0.3 → 0.0.5
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/dist/stripe/index.cjs +10 -76
- package/dist/stripe/index.cjs.map +1 -1
- package/dist/stripe/index.d.cts +7 -60
- package/dist/stripe/index.d.ts +7 -60
- package/dist/stripe/index.mjs +7 -71
- package/dist/stripe/index.mjs.map +1 -1
- package/dist/stripe/mapper.cjs +85 -0
- package/dist/stripe/mapper.cjs.map +1 -0
- package/dist/stripe/mapper.d.cts +30 -0
- package/dist/stripe/mapper.d.ts +30 -0
- package/dist/stripe/mapper.mjs +58 -0
- package/dist/stripe/mapper.mjs.map +1 -0
- package/dist/stripe/metadata.cjs +34 -0
- package/dist/stripe/metadata.cjs.map +1 -0
- package/dist/stripe/metadata.d.cts +6 -0
- package/dist/stripe/metadata.d.ts +6 -0
- package/dist/stripe/metadata.mjs +9 -0
- package/dist/stripe/metadata.mjs.map +1 -0
- package/dist/stripe/schema.cjs +57 -0
- package/dist/stripe/schema.cjs.map +1 -0
- package/dist/stripe/schema.d.cts +28 -0
- package/dist/stripe/schema.d.ts +28 -0
- package/dist/stripe/schema.mjs +39 -0
- package/dist/stripe/schema.mjs.map +1 -0
- package/dist/stripe/types.cjs +19 -0
- package/dist/stripe/types.cjs.map +1 -0
- package/dist/stripe/types.d.cts +12 -0
- package/dist/stripe/types.d.ts +12 -0
- package/dist/stripe/types.mjs +1 -0
- package/dist/stripe/types.mjs.map +1 -0
- package/package.json +1 -1
package/dist/stripe/index.cjs
CHANGED
|
@@ -20,88 +20,22 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/stripe/index.ts
|
|
21
21
|
var stripe_exports = {};
|
|
22
22
|
__export(stripe_exports, {
|
|
23
|
-
METADATA_KEYS: () => METADATA_KEYS,
|
|
24
|
-
cancellationDetailsSchema: () => cancellationDetailsSchema,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
METADATA_KEYS: () => import_metadata.METADATA_KEYS,
|
|
24
|
+
cancellationDetailsSchema: () => import_schema.cancellationDetailsSchema,
|
|
25
|
+
checkoutSessionSchema: () => import_schema.checkoutSessionSchema,
|
|
26
|
+
mapCheckoutSession: () => import_mapper.mapCheckoutSession,
|
|
27
|
+
mapStatus: () => import_mapper.mapStatus,
|
|
28
|
+
mapTime: () => import_mapper.mapTime
|
|
28
29
|
});
|
|
29
30
|
module.exports = __toCommonJS(stripe_exports);
|
|
30
|
-
var
|
|
31
|
-
var
|
|
32
|
-
var
|
|
33
|
-
USER_ID: "user_id",
|
|
34
|
-
PRODUCT_ID: "product_id"
|
|
35
|
-
};
|
|
36
|
-
function mapTime(stripeTimestampSeconds) {
|
|
37
|
-
if (!stripeTimestampSeconds) return null;
|
|
38
|
-
return new Date(stripeTimestampSeconds * 1e3).toISOString();
|
|
39
|
-
}
|
|
40
|
-
function mapCheckoutSession(session) {
|
|
41
|
-
return {
|
|
42
|
-
id: session.id,
|
|
43
|
-
url: session.url,
|
|
44
|
-
livemode: session.livemode,
|
|
45
|
-
expires_at: session.expires_at,
|
|
46
|
-
payment_status: session.payment_status,
|
|
47
|
-
currency: session.currency,
|
|
48
|
-
amount_total: session.amount_total,
|
|
49
|
-
line_items: session.line_items?.data.map((item) => ({
|
|
50
|
-
id: item.id,
|
|
51
|
-
currency: item.currency,
|
|
52
|
-
quantity: item.quantity,
|
|
53
|
-
description: item.description,
|
|
54
|
-
amount_tax: item.amount_tax,
|
|
55
|
-
amount_total: item.amount_total,
|
|
56
|
-
amount_subtotal: item.amount_subtotal,
|
|
57
|
-
amount_discount: item.amount_discount,
|
|
58
|
-
price: item.price ? { id: item.price.id } : null
|
|
59
|
-
})) ?? []
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
function mapStatus(status) {
|
|
63
|
-
switch (status) {
|
|
64
|
-
case "active":
|
|
65
|
-
return import_subscription.SubscriptionStatus.ACTIVE;
|
|
66
|
-
case "canceled":
|
|
67
|
-
return import_subscription.SubscriptionStatus.CANCELED;
|
|
68
|
-
case "incomplete":
|
|
69
|
-
return import_subscription.SubscriptionStatus.INCOMPLETE;
|
|
70
|
-
case "incomplete_expired":
|
|
71
|
-
return import_subscription.SubscriptionStatus.INCOMPLETE_EXPIRED;
|
|
72
|
-
case "past_due":
|
|
73
|
-
return import_subscription.SubscriptionStatus.PAST_DUE;
|
|
74
|
-
case "paused":
|
|
75
|
-
return import_subscription.SubscriptionStatus.PAUSED;
|
|
76
|
-
case "trialing":
|
|
77
|
-
return import_subscription.SubscriptionStatus.TRIALING;
|
|
78
|
-
case "unpaid":
|
|
79
|
-
return import_subscription.SubscriptionStatus.UNPAID;
|
|
80
|
-
default: {
|
|
81
|
-
console.error(`Invalid stripe status: ${status}`);
|
|
82
|
-
throw new Error(`Invalid stripe status: ${status}`);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
var cancellationDetailsSchema = (0, import_v4_mini.object)({
|
|
87
|
-
comment: (0, import_v4_mini.optional)((0, import_v4_mini.string)().check((0, import_v4_mini.maxLength)(1024))),
|
|
88
|
-
feedback: (0, import_v4_mini.optional)(
|
|
89
|
-
(0, import_v4_mini.enum)([
|
|
90
|
-
"customer_service",
|
|
91
|
-
"low_quality",
|
|
92
|
-
"missing_features",
|
|
93
|
-
"switched_service",
|
|
94
|
-
"too_complex",
|
|
95
|
-
"too_expensive",
|
|
96
|
-
"unused",
|
|
97
|
-
"other"
|
|
98
|
-
])
|
|
99
|
-
)
|
|
100
|
-
});
|
|
31
|
+
var import_mapper = require("./mapper.cjs");
|
|
32
|
+
var import_schema = require("./schema.cjs");
|
|
33
|
+
var import_metadata = require("./metadata.cjs");
|
|
101
34
|
// Annotate the CommonJS export names for ESM import in node:
|
|
102
35
|
0 && (module.exports = {
|
|
103
36
|
METADATA_KEYS,
|
|
104
37
|
cancellationDetailsSchema,
|
|
38
|
+
checkoutSessionSchema,
|
|
105
39
|
mapCheckoutSession,
|
|
106
40
|
mapStatus,
|
|
107
41
|
mapTime
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/stripe/index.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../src/stripe/index.ts"],"sourcesContent":["export { mapTime, mapStatus, mapCheckoutSession, type CheckoutSession } from './mapper';\nexport {\n cancellationDetailsSchema,\n checkoutSessionSchema,\n type CancellationDetails,\n} from './schema';\nexport type { ProductId, PriceId, Config } from './types';\nexport { METADATA_KEYS } from './metadata';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA6E;AAC7E,oBAIO;AAEP,sBAA8B;","names":[]}
|
package/dist/stripe/index.d.cts
CHANGED
|
@@ -1,60 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
type ProductId = Lowercase<string>;
|
|
10
|
-
type PriceId = `price_${string}`;
|
|
11
|
-
interface Config {
|
|
12
|
-
returnUrl: string;
|
|
13
|
-
cancelUrl: string;
|
|
14
|
-
successUrl: `${string}?session_id={CHECKOUT_SESSION_ID}`;
|
|
15
|
-
allowPromotionCodes: boolean;
|
|
16
|
-
payments: Record<ProductId, PriceId>;
|
|
17
|
-
subscriptions: Record<ProductId, PriceId>;
|
|
18
|
-
}
|
|
19
|
-
declare function mapTime<T extends number | null>(stripeTimestampSeconds: T): T extends number ? string : null;
|
|
20
|
-
declare function mapCheckoutSession(session: Stripe.Checkout.Session): {
|
|
21
|
-
id: string;
|
|
22
|
-
url: string | null;
|
|
23
|
-
livemode: boolean;
|
|
24
|
-
expires_at: number;
|
|
25
|
-
payment_status: Stripe.Checkout.Session.PaymentStatus;
|
|
26
|
-
currency: string | null;
|
|
27
|
-
amount_total: number | null;
|
|
28
|
-
line_items: {
|
|
29
|
-
id: string;
|
|
30
|
-
currency: string;
|
|
31
|
-
quantity: number | null;
|
|
32
|
-
description: string | null;
|
|
33
|
-
amount_tax: number;
|
|
34
|
-
amount_total: number;
|
|
35
|
-
amount_subtotal: number;
|
|
36
|
-
amount_discount: number;
|
|
37
|
-
price: {
|
|
38
|
-
id: string;
|
|
39
|
-
} | null;
|
|
40
|
-
}[];
|
|
41
|
-
};
|
|
42
|
-
declare function mapStatus(status: Stripe.Subscription.Status): SubscriptionStatus;
|
|
43
|
-
declare const cancellationDetailsSchema: z.ZodMiniObject<{
|
|
44
|
-
comment: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
45
|
-
feedback: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
46
|
-
customer_service: "customer_service";
|
|
47
|
-
low_quality: "low_quality";
|
|
48
|
-
missing_features: "missing_features";
|
|
49
|
-
switched_service: "switched_service";
|
|
50
|
-
too_complex: "too_complex";
|
|
51
|
-
too_expensive: "too_expensive";
|
|
52
|
-
unused: "unused";
|
|
53
|
-
other: "other";
|
|
54
|
-
}>>;
|
|
55
|
-
}, z.core.$strip>;
|
|
56
|
-
interface CancellationDetails extends z.output<typeof cancellationDetailsSchema> {
|
|
57
|
-
reason?: 'cancellation_requested' | 'payment_disputed' | 'payment_failed';
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export { type CancellationDetails, type Config, METADATA_KEYS, type PriceId, type ProductId, cancellationDetailsSchema, mapCheckoutSession, mapStatus, mapTime };
|
|
1
|
+
export { CheckoutSession, mapCheckoutSession, mapStatus, mapTime } from './mapper.cjs';
|
|
2
|
+
export { CancellationDetails, cancellationDetailsSchema, checkoutSessionSchema } from './schema.cjs';
|
|
3
|
+
export { Config, PriceId, ProductId } from './types.cjs';
|
|
4
|
+
export { METADATA_KEYS } from './metadata.cjs';
|
|
5
|
+
import 'stripe';
|
|
6
|
+
import '../subscription/index.cjs';
|
|
7
|
+
import 'zod/v4-mini';
|
package/dist/stripe/index.d.ts
CHANGED
|
@@ -1,60 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
type ProductId = Lowercase<string>;
|
|
10
|
-
type PriceId = `price_${string}`;
|
|
11
|
-
interface Config {
|
|
12
|
-
returnUrl: string;
|
|
13
|
-
cancelUrl: string;
|
|
14
|
-
successUrl: `${string}?session_id={CHECKOUT_SESSION_ID}`;
|
|
15
|
-
allowPromotionCodes: boolean;
|
|
16
|
-
payments: Record<ProductId, PriceId>;
|
|
17
|
-
subscriptions: Record<ProductId, PriceId>;
|
|
18
|
-
}
|
|
19
|
-
declare function mapTime<T extends number | null>(stripeTimestampSeconds: T): T extends number ? string : null;
|
|
20
|
-
declare function mapCheckoutSession(session: Stripe.Checkout.Session): {
|
|
21
|
-
id: string;
|
|
22
|
-
url: string | null;
|
|
23
|
-
livemode: boolean;
|
|
24
|
-
expires_at: number;
|
|
25
|
-
payment_status: Stripe.Checkout.Session.PaymentStatus;
|
|
26
|
-
currency: string | null;
|
|
27
|
-
amount_total: number | null;
|
|
28
|
-
line_items: {
|
|
29
|
-
id: string;
|
|
30
|
-
currency: string;
|
|
31
|
-
quantity: number | null;
|
|
32
|
-
description: string | null;
|
|
33
|
-
amount_tax: number;
|
|
34
|
-
amount_total: number;
|
|
35
|
-
amount_subtotal: number;
|
|
36
|
-
amount_discount: number;
|
|
37
|
-
price: {
|
|
38
|
-
id: string;
|
|
39
|
-
} | null;
|
|
40
|
-
}[];
|
|
41
|
-
};
|
|
42
|
-
declare function mapStatus(status: Stripe.Subscription.Status): SubscriptionStatus;
|
|
43
|
-
declare const cancellationDetailsSchema: z.ZodMiniObject<{
|
|
44
|
-
comment: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
45
|
-
feedback: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
46
|
-
customer_service: "customer_service";
|
|
47
|
-
low_quality: "low_quality";
|
|
48
|
-
missing_features: "missing_features";
|
|
49
|
-
switched_service: "switched_service";
|
|
50
|
-
too_complex: "too_complex";
|
|
51
|
-
too_expensive: "too_expensive";
|
|
52
|
-
unused: "unused";
|
|
53
|
-
other: "other";
|
|
54
|
-
}>>;
|
|
55
|
-
}, z.core.$strip>;
|
|
56
|
-
interface CancellationDetails extends z.output<typeof cancellationDetailsSchema> {
|
|
57
|
-
reason?: 'cancellation_requested' | 'payment_disputed' | 'payment_failed';
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export { type CancellationDetails, type Config, METADATA_KEYS, type PriceId, type ProductId, cancellationDetailsSchema, mapCheckoutSession, mapStatus, mapTime };
|
|
1
|
+
export { CheckoutSession, mapCheckoutSession, mapStatus, mapTime } from './mapper.js';
|
|
2
|
+
export { CancellationDetails, cancellationDetailsSchema, checkoutSessionSchema } from './schema.js';
|
|
3
|
+
export { Config, PriceId, ProductId } from './types.js';
|
|
4
|
+
export { METADATA_KEYS } from './metadata.js';
|
|
5
|
+
import 'stripe';
|
|
6
|
+
import '../subscription/index.js';
|
|
7
|
+
import 'zod/v4-mini';
|
package/dist/stripe/index.mjs
CHANGED
|
@@ -1,78 +1,14 @@
|
|
|
1
1
|
// src/stripe/index.ts
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
function mapTime(stripeTimestampSeconds) {
|
|
9
|
-
if (!stripeTimestampSeconds) return null;
|
|
10
|
-
return new Date(stripeTimestampSeconds * 1e3).toISOString();
|
|
11
|
-
}
|
|
12
|
-
function mapCheckoutSession(session) {
|
|
13
|
-
return {
|
|
14
|
-
id: session.id,
|
|
15
|
-
url: session.url,
|
|
16
|
-
livemode: session.livemode,
|
|
17
|
-
expires_at: session.expires_at,
|
|
18
|
-
payment_status: session.payment_status,
|
|
19
|
-
currency: session.currency,
|
|
20
|
-
amount_total: session.amount_total,
|
|
21
|
-
line_items: session.line_items?.data.map((item) => ({
|
|
22
|
-
id: item.id,
|
|
23
|
-
currency: item.currency,
|
|
24
|
-
quantity: item.quantity,
|
|
25
|
-
description: item.description,
|
|
26
|
-
amount_tax: item.amount_tax,
|
|
27
|
-
amount_total: item.amount_total,
|
|
28
|
-
amount_subtotal: item.amount_subtotal,
|
|
29
|
-
amount_discount: item.amount_discount,
|
|
30
|
-
price: item.price ? { id: item.price.id } : null
|
|
31
|
-
})) ?? []
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
function mapStatus(status) {
|
|
35
|
-
switch (status) {
|
|
36
|
-
case "active":
|
|
37
|
-
return SubscriptionStatus.ACTIVE;
|
|
38
|
-
case "canceled":
|
|
39
|
-
return SubscriptionStatus.CANCELED;
|
|
40
|
-
case "incomplete":
|
|
41
|
-
return SubscriptionStatus.INCOMPLETE;
|
|
42
|
-
case "incomplete_expired":
|
|
43
|
-
return SubscriptionStatus.INCOMPLETE_EXPIRED;
|
|
44
|
-
case "past_due":
|
|
45
|
-
return SubscriptionStatus.PAST_DUE;
|
|
46
|
-
case "paused":
|
|
47
|
-
return SubscriptionStatus.PAUSED;
|
|
48
|
-
case "trialing":
|
|
49
|
-
return SubscriptionStatus.TRIALING;
|
|
50
|
-
case "unpaid":
|
|
51
|
-
return SubscriptionStatus.UNPAID;
|
|
52
|
-
default: {
|
|
53
|
-
console.error(`Invalid stripe status: ${status}`);
|
|
54
|
-
throw new Error(`Invalid stripe status: ${status}`);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
var cancellationDetailsSchema = object({
|
|
59
|
-
comment: optional(string().check(maxLength(1024))),
|
|
60
|
-
feedback: optional(
|
|
61
|
-
_enum([
|
|
62
|
-
"customer_service",
|
|
63
|
-
"low_quality",
|
|
64
|
-
"missing_features",
|
|
65
|
-
"switched_service",
|
|
66
|
-
"too_complex",
|
|
67
|
-
"too_expensive",
|
|
68
|
-
"unused",
|
|
69
|
-
"other"
|
|
70
|
-
])
|
|
71
|
-
)
|
|
72
|
-
});
|
|
2
|
+
import { mapTime, mapStatus, mapCheckoutSession } from "./mapper.mjs";
|
|
3
|
+
import {
|
|
4
|
+
cancellationDetailsSchema,
|
|
5
|
+
checkoutSessionSchema
|
|
6
|
+
} from "./schema.mjs";
|
|
7
|
+
import { METADATA_KEYS } from "./metadata.mjs";
|
|
73
8
|
export {
|
|
74
9
|
METADATA_KEYS,
|
|
75
10
|
cancellationDetailsSchema,
|
|
11
|
+
checkoutSessionSchema,
|
|
76
12
|
mapCheckoutSession,
|
|
77
13
|
mapStatus,
|
|
78
14
|
mapTime
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/stripe/index.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../src/stripe/index.ts"],"sourcesContent":["export { mapTime, mapStatus, mapCheckoutSession, type CheckoutSession } from './mapper';\nexport {\n cancellationDetailsSchema,\n checkoutSessionSchema,\n type CancellationDetails,\n} from './schema';\nexport type { ProductId, PriceId, Config } from './types';\nexport { METADATA_KEYS } from './metadata';\n"],"mappings":";AAAA,SAAS,SAAS,WAAW,0BAAgD;AAC7E;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AAEP,SAAS,qBAAqB;","names":[]}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/stripe/mapper.ts
|
|
21
|
+
var mapper_exports = {};
|
|
22
|
+
__export(mapper_exports, {
|
|
23
|
+
mapCheckoutSession: () => mapCheckoutSession,
|
|
24
|
+
mapStatus: () => mapStatus,
|
|
25
|
+
mapTime: () => mapTime
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(mapper_exports);
|
|
28
|
+
var import_subscription = require("../subscription/index.cjs");
|
|
29
|
+
function mapTime(stripeTimestampSeconds) {
|
|
30
|
+
if (!stripeTimestampSeconds) return null;
|
|
31
|
+
return new Date(stripeTimestampSeconds * 1e3).toISOString();
|
|
32
|
+
}
|
|
33
|
+
function mapCheckoutSession(session) {
|
|
34
|
+
return {
|
|
35
|
+
id: session.id,
|
|
36
|
+
url: session.url,
|
|
37
|
+
livemode: session.livemode,
|
|
38
|
+
expires_at: session.expires_at,
|
|
39
|
+
payment_status: session.payment_status,
|
|
40
|
+
currency: session.currency,
|
|
41
|
+
amount_total: session.amount_total,
|
|
42
|
+
line_items: session.line_items?.data.map((item) => ({
|
|
43
|
+
id: item.id,
|
|
44
|
+
currency: item.currency,
|
|
45
|
+
quantity: item.quantity,
|
|
46
|
+
description: item.description,
|
|
47
|
+
amount_tax: item.amount_tax,
|
|
48
|
+
amount_total: item.amount_total,
|
|
49
|
+
amount_subtotal: item.amount_subtotal,
|
|
50
|
+
amount_discount: item.amount_discount,
|
|
51
|
+
price: item.price ? { id: item.price.id } : null
|
|
52
|
+
})) ?? []
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function mapStatus(status) {
|
|
56
|
+
switch (status) {
|
|
57
|
+
case "active":
|
|
58
|
+
return import_subscription.SubscriptionStatus.ACTIVE;
|
|
59
|
+
case "canceled":
|
|
60
|
+
return import_subscription.SubscriptionStatus.CANCELED;
|
|
61
|
+
case "incomplete":
|
|
62
|
+
return import_subscription.SubscriptionStatus.INCOMPLETE;
|
|
63
|
+
case "incomplete_expired":
|
|
64
|
+
return import_subscription.SubscriptionStatus.INCOMPLETE_EXPIRED;
|
|
65
|
+
case "past_due":
|
|
66
|
+
return import_subscription.SubscriptionStatus.PAST_DUE;
|
|
67
|
+
case "paused":
|
|
68
|
+
return import_subscription.SubscriptionStatus.PAUSED;
|
|
69
|
+
case "trialing":
|
|
70
|
+
return import_subscription.SubscriptionStatus.TRIALING;
|
|
71
|
+
case "unpaid":
|
|
72
|
+
return import_subscription.SubscriptionStatus.UNPAID;
|
|
73
|
+
default: {
|
|
74
|
+
console.error(`Invalid stripe status: ${status}`);
|
|
75
|
+
throw new Error(`Invalid stripe status: ${status}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
80
|
+
0 && (module.exports = {
|
|
81
|
+
mapCheckoutSession,
|
|
82
|
+
mapStatus,
|
|
83
|
+
mapTime
|
|
84
|
+
});
|
|
85
|
+
//# sourceMappingURL=mapper.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/stripe/mapper.ts"],"sourcesContent":["import type Stripe from 'stripe';\nimport { SubscriptionStatus } from '../subscription/index';\n\nexport function mapTime<T extends number | null>(\n stripeTimestampSeconds: T\n): T extends number ? string : null {\n if (!stripeTimestampSeconds) return null as T extends number ? string : null;\n return new Date(stripeTimestampSeconds * 1000).toISOString() as T extends number ? string : null;\n}\n\nexport function mapCheckoutSession(session: Stripe.Checkout.Session) {\n return {\n id: session.id,\n url: session.url,\n livemode: session.livemode,\n expires_at: session.expires_at,\n payment_status: session.payment_status,\n currency: session.currency,\n amount_total: session.amount_total,\n line_items:\n session.line_items?.data.map((item) => ({\n id: item.id,\n currency: item.currency,\n quantity: item.quantity,\n description: item.description,\n amount_tax: item.amount_tax,\n amount_total: item.amount_total,\n amount_subtotal: item.amount_subtotal,\n amount_discount: item.amount_discount,\n price: item.price ? { id: item.price.id } : null,\n })) ?? [],\n };\n}\n\nexport type CheckoutSession = ReturnType<typeof mapCheckoutSession>;\n\nexport function mapStatus(status: Stripe.Subscription.Status): SubscriptionStatus {\n switch (status) {\n case 'active':\n return SubscriptionStatus.ACTIVE;\n case 'canceled':\n return SubscriptionStatus.CANCELED;\n case 'incomplete':\n return SubscriptionStatus.INCOMPLETE;\n case 'incomplete_expired':\n return SubscriptionStatus.INCOMPLETE_EXPIRED;\n case 'past_due':\n return SubscriptionStatus.PAST_DUE;\n case 'paused':\n return SubscriptionStatus.PAUSED;\n case 'trialing':\n return SubscriptionStatus.TRIALING;\n case 'unpaid':\n return SubscriptionStatus.UNPAID;\n default: {\n console.error(`Invalid stripe status: ${status}`);\n throw new Error(`Invalid stripe status: ${status}`);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,0BAAmC;AAE5B,SAAS,QACd,wBACkC;AAClC,MAAI,CAAC,uBAAwB,QAAO;AACpC,SAAO,IAAI,KAAK,yBAAyB,GAAI,EAAE,YAAY;AAC7D;AAEO,SAAS,mBAAmB,SAAkC;AACnE,SAAO;AAAA,IACL,IAAI,QAAQ;AAAA,IACZ,KAAK,QAAQ;AAAA,IACb,UAAU,QAAQ;AAAA,IAClB,YAAY,QAAQ;AAAA,IACpB,gBAAgB,QAAQ;AAAA,IACxB,UAAU,QAAQ;AAAA,IAClB,cAAc,QAAQ;AAAA,IACtB,YACE,QAAQ,YAAY,KAAK,IAAI,CAAC,UAAU;AAAA,MACtC,IAAI,KAAK;AAAA,MACT,UAAU,KAAK;AAAA,MACf,UAAU,KAAK;AAAA,MACf,aAAa,KAAK;AAAA,MAClB,YAAY,KAAK;AAAA,MACjB,cAAc,KAAK;AAAA,MACnB,iBAAiB,KAAK;AAAA,MACtB,iBAAiB,KAAK;AAAA,MACtB,OAAO,KAAK,QAAQ,EAAE,IAAI,KAAK,MAAM,GAAG,IAAI;AAAA,IAC9C,EAAE,KAAK,CAAC;AAAA,EACZ;AACF;AAIO,SAAS,UAAU,QAAwD;AAChF,UAAQ,QAAQ;AAAA,IACd,KAAK;AACH,aAAO,uCAAmB;AAAA,IAC5B,KAAK;AACH,aAAO,uCAAmB;AAAA,IAC5B,KAAK;AACH,aAAO,uCAAmB;AAAA,IAC5B,KAAK;AACH,aAAO,uCAAmB;AAAA,IAC5B,KAAK;AACH,aAAO,uCAAmB;AAAA,IAC5B,KAAK;AACH,aAAO,uCAAmB;AAAA,IAC5B,KAAK;AACH,aAAO,uCAAmB;AAAA,IAC5B,KAAK;AACH,aAAO,uCAAmB;AAAA,IAC5B,SAAS;AACP,cAAQ,MAAM,0BAA0B,MAAM,EAAE;AAChD,YAAM,IAAI,MAAM,0BAA0B,MAAM,EAAE;AAAA,IACpD;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import Stripe from 'stripe';
|
|
2
|
+
import { SubscriptionStatus } from '../subscription/index.cjs';
|
|
3
|
+
|
|
4
|
+
declare function mapTime<T extends number | null>(stripeTimestampSeconds: T): T extends number ? string : null;
|
|
5
|
+
declare function mapCheckoutSession(session: Stripe.Checkout.Session): {
|
|
6
|
+
id: string;
|
|
7
|
+
url: string | null;
|
|
8
|
+
livemode: boolean;
|
|
9
|
+
expires_at: number;
|
|
10
|
+
payment_status: Stripe.Checkout.Session.PaymentStatus;
|
|
11
|
+
currency: string | null;
|
|
12
|
+
amount_total: number | null;
|
|
13
|
+
line_items: {
|
|
14
|
+
id: string;
|
|
15
|
+
currency: string;
|
|
16
|
+
quantity: number | null;
|
|
17
|
+
description: string | null;
|
|
18
|
+
amount_tax: number;
|
|
19
|
+
amount_total: number;
|
|
20
|
+
amount_subtotal: number;
|
|
21
|
+
amount_discount: number;
|
|
22
|
+
price: {
|
|
23
|
+
id: string;
|
|
24
|
+
} | null;
|
|
25
|
+
}[];
|
|
26
|
+
};
|
|
27
|
+
type CheckoutSession = ReturnType<typeof mapCheckoutSession>;
|
|
28
|
+
declare function mapStatus(status: Stripe.Subscription.Status): SubscriptionStatus;
|
|
29
|
+
|
|
30
|
+
export { type CheckoutSession, mapCheckoutSession, mapStatus, mapTime };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import Stripe from 'stripe';
|
|
2
|
+
import { SubscriptionStatus } from '../subscription/index.js';
|
|
3
|
+
|
|
4
|
+
declare function mapTime<T extends number | null>(stripeTimestampSeconds: T): T extends number ? string : null;
|
|
5
|
+
declare function mapCheckoutSession(session: Stripe.Checkout.Session): {
|
|
6
|
+
id: string;
|
|
7
|
+
url: string | null;
|
|
8
|
+
livemode: boolean;
|
|
9
|
+
expires_at: number;
|
|
10
|
+
payment_status: Stripe.Checkout.Session.PaymentStatus;
|
|
11
|
+
currency: string | null;
|
|
12
|
+
amount_total: number | null;
|
|
13
|
+
line_items: {
|
|
14
|
+
id: string;
|
|
15
|
+
currency: string;
|
|
16
|
+
quantity: number | null;
|
|
17
|
+
description: string | null;
|
|
18
|
+
amount_tax: number;
|
|
19
|
+
amount_total: number;
|
|
20
|
+
amount_subtotal: number;
|
|
21
|
+
amount_discount: number;
|
|
22
|
+
price: {
|
|
23
|
+
id: string;
|
|
24
|
+
} | null;
|
|
25
|
+
}[];
|
|
26
|
+
};
|
|
27
|
+
type CheckoutSession = ReturnType<typeof mapCheckoutSession>;
|
|
28
|
+
declare function mapStatus(status: Stripe.Subscription.Status): SubscriptionStatus;
|
|
29
|
+
|
|
30
|
+
export { type CheckoutSession, mapCheckoutSession, mapStatus, mapTime };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// src/stripe/mapper.ts
|
|
2
|
+
import { SubscriptionStatus } from "../subscription/index.mjs";
|
|
3
|
+
function mapTime(stripeTimestampSeconds) {
|
|
4
|
+
if (!stripeTimestampSeconds) return null;
|
|
5
|
+
return new Date(stripeTimestampSeconds * 1e3).toISOString();
|
|
6
|
+
}
|
|
7
|
+
function mapCheckoutSession(session) {
|
|
8
|
+
return {
|
|
9
|
+
id: session.id,
|
|
10
|
+
url: session.url,
|
|
11
|
+
livemode: session.livemode,
|
|
12
|
+
expires_at: session.expires_at,
|
|
13
|
+
payment_status: session.payment_status,
|
|
14
|
+
currency: session.currency,
|
|
15
|
+
amount_total: session.amount_total,
|
|
16
|
+
line_items: session.line_items?.data.map((item) => ({
|
|
17
|
+
id: item.id,
|
|
18
|
+
currency: item.currency,
|
|
19
|
+
quantity: item.quantity,
|
|
20
|
+
description: item.description,
|
|
21
|
+
amount_tax: item.amount_tax,
|
|
22
|
+
amount_total: item.amount_total,
|
|
23
|
+
amount_subtotal: item.amount_subtotal,
|
|
24
|
+
amount_discount: item.amount_discount,
|
|
25
|
+
price: item.price ? { id: item.price.id } : null
|
|
26
|
+
})) ?? []
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function mapStatus(status) {
|
|
30
|
+
switch (status) {
|
|
31
|
+
case "active":
|
|
32
|
+
return SubscriptionStatus.ACTIVE;
|
|
33
|
+
case "canceled":
|
|
34
|
+
return SubscriptionStatus.CANCELED;
|
|
35
|
+
case "incomplete":
|
|
36
|
+
return SubscriptionStatus.INCOMPLETE;
|
|
37
|
+
case "incomplete_expired":
|
|
38
|
+
return SubscriptionStatus.INCOMPLETE_EXPIRED;
|
|
39
|
+
case "past_due":
|
|
40
|
+
return SubscriptionStatus.PAST_DUE;
|
|
41
|
+
case "paused":
|
|
42
|
+
return SubscriptionStatus.PAUSED;
|
|
43
|
+
case "trialing":
|
|
44
|
+
return SubscriptionStatus.TRIALING;
|
|
45
|
+
case "unpaid":
|
|
46
|
+
return SubscriptionStatus.UNPAID;
|
|
47
|
+
default: {
|
|
48
|
+
console.error(`Invalid stripe status: ${status}`);
|
|
49
|
+
throw new Error(`Invalid stripe status: ${status}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
mapCheckoutSession,
|
|
55
|
+
mapStatus,
|
|
56
|
+
mapTime
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=mapper.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/stripe/mapper.ts"],"sourcesContent":["import type Stripe from 'stripe';\nimport { SubscriptionStatus } from '../subscription/index';\n\nexport function mapTime<T extends number | null>(\n stripeTimestampSeconds: T\n): T extends number ? string : null {\n if (!stripeTimestampSeconds) return null as T extends number ? string : null;\n return new Date(stripeTimestampSeconds * 1000).toISOString() as T extends number ? string : null;\n}\n\nexport function mapCheckoutSession(session: Stripe.Checkout.Session) {\n return {\n id: session.id,\n url: session.url,\n livemode: session.livemode,\n expires_at: session.expires_at,\n payment_status: session.payment_status,\n currency: session.currency,\n amount_total: session.amount_total,\n line_items:\n session.line_items?.data.map((item) => ({\n id: item.id,\n currency: item.currency,\n quantity: item.quantity,\n description: item.description,\n amount_tax: item.amount_tax,\n amount_total: item.amount_total,\n amount_subtotal: item.amount_subtotal,\n amount_discount: item.amount_discount,\n price: item.price ? { id: item.price.id } : null,\n })) ?? [],\n };\n}\n\nexport type CheckoutSession = ReturnType<typeof mapCheckoutSession>;\n\nexport function mapStatus(status: Stripe.Subscription.Status): SubscriptionStatus {\n switch (status) {\n case 'active':\n return SubscriptionStatus.ACTIVE;\n case 'canceled':\n return SubscriptionStatus.CANCELED;\n case 'incomplete':\n return SubscriptionStatus.INCOMPLETE;\n case 'incomplete_expired':\n return SubscriptionStatus.INCOMPLETE_EXPIRED;\n case 'past_due':\n return SubscriptionStatus.PAST_DUE;\n case 'paused':\n return SubscriptionStatus.PAUSED;\n case 'trialing':\n return SubscriptionStatus.TRIALING;\n case 'unpaid':\n return SubscriptionStatus.UNPAID;\n default: {\n console.error(`Invalid stripe status: ${status}`);\n throw new Error(`Invalid stripe status: ${status}`);\n }\n }\n}\n"],"mappings":";AACA,SAAS,0BAA0B;AAE5B,SAAS,QACd,wBACkC;AAClC,MAAI,CAAC,uBAAwB,QAAO;AACpC,SAAO,IAAI,KAAK,yBAAyB,GAAI,EAAE,YAAY;AAC7D;AAEO,SAAS,mBAAmB,SAAkC;AACnE,SAAO;AAAA,IACL,IAAI,QAAQ;AAAA,IACZ,KAAK,QAAQ;AAAA,IACb,UAAU,QAAQ;AAAA,IAClB,YAAY,QAAQ;AAAA,IACpB,gBAAgB,QAAQ;AAAA,IACxB,UAAU,QAAQ;AAAA,IAClB,cAAc,QAAQ;AAAA,IACtB,YACE,QAAQ,YAAY,KAAK,IAAI,CAAC,UAAU;AAAA,MACtC,IAAI,KAAK;AAAA,MACT,UAAU,KAAK;AAAA,MACf,UAAU,KAAK;AAAA,MACf,aAAa,KAAK;AAAA,MAClB,YAAY,KAAK;AAAA,MACjB,cAAc,KAAK;AAAA,MACnB,iBAAiB,KAAK;AAAA,MACtB,iBAAiB,KAAK;AAAA,MACtB,OAAO,KAAK,QAAQ,EAAE,IAAI,KAAK,MAAM,GAAG,IAAI;AAAA,IAC9C,EAAE,KAAK,CAAC;AAAA,EACZ;AACF;AAIO,SAAS,UAAU,QAAwD;AAChF,UAAQ,QAAQ;AAAA,IACd,KAAK;AACH,aAAO,mBAAmB;AAAA,IAC5B,KAAK;AACH,aAAO,mBAAmB;AAAA,IAC5B,KAAK;AACH,aAAO,mBAAmB;AAAA,IAC5B,KAAK;AACH,aAAO,mBAAmB;AAAA,IAC5B,KAAK;AACH,aAAO,mBAAmB;AAAA,IAC5B,KAAK;AACH,aAAO,mBAAmB;AAAA,IAC5B,KAAK;AACH,aAAO,mBAAmB;AAAA,IAC5B,KAAK;AACH,aAAO,mBAAmB;AAAA,IAC5B,SAAS;AACP,cAAQ,MAAM,0BAA0B,MAAM,EAAE;AAChD,YAAM,IAAI,MAAM,0BAA0B,MAAM,EAAE;AAAA,IACpD;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/stripe/metadata.ts
|
|
21
|
+
var metadata_exports = {};
|
|
22
|
+
__export(metadata_exports, {
|
|
23
|
+
METADATA_KEYS: () => METADATA_KEYS
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(metadata_exports);
|
|
26
|
+
var METADATA_KEYS = {
|
|
27
|
+
USER_ID: "user_id",
|
|
28
|
+
PRODUCT_ID: "product_id"
|
|
29
|
+
};
|
|
30
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
+
0 && (module.exports = {
|
|
32
|
+
METADATA_KEYS
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=metadata.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/stripe/metadata.ts"],"sourcesContent":["export const METADATA_KEYS = {\n USER_ID: 'user_id',\n PRODUCT_ID: 'product_id',\n} as const;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,IAAM,gBAAgB;AAAA,EAC3B,SAAS;AAAA,EACT,YAAY;AACd;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/stripe/metadata.ts"],"sourcesContent":["export const METADATA_KEYS = {\n USER_ID: 'user_id',\n PRODUCT_ID: 'product_id',\n} as const;\n"],"mappings":";AAAO,IAAM,gBAAgB;AAAA,EAC3B,SAAS;AAAA,EACT,YAAY;AACd;","names":[]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/stripe/schema.ts
|
|
21
|
+
var schema_exports = {};
|
|
22
|
+
__export(schema_exports, {
|
|
23
|
+
cancellationDetailsSchema: () => cancellationDetailsSchema,
|
|
24
|
+
checkoutSessionSchema: () => checkoutSessionSchema
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(schema_exports);
|
|
27
|
+
var import_v4_mini = require("zod/v4-mini");
|
|
28
|
+
var cancellationDetailsSchema = (0, import_v4_mini.object)({
|
|
29
|
+
comment: (0, import_v4_mini.optional)((0, import_v4_mini.nullable)((0, import_v4_mini.string)().check((0, import_v4_mini.maxLength)(1024)))),
|
|
30
|
+
feedback: (0, import_v4_mini.optional)(
|
|
31
|
+
(0, import_v4_mini.nullable)(
|
|
32
|
+
(0, import_v4_mini.enum)([
|
|
33
|
+
"customer_service",
|
|
34
|
+
"low_quality",
|
|
35
|
+
"missing_features",
|
|
36
|
+
"switched_service",
|
|
37
|
+
"too_complex",
|
|
38
|
+
"too_expensive",
|
|
39
|
+
"unused",
|
|
40
|
+
"other"
|
|
41
|
+
])
|
|
42
|
+
)
|
|
43
|
+
)
|
|
44
|
+
});
|
|
45
|
+
function checkoutSessionSchema(productIds) {
|
|
46
|
+
return (0, import_v4_mini.object)({
|
|
47
|
+
productId: (0, import_v4_mini.enum)(productIds),
|
|
48
|
+
cancelUrl: (0, import_v4_mini.optional)((0, import_v4_mini.url)()),
|
|
49
|
+
successUrl: (0, import_v4_mini.optional)((0, import_v4_mini.url)())
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
53
|
+
0 && (module.exports = {
|
|
54
|
+
cancellationDetailsSchema,
|
|
55
|
+
checkoutSessionSchema
|
|
56
|
+
});
|
|
57
|
+
//# sourceMappingURL=schema.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/stripe/schema.ts"],"sourcesContent":["import {\n maxLength,\n object,\n optional,\n nullable,\n string,\n enum as _enum,\n url,\n type z,\n} from 'zod/v4-mini';\nimport type { ProductId } from './types';\n\nexport const cancellationDetailsSchema = object({\n comment: optional(nullable(string().check(maxLength(1024)))),\n feedback: optional(\n nullable(\n _enum([\n 'customer_service',\n 'low_quality',\n 'missing_features',\n 'switched_service',\n 'too_complex',\n 'too_expensive',\n 'unused',\n 'other',\n ])\n )\n ),\n});\n\nexport function checkoutSessionSchema(productIds: [ProductId, ...ProductId[]]) {\n return object({\n productId: _enum(productIds),\n cancelUrl: optional(url()),\n successUrl: optional(url()),\n });\n}\n\nexport interface CancellationDetails extends z.output<typeof cancellationDetailsSchema> {\n reason?: 'cancellation_requested' | 'payment_disputed' | 'payment_failed' | null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBASO;AAGA,IAAM,gCAA4B,uBAAO;AAAA,EAC9C,aAAS,6BAAS,6BAAS,uBAAO,EAAE,UAAM,0BAAU,IAAI,CAAC,CAAC,CAAC;AAAA,EAC3D,cAAU;AAAA,QACR;AAAA,UACE,eAAAA,MAAM;AAAA,QACJ;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF,CAAC;AAEM,SAAS,sBAAsB,YAAyC;AAC7E,aAAO,uBAAO;AAAA,IACZ,eAAW,eAAAA,MAAM,UAAU;AAAA,IAC3B,eAAW,6BAAS,oBAAI,CAAC;AAAA,IACzB,gBAAY,6BAAS,oBAAI,CAAC;AAAA,EAC5B,CAAC;AACH;","names":["_enum"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z } from 'zod/v4-mini';
|
|
2
|
+
import { ProductId } from './types.cjs';
|
|
3
|
+
|
|
4
|
+
declare const cancellationDetailsSchema: z.ZodMiniObject<{
|
|
5
|
+
comment: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniString<string>>>;
|
|
6
|
+
feedback: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniEnum<{
|
|
7
|
+
customer_service: "customer_service";
|
|
8
|
+
low_quality: "low_quality";
|
|
9
|
+
missing_features: "missing_features";
|
|
10
|
+
switched_service: "switched_service";
|
|
11
|
+
too_complex: "too_complex";
|
|
12
|
+
too_expensive: "too_expensive";
|
|
13
|
+
unused: "unused";
|
|
14
|
+
other: "other";
|
|
15
|
+
}>>>;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
declare function checkoutSessionSchema(productIds: [ProductId, ...ProductId[]]): z.ZodMiniObject<{
|
|
18
|
+
productId: z.ZodMiniEnum<{
|
|
19
|
+
[x: Lowercase<string>]: Lowercase<string>;
|
|
20
|
+
}>;
|
|
21
|
+
cancelUrl: z.ZodMiniOptional<z.ZodMiniURL>;
|
|
22
|
+
successUrl: z.ZodMiniOptional<z.ZodMiniURL>;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
interface CancellationDetails extends z.output<typeof cancellationDetailsSchema> {
|
|
25
|
+
reason?: 'cancellation_requested' | 'payment_disputed' | 'payment_failed' | null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { type CancellationDetails, cancellationDetailsSchema, checkoutSessionSchema };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z } from 'zod/v4-mini';
|
|
2
|
+
import { ProductId } from './types.js';
|
|
3
|
+
|
|
4
|
+
declare const cancellationDetailsSchema: z.ZodMiniObject<{
|
|
5
|
+
comment: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniString<string>>>;
|
|
6
|
+
feedback: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniEnum<{
|
|
7
|
+
customer_service: "customer_service";
|
|
8
|
+
low_quality: "low_quality";
|
|
9
|
+
missing_features: "missing_features";
|
|
10
|
+
switched_service: "switched_service";
|
|
11
|
+
too_complex: "too_complex";
|
|
12
|
+
too_expensive: "too_expensive";
|
|
13
|
+
unused: "unused";
|
|
14
|
+
other: "other";
|
|
15
|
+
}>>>;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
declare function checkoutSessionSchema(productIds: [ProductId, ...ProductId[]]): z.ZodMiniObject<{
|
|
18
|
+
productId: z.ZodMiniEnum<{
|
|
19
|
+
[x: Lowercase<string>]: Lowercase<string>;
|
|
20
|
+
}>;
|
|
21
|
+
cancelUrl: z.ZodMiniOptional<z.ZodMiniURL>;
|
|
22
|
+
successUrl: z.ZodMiniOptional<z.ZodMiniURL>;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
interface CancellationDetails extends z.output<typeof cancellationDetailsSchema> {
|
|
25
|
+
reason?: 'cancellation_requested' | 'payment_disputed' | 'payment_failed' | null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { type CancellationDetails, cancellationDetailsSchema, checkoutSessionSchema };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// src/stripe/schema.ts
|
|
2
|
+
import {
|
|
3
|
+
maxLength,
|
|
4
|
+
object,
|
|
5
|
+
optional,
|
|
6
|
+
nullable,
|
|
7
|
+
string,
|
|
8
|
+
enum as _enum,
|
|
9
|
+
url
|
|
10
|
+
} from "zod/v4-mini";
|
|
11
|
+
var cancellationDetailsSchema = object({
|
|
12
|
+
comment: optional(nullable(string().check(maxLength(1024)))),
|
|
13
|
+
feedback: optional(
|
|
14
|
+
nullable(
|
|
15
|
+
_enum([
|
|
16
|
+
"customer_service",
|
|
17
|
+
"low_quality",
|
|
18
|
+
"missing_features",
|
|
19
|
+
"switched_service",
|
|
20
|
+
"too_complex",
|
|
21
|
+
"too_expensive",
|
|
22
|
+
"unused",
|
|
23
|
+
"other"
|
|
24
|
+
])
|
|
25
|
+
)
|
|
26
|
+
)
|
|
27
|
+
});
|
|
28
|
+
function checkoutSessionSchema(productIds) {
|
|
29
|
+
return object({
|
|
30
|
+
productId: _enum(productIds),
|
|
31
|
+
cancelUrl: optional(url()),
|
|
32
|
+
successUrl: optional(url())
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
cancellationDetailsSchema,
|
|
37
|
+
checkoutSessionSchema
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=schema.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/stripe/schema.ts"],"sourcesContent":["import {\n maxLength,\n object,\n optional,\n nullable,\n string,\n enum as _enum,\n url,\n type z,\n} from 'zod/v4-mini';\nimport type { ProductId } from './types';\n\nexport const cancellationDetailsSchema = object({\n comment: optional(nullable(string().check(maxLength(1024)))),\n feedback: optional(\n nullable(\n _enum([\n 'customer_service',\n 'low_quality',\n 'missing_features',\n 'switched_service',\n 'too_complex',\n 'too_expensive',\n 'unused',\n 'other',\n ])\n )\n ),\n});\n\nexport function checkoutSessionSchema(productIds: [ProductId, ...ProductId[]]) {\n return object({\n productId: _enum(productIds),\n cancelUrl: optional(url()),\n successUrl: optional(url()),\n });\n}\n\nexport interface CancellationDetails extends z.output<typeof cancellationDetailsSchema> {\n reason?: 'cancellation_requested' | 'payment_disputed' | 'payment_failed' | null;\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,OAEK;AAGA,IAAM,4BAA4B,OAAO;AAAA,EAC9C,SAAS,SAAS,SAAS,OAAO,EAAE,MAAM,UAAU,IAAI,CAAC,CAAC,CAAC;AAAA,EAC3D,UAAU;AAAA,IACR;AAAA,MACE,MAAM;AAAA,QACJ;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF,CAAC;AAEM,SAAS,sBAAsB,YAAyC;AAC7E,SAAO,OAAO;AAAA,IACZ,WAAW,MAAM,UAAU;AAAA,IAC3B,WAAW,SAAS,IAAI,CAAC;AAAA,IACzB,YAAY,SAAS,IAAI,CAAC;AAAA,EAC5B,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/stripe/types.ts
|
|
17
|
+
var types_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(types_exports);
|
|
19
|
+
//# sourceMappingURL=types.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/stripe/types.ts"],"sourcesContent":["export type ProductId = Lowercase<string>;\nexport type PriceId = `price_${string}`;\n\nexport interface Config {\n returnUrl: string;\n cancelUrl: string;\n successUrl: `${string}?session_id={CHECKOUT_SESSION_ID}`;\n allowPromotionCodes: boolean;\n payments: Record<ProductId, PriceId>;\n subscriptions: Record<ProductId, PriceId>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type ProductId = Lowercase<string>;
|
|
2
|
+
type PriceId = `price_${string}`;
|
|
3
|
+
interface Config {
|
|
4
|
+
returnUrl: string;
|
|
5
|
+
cancelUrl: string;
|
|
6
|
+
successUrl: `${string}?session_id={CHECKOUT_SESSION_ID}`;
|
|
7
|
+
allowPromotionCodes: boolean;
|
|
8
|
+
payments: Record<ProductId, PriceId>;
|
|
9
|
+
subscriptions: Record<ProductId, PriceId>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type { Config, PriceId, ProductId };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type ProductId = Lowercase<string>;
|
|
2
|
+
type PriceId = `price_${string}`;
|
|
3
|
+
interface Config {
|
|
4
|
+
returnUrl: string;
|
|
5
|
+
cancelUrl: string;
|
|
6
|
+
successUrl: `${string}?session_id={CHECKOUT_SESSION_ID}`;
|
|
7
|
+
allowPromotionCodes: boolean;
|
|
8
|
+
payments: Record<ProductId, PriceId>;
|
|
9
|
+
subscriptions: Record<ProductId, PriceId>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type { Config, PriceId, ProductId };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|