@shware/purchase 1.8.9 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_rolldown/runtime.cjs +23 -0
- package/dist/app-store/config.cjs +98 -128
- package/dist/app-store/config.cjs.map +1 -1
- package/dist/app-store/config.d.cts +31 -31
- package/dist/app-store/config.d.cts.map +1 -0
- package/dist/app-store/config.d.mts +39 -0
- package/dist/app-store/config.d.mts.map +1 -0
- package/dist/app-store/config.mjs +93 -91
- package/dist/app-store/config.mjs.map +1 -1
- package/dist/app-store/index.cjs +3 -31
- package/dist/app-store/index.d.cts +2 -3
- package/dist/app-store/index.d.mts +2 -0
- package/dist/app-store/index.mjs +1 -5
- package/dist/google-play/config.cjs +100 -123
- package/dist/google-play/config.cjs.map +1 -1
- package/dist/google-play/config.d.cts +31 -31
- package/dist/google-play/config.d.cts.map +1 -0
- package/dist/google-play/config.d.mts +39 -0
- package/dist/google-play/config.d.mts.map +1 -0
- package/dist/google-play/config.mjs +95 -86
- package/dist/google-play/config.mjs.map +1 -1
- package/dist/google-play/index.cjs +9 -42
- package/dist/google-play/index.d.cts +3 -4
- package/dist/google-play/index.d.mts +3 -0
- package/dist/google-play/index.mjs +2 -17
- package/dist/google-play/real-time-developer-notification.cjs +122 -81
- package/dist/google-play/real-time-developer-notification.cjs.map +1 -1
- package/dist/google-play/real-time-developer-notification.d.cts +119 -117
- package/dist/google-play/real-time-developer-notification.d.cts.map +1 -0
- package/dist/google-play/real-time-developer-notification.d.mts +150 -0
- package/dist/google-play/real-time-developer-notification.d.mts.map +1 -0
- package/dist/google-play/real-time-developer-notification.mjs +118 -53
- package/dist/google-play/real-time-developer-notification.mjs.map +1 -1
- package/dist/index.cjs +13 -48
- package/dist/index.d.cts +5 -6
- package/dist/index.d.mts +5 -0
- package/dist/index.mjs +2 -19
- package/dist/stripe/config.cjs +104 -133
- package/dist/stripe/config.cjs.map +1 -1
- package/dist/stripe/config.d.cts +35 -35
- package/dist/stripe/config.d.cts.map +1 -0
- package/dist/stripe/config.d.mts +43 -0
- package/dist/stripe/config.d.mts.map +1 -0
- package/dist/stripe/config.mjs +99 -96
- package/dist/stripe/config.mjs.map +1 -1
- package/dist/stripe/handler.cjs +25 -53
- package/dist/stripe/handler.cjs.map +1 -1
- package/dist/stripe/handler.d.cts +10 -9
- package/dist/stripe/handler.d.cts.map +1 -0
- package/dist/stripe/handler.d.mts +16 -0
- package/dist/stripe/handler.d.mts.map +1 -0
- package/dist/stripe/handler.mjs +25 -29
- package/dist/stripe/handler.mjs.map +1 -1
- package/dist/stripe/index.cjs +27 -74
- package/dist/stripe/index.d.cts +8 -12
- package/dist/stripe/index.d.mts +8 -0
- package/dist/stripe/index.mjs +5 -44
- package/dist/stripe/mapper.cjs +168 -219
- package/dist/stripe/mapper.cjs.map +1 -1
- package/dist/stripe/mapper.d.cts +115 -114
- package/dist/stripe/mapper.d.cts.map +1 -0
- package/dist/stripe/mapper.d.mts +158 -0
- package/dist/stripe/mapper.d.mts.map +1 -0
- package/dist/stripe/mapper.mjs +155 -182
- package/dist/stripe/mapper.mjs.map +1 -1
- package/dist/stripe/metadata.cjs +11 -35
- package/dist/stripe/metadata.cjs.map +1 -1
- package/dist/stripe/metadata.d.cts +9 -7
- package/dist/stripe/metadata.d.cts.map +1 -0
- package/dist/stripe/metadata.d.mts +12 -0
- package/dist/stripe/metadata.d.mts.map +1 -0
- package/dist/stripe/metadata.mjs +11 -11
- package/dist/stripe/metadata.mjs.map +1 -1
- package/dist/stripe/pending-checkout.cjs +55 -61
- package/dist/stripe/pending-checkout.cjs.map +1 -1
- package/dist/stripe/pending-checkout.d.cts +3 -1
- package/dist/stripe/pending-checkout.d.cts.map +1 -0
- package/dist/stripe/{pending-checkout.d.ts → pending-checkout.d.mts} +3 -1
- package/dist/stripe/pending-checkout.d.mts.map +1 -0
- package/dist/stripe/pending-checkout.mjs +52 -34
- package/dist/stripe/pending-checkout.mjs.map +1 -1
- package/dist/stripe/schema.cjs +30 -55
- package/dist/stripe/schema.cjs.map +1 -1
- package/dist/stripe/schema.d.cts +36 -37
- package/dist/stripe/schema.d.cts.map +1 -0
- package/dist/stripe/schema.d.mts +40 -0
- package/dist/stripe/schema.d.mts.map +1 -0
- package/dist/stripe/schema.mjs +28 -40
- package/dist/stripe/schema.mjs.map +1 -1
- package/dist/subscription/index.cjs +178 -80
- package/dist/subscription/index.cjs.map +1 -1
- package/dist/subscription/index.d.cts +136 -134
- package/dist/subscription/index.d.cts.map +1 -0
- package/dist/subscription/index.d.mts +150 -0
- package/dist/subscription/index.d.mts.map +1 -0
- package/dist/subscription/index.mjs +173 -51
- package/dist/subscription/index.mjs.map +1 -1
- package/dist/types.cjs +0 -19
- package/dist/types.d.cts +7 -6
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +10 -0
- package/dist/types.d.mts.map +1 -0
- package/dist/types.mjs +1 -1
- package/package.json +40 -25
- package/dist/app-store/config.d.ts +0 -39
- package/dist/app-store/index.cjs.map +0 -1
- package/dist/app-store/index.d.ts +0 -3
- package/dist/app-store/index.mjs.map +0 -1
- package/dist/google-play/config.d.ts +0 -39
- package/dist/google-play/index.cjs.map +0 -1
- package/dist/google-play/index.d.ts +0 -4
- package/dist/google-play/index.mjs.map +0 -1
- package/dist/google-play/real-time-developer-notification.d.ts +0 -148
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts +0 -6
- package/dist/index.mjs.map +0 -1
- package/dist/stripe/config.d.ts +0 -43
- package/dist/stripe/handler.d.ts +0 -15
- package/dist/stripe/index.cjs.map +0 -1
- package/dist/stripe/index.d.ts +0 -12
- package/dist/stripe/index.mjs.map +0 -1
- package/dist/stripe/mapper.d.ts +0 -157
- package/dist/stripe/metadata.d.ts +0 -10
- package/dist/stripe/schema.d.ts +0 -41
- package/dist/subscription/index.d.ts +0 -148
- package/dist/types.cjs.map +0 -1
- package/dist/types.d.ts +0 -9
- package/dist/types.mjs.map +0 -1
package/dist/stripe/mapper.mjs
CHANGED
|
@@ -1,207 +1,180 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import "../subscription/index.mjs";
|
|
2
|
+
//#region src/stripe/mapper.ts
|
|
3
3
|
function mapTime(stripeTimestampSeconds) {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
if (!stripeTimestampSeconds) return null;
|
|
5
|
+
return (/* @__PURE__ */ new Date(stripeTimestampSeconds * 1e3)).toISOString();
|
|
6
6
|
}
|
|
7
|
-
function mapPrice(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
function mapPrice(price) {
|
|
8
|
+
return {
|
|
9
|
+
id: price.id,
|
|
10
|
+
type: price.type,
|
|
11
|
+
active: price.active,
|
|
12
|
+
billing_scheme: price.billing_scheme,
|
|
13
|
+
currency: price.currency,
|
|
14
|
+
unit_amount: price.unit_amount,
|
|
15
|
+
unit_amount_decimal: price.unit_amount_decimal?.toString() ?? null,
|
|
16
|
+
recurring: price.recurring
|
|
17
|
+
};
|
|
18
18
|
}
|
|
19
19
|
function mapLineItem(item) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
return {
|
|
21
|
+
id: item.price ? typeof item.price.product === "string" ? item.price.product : item.price.product.id : item.id,
|
|
22
|
+
currency: item.currency,
|
|
23
|
+
quantity: item.quantity,
|
|
24
|
+
description: item.description,
|
|
25
|
+
amount_tax: item.amount_tax,
|
|
26
|
+
amount_total: item.amount_total,
|
|
27
|
+
amount_subtotal: item.amount_subtotal,
|
|
28
|
+
amount_discount: item.amount_discount,
|
|
29
|
+
price: item.price ? mapPrice(item.price) : null
|
|
30
|
+
};
|
|
31
31
|
}
|
|
32
32
|
function mapCheckoutSession(session) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
currency: session.currency,
|
|
53
|
-
amount_total: session.amount_total,
|
|
54
|
-
line_items: session.line_items?.data.map(mapLineItem)
|
|
55
|
-
};
|
|
33
|
+
let coupon = void 0;
|
|
34
|
+
if (Array.isArray(session.discounts) && session.discounts.length !== 0) {
|
|
35
|
+
const discount = session.discounts[0];
|
|
36
|
+
if (discount.coupon && typeof discount.coupon === "object") coupon = discount.coupon.id;
|
|
37
|
+
else if (typeof discount.coupon === "string") coupon = discount.coupon;
|
|
38
|
+
else coupon = void 0;
|
|
39
|
+
}
|
|
40
|
+
const payment_status = session.payment_status;
|
|
41
|
+
return {
|
|
42
|
+
id: session.id,
|
|
43
|
+
url: session.url,
|
|
44
|
+
coupon,
|
|
45
|
+
livemode: session.livemode,
|
|
46
|
+
expires_at: session.expires_at,
|
|
47
|
+
payment_status,
|
|
48
|
+
currency: session.currency,
|
|
49
|
+
amount_total: session.amount_total,
|
|
50
|
+
line_items: session.line_items?.data.map(mapLineItem)
|
|
51
|
+
};
|
|
56
52
|
}
|
|
57
53
|
function mapInvoice(i) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
54
|
+
return {
|
|
55
|
+
id: i.id,
|
|
56
|
+
number: i.number,
|
|
57
|
+
total: i.total,
|
|
58
|
+
subtotal: i.subtotal,
|
|
59
|
+
amount_due: i.amount_due,
|
|
60
|
+
amount_paid: i.amount_paid,
|
|
61
|
+
amount_remaining: i.amount_remaining,
|
|
62
|
+
currency: i.currency,
|
|
63
|
+
billing_reason: i.billing_reason,
|
|
64
|
+
hosted_invoice_url: i.hosted_invoice_url,
|
|
65
|
+
invoice_pdf: i.invoice_pdf,
|
|
66
|
+
receipt_number: i.receipt_number,
|
|
67
|
+
status: i.status,
|
|
68
|
+
created: i.created,
|
|
69
|
+
period_start: i.period_start,
|
|
70
|
+
period_end: i.period_end
|
|
71
|
+
};
|
|
76
72
|
}
|
|
77
73
|
function mapPaymentIntent(intent) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
74
|
+
return {
|
|
75
|
+
id: intent.id,
|
|
76
|
+
amount: intent.amount,
|
|
77
|
+
amount_capturable: intent.amount_capturable,
|
|
78
|
+
amount_received: intent.amount_received,
|
|
79
|
+
currency: intent.currency,
|
|
80
|
+
client_secret: intent.client_secret,
|
|
81
|
+
description: intent.description,
|
|
82
|
+
status: intent.status,
|
|
83
|
+
created: intent.created
|
|
84
|
+
};
|
|
89
85
|
}
|
|
90
86
|
function mapCharge(charge) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
87
|
+
return {
|
|
88
|
+
id: charge.id,
|
|
89
|
+
description: charge.description,
|
|
90
|
+
currency: charge.currency,
|
|
91
|
+
amount: charge.amount,
|
|
92
|
+
amount_captured: charge.amount_captured,
|
|
93
|
+
amount_refunded: charge.amount_refunded,
|
|
94
|
+
receipt_email: charge.receipt_email,
|
|
95
|
+
receipt_number: charge.receipt_number,
|
|
96
|
+
receipt_url: charge.receipt_url,
|
|
97
|
+
status: charge.status,
|
|
98
|
+
created: charge.created,
|
|
99
|
+
payment_intent: charge.payment_intent && typeof charge.payment_intent === "object" ? mapPaymentIntent(charge.payment_intent) : void 0
|
|
100
|
+
};
|
|
105
101
|
}
|
|
106
102
|
function mapSubscriptionStatus(status) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
case "trialing":
|
|
121
|
-
return SubscriptionStatus.TRIALING;
|
|
122
|
-
case "unpaid":
|
|
123
|
-
return SubscriptionStatus.UNPAID;
|
|
124
|
-
default: {
|
|
125
|
-
console.error(`Invalid stripe status: ${String(status)}`);
|
|
126
|
-
throw new Error(`Invalid stripe status: ${String(status)}`);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
103
|
+
switch (status) {
|
|
104
|
+
case "active": return "ACTIVE";
|
|
105
|
+
case "canceled": return "CANCELED";
|
|
106
|
+
case "incomplete": return "INCOMPLETE";
|
|
107
|
+
case "incomplete_expired": return "INCOMPLETE_EXPIRED";
|
|
108
|
+
case "past_due": return "PAST_DUE";
|
|
109
|
+
case "paused": return "PAUSED";
|
|
110
|
+
case "trialing": return "TRIALING";
|
|
111
|
+
case "unpaid": return "UNPAID";
|
|
112
|
+
default:
|
|
113
|
+
console.error(`Invalid stripe status: ${String(status)}`);
|
|
114
|
+
throw new Error(`Invalid stripe status: ${String(status)}`);
|
|
115
|
+
}
|
|
129
116
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
117
|
+
const ZERO_DECIMAL_CURRENCIES = [
|
|
118
|
+
"BIF",
|
|
119
|
+
"CLP",
|
|
120
|
+
"DJF",
|
|
121
|
+
"GNF",
|
|
122
|
+
"JPY",
|
|
123
|
+
"KMF",
|
|
124
|
+
"KRW",
|
|
125
|
+
"MGA",
|
|
126
|
+
"PYG",
|
|
127
|
+
"RWF",
|
|
128
|
+
"UGX",
|
|
129
|
+
"VND",
|
|
130
|
+
"VUV",
|
|
131
|
+
"XAF",
|
|
132
|
+
"XOF",
|
|
133
|
+
"XPF"
|
|
147
134
|
];
|
|
148
135
|
function minorUnits(currency) {
|
|
149
|
-
|
|
136
|
+
return ZERO_DECIMAL_CURRENCIES.includes(currency.toUpperCase()) ? 1 : 100;
|
|
150
137
|
}
|
|
151
138
|
function price(value, currency) {
|
|
152
|
-
|
|
139
|
+
return value / minorUnits(currency);
|
|
153
140
|
}
|
|
154
141
|
function getPurchaseProperties(session) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
142
|
+
let value;
|
|
143
|
+
let currency;
|
|
144
|
+
if (!session.amount_total || !session.currency) {
|
|
145
|
+
value = session.line_items?.reduce((acc, item) => acc + (item.amount_total ?? 0), 0) ?? 0;
|
|
146
|
+
currency = session.line_items?.[0]?.currency ?? "usd";
|
|
147
|
+
} else {
|
|
148
|
+
value = session.amount_total;
|
|
149
|
+
currency = session.currency;
|
|
150
|
+
}
|
|
151
|
+
return {
|
|
152
|
+
transaction_id: session.id,
|
|
153
|
+
value: price(value, currency),
|
|
154
|
+
currency: currency.toUpperCase(),
|
|
155
|
+
coupon: session.coupon,
|
|
156
|
+
items: session.line_items?.map((item, index) => ({
|
|
157
|
+
index,
|
|
158
|
+
item_id: item.id,
|
|
159
|
+
item_name: item.description ?? "",
|
|
160
|
+
price: price(item.amount_total, item.currency),
|
|
161
|
+
quantity: item.quantity ?? 1,
|
|
162
|
+
discount: price(item.amount_discount, item.currency)
|
|
163
|
+
}))
|
|
164
|
+
};
|
|
178
165
|
}
|
|
179
166
|
function getBeginCheckoutProperties(p) {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
]
|
|
190
|
-
};
|
|
167
|
+
return {
|
|
168
|
+
currency: p.currency.toUpperCase(),
|
|
169
|
+
value: price(p.unit_amount, p.currency),
|
|
170
|
+
items: [{
|
|
171
|
+
item_id: p.product.id,
|
|
172
|
+
item_name: p.product.name,
|
|
173
|
+
price: price(p.unit_amount, p.currency)
|
|
174
|
+
}]
|
|
175
|
+
};
|
|
191
176
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
getPurchaseProperties,
|
|
196
|
-
mapCharge,
|
|
197
|
-
mapCheckoutSession,
|
|
198
|
-
mapInvoice,
|
|
199
|
-
mapLineItem,
|
|
200
|
-
mapPaymentIntent,
|
|
201
|
-
mapPrice,
|
|
202
|
-
mapSubscriptionStatus,
|
|
203
|
-
mapTime,
|
|
204
|
-
minorUnits,
|
|
205
|
-
price
|
|
206
|
-
};
|
|
177
|
+
//#endregion
|
|
178
|
+
export { ZERO_DECIMAL_CURRENCIES, getBeginCheckoutProperties, getPurchaseProperties, mapCharge, mapCheckoutSession, mapInvoice, mapLineItem, mapPaymentIntent, mapPrice, mapSubscriptionStatus, mapTime, minorUnits, price };
|
|
179
|
+
|
|
207
180
|
//# sourceMappingURL=mapper.mjs.map
|
|
@@ -1 +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 type Price = {\n id: string;\n type: Stripe.Price.Type;\n active: boolean;\n billing_scheme: Stripe.Price.BillingScheme;\n currency: Stripe.Price['currency'];\n unit_amount: number | null;\n unit_amount_decimal: string | null;\n recurring: Stripe.Price.Recurring | null;\n};\n\nexport function mapPrice(price: Stripe.Price): Price {\n return {\n id: price.id,\n type: price.type,\n active: price.active,\n billing_scheme: price.billing_scheme,\n currency: price.currency,\n unit_amount: price.unit_amount,\n unit_amount_decimal: price.unit_amount_decimal?.toString() ?? null,\n recurring: price.recurring,\n };\n}\n\nexport function mapLineItem(item: Stripe.LineItem) {\n return {\n id: item.price\n ? typeof item.price.product === 'string'\n ? item.price.product\n : item.price.product.id\n : 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 ? mapPrice(item.price) : null,\n };\n}\n\nexport type PaymentStatus = 'no_payment_required' | 'paid' | 'unpaid';\n\nexport function mapCheckoutSession(session: Stripe.Checkout.Session) {\n let coupon: string | undefined = undefined;\n if (Array.isArray(session.discounts) && session.discounts.length !== 0) {\n const discount = session.discounts[0];\n if (discount.coupon && typeof discount.coupon === 'object') {\n coupon = discount.coupon.id;\n } else if (typeof discount.coupon === 'string') {\n coupon = discount.coupon;\n } else {\n coupon = undefined;\n }\n }\n\n // The variable annotation makes the emitted .d.ts reference the local\n // PaymentStatus alias instead of stripe's internal module path (TS2883)\n const payment_status: PaymentStatus = session.payment_status;\n\n return {\n id: session.id,\n url: session.url,\n coupon,\n livemode: session.livemode,\n expires_at: session.expires_at,\n payment_status,\n currency: session.currency,\n amount_total: session.amount_total,\n line_items: session.line_items?.data.map(mapLineItem),\n };\n}\n\nexport function mapInvoice(i: Stripe.Invoice) {\n return {\n id: i.id,\n number: i.number,\n total: i.total,\n subtotal: i.subtotal,\n amount_due: i.amount_due,\n amount_paid: i.amount_paid,\n amount_remaining: i.amount_remaining,\n currency: i.currency,\n billing_reason: i.billing_reason,\n hosted_invoice_url: i.hosted_invoice_url,\n invoice_pdf: i.invoice_pdf,\n receipt_number: i.receipt_number,\n status: i.status,\n created: i.created,\n period_start: i.period_start,\n period_end: i.period_end,\n };\n}\n\nexport function mapPaymentIntent(intent: Stripe.PaymentIntent) {\n return {\n id: intent.id,\n amount: intent.amount,\n amount_capturable: intent.amount_capturable,\n amount_received: intent.amount_received,\n currency: intent.currency,\n client_secret: intent.client_secret,\n description: intent.description,\n status: intent.status,\n created: intent.created,\n };\n}\n\nexport function mapCharge(charge: Stripe.Charge) {\n return {\n id: charge.id,\n description: charge.description,\n currency: charge.currency,\n amount: charge.amount,\n amount_captured: charge.amount_captured,\n amount_refunded: charge.amount_refunded,\n receipt_email: charge.receipt_email,\n receipt_number: charge.receipt_number,\n receipt_url: charge.receipt_url,\n status: charge.status,\n created: charge.created,\n payment_intent:\n charge.payment_intent && typeof charge.payment_intent === 'object'\n ? mapPaymentIntent(charge.payment_intent)\n : undefined,\n };\n}\n\nexport type CheckoutSession = ReturnType<typeof mapCheckoutSession>;\nexport type ProductPrice = {\n id: string;\n type: Stripe.Price.Type;\n unit_amount: number;\n currency: Stripe.Price['currency'];\n product: {\n id: Stripe.Product['id'];\n name: Stripe.Product['name'];\n description: Stripe.Product['description'];\n livemode: Stripe.Product['livemode'];\n };\n};\n\nexport function mapSubscriptionStatus(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: ${String(status)}`);\n throw new Error(`Invalid stripe status: ${String(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\nexport interface Item {\n item_id: string;\n item_name: string;\n affiliation?: 'Google Store' | (string & {});\n coupon?: string;\n discount?: number;\n index?: number;\n item_brand?: string;\n item_category?: string;\n item_category2?: string;\n item_category3?: string;\n item_category4?: string;\n item_category5?: string;\n item_list_id?: string;\n item_list_name?: string;\n item_variant?: string;\n location_id?: string;\n price?: number;\n quantity?: number;\n}\n\nexport interface PurchaseProperties {\n currency: string;\n value: number;\n transaction_id: string;\n coupon?: string;\n shipping?: number;\n tax?: number;\n items?: Item[];\n}\n\nexport interface BeginCheckoutProperties {\n currency: string;\n value: number;\n coupon?: string;\n items: Item[];\n}\n\nexport function getPurchaseProperties(session: CheckoutSession): PurchaseProperties {\n let value: number;\n let currency: string;\n if (!session.amount_total || !session.currency) {\n value = session.line_items?.reduce((acc, item) => acc + (item.amount_total ?? 0), 0) ?? 0;\n currency = session.line_items?.[0]?.currency ?? 'usd';\n } else {\n value = session.amount_total;\n currency = session.currency;\n }\n\n return {\n transaction_id: session.id,\n value: price(value, currency),\n currency: currency.toUpperCase(),\n coupon: session.coupon,\n items: session.line_items?.map((item, index) => ({\n index,\n item_id: item.id,\n item_name: item.description ?? '',\n price: price(item.amount_total, item.currency),\n quantity: item.quantity ?? 1,\n discount: price(item.amount_discount, item.currency),\n })),\n };\n}\n\nexport function getBeginCheckoutProperties(p: ProductPrice): BeginCheckoutProperties {\n return {\n currency: p.currency.toUpperCase(),\n value: price(p.unit_amount, p.currency),\n items: [\n {\n item_id: p.product.id,\n item_name: p.product.name,\n price: price(p.unit_amount, p.currency),\n },\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;AAaO,SAAS,SAASA,QAA4B;AACnD,SAAO;AAAA,IACL,IAAIA,OAAM;AAAA,IACV,MAAMA,OAAM;AAAA,IACZ,QAAQA,OAAM;AAAA,IACd,gBAAgBA,OAAM;AAAA,IACtB,UAAUA,OAAM;AAAA,IAChB,aAAaA,OAAM;AAAA,IACnB,qBAAqBA,OAAM,qBAAqB,SAAS,KAAK;AAAA,IAC9D,WAAWA,OAAM;AAAA,EACnB;AACF;AAEO,SAAS,YAAY,MAAuB;AACjD,SAAO;AAAA,IACL,IAAI,KAAK,QACL,OAAO,KAAK,MAAM,YAAY,WAC5B,KAAK,MAAM,UACX,KAAK,MAAM,QAAQ,KACrB,KAAK;AAAA,IACT,UAAU,KAAK;AAAA,IACf,UAAU,KAAK;AAAA,IACf,aAAa,KAAK;AAAA,IAClB,YAAY,KAAK;AAAA,IACjB,cAAc,KAAK;AAAA,IACnB,iBAAiB,KAAK;AAAA,IACtB,iBAAiB,KAAK;AAAA,IACtB,OAAO,KAAK,QAAQ,SAAS,KAAK,KAAK,IAAI;AAAA,EAC7C;AACF;AAIO,SAAS,mBAAmB,SAAkC;AACnE,MAAI,SAA6B;AACjC,MAAI,MAAM,QAAQ,QAAQ,SAAS,KAAK,QAAQ,UAAU,WAAW,GAA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AACrD,SAAO,QAAQ,WAAW,QAAQ;AACpC;AAwCO,SAAS,sBAAsB,SAA8C;AAClF,MAAI;AACJ,MAAI;AACJ,MAAI,CAAC,QAAQ,gBAAgB,CAAC,QAAQ,UAAU;AAC9C,YAAQ,QAAQ,YAAY,OAAO,CAAC,KAAK,SAAS,OAAO,KAAK,gBAAgB,IAAI,CAAC,KAAK;AACxF,eAAW,QAAQ,aAAa,CAAC,GAAG,YAAY;AAAA,EAClD,OAAO;AACL,YAAQ,QAAQ;AAChB,eAAW,QAAQ;AAAA,EACrB;AAEA,SAAO;AAAA,IACL,gBAAgB,QAAQ;AAAA,IACxB,OAAO,MAAM,OAAO,QAAQ;AAAA,IAC5B,UAAU,SAAS,YAAY;AAAA,IAC/B,QAAQ,QAAQ;AAAA,IAChB,OAAO,QAAQ,YAAY,IAAI,CAAC,MAAM,WAAW;AAAA,MAC/C;AAAA,MACA,SAAS,KAAK;AAAA,MACd,WAAW,KAAK,eAAe;AAAA,MAC/B,OAAO,MAAM,KAAK,cAAc,KAAK,QAAQ;AAAA,MAC7C,UAAU,KAAK,YAAY;AAAA,MAC3B,UAAU,MAAM,KAAK,iBAAiB,KAAK,QAAQ;AAAA,IACrD,EAAE;AAAA,EACJ;AACF;AAEO,SAAS,2BAA2B,GAA0C;AACnF,SAAO;AAAA,IACL,UAAU,EAAE,SAAS,YAAY;AAAA,IACjC,OAAO,MAAM,EAAE,aAAa,EAAE,QAAQ;AAAA,IACtC,OAAO;AAAA,MACL;AAAA,QACE,SAAS,EAAE,QAAQ;AAAA,QACnB,WAAW,EAAE,QAAQ;AAAA,QACrB,OAAO,MAAM,EAAE,aAAa,EAAE,QAAQ;AAAA,MACxC;AAAA,IACF;AAAA,EACF;AACF;","names":["price"]}
|
|
1
|
+
{"version":3,"file":"mapper.mjs","names":[],"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 type Price = {\n id: string;\n type: Stripe.Price.Type;\n active: boolean;\n billing_scheme: Stripe.Price.BillingScheme;\n currency: Stripe.Price['currency'];\n unit_amount: number | null;\n unit_amount_decimal: string | null;\n recurring: Stripe.Price.Recurring | null;\n};\n\nexport function mapPrice(price: Stripe.Price): Price {\n return {\n id: price.id,\n type: price.type,\n active: price.active,\n billing_scheme: price.billing_scheme,\n currency: price.currency,\n unit_amount: price.unit_amount,\n unit_amount_decimal: price.unit_amount_decimal?.toString() ?? null,\n recurring: price.recurring,\n };\n}\n\nexport function mapLineItem(item: Stripe.LineItem) {\n return {\n id: item.price\n ? typeof item.price.product === 'string'\n ? item.price.product\n : item.price.product.id\n : 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 ? mapPrice(item.price) : null,\n };\n}\n\nexport type PaymentStatus = 'no_payment_required' | 'paid' | 'unpaid';\n\nexport function mapCheckoutSession(session: Stripe.Checkout.Session) {\n let coupon: string | undefined = undefined;\n if (Array.isArray(session.discounts) && session.discounts.length !== 0) {\n const discount = session.discounts[0];\n if (discount.coupon && typeof discount.coupon === 'object') {\n coupon = discount.coupon.id;\n } else if (typeof discount.coupon === 'string') {\n coupon = discount.coupon;\n } else {\n coupon = undefined;\n }\n }\n\n // The variable annotation makes the emitted .d.ts reference the local\n // PaymentStatus alias instead of stripe's internal module path (TS2883)\n const payment_status: PaymentStatus = session.payment_status;\n\n return {\n id: session.id,\n url: session.url,\n coupon,\n livemode: session.livemode,\n expires_at: session.expires_at,\n payment_status,\n currency: session.currency,\n amount_total: session.amount_total,\n line_items: session.line_items?.data.map(mapLineItem),\n };\n}\n\nexport function mapInvoice(i: Stripe.Invoice) {\n return {\n id: i.id,\n number: i.number,\n total: i.total,\n subtotal: i.subtotal,\n amount_due: i.amount_due,\n amount_paid: i.amount_paid,\n amount_remaining: i.amount_remaining,\n currency: i.currency,\n billing_reason: i.billing_reason,\n hosted_invoice_url: i.hosted_invoice_url,\n invoice_pdf: i.invoice_pdf,\n receipt_number: i.receipt_number,\n status: i.status,\n created: i.created,\n period_start: i.period_start,\n period_end: i.period_end,\n };\n}\n\nexport function mapPaymentIntent(intent: Stripe.PaymentIntent) {\n return {\n id: intent.id,\n amount: intent.amount,\n amount_capturable: intent.amount_capturable,\n amount_received: intent.amount_received,\n currency: intent.currency,\n client_secret: intent.client_secret,\n description: intent.description,\n status: intent.status,\n created: intent.created,\n };\n}\n\nexport function mapCharge(charge: Stripe.Charge) {\n return {\n id: charge.id,\n description: charge.description,\n currency: charge.currency,\n amount: charge.amount,\n amount_captured: charge.amount_captured,\n amount_refunded: charge.amount_refunded,\n receipt_email: charge.receipt_email,\n receipt_number: charge.receipt_number,\n receipt_url: charge.receipt_url,\n status: charge.status,\n created: charge.created,\n payment_intent:\n charge.payment_intent && typeof charge.payment_intent === 'object'\n ? mapPaymentIntent(charge.payment_intent)\n : undefined,\n };\n}\n\nexport type CheckoutSession = ReturnType<typeof mapCheckoutSession>;\nexport type ProductPrice = {\n id: string;\n type: Stripe.Price.Type;\n unit_amount: number;\n currency: Stripe.Price['currency'];\n product: {\n id: Stripe.Product['id'];\n name: Stripe.Product['name'];\n description: Stripe.Product['description'];\n livemode: Stripe.Product['livemode'];\n };\n};\n\nexport function mapSubscriptionStatus(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: ${String(status)}`);\n throw new Error(`Invalid stripe status: ${String(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\nexport interface Item {\n item_id: string;\n item_name: string;\n affiliation?: 'Google Store' | (string & {});\n coupon?: string;\n discount?: number;\n index?: number;\n item_brand?: string;\n item_category?: string;\n item_category2?: string;\n item_category3?: string;\n item_category4?: string;\n item_category5?: string;\n item_list_id?: string;\n item_list_name?: string;\n item_variant?: string;\n location_id?: string;\n price?: number;\n quantity?: number;\n}\n\nexport interface PurchaseProperties {\n currency: string;\n value: number;\n transaction_id: string;\n coupon?: string;\n shipping?: number;\n tax?: number;\n items?: Item[];\n}\n\nexport interface BeginCheckoutProperties {\n currency: string;\n value: number;\n coupon?: string;\n items: Item[];\n}\n\nexport function getPurchaseProperties(session: CheckoutSession): PurchaseProperties {\n let value: number;\n let currency: string;\n if (!session.amount_total || !session.currency) {\n value = session.line_items?.reduce((acc, item) => acc + (item.amount_total ?? 0), 0) ?? 0;\n currency = session.line_items?.[0]?.currency ?? 'usd';\n } else {\n value = session.amount_total;\n currency = session.currency;\n }\n\n return {\n transaction_id: session.id,\n value: price(value, currency),\n currency: currency.toUpperCase(),\n coupon: session.coupon,\n items: session.line_items?.map((item, index) => ({\n index,\n item_id: item.id,\n item_name: item.description ?? '',\n price: price(item.amount_total, item.currency),\n quantity: item.quantity ?? 1,\n discount: price(item.amount_discount, item.currency),\n })),\n };\n}\n\nexport function getBeginCheckoutProperties(p: ProductPrice): BeginCheckoutProperties {\n return {\n currency: p.currency.toUpperCase(),\n value: price(p.unit_amount, p.currency),\n items: [\n {\n item_id: p.product.id,\n item_name: p.product.name,\n price: price(p.unit_amount, p.currency),\n },\n ],\n };\n}\n"],"mappings":";;AAGA,SAAgB,QACd,wBACkC;CAClC,IAAI,CAAC,wBAAwB,OAAO;CACpC,wBAAO,IAAI,KAAK,yBAAyB,GAAI,EAAA,CAAE,YAAY;AAC7D;AAaA,SAAgB,SAAS,OAA4B;CACnD,OAAO;EACL,IAAI,MAAM;EACV,MAAM,MAAM;EACZ,QAAQ,MAAM;EACd,gBAAgB,MAAM;EACtB,UAAU,MAAM;EAChB,aAAa,MAAM;EACnB,qBAAqB,MAAM,qBAAqB,SAAS,KAAK;EAC9D,WAAW,MAAM;CACnB;AACF;AAEA,SAAgB,YAAY,MAAuB;CACjD,OAAO;EACL,IAAI,KAAK,QACL,OAAO,KAAK,MAAM,YAAY,WAC5B,KAAK,MAAM,UACX,KAAK,MAAM,QAAQ,KACrB,KAAK;EACT,UAAU,KAAK;EACf,UAAU,KAAK;EACf,aAAa,KAAK;EAClB,YAAY,KAAK;EACjB,cAAc,KAAK;EACnB,iBAAiB,KAAK;EACtB,iBAAiB,KAAK;EACtB,OAAO,KAAK,QAAQ,SAAS,KAAK,KAAK,IAAI;CAC7C;AACF;AAIA,SAAgB,mBAAmB,SAAkC;CACnE,IAAI,SAA6B,KAAA;CACjC,IAAI,MAAM,QAAQ,QAAQ,SAAS,KAAK,QAAQ,UAAU,WAAW,GAAG;EACtE,MAAM,WAAW,QAAQ,UAAU;EACnC,IAAI,SAAS,UAAU,OAAO,SAAS,WAAW,UAChD,SAAS,SAAS,OAAO;OACpB,IAAI,OAAO,SAAS,WAAW,UACpC,SAAS,SAAS;OAElB,SAAS,KAAA;CAEb;CAIA,MAAM,iBAAgC,QAAQ;CAE9C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AAQ;GACnB,WAAW,EAAE,QAAQ;GACrB,OAAO,MAAM,EAAE,aAAa,EAAE,QAAQ;EACxC,CACF;CACF;AACF"}
|
package/dist/stripe/metadata.cjs
CHANGED
|
@@ -1,38 +1,14 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/stripe/metadata.ts
|
|
3
|
+
const METADATA_KEYS = {
|
|
4
|
+
USER_ID: "user_id",
|
|
5
|
+
USER_ACCOUNT_TOKEN: "user_account_token",
|
|
6
|
+
PRODUCT_ID: "product_id",
|
|
7
|
+
REFERRAL_CODE: "referral_code",
|
|
8
|
+
CREDIT_AMOUNT: "credit_amount",
|
|
9
|
+
CREDIT_EXPIRES_IN: "credit_expires_in"
|
|
9
10
|
};
|
|
10
|
-
|
|
11
|
-
|
|
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);
|
|
11
|
+
//#endregion
|
|
12
|
+
exports.METADATA_KEYS = METADATA_KEYS;
|
|
19
13
|
|
|
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
|
-
USER_ACCOUNT_TOKEN: "user_account_token",
|
|
29
|
-
PRODUCT_ID: "product_id",
|
|
30
|
-
REFERRAL_CODE: "referral_code",
|
|
31
|
-
CREDIT_AMOUNT: "credit_amount",
|
|
32
|
-
CREDIT_EXPIRES_IN: "credit_expires_in"
|
|
33
|
-
};
|
|
34
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
-
0 && (module.exports = {
|
|
36
|
-
METADATA_KEYS
|
|
37
|
-
});
|
|
38
14
|
//# sourceMappingURL=metadata.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/stripe/metadata.ts"],"sourcesContent":["export const METADATA_KEYS = {\n USER_ID: 'user_id',\n USER_ACCOUNT_TOKEN: 'user_account_token',\n PRODUCT_ID: 'product_id',\n REFERRAL_CODE: 'referral_code',\n CREDIT_AMOUNT: 'credit_amount',\n CREDIT_EXPIRES_IN: 'credit_expires_in',\n} as const;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"metadata.cjs","names":[],"sources":["../../src/stripe/metadata.ts"],"sourcesContent":["export const METADATA_KEYS = {\n USER_ID: 'user_id',\n USER_ACCOUNT_TOKEN: 'user_account_token',\n PRODUCT_ID: 'product_id',\n REFERRAL_CODE: 'referral_code',\n CREDIT_AMOUNT: 'credit_amount',\n CREDIT_EXPIRES_IN: 'credit_expires_in',\n} as const;\n"],"mappings":";;AAAA,MAAa,gBAAgB;CAC3B,SAAS;CACT,oBAAoB;CACpB,YAAY;CACZ,eAAe;CACf,eAAe;CACf,mBAAmB;AACrB"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
//#region src/stripe/metadata.d.ts
|
|
1
2
|
declare const METADATA_KEYS: {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
readonly USER_ID: 'user_id';
|
|
4
|
+
readonly USER_ACCOUNT_TOKEN: 'user_account_token';
|
|
5
|
+
readonly PRODUCT_ID: 'product_id';
|
|
6
|
+
readonly REFERRAL_CODE: 'referral_code';
|
|
7
|
+
readonly CREDIT_AMOUNT: 'credit_amount';
|
|
8
|
+
readonly CREDIT_EXPIRES_IN: 'credit_expires_in';
|
|
8
9
|
};
|
|
9
|
-
|
|
10
|
+
//#endregion
|
|
10
11
|
export { METADATA_KEYS };
|
|
12
|
+
//# sourceMappingURL=metadata.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.d.cts","names":[],"sources":["../../src/stripe/metadata.ts"],"mappings":";cAAa;WACX;WACA;WACA;WACA;WACA;WACA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/stripe/metadata.d.ts
|
|
2
|
+
declare const METADATA_KEYS: {
|
|
3
|
+
readonly USER_ID: 'user_id';
|
|
4
|
+
readonly USER_ACCOUNT_TOKEN: 'user_account_token';
|
|
5
|
+
readonly PRODUCT_ID: 'product_id';
|
|
6
|
+
readonly REFERRAL_CODE: 'referral_code';
|
|
7
|
+
readonly CREDIT_AMOUNT: 'credit_amount';
|
|
8
|
+
readonly CREDIT_EXPIRES_IN: 'credit_expires_in';
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { METADATA_KEYS };
|
|
12
|
+
//# sourceMappingURL=metadata.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.d.mts","names":[],"sources":["../../src/stripe/metadata.ts"],"mappings":";cAAa;WACX;WACA;WACA;WACA;WACA;WACA"}
|
package/dist/stripe/metadata.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
export {
|
|
11
|
-
METADATA_KEYS
|
|
1
|
+
//#region src/stripe/metadata.ts
|
|
2
|
+
const METADATA_KEYS = {
|
|
3
|
+
USER_ID: "user_id",
|
|
4
|
+
USER_ACCOUNT_TOKEN: "user_account_token",
|
|
5
|
+
PRODUCT_ID: "product_id",
|
|
6
|
+
REFERRAL_CODE: "referral_code",
|
|
7
|
+
CREDIT_AMOUNT: "credit_amount",
|
|
8
|
+
CREDIT_EXPIRES_IN: "credit_expires_in"
|
|
12
9
|
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { METADATA_KEYS };
|
|
12
|
+
|
|
13
13
|
//# sourceMappingURL=metadata.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/stripe/metadata.ts"],"sourcesContent":["export const METADATA_KEYS = {\n USER_ID: 'user_id',\n USER_ACCOUNT_TOKEN: 'user_account_token',\n PRODUCT_ID: 'product_id',\n REFERRAL_CODE: 'referral_code',\n CREDIT_AMOUNT: 'credit_amount',\n CREDIT_EXPIRES_IN: 'credit_expires_in',\n} as const;\n"],"mappings":";
|
|
1
|
+
{"version":3,"file":"metadata.mjs","names":[],"sources":["../../src/stripe/metadata.ts"],"sourcesContent":["export const METADATA_KEYS = {\n USER_ID: 'user_id',\n USER_ACCOUNT_TOKEN: 'user_account_token',\n PRODUCT_ID: 'product_id',\n REFERRAL_CODE: 'referral_code',\n CREDIT_AMOUNT: 'credit_amount',\n CREDIT_EXPIRES_IN: 'credit_expires_in',\n} as const;\n"],"mappings":";AAAA,MAAa,gBAAgB;CAC3B,SAAS;CACT,oBAAoB;CACpB,YAAY;CACZ,eAAe;CACf,eAAe;CACf,mBAAmB;AACrB"}
|