@shware/purchase 0.0.4 → 0.0.6
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 +14 -85
- package/dist/stripe/index.cjs.map +1 -1
- package/dist/stripe/index.d.cts +7 -68
- package/dist/stripe/index.d.ts +7 -68
- package/dist/stripe/index.mjs +15 -79
- package/dist/stripe/index.mjs.map +1 -1
- package/dist/stripe/mapper.cjs +115 -0
- package/dist/stripe/mapper.cjs.map +1 -0
- package/dist/stripe/mapper.d.cts +33 -0
- package/dist/stripe/mapper.d.ts +33 -0
- package/dist/stripe/mapper.mjs +85 -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,92 +20,19 @@ 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
|
-
checkoutSessionSchema: () => checkoutSessionSchema,
|
|
26
|
-
mapCheckoutSession: () => mapCheckoutSession,
|
|
27
|
-
mapStatus: () => mapStatus,
|
|
28
|
-
mapTime: () => mapTime
|
|
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,
|
|
29
|
+
minorUnits: () => import_mapper.minorUnits,
|
|
30
|
+
price: () => import_mapper.price
|
|
29
31
|
});
|
|
30
32
|
module.exports = __toCommonJS(stripe_exports);
|
|
31
|
-
var
|
|
32
|
-
var
|
|
33
|
-
var
|
|
34
|
-
USER_ID: "user_id",
|
|
35
|
-
PRODUCT_ID: "product_id"
|
|
36
|
-
};
|
|
37
|
-
function mapTime(stripeTimestampSeconds) {
|
|
38
|
-
if (!stripeTimestampSeconds) return null;
|
|
39
|
-
return new Date(stripeTimestampSeconds * 1e3).toISOString();
|
|
40
|
-
}
|
|
41
|
-
function mapCheckoutSession(session) {
|
|
42
|
-
return {
|
|
43
|
-
id: session.id,
|
|
44
|
-
url: session.url,
|
|
45
|
-
livemode: session.livemode,
|
|
46
|
-
expires_at: session.expires_at,
|
|
47
|
-
payment_status: session.payment_status,
|
|
48
|
-
currency: session.currency,
|
|
49
|
-
amount_total: session.amount_total,
|
|
50
|
-
line_items: session.line_items?.data.map((item) => ({
|
|
51
|
-
id: item.id,
|
|
52
|
-
currency: item.currency,
|
|
53
|
-
quantity: item.quantity,
|
|
54
|
-
description: item.description,
|
|
55
|
-
amount_tax: item.amount_tax,
|
|
56
|
-
amount_total: item.amount_total,
|
|
57
|
-
amount_subtotal: item.amount_subtotal,
|
|
58
|
-
amount_discount: item.amount_discount,
|
|
59
|
-
price: item.price ? { id: item.price.id } : null
|
|
60
|
-
})) ?? []
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
function mapStatus(status) {
|
|
64
|
-
switch (status) {
|
|
65
|
-
case "active":
|
|
66
|
-
return import_subscription.SubscriptionStatus.ACTIVE;
|
|
67
|
-
case "canceled":
|
|
68
|
-
return import_subscription.SubscriptionStatus.CANCELED;
|
|
69
|
-
case "incomplete":
|
|
70
|
-
return import_subscription.SubscriptionStatus.INCOMPLETE;
|
|
71
|
-
case "incomplete_expired":
|
|
72
|
-
return import_subscription.SubscriptionStatus.INCOMPLETE_EXPIRED;
|
|
73
|
-
case "past_due":
|
|
74
|
-
return import_subscription.SubscriptionStatus.PAST_DUE;
|
|
75
|
-
case "paused":
|
|
76
|
-
return import_subscription.SubscriptionStatus.PAUSED;
|
|
77
|
-
case "trialing":
|
|
78
|
-
return import_subscription.SubscriptionStatus.TRIALING;
|
|
79
|
-
case "unpaid":
|
|
80
|
-
return import_subscription.SubscriptionStatus.UNPAID;
|
|
81
|
-
default: {
|
|
82
|
-
console.error(`Invalid stripe status: ${status}`);
|
|
83
|
-
throw new Error(`Invalid stripe status: ${status}`);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
var cancellationDetailsSchema = (0, import_v4_mini.object)({
|
|
88
|
-
comment: (0, import_v4_mini.optional)((0, import_v4_mini.string)().check((0, import_v4_mini.maxLength)(1024))),
|
|
89
|
-
feedback: (0, import_v4_mini.optional)(
|
|
90
|
-
(0, import_v4_mini.enum)([
|
|
91
|
-
"customer_service",
|
|
92
|
-
"low_quality",
|
|
93
|
-
"missing_features",
|
|
94
|
-
"switched_service",
|
|
95
|
-
"too_complex",
|
|
96
|
-
"too_expensive",
|
|
97
|
-
"unused",
|
|
98
|
-
"other"
|
|
99
|
-
])
|
|
100
|
-
)
|
|
101
|
-
});
|
|
102
|
-
function checkoutSessionSchema(productIds) {
|
|
103
|
-
return (0, import_v4_mini.object)({
|
|
104
|
-
productId: (0, import_v4_mini.enum)(productIds),
|
|
105
|
-
cancelUrl: (0, import_v4_mini.optional)((0, import_v4_mini.url)()),
|
|
106
|
-
successUrl: (0, import_v4_mini.optional)((0, import_v4_mini.url)())
|
|
107
|
-
});
|
|
108
|
-
}
|
|
33
|
+
var import_mapper = require("./mapper.cjs");
|
|
34
|
+
var import_schema = require("./schema.cjs");
|
|
35
|
+
var import_metadata = require("./metadata.cjs");
|
|
109
36
|
// Annotate the CommonJS export names for ESM import in node:
|
|
110
37
|
0 && (module.exports = {
|
|
111
38
|
METADATA_KEYS,
|
|
@@ -113,6 +40,8 @@ function checkoutSessionSchema(productIds) {
|
|
|
113
40
|
checkoutSessionSchema,
|
|
114
41
|
mapCheckoutSession,
|
|
115
42
|
mapStatus,
|
|
116
|
-
mapTime
|
|
43
|
+
mapTime,
|
|
44
|
+
minorUnits,
|
|
45
|
+
price
|
|
117
46
|
});
|
|
118
47
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/stripe/index.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../src/stripe/index.ts"],"sourcesContent":["export {\n mapTime,\n mapStatus,\n mapCheckoutSession,\n minorUnits,\n price,\n type CheckoutSession,\n} 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;AAAA;AAAA,oBAOO;AACP,oBAIO;AAEP,sBAA8B;","names":[]}
|
package/dist/stripe/index.d.cts
CHANGED
|
@@ -1,68 +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
|
-
type CheckoutSession = ReturnType<typeof mapCheckoutSession>;
|
|
43
|
-
declare function mapStatus(status: Stripe.Subscription.Status): SubscriptionStatus;
|
|
44
|
-
declare const cancellationDetailsSchema: z.ZodMiniObject<{
|
|
45
|
-
comment: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
46
|
-
feedback: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
47
|
-
customer_service: "customer_service";
|
|
48
|
-
low_quality: "low_quality";
|
|
49
|
-
missing_features: "missing_features";
|
|
50
|
-
switched_service: "switched_service";
|
|
51
|
-
too_complex: "too_complex";
|
|
52
|
-
too_expensive: "too_expensive";
|
|
53
|
-
unused: "unused";
|
|
54
|
-
other: "other";
|
|
55
|
-
}>>;
|
|
56
|
-
}, z.core.$strip>;
|
|
57
|
-
declare function checkoutSessionSchema(productIds: [ProductId, ...ProductId[]]): z.ZodMiniObject<{
|
|
58
|
-
productId: z.ZodMiniEnum<{
|
|
59
|
-
[x: Lowercase<string>]: Lowercase<string>;
|
|
60
|
-
}>;
|
|
61
|
-
cancelUrl: z.ZodMiniOptional<z.ZodMiniURL>;
|
|
62
|
-
successUrl: z.ZodMiniOptional<z.ZodMiniURL>;
|
|
63
|
-
}, z.core.$strip>;
|
|
64
|
-
interface CancellationDetails extends z.output<typeof cancellationDetailsSchema> {
|
|
65
|
-
reason?: 'cancellation_requested' | 'payment_disputed' | 'payment_failed';
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export { type CancellationDetails, type CheckoutSession, type Config, METADATA_KEYS, type PriceId, type ProductId, cancellationDetailsSchema, checkoutSessionSchema, mapCheckoutSession, mapStatus, mapTime };
|
|
1
|
+
export { CheckoutSession, mapCheckoutSession, mapStatus, mapTime, minorUnits, price } 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,68 +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
|
-
type CheckoutSession = ReturnType<typeof mapCheckoutSession>;
|
|
43
|
-
declare function mapStatus(status: Stripe.Subscription.Status): SubscriptionStatus;
|
|
44
|
-
declare const cancellationDetailsSchema: z.ZodMiniObject<{
|
|
45
|
-
comment: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
46
|
-
feedback: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
47
|
-
customer_service: "customer_service";
|
|
48
|
-
low_quality: "low_quality";
|
|
49
|
-
missing_features: "missing_features";
|
|
50
|
-
switched_service: "switched_service";
|
|
51
|
-
too_complex: "too_complex";
|
|
52
|
-
too_expensive: "too_expensive";
|
|
53
|
-
unused: "unused";
|
|
54
|
-
other: "other";
|
|
55
|
-
}>>;
|
|
56
|
-
}, z.core.$strip>;
|
|
57
|
-
declare function checkoutSessionSchema(productIds: [ProductId, ...ProductId[]]): z.ZodMiniObject<{
|
|
58
|
-
productId: z.ZodMiniEnum<{
|
|
59
|
-
[x: Lowercase<string>]: Lowercase<string>;
|
|
60
|
-
}>;
|
|
61
|
-
cancelUrl: z.ZodMiniOptional<z.ZodMiniURL>;
|
|
62
|
-
successUrl: z.ZodMiniOptional<z.ZodMiniURL>;
|
|
63
|
-
}, z.core.$strip>;
|
|
64
|
-
interface CancellationDetails extends z.output<typeof cancellationDetailsSchema> {
|
|
65
|
-
reason?: 'cancellation_requested' | 'payment_disputed' | 'payment_failed';
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export { type CancellationDetails, type CheckoutSession, type Config, METADATA_KEYS, type PriceId, type ProductId, cancellationDetailsSchema, checkoutSessionSchema, mapCheckoutSession, mapStatus, mapTime };
|
|
1
|
+
export { CheckoutSession, mapCheckoutSession, mapStatus, mapTime, minorUnits, price } 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,88 +1,24 @@
|
|
|
1
1
|
// src/stripe/index.ts
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
});
|
|
73
|
-
function checkoutSessionSchema(productIds) {
|
|
74
|
-
return object({
|
|
75
|
-
productId: _enum(productIds),
|
|
76
|
-
cancelUrl: optional(url()),
|
|
77
|
-
successUrl: optional(url())
|
|
78
|
-
});
|
|
79
|
-
}
|
|
2
|
+
import {
|
|
3
|
+
mapTime,
|
|
4
|
+
mapStatus,
|
|
5
|
+
mapCheckoutSession,
|
|
6
|
+
minorUnits,
|
|
7
|
+
price
|
|
8
|
+
} from "./mapper.mjs";
|
|
9
|
+
import {
|
|
10
|
+
cancellationDetailsSchema,
|
|
11
|
+
checkoutSessionSchema
|
|
12
|
+
} from "./schema.mjs";
|
|
13
|
+
import { METADATA_KEYS } from "./metadata.mjs";
|
|
80
14
|
export {
|
|
81
15
|
METADATA_KEYS,
|
|
82
16
|
cancellationDetailsSchema,
|
|
83
17
|
checkoutSessionSchema,
|
|
84
18
|
mapCheckoutSession,
|
|
85
19
|
mapStatus,
|
|
86
|
-
mapTime
|
|
20
|
+
mapTime,
|
|
21
|
+
minorUnits,
|
|
22
|
+
price
|
|
87
23
|
};
|
|
88
24
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/stripe/index.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../src/stripe/index.ts"],"sourcesContent":["export {\n mapTime,\n mapStatus,\n mapCheckoutSession,\n minorUnits,\n price,\n type CheckoutSession,\n} 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,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AAEP,SAAS,qBAAqB;","names":[]}
|
|
@@ -0,0 +1,115 @@
|
|
|
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
|
+
ZERO_DECIMAL_CURRENCIES: () => ZERO_DECIMAL_CURRENCIES,
|
|
24
|
+
mapCheckoutSession: () => mapCheckoutSession,
|
|
25
|
+
mapStatus: () => mapStatus,
|
|
26
|
+
mapTime: () => mapTime,
|
|
27
|
+
minorUnits: () => minorUnits,
|
|
28
|
+
price: () => price
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(mapper_exports);
|
|
31
|
+
var import_subscription = require("../subscription/index.cjs");
|
|
32
|
+
function mapTime(stripeTimestampSeconds) {
|
|
33
|
+
if (!stripeTimestampSeconds) return null;
|
|
34
|
+
return new Date(stripeTimestampSeconds * 1e3).toISOString();
|
|
35
|
+
}
|
|
36
|
+
function mapCheckoutSession(session) {
|
|
37
|
+
return {
|
|
38
|
+
id: session.id,
|
|
39
|
+
url: session.url,
|
|
40
|
+
livemode: session.livemode,
|
|
41
|
+
expires_at: session.expires_at,
|
|
42
|
+
payment_status: session.payment_status,
|
|
43
|
+
currency: session.currency,
|
|
44
|
+
amount_total: session.amount_total,
|
|
45
|
+
line_items: session.line_items?.data.map((item) => ({
|
|
46
|
+
id: item.id,
|
|
47
|
+
currency: item.currency,
|
|
48
|
+
quantity: item.quantity,
|
|
49
|
+
description: item.description,
|
|
50
|
+
amount_tax: item.amount_tax,
|
|
51
|
+
amount_total: item.amount_total,
|
|
52
|
+
amount_subtotal: item.amount_subtotal,
|
|
53
|
+
amount_discount: item.amount_discount,
|
|
54
|
+
price: item.price ? { id: item.price.id } : null
|
|
55
|
+
})) ?? []
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function mapStatus(status) {
|
|
59
|
+
switch (status) {
|
|
60
|
+
case "active":
|
|
61
|
+
return import_subscription.SubscriptionStatus.ACTIVE;
|
|
62
|
+
case "canceled":
|
|
63
|
+
return import_subscription.SubscriptionStatus.CANCELED;
|
|
64
|
+
case "incomplete":
|
|
65
|
+
return import_subscription.SubscriptionStatus.INCOMPLETE;
|
|
66
|
+
case "incomplete_expired":
|
|
67
|
+
return import_subscription.SubscriptionStatus.INCOMPLETE_EXPIRED;
|
|
68
|
+
case "past_due":
|
|
69
|
+
return import_subscription.SubscriptionStatus.PAST_DUE;
|
|
70
|
+
case "paused":
|
|
71
|
+
return import_subscription.SubscriptionStatus.PAUSED;
|
|
72
|
+
case "trialing":
|
|
73
|
+
return import_subscription.SubscriptionStatus.TRIALING;
|
|
74
|
+
case "unpaid":
|
|
75
|
+
return import_subscription.SubscriptionStatus.UNPAID;
|
|
76
|
+
default: {
|
|
77
|
+
console.error(`Invalid stripe status: ${status}`);
|
|
78
|
+
throw new Error(`Invalid stripe status: ${status}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
var ZERO_DECIMAL_CURRENCIES = [
|
|
83
|
+
"BIF",
|
|
84
|
+
"CLP",
|
|
85
|
+
"DJF",
|
|
86
|
+
"GNF",
|
|
87
|
+
"JPY",
|
|
88
|
+
"KMF",
|
|
89
|
+
"KRW",
|
|
90
|
+
"MGA",
|
|
91
|
+
"PYG",
|
|
92
|
+
"RWF",
|
|
93
|
+
"UGX",
|
|
94
|
+
"VND",
|
|
95
|
+
"VUV",
|
|
96
|
+
"XAF",
|
|
97
|
+
"XOF",
|
|
98
|
+
"XPF"
|
|
99
|
+
];
|
|
100
|
+
function minorUnits(currency) {
|
|
101
|
+
return ZERO_DECIMAL_CURRENCIES.includes(currency.toUpperCase()) ? 1 : 100;
|
|
102
|
+
}
|
|
103
|
+
function price(value, currency) {
|
|
104
|
+
return value / minorUnits(currency);
|
|
105
|
+
}
|
|
106
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
107
|
+
0 && (module.exports = {
|
|
108
|
+
ZERO_DECIMAL_CURRENCIES,
|
|
109
|
+
mapCheckoutSession,
|
|
110
|
+
mapStatus,
|
|
111
|
+
mapTime,
|
|
112
|
+
minorUnits,
|
|
113
|
+
price
|
|
114
|
+
});
|
|
115
|
+
//# 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\nexport const ZERO_DECIMAL_CURRENCIES = [\n 'BIF',\n 'CLP',\n 'DJF',\n 'GNF',\n 'JPY',\n 'KMF',\n 'KRW',\n 'MGA',\n 'PYG',\n 'RWF',\n 'UGX',\n 'VND',\n 'VUV',\n 'XAF',\n 'XOF',\n 'XPF',\n];\n\nexport function minorUnits(currency: string) {\n return ZERO_DECIMAL_CURRENCIES.includes(currency.toUpperCase()) ? 1 : 100;\n}\n\nexport function price(value: number, currency: string) {\n return value / minorUnits(currency);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;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;AAEO,IAAM,0BAA0B;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,SAAS,WAAW,UAAkB;AAC3C,SAAO,wBAAwB,SAAS,SAAS,YAAY,CAAC,IAAI,IAAI;AACxE;AAEO,SAAS,MAAM,OAAe,UAAkB;AACrD,SAAO,QAAQ,WAAW,QAAQ;AACpC;","names":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
declare const ZERO_DECIMAL_CURRENCIES: string[];
|
|
30
|
+
declare function minorUnits(currency: string): 1 | 100;
|
|
31
|
+
declare function price(value: number, currency: string): number;
|
|
32
|
+
|
|
33
|
+
export { type CheckoutSession, ZERO_DECIMAL_CURRENCIES, mapCheckoutSession, mapStatus, mapTime, minorUnits, price };
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
declare const ZERO_DECIMAL_CURRENCIES: string[];
|
|
30
|
+
declare function minorUnits(currency: string): 1 | 100;
|
|
31
|
+
declare function price(value: number, currency: string): number;
|
|
32
|
+
|
|
33
|
+
export { type CheckoutSession, ZERO_DECIMAL_CURRENCIES, mapCheckoutSession, mapStatus, mapTime, minorUnits, price };
|
|
@@ -0,0 +1,85 @@
|
|
|
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
|
+
var ZERO_DECIMAL_CURRENCIES = [
|
|
54
|
+
"BIF",
|
|
55
|
+
"CLP",
|
|
56
|
+
"DJF",
|
|
57
|
+
"GNF",
|
|
58
|
+
"JPY",
|
|
59
|
+
"KMF",
|
|
60
|
+
"KRW",
|
|
61
|
+
"MGA",
|
|
62
|
+
"PYG",
|
|
63
|
+
"RWF",
|
|
64
|
+
"UGX",
|
|
65
|
+
"VND",
|
|
66
|
+
"VUV",
|
|
67
|
+
"XAF",
|
|
68
|
+
"XOF",
|
|
69
|
+
"XPF"
|
|
70
|
+
];
|
|
71
|
+
function minorUnits(currency) {
|
|
72
|
+
return ZERO_DECIMAL_CURRENCIES.includes(currency.toUpperCase()) ? 1 : 100;
|
|
73
|
+
}
|
|
74
|
+
function price(value, currency) {
|
|
75
|
+
return value / minorUnits(currency);
|
|
76
|
+
}
|
|
77
|
+
export {
|
|
78
|
+
ZERO_DECIMAL_CURRENCIES,
|
|
79
|
+
mapCheckoutSession,
|
|
80
|
+
mapStatus,
|
|
81
|
+
mapTime,
|
|
82
|
+
minorUnits,
|
|
83
|
+
price
|
|
84
|
+
};
|
|
85
|
+
//# 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\nexport const ZERO_DECIMAL_CURRENCIES = [\n 'BIF',\n 'CLP',\n 'DJF',\n 'GNF',\n 'JPY',\n 'KMF',\n 'KRW',\n 'MGA',\n 'PYG',\n 'RWF',\n 'UGX',\n 'VND',\n 'VUV',\n 'XAF',\n 'XOF',\n 'XPF',\n];\n\nexport function minorUnits(currency: string) {\n return ZERO_DECIMAL_CURRENCIES.includes(currency.toUpperCase()) ? 1 : 100;\n}\n\nexport function price(value: number, currency: string) {\n return value / minorUnits(currency);\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;AAEO,IAAM,0BAA0B;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,SAAS,WAAW,UAAkB;AAC3C,SAAO,wBAAwB,SAAS,SAAS,YAAY,CAAC,IAAI,IAAI;AACxE;AAEO,SAAS,MAAM,OAAe,UAAkB;AACrD,SAAO,QAAQ,WAAW,QAAQ;AACpC;","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":[]}
|